tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rf...@apache.org
Subject svn commit: r783170 - /tuscany/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadDocumentTestCase.java
Date Wed, 10 Jun 2009 01:10:10 GMT
Author: rfeng
Date: Wed Jun 10 01:10:10 2009
New Revision: 783170

URL: http://svn.apache.org/viewvc?rev=783170&view=rev
Log:
Disable SAX entity processing to avoid IOException 

Modified:
    tuscany/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadDocumentTestCase.java

Modified: tuscany/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadDocumentTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadDocumentTestCase.java?rev=783170&r1=783169&r2=783170&view=diff
==============================================================================
--- tuscany/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadDocumentTestCase.java
(original)
+++ tuscany/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadDocumentTestCase.java
Wed Jun 10 01:10:10 2009
@@ -50,6 +50,7 @@
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
 import org.xml.sax.XMLReader;
 
 /**
@@ -64,6 +65,7 @@
     private static ModelResolver resolver;
     private static XMLInputFactory inputFactory;
     private static StAXArtifactProcessor<Object> staxProcessor;
+    private static ValidatorHandler handler;
 
     @BeforeClass
     public static void setUp() throws Exception {
@@ -78,24 +80,12 @@
         staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory,
null, null);
 
         resolver = new DefaultModelResolver();
+        handler = getValidationHandler();
+
     }
 
     @Test
     public void testValidateAssembly() throws Exception {
-
-        SchemaFactory schemaFactory;
-        try {
-            schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
-        } catch (Error e) {
-            // Some old JDKs don't support XMLSchema validation
-            return;
-        } catch (Exception e) {
-            // Some old JDKs don't support XMLSchema validation
-            return;
-        }
-        Schema schema = schemaFactory.newSchema(getClass().getClassLoader().getResource(TUSCANY_11_XSD));
-        ValidatorHandler handler = schema.newValidatorHandler();
-
         SAXParserFactory parserFactory = SAXParserFactory.newInstance();
         URL url = getClass().getResource("Calculator.composite");
         XMLReader reader = parserFactory.newSAXParser().getXMLReader();
@@ -105,22 +95,25 @@
 
     }
 
-    @Test
-    public void testValidateImplementation() throws Exception {
-
+    private static ValidatorHandler getValidationHandler() throws SAXException {
         SchemaFactory schemaFactory;
         try {
             schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+            schemaFactory.setFeature("http://xml.org/sax/features/external-parameter-entities",
false);
         } catch (Error e) {
             // Some old JDKs don't support XMLSchema validation
-            return;
+            return null;
         } catch (Exception e) {
             // Some old JDKs don't support XMLSchema validation
-            return;
+            return null;
         }
-        Schema schema = schemaFactory.newSchema(getClass().getClassLoader().getResource(TUSCANY_11_XSD));
+        Schema schema = schemaFactory.newSchema(ReadDocumentTestCase.class.getClassLoader().getResource(TUSCANY_11_XSD));
         ValidatorHandler handler = schema.newValidatorHandler();
+        return handler;
+    }
 
+    @Test
+    public void testValidateImplementation() throws Exception {
         SAXParserFactory parserFactory = SAXParserFactory.newInstance();
         URL url = getClass().getResource("Calculator.composite");
         XMLReader reader = parserFactory.newSAXParser().getXMLReader();
@@ -149,20 +142,6 @@
 
     @Test
     public void testValidateBinding() throws Exception {
-
-        SchemaFactory schemaFactory;
-        try {
-            schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
-        } catch (Error e) {
-            // Some old JDKs don't support XMLSchema validation
-            return;
-        } catch (Exception e) {
-            // Some old JDKs don't support XMLSchema validation
-            return;
-        }
-        Schema schema = schemaFactory.newSchema(getClass().getClassLoader().getResource(TUSCANY_11_XSD));
-        ValidatorHandler handler = schema.newValidatorHandler();
-
         SAXParserFactory parserFactory = SAXParserFactory.newInstance();
         URL url = getClass().getResource("RMIBindingTest.composite");
         XMLReader reader = parserFactory.newSAXParser().getXMLReader();



Mime
View raw message