Examples of WebAppRegistry


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

Examples of org.gatein.wci.WebAppRegistry

         {
            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

Examples of org.gatein.wci.WebAppRegistry

           {
              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

Examples of org.gatein.wci.WebAppRegistry

   @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

Examples of org.gatein.wci.WebAppRegistry

   @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

Examples of org.gatein.wci.WebAppRegistry

   @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

Examples of org.gatein.wci.WebAppRegistry

   @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

Examples of org.gatein.wci.WebAppRegistry

         {
            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

Examples of org.gatein.wci.WebAppRegistry

         {
            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

Examples of org.gatein.wci.test.WebAppRegistry

   @Override
   protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
   {
      ServletContainer container = ServletContainerFactory.getServletContainer();
      WebAppRegistry registry = new WebAppRegistry();
      if (container.addWebAppListener(registry))
      {
         try
         {
            WebApp app = registry.getWebApp("/rdapp");
            if (app != null)
            {
               NormalCallback cb1 = new NormalCallback(app.getServletContext(), app.getClassLoader());
               Exception ex = new Exception();
               ExceptionCallback cb2 = new ExceptionCallback(app.getServletContext(), ex, ex);
               Error err = new Error();
               ExceptionCallback cb3 = new ExceptionCallback(app.getServletContext(), err, err);
               RuntimeException rex = new RuntimeException();
               ExceptionCallback cb4 = new ExceptionCallback(app.getServletContext(), rex, rex);
               IOException ioe = new IOException();
               ExceptionCallback cb5 = new ExceptionCallback(app.getServletContext(), ioe, ioe);

               //
               ServletContextDispatcher dispatcher = new ServletContextDispatcher(req, resp, container);
               Throwable response = cb1.test(null, dispatcher);
               response = cb2.test(response, dispatcher);
               response = cb3.test(response, dispatcher);
               response = cb4.test(response, dispatcher);
               response = cb5.test(response, dispatcher);

               //
               if (response != null)
               {
                  throw new ServletException(response);
               }
               else
               {
                  resp.setStatus(200);
               }
            }
            else
            {
               resp.sendError(500, "Could not find application among " + registry.getKeys());
            }
         }
         finally
         {
            container.removeWebAppListener(registry);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.