use of org.webpieces.webserver.test.HttpDummyRequest in project webpieces by deanhiller.
the class TestScopes method runInvalidPost.
private FullResponse runInvalidPost() {
HttpDummyRequest req = Requests.createPostRequest("/user/post", //invalid first name
"user.firstName", //invalid first name
"D", "user.lastName", "Hiller", "user.fullName", "Dean Hiller", "user.address.zipCode", "555", "user.address.street", "Coolness Dr.");
http11Socket.send(req);
FullResponse response = ResponseExtract.assertSingleResponse(http11Socket);
response.assertStatusCode(KnownStatusCode.HTTP_303_SEEOTHER);
return response;
}
use of org.webpieces.webserver.test.HttpDummyRequest in project webpieces by deanhiller.
the class TestJson method testSyncWriteOnlyPost.
@Test
public void testSyncWriteOnlyPost() {
HttpDummyRequest req = Requests.createJsonRequest(KnownHttpMethod.POST, "/json/write");
http11Socket.send(req);
FullResponse response = ResponseExtract.assertSingleResponse(http11Socket);
response.assertStatusCode(KnownStatusCode.HTTP_200_OK);
Assert.assertEquals("", response.getBodyAsString());
}
use of org.webpieces.webserver.test.HttpDummyRequest in project webpieces by deanhiller.
the class TestJson method testRouteParamConversionFail.
@Test
public void testRouteParamConversionFail() {
HttpDummyRequest req = Requests.createBadJsonRequest(KnownHttpMethod.POST, "/json/somenotexistroute");
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");
}
use of org.webpieces.webserver.test.HttpDummyRequest in project webpieces by deanhiller.
the class TestJson method testAsyncBadJsonPost.
@Test
public void testAsyncBadJsonPost() {
HttpDummyRequest req = Requests.createBadJsonRequest(KnownHttpMethod.POST, "/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.HttpDummyRequest in project webpieces by deanhiller.
the class TestJson method testSyncJsonPost.
@Test
public void testSyncJsonPost() {
HttpDummyRequest req = Requests.createJsonRequest(KnownHttpMethod.POST, "/json/45");
http11Socket.send(req);
FullResponse response = ResponseExtract.assertSingleResponse(http11Socket);
response.assertStatusCode(KnownStatusCode.HTTP_200_OK);
response.assertContains("{`searchTime`:99,`matches`:[`match1`,`match2`]}".replace("`", "\""));
response.assertContentType("application/json");
}
Aggregations