Search in sources :

Example 76 with ResponseWrapper

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

the class TestSynchronousErrors 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 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 77 with ResponseWrapper

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

the class TestBeansAndSplit method create.

private ResponseWrapper create() {
    List<HttpPayload> payloads = parser.parse(dataReceived);
    HttpResponse response = (HttpResponse) payloads.get(0);
    DataWrapper all = dataGen.emptyWrapper();
    for (int i = 1; i < payloads.size(); i++) {
        HttpData d = (HttpData) payloads.get(i);
        all = dataGen.chainDataWrappers(all, d.getBodyNonNull());
    }
    HttpFullResponse fResponse = new HttpFullResponse(response, all);
    return new ResponseWrapper(fResponse);
}
Also used : DataWrapper(org.webpieces.data.api.DataWrapper) HttpFullResponse(org.webpieces.httpclient11.api.HttpFullResponse) HttpPayload(org.webpieces.httpparser.api.dto.HttpPayload) HttpData(org.webpieces.httpparser.api.dto.HttpData) HttpResponse(org.webpieces.httpparser.api.dto.HttpResponse) ResponseWrapper(org.webpieces.webserver.test.ResponseWrapper)

Example 78 with ResponseWrapper

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

the class TestBeans method testBeanMissingForGetSoNotFoundResults.

@Test
public void testBeanMissingForGetSoNotFoundResults() {
    HttpFullRequest req = Requests.createRequest(KnownHttpMethod.GET, "/getuser?user.firstName=jeff&password=as");
    XFuture<HttpFullResponse> respFuture = http11Socket.send(req);
    ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
    response.assertStatusCode(KnownStatusCode.HTTP_303_SEEOTHER);
}
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 79 with ResponseWrapper

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

the class TestBeans method testArraySaved.

@Test
public void testArraySaved() {
    HttpFullRequest req = Requests.createPostRequest("/postArray2", "user.accounts[1].name", "Account2Name", "user.accounts[1].color", "green", "user.accounts[2].addresses[0].number", "56", "user.firstName", "D&D", "user.lastName", "Hiller", "user.fullName", "Dean Hiller");
    XFuture<HttpFullResponse> respFuture = http11Socket.send(req);
    ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
    response.assertStatusCode(KnownStatusCode.HTTP_303_SEEOTHER);
    UserDto user = mockSomeLib.getUser();
    Assert.assertEquals("D&D", user.getFirstName());
    Assert.assertEquals(3, user.getAccounts().size());
    Assert.assertEquals("Account2Name", user.getAccounts().get(1).getName());
    Assert.assertEquals(56, user.getAccounts().get(2).getAddresses().get(0).getNumber());
}
Also used : HttpFullResponse(org.webpieces.httpclient11.api.HttpFullResponse) HttpFullRequest(org.webpieces.httpclient11.api.HttpFullRequest) UserDto(org.webpieces.webserver.basic.app.biz.UserDto) ResponseWrapper(org.webpieces.webserver.test.ResponseWrapper) AbstractWebpiecesTest(org.webpieces.webserver.test.AbstractWebpiecesTest) PrivateWebserverForTest(org.webpieces.webserver.PrivateWebserverForTest) Test(org.junit.Test)

Example 80 with ResponseWrapper

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

the class TestBeans method testComplexBeanSaved.

@Test
public void testComplexBeanSaved() {
    HttpFullRequest req = Requests.createPostRequest("/postuser2", "user.firstName", "D&D", "user.lastName", "Hiller", "user.fullName", "Dean Hiller", "user.address.zipCode", "555", "user.address.street", "Coolness Dr.");
    XFuture<HttpFullResponse> respFuture = http11Socket.send(req);
    ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
    response.assertStatusCode(KnownStatusCode.HTTP_303_SEEOTHER);
    UserDto user = mockSomeOtherLib.getUser();
    Assert.assertEquals(555, user.getAddress().getZipCode());
    Assert.assertEquals("D&D", user.getFirstName());
    Assert.assertEquals("Coolness Dr.", user.getAddress().getStreet());
}
Also used : HttpFullResponse(org.webpieces.httpclient11.api.HttpFullResponse) HttpFullRequest(org.webpieces.httpclient11.api.HttpFullRequest) UserDto(org.webpieces.webserver.basic.app.biz.UserDto) 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