use of jakarta.ws.rs.core.GenericEntity in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method jaxbWriterClientInterceptorTest.
/*
* @testName: jaxbWriterClientInterceptorTest
*
* @assertion_ids: JAXRS:SPEC:84;
*
* @test_Strategy: JAX-RS implementations are REQUIRED to call registered
* interceptors when mapping representations to Java types and vice versa.
*/
@Test
@Tag("xml_binding")
public void jaxbWriterClientInterceptorTest() throws Fault {
JAXBElement<String> element = new JAXBElement<String>(new QName("element"), String.class, content);
GenericEntity<JAXBElement<String>> entity = new GenericEntity<JAXBElement<String>>(element) {
};
addProvider(EntityWriterInterceptor.class);
addInterceptors(EntityWriterInterceptor.class);
setRequestContentEntity(entity);
setProperty(Property.REQUEST, buildRequest(Request.POST, "poststring"));
setProperty(Property.SEARCH_STRING, EntityWriterInterceptor.class.getName());
setProperty(Property.REQUEST_HEADERS, buildContentType(MediaType.TEXT_XML_TYPE));
setProperty(Property.UNEXPECTED_RESPONSE_MATCH, Resource.DIRECTION);
invoke();
logMsg("JAXRS called registered writer interceptor for JAXBElement provider");
}
use of jakarta.ws.rs.core.GenericEntity in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method acceptedGenericEntityTest.
/*
* @testName: acceptedGenericEntityTest
*
* @assertion_ids: JAXRS:JAVADOC:837;
*
* @test_Strategy: Create a new ResponseBuilder with an ACCEPTED status that
* contains a representation. It is the callers responsibility to wrap the
* actual entity with GenericEntity if preservation of its generic type is
* required.
*/
@Test
public void acceptedGenericEntityTest() throws Fault {
VerificationResult result;
String entity = "ENtiTy";
GenericEntity<String> generic = new GenericEntity<String>(entity, String.class);
Response response = Response.accepted(generic).build();
result = verifyStatus(response, Status.ACCEPTED.getStatusCode());
result.append(verifyContent(response, entity));
logMsg(result.message);
assertResultTrue(result);
}
use of jakarta.ws.rs.core.GenericEntity in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method getEntityTypeListStringTest.
/*
* @testName: getEntityTypeListStringTest
*
* @assertion_ids: JAXRS:JAVADOC:438; JAXRS:JAVADOC:455; JAXRS:JAVADOC:456;
* JAXRS:SPEC:85; JAXRS:JAVADOC:427;
*
* @test_Strategy: Get the generic entity type information.
*
* ClientRequestFilter.abortWith
*/
@Test
public void getEntityTypeListStringTest() throws Fault {
ContextProvider provider = new ContextProvider() {
@Override
protected void checkFilterContext(ClientRequestContext context) throws Fault {
Type type = context.getEntityType();
String entity = type.toString();
Response r = Response.ok(entity).build();
context.abortWith(r);
}
};
List<String> list = new ArrayList<String>();
GenericEntity<List<String>> generic = new GenericEntity<List<String>>(list) {
};
Entity<GenericEntity<List<String>>> post = createEntity(generic);
Invocation invocation = buildBuilder(provider).buildPost(post);
Response response = invoke(invocation);
String entity = response.readEntity(String.class);
assertContains(entity, String.class.getName());
}
use of jakarta.ws.rs.core.GenericEntity in project jaxrs-api by eclipse-ee4j.
the class Resource method getJaxbElement.
@GET
@Path("getjaxb")
public Response getJaxbElement() {
JAXBElement<String> element = new JAXBElement<String>(new QName("resource"), String.class, getClass().getName());
GenericEntity<JAXBElement<String>> generic = new GenericEntity<JAXBElement<String>>(element) {
};
return buildResponse(generic, MediaType.TEXT_XML_TYPE);
}
Aggregations