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("`", "\""));
}
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);
}
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);
}
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");
}
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"));
}
Aggregations