SAXSourceEntityProvider implements EntityProvider<SAXSource> { @Override public SAXSource readFrom(Class<SAXSource> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException { return new SAXSource(new InputSource(entityStream)); }  @Override boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType); @Override SAXSource readFrom(Class<SAXSource> type,
                              Type genericType,
                              Annotation[] annotations,
                              MediaType mediaType,
                              MultivaluedMap<String, String> httpHeaders,
                              InputStream entityStream); @Override long getSize(SAXSource t, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType); @Override boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType); @Override void writeTo(SAXSource saxSource,
                        Class<?> type,
                        Type genericType,
                        Annotation[] annotations,
                        MediaType mediaType,
                        MultivaluedMap<String, Object> httpHeaders,
                        OutputStream entityStream);  }
@Test public void readsContentOfEntityStreamAsSAXSource() throws Exception { SAXSource saxSource = saxSourceEntityProvider.readFrom(SAXSource.class, null, null, APPLICATION_XML_TYPE, new MultivaluedMapImpl(), new ByteArrayInputStream(TEST_XML_CONTENT_BYTES)); Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(saxSource.getInputSource()); assertThatXmlDocumentContainsAllExpectedNodes(document); }