use of ee.jakarta.tck.ws.rs.common.provider.StringBean in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method proceedThrowsWebApplicationExceptionTest.
/*
* @testName: proceedThrowsWebApplicationExceptionTest
*
* @assertion_ids: JAXRS:JAVADOC:925; JAXRS:JAVADOC:1008; JAXRS:JAVADOC:920;
* JAXRS:SPEC:85;
*
* @test_Strategy: Throws: WebApplicationException - thrown by the wrapped
* {@code MessageBodyReader.readFrom} method.
*
* Proceed is tested in any of the intercepter tests.
*
* ReaderInterceptor.aroundReadFrom If abortWith is invoked, execution is
* aborted
*/
@Test
public void proceedThrowsWebApplicationExceptionTest() throws Fault {
ResponseBuilder builder = createResponse(ContextOperation.PROCEEDTHROWSWEBAPPEXCEPTION);
Response fake = builder.build();
addProviders(fake);
addProvider(ExceptionThrowingStringBeanEntityProvider.class);
invoke();
// Exception thrown, caught in InterceptorBodyOne
StringBean bean = getResponseBody(ExceptionThrowingStringBean.class);
//
assertContains(bean.get(), TemplateInterceptorBody.WAE, "WebApplicationException has not been thrown and the message is", bean.get());
logMsg("WebApplicationException has been thrown as expected", bean.get());
}
use of ee.jakarta.tck.ws.rs.common.provider.StringBean in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method getHeaderStringUsesToStringTest.
/*
* @testName: getHeaderStringUsesToStringTest
*
* @assertion_ids: JAXRS:JAVADOC:780;
*
* @test_Strategy: Get a HTTP header as a single string value. Each single
* header value is converted to String using its toString method if a header
* delegate is not available.
*/
@Test
public void getHeaderStringUsesToStringTest() throws Fault {
final StringBean bean = new StringBean("bean");
ClientRequestFilter filter = new ClientRequestFilter() {
@Override
public void filter(ClientRequestContext ctx) throws IOException {
ctx.getHeaders().add(bean.get(), bean);
}
};
setProperty(Property.REQUEST, buildRequest(Request.POST, "headerstring"));
setProperty(Property.CONTENT, bean.get());
addProvider(filter);
setProperty(Property.SEARCH_STRING, bean.toString());
invoke();
logMsg("#getHeaderString() returned expected header converted by toString() method");
}
use of ee.jakarta.tck.ws.rs.common.provider.StringBean in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method clientWriterTest.
/* Run test */
/*
* @testName: clientWriterTest
*
* @assertion_ids: JAXRS:SPEC:93; JAXRS:SPEC:93.3; JAXRS:SPEC:94;
* JAXRS:SPEC:95; JAXRS:SPEC:96; JAXRS:SPEC:97; JAXRS:SPEC:98; JAXRS:SPEC:99;
* JAXRS:SPEC:100; JAXRS:JAVADOC:754;
*
* @test_Strategy: @Context available to providers
*
* An instance can be injected into a class field or method parameter using
* the @Context annotation.
*
* The lifecycle of components registered using this class-based register(...)
* method is fully managed by the JAX-RS implementation or any underlying IoC
* container supported by the implementation.
*/
@Test
public void clientWriterTest() throws Fault {
addProvider(StringBeanEntityProviderWithInjectables.class);
setRequestContentEntity(new StringBean("stringbean"));
setProperty(Property.REQUEST, buildRequest(Request.POST, "echo"));
invoke();
assertInjection("@Context injection did not work properly:");
}
use of ee.jakarta.tck.ws.rs.common.provider.StringBean in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method clientReaderTest.
/*
* @testName: clientReaderTest
*
* @assertion_ids: JAXRS:SPEC:93; JAXRS:SPEC:93.3; JAXRS:SPEC:94;
* JAXRS:SPEC:95; JAXRS:SPEC:96; JAXRS:SPEC:97; JAXRS:SPEC:98; JAXRS:SPEC:99;
* JAXRS:SPEC:100; JAXRS:JAVADOC:754;
*
* @test_Strategy: @Context available to providers
*
* An instance can be injected into a class field or method parameter using
* the @Context annotation.
*
* The lifecycle of components registered using this class-based register(...)
* method is fully managed by the JAX-RS implementation or any underlying IoC
* container supported by the implementation.
*/
@Test
public void clientReaderTest() throws Fault {
addProvider(StringBeanEntityProviderWithInjectables.class);
setRequestContentEntity("stringbean");
setProperty(Property.REQUEST, buildRequest(Request.POST, "echo"));
invoke();
StringBean content = getResponseBody(StringBean.class);
assertNotNull(content, "response body is null");
logMsg("Injectables are", content.get());
assertInjection(content.get(), "@Context injection did not work properly:");
}
use of ee.jakarta.tck.ws.rs.common.provider.StringBean in project jaxrs-api by eclipse-ee4j.
the class TextPlainStringBeanEntityProvider method readFrom.
@Override
public StringBean readFrom(Class<StringBean> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException, WebApplicationException {
StringBean bean = super.readFrom(type, genericType, annotations, mediaType, httpHeaders, entityStream);
bean.set(bean.get() + MediaType.TEXT_PLAIN_TYPE.getType() + "/");
return bean;
}
Aggregations