Search in sources :

Example 91 with ResponseWrapper

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

the class TestSyncHibernate method testRollback.

@Test
public void testRollback() {
    HttpFullRequest req = Requests.createRequest(KnownHttpMethod.GET, "/fail");
    mock.addException(() -> {
        throw new RuntimeException("for test");
    });
    XFuture<HttpFullResponse> respFuture = http11Socket.send(req);
    ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
    response.assertStatusCode(KnownStatusCode.HTTP_500_INTERNAL_SVR_ERROR);
    Assert.assertEquals(2, TransactionFilter.getState());
}
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 92 with ResponseWrapper

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

the class TestSyncHibernate method testRenderEditPage.

@Test
public void testRenderEditPage() {
    int id = loadDataInDb().getId();
    HttpFullRequest req = Requests.createRequest(KnownHttpMethod.GET, "/user/edit/" + id);
    XFuture<HttpFullResponse> respFuture = http11Socket.send(req);
    ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
    response.assertStatusCode(KnownStatusCode.HTTP_200_OK);
    response.assertContains("name='SomeName' email='dean2@sync.xsoftware.biz'");
}
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 93 with ResponseWrapper

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

the class TestSyncHibernate method saveBean.

private String saveBean(String path) {
    HttpFullRequest req = Requests.createRequest(KnownHttpMethod.POST, path);
    XFuture<HttpFullResponse> respFuture = http11Socket.send(req);
    ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
    response.assertStatusCode(KnownStatusCode.HTTP_303_SEEOTHER);
    return response.getRedirectUrl();
}
Also used : HttpFullResponse(org.webpieces.httpclient11.api.HttpFullResponse) HttpFullRequest(org.webpieces.httpclient11.api.HttpFullRequest) ResponseWrapper(org.webpieces.webserver.test.ResponseWrapper)

Example 94 with ResponseWrapper

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

the class TestSyncHibernate method readBean.

private void readBean(String redirectUrl, String email) {
    HttpFullRequest req = Requests.createRequest(KnownHttpMethod.GET, redirectUrl);
    XFuture<HttpFullResponse> respFuture = http11Socket.send(req);
    ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
    response.assertStatusCode(KnownStatusCode.HTTP_200_OK);
    response.assertContains("name=SomeName email=" + email);
}
Also used : HttpFullResponse(org.webpieces.httpclient11.api.HttpFullResponse) HttpFullRequest(org.webpieces.httpclient11.api.HttpFullRequest) ResponseWrapper(org.webpieces.webserver.test.ResponseWrapper)

Example 95 with ResponseWrapper

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

the class TestSyncHibernate method testReverseAddAndEditFromRouteId.

@Test
public void testReverseAddAndEditFromRouteId() {
    loadDataInDb();
    HttpFullRequest req = Requests.createRequest(KnownHttpMethod.GET, "/user/list");
    XFuture<HttpFullResponse> respFuture = http11Socket.send(req);
    ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
    response.assertStatusCode(KnownStatusCode.HTTP_200_OK);
    response.assertContains("<a href=`/user/new`>Add User</a>".replace("`", "\""));
    response.assertContains("<a href=`/user/edit/1`>Edit</a>".replace("`", "\""));
}
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

ResponseWrapper (org.webpieces.webserver.test.ResponseWrapper)209 HttpFullRequest (org.webpieces.httpclient11.api.HttpFullRequest)204 HttpFullResponse (org.webpieces.httpclient11.api.HttpFullResponse)200 Test (org.junit.Test)189 AbstractWebpiecesTest (org.webpieces.webserver.test.AbstractWebpiecesTest)189 PrivateWebserverForTest (org.webpieces.webserver.PrivateWebserverForTest)174 Header (org.webpieces.httpparser.api.common.Header)39 XFuture (org.webpieces.util.futures.XFuture)11 WebserverForTest (org.webpieces.plugins.fortesting.WebserverForTest)8 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 DataWrapper (org.webpieces.data.api.DataWrapper)2 NotFoundException (org.webpieces.http.exception.NotFoundException)2 AcmeInfo (org.webpieces.plugin.secure.sslcert.acme.AcmeInfo)2 SearchRequest (org.webpieces.webserver.json.app.SearchRequest)2 FetchValueResponse (webpiecesxxxxxpackage.service.FetchValueResponse)2 Counter (io.micrometer.core.instrument.Counter)1 RequiredSearch (io.micrometer.core.instrument.search.RequiredSearch)1