Package org.gatein.wci.spi.callbacks

Examples of org.gatein.wci.spi.callbacks.NormalCallback


            fail("Cannot get access to the /test-spi-app servlet context");
         }

         //
         WebApp webApp = registry.getWebApp("/test-spi-app");
         NormalCallback cb1 = new NormalCallback(appContext, webApp.getClassLoader());
         Exception ex = new Exception();
         ExceptionCallback cb2 = new ExceptionCallback(appContext, ex, ex);
         Error err = new Error();
         ExceptionCallback cb3 = new ExceptionCallback(appContext, err, err);
         RuntimeException rex = new RuntimeException();
         ExceptionCallback cb4 = new ExceptionCallback(appContext, rex, rex);
         IOException ioe = new IOException();
         ExceptionCallback cb5 = new ExceptionCallback(appContext, ioe, ioe);

         //
         ServletContextDispatcher dispatcher = new ServletContextDispatcher(req, resp, container);
         DriverResponse 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);
View Full Code Here


            fail("Cannot get access to the /test-native-skip-with-gateinservlet-app context");
         }

         //
         WebApp webApp = registry.getWebApp("/test-native-skip-with-gateinservlet-app");
         NormalCallback cb1 = new NormalCallback(appContext, webApp.getClassLoader());
         Exception ex = new Exception();
         ExceptionCallback cb2 = new ExceptionCallback(appContext, ex, ex);
         Error err = new Error();
         ExceptionCallback cb3 = new ExceptionCallback(appContext, err, err);
         RuntimeException rex = new RuntimeException();
         ExceptionCallback cb4 = new ExceptionCallback(appContext, rex, rex);
         IOException ioe = new IOException();
         ExceptionCallback cb5 = new ExceptionCallback(appContext, ioe, ioe);

         //
         ServletContextDispatcher dispatcher = new ServletContextDispatcher(req, resp, container);
         DriverResponse 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);
View Full Code Here

         // Set some session state in another context
         ServletContext appContext = testServlet.getServletContext().getContext("/test-spi-app");
         ServletContextDispatcher dispatcher = new ServletContextDispatcher(req, resp, container);

         NormalCallback cb = new NormalCallback(appContext, registry.getWebApp("/test-spi-app").getClassLoader())
         {
            public Object doCallback(ServletContext dispatchedServletContext, HttpServletRequest dispatchedRequest, HttpServletResponse dispatchedResponse, Object handback) throws ServletException, IOException
            {
               dispatchedRequest.getSession().setAttribute(CROSS_CTX_TEST_ATTR, "2");
               rets.put(COUNT_KEY, "1");
               return super.doCallback(dispatchedServletContext, dispatchedRequest, dispatchedResponse, handback);
            }
         };

         DriverResponse response = cb.test(null, dispatcher);
         if (response != null)
            return response;

         // Check that the callback was invoked and the other context really was used with another session
         assertEquals("1", req.getSession().getAttribute(CROSS_CTX_TEST_ATTR));
         assertEquals("1", rets.get(COUNT_KEY));

         String url = resp.renderURL("/", null, null);
         return new InvokeGetResponse(url);
      }
      else if (getRequestCount() == 3)
      {
         // Check that the sessions retained values between requests
         // test-spi-server context
         assertEquals("1", req.getSession().getAttribute(CROSS_CTX_TEST_ATTR));

         // test-spi-app context

         // Map to get data from includes
         final Map<String, String> rets = new HashMap<String, String>();

         ServletContext appContext = testServlet.getServletContext().getContext("/test-spi-app");
         ServletContextDispatcher dispatcher = new ServletContextDispatcher(req, resp, container);

         NormalCallback cb = new NormalCallback(appContext, registry.getWebApp("/test-spi-app").getClassLoader())
         {
            public Object doCallback(ServletContext dispatchedServletContext, HttpServletRequest dispatchedRequest, HttpServletResponse dispatchedResponse, Object handback) throws ServletException, IOException
            {
               rets.put(CROSS_CTX_TEST_ATTR, (String) dispatchedRequest.getSession().getAttribute(CROSS_CTX_TEST_ATTR));
               rets.put(COUNT_KEY, "1");
               return super.doCallback(dispatchedServletContext, dispatchedRequest, dispatchedResponse, handback);
            }
         };

         DriverResponse response = cb.test(null, dispatcher);
         if (response != null)
            return response;

         // Check that the callback was invoked and the other context really was used with another session
         assertEquals("1", rets.get(COUNT_KEY));
         assertEquals("2", rets.get(CROSS_CTX_TEST_ATTR));


         // Perform logout

         if ("Tomcat/7.x".equals(container.getContainerInfo()) || "JBossas/6.x".equals(container.getContainerInfo()))
         {
            assertEquals("login", v.value);

            container.logout(req, resp);

            assertEquals("logout", v.value);
            assertNull(req.getUserPrincipal());
         }
         else
         {
            // Test logout
            assertNotNull(req.getSession(false));
            assertEquals("login", v.value);
            container.logout(req, resp);
            assertNull(req.getSession(false));

            // Test logout Event
            assertEquals("logout", v.value);
         }

         // Session state must be gone
         assertNull(req.getSession().getAttribute(CROSS_CTX_TEST_ATTR));

         // Get session state from the other context again
         cb = new NormalCallback(appContext, registry.getWebApp("/test-spi-app").getClassLoader())
         {
            public Object doCallback(ServletContext dispatchedServletContext, HttpServletRequest dispatchedRequest, HttpServletResponse dispatchedResponse, Object handback) throws ServletException, IOException
            {
               rets.put(COUNT_KEY, "2");
               rets.put(CROSS_CTX_TEST_ATTR, (String) dispatchedRequest.getSession().getAttribute("cross-ctx-test"));
               return super.doCallback(dispatchedServletContext, dispatchedRequest, dispatchedResponse, handback);
            }
         };

         response = cb.test(null, dispatcher);
         if (response != null)
            return response;

         // check that in the other context session state is deleted as well
         assertEquals("2", rets.get(COUNT_KEY));
View Full Code Here

TOP

Related Classes of org.gatein.wci.spi.callbacks.NormalCallback

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.