Package org.gatein.wci

Examples of org.gatein.wci.WebAppRegistry


   @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");
       }
     });

     //
     try
     {
       scc.registration.registerWebApp(new WebAppContextImpl("/foo"));
       fail("Was expecting an error to be thrown");
     }
     catch (Throwable t)
     {  
     }
     assertTrue(called.get());
     assertEquals(Tools.toSet("/foo"), registry.getKeys());
   }
View Full Code Here


         {
            return new FailureResponse(Failure.createAssertionFailure("No servlet container present"));
         }

         // Register and save the deployed web apps
         registry = new WebAppRegistry();
         container.addWebAppListener(registry);
         keys = new HashSet<String>(registry.getKeys());

         // Deploy the application web app
         return new DeployResponse("test-spi-app.war");
View Full Code Here

           {
              return new FailureResponse(Failure.createAssertionFailure("No servlet container present"));
           }

           // Register and save the deployed web apps
           registry = new WebAppRegistry();
           container.addWebAppListener(registry);
           keys = new HashSet<String>(registry.getKeys());

           // Deploy the application web app
           return new DeployResponse("test-spi-app.war");
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());

      //
      scc.registration.cancel();
      assertEquals(Tools.toSet(), 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
      scc.registration.registerWebApp(new WebAppContextImpl("/foo"));

      // hen unregistered, a new web app registration does not send event
      assertEquals(Tools.toSet(), registry.getKeys());
   }
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");
         }
      });

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

         {
            return new FailureResponse(Failure.createAssertionFailure("No servlet container present"));
         }

         // Register and save the deployed web apps
         registry = new WebAppRegistry();
         container.addWebAppListener(registry);
         keys = new HashSet<String>(registry.getKeys());
        
         // Deploy the web app with init param of gatein.wci.native.DisableRegistration set to true
         return new DeployResponse("test-native-skip-app.war");
View Full Code Here

         {
            return new FailureResponse(Failure.createAssertionFailure("No servlet container present"));
         }

         // Register and save the deployed web apps
         registry = new WebAppRegistry();
         container.addWebAppListener(registry);
         keys = new HashSet<String>(registry.getKeys());

         // Deploy the application web app
         return new DeployResponse("test-spi-app.war");
View Full Code Here

TOP

Related Classes of org.gatein.wci.WebAppRegistry

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.