Re: [PR] Convert dom.serialization.Test to JUnit [xerc es-j]

mrglavas (via GitHub) <[email protected]> Tue, 14 Jul 2026 19:00:18 -0000
Newsgroups gmane.text.xml.xerces-j.devel
Message-ID <PR_kwDOLzdO6M7vBQQ6-8e0ac28f-7f57-4063-a02b-3e6ea15c53b0@gitbox.apache.org>
mrglavas commented on code in PR #105:
URL: https://github.com/apache/xerces-j/pull/105#discussion_r3581848800


##########
tests/dom/serialization/Test.java:
##########
@@ -17,87 +17,53 @@
 
 package dom.serialization;
 
+import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 
-import org.w3c.dom.Document;
-import org.xml.sax.SAXException;
-
-import dom.ParserWrapper;
-
-/**
- * A java serialization test. This sample program parses a
- * document, then serializes out to a file, then reloads
- * it from the file.  The intent is to have zero exceptions
- * in the process.
- *
- * @author <a href="mailto:[email protected]">Scott Sanders</a>
- * @version $Id$
- */
-public class Test {
+import junit.framework.TestCase;
 
-    protected static final String NAMESPACES_FEATURE_ID = "http://xml.org/sax/features/namespaces";
-
-    protected static final String DEFAULT_PARSER_NAME = "dom.wrappers.Xerces";
-
-    public static void main(String args[]) {
-
-        if (args.length != 2) {
-            System.out.println("Usage: dom.serialization.Test input.xml output.xml");
-            System.exit(1);
-        }
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Text;
 
-        ParserWrapper parser = null;
+import org.apache.xerces.dom.DocumentImpl;
 
-        try {
-            parser = (ParserWrapper) Class.forName(DEFAULT_PARSER_NAME).newInstance();
-        } catch (Exception e) {
-            System.err.println("error: Unable to instantiate parser (" + DEFAULT_PARSER_NAME + ")");
-        }
+public class Test extends TestCase {
 
-        try {
-            parser.setFeature(NAMESPACES_FEATURE_ID, true);
-        } catch (SAXException e) {
-            System.err.println("warning: Parser does not support feature (" + NAMESPACES_FEATURE_ID + ")");
-        }
+    public void testSerializationRoundTrip() throws Exception {
+        DocumentImpl doc = new DocumentImpl();
+        Element root = doc.createElement("root");

Review Comment:
   Should probably be using `createElementNS()` here to be consistent with namespace-aware API usage.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]