Search in sources :

Example 46 with FullResponse

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

the class TestDomainMatching method testStaticFileFromDomain2.

@Test
public void testStaticFileFromDomain2() {
    HttpRequest req = Requests.createGetRequest("domain2.com", "/public/myfile");
    httpsSocket.send(req);
    FullResponse response = ResponseExtract.assertSingleResponse(httpsSocket);
    response.assertStatusCode(KnownStatusCode.HTTP_200_OK);
    response.assertContains("org.webpieces.webserver");
}
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 47 with FullResponse

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

the class TestDomainMatching method testDomain2RequestDomain1Route.

@Test
public void testDomain2RequestDomain1Route() {
    HttpRequest req = Requests.createGetRequest("domain2.com", "/domain1");
    httpsSocket.send(req);
    FullResponse response = ResponseExtract.assertSingleResponse(httpsSocket);
    response.assertStatusCode(KnownStatusCode.HTTP_404_NOTFOUND);
    response.assertContains("Your page was not found");
}
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 48 with FullResponse

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

the class TestDomainMatching method testStaticDirFromDomain2.

@Test
public void testStaticDirFromDomain2() {
    HttpRequest req = Requests.createGetRequest("domain2.com", "/public/asyncMeta.txt");
    httpsSocket.send(req);
    FullResponse response = ResponseExtract.assertSingleResponse(httpsSocket);
    response.assertStatusCode(KnownStatusCode.HTTP_200_OK);
    response.assertContains("org.webpieces.webserver");
}
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 49 with FullResponse

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

the class TestJson method testSyncWriteOnlyPost.

@Test
public void testSyncWriteOnlyPost() {
    HttpDummyRequest req = Requests.createJsonRequest(KnownHttpMethod.POST, "/json/write");
    http11Socket.send(req);
    FullResponse response = ResponseExtract.assertSingleResponse(http11Socket);
    response.assertStatusCode(KnownStatusCode.HTTP_200_OK);
    Assert.assertEquals("", response.getBodyAsString());
}
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 50 with FullResponse

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

the class TestJson method testRouteParamConversionFail.

@Test
public void testRouteParamConversionFail() {
    HttpDummyRequest req = Requests.createBadJsonRequest(KnownHttpMethod.POST, "/json/somenotexistroute");
    http11Socket.send(req);
    FullResponse response = ResponseExtract.assertSingleResponse(http11Socket);
    //clearly this url has nothing there
    response.assertStatusCode(KnownStatusCode.HTTP_404_NOTFOUND);
    response.assertContains("{`error`:`This url has no api.  try another url`,`code`:0}".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)

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