use of org.webpieces.httpclient11.api.HttpFullResponse 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.HttpFullResponse 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.HttpFullResponse 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.HttpFullResponse 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());
}
use of org.webpieces.httpclient11.api.HttpFullResponse in project webpieces by deanhiller.
the class TestSyncWebServer method testJsonFile.
@Test
public void testJsonFile() {
HttpFullRequest req = Requests.createRequest(KnownHttpMethod.GET, "/somejson");
XFuture<HttpFullResponse> respFuture = http11Socket.send(req);
ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
response.assertStatusCode(KnownStatusCode.HTTP_200_OK);
response.assertContains("red");
response.assertContentType("application/json");
}
Aggregations