### Question:
XSLTJaxbProvider extends JAXBElementProvider<T> { public void setOutTemplate(String loc) { outTemplates = createTemplates(loc); }  void setSupportJaxbOnly(boolean support); @Override boolean isReadable(Class<?> type, Type genericType, Annotation[] anns, MediaType mt); @Override boolean isWriteable(Class<?> type, Type genericType, Annotation[] anns, MediaType mt); void setOutTemplate(String loc); void setInTemplate(String loc); void setInMediaTemplates(Map<String, String> map); void setOutMediaTemplates(Map<String, String> map); void setResolver(URIResolver resolver); void setSystemId(String system); void setInParameters(Map<String, Object> inParams); void setOutParameters(Map<String, Object> outParams); void setInProperties(Map<String, String> inProps); void setOutProperties(Map<String, String> outProps); void setInClassNames(List<String> classNames); boolean inClassCanBeHandled(String className); void setOutClassNames(List<String> classNames); boolean outClassCanBeHandled(String className); void setRefreshTemplates(boolean refresh); void setSecureProcessing(boolean secureProcessing);  }### Answer:
@Test public void testWrite() throws Exception { XSLTJaxbProvider<Book> provider = new XSLTJaxbProvider<>(); provider.setOutTemplate(TEMPLATE_LOCATION); provider.setMessageContext(new MessageContextImpl(createMessage())); Book b = new Book(); b.setId(123L); b.setName("TheBook"); ByteArrayOutputStream bos = new ByteArrayOutputStream(); provider.writeTo(b, Book.class, Book.class, b.getClass().getAnnotations(), MediaType.TEXT_XML_TYPE, new MetadataMap<String, Object>(), bos); Unmarshaller um = provider.getClassContext(Book.class).createUnmarshaller(); Book b2 = (Book)um.unmarshal(new StringReader(bos.toString())); b.setName("TheBook2"); assertEquals("Transformation is bad", b, b2); }
@Test public void testWriteToStreamWriter() throws Exception { XSLTJaxbProvider<Book> provider = new XSLTJaxbProvider<Book>() { @Override protected XMLStreamWriter getStreamWriter(Object obj, OutputStream os, MediaType mt) { return StaxUtils.createXMLStreamWriter(os); } }; provider.setOutTemplate(TEMPLATE_LOCATION); provider.setMessageContext(new MessageContextImpl(createMessage())); Book b = new Book(); b.setId(123L); b.setName("TheBook"); ByteArrayOutputStream bos = new ByteArrayOutputStream(); provider.writeTo(b, Book.class, Book.class, b.getClass().getAnnotations(), MediaType.TEXT_XML_TYPE, new MetadataMap<String, Object>(), bos); Unmarshaller um = provider.getClassContext(Book.class).createUnmarshaller(); Book b2 = (Book)um.unmarshal(new StringReader(bos.toString())); b.setName("TheBook2"); assertEquals("Transformation is bad", b, b2); }