Search in sources :

Example 36 with FullResponse

use of org.webpieces.webserver.test.FullResponse in project webpieces by deanhiller.

the class TestSyncHibernate method testRollback.

@Test
public void testRollback() {
    HttpRequest req = Requests.createRequest(KnownHttpMethod.GET, "/fail");
    mock.addException(() -> {
        throw new RuntimeException("for test");
    });
    http11Socket.send(req);
    FullResponse response = ResponseExtract.assertSingleResponse(http11Socket);
    response.assertStatusCode(KnownStatusCode.HTTP_500_INTERNAL_SVR_ERROR);
    Assert.assertEquals(2, TransactionFilter.getState());
}
Also used : HttpRequest(org.webpieces.httpparser.api.dto.HttpRequest) FullResponse(org.webpieces.webserver.test.FullResponse) AbstractWebpiecesTest(org.webpieces.webserver.test.AbstractWebpiecesTest) Test(org.junit.Test) WebserverForTest(org.webpieces.webserver.WebserverForTest)

Example 37 with FullResponse

use of org.webpieces.webserver.test.FullResponse in project webpieces by deanhiller.

the class TestSyncHibernate method saveBean.

private String saveBean(String path) {
    HttpRequest req = Requests.createRequest(KnownHttpMethod.POST, path);
    http11Socket.send(req);
    FullResponse response = ResponseExtract.assertSingleResponse(http11Socket);
    response.assertStatusCode(KnownStatusCode.HTTP_303_SEEOTHER);
    return response.getRedirectUrl();
}
Also used : HttpRequest(org.webpieces.httpparser.api.dto.HttpRequest) FullResponse(org.webpieces.webserver.test.FullResponse)

Example 38 with FullResponse

use of org.webpieces.webserver.test.FullResponse in project webpieces by deanhiller.

the class TestDevSynchronousErrors method testWebAppHasBugAndRender500HasBug.

@Test
public void testWebAppHasBugAndRender500HasBug() {
    mockNotFoundLib.throwRuntime();
    mockInternalSvrErrorLib.throwRuntime();
    HttpRequest req = Requests.createRequest(KnownHttpMethod.GET, "/");
    http11Socket.send(req);
    FullResponse response = ResponseExtract.assertSingleResponse(http11Socket);
    response.assertStatusCode(KnownStatusCode.HTTP_500_INTERNAL_SVR_ERROR);
    response.assertContains("The webpieces platform saved them");
}
Also used : HttpRequest(org.webpieces.httpparser.api.dto.HttpRequest) FullResponse(org.webpieces.webserver.test.FullResponse) AbstractWebpiecesTest(org.webpieces.webserver.test.AbstractWebpiecesTest) PlatformOverridesForTest(org.webpieces.webserver.test.PlatformOverridesForTest) Test(org.junit.Test) WebserverForTest(org.webpieces.webserver.WebserverForTest)

Example 39 with FullResponse

use of org.webpieces.webserver.test.FullResponse 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
    HttpRequest req = Requests.createRequest(KnownHttpMethod.GET, "/redirectint/notAnInt");
    http11Socket.send(req);
    FullResponse response = ResponseExtract.assertSingleResponse(http11Socket);
    response.assertStatusCode(KnownStatusCode.HTTP_404_NOTFOUND);
    response.assertContains("Your app's webpage was not found");
}
Also used : HttpRequest(org.webpieces.httpparser.api.dto.HttpRequest) FullResponse(org.webpieces.webserver.test.FullResponse) AbstractWebpiecesTest(org.webpieces.webserver.test.AbstractWebpiecesTest) PlatformOverridesForTest(org.webpieces.webserver.test.PlatformOverridesForTest) Test(org.junit.Test) WebserverForTest(org.webpieces.webserver.WebserverForTest)

Example 40 with FullResponse

use of org.webpieces.webserver.test.FullResponse in project webpieces by deanhiller.

the class TestHttps method testReverseUrlLookupOnHttpPageForHttpsUrl.

@Test
public void testReverseUrlLookupOnHttpPageForHttpsUrl() {
    HttpRequest req = Requests.createRequest(KnownHttpMethod.GET, "/same");
    httpSocket.send(req);
    FullResponse response = ResponseExtract.assertSingleResponse(httpSocket);
    response.assertStatusCode(KnownStatusCode.HTTP_200_OK);
    //notice the Https Route page is not shown	
    response.assertContains("https://myhost.com:8443");
}
Also used : HttpRequest(org.webpieces.httpparser.api.dto.HttpRequest) FullResponse(org.webpieces.webserver.test.FullResponse) Test(org.junit.Test) AbstractWebpiecesTest(org.webpieces.webserver.test.AbstractWebpiecesTest) WebserverForTest(org.webpieces.webserver.WebserverForTest)

Aggregations

FullResponse (org.webpieces.webserver.test.FullResponse)154 Test (org.junit.Test)142 AbstractWebpiecesTest (org.webpieces.webserver.test.AbstractWebpiecesTest)142 WebserverForTest (org.webpieces.webserver.WebserverForTest)136 HttpRequest (org.webpieces.httpparser.api.dto.HttpRequest)120 HttpDummyRequest (org.webpieces.webserver.test.HttpDummyRequest)32 Header (org.webpieces.httpparser.api.common.Header)16 CompletableFuture (java.util.concurrent.CompletableFuture)11 PlatformOverridesForTest (org.webpieces.webserver.test.PlatformOverridesForTest)9 UserDto (org.webpieces.webserver.basic.app.biz.UserDto)4 UserTestDbo (org.webpieces.plugins.hibernate.app.dbo.UserTestDbo)3 NotFoundException (org.webpieces.router.api.exceptions.NotFoundException)2 ByteBuffer (java.nio.ByteBuffer)1 BufferCreationPool (org.webpieces.data.api.BufferCreationPool)1 DataWrapper (org.webpieces.data.api.DataWrapper)1 DataWrapperGenerator (org.webpieces.data.api.DataWrapperGenerator)1 HttpParser (org.webpieces.httpparser.api.HttpParser)1 MarshalState (org.webpieces.httpparser.api.MarshalState)1