Search in sources :

Example 86 with FullResponse

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

the class TestFlashAndSelect method testAssertBeanNoNullsOnLastNameAndEnum.

@Test
public void testAssertBeanNoNullsOnLastNameAndEnum() {
    String urlPath = "/user/edit/" + 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("<input type=`text` name=`entity.lastName` value=`Hill` class=`input-xlarge`>".replace('`', '\"'));
    response.assertContains("<option value=`` >Unselected</option>".replace('`', '\"'));
    response.assertContains("<option value=`k` selected=`selected`>Kindergarten</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)

Example 87 with FullResponse

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

the class TestSyncHibernate method testHibernateNoUserIdWillSaveNewUser.

@Test
public void testHibernateNoUserIdWillSaveNewUser() {
    String email = "test2";
    HttpDummyRequest req = Requests.createPostRequest("/testmerge", "user.id", "", "user.email", email, "user.name", "blah1", "user.firstName", "blah2", "user.levelOfEducation", LevelEducation.COLLEGE.getDbCode() + "");
    http11Socket.send(req);
    FullResponse response = ResponseExtract.assertSingleResponse(http11Socket);
    response.assertStatusCode(KnownStatusCode.HTTP_303_SEEOTHER);
    UserTestDbo user2 = loadByEmail(email);
    //name changed
    Assert.assertEquals("blah1", user2.getName());
    //firstname changed
    Assert.assertEquals("blah2", user2.getFirstName());
    Assert.assertEquals(LevelEducation.COLLEGE, user2.getLevelOfEducation());
}
Also used : FullResponse(org.webpieces.webserver.test.FullResponse) UserTestDbo(org.webpieces.plugins.hibernate.app.dbo.UserTestDbo) HttpDummyRequest(org.webpieces.webserver.test.HttpDummyRequest) AbstractWebpiecesTest(org.webpieces.webserver.test.AbstractWebpiecesTest) Test(org.junit.Test) WebserverForTest(org.webpieces.webserver.WebserverForTest)

Example 88 with FullResponse

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

the class TestAsyncHibernate method saveBean.

private String saveBean(String path) {
    HttpRequest req = Requests.createRequest(KnownHttpMethod.POST, path);
    http11Socket.send(req);
    List<FullResponse> responses1 = http11Socket.getResponses();
    Assert.assertEquals(0, responses1.size());
    List<Runnable> runnables = mockExecutor.getRunnablesScheduled();
    runnables.get(0).run();
    mockExecutor.clear();
    FullResponse response = ResponseExtract.assertSingleResponse(http11Socket);
    response.assertStatusCode(KnownStatusCode.HTTP_303_SEEOTHER);
    Header header = response.getResponse().getHeaderLookupStruct().getHeader(KnownHeaderName.LOCATION);
    String url = header.getValue();
    return url;
}
Also used : HttpRequest(org.webpieces.httpparser.api.dto.HttpRequest) FullResponse(org.webpieces.webserver.test.FullResponse) Header(org.webpieces.httpparser.api.common.Header)

Example 89 with FullResponse

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

the class TestSyncHibernate method testHibernatePostPartialDataDoesntBlowDataAway.

@Test
public void testHibernatePostPartialDataDoesntBlowDataAway() {
    UserTestDbo user = loadDataInDb();
    HttpDummyRequest req = Requests.createPostRequest("/testmerge", "user.id", user.getId() + "", "user.name", "blah1", "user.firstName", "blah2");
    http11Socket.send(req);
    FullResponse response = ResponseExtract.assertSingleResponse(http11Socket);
    response.assertStatusCode(KnownStatusCode.HTTP_303_SEEOTHER);
    UserTestDbo user2 = load(user.getId());
    //name changed
    Assert.assertEquals("blah1", user2.getName());
    //firstname changed
    Assert.assertEquals("blah2", user2.getFirstName());
    //lastname remained the same
    Assert.assertEquals(user.getLastName(), user2.getLastName());
}
Also used : FullResponse(org.webpieces.webserver.test.FullResponse) UserTestDbo(org.webpieces.plugins.hibernate.app.dbo.UserTestDbo) HttpDummyRequest(org.webpieces.webserver.test.HttpDummyRequest) AbstractWebpiecesTest(org.webpieces.webserver.test.AbstractWebpiecesTest) Test(org.junit.Test) WebserverForTest(org.webpieces.webserver.WebserverForTest)

Example 90 with FullResponse

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

the class TestSyncHibernate method testRenderAddPage.

@Test
public void testRenderAddPage() {
    HttpRequest req = Requests.createRequest(KnownHttpMethod.GET, "/user/new");
    http11Socket.send(req);
    FullResponse response = ResponseExtract.assertSingleResponse(http11Socket);
    response.assertStatusCode(KnownStatusCode.HTTP_200_OK);
    response.assertContains("name='' email=''");
}
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