use of org.webpieces.httpclient11.api.HttpFullResponse in project webpieces by deanhiller.
the class TestSyncWebServer method testRedirectRawRelativeUrl.
@Test
public void testRedirectRawRelativeUrl() {
HttpFullRequest req = Requests.createRequest(KnownHttpMethod.GET, "/rawurlredirect");
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 TestAsyncWebServer method testCompletePromiseOnRequestThread.
@Test
public void testCompletePromiseOnRequestThread() {
HttpFullRequest req = Requests.createRequest(KnownHttpMethod.GET, "/myroute");
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");
}
use of org.webpieces.httpclient11.api.HttpFullResponse in project webpieces by deanhiller.
the class TestAsynchronousErrors method testNotFoundHandlerThrowsNotFound.
@Test
public void testNotFoundHandlerThrowsNotFound() {
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 NotFoundException("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.httpclient11.api.HttpFullResponse in project webpieces by deanhiller.
the class TestAsynchronousErrors method testWebappThrowsNotFound.
@Test
public void testWebappThrowsNotFound() {
XFuture<Integer> future = new XFuture<Integer>();
mockNotFoundLib.queueFuture(future);
XFuture<Integer> future2 = new XFuture<Integer>();
mockNotFoundLib.queueFuture(future2);
HttpFullRequest req = Requests.createRequest(KnownHttpMethod.GET, "/throwNotFound");
XFuture<HttpFullResponse> respFuture = http11Socket.send(req);
Assert.assertFalse(respFuture.isDone());
future.completeExceptionally(new NotFoundException("some async NotFound"));
Assert.assertFalse(respFuture.isDone());
future2.complete(55);
ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
response.assertStatusCode(KnownStatusCode.HTTP_404_NOTFOUND);
response.assertContains("Your page was not found");
}
use of org.webpieces.httpclient11.api.HttpFullResponse in project webpieces by deanhiller.
the class TestAsynchronousErrors method testNotFoundRoute.
@Test
public void testNotFoundRoute() {
// NOTE: This is adding future to the notFound route
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());
// now resolve the future (which would be done on another thread)
future.complete(22);
ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
response.assertStatusCode(KnownStatusCode.HTTP_404_NOTFOUND);
response.assertContains("Your page was not found");
}
Aggregations