Search in sources :

Example 46 with HttpFullRequest

use of org.webpieces.httpclient11.api.HttpFullRequest in project webpieces by deanhiller.

the class TestBootstrapTag method testBootstrap.

@Test
public void testBootstrap() {
    HttpFullRequest req = Requests.createRequest(KnownHttpMethod.GET, "/bootstrap");
    XFuture<HttpFullResponse> respFuture = http11Socket.send(req);
    ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
    response.assertStatusCode(KnownStatusCode.HTTP_200_OK);
    response.assertContains("$(`#editLink_2`).click(function(e){".replaceAll("`", "\""));
    response.assertContains("$('#addEditModal').load('/user/2', function(response, status, xhr){");
    response.assertContains("$(`#editLink_4`).click(function(e){".replaceAll("`", "\""));
    response.assertContains("$('#addEditModal').load('/user/2', function(response, status, xhr){");
}
Also used : HttpFullResponse(org.webpieces.httpclient11.api.HttpFullResponse) HttpFullRequest(org.webpieces.httpclient11.api.HttpFullRequest) ResponseWrapper(org.webpieces.webserver.test.ResponseWrapper) PrivateWebserverForTest(org.webpieces.webserver.PrivateWebserverForTest) Test(org.junit.Test) AbstractWebpiecesTest(org.webpieces.webserver.test.AbstractWebpiecesTest)

Example 47 with HttpFullRequest

use of org.webpieces.httpclient11.api.HttpFullRequest in project webpieces by deanhiller.

the class TestScopes method testGetStaticFileDoesNotClearFlashMessage.

@Test
public void testGetStaticFileDoesNotClearFlashMessage() {
    HttpFullRequest req = Requests.createRequest(KnownHttpMethod.GET, "/flashmessage");
    XFuture<HttpFullResponse> respFuture1 = http11Socket.send(req);
    ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture1);
    response.assertStatusCode(KnownStatusCode.HTTP_200_OK);
    Header header = response.createCookieRequestHeader();
    HttpFullRequest req2 = Requests.createRequest(KnownHttpMethod.GET, "/public/fonts.css");
    req2.addHeader(header);
    XFuture<HttpFullResponse> respFuture = http11Socket.send(req2);
    ResponseWrapper response2 = ResponseExtract.waitResponseAndWrap(respFuture);
    response2.assertStatusCode(KnownStatusCode.HTTP_200_OK);
    Header cookie = response2.getResponse().getHeaderLookupStruct().getHeader(KnownHeaderName.SET_COOKIE);
    Assert.assertNull("static routes should not be clearing cookies or things go south", cookie);
}
Also used : HttpFullResponse(org.webpieces.httpclient11.api.HttpFullResponse) HttpFullRequest(org.webpieces.httpclient11.api.HttpFullRequest) Header(org.webpieces.httpparser.api.common.Header) ResponseWrapper(org.webpieces.webserver.test.ResponseWrapper) PrivateWebserverForTest(org.webpieces.webserver.PrivateWebserverForTest) Test(org.junit.Test) AbstractWebpiecesTest(org.webpieces.webserver.test.AbstractWebpiecesTest)

Example 48 with HttpFullRequest

use of org.webpieces.httpclient11.api.HttpFullRequest in project webpieces by deanhiller.

the class TestIfGenerator method testIfTag.

@Test
public void testIfTag() {
    HttpFullRequest req = Requests.createRequest(KnownHttpMethod.GET, "/if");
    XFuture<HttpFullResponse> respFuture = http11Socket.send(req);
    ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
    response.assertStatusCode(KnownStatusCode.HTTP_200_OK);
    response.assertContains("This should exist");
    response.assertNotContains("Negative1");
    response.assertNotContains("Negative2");
}
Also used : HttpFullResponse(org.webpieces.httpclient11.api.HttpFullResponse) HttpFullRequest(org.webpieces.httpclient11.api.HttpFullRequest) ResponseWrapper(org.webpieces.webserver.test.ResponseWrapper) PrivateWebserverForTest(org.webpieces.webserver.PrivateWebserverForTest) Test(org.junit.Test) AbstractWebpiecesTest(org.webpieces.webserver.test.AbstractWebpiecesTest)

Example 49 with HttpFullRequest

use of org.webpieces.httpclient11.api.HttpFullRequest in project webpieces by deanhiller.

the class TestIfGenerator method testElseIFTag.

@Test
public void testElseIFTag() {
    HttpFullRequest req = Requests.createRequest(KnownHttpMethod.GET, "/elseif");
    XFuture<HttpFullResponse> respFuture = http11Socket.send(req);
    ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
    response.assertStatusCode(KnownStatusCode.HTTP_200_OK);
    response.assertNotContains("This should not exist");
    response.assertContains("This should exist");
    response.assertContains("ElseIf1");
}
Also used : HttpFullResponse(org.webpieces.httpclient11.api.HttpFullResponse) HttpFullRequest(org.webpieces.httpclient11.api.HttpFullRequest) ResponseWrapper(org.webpieces.webserver.test.ResponseWrapper) PrivateWebserverForTest(org.webpieces.webserver.PrivateWebserverForTest) Test(org.junit.Test) AbstractWebpiecesTest(org.webpieces.webserver.test.AbstractWebpiecesTest)

Example 50 with HttpFullRequest

use of org.webpieces.httpclient11.api.HttpFullRequest in project webpieces by deanhiller.

the class TestDomainMatching method testStaticFileFromDomain2.

@Test
public void testStaticFileFromDomain2() {
    HttpFullRequest req = Requests.createGetRequest("domain2.com", "/public2/myfile");
    XFuture<HttpFullResponse> respFuture = httpsSocket.send(req);
    ResponseWrapper response = ResponseExtract.waitResponseAndWrap(respFuture);
    response.assertStatusCode(KnownStatusCode.HTTP_200_OK);
    response.assertContains("org.webpieces.webserver");
}
Also used : HttpFullResponse(org.webpieces.httpclient11.api.HttpFullResponse) HttpFullRequest(org.webpieces.httpclient11.api.HttpFullRequest) ResponseWrapper(org.webpieces.webserver.test.ResponseWrapper) PrivateWebserverForTest(org.webpieces.webserver.PrivateWebserverForTest) Test(org.junit.Test) AbstractWebpiecesTest(org.webpieces.webserver.test.AbstractWebpiecesTest)

Aggregations

HttpFullRequest (org.webpieces.httpclient11.api.HttpFullRequest)222 HttpFullResponse (org.webpieces.httpclient11.api.HttpFullResponse)205 ResponseWrapper (org.webpieces.webserver.test.ResponseWrapper)204 Test (org.junit.Test)194 AbstractWebpiecesTest (org.webpieces.webserver.test.AbstractWebpiecesTest)193 PrivateWebserverForTest (org.webpieces.webserver.PrivateWebserverForTest)180 Header (org.webpieces.httpparser.api.common.Header)50 XFuture (org.webpieces.util.futures.XFuture)13 HttpRequest (org.webpieces.httpparser.api.dto.HttpRequest)12 Http2Header (com.webpieces.http2.api.dto.lowlevel.lib.Http2Header)9 HttpRequestLine (org.webpieces.httpparser.api.dto.HttpRequestLine)9 HttpUri (org.webpieces.httpparser.api.dto.HttpUri)9 WebserverForTest (org.webpieces.plugins.fortesting.WebserverForTest)8 DataWrapper (org.webpieces.data.api.DataWrapper)6 UserDto (org.webpieces.webserver.basic.app.biz.UserDto)4 URL (java.net.URL)3 UserTestDbo (org.webpieces.plugins.hibernate.app.dbo.UserTestDbo)3 URI (java.net.URI)2 ByteBuffer (java.nio.ByteBuffer)2 NotFoundException (org.webpieces.http.exception.NotFoundException)2