Package org.gatein.pc.test.unit.actions

Examples of org.gatein.pc.test.unit.actions.PortletRenderTestAction


public class IncludeFromRenderObjects
{
  
   public IncludeFromRenderObjects(final PortletTestCase seq)
   {
      seq.bindAction(0, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
         {
            // Invoke render with header
            InvokeGetResponse render = new InvokeGetResponse(response.createRenderURL().toString());
            render.addHeader("myheader", "render-value");

            return render;
         }
      });

      seq.bindAction(1, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
         {
            //we dispatch to servlet and assertions will be done there
            String queryString = "?key1=k1value1&key2=k2value1";
View Full Code Here


   })
public class ContentType
{
   public ContentType(PortletTestCase seq)
   {
      seq.bindAction(0, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
         {
            String responseContentType = request.getResponseContentType();
            response.setContentType(responseContentType);
View Full Code Here

   private final byte[] byteContent = {65, 66, 67, 68, 69, 70};

   public ActionRequestUseReader(PortletTestCase seq)
   {
      seq.bindAction(0, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
         {
            PortletURL url = response.createActionURL();
            url.setParameter("g_foo1", "g_bar1_1");
            url.setParameter("g_foo2", new String[]{"g_bar2_1", "g_bar2_2"});
            InvokePostResponse iur = new InvokePostResponse(url.toString());
            Body.Raw body = new Body.Raw();
            body.setBytes(byteContent);
            iur.setBody(body);
            iur.setContentType(InvokePostResponse.MULTIPART_FORM_DATA);
            return iur;
         }
      });

      seq.bindAction(1, UTP1.ACTION_JOIN_POINT, new PortletActionTestAction()
      {
         protected void run(Portlet portlet, ActionRequest request, ActionResponse response, PortletTestContext context) throws IOException
         {
            assertEquals(new String[]{"g_bar1_1"}, request.getParameterValues("g_foo1"));
            assertEquals(new String[]{"g_bar2_1", "g_bar2_2"}, request.getParameterValues("g_foo2"));
            assertEquals(InvokePostResponse.MULTIPART_FORM_DATA, request.getContentType());
            assertEquals(byteContent.length, request.getContentLength());
            Reader in = null;
            try
            {
               in = request.getReader();
               StringWriter out = new StringWriter();
               IOTools.copy(in, out);
               out.close();
               byte[] bytes = out.toString().getBytes("UTF-8");
               assertEquals(-1, in.read());
               assertEquals(byteContent, bytes);
            }
            catch (IllegalStateException e)
            {
               fail("Was not expecting an ISE");
            }
            catch (IOException e)
            {
               fail("Was not expecting an IOException");
            }
            finally
            {
               IOTools.safeClose(in);
            }
            try
            {
               request.getPortletInputStream();
               fail("The inputstream should not be available");
            }
            catch (IllegalStateException expected)
            {
            }
         }
      });

      seq.bindAction(1, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
         {
            return new EndTestResponse();
         }
View Full Code Here

@TestCase({Assertion.JSR286_50})
public class ListenedURLUpdate
{
   public ListenedURLUpdate(PortletTestCase seq)
   {
      seq.bindAction(0, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
         {
            URLGenerationListener1.delegate = updater1;
            URLGenerationListener2.delegate = updater2;

            //
            PortletURL actionURL = response.createActionURL();

            //
            String s = actionURL.toString();

            //
            assertEquals(null, actionURL.getPortletMode());
            assertEquals(null, actionURL.getWindowState());
            assertEquals(0, actionURL.getParameterMap().size());

            //
            return new InvokeGetResponse(s);
         }
      });
      seq.bindAction(1, UTP1.ACTION_JOIN_POINT, new PortletActionTestAction()
      {
         protected void run(Portlet portlet, ActionRequest request, ActionResponse response, PortletTestContext context) throws PortletException, IOException
         {
            assertParameterMap(Collections.singletonMap("foo", new String[]{"fooAction"}), request);
            assertEquals(PortletMode.EDIT, request.getPortletMode());
            assertEquals(WindowState.MAXIMIZED, request.getWindowState());
         }
      });
      seq.bindAction(1, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
         {
            PortletURL renderURL = response.createRenderURL();

            //
            String s = renderURL.toString();

            //
            assertEquals(null, renderURL.getPortletMode());
            assertEquals(null, renderURL.getWindowState());
            assertEquals(0, renderURL.getParameterMap().size());

            //
            return new InvokeGetResponse(s);
         }
      });
      seq.bindAction(2, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
         {
            assertParameterMap(Collections.singletonMap("foo", new String[]{"fooRender"}), request);
            assertEquals(PortletMode.VIEW, request.getPortletMode());
View Full Code Here

   })
public class RequestAttributeScoping
{
   public RequestAttributeScoping(PortletTestCase seq)
   {
      seq.bindAction(0, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
         {
            assertNull(request.getAttribute("foo"));
            request.setAttribute("foo", "foo");
View Full Code Here

   })
public class ResourceBundleWithEmptyTitle
{
   public ResourceBundleWithEmptyTitle(PortletTestCase seq)
   {
      seq.bindAction(0, ResourceBundlePortlet.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
         {
            PortletConfig cfg = ((AbstractUniversalTestPortlet)portlet).getPortletConfig();
            ResourceBundle bundle = cfg.getResourceBundle(Locale.ENGLISH);
View Full Code Here

   private final byte[] byteContent = {65, 66, 67, 68, 69, 70};

   public ActionRequestUseInputStream(PortletTestCase seq)
   {
      seq.bindAction(0, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {

         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
         {
            PortletURL url = response.createActionURL();
            url.setParameter("g_foo1", "g_bar1_1");
            url.setParameter("g_foo2", new String[]{"g_bar2_1", "g_bar2_2"});
            InvokePostResponse iur = new InvokePostResponse(url.toString());
            Body.Raw body = new Body.Raw();
            body.setBytes(byteContent);
            iur.setBody(body);
            iur.setContentType(InvokePostResponse.MULTIPART_FORM_DATA);
            return iur;
         }
      });

      seq.bindAction(1, UTP1.ACTION_JOIN_POINT, new PortletActionTestAction()
      {

         protected void run(Portlet portlet, ActionRequest request, ActionResponse response, PortletTestContext context) throws IOException
         {

            assertEquals(new String[]{"g_bar1_1"}, request.getParameterValues("g_foo1"));
            assertEquals(new String[]{"g_bar2_1", "g_bar2_2"}, request.getParameterValues("g_foo2"));
            assertEquals(InvokePostResponse.MULTIPART_FORM_DATA, request.getContentType());
            assertEquals(byteContent.length, request.getContentLength());
            InputStream in = null;
            try
            {
               in = request.getPortletInputStream();
               ByteArrayOutputStream out = new ByteArrayOutputStream();
               IOTools.copy(in, out);
               out.close();
               byte[] bytes = out.toByteArray();
               assertEquals(-1, in.read());
               assertEquals(byteContent, bytes);
            }
            catch (IllegalStateException e)
            {
               fail("Was not expecting an ISE");
            }
            catch (IOException e)
            {
               fail("Was not expecting an IOException");
            }
            finally
            {
               IOTools.safeClose(in);
            }
            try
            {
               request.getReader();
               fail("The reader should not be available");
            }
            catch (IllegalStateException expected)
            {
            }
         }
      });

      seq.bindAction(1, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
         {
            return new EndTestResponse();
         }
View Full Code Here

   })
public class GetResourceBundleDuringInit
{
   public GetResourceBundleDuringInit(PortletTestCase seq)
   {
      seq.bindAction(0, GetResourceBundleDuringInitPortlet.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
         {
            ResourceBundle bundle = GetResourceBundleDuringInitPortlet.bundle;
            assertNotNull(bundle);
View Full Code Here

   })
public class InlineBundleWithEmptyTitle
{
   public InlineBundleWithEmptyTitle(PortletTestCase seq)
   {
      seq.bindAction(0, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws PortletException, IOException
         {
            PortletConfig config = ((AbstractUniversalTestPortlet)portlet).getPortletConfig();
            assertNotNull(config);
View Full Code Here

   })
public class RequestAttribute
{
   public RequestAttribute(PortletTestCase seq)
   {
      seq.bindAction(0, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
         {
            // Take a snapshot of the attribute names
            Set snapshot = Tools.toSet(request.getAttributeNames());
View Full Code Here

TOP

Related Classes of org.gatein.pc.test.unit.actions.PortletRenderTestAction

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.