use of org.webpieces.webserver.test.FullResponse in project webpieces by deanhiller.
the class TestJson method testAsyncJsonPost.
@Test
public void testAsyncJsonPost() {
HttpDummyRequest req = Requests.createJsonRequest(KnownHttpMethod.POST, "/json/async/45");
http11Socket.send(req);
FullResponse response = ResponseExtract.assertSingleResponse(http11Socket);
response.assertStatusCode(KnownStatusCode.HTTP_200_OK);
response.assertContains("{`searchTime`:98,`matches`:[`match1`,`match2`]}".replace("`", "\""));
response.assertContentType("application/json");
}
use of org.webpieces.webserver.test.FullResponse in project webpieces by deanhiller.
the class TestJson method testSyncBadJsonGet.
@Test
public void testSyncBadJsonGet() {
HttpDummyRequest req = Requests.createBadJsonRequest(KnownHttpMethod.GET, "/json/45");
http11Socket.send(req);
FullResponse response = ResponseExtract.assertSingleResponse(http11Socket);
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");
}
use of org.webpieces.webserver.test.FullResponse in project webpieces by deanhiller.
the class TestJson method testNotFoundInHtmlUrls.
@Test
public void testNotFoundInHtmlUrls() {
HttpDummyRequest req = Requests.createBadJsonRequest(KnownHttpMethod.POST, "/html");
http11Socket.send(req);
FullResponse response = ResponseExtract.assertSingleResponse(http11Socket);
response.assertStatusCode(KnownStatusCode.HTTP_404_NOTFOUND);
response.assertContains("Your page was not found");
response.assertContentType("text/html; charset=utf-8");
}
use of org.webpieces.webserver.test.FullResponse in project webpieces by deanhiller.
the class TestJson method testAsyncBadJsonGet.
@Test
public void testAsyncBadJsonGet() {
HttpDummyRequest req = Requests.createBadJsonRequest(KnownHttpMethod.GET, "/json/async/45");
http11Socket.send(req);
FullResponse response = ResponseExtract.assertSingleResponse(http11Socket);
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");
}
use of org.webpieces.webserver.test.FullResponse in project webpieces by deanhiller.
the class TestJson method testControllerThrowsNotFound.
@Test
public void testControllerThrowsNotFound() {
HttpDummyRequest req = Requests.createJsonRequest(KnownHttpMethod.GET, "/json/throw/333");
http11Socket.send(req);
FullResponse response = ResponseExtract.assertSingleResponse(http11Socket);
//clearly this url has nothing there
response.assertStatusCode(KnownStatusCode.HTTP_404_NOTFOUND);
response.assertContains("{`error`:`This url has no api. try another url`,`code`:0}".replace("`", "\""));
response.assertContentType("application/json");
}
Aggregations