/** @throws Exception */
  @Test
  public void shouldAccessStaticResource() throws Exception {
    server
        .withWebAppAt(WebAppBuilder.buildFrom(new BarResource("bar-value")), "/api/*")
        .withStaticResourcesAt("/static", "/*")
        .start();

    shouldRetrieveResourceWithValue("/api/bar", "bar-value");
    shouldRetrieveResourceWithValue("/index.html", "<html>\nfoo\n</html>");
  }
  /** Start the service, i.e, start receiving events and running rules. */
  @Override
  public void start() {
    log.info("this is {} with pid {}", this, vminfo.getPID());
    log.debug("starting subsystems");
    sources.start();

    try {
      httpServer.start();
    } catch (final Exception e) {
      log.warn("starting http server", e);
    }
  }
  /** @see gr.ntua.vision.monitoring.service.Service#halt() */
  @Override
  public void halt() {
    log.debug("halting subsystems");
    timer.cancel();
    sources.halt();
    engine.halt();

    try {
      httpServer.stop();
    } catch (final Exception e) {
      log.warn("stopping http server", e);
    }
  }
  /** @throws Exception */
  @Test
  public void shouldAccessJerseyResources() throws Exception {
    server
        .withWebAppAt(
            WebAppBuilder.buildFrom(new FooResource("foo-value"), new BarResource("bar-value")),
            "/*")
        .start();

    shouldRetrieveResourceWithValue("/foo/0", "foo-value");
    shouldRetrieveResourceWithValue("/bar", "bar-value");

    assertEquals(
        ClientResponse.Status.NO_CONTENT,
        root()
            .path("/foo/other-foo")
            .accept(MediaType.TEXT_PLAIN)
            .put(ClientResponse.class)
            .getClientResponseStatus());

    shouldRetrieveResourceWithValue("/foo/1", "other-foo");
  }
 /** @throws Exception */
 @After
 public void tearDown() throws Exception {
   if (server != null) server.stop();
 }