Search in sources :

Example 26 with FullResponse

use of org.webpieces.webserver.test.FullResponse in project webpieces by deanhiller.

the class TestAjaxHibernate method testAjaxAddUser.

@Test
public void testAjaxAddUser() {
    HttpDummyRequest req = Requests.createPostRequest("/ajax/user/post", "entity.id", "", "entity.name", "blah1", "entity.firstName", "blah2", "password", "asddd");
    http11Socket.send(req);
    FullResponse response = ResponseExtract.assertSingleResponse(http11Socket);
    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 : FullResponse(org.webpieces.webserver.test.FullResponse) Header(org.webpieces.httpparser.api.common.Header) HttpDummyRequest(org.webpieces.webserver.test.HttpDummyRequest) AbstractWebpiecesTest(org.webpieces.webserver.test.AbstractWebpiecesTest) Test(org.junit.Test) WebserverForTest(org.webpieces.webserver.WebserverForTest)

Example 27 with FullResponse

use of org.webpieces.webserver.test.FullResponse 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);
    HttpRequest req = Requests.createRequest(KnownHttpMethod.GET, "/async/dynamic/" + id);
    http11Socket.send(req);
    List<FullResponse> responses1 = http11Socket.getResponses();
    Assert.assertEquals(0, responses1.size());
    List<Runnable> runnables = mockExecutor.getRunnablesScheduled();
    runnables.get(0).run();
    FullResponse response = ResponseExtract.assertSingleResponse(http11Socket);
    response.assertStatusCode(KnownStatusCode.HTTP_500_INTERNAL_SVR_ERROR);
}
Also used : HttpRequest(org.webpieces.httpparser.api.dto.HttpRequest) FullResponse(org.webpieces.webserver.test.FullResponse) AbstractWebpiecesTest(org.webpieces.webserver.test.AbstractWebpiecesTest) Test(org.junit.Test) WebserverForTest(org.webpieces.webserver.WebserverForTest)

Example 28 with FullResponse

use of org.webpieces.webserver.test.FullResponse in project webpieces by deanhiller.

the class TestAsyncHibernate method readBean.

private void readBean(String redirectUrl, String email) {
    HttpRequest req = Requests.createRequest(KnownHttpMethod.GET, redirectUrl);
    http11Socket.send(req);
    List<FullResponse> responses1 = http11Socket.getResponses();
    Assert.assertEquals(0, responses1.size());
    List<Runnable> runnables = mockExecutor.getRunnablesScheduled();
    runnables.get(0).run();
    FullResponse response = ResponseExtract.assertSingleResponse(http11Socket);
    response.assertStatusCode(KnownStatusCode.HTTP_200_OK);
    response.assertContains("name=SomeName email=" + email);
}
Also used : HttpRequest(org.webpieces.httpparser.api.dto.HttpRequest) FullResponse(org.webpieces.webserver.test.FullResponse)

Example 29 with FullResponse

use of org.webpieces.webserver.test.FullResponse in project webpieces by deanhiller.

the class TestFlashAndSelect method testMultiSelect.

@Test
public void testMultiSelect() {
    HttpDummyRequest req1 = Requests.createPostRequest("/multiselect", "entity.id", user.getId() + "", //invalid first name
    "entity.firstName", //invalid first name
    "NextName", "entity.email", "dean@zz.com", "entity.lastName", "", "entity.password", "", "entity.levelOfEducation", "", "selectedRoles", "j", "selectedRoles", "d");
    http11Socket.send(req1);
    FullResponse response1 = ResponseExtract.assertSingleResponse(http11Socket);
    response1.assertStatusCode(KnownStatusCode.HTTP_303_SEEOTHER);
    String urlPath = "/multiselect/" + user.getId();
    Assert.assertEquals("http://myhost.com" + urlPath, response1.getRedirectUrl());
    HttpRequest req = Requests.createRequest(KnownHttpMethod.GET, urlPath);
    Header cookieHeader = response1.createCookieRequestHeader();
    req.addHeader(cookieHeader);
    http11Socket.send(req);
    FullResponse response = ResponseExtract.assertSingleResponse(http11Socket);
    response.assertStatusCode(KnownStatusCode.HTTP_200_OK);
    response.assertContains("<option value=`b` >Badass</script>".replace('`', '\"'));
    response.assertContains("<option value=`j` selected=`selected`>Jerk</script>".replace('`', '\"'));
    response.assertContains("<option value=`d` selected=`selected`>Delinquint</script>".replace('`', '\"'));
}
Also used : HttpRequest(org.webpieces.httpparser.api.dto.HttpRequest) FullResponse(org.webpieces.webserver.test.FullResponse) Header(org.webpieces.httpparser.api.common.Header) HttpDummyRequest(org.webpieces.webserver.test.HttpDummyRequest) AbstractWebpiecesTest(org.webpieces.webserver.test.AbstractWebpiecesTest) Test(org.junit.Test) WebserverForTest(org.webpieces.webserver.WebserverForTest)

Example 30 with FullResponse

use of org.webpieces.webserver.test.FullResponse in project webpieces by deanhiller.

the class TestFlashAndSelect method testRenderGetMultiselect.

@Test
public void testRenderGetMultiselect() {
    String urlPath = "/multiselect/" + user.getId();
    HttpRequest req = Requests.createRequest(KnownHttpMethod.GET, urlPath);
    http11Socket.send(req);
    FullResponse response = ResponseExtract.assertSingleResponse(http11Socket);
    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 : HttpRequest(org.webpieces.httpparser.api.dto.HttpRequest) FullResponse(org.webpieces.webserver.test.FullResponse) AbstractWebpiecesTest(org.webpieces.webserver.test.AbstractWebpiecesTest) Test(org.junit.Test) WebserverForTest(org.webpieces.webserver.WebserverForTest)

Aggregations

FullResponse (org.webpieces.webserver.test.FullResponse)154 Test (org.junit.Test)142 AbstractWebpiecesTest (org.webpieces.webserver.test.AbstractWebpiecesTest)142 WebserverForTest (org.webpieces.webserver.WebserverForTest)136 HttpRequest (org.webpieces.httpparser.api.dto.HttpRequest)120 HttpDummyRequest (org.webpieces.webserver.test.HttpDummyRequest)32 Header (org.webpieces.httpparser.api.common.Header)16 CompletableFuture (java.util.concurrent.CompletableFuture)11 PlatformOverridesForTest (org.webpieces.webserver.test.PlatformOverridesForTest)9 UserDto (org.webpieces.webserver.basic.app.biz.UserDto)4 UserTestDbo (org.webpieces.plugins.hibernate.app.dbo.UserTestDbo)3 NotFoundException (org.webpieces.router.api.exceptions.NotFoundException)2 ByteBuffer (java.nio.ByteBuffer)1 BufferCreationPool (org.webpieces.data.api.BufferCreationPool)1 DataWrapper (org.webpieces.data.api.DataWrapper)1 DataWrapperGenerator (org.webpieces.data.api.DataWrapperGenerator)1 HttpParser (org.webpieces.httpparser.api.HttpParser)1 MarshalState (org.webpieces.httpparser.api.MarshalState)1