FSEntityResolver implements EntityResolver { @Override public InputSource resolveEntity(String publicID, String systemID) { InputSource local = null; String url = getEntities().get(publicID); if (url != null) { URL realUrl = FSEntityResolver.class.getResource(url); InputStream is = null; try { is = realUrl.openStream(); } catch (IOException e) { e.printStackTrace(); } if (is == null) { XRLog.log(Level.WARNING, LogMessageId.LogMessageId2Param.XML_ENTITIES_ENTITY_CANT_FIND_LOCAL_REFERENCE, publicID, url); } local = new InputSource(is); local.setSystemId(realUrl.toExternalForm()); XRLog.log(Level.FINE, LogMessageId.LogMessageId2Param.XML_ENTITIES_ENTITY_PUBLIC_NOT_FOUND_OR_LOCAL, publicID, url + (local == null ? ", NOT FOUND" : " (local)")); } else { XRLog.log(Level.INFO, LogMessageId.LogMessageId1Param.XML_ENTITIES_ENTITY_PUBLIC_NO_LOCAL_MAPPING, publicID); local = new InputSource(new StringReader("")); } return local; } private  FSEntityResolver(); @Override InputSource resolveEntity(String publicID,
                                     String systemID); static FSEntityResolver instance(); Map<String, String> getEntities();  }
@Test public void testResolveEntity() throws Exception { FSEntityResolver instance = FSEntityResolver.instance(); String publicId = "- InputSource resolvedEntity = instance.resolveEntity(publicId, null); try (InputStream in = resolvedEntity.getByteStream()) { Assert.assertThat(in, notNullValue()); } }