use of org.webpieces.httpclient11.api.HttpFullRequest in project webpieces by deanhiller.
the class TestSyncHibernate method testDbUseWhileRenderingPage.
/**
* Tests when we load user but not company, user.company.name will blow up since company was not
* loaded in the controller from the database.
*
* (ie. we only let you traverse the loaded graph so that we don't accidentally have 1+N queries running)
*/
@Test
public void testDbUseWhileRenderingPage() {
Integer id = loadDataInDb().getId();
verifyLazyLoad(id);
HttpFullRequest req = Requests.createRequest(KnownHttpMethod.GET, "/dynamic/" + id);
XFuture<HttpFullResponse> respFuture = http11Socket.send(req);
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 TestSyncHibernate method testRollback.
@Test
public void testRollback() {
HttpFullRequest req = Requests.createRequest(KnownHttpMethod.GET, "/fail");
mock.addException(() -> {
throw new RuntimeException("for test");
});
XFuture<HttpFullResponse> respFuture = http11Socket.send(req);
ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
response.assertStatusCode(KnownStatusCode.HTTP_500_INTERNAL_SVR_ERROR);
Assert.assertEquals(2, TransactionFilter.getState());
}
use of org.webpieces.httpclient11.api.HttpFullRequest in project webpieces by deanhiller.
the class TestSyncHibernate method testRenderEditPage.
@Test
public void testRenderEditPage() {
int id = loadDataInDb().getId();
HttpFullRequest req = Requests.createRequest(KnownHttpMethod.GET, "/user/edit/" + id);
XFuture<HttpFullResponse> respFuture = http11Socket.send(req);
ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
response.assertStatusCode(KnownStatusCode.HTTP_200_OK);
response.assertContains("name='SomeName' email='dean2@sync.xsoftware.biz'");
}
use of org.webpieces.httpclient11.api.HttpFullRequest in project webpieces by deanhiller.
the class TestSyncHibernate method saveBean.
private String saveBean(String path) {
HttpFullRequest req = Requests.createRequest(KnownHttpMethod.POST, path);
XFuture<HttpFullResponse> respFuture = http11Socket.send(req);
ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
response.assertStatusCode(KnownStatusCode.HTTP_303_SEEOTHER);
return response.getRedirectUrl();
}
use of org.webpieces.httpclient11.api.HttpFullRequest in project webpieces by deanhiller.
the class TestSyncHibernate method readBean.
private void readBean(String redirectUrl, String email) {
HttpFullRequest req = Requests.createRequest(KnownHttpMethod.GET, redirectUrl);
XFuture<HttpFullResponse> respFuture = http11Socket.send(req);
ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
response.assertStatusCode(KnownStatusCode.HTTP_200_OK);
response.assertContains("name=SomeName email=" + email);
}
Aggregations