Search in sources :

Example 81 with HttpFullResponse

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

the class TestBeans method testInvalidComplexBean.

@Test
public void testInvalidComplexBean() {
    HttpFullRequest req = Requests.createPostRequest("/postuser2", "user.firstName", "D&D", "user.lastName", "Hiller", "user.fullName", "Dean Hiller", "user.address.zipCode", "This test value invalid since not an int", "user.address.street", "Coolness Dr.", "password", "should be hidden from flash");
    XFuture<HttpFullResponse> respFuture = http11Socket.send(req);
    ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
    response.assertStatusCode(KnownStatusCode.HTTP_303_SEEOTHER);
    UserDto savedUser = mockSomeOtherLib.getUser();
    // user was not
    Assert.assertEquals(null, savedUser);
    UserDto user = mockSomeLib.getUser();
    // this is not set since it was invalid
    Assert.assertEquals(0, 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)

Example 82 with HttpFullResponse

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

the class TestBeans method testPageParam.

@Test
public void testPageParam() {
    HttpFullRequest req = Requests.createRequest(KnownHttpMethod.GET, "/pageparam");
    XFuture<HttpFullResponse> respFuture = http11Socket.send(req);
    ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
    response.assertStatusCode(KnownStatusCode.HTTP_200_OK);
    response.assertContains("Hi Dean Hiller, this is testing");
    response.assertContains("Or we can try to get a flash: testflashvalue");
}
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 83 with HttpFullResponse

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

the class TestBeans method testPostFailDueToSecureTokenCheck.

@Test
public void testPostFailDueToSecureTokenCheck() {
    HttpFullRequest req = Requests.createPostRequest("/postuser", "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);
    // We should change this to a 400 bad request
    response.assertStatusCode(KnownStatusCode.HTTP_500_INTERNAL_SVR_ERROR);
}
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 84 with HttpFullResponse

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

the class TestBeans method testArrayForm.

@Test
public void testArrayForm() {
    HttpFullRequest req = Requests.createRequest(KnownHttpMethod.GET, "/arrayForm");
    XFuture<HttpFullResponse> respFuture = http11Socket.send(req);
    ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
    response.assertStatusCode(KnownStatusCode.HTTP_200_OK);
    response.assertContains("value=`FirstAccName`".replace('`', '"'));
    response.assertContains("value=`SecondAccName`".replace('`', '"'));
    response.assertContains("value=`someStreet2-0`".replace('`', '"'));
    response.assertContains("value=`someStreet2-1`".replace('`', '"'));
    // default labels are there...
    response.assertContains("First NameX");
    response.assertContains("StreetX");
}
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 85 with HttpFullResponse

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

the class TestBeans method testNullIdFromForm.

/**
 * Found this bug where it blew up translating 'null' to 'null' and tried to convert it
 *  to int instead, so added test then fixed
 */
@Test
public void testNullIdFromForm() {
    HttpFullRequest req = Requests.createPostRequest("/postuser2", // multipart is "" and nearly all webservers convert that to null(including ours)
    "user.id", // multipart is "" and nearly all webservers convert that to null(including ours)
    "");
    XFuture<HttpFullResponse> respFuture = http11Socket.send(req);
    ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
    response.assertStatusCode(KnownStatusCode.HTTP_303_SEEOTHER);
    // should not have any errors and should redirect back to list of users page..
    Assert.assertEquals("http://myhost.com/listusers", response.getRedirectUrl());
}
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