Search in sources :

Example 56 with HttpFullResponse

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

the class TestDevRefreshPageWithNoRestarting method testNotFoundDisplaysWithIframeANDSpecialUrl.

@Test
public void testNotFoundDisplaysWithIframeANDSpecialUrl() {
    HttpFullRequest req = Requests.createRequest(KnownHttpMethod.GET, "/notFound");
    XFuture<HttpFullResponse> respFuture = http11Socket.send(req);
    ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
    response.assertStatusCode(KnownStatusCode.HTTP_404_NOTFOUND);
    // platform should convert request into a development not found page which has an iframe
    // of the original page with a query param to tell platform to display original
    // page requested
    response.assertContains("<iframe id=\"production\" src=\"/notFound?webpiecesShowPage=true");
}
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 57 with HttpFullResponse

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

the class TestDevRefreshPageWithNoRestarting method testJustControllerChangedToCompileError.

@Test
public void testJustControllerChangedToCompileError() throws IOException {
    HttpFullRequest req = Requests.createRequest(KnownHttpMethod.GET, "/home");
    XFuture<HttpFullResponse> respFuture1 = http11Socket.send(req);
    verifyPageContents(respFuture1, "user=Dean Hiller");
    simulateDeveloperMakesChanges("src/test/devServerTest/controllerChangeCompileError");
    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");
    // showing the compile error
    response.assertContains("<span style=\"color:red;\">Error: cannot find symbol\n" + "  symbol:   method renThis()\n" + "  location: class org.webpieces.router.api.controller.actions.Actions</span>");
}
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 58 with HttpFullResponse

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

the class TestDevRefreshPageWithNoRestarting method testGuiceModuleAddAndControllerChange.

@Test
public void testGuiceModuleAddAndControllerChange() throws IOException {
    HttpFullRequest req = Requests.createRequest(KnownHttpMethod.GET, "/home");
    XFuture<HttpFullResponse> respFuture1 = http11Socket.send(req);
    verifyPageContents(respFuture1, "user=Dean Hiller");
    simulateDeveloperMakesChanges("src/test/devServerTest/guiceModule");
    XFuture<HttpFullResponse> respFuture = http11Socket.send(req);
    verifyPageContents(respFuture, "newuser=Joseph");
}
Also used : HttpFullResponse(org.webpieces.httpclient11.api.HttpFullResponse) HttpFullRequest(org.webpieces.httpclient11.api.HttpFullRequest) AbstractWebpiecesTest(org.webpieces.webserver.test.AbstractWebpiecesTest) PrivateWebserverForTest(org.webpieces.webserver.PrivateWebserverForTest) Test(org.junit.Test)

Example 59 with HttpFullResponse

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

the class TestDevSynchronousErrors method testWebappThrowsNotFound.

@Test
public void testWebappThrowsNotFound() {
    HttpFullRequest req = Requests.createRequest(KnownHttpMethod.GET, "/throwNotFound");
    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");
}
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 60 with HttpFullResponse

use of org.webpieces.httpclient11.api.HttpFullResponse 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");
}
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

HttpFullResponse (org.webpieces.httpclient11.api.HttpFullResponse)208 HttpFullRequest (org.webpieces.httpclient11.api.HttpFullRequest)204 ResponseWrapper (org.webpieces.webserver.test.ResponseWrapper)200 Test (org.junit.Test)192 AbstractWebpiecesTest (org.webpieces.webserver.test.AbstractWebpiecesTest)192 PrivateWebserverForTest (org.webpieces.webserver.PrivateWebserverForTest)178 Header (org.webpieces.httpparser.api.common.Header)39 XFuture (org.webpieces.util.futures.XFuture)12 WebserverForTest (org.webpieces.plugins.fortesting.WebserverForTest)8 URL (java.net.URL)3 UserTestDbo (org.webpieces.plugins.hibernate.app.dbo.UserTestDbo)3 UserDto (org.webpieces.webserver.basic.app.biz.UserDto)3 URI (java.net.URI)2 DataWrapper (org.webpieces.data.api.DataWrapper)2 NotFoundException (org.webpieces.http.exception.NotFoundException)2 HttpData (org.webpieces.httpparser.api.dto.HttpData)2 HttpResponse (org.webpieces.httpparser.api.dto.HttpResponse)2 AcmeInfo (org.webpieces.plugin.secure.sslcert.acme.AcmeInfo)2 SearchRequest (org.webpieces.webserver.json.app.SearchRequest)2 FetchValueResponse (webpiecesxxxxxpackage.service.FetchValueResponse)2