Author: thomas.diesler(a)jboss.com
Date: 2009-08-28 11:56:12 -0400 (Fri, 28 Aug 2009)
New Revision: 92970
Modified:
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/xml/parser/DOMParserTestCase.java
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/xml/parser/SAXParserTestCase.java
Log:
Use jboss provided service
Modified:
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/xml/parser/DOMParserTestCase.java
===================================================================
---
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/xml/parser/DOMParserTestCase.java 2009-08-28
15:55:41 UTC (rev 92969)
+++
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/xml/parser/DOMParserTestCase.java 2009-08-28
15:56:12 UTC (rev 92970)
@@ -44,6 +44,7 @@
import org.junit.Before;
import org.junit.Test;
import org.osgi.framework.BundleContext;
+import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceReference;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -109,14 +110,15 @@
assertEquals("content", child.getTextContent());
}
- private DocumentBuilder getDocumentBuilder() throws ParserConfigurationException
+ private DocumentBuilder getDocumentBuilder() throws ParserConfigurationException,
InvalidSyntaxException
{
// This service gets registerd by the jboss-osgi-apache-xerces service
- ServiceReference sref =
context.getServiceReference(DocumentBuilderFactory.class.getName());
- if (sref == null)
+ String filter = "(" + XMLParserCapability.PARSER_PROVIDER + "="
+ XMLParserCapability.PROVIDER_JBOSS_OSGI + ")";
+ ServiceReference[] srefs =
context.getServiceReferences(DocumentBuilderFactory.class.getName(), filter);
+ if (srefs == null)
throw new IllegalStateException("DocumentBuilderFactory not
available");
- DocumentBuilderFactory factory = (DocumentBuilderFactory)context.getService(sref);
+ DocumentBuilderFactory factory =
(DocumentBuilderFactory)context.getService(srefs[0]);
factory.setValidating(false);
DocumentBuilder domBuilder = factory.newDocumentBuilder();
Modified:
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/xml/parser/SAXParserTestCase.java
===================================================================
---
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/xml/parser/SAXParserTestCase.java 2009-08-28
15:55:41 UTC (rev 92969)
+++
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/xml/parser/SAXParserTestCase.java 2009-08-28
15:56:12 UTC (rev 92970)
@@ -43,6 +43,7 @@
import org.junit.Before;
import org.junit.Test;
import org.osgi.framework.BundleContext;
+import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceReference;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
@@ -102,14 +103,15 @@
assertEquals("content", saxHandler.getContent());
}
- private SAXParser getSAXParser() throws SAXException, ParserConfigurationException
+ private SAXParser getSAXParser() throws SAXException, ParserConfigurationException,
InvalidSyntaxException
{
// This service gets registerd by the jboss-osgi-apache-xerces service
- ServiceReference sref =
context.getServiceReference(SAXParserFactory.class.getName());
- if (sref == null)
+ String filter = "(" + XMLParserCapability.PARSER_PROVIDER + "="
+ XMLParserCapability.PROVIDER_JBOSS_OSGI + ")";
+ ServiceReference[] srefs =
context.getServiceReferences(SAXParserFactory.class.getName(), filter);
+ if (srefs == null)
throw new IllegalStateException("SAXParserFactory not available");
- SAXParserFactory factory = (SAXParserFactory)context.getService(sref);
+ SAXParserFactory factory = (SAXParserFactory)context.getService(srefs[0]);
factory.setValidating(false);
SAXParser saxParser = factory.newSAXParser();
Show replies by date