Search in sources :

Example 96 with HttpFullRequest

use of org.webpieces.httpclient11.api.HttpFullRequest 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)

Example 97 with HttpFullRequest

use of org.webpieces.httpclient11.api.HttpFullRequest 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 98 with HttpFullRequest

use of org.webpieces.httpclient11.api.HttpFullRequest 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 99 with HttpFullRequest

use of org.webpieces.httpclient11.api.HttpFullRequest 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 100 with HttpFullRequest

use of org.webpieces.httpclient11.api.HttpFullRequest 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)

Aggregations

HttpFullRequest (org.webpieces.httpclient11.api.HttpFullRequest)222 HttpFullResponse (org.webpieces.httpclient11.api.HttpFullResponse)205 ResponseWrapper (org.webpieces.webserver.test.ResponseWrapper)204 Test (org.junit.Test)194 AbstractWebpiecesTest (org.webpieces.webserver.test.AbstractWebpiecesTest)193 PrivateWebserverForTest (org.webpieces.webserver.PrivateWebserverForTest)180 Header (org.webpieces.httpparser.api.common.Header)50 XFuture (org.webpieces.util.futures.XFuture)13 HttpRequest (org.webpieces.httpparser.api.dto.HttpRequest)12 Http2Header (com.webpieces.http2.api.dto.lowlevel.lib.Http2Header)9 HttpRequestLine (org.webpieces.httpparser.api.dto.HttpRequestLine)9 HttpUri (org.webpieces.httpparser.api.dto.HttpUri)9 WebserverForTest (org.webpieces.plugins.fortesting.WebserverForTest)8 DataWrapper (org.webpieces.data.api.DataWrapper)6 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 ByteBuffer (java.nio.ByteBuffer)2 NotFoundException (org.webpieces.http.exception.NotFoundException)2