The XML parser test cases get a DocumentBuilderFactory/SAXParserFactory respectivly and unmarshalls an XML document using that parser.
DocumentBuilderFactory factory = XMLParserSupport.provideDocumentBuilderFactory(context, bundle);
factory.setValidating(false);
DocumentBuilder domBuilder = factory.newDocumentBuilder();
URL resURL = context.getBundle().getResource("example-xml-parser.xml");
Document dom = domBuilder.parse(resURL.openStream());
assertNotNull("Document not null", dom);SAXParserFactory factory = XMLParserSupport.provideSAXParserFactory(context, bundle);
factory.setValidating(false);
SAXParser saxParser = factory.newSAXParser();
URL resURL = context.getBundle().getResource("example-xml-parser.xml");
SAXHandler saxHandler = new SAXHandler();
saxParser.parse(resURL.openStream(), saxHandler);
assertEquals("content", saxHandler.getContent());This test uses the OSGi Repository functionality to provision the runtime with the required support functionality like this
XMLParserSupport.provideDocumentBuilderFactory(context, bundle); XMLParserSupport.provideSAXParserFactory(context, bundle);
To enable OSGi Web Application support in AS7 you would configure this capability
<capability name="org.jboss.osgi.xerces:jbosgi-xerces:2.10.0"/>