use of org.webpieces.webserver.test.ResponseWrapper 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.webserver.test.ResponseWrapper 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.webserver.test.ResponseWrapper 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.webserver.test.ResponseWrapper 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"));
}
use of org.webpieces.webserver.test.ResponseWrapper 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('`', '\"'));
}
Aggregations