use of org.webpieces.httpclient11.api.HttpFullResponse in project webpieces by deanhiller.
the class TestStaticPaths method testStaticDirWithKeepAlive.
@Test
public void testStaticDirWithKeepAlive() {
HttpFullRequest req = Requests.createRequest(KnownHttpMethod.GET, "/public/staticMeta.txt");
req.addHeader(new Header(KnownHeaderName.CONNECTION, "keep-alive"));
XFuture<HttpFullResponse> respFuture = http11Socket.send(req);
ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
response.assertStatusCode(KnownStatusCode.HTTP_200_OK);
response.assertContains("org.webpieces.webserver.staticpath.app.StaticMeta");
response.assertContentType("text/plain; charset=utf-8");
// there is a keep alive. socket should be open
Assert.assertFalse(http11Socket.isClosed());
}
use of org.webpieces.httpclient11.api.HttpFullResponse in project webpieces by deanhiller.
the class TestStaticPaths method testStaticFile.
@Test
public void testStaticFile() {
HttpFullRequest req = Requests.createRequest(KnownHttpMethod.GET, "/public/myfile");
XFuture<HttpFullResponse> respFuture = http11Socket.send(req);
ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
response.assertStatusCode(KnownStatusCode.HTTP_200_OK);
response.assertContains("app.TagsMeta");
}
use of org.webpieces.httpclient11.api.HttpFullResponse in project webpieces by deanhiller.
the class TestJsonCustomFilter method testNotFoundInJsonUrls.
@Test
public void testNotFoundInJsonUrls() {
HttpFullRequest req = Requests.createBadJsonRequest(KnownHttpMethod.POST, "/json/some/notexist/route");
XFuture<HttpFullResponse> respFuture = http11Socket.send(req);
ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
response.assertStatusCode(KnownStatusCode.HTTP_404_NOTFOUND);
response.assertContains("{`error`:`This url has no api. try another url`,`code`:0}".replace("`", "\""));
response.assertContentType("application/json");
}
use of org.webpieces.httpclient11.api.HttpFullResponse in project webpieces by deanhiller.
the class TestJsonCustomFilter method testSimulateCurl.
// had a bug on this one so add a test
@Test
public void testSimulateCurl() {
HttpFullRequest req = Requests.createJsonRequest(KnownHttpMethod.GET, "/json/45");
req.addHeader(new Header(KnownHeaderName.CONTENT_TYPE, "application/x-www-form-urlencoded"));
XFuture<HttpFullResponse> respFuture = http11Socket.send(req);
ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
response.assertStatusCode(KnownStatusCode.HTTP_200_OK);
response.assertContains("{`searchTime`:5,`matches`:[`match1`,`match2`]}".replace("`", "\""));
response.assertContentType("application/json");
}
use of org.webpieces.httpclient11.api.HttpFullResponse in project webpieces by deanhiller.
the class TestJsonCustomFilter method testSyncBadJsonPost.
@Test
public void testSyncBadJsonPost() {
HttpFullRequest req = Requests.createBadJsonRequest(KnownHttpMethod.POST, "/json/45");
XFuture<HttpFullResponse> respFuture = http11Socket.send(req);
ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
response.assertStatusCode(KnownStatusCode.HTTP_400_BADREQUEST);
response.assertContains("{`error`:`invalid json in client request. Unexpected character ('c' (code 99)): was expecting a colon to separate field name and value".replace("`", "\""));
response.assertContentType("application/json");
}
Aggregations