public void testCanInstantiateWebContainerContextAndServletInstance()
      throws InterruptedException, IOException {

    server = new PicoJettyServer("localhost", 8080, new EmptyPicoContainer());
    PicoContextHandler barContext = server.createContext("/bar", false);

    DependencyInjectionTestServlet servlet0 = new DependencyInjectionTestServlet("Fred");
    DependencyInjectionTestServlet servlet1 =
        (DependencyInjectionTestServlet) barContext.addServletWithMapping(servlet0, "/foo");
    servlet1.setFoo("bar");

    server.start();

    Thread.sleep(2 * 1000);

    URL url = new URL("http://localhost:8080/bar/foo");
    assertEquals("hello Fred bar", IO.toString(url.openStream()));
  }
  public void testCanInstantiateWebContainerContextAndServlet()
      throws InterruptedException, IOException {

    final DefaultPicoContainer parentContainer = new DefaultPicoContainer();
    parentContainer.registerComponentInstance(String.class, "Fred");

    server = new PicoJettyServer("localhost", 8080, parentContainer);
    PicoContextHandler barContext = server.createContext("/bar", false);
    Class servletClass = DependencyInjectionTestServlet.class;
    PicoServletHolder holder = barContext.addServletWithMapping(servletClass, "/foo");
    holder.setInitParameter("foo", "bar");

    server.start();

    Thread.sleep(2 * 1000);

    URL url = new URL("http://localhost:8080/bar/foo");
    assertEquals("hello Fred bar", IO.toString(url.openStream()));
  }
 protected void tearDown() throws Exception {
   if (server != null) {
     server.stop();
   }
   Thread.sleep(1 * 1000);
 }