Search in sources :

Example 11 with SuperBook

use of org.apache.cxf.jaxrs.resources.SuperBook in project cxf by apache.

the class JAXBElementProviderTest method testWriteDerivedType.

@Test
public void testWriteDerivedType() throws Exception {
    JAXBElementProvider<Book> provider = new JAXBElementProvider<Book>();
    provider.setJaxbElementClassNames(Collections.singletonList(Book.class.getName()));
    Book b = new SuperBook("CXF in Action", 123L, 124L);
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    provider.writeTo(b, Book.class, Book.class, new Annotation[0], MediaType.TEXT_XML_TYPE, new MetadataMap<String, Object>(), bos);
    readSuperBook(bos.toString(), true);
}
Also used : SuperBook(org.apache.cxf.jaxrs.resources.SuperBook) Book(org.apache.cxf.jaxrs.resources.Book) SuperBook(org.apache.cxf.jaxrs.resources.SuperBook) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Test(org.junit.Test)

Aggregations

SuperBook (org.apache.cxf.jaxrs.resources.SuperBook)11 Test (org.junit.Test)9 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 ByteArrayInputStream (java.io.ByteArrayInputStream)5 HashMap (java.util.HashMap)4 ArrayList (java.util.ArrayList)2 List (java.util.List)2 JAXBContext (javax.xml.bind.JAXBContext)2 ClassResourceInfo (org.apache.cxf.jaxrs.model.ClassResourceInfo)2 Book (org.apache.cxf.jaxrs.resources.Book)2 LinkedHashMap (java.util.LinkedHashMap)1 LinkedList (java.util.LinkedList)1