use of org.apache.cxf.jaxrs.resources.Book in project cxf by apache.
the class JAXBElementProviderTest method testReadJAXBElement.
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testReadJAXBElement() throws Exception {
String xml = "<Book><id>123</id><name>CXF in Action</name></Book>";
JAXBElementProvider<JAXBElement> provider = new JAXBElementProvider<JAXBElement>();
JAXBElement<Book> jaxbElement = provider.readFrom(JAXBElement.class, Book.class, new Annotation[0], MediaType.TEXT_XML_TYPE, new MetadataMap<String, String>(), new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8)));
Book book = jaxbElement.getValue();
assertEquals(123L, book.getId());
assertEquals("CXF in Action", book.getName());
}
use of org.apache.cxf.jaxrs.resources.Book in project cxf by apache.
the class ResponseImplTest method testGetEntityUnwrapped.
@Test
public void testGetEntityUnwrapped() {
final Book book = new Book();
Response r = Response.ok().entity(new GenericEntity<Book>(book) {
}).build();
assertSame(book, r.getEntity());
}
Aggregations