@Test
    public void testDOM() throws Exception {
        byte[] bytes = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><document>blah</document>"
                .getBytes(StandardCharsets.UTF_8);
        byte[] injected = injectXML(bytes, ENTITY_EXPANSION_BOMB);
        for (int i = 0; i < XMLReaderUtils.getPoolSize() * 6; i++) {
            try {
                XMLReaderUtils.buildDOM(new ByteArrayInputStream(injected));
                fail("should never parse!");
            } catch (SAXParseException e) {
                //can't rely on message content with different xml parsers/java versions
                //assertTrue(e.getMessage() != null && e.getMessage().contains("entity
                // expansions"));
            }
        }
    }
Tests to confirm defenses against entity expansion attacks.
tika-parsers/tika-parsers-standard/tika-parsers-standard-package/src/test/java/org/apache/tika/parser/TestXMLEntityExpansion.java