### Question:
XMLParserUtils { public static SAXParser createXIncludeAwareSAXParser(boolean doBaseURIFixup) { SAXParserFactory factory = SAXParserFactory.newInstance(); factory.setNamespaceAware(true); factory.setXIncludeAware(true); SAXParser parser = null; try { factory.setFeature(Constants.XERCES_FEATURE_PREFIX + Constants.XINCLUDE_FIXUP_BASE_URIS_FEATURE, doBaseURIFixup); parser = factory.newSAXParser(); } catch (Exception x) { throw new RuntimeException(x); } return parser; } private  XMLParserUtils(); static SAXParser createXIncludeAwareSAXParser(boolean doBaseURIFixup);  }### Answer:
@Test public void xincludeParserNoBaseURIFixup() throws SAXException { SAXParser parser = XMLParserUtils.createXIncludeAwareSAXParser(false); assertNotNull(parser); XMLReader reader = parser.getXMLReader(); reader.setFeature("http: boolean baseURIFixup = reader .getFeature(Constants.XERCES_FEATURE_PREFIX + Constants.XINCLUDE_FIXUP_BASE_URIS_FEATURE); assertFalse("Expected feature to be false: " + Constants.XINCLUDE_FIXUP_BASE_URIS_FEATURE, baseURIFixup); }
@Test public void resolveXInclude_omitXMLBase() throws SAXException, IOException { File file = new File("src/test/resources/article.xml"); SAXParser parser = XMLParserUtils.createXIncludeAwareSAXParser(false); XMLReader reader = parser.getXMLReader(); reader.setFeature("http: LegalNoticeHandler handler = new LegalNoticeHandler(); parser.parse(file, handler); }
@Test(expected = AssertionError.class) public void resolveXInclude_keepXMLBase() throws SAXException, IOException { File file = new File("src/test/resources/article.xml"); SAXParser parser = XMLParserUtils.createXIncludeAwareSAXParser(true); XMLReader reader = parser.getXMLReader(); reader.setFeature("http: LegalNoticeHandler handler = new LegalNoticeHandler(); parser.parse(file, handler); }