You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by el...@apache.org on 2026/07/17 19:27:07 UTC

(xerces-j) branch main updated: Convert schema.Test to JUnit 3 (#111)

This is an automated email from the ASF dual-hosted git repository.

elharo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/xerces-j.git


The following commit(s) were added to refs/heads/main by this push:
     new 30a534e66 Convert schema.Test to JUnit 3 (#111)
30a534e66 is described below

commit 30a534e66449a1439e9c2fa444ba31ba8b199dea
Author: Elliotte Rusty Harold <el...@users.noreply.github.com>
AuthorDate: Fri Jul 17 19:27:02 2026 +0000

    Convert schema.Test to JUnit 3 (#111)
---
 build.xml              |  11 ++---
 tests/schema/Test.java | 115 +++++++------------------------------------------
 2 files changed, 18 insertions(+), 108 deletions(-)

diff --git a/build.xml b/build.xml
index 3f17b5112..b48d8853d 100644
--- a/build.xml
+++ b/build.xml
@@ -845,8 +845,9 @@ Authors:
              <include name="schema/config/UseGrammarPoolOnly_True_Test.class"/>
              <include name="schema/config/UnparsedEntityCheckingTest.class"/>
             -->             
-             <include name="jaxp/JAXPSpecTest.class"/>
-             <include name="dom/ids/Test.class"/>
+              <include name="schema/Test.class"/>
+              <include name="jaxp/JAXPSpecTest.class"/>
+              <include name="dom/ids/Test.class"/>
            </fileset>
          </batchtest>
 
@@ -935,12 +936,6 @@ Authors:
         <arg value="out.xml"/>
     </java>
     
-    <echo message="Running schema.Test..." />
-    <java fork="yes"
-          classname="schema.Test"
-          classpathref="test.classpath"
-          failOnError="yes">
-    </java>
     <echo message="Running jaxp.PropertyTest..." />
     <java fork="yes"
           classname="jaxp.PropertyTest"
diff --git a/tests/schema/Test.java b/tests/schema/Test.java
index 2c423a37c..7bf6da46a 100644
--- a/tests/schema/Test.java
+++ b/tests/schema/Test.java
@@ -17,9 +17,8 @@
 
 package schema;
 
+import junit.framework.TestCase;
 import org.apache.xerces.parsers.SAXParser;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
 import org.xml.sax.helpers.DefaultHandler;
 
 /**
@@ -27,125 +26,41 @@ import org.xml.sax.helpers.DefaultHandler;
  *
  * @author Khaled Noaman, IBM
  */
-public class Test extends DefaultHandler {
-
+public class Test extends TestCase {
 
     // feature ids
-
-    /** Namespaces feature id (http://xml.org/sax/features/namespaces). */
     protected static final String NAMESPACES_FEATURE_ID = "http://xml.org/sax/features/namespaces";
-
-    /** Namespace prefixes feature id (http://xml.org/sax/features/namespace-prefixes). */
     protected static final String NAMESPACE_PREFIXES_FEATURE_ID = "http://xml.org/sax/features/namespace-prefixes";
-
-    /** Validation feature id (http://xml.org/sax/features/validation). */
     protected static final String VALIDATION_FEATURE_ID = "http://xml.org/sax/features/validation";
-
-    /** Schema validation feature id (http://apache.org/xml/features/validation/schema). */
     protected static final String SCHEMA_VALIDATION_FEATURE_ID = "http://apache.org/xml/features/validation/schema";
-
-    /** Schema full checking feature id (http://apache.org/xml/features/validation/schema-full-checking). */
     protected static final String SCHEMA_FULL_CHECKING_FEATURE_ID = "http://apache.org/xml/features/validation/schema-full-checking";
-
-    /** Dynamic validation feature id (http://apache.org/xml/features/validation/dynamic). */
     protected static final String DYNAMIC_VALIDATION_FEATURE_ID = "http://apache.org/xml/features/validation/dynamic";
 
-
     // property ids
-
-    /** schema noNamespaceSchemaLocation property id (http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation). */
     protected static final String SCHEMA_NONS_LOCATION_ID = "http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation";
 
-
     // Default data source location
     protected static final String SOURCE_LOC_ID = "./tests/schema/";
 
-
-    // Default constructor
-    public Test() {
-    }
-
-
-    // ErrorHandler methods
-
-    public void warning(SAXParseException ex) throws SAXException {
-        printError("Warning", ex);
-    }
-
-    public void error(SAXParseException ex) throws SAXException {
-        printError("Error", ex);
-    }
-
-    public void fatalError(SAXParseException ex) throws SAXException {
-        printError("Fatal Error", ex);
-    }
-
-
-    // Protected methods
-    protected void printError(String type, SAXParseException ex) {
-
-        System.err.print("[");
-        System.err.print(type);
-        System.err.print("] ");
-        if (ex== null) {
-            System.out.println("!!!");
-        }
-        String systemId = ex.getSystemId();
-        if (systemId != null) {
-            int index = systemId.lastIndexOf('/');
-            if (index != -1)
-                systemId = systemId.substring(index + 1);
-            System.err.print(systemId);
-        }
-        System.err.print(':');
-        System.err.print(ex.getLineNumber());
-        System.err.print(':');
-        System.err.print(ex.getColumnNumber());
-        System.err.print(": ");
-        System.err.print(ex.getMessage());
-        System.err.println();
-        System.err.flush();
+    public Test(String name) {
+        super(name);
     }
 
     public void testSettingNoNamespaceSchemaLocation() throws Exception {
+        SAXParser parser = new org.apache.xerces.parsers.SAXParser();
 
-        System.err.println("#");
-        System.err.println("# Testing Setting noNamespaceSchemaLocation property");
-        System.err.println("#");
-
-        try {
-            SAXParser parser = new org.apache.xerces.parsers.SAXParser();
-
-            // Set features
-            parser.setFeature(NAMESPACES_FEATURE_ID, true);
-            parser.setFeature(NAMESPACE_PREFIXES_FEATURE_ID, false);
-            parser.setFeature(VALIDATION_FEATURE_ID, true);
-            parser.setFeature(SCHEMA_VALIDATION_FEATURE_ID, true);
-            parser.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID, false);
-            parser.setFeature(DYNAMIC_VALIDATION_FEATURE_ID, false);
-
-            // Set properties
-            parser.setProperty(SCHEMA_NONS_LOCATION_ID, "personal.xsd");
-
-            // Set handlers
-            parser.setContentHandler(this);
-            parser.setErrorHandler(this);
-
-            // parse document
-            parser.parse(SOURCE_LOC_ID + "personal-schema.xml");
-            System.err.println("Pass: " + SOURCE_LOC_ID + "personal-schema.xml");
-            System.err.println();
-        }
-        catch (SAXException e) {
-            System.err.println("Fail:" + e.getMessage());
-        }
-    }
+        parser.setFeature(NAMESPACES_FEATURE_ID, true);
+        parser.setFeature(NAMESPACE_PREFIXES_FEATURE_ID, false);
+        parser.setFeature(VALIDATION_FEATURE_ID, true);
+        parser.setFeature(SCHEMA_VALIDATION_FEATURE_ID, true);
+        parser.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID, false);
+        parser.setFeature(DYNAMIC_VALIDATION_FEATURE_ID, false);
 
+        parser.setProperty(SCHEMA_NONS_LOCATION_ID, "personal.xsd");
 
-    /** Main program entry point. */
-    public static void main(String argv[]) throws Exception {
+        parser.setContentHandler(new DefaultHandler());
+        parser.setErrorHandler(new DefaultHandler());
 
-        Test test = new Test();
-        test.testSettingNoNamespaceSchemaLocation();
+        parser.parse(SOURCE_LOC_ID + "personal-schema.xml");
     }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org