Package org.gatein.pc.test.unit.protocol.response

Examples of org.gatein.pc.test.unit.protocol.response.FailureResponse


               //
               return new EndTestResponse();
            }
            default:
               return new FailureResponse(Failure.createAssertionFailure(""));
         }
      }
      finally
      {
         this.context = null;
View Full Code Here


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

      //
      Response 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));
            }
         }
      }

      //
View Full Code Here

               super.render(req, resp);
               response = postRender(req, resp, context);
            }
            catch (AssertionError e)
            {
               response = new FailureResponse(Failure.createFailure(e));
            }

            //
            if (response != null)
            {
View Full Code Here

      }

      //
      if (nextCommandContext == null)
      {
         return new FailureResponse(Failure.createErrorFailure("Response " + response + " was not handled"));
      }
      else
      {
         commandContext = nextCommandContext;
      }
View Full Code Here

            }
         }
      }
      else
      {
         return commandContext.createResponseContext(new FailureResponse(Failure.createErrorFailure("Unexpected command")));
      }
   }
View Full Code Here

      {
         case 200:
            // HTTP response is ok
            if (response == null)
            {
               response = new FailureResponse(Failure.createErrorFailure("No result for test " + testName + " in the response"));
            }

            //
            log.info("# Received '200' code");
            break;
         case 302:
            // Send redirect
            if (response == null)
            {
               // Satisfy the 302 code
               Header locationHeader = httpMethod.getResponseHeader("location");
               if (locationHeader != null)
               {
                  String redirectLocation = locationHeader.getValue();
                  log.info("# Received '302' code --> " + redirectLocation);
                  DoGetRequest cmd = new DoGetRequest(new URI(redirectLocation));

                  // We should somehow stuff the response in the next payload
                  // but it's not yet proven it's usefull

                  // For now we don't add any contextual payload as
                  // 302 is some kind of implicit redirect response
                  return invoke(new ClientRequestContext(commandContext.getResponseContext(), cmd));
               }
               else
               {
                  // The response is invalid
                  response = new FailureResponse(Failure.createErrorFailure("302 Code with corrupted data"));
               }
            }
            else
            {
               // If any result has been setup during the action it overrides the 302 code
               log.info("# Received Result object which overrides the 302");
            }
            break;
         case 500:
            log.info("# Received '500' code");
            response = new FailureResponse(Failure.createErrorFailure("Received '500' code at " + httpMethod.getURI()));
            break;
         case 404:
            log.info("# Received '404' code");
            response = new FailureResponse(Failure.createErrorFailure("Received '404' code at " + httpMethod.getURI()));
            break;
         default:
            response = new FailureResponse(Failure.createErrorFailure("Unexpected http code " + status + " at " + httpMethod.getURI()));
            break;
      }

      //
      ClientResponseContext responseCtx = commandContext.createResponseContext(response);
View Full Code Here

      seq.bindAction(1, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
         {
            return new FailureResponse(Failure.createAssertionFailure("Render wasn't expected"));
         }
      });
   }
View Full Code Here

               // Refresh
               return new InvokeGetResponse(url);
            }
            catch (InterruptedException e)
            {
               return new FailureResponse(Failure.createFailure(e));
            }
         }
      });

      //
      seq.bindAction(3, UTP10.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
         {
            // Should be called
            calls.add("3");

            // Invoke the same but with different render parameter
            PortletURL tmp = response.createRenderURL();
            tmp.setParameter("abc", "def");
            url = tmp.toString();
            return new InvokeGetResponse(url);
         }
      });

      //
      seq.bindAction(4, UTP10.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
         {
            // Should be called
            calls.add("4");

            // Refresh
            return new InvokeGetResponse(url);
         }
      });

      //
      seq.bindAction(5, UTP10.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
         {
            // Should not be called
            calls.add("5");
            return null;
         }
      });
      seq.bindAction(5, UTP11.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
         {
            // Refresh
            return new InvokeGetResponse(url);
         }
      });

      //
      seq.bindAction(6, UTP10.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
         {
            // Could be called depending on whether the portal
            // decides to invoke UTP2 or UTP3 first
            // so if it's called we need to disable cache otherwise the next
            // render will probably not be called
            response.setProperty(RenderResponse.EXPIRATION_CACHE, "0");
            return null;
         }
      });
      seq.bindAction(6, UTP11.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
         {
            try
            {
               assertFalse(calls.contains("5"));

               // Wait 5 seconds for the cache entry to be invalid
               Thread.sleep(5 * 1000);

               // Refresh
               return new InvokeGetResponse(url);
            }
            catch (InterruptedException e)
            {
               return new FailureResponse(Failure.createFailure(e));
            }
         }
      });

      //
View Full Code Here

               // Refresh
               return new InvokeGetResponse(url);
            }
            catch (InterruptedException e)
            {
               return new FailureResponse(Failure.createFailure(e));
            }
         }
      });

      //
      seq.bindAction(5, p1renderjp, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
         {
            assertEquals("xyz", request.getETag());
            assertTrue(Tools.toSet(request.getPropertyNames()).contains(RenderRequest.ETAG));
            assertEquals("xyz", request.getProperty(RenderRequest.ETAG));

            // Record we were called
            calls.add("5");

            // Revalidate existing content
            response.setProperty(RenderResponse.EXPIRATION_CACHE, "5");
            response.setProperty(RenderResponse.USE_CACHED_CONTENT, "foo");

            //
            url = response.createRenderURL().toString();
            return new InvokeGetResponse(url);
         }
      });

      //
      seq.bindAction(6, p1renderjp, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
         {
            // Should not be called
            calls.add("6");
            return null;
         }
      });
      seq.bindAction(6, p2renderjp, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
         {
            // Refresh
            return new InvokeGetResponse(url);
         }
      });

      //
      seq.bindAction(7, p1renderjp, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
         {
            // Could be called or not depending on the page rendering ordre
            return null;
         }
      });
      seq.bindAction(7, p2renderjp, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context) throws IOException, PortletException
         {
            try
            {
               // Wait 5 seconds for the cache entry to be invalid
               Thread.sleep(5 * 1000);

               // Refresh
               return new InvokeGetResponse(url);
            }
            catch (InterruptedException e)
            {
               return new FailureResponse(Failure.createFailure(e));
            }
         }
      });

      //
View Full Code Here

      seq.bindAction(1, UTP1.RENDER_JOIN_POINT, new PortletRenderTestAction()
      {
         protected Response run(Portlet portlet, RenderRequest request, RenderResponse response, PortletTestContext context)
         {
            //We shouldn't be here
            return new FailureResponse(Failure.createAssertionFailure("Render wasn't expected to be invoked"));
         }
      });
   }
View Full Code Here

TOP

Related Classes of org.gatein.pc.test.unit.protocol.response.FailureResponse

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.