Examples of PortletTestContext


Examples of org.gatein.pc.test.unit.PortletTestContext

    * @throws PortletSecurityException
    * @throws IOException
    */
   public final void processAction(ActionRequest req, ActionResponse resp) throws PortletException, IOException
   {
      PortletTestContext ctx = PortletTestDriver.getPortletTestContext();

      //
      log.debug("JoinPoint '" + actionJoinPoint + "' invoked for '"
         + ctx.getTestName() + "' testId and '" +
         +ctx.getRequestCount() + "' request count");

      //
      PortletTestCase portletTestCase = getSequence(ctx.getTestName());

      //
      if (portletTestCase != null)
      {
         //
         TestAction action = portletTestCase.getAction(ctx.getRequestCount(), NodeId.locate(), actionJoinPoint);

         //
         DriverResponse response;
         if (action instanceof PortletTestAction)
         {
            log.debug("Found action for jointpoint " + actionJoinPoint + " : " + action);

            //
            response = ((PortletTestAction)action).execute(this, req, resp, ctx);
         }
         else if (action instanceof PortletActionTestAction)
         {
            log.debug("Found action for jointpoint " + actionJoinPoint + " : " + action);

            //
            response = ((PortletActionTestAction)action).execute(this, req, resp, ctx);
         }
         else
         {
            response = new FailureResponse(Failure.createAssertionFailure("Action for " + ctx.getRequestCount() +
               " " + NodeId.locate() + " " + actionJoinPoint + " does not have the right type but has the type " +
               action.getClass().getName()));
         }

         //
         if (response != null)
         {
            ctx.updateResponse(response);
         }
      }
   }
View Full Code Here

Examples of org.gatein.pc.test.unit.PortletTestContext

      }
   }

   public void processEvent(EventRequest req, EventResponse resp) throws PortletException, IOException
   {
      PortletTestContext ctx = PortletTestDriver.getPortletTestContext();

      //
      if (ctx.getResponse() == null)
      {
         log.debug("JoinPoint '" + eventJoinPoint + "' invoked for '"
            + ctx.getTestName() + "' testId and '" +
            +ctx.getRequestCount() + "' request count");

         //
         PortletTestCase portletTestCase = getSequence(ctx.getTestName());

         //
         if (portletTestCase != null)
         {
            //
            TestAction action = portletTestCase.getAction(ctx.getRequestCount(), NodeId.locate(), eventJoinPoint);

            //
            if (action != null)
            {
               DriverResponse response = null;
               if (action instanceof PortletTestAction)
               {
                  log.debug("Found action for jointpoint " + eventJoinPoint + " : " + action);

                  //
                  response = ((PortletTestAction)action).execute(this, req, resp, ctx);
               }
               else if (action instanceof PortletEventTestAction)
               {
                  log.debug("Found action for jointpoint " + eventJoinPoint + " : " + action);

                  //
                  response = ((PortletEventTestAction)action).execute(this, req, resp, ctx);
               }
               else if (action == null)
               {
                  response = new FailureResponse(Failure.createAssertionFailure("Action for " + ctx.getRequestCount() +
                     " " + NodeId.locate() + " " + actionJoinPoint + " is null"));
               }
               else
               {
                  response = new FailureResponse(Failure.createAssertionFailure("Action for " + ctx.getRequestCount() +
                     " " + NodeId.locate() + " " + actionJoinPoint + " does not have the right type but has the type " +
                     action.getClass().getName()));
               }

               //
               if (response != null)
               {
                  ctx.updateResponse(response);
               }
            }
         }
      }
   }
View Full Code Here

Examples of org.gatein.pc.test.unit.PortletTestContext

    * @throws PortletSecurityException
    * @throws IOException
    */
   public final void render(RenderRequest req, RenderResponse resp) throws PortletException, IOException
   {
      PortletTestContext ctx = PortletTestDriver.getPortletTestContext();

      //
      log.debug("JoinPoint '" + renderJoinPoint +  " invoked for '"
         + ctx.getTestName() + "' testId and '" +
         +ctx.getRequestCount() + "' request count");

      // Reset AssertResult at begining of test
      if (ctx.getRequestCount() == 0)
      {
         reset();
      }

      // Get the action
      TestAction action = null;
      PortletTestCase portletTestCase = getSequence(ctx.getTestName());
      if (portletTestCase != null)
      {
         action = portletTestCase.getAction(ctx.getRequestCount(), NodeId.locate(), renderJoinPoint);
      }

      //
      if (action != null)
      {
         // Get the result
         DriverResponse response;
         if (action instanceof PortletTestAction)
         {
            log.debug("Found action for joinpoint " + renderJoinPoint + " : " + action);

            //
            response = ((PortletTestAction)action).execute(this, req, resp, ctx);
         }
         else if (action instanceof PortletRenderTestAction)
         {
            log.debug("Found action for joinpoint " + renderJoinPoint + " : " + action);

            //
            response = ((PortletRenderTestAction)action).execute(this, req, resp, ctx);
         }
         else if (action == null)
         {
            response = new FailureResponse(Failure.createAssertionFailure("Action for " + ctx.getRequestCount() +
            " " + NodeId.locate() + " " + resourceJoinPoint + " is null"));
         }
         else
         {
            response = new FailureResponse(Failure.createAssertionFailure("Action for " + ctx.getRequestCount() +
            " " + NodeId.locate() + " " + resourceJoinPoint + " does not have the right type but has the type " +
            action.getClass().getName()));
         }

         // If we have one result it is meant to be returned to the client
         if (response != null)
         {
            ctx.updateResponse(response);
         }
      }
      else
      {
         // As we are not involved we don't want content to be cached that would prevent
View Full Code Here

Examples of org.gatein.pc.test.unit.PortletTestContext

      }
   }

   public void serveResource(ResourceRequest req, ResourceResponse resp) throws PortletException, IOException
   {
      PortletTestContext ctx = PortletTestDriver.getPortletTestContext();

      //
      log.debug("JoinPoint '" + resourceJoinPoint +  " invoked for '"
         + ctx.getTestName() + "' testId and '" +
         +ctx.getRequestCount() + "' request count");

      // Get the action
      TestAction action = null;
      PortletTestCase portletTestCase = getSequence(ctx.getTestName());
      if (portletTestCase != null)
      {
         action = portletTestCase.getAction(ctx.getRequestCount(), NodeId.locate(), resourceJoinPoint);

      }

      //
      DriverResponse response;
      if (action instanceof PortletTestAction)
      {
         log.debug("Found action for joinpoint " + resourceJoinPoint + " : " + action);

         // Get the result that must exist since it is the only joinpoint invoked during this request
         response = ((PortletTestAction)action).execute(this, req, resp, ctx);
      }
      else if (action instanceof PortletResourceTestAction)
      {
         log.debug("Found action for joinpoint " + resourceJoinPoint + " : " + action);

         // Get the result that must exist since it is the only joinpoint invoked during this request
         response = ((PortletResourceTestAction)action).execute(this, req, resp, ctx);
      }
      else if (action == null)
      {
         response = new FailureResponse(Failure.createAssertionFailure("Action for " + ctx.getRequestCount() +
            " " + NodeId.locate() + " " + resourceJoinPoint + " is null"));
      }
      else
      {
         response = new FailureResponse(Failure.createAssertionFailure("Action for " + ctx.getRequestCount() +
            " " + NodeId.locate() + " " + resourceJoinPoint + " does not have the right type but has the type " +
            action.getClass().getName()));
      }

      //
      if (response != null)
      {
         ctx.updateResponse(response);
      }
   }
View Full Code Here

Examples of org.gatein.pc.test.unit.PortletTestContext

   /** Joinpoint for action phase. */
   private final JoinPoint actionJoinPoint = JoinPoint.createJoinPoint(getClass(), JoinPointType.PORTLET_ACTION);

   public void processAction(ActionRequest req, ActionResponse resp) throws PortletException, IOException
   {
      PortletTestContext context = PortletTestDriver.getPortletTestContext();

      //
      String actorId = context.getActorId(JoinPointType.PORTLET_ACTION);

      //
      DriverResponse response = new FailureResponse(Failure.createErrorFailure(""));

      //
      if (actorId != null)
      {
         JoinPoint tmp = new JoinPoint(actorId, JoinPointType.PORTLET_ACTION);

         //
         if (tmp.equals(actionJoinPoint))
         {
            try
            {
               response = doProcessAction(req, resp, context);
            }
            catch (AssertionError e)
            {
               response = new FailureResponse(Failure.createFailure(e));
            }
         }
      }

      //
      context.updateResponse(response);
   }
View Full Code Here

Examples of org.gatein.pc.test.unit.PortletTestContext

      context.updateResponse(response);
   }

   public void render(RenderRequest req, RenderResponse resp) throws PortletException, IOException
   {
      PortletTestContext context = PortletTestDriver.getPortletTestContext();

      //
      String actorId = context.getActorId(JoinPointType.PORTLET_RENDER);

      //
      if (actorId != null)
      {
         JoinPoint tmp = new JoinPoint(actorId, JoinPointType.PORTLET_RENDER);

         //
         if (tmp.equals(renderJoinPoint))
         {
            DriverResponse response;
            try
            {
               preRender(req, resp, context);
               super.render(req, resp);
               response = postRender(req, resp, context);
            }
            catch (AssertionError e)
            {
               response = new FailureResponse(Failure.createFailure(e));
            }

            //
            if (response != null)
            {
               context.updateResponse(response);
            }
         }
      }
   }
View Full Code Here

Examples of org.gatein.pc.test.unit.PortletTestContext

    * @throws ServletException
    * @throws IOException
    */
   protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
   {
      PortletTestContext ctx = PortletTestDriver.getPortletTestContext();

      //
      log.info("JoinPoint " + serviceJoinPoint + " invoked for '"
         + ctx.getTestName() + "' testId and '" +
         +ctx.getRequestCount() + "' request count");

      // Reset instance state
      if (ctx.getRequestCount() == 0)
      {
         reset();
      }

      PortletTestCase portletTestCase = getSequence(ctx.getTestName());
      if (portletTestCase != null)
      {
         TestAction action = portletTestCase.getAction(ctx.getRequestCount(), NodeId.locate(), getServiceJointpoint());
         if (action != null && action instanceof ServletServiceTestAction)
         {
            log.info("Found Action for this jointpoint");
            DriverResponse dr = ((ServletServiceTestAction)action).execute(this, request, response, ctx);
            if (dr != null)
            {
               ctx.updateResponse(dr);
            }
         }

      }
   }
View Full Code Here

Examples of org.gatein.pc.test.unit.PortletTestContext

    * @throws PortletSecurityException
    * @throws IOException
    */
   public final void processAction(ActionRequest req, ActionResponse resp) throws PortletException, IOException
   {
      PortletTestContext ctx = PortletTestDriver.getPortletTestContext();

      //
      log.debug("JoinPoint '" + actionJoinPoint + "' invoked for '"
         + ctx.getTestName() + "' testId and '" +
         +ctx.getRequestCount() + "' request count");

      //
      PortletTestCase portletTestCase = getSequence(ctx.getTestName());

      //
      if (portletTestCase != null)
      {
         //
         TestAction action = portletTestCase.getAction(ctx.getRequestCount(), NodeId.locate(), actionJoinPoint);

         //
         DriverResponse response;
         if (action instanceof PortletTestAction)
         {
            log.debug("Found action for jointpoint " + actionJoinPoint + " : " + action);

            //
            response = ((PortletTestAction)action).execute(this, req, resp, ctx);
         }
         else if (action instanceof PortletActionTestAction)
         {
            log.debug("Found action for jointpoint " + actionJoinPoint + " : " + action);

            //
            response = ((PortletActionTestAction)action).execute(this, req, resp, ctx);
         }
         else
         {
            response = new FailureResponse(Failure.createAssertionFailure("Action for " + ctx.getRequestCount() +
               " " + NodeId.locate() + " " + actionJoinPoint + " does not have the right type but has the type " +
               action.getClass().getName()));
         }

         //
         if (response != null)
         {
            ctx.updateResponse(response);
         }
      }
   }
View Full Code Here

Examples of org.gatein.pc.test.unit.PortletTestContext

      }
   }

   public void processEvent(EventRequest req, EventResponse resp) throws PortletException, IOException
   {
      PortletTestContext ctx = PortletTestDriver.getPortletTestContext();

      //
      if (ctx.getResponse() == null)
      {
         log.debug("JoinPoint '" + eventJoinPoint + "' invoked for '"
            + ctx.getTestName() + "' testId and '" +
            +ctx.getRequestCount() + "' request count");

         //
         PortletTestCase portletTestCase = getSequence(ctx.getTestName());

         //
         if (portletTestCase != null)
         {
            //
            TestAction action = portletTestCase.getAction(ctx.getRequestCount(), NodeId.locate(), eventJoinPoint);

            //
            if (action != null)
            {
               DriverResponse response = null;
               if (action instanceof PortletTestAction)
               {
                  log.debug("Found action for jointpoint " + eventJoinPoint + " : " + action);

                  //
                  response = ((PortletTestAction)action).execute(this, req, resp, ctx);
               }
               else if (action instanceof PortletEventTestAction)
               {
                  log.debug("Found action for jointpoint " + eventJoinPoint + " : " + action);

                  //
                  response = ((PortletEventTestAction)action).execute(this, req, resp, ctx);
               }
               else if (action == null)
               {
                  response = new FailureResponse(Failure.createAssertionFailure("Action for " + ctx.getRequestCount() +
                     " " + NodeId.locate() + " " + actionJoinPoint + " is null"));
               }
               else
               {
                  response = new FailureResponse(Failure.createAssertionFailure("Action for " + ctx.getRequestCount() +
                     " " + NodeId.locate() + " " + actionJoinPoint + " does not have the right type but has the type " +
                     action.getClass().getName()));
               }

               //
               if (response != null)
               {
                  ctx.updateResponse(response);
               }
            }
         }
      }
   }
View Full Code Here

Examples of org.gatein.pc.test.unit.PortletTestContext

    * @throws PortletSecurityException
    * @throws IOException
    */
   public final void render(RenderRequest req, RenderResponse resp) throws PortletException, IOException
   {
      PortletTestContext ctx = PortletTestDriver.getPortletTestContext();

      //
      log.debug("JoinPoint '" + renderJoinPoint +  " invoked for '"
         + ctx.getTestName() + "' testId and '" +
         +ctx.getRequestCount() + "' request count");

      // Reset AssertResult at begining of test
      if (ctx.getRequestCount() == 0)
      {
         reset();
      }

      // Get the action
      TestAction action = null;
      PortletTestCase portletTestCase = getSequence(ctx.getTestName());
      if (portletTestCase != null)
      {
         action = portletTestCase.getAction(ctx.getRequestCount(), NodeId.locate(), renderJoinPoint);
      }

      //
      if (action != null)
      {
         // Get the result
         DriverResponse response;
         if (action instanceof PortletTestAction)
         {
            log.debug("Found action for joinpoint " + renderJoinPoint + " : " + action);

            //
            response = ((PortletTestAction)action).execute(this, req, resp, ctx);
         }
         else if (action instanceof PortletRenderTestAction)
         {
            log.debug("Found action for joinpoint " + renderJoinPoint + " : " + action);

            //
            response = ((PortletRenderTestAction)action).execute(this, req, resp, ctx);
         }
         else if (action == null)
         {
            response = new FailureResponse(Failure.createAssertionFailure("Action for " + ctx.getRequestCount() +
            " " + NodeId.locate() + " " + resourceJoinPoint + " is null"));
         }
         else
         {
            response = new FailureResponse(Failure.createAssertionFailure("Action for " + ctx.getRequestCount() +
            " " + NodeId.locate() + " " + resourceJoinPoint + " does not have the right type but has the type " +
            action.getClass().getName()));
         }

         // If we have one result it is meant to be returned to the client
         if (response != null)
         {
            ctx.updateResponse(response);
         }
      }
      else
      {
         // As we are not involved we don't want content to be cached that would prevent
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.