Package jodd.http

Examples of jodd.http.HttpResponse


    assertEquals("123", response.bodyText().trim());
  }

  @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


    assertEquals("321", response.bodyText().trim());
  }

  @Test
  public void testRestAction3() {
    HttpResponse response = HttpRequest.get("localhost:8173/re/view3/555").send();
    assertEquals("555", response.bodyText().trim());
  }
View Full Code Here

    assertEquals("555", response.bodyText().trim());
  }

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

    MadvocSuite.stopTomcat();
  }

  @Test
  public void testMissingAction() {
    HttpResponse response = HttpRequest.get("localhost:8173/missing.html?data.miss=123").send();
    assertEquals(":null", response.bodyText().trim());
  }
View Full Code Here

  }

  @Test
  public void testException() {
    HttpBrowser httpBrowser = new HttpBrowser();
    HttpResponse response = httpBrowser.sendRequest(HttpRequest.get("localhost:8173/exc.html"));

    assertEquals("500!", response.bodyText().trim());
  }
View Full Code Here

  }

  @Test
  public void testRedirect500() {
    HttpBrowser httpBrowser = new HttpBrowser();
    HttpResponse response = httpBrowser.sendRequest(HttpRequest.get("localhost:8173/exc.red.html"));

    assertEquals("500!", response.bodyText().trim());
  }
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

    MadvocSuite.stopTomcat();
  }

  @Test
  public void testMoveWithFiles() {
    HttpResponse response;
    response = HttpRequest
        .post("localhost:8173/mv/upload.html")
        .form("uploadFiles[0]", new ByteArrayUploadable(new byte[] {65, 66, 67}, "hello.txt"))
        .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();

    assertEquals("33hello.txt 33uploadFiles[1] a1 a2 ", response.bodyText());
  }
View Full Code Here

    MadvocSuite.stopTomcat();
  }

  @Test
  public void testFilterAction() {
    HttpResponse response = HttpRequest.get("localhost:8173/filter.html").send();
    assertEquals("Hello.peep!peep!", response.bodyText().trim());
  }
View Full Code Here

TOP

Related Classes of jodd.http.HttpResponse

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.