Package org.gatein.pc.test.unit.web

Examples of org.gatein.pc.test.unit.web.AbstractUniversalTestPortlet


      seq.bindAction(0, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
         {

            AbstractUniversalTestPortlet aport = (AbstractUniversalTestPortlet)portlet;

            try
            {
               aport.getPortletContext().getAttribute(null);
               fail();
            }
            catch (IllegalArgumentException e)
            {
               //expected
            }

            try
            {
               aport.getPortletContext().setAttribute(null, null);
               fail();
            }
            catch (IllegalArgumentException e)
            {
               //expected
            }

            try
            {
               aport.getPortletContext().removeAttribute(null);
               fail();
            }
            catch (IllegalArgumentException e)
            {
               //expected
View Full Code Here


   {
      seq.bindAction(0, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
         {
            AbstractUniversalTestPortlet aport = (AbstractUniversalTestPortlet)portlet;
            //we get resource and pass it to servlet
            URL url = aport.getPortletContext().getResource("/simple_resource.txt");
            assertNotNull(url);
            aport.getPortletContext().setAttribute("resource", url);

            //and we construct resource content and pass to servlet
            InputStream is = aport.getPortletContext().getResourceAsStream("/simple_resource.txt");
            assertNotNull(is);
            byte[] byteArray = new byte[is.available()];
            is.read(byteArray);
            aport.getPortletContext().setAttribute("content", byteArray);

            //then we dispatch to servlet
            PortletRequestDispatcher dispatcher = aport.getPortletContext().getNamedDispatcher("UniversalServletA");
            assertNotNull(dispatcher);

            dispatcher.include(request, response);
            Object o = (Boolean)UTP1.local.get();
            //assert out assertion was correct in Servlet
View Full Code Here

   {
      seq.bindAction(0, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
         {
            AbstractUniversalTestPortlet aport = (AbstractUniversalTestPortlet)portlet;
            PortletConfig config = aport.getPortletConfig();

            assertNotNull(config);

            PortletContext portletContext = config.getPortletContext();
View Full Code Here

   {
      seq.bindAction(0, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
         {
            AbstractUniversalTestPortlet aport = (AbstractUniversalTestPortlet)portlet;

            //wrong url format
            try
            {
               aport.getPortletContext().getResource("simple_resource.txt");
               fail();
            }
            catch (MalformedURLException e)
            {
               //expected
            }

            //not existing resource
            try
            {
               assertNull(aport.getPortletContext().getResource("/NotExist.txt"));
            }
            catch (MalformedURLException e)
            {
               //something wrong?
               fail();
View Full Code Here

   {
      seq.bindAction(0, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
         {
            AbstractUniversalTestPortlet aport = (AbstractUniversalTestPortlet)portlet;
            // Just test we can retrieve any value without an error
            aport.getPortletContext().getMinorVersion();
            aport.getPortletContext().getMajorVersion();
            return new EndTestResponse();
         }
      });
   }
View Full Code Here

   {
      seq.bindAction(0, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
         {
            AbstractUniversalTestPortlet aport = (AbstractUniversalTestPortlet)portlet;
            String info = aport.getPortletContext().getServerInfo();
            boolean matches = VERSION_PATTERN.matcher(info).matches();
            assertTrue("Version " + info + " does not match the format", matches);
            return new EndTestResponse();
         }
      });
View Full Code Here

      seq.bindAction(0, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
         {

            AbstractUniversalTestPortlet aport = (AbstractUniversalTestPortlet)portlet;

            assertNull(aport.getPortletContext().getInitParameter("NotExistingParamName"));

            try
            {
               aport.getPortletContext().getInitParameter(null);
               fail();
            }
            catch (IllegalArgumentException e)
            {
               //expected
View Full Code Here

      seq.bindAction(0, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
         {

            AbstractUniversalTestPortlet aport = (AbstractUniversalTestPortlet)portlet;

            assertEquals("PortletContext WebApp", aport.getPortletContext().getPortletContextName());
            return new EndTestResponse();
         }
      });
   }
View Full Code Here

   {
      seq.bindAction(0, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
         {
            AbstractUniversalTestPortlet aport = (AbstractUniversalTestPortlet)portlet;

            //when dispatcher is not obtained it should return null
            //assertNull(aport.getPortletContext().getRequestDispatcher("/notExistingDispatcher.jsp"));
            assertNull(aport.getPortletContext().getNamedDispatcher("NotExistingDispatcher"));

            return new EndTestResponse();
         }
      });
   }
View Full Code Here

TOP

Related Classes of org.gatein.pc.test.unit.web.AbstractUniversalTestPortlet

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.