Package play.mvc.Http

Examples of play.mvc.Http.Response


    public void deleteEventTest() {

      final Long originalCount = Event.count();
      final Event originalNextEvent = Event.find("order by date desc").first();
     
        Response response = DELETE("/event/" + originalNextEvent.id);
        assertStatus(302, response);
        assertHeaderEquals("Location", "/", response);
       
        assertEquals("There should be one less event", originalCount-1, Event.count());
       
View Full Code Here


     * @param url relative url such as <em>"/products/1234"</em>
     * @param followRedirect indicates if request have to follow redirection (status 302)
     * @return the response
     */
    public static Response GET(Object url, boolean followRedirect) {
        Response response = GET(url);
        if (Http.StatusCode.FOUND == response.status && followRedirect) {
            Http.Header redirectedTo = response.headers.get("Location");
            java.net.URL redirectedUrl = null;
            try {
                redirectedUrl = new java.net.URL(redirectedTo.value());
View Full Code Here

            throw new RuntimeException(ex);
        }
    }

    public static Response makeRequest(final Request request) {
        Response response = newResponse();
        makeRequest(request, response);

        if (response.status == 302) { // redirect
            // if Location-header is pressent, fix it to "look like" a functional-test-url
            Http.Header locationHeader = response.headers.get("Location");
View Full Code Here

        }
        return response;
    }

    public static Response newResponse() {
        Response response = new Response();
        response.out = new ByteArrayOutputStream();
        return response;
    }
View Full Code Here

            // Plain old HttpRequest
            try {
                final Request request = parseRequest(ctx, nettyRequest);

                final Response response = new Response();
                Http.Response.current.set(response);

                // Buffered in memory output
                response.out = new ByteArrayOutputStream();

                // Direct output (will be set later)
                response.direct = null;

                // Streamed output (using response.writeChunk)
                response.onWriteChunk(new Action<Object>() {

                    public void invoke(Object result) {
                        writeChunk(request, response, ctx, nettyRequest, result);
                    }
                });
View Full Code Here

        if (exposePlayServer) {
            nettyResponse.setHeader(SERVER, signature);
        }

        Request request = Request.current();
        Response response = Response.current();

        String encoding = response.encoding;

        try {
            if (!(e instanceof PlayException)) {
View Full Code Here

        }

        Logger.trace("ServletWrapper>service " + httpServletRequest.getRequestURI());
        Request request = null;
        try {
            Response response = new Response();
            response.out = new ByteArrayOutputStream();
            Response.current.set(response);
            request = parseRequest(httpServletRequest);
            Logger.trace("ServletWrapper>service, request: " + request);
            boolean raw = Play.pluginCollection.rawInvocation(request, response);
View Full Code Here

        new PlayBuilder().build();
    }

    private static void mockRequestAndResponse() {
        Request.current.set(new Request());
        Response.current.set(new Response());
    }
View Full Code Here

  }
    }

  private void assertValidTest(String remoteAddress, String xForwardedFor) {
    Request request = getRequest(remoteAddress, xForwardedFor);
    Response response = GET(request, PAGE_URL);
    assertIsOk(response);
   
    //remoteAddress should be changed to xForwardedFor address
    assertEquals(xForwardedFor, request.remoteAddress);
  }
View Full Code Here

  }

  private void assertInvalidTest(String remoteAddress, String xForwardedFor) {
    try {
      Request request = getRequest(remoteAddress, xForwardedFor);
      Response response = GET(request, PAGE_URL);
      fail("XForwarded request should have thrown a runtime exception.");
    } catch (RuntimeException re) {
      assertTrue(re.getMessage().contains(remoteAddress));
    }
  }
View Full Code Here

TOP

Related Classes of play.mvc.Http.Response

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.