Search in sources :

Example 96 with HttpFullResponse

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

the class TestAsyncHibernate method readBean.

private void readBean(String redirectUrl, String email) {
    HttpFullRequest req = Requests.createRequest(KnownHttpMethod.GET, redirectUrl);
    XFuture<HttpFullResponse> respFuture = http11Socket.send(req);
    Assert.assertFalse(respFuture.isDone());
    List<Runnable> runnables = mockExecutor.getRunnablesScheduled();
    runnables.get(0).run();
    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 97 with HttpFullResponse

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

the class TestAsyncHibernate method testDbUseWhileRenderingPage.

/**
 * Tests when we load user but not company, user.company.name in the page will blow up.
 * Database loads must be done in the controllers
 */
@Test
public void testDbUseWhileRenderingPage() {
    Integer id = TestSyncHibernate.loadDataInDb().getId();
    TestSyncHibernate.verifyLazyLoad(id);
    HttpFullRequest req = Requests.createRequest(KnownHttpMethod.GET, "/async/dynamic/" + id);
    XFuture<HttpFullResponse> respFuture = http11Socket.send(req);
    Assert.assertFalse(respFuture.isDone());
    List<Runnable> runnables = mockExecutor.getRunnablesScheduled();
    runnables.get(0).run();
    ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
    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 98 with HttpFullResponse

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

the class TestAjaxHibernate method testNotFoundInSubRoute.

@Test
public void testNotFoundInSubRoute() {
    HttpFullRequest req = Requests.createRequest(KnownHttpMethod.GET, "/ajax/notfound");
    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) AbstractWebpiecesTest(org.webpieces.webserver.test.AbstractWebpiecesTest) PrivateWebserverForTest(org.webpieces.webserver.PrivateWebserverForTest) Test(org.junit.Test)

Example 99 with HttpFullResponse

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

the class TestAjaxHibernate method testAjaxAddUser.

@Test
public void testAjaxAddUser() {
    HttpFullRequest req = Requests.createPostRequest("/ajax/user/post", "entity.id", "", "entity.name", "blah1", "entity.firstName", "blah2", "password", "asddd");
    XFuture<HttpFullResponse> respFuture = http11Socket.send(req);
    ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
    response.assertStatusCode(KnownStatusCode.HTTP_303_SEEOTHER);
    Assert.assertEquals("http://myhost.com/ajax/user/list", response.getRedirectUrl());
    Header header = response.createCookieRequestHeader();
    Assert.assertTrue("contents actually was=" + header.getValue(), header.getValue().contains("User+successfully+saved"));
}
Also used : HttpFullResponse(org.webpieces.httpclient11.api.HttpFullResponse) HttpFullRequest(org.webpieces.httpclient11.api.HttpFullRequest) Header(org.webpieces.httpparser.api.common.Header) ResponseWrapper(org.webpieces.webserver.test.ResponseWrapper) AbstractWebpiecesTest(org.webpieces.webserver.test.AbstractWebpiecesTest) PrivateWebserverForTest(org.webpieces.webserver.PrivateWebserverForTest) Test(org.junit.Test)

Example 100 with HttpFullResponse

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

the class TestFlashAndSelect method testRenderGetMultiselect.

@Test
public void testRenderGetMultiselect() {
    String urlPath = "/multiselect/" + user.getId();
    HttpFullRequest req = Requests.createRequest(KnownHttpMethod.GET, urlPath);
    XFuture<HttpFullResponse> respFuture = http11Socket.send(req);
    ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
    response.assertStatusCode(KnownStatusCode.HTTP_200_OK);
    // assert the nulls came through
    response.assertContains("<option value=`b` selected=`selected`>Badass</script>".replace('`', '\"'));
    response.assertContains("<option value=`j` >Jerk</script>".replace('`', '\"'));
    response.assertContains("<option value=`d` selected=`selected`>Delinquint</script>".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

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