use of org.webpieces.webserver.test.FullResponse in project webpieces by deanhiller.
the class TestAsynchronousErrors method testWebAppHasBugAndRender500HasBug.
@Test
public void testWebAppHasBugAndRender500HasBug() {
CompletableFuture<Integer> future = new CompletableFuture<Integer>();
mockNotFoundLib.queueFuture(future);
CompletableFuture<Integer> future2 = new CompletableFuture<Integer>();
mockInternalSvrErrorLib.queueFuture(future2);
HttpRequest req = Requests.createRequest(KnownHttpMethod.GET, "/");
http11Socket.send(req);
List<FullResponse> responses2 = http11Socket.getResponses();
Assert.assertEquals(0, responses2.size());
future.completeExceptionally(new RuntimeException("fail notfound route"));
List<FullResponse> responses3 = http11Socket.getResponses();
Assert.assertEquals(0, responses3.size());
future2.completeExceptionally(new RuntimeException("fail internal server error route"));
FullResponse response = ResponseExtract.assertSingleResponse(http11Socket);
response.assertStatusCode(KnownStatusCode.HTTP_500_INTERNAL_SVR_ERROR);
response.assertContains("The webpieces platform saved them");
}
use of org.webpieces.webserver.test.FullResponse in project webpieces by deanhiller.
the class TestAsynchronousErrors method testWebAppHasBugRenders500Route.
/**
* This tests bug in your webapp "/another" route, you could also test you have a bug in that route AND a bug in your internal
* server route as well!!!
*/
@Test
public void testWebAppHasBugRenders500Route() {
CompletableFuture<Integer> future = new CompletableFuture<Integer>();
mockNotFoundLib.queueFuture(future);
HttpRequest req = Requests.createRequest(KnownHttpMethod.GET, "/");
http11Socket.send(req);
List<FullResponse> responses2 = http11Socket.getResponses();
Assert.assertEquals(0, responses2.size());
future.completeExceptionally(new RuntimeException("test async exception"));
FullResponse response = ResponseExtract.assertSingleResponse(http11Socket);
response.assertStatusCode(KnownStatusCode.HTTP_500_INTERNAL_SVR_ERROR);
response.assertContains("There was a bug in our software...sorry about that");
}
use of org.webpieces.webserver.test.FullResponse in project webpieces by deanhiller.
the class TestAsynchronousErrors method testCompletePromiseAnotherThreadAndPageParamMissing.
@Test
public void testCompletePromiseAnotherThreadAndPageParamMissing() {
CompletableFuture<Integer> future = new CompletableFuture<Integer>();
mockNotFoundLib.queueFuture(future);
HttpRequest req = Requests.createRequest(KnownHttpMethod.GET, "/asyncFailRoute");
http11Socket.send(req);
//now have the server complete processing
future.complete(5);
FullResponse response = ResponseExtract.assertSingleResponse(http11Socket);
response.assertStatusCode(KnownStatusCode.HTTP_500_INTERNAL_SVR_ERROR);
response.assertContains("There was a bug in our software");
}
use of org.webpieces.webserver.test.FullResponse in project webpieces by deanhiller.
the class TestSyncWebServer method testScopedRoot.
@Test
public void testScopedRoot() {
HttpRequest req = Requests.createRequest(KnownHttpMethod.GET, "/scoped");
http11Socket.send(req);
FullResponse response = ResponseExtract.assertSingleResponse(http11Socket);
response.assertStatusCode(KnownStatusCode.HTTP_200_OK);
response.assertContains("This is the first raw html page");
}
use of org.webpieces.webserver.test.FullResponse in project webpieces by deanhiller.
the class TestSyncWebServer method testBasic.
@Test
public void testBasic() {
HttpRequest req = Requests.createRequest(KnownHttpMethod.GET, "/myroute");
http11Socket.send(req);
FullResponse response = ResponseExtract.assertSingleResponse(http11Socket);
response.assertStatusCode(KnownStatusCode.HTTP_200_OK);
response.assertContains("This is the first raw html page");
response.assertContentType("text/html; charset=utf-8");
List<Header> headers = response.getResponse().getHeaderLookupStruct().getHeaders(KnownHeaderName.CONTENT_TYPE);
Assert.assertEquals(1, headers.size());
}
Aggregations