Package org.gatein.wci.impl

Examples of org.gatein.wci.impl.DefaultServletContainer$RegistrationImpl


{

   @Test
   public void testContextRegistrationLifeCycle()
   {
      ServletContainer container = new DefaultServletContainer();
      ServletContainerContextImpl scc = new ServletContainerContextImpl();

      //
      container.register(scc);

      // Assert we got registration
      assertNotNull(scc.registration);

      // Keep a ref on registration
View Full Code Here


   }

   @Test
   public void testConcurrentContextRegistrations()
   {
      ServletContainer container = new DefaultServletContainer();
      ServletContainerContextImpl scc1 = new ServletContainerContextImpl();
      ServletContainerContextImpl scc2 = new ServletContainerContextImpl();

      // We register
      container.register(scc1);

      // Registration was done
      assertNotNull(scc1.registration);

      // Try register
      container.register(scc2);

      // Registration failed
      assertNull(scc2.registration);

      // Cancel
      scc1.registration.cancel();

      // Try register again
      container.register(scc2);

      // Registration should have worked now
      assertNotNull(scc2.registration);
   }
View Full Code Here

   }

   @Test
   public void testContextRegistrationCancellationUnregistersWebApps()
   {
      ServletContainer container = new DefaultServletContainer();
      ServletContainerContextImpl scc = new ServletContainerContextImpl();
      WebAppRegistry registry = new WebAppRegistry();

      //
      container.register(scc);

      //
      container.addWebAppListener(registry);

      //
      scc.registration.registerWebApp(new WebAppContextImpl("/foo"));
      scc.registration.registerWebApp(new WebAppContextImpl("/bar"));
      assertEquals(Tools.toSet("/foo", "/bar"), registry.getKeys());
View Full Code Here

   }

   @Test
   public void testListenerDoubleRegistration()
   {
      ServletContainer container = new DefaultServletContainer();
      ServletContainerContextImpl scc = new ServletContainerContextImpl();
      WebAppRegistry registry = new WebAppRegistry();

      //
      container.addWebAppListener(registry);
      container.addWebAppListener(registry);

      //
      container.register(scc);
      scc.registration.registerWebApp(new WebAppContextImpl("/foo"));
      assertEquals(Tools.toSet("/foo"), registry.getKeys());

      //
      container.addWebAppListener(registry);
      assertEquals(Tools.toSet("/foo"), registry.getKeys());

      //
      container.removeWebAppListener(registry);
      assertEquals(Tools.toSet(), registry.getKeys());

      //
      container.removeWebAppListener(registry);
      assertEquals(Tools.toSet(), registry.getKeys());
   }
View Full Code Here

   }

   @Test
   public void testListenerIsNotified()
   {
      ServletContainer container = new DefaultServletContainer();
      ServletContainerContextImpl scc = new ServletContainerContextImpl();
      WebAppRegistry registry = new WebAppRegistry();

      //
      container.register(scc);

      // Add 2 web apps
      scc.registration.registerWebApp(new WebAppContextImpl("/foo"));
      scc.registration.registerWebApp(new WebAppContextImpl("/bar"));

      // Add listener
      container.addWebAppListener(registry);

      // Assert we received events during the registration
      assertEquals(Tools.toSet("/foo", "/bar"), registry.getKeys());

      // Add a new web app
      scc.registration.registerWebApp(new WebAppContextImpl("/juu"));

      // Assert we now have 3 web apps
      assertEquals(Tools.toSet("/foo", "/bar", "/juu"), registry.getKeys());

      // Remove one web app
      scc.registration.unregisterWebApp("/foo");

      // Assert we have 2 web apps
      assertEquals(Tools.toSet("/bar", "/juu"), registry.getKeys());

      // Remove registration
      container.removeWebAppListener(registry);

      // Assert we receveived events during removal
      assertEquals(Tools.toSet(), registry.getKeys());

      // W Add a new web app
View Full Code Here

   }

   @Test
   public void testServletContainerThrowsIAE()
   {
      ServletContainer container = new DefaultServletContainer();
      try
      {
         container.register(null);
         fail("Was expecting an IAE");
      }
      catch (IllegalArgumentException ignore)
      {
      }
      try
      {
         container.addWebAppListener(null);
         fail("Was expecting an IAE");
      }
      catch (IllegalArgumentException ignore)
      {
      }
      try
      {
         container.removeWebAppListener(null);
         fail("Was expecting an IAE");
      }
      catch (IllegalArgumentException ignore)
      {
      }
View Full Code Here

   }

   @Test
   public void testServletContainerThrowsISE() throws Exception
   {
      ServletContainer container = new DefaultServletContainer();
      try
      {
         container.include(null, null, null, null, null);
         fail("Was expecting an ISE");
      }
      catch (IllegalStateException ignore)
      {
      }
View Full Code Here

   }

   @Test
   public void testListenerFailure()
   {
      ServletContainer container = new DefaultServletContainer();
      ServletContainerContextImpl scc = new ServletContainerContextImpl();
      WebAppRegistry registry = new WebAppRegistry();

      //
      final SynchronizedBoolean called = new SynchronizedBoolean(false);
      container.register(scc);
      container.addWebAppListener(registry);
      container.addWebAppListener(new WebAppListener()
      {
         public void onEvent(WebAppEvent event)
         {
            called.set(true);
            throw new RuntimeException("Expected Exception: don't freak out");
View Full Code Here

   }
  
   @Test
   public void testListenerError()
   {
     ServletContainer container = new DefaultServletContainer();
     ServletContainerContextImpl scc = new ServletContainerContextImpl();
     WebAppRegistry registry = new WebAppRegistry();

     //
     final SynchronizedBoolean called = new SynchronizedBoolean(false);
     container.register(scc);
     container.addWebAppListener(registry);
     container.addWebAppListener(new WebAppListener()
     {
       public void onEvent(WebAppEvent event)
       {
         called.set(true);
         throw new Error("Expected Error: don't freak out");
View Full Code Here

TOP

Related Classes of org.gatein.wci.impl.DefaultServletContainer$RegistrationImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.