Package jodd.http

Examples of jodd.http.HttpResponse.statusCode()


  }

  @Test
  public void testRestAction2() {
    HttpResponse response = HttpRequest.get("localhost:8173/re/view2/g-321.html").send();
    assertEquals(302, response.statusCode());

    response = HttpRequest.get(response.header("location")).send();
    assertEquals("321", response.bodyText().trim());
  }
View Full Code Here


  }

  @Test
  public void testRestAction3_nomatch() {
    HttpResponse response = HttpRequest.get("localhost:8173/re/view3/1x2").send();
    assertEquals(404, response.statusCode());
  }

}
View Full Code Here

  // ---------------------------------------------------------------- raw

  @Test
  public void testRawResult() {
    HttpResponse httpResponse = HttpRequest.get("localhost:8173/madvocRawImage").send();
    assertEquals(200, httpResponse.statusCode());
    assertEquals("image/gif", httpResponse.contentType());
    byte[] bytes = httpResponse.bodyBytes();
    assertArrayEquals(RawResultAction.SMALLEST_GIF, bytes);
  }
View Full Code Here

  // ---------------------------------------------------------------- text

  @Test
  public void testEncoding() {
    HttpResponse httpResponse = HttpRequest.get("localhost:8173/madvocEncoding").send();
    assertEquals(200, httpResponse.statusCode());
    assertEquals("text/plain;charset=UTF-8", httpResponse.contentType());
    assertEquals("this text contents chinese chars 中文", httpResponse.bodyText());
  }

}
View Full Code Here

        .form("uploadFiles[1]", new byte[] {75, 77, 78})
        .form("uploadFileNames[0]", "a1")
        .form("uploadFileNames[1]", "a2")
        .send();

    assertEquals(302, response.statusCode());

    String location = response.header("location");

    response = HttpRequest.get(location).send();
View Full Code Here

  }

  @Test
  public void testHelloNoJspAction() {
    HttpResponse response = HttpRequest.get("localhost:8173/nohello.nojsp.html").send();
    assertEquals(404, response.statusCode());
    assertTrue(response.bodyText().contains("/nohello.nojsp.html"));
  }

  @Test
  public void testChain() {
View Full Code Here

  @Test
  public void testOneRedirectAction() {
    HttpResponse response = HttpRequest.get("localhost:8173/oneRedirect.html").send();
    assertEquals("", response.bodyText());
    assertEquals(302, response.statusCode());

    String redirectLocation = response.header("location");

    response = HttpRequest.get(redirectLocation).send();
    assertEquals("value = [333]", response.bodyText());
View Full Code Here

  @Test
  public void testOneMoveAction() {
    HttpResponse response = HttpRequest.get("localhost:8173/oneMove.html").send();
    assertEquals("", response.bodyText());
    assertEquals(302, response.statusCode());

    String redirectLocation = response.header("location");

    response = HttpRequest.get(redirectLocation).send();
    assertEquals("value = [777]", response.bodyText());
View Full Code Here

  @Test
  public void testOneMoveGoAction() {
    HttpResponse response = HttpRequest.get("localhost:8173/oneMove.go.html").send();
    assertEquals("", response.bodyText());
    assertEquals(302, response.statusCode());

    String redirectLocation = response.header("location");

    response = HttpRequest.get(redirectLocation).send();
    assertEquals("value = [888]", response.bodyText());
View Full Code Here

  @Test
  public void testOneRedirectPermanentAction() {
    HttpResponse response = HttpRequest.get("localhost:8173/oneRedirect.perm.html").send();
    assertEquals("", response.bodyText());
    assertEquals(301, response.statusCode());

    String redirectLocation = response.header("location");
    assertEquals("/two.html?value=444", redirectLocation);
  }
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.