Search in sources :

Example 71 with FullResponse

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

the class TestJson method testAsyncJsonGet.

@Test
public void testAsyncJsonGet() {
    HttpDummyRequest req = Requests.createJsonRequest(KnownHttpMethod.GET, "/json/async/45");
    http11Socket.send(req);
    FullResponse response = ResponseExtract.assertSingleResponse(http11Socket);
    response.assertStatusCode(KnownStatusCode.HTTP_200_OK);
    response.assertContains("{`searchTime`:8,`matches`:[`match1`,`match2`]}".replace("`", "\""));
    response.assertContentType("application/json");
}
Also used : FullResponse(org.webpieces.webserver.test.FullResponse) HttpDummyRequest(org.webpieces.webserver.test.HttpDummyRequest) Test(org.junit.Test) AbstractWebpiecesTest(org.webpieces.webserver.test.AbstractWebpiecesTest) WebserverForTest(org.webpieces.webserver.WebserverForTest)

Example 72 with FullResponse

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

the class TestStaticPaths method testStaticDir.

@Test
public void testStaticDir() {
    HttpRequest req = Requests.createRequest(KnownHttpMethod.GET, "/public/staticMeta.txt");
    http11Socket.send(req);
    FullResponse response = ResponseExtract.assertSingleResponse(http11Socket);
    response.assertStatusCode(KnownStatusCode.HTTP_200_OK);
    response.assertContains("org.webpieces.webserver.staticpath.app.StaticMeta");
    response.assertContentType("text/plain; charset=utf-8");
}
Also used : HttpRequest(org.webpieces.httpparser.api.dto.HttpRequest) FullResponse(org.webpieces.webserver.test.FullResponse) Test(org.junit.Test) AbstractWebpiecesTest(org.webpieces.webserver.test.AbstractWebpiecesTest) WebserverForTest(org.webpieces.webserver.WebserverForTest)

Example 73 with FullResponse

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

the class TestListGenerator method testListTag.

@Test
public void testListTag() {
    HttpRequest req = Requests.createRequest(KnownHttpMethod.GET, "/list");
    http11Socket.send(req);
    FullResponse response = ResponseExtract.assertSingleResponse(http11Socket);
    response.assertStatusCode(KnownStatusCode.HTTP_200_OK);
    response.assertContains("<td>dean</td><td>5</td><td>red</td>");
    response.assertContains("<td>jeff</td><td>2</td><td>blue</td");
    response.assertNotContains("You have no accounts at this time");
}
Also used : HttpRequest(org.webpieces.httpparser.api.dto.HttpRequest) FullResponse(org.webpieces.webserver.test.FullResponse) Test(org.junit.Test) WebserverForTest(org.webpieces.webserver.WebserverForTest) AbstractWebpiecesTest(org.webpieces.webserver.test.AbstractWebpiecesTest)

Example 74 with FullResponse

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

the class TestListGenerator method testEmptyList.

@Test
public void testEmptyList() {
    HttpRequest req = Requests.createRequest(KnownHttpMethod.GET, "/emptyList");
    http11Socket.send(req);
    FullResponse response = ResponseExtract.assertSingleResponse(http11Socket);
    response.assertStatusCode(KnownStatusCode.HTTP_200_OK);
    response.assertNotContains("<td>dean</td><td>5</td><td>red</td>");
    response.assertNotContains("<td>jeff</td><td>2</td><td>blue</td");
    response.assertContains("You have no accounts at this time");
}
Also used : HttpRequest(org.webpieces.httpparser.api.dto.HttpRequest) FullResponse(org.webpieces.webserver.test.FullResponse) Test(org.junit.Test) WebserverForTest(org.webpieces.webserver.WebserverForTest) AbstractWebpiecesTest(org.webpieces.webserver.test.AbstractWebpiecesTest)

Example 75 with FullResponse

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

the class TestAHrefTag method testAHref.

@Test
public void testAHref() {
    HttpRequest req = Requests.createRequest(KnownHttpMethod.GET, "/ahref");
    http11Socket.send(req);
    FullResponse response = ResponseExtract.assertSingleResponse(http11Socket);
    response.assertStatusCode(KnownStatusCode.HTTP_200_OK);
    response.assertContains("<a href=`/verbatim` id=`myid`>My link2</a>".replace('`', '"'));
    response.assertContains("<a href=`/if`>My render link2</a>".replace('`', '"'));
    response.assertContains("<a href=`/else`>My full route link</a>".replace('`', '"'));
    response.assertContains("<a href=`/redirect/Dean+Hiller`>PureALink</a>".replace('`', '"'));
    response.assertContains("Link but no ahref='/redirect/Dean+Hiller'");
}
Also used : HttpRequest(org.webpieces.httpparser.api.dto.HttpRequest) FullResponse(org.webpieces.webserver.test.FullResponse) Test(org.junit.Test) WebserverForTest(org.webpieces.webserver.WebserverForTest) AbstractWebpiecesTest(org.webpieces.webserver.test.AbstractWebpiecesTest)

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