Search in sources :

Example 1 with RestSupportImpl

use of org.apache.tapestry5.http.internal.services.RestSupportImpl in project tapestry-5 by apache.

the class RestSupportImplTest method get_request_body_as_null_result.

@Test
public void get_request_body_as_null_result() {
    HttpRequestBodyConverter converter = new TestHttpRequestBodyConverter(null);
    RestSupport restSupport = new RestSupportImpl(null, converter);
    Optional<String> result = restSupport.getRequestBodyAs(String.class);
    assertFalse(result.isPresent());
}
Also used : HttpRequestBodyConverter(org.apache.tapestry5.http.services.HttpRequestBodyConverter) RestSupportImpl(org.apache.tapestry5.http.internal.services.RestSupportImpl) RestSupport(org.apache.tapestry5.http.services.RestSupport) Test(org.testng.annotations.Test)

Example 2 with RestSupportImpl

use of org.apache.tapestry5.http.internal.services.RestSupportImpl in project tapestry-5 by apache.

the class RestSupportImplTest method get_request_body_as_result_provided.

@Test
public void get_request_body_as_result_provided() {
    final String TEXT_CONTENT = "asdfadfasdfs";
    HttpRequestBodyConverter converter = new TestHttpRequestBodyConverter(TEXT_CONTENT);
    RestSupport restSupport = new RestSupportImpl(null, converter);
    Optional<String> result = restSupport.getRequestBodyAs(String.class);
    assertTrue(result.isPresent());
    assertEquals(result.get(), TEXT_CONTENT);
}
Also used : HttpRequestBodyConverter(org.apache.tapestry5.http.services.HttpRequestBodyConverter) RestSupportImpl(org.apache.tapestry5.http.internal.services.RestSupportImpl) RestSupport(org.apache.tapestry5.http.services.RestSupport) Test(org.testng.annotations.Test)

Example 3 with RestSupportImpl

use of org.apache.tapestry5.http.internal.services.RestSupportImpl in project tapestry-5 by apache.

the class RestSupportImplTest method test.

private void test(String method, byte[] body, Consumer<RestSupport> testCode) throws IOException {
    HttpServletRequest request = createRequest(method, body);
    RestSupport restSupport = new RestSupportImpl(request, null);
    testCode.accept(restSupport);
    EasyMock.verify(request);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) RestSupportImpl(org.apache.tapestry5.http.internal.services.RestSupportImpl) RestSupport(org.apache.tapestry5.http.services.RestSupport)

Aggregations

RestSupportImpl (org.apache.tapestry5.http.internal.services.RestSupportImpl)3 RestSupport (org.apache.tapestry5.http.services.RestSupport)3 HttpRequestBodyConverter (org.apache.tapestry5.http.services.HttpRequestBodyConverter)2 Test (org.testng.annotations.Test)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)1