Package jodd.http

Examples of jodd.http.HttpResponse


  }

  @Test
  public void testUserActionGet() {
    HttpBrowser httpBrowser = new HttpBrowser();
    HttpResponse response = httpBrowser.sendRequest(
        HttpRequest.get("localhost:8173/sys/user/123"));

    assertEquals("Huh 123.", response.bodyText().trim());
  }
View Full Code Here


  }

  @Test
  public void testUserActionPost() {
    HttpBrowser httpBrowser = new HttpBrowser();
    HttpResponse response = httpBrowser.sendRequest(
        HttpRequest.post("localhost:8173/sys/user/123"));

    assertEquals("Post 123.", response.bodyText().trim());
  }
View Full Code Here

    MadvocSuite.stopTomcat();
  }

  @Test
  public void testSessionScope() {
    HttpResponse response = HttpRequest.get("localhost:8173/item.html").send();
    String out1 = response.bodyText().trim();

    response = HttpRequest.get("localhost:8173/item.html").send();
    String out2 = response.bodyText().trim();

    assertFalse(out1.equals(out2));

    String jsessionid = out2.substring(out2.indexOf("sid:") + 4);

    response = HttpRequest.get("localhost:8173/item.html;jsessionid=" + jsessionid).send();
    String out3 = response.bodyText().trim();

    assertEquals(out2, out3);
  }
View Full Code Here

    assertEquals(out2, out3);
  }

  @Test
  public void testSessionScopeWithScopedProxy() {
    HttpResponse response = HttpRequest.get("localhost:8173/item.global.html").send();
    String out1 = response.bodyText().trim();

    response = HttpRequest.get("localhost:8173/item.global.html").send();
    String out2 = response.bodyText().trim();

    assertFalse(out1.equals(out2));

    String jsessionid = out2.substring(out2.indexOf("sid:") + 4);

    response = HttpRequest.get("localhost:8173/item.global.html;jsessionid=" + jsessionid).send();
    String out3 = response.bodyText().trim();

    assertEquals(out2, out3);
  }
View Full Code Here

    assertEquals(out2, out3);
  }

  @Test
  public void testSessionScopeWithInOut() {
    HttpResponse response = HttpRequest.get("localhost:8173/sess.html?name=jodd").send();
    String out = response.bodyText().trim();

    int ndx = out.indexOf('>');
    String sid = out.substring(ndx + 1);
    assertEquals("Sess: jodd", out.substring(0, ndx).trim());

    response = HttpRequest.get("localhost:8173/sess.two.html;jsessionid=" + sid).send();
    out = response.bodyText().trim();

    ndx = out.indexOf('>');
    sid = out.substring(ndx + 1);
    assertEquals("Sess: JODD", out.substring(0, ndx).trim());

    response = HttpRequest.get("localhost:8173/sess.three.html;jsessionid=" + sid).send();
    out = response.bodyText().trim();

    ndx = out.indexOf('>');
    sid = out.substring(ndx + 1);
    assertEquals("Sess:", out.substring(0, ndx).trim());

    response = HttpRequest.get("localhost:8173/sess.four.html;jsessionid=" + sid).send();
    out = response.bodyText().trim();
    assertEquals("ne:true", out.trim());
  }
View Full Code Here

    MadvocSuite.stopTomcat();
  }

  @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

    assertEquals("value = [333]", response.bodyText());
  }

  @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

    assertEquals("value = [777]", response.bodyText());
  }

  @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

    assertEquals("value = [888]", response.bodyText());
  }

  @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

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.