use of org.webpieces.httpclient11.api.HttpFullRequest in project webpieces by deanhiller.
the class TestDevSynchronousErrors 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() {
mockNotFoundLib.throwRuntime();
HttpFullRequest req = Requests.createRequest(KnownHttpMethod.GET, "/");
XFuture<HttpFullResponse> respFuture = http11Socket.send(req);
ResponseWrapper response1 = ResponseExtract.waitResponseAndWrap(respFuture);
response1.assertStatusCode(KnownStatusCode.HTTP_500_INTERNAL_SVR_ERROR);
// There should be a callback url to render what shows in production
response1.assertContains("/?webpiecesShowInternalErrorPage=true");
// callback shows the original page...
HttpFullRequest req2 = Requests.createRequest(KnownHttpMethod.GET, "/?webpiecesShowInternalErrorPage=true");
XFuture<HttpFullResponse> respFuture2 = http11Socket.send(req2);
ResponseWrapper response2 = ResponseExtract.waitResponseAndWrap(respFuture2);
response2.assertStatusCode(KnownStatusCode.HTTP_500_INTERNAL_SVR_ERROR);
response2.assertContains("There was a bug in our software...sorry about that");
}
use of org.webpieces.httpclient11.api.HttpFullRequest in project webpieces by deanhiller.
the class TestDevSynchronousErrors method testNotFoundFromMismatchArgType.
@Test
public void testNotFoundFromMismatchArgType() {
// because 'notAnInt' is not convertable to integer, this result in NotFound rather than 500 as truly a route with
// no int doesn't really exist so it's a NotFound
HttpFullRequest req = Requests.createRequest(KnownHttpMethod.GET, "/redirectint/notAnInt");
XFuture<HttpFullResponse> respFuture = http11Socket.send(req);
ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
response.assertStatusCode(KnownStatusCode.HTTP_404_NOTFOUND);
response.assertContains("Your app's webpage was not found");
}
use of org.webpieces.httpclient11.api.HttpFullRequest in project webpieces by deanhiller.
the class TestDevSynchronousErrors method testWebAppHasBugAndRender500HasBug.
@Test
public void testWebAppHasBugAndRender500HasBug() {
mockNotFoundLib.throwRuntime();
mockInternalSvrErrorLib.throwRuntime();
HttpFullRequest req = Requests.createRequest(KnownHttpMethod.GET, "/");
XFuture<HttpFullResponse> respFuture = http11Socket.send(req);
ResponseWrapper response1 = ResponseExtract.waitResponseAndWrap(respFuture);
response1.assertStatusCode(KnownStatusCode.HTTP_500_INTERNAL_SVR_ERROR);
// There should be a callback url to render what shows in production
response1.assertContains("/?webpiecesShowInternalErrorPage=true");
// callback shows the original page...
HttpFullRequest req2 = Requests.createRequest(KnownHttpMethod.GET, "/?webpiecesShowInternalErrorPage=true");
XFuture<HttpFullResponse> respFuture2 = http11Socket.send(req2);
ResponseWrapper response2 = ResponseExtract.waitResponseAndWrap(respFuture2);
response2.assertStatusCode(KnownStatusCode.HTTP_500_INTERNAL_SVR_ERROR);
response2.assertContains("There was a bug in the developers application or webpieces server");
}
use of org.webpieces.httpclient11.api.HttpFullRequest in project webpieces by deanhiller.
the class TestSyncWebServer method testRedirectRawAbsoluteUrl.
@Test
public void testRedirectRawAbsoluteUrl() {
HttpFullRequest req = Requests.createRequest(KnownHttpMethod.GET, "/rawabsoluteurlredirect");
XFuture<HttpFullResponse> respFuture = http11Socket.send(req);
ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
response.assertStatusCode(KnownStatusCode.HTTP_303_SEEOTHER);
Assert.assertEquals(0, response.getBody().getReadableSize());
Assert.assertEquals("https://something.com/hi", response.getRedirectUrl());
}
use of org.webpieces.httpclient11.api.HttpFullRequest in project webpieces by deanhiller.
the class TestSyncWebServer method testRedirect.
@Test
public void testRedirect() {
HttpFullRequest req = Requests.createRequest(KnownHttpMethod.GET, "/");
XFuture<HttpFullResponse> respFuture = http11Socket.send(req);
ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
response.assertStatusCode(KnownStatusCode.HTTP_303_SEEOTHER);
Assert.assertEquals(0, response.getBody().getReadableSize());
Assert.assertEquals("http://myhost.com/myroute", response.getRedirectUrl());
}
Aggregations