DefaultXMLEntityResolver implements EntityResolver { @Override public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { if (systemId != null && !"".equals(systemId)) { InputSource is = search(systemId, null); if (is != null) { return is; } if (this.searchPath != null) { is = search(systemId, this.searchPath); if (is != null) { return is; } } } if (this.emptyExternalResource) { return new InputSource(new ByteArrayInputStream(new byte[0])); } return null; } DefaultXMLEntityResolver();  DefaultXMLEntityResolver(File searchPath);  DefaultXMLEntityResolver(URL searchPath);  DefaultXMLEntityResolver(boolean assumeEmptyExternalResource);  DefaultXMLEntityResolver(File searchPath, boolean assumeEmptyExternalResource);  DefaultXMLEntityResolver(URL searchPath, boolean assumeEmptyExternalResource); @Override InputSource resolveEntity(String publicId, String systemId);  }
@Test public void resolveEntityStringString_resourceUrl() throws Exception { URL resource = Resources.getResource(getClass(), "xmlResource.txt"); InputSource src = this.resolver.resolveEntity(null, resource.toString()); assertNotNull(src); assertNotNull(src.getByteStream()); }
@Test public void resolveEntityStringString_resourceName() throws Exception { String resource = getClass().getPackage().getName().replace('.', '/') + "/xmlResource.txt"; InputSource src = this.resolver.resolveEntity(null, resource); assertNotNull(src); assertNotNull(src.getByteStream()); }