Replace DOMParser with calls to pool or helper class.
[java-idp.git] / tests / edu / internet2 / middleware / shibboleth / common / CredentialsTests.java
index 2698d9c..d96c177 100644 (file)
@@ -38,7 +38,6 @@
 package edu.internet2.middleware.shibboleth.common;
 
 import java.io.FileInputStream;
-import java.io.FileNotFoundException;
 import java.io.InputStream;
 
 import junit.framework.TestCase;
@@ -46,12 +45,8 @@ import junit.framework.TestCase;
 import org.apache.log4j.BasicConfigurator;
 import org.apache.log4j.Level;
 import org.apache.log4j.Logger;
-import org.apache.xerces.parsers.DOMParser;
-import org.xml.sax.EntityResolver;
-import org.xml.sax.ErrorHandler;
 import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
+import edu.internet2.middleware.shibboleth.xml.Parser;
 
 /**
  * Validation suite for the <code>Credentials</code> interface.
@@ -61,7 +56,7 @@ import org.xml.sax.SAXParseException;
 
 public class CredentialsTests extends TestCase {
 
-       private DOMParser parser = new DOMParser();
+       private Parser.DOMParser parser = new Parser.DOMParser(true);
 
        public CredentialsTests(String name) {
                super(name);
@@ -81,55 +76,6 @@ public class CredentialsTests extends TestCase {
         */
        protected void setUp() throws Exception {
                super.setUp();
-               try {
-                       parser.setFeature("http://xml.org/sax/features/validation", true);
-                       parser.setFeature("http://apache.org/xml/features/validation/schema", true);
-                       parser.setEntityResolver(new EntityResolver() {
-                               public InputSource resolveEntity(String publicId, String systemId) throws SAXException {
-
-                                       if (systemId.endsWith("credentials.xsd")) {
-                                               InputStream stream;
-                                               try {
-                                                       stream = new FileInputStream("src/schemas/credentials.xsd");
-                                                       if (stream != null) {
-                                                               return new InputSource(stream);
-                                                       }
-                                                       throw new SAXException("Could not load entity: Null input stream");
-                                               } catch (FileNotFoundException e) {
-                                                       throw new SAXException("Could not load entity: " + e);
-                                               }
-                                       } else if (systemId.endsWith("xmldsig-core-schema.xsd")) {
-                                               InputStream stream;
-                                               try {
-                                                       stream = new FileInputStream("src/schemas/xmldsig-core-schema.xsd");
-                                                       if (stream != null) {
-                                                               return new InputSource(stream);
-                                                       }
-                                                       throw new SAXException("Could not load entity: Null input stream");
-                                               } catch (FileNotFoundException e) {
-                                                       throw new SAXException("Could not load entity: " + e);
-                                               }
-                                       } else {
-                                               return null;
-                                       }
-                               }
-                       });
-
-                       parser.setErrorHandler(new ErrorHandler() {
-                               public void error(SAXParseException arg0) throws SAXException {
-                                       throw new SAXException("Error parsing xml file: " + arg0);
-                               }
-                               public void fatalError(SAXParseException arg0) throws SAXException {
-                                       throw new SAXException("Error parsing xml file: " + arg0);
-                               }
-                               public void warning(SAXParseException arg0) throws SAXException {
-                                       throw new SAXException("Error parsing xml file: " + arg0);
-                               }
-                       });
-               } catch (Exception e) {
-                       fail("Failed to setup xml parser: " + e);
-               }
-
        }
 
        public void testKeyStoreX509CompleteChain() {