mbeckerle commented on code in PR #7:
URL: https://github.com/apache/xerces-j/pull/7#discussion_r2021825857


##########
tests/loc/XercesDOMLocationTest.java:
##########
@@ -0,0 +1,136 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package loc;
+
+import junit.framework.TestCase;
+import org.apache.xerces.parsers.DOMParser;
+
+import static 
org.apache.xerces.parsers.XML11Configuration.LOCATION_INFO_FEATURE;
+
+import org.apache.xerces.dom.NodeImpl;
+
+import org.w3c.dom.DOMLocator;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+public class XercesDOMLocationTest extends TestCase {
+
+    private static final String TEST_XML_PATH = "tests/loc/test.xml";
+
+    private static List<Element> getElementChildren(Element parent) {
+        List<Element> result = new ArrayList<>();
+        NodeList children = parent.getChildNodes();
+        for (int i = 0; i < children.getLength(); i++) {
+            Node node = children.item(i);
+            if (node.getNodeType() == Node.ELEMENT_NODE) {
+                result.add((Element) node);
+            }
+        }
+        return result;
+    }
+
+    private Document parseXML(Boolean enableLocationFeature) throws Exception {
+        DOMParser parser = new DOMParser();
+        if (enableLocationFeature != null)
+            parser.setFeature(LOCATION_INFO_FEATURE, enableLocationFeature);
+        parser.parse(new File(TEST_XML_PATH).toURI().toString());
+        Document doc = parser.getDocument();
+        // inspect structure a bit to make sure the parse worked.

Review Comment:
   Added doc and moved into a separate test. All the asserts are in a test 
method now. 



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to