Search in sources :

Example 51 with HttpFullRequest

use of org.webpieces.httpclient11.api.HttpFullRequest in project webpieces by deanhiller.

the class TestDomainMatching method testDomain2RequestDomain1Route.

@Test
public void testDomain2RequestDomain1Route() {
    HttpFullRequest req = Requests.createGetRequest("domain2.com", "/domain1");
    XFuture<HttpFullResponse> respFuture = httpsSocket.send(req);
    ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
    response.assertStatusCode(KnownStatusCode.HTTP_404_NOTFOUND);
    response.assertContains("Your page was not found");
}
Also used : HttpFullResponse(org.webpieces.httpclient11.api.HttpFullResponse) HttpFullRequest(org.webpieces.httpclient11.api.HttpFullRequest) ResponseWrapper(org.webpieces.webserver.test.ResponseWrapper) PrivateWebserverForTest(org.webpieces.webserver.PrivateWebserverForTest) Test(org.junit.Test) AbstractWebpiecesTest(org.webpieces.webserver.test.AbstractWebpiecesTest)

Example 52 with HttpFullRequest

use of org.webpieces.httpclient11.api.HttpFullRequest in project webpieces by deanhiller.

the class TestDomainMatching method testDomain1RequestDomain1Route.

@Test
public void testDomain1RequestDomain1Route() {
    HttpFullRequest req = Requests.createGetRequest("mydomain.com", "/domain1");
    XFuture<HttpFullResponse> respFuture = httpsSocket.send(req);
    ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
    response.assertStatusCode(KnownStatusCode.HTTP_200_OK);
    response.assertContains("This is domain1");
}
Also used : HttpFullResponse(org.webpieces.httpclient11.api.HttpFullResponse) HttpFullRequest(org.webpieces.httpclient11.api.HttpFullRequest) ResponseWrapper(org.webpieces.webserver.test.ResponseWrapper) PrivateWebserverForTest(org.webpieces.webserver.PrivateWebserverForTest) Test(org.junit.Test) AbstractWebpiecesTest(org.webpieces.webserver.test.AbstractWebpiecesTest)

Example 53 with HttpFullRequest

use of org.webpieces.httpclient11.api.HttpFullRequest in project webpieces by deanhiller.

the class TestDomainMatching method testDomain2RequestDomain2Route.

@Test
public void testDomain2RequestDomain2Route() {
    HttpFullRequest req = Requests.createGetRequest("domain2.com", "/domain2");
    XFuture<HttpFullResponse> respFuture = httpsSocket.send(req);
    ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
    response.assertStatusCode(KnownStatusCode.HTTP_200_OK);
    response.assertContains("This is domain2");
}
Also used : HttpFullResponse(org.webpieces.httpclient11.api.HttpFullResponse) HttpFullRequest(org.webpieces.httpclient11.api.HttpFullRequest) ResponseWrapper(org.webpieces.webserver.test.ResponseWrapper) PrivateWebserverForTest(org.webpieces.webserver.PrivateWebserverForTest) Test(org.junit.Test) AbstractWebpiecesTest(org.webpieces.webserver.test.AbstractWebpiecesTest)

Example 54 with HttpFullRequest

use of org.webpieces.httpclient11.api.HttpFullRequest in project webpieces by deanhiller.

the class TestDevRefreshPageWithNoRestarting method testInternalErrorModifiedAndControllerModified.

@Test
public void testInternalErrorModifiedAndControllerModified() throws IOException {
    HttpFullRequest req1 = Requests.createRequest(KnownHttpMethod.GET, "/causeError");
    XFuture<HttpFullResponse> respFuture1 = http11Socket.send(req1);
    ResponseWrapper response1 = ResponseExtract.waitResponseAndWrap(respFuture1);
    response1.assertStatusCode(KnownStatusCode.HTTP_500_INTERNAL_SVR_ERROR);
    // There should be a callback url to render what shows in production
    response1.assertContains("/causeError?webpiecesShowInternalErrorPage=true");
    HttpFullRequest req2 = Requests.createRequest(KnownHttpMethod.GET, "/causeError?webpiecesShowInternalErrorPage=true");
    XFuture<HttpFullResponse> respFuture2 = http11Socket.send(req2);
    ResponseWrapper response2 = ResponseExtract.waitResponseAndWrap(respFuture2);
    response2.assertStatusCode(KnownStatusCode.HTTP_500_INTERNAL_SVR_ERROR);
    response2.assertContains("InternalError1=error1");
    simulateDeveloperMakesChanges("src/test/devServerTest/internalError");
    XFuture<HttpFullResponse> respFuture3 = http11Socket.send(req1);
    ResponseWrapper response3 = ResponseExtract.waitResponseAndWrap(respFuture3);
    response3.assertStatusCode(KnownStatusCode.HTTP_500_INTERNAL_SVR_ERROR);
    // There should be a callback url to render what shows in production
    response3.assertContains("/causeError?webpiecesShowInternalErrorPage=true");
    XFuture<HttpFullResponse> respFuture4 = http11Socket.send(req2);
    ResponseWrapper response4 = ResponseExtract.waitResponseAndWrap(respFuture4);
    response4.assertStatusCode(KnownStatusCode.HTTP_500_INTERNAL_SVR_ERROR);
    response4.assertContains("InternalError2=error2");
}
Also used : HttpFullResponse(org.webpieces.httpclient11.api.HttpFullResponse) HttpFullRequest(org.webpieces.httpclient11.api.HttpFullRequest) ResponseWrapper(org.webpieces.webserver.test.ResponseWrapper) AbstractWebpiecesTest(org.webpieces.webserver.test.AbstractWebpiecesTest) PrivateWebserverForTest(org.webpieces.webserver.PrivateWebserverForTest) Test(org.junit.Test)

Example 55 with HttpFullRequest

use of org.webpieces.httpclient11.api.HttpFullRequest in project webpieces by deanhiller.

the class TestDevRefreshPageWithNoRestarting method testNotFoundFilterModifiedAndInvalidRoute.

@Test
public void testNotFoundFilterModifiedAndInvalidRoute() throws IOException {
    HttpFullRequest req = Requests.createRequest(KnownHttpMethod.GET, "/enableFilter?webpiecesShowPage=true");
    XFuture<HttpFullResponse> respFuture1 = http11Socket.send(req);
    verify303(respFuture1, "http://myhost.com/home");
    simulateDeveloperMakesChanges("src/test/devServerTest/notFoundNewInvalidRoute");
    XFuture<HttpFullResponse> respFuture = http11Socket.send(req);
    ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
    response.assertStatusCode(KnownStatusCode.HTTP_500_INTERNAL_SVR_ERROR);
    response.assertContains("You are in the WebPieces Development Server. You appear to have a bug in your application.");
    // Encountered a bug that can't happen in production as prod server won't even start...
    response.assertContains("The above looks like an issue that cannot happen in production so we can't display a production page here");
}
Also used : HttpFullResponse(org.webpieces.httpclient11.api.HttpFullResponse) HttpFullRequest(org.webpieces.httpclient11.api.HttpFullRequest) ResponseWrapper(org.webpieces.webserver.test.ResponseWrapper) AbstractWebpiecesTest(org.webpieces.webserver.test.AbstractWebpiecesTest) PrivateWebserverForTest(org.webpieces.webserver.PrivateWebserverForTest) Test(org.junit.Test)

Aggregations

HttpFullRequest (org.webpieces.httpclient11.api.HttpFullRequest)222 HttpFullResponse (org.webpieces.httpclient11.api.HttpFullResponse)205 ResponseWrapper (org.webpieces.webserver.test.ResponseWrapper)204 Test (org.junit.Test)194 AbstractWebpiecesTest (org.webpieces.webserver.test.AbstractWebpiecesTest)193 PrivateWebserverForTest (org.webpieces.webserver.PrivateWebserverForTest)180 Header (org.webpieces.httpparser.api.common.Header)50 XFuture (org.webpieces.util.futures.XFuture)13 HttpRequest (org.webpieces.httpparser.api.dto.HttpRequest)12 Http2Header (com.webpieces.http2.api.dto.lowlevel.lib.Http2Header)9 HttpRequestLine (org.webpieces.httpparser.api.dto.HttpRequestLine)9 HttpUri (org.webpieces.httpparser.api.dto.HttpUri)9 WebserverForTest (org.webpieces.plugins.fortesting.WebserverForTest)8 DataWrapper (org.webpieces.data.api.DataWrapper)6 UserDto (org.webpieces.webserver.basic.app.biz.UserDto)4 URL (java.net.URL)3 UserTestDbo (org.webpieces.plugins.hibernate.app.dbo.UserTestDbo)3 URI (java.net.URI)2 ByteBuffer (java.nio.ByteBuffer)2 NotFoundException (org.webpieces.http.exception.NotFoundException)2