use of org.webpieces.webserver.test.ResponseWrapper in project webpieces by deanhiller.
the class TestAsynchronousErrors method testNotFoundThrowsException.
@Test
public void testNotFoundThrowsException() {
XFuture<Integer> future = new XFuture<Integer>();
mockNotFoundLib.queueFuture(future);
HttpFullRequest req = Requests.createRequest(KnownHttpMethod.GET, "/route/that/does/not/exist");
XFuture<HttpFullResponse> respFuture = http11Socket.send(req);
Assert.assertFalse(respFuture.isDone());
future.completeExceptionally(new RuntimeException("testing notfound from notfound route"));
ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
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.ResponseWrapper in project webpieces by deanhiller.
the class TestSyncWebServer method testAbsoluteHtmlPath.
@Test
public void testAbsoluteHtmlPath() {
HttpFullRequest req = Requests.createRequest(KnownHttpMethod.GET, "/myroute2");
XFuture<HttpFullResponse> respFuture = http11Socket.send(req);
ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
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());
}
use of org.webpieces.webserver.test.ResponseWrapper in project webpieces by deanhiller.
the class TestSynchronousErrors method testTemplateHasBug.
// This stack is deeper and a good test to make sure no one breaks the 500 rendering of
// this by putting some if(responseSent) throw in the wrong place
@Test
public void testTemplateHasBug() {
HttpFullRequest req = Requests.createRequest(KnownHttpMethod.GET, "/badtemplate");
XFuture<HttpFullResponse> respFuture = http11Socket.send(req);
ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
response.assertContains("There was a bug in our software...sorry about that");
response.assertStatusCode(KnownStatusCode.HTTP_500_INTERNAL_SVR_ERROR);
}
use of org.webpieces.webserver.test.ResponseWrapper in project webpieces by deanhiller.
the class TestSynchronousErrors method testNotFoundThrowsException.
@Test
public void testNotFoundThrowsException() {
mockNotFoundLib.throwRuntime();
HttpFullRequest req = Requests.createRequest(KnownHttpMethod.GET, "/route/that/does/not/exist");
XFuture<HttpFullResponse> respFuture = http11Socket.send(req);
ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
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.ResponseWrapper in project webpieces by deanhiller.
the class TestSynchronousErrors method testNotFoundThrowsThenInternalSvrErrorHandlerThrows.
@Test
public void testNotFoundThrowsThenInternalSvrErrorHandlerThrows() {
mockNotFoundLib.throwRuntime();
mockInternalSvrErrorLib.throwRuntime();
HttpFullRequest req = Requests.createRequest(KnownHttpMethod.GET, "/route/that/does/not/exist");
XFuture<HttpFullResponse> respFuture = http11Socket.send(req);
ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
response.assertStatusCode(KnownStatusCode.HTTP_500_INTERNAL_SVR_ERROR);
response.assertContains("There was a bug in the developers application or webpieces server");
}
Aggregations