elharo commented on code in PR #103:
URL: https://github.com/apache/xerces-j/pull/103#discussion_r3543634715
##########
tests/dom/ids/Test.java:
##########
@@ -79,280 +79,94 @@ public class Test {
// Public methods
//
- /** Performs the actual test. */
- public void test(Document doc) {
-
+ public void testGetElementById() throws Exception {
System.out.println("DOM IDs Test...");
+
+ ParserWrapper parser = (ParserWrapper)
+ Class.forName(DEFAULT_PARSER_NAME).newInstance();
+
+ parser.setFeature(NAMESPACES_FEATURE_ID, DEFAULT_NAMESPACES);
+ parser.setFeature(VALIDATION_FEATURE_ID, DEFAULT_VALIDATION);
+ parser.setFeature(SCHEMA_VALIDATION_FEATURE_ID,
DEFAULT_SCHEMA_VALIDATION);
+ parser.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID,
DEFAULT_SCHEMA_FULL_CHECKING);
+
+ if (parser instanceof dom.wrappers.Xerces) {
+ parser.setFeature(DEFERRED_DOM_FEATURE_ID, DEFAULT_DEFERRED_DOM);
+ }
+
+ Document doc;
+ try {
+ doc = parser.parse("tests/dom/ids/input.xml");
+ }
+ catch (SAXParseException e) {
+ // ignore
+ return;
+ }
+
Element el = doc.getElementById("one.worker");
- Assertion.verify(el != null);
+ assertTrue("el != null", el != null);
Element el2 = doc.getElementById("one.worker there");
- Assertion.verify(el2 == null);
+ assertTrue("el2 == null", el2 == null);
if (el != null) {
- Assertion.equals(el.getAttribute("id"), "one.worker");
+ assertEquals("el.getAttribute(\"id\")", "one.worker",
el.getAttribute("id"));
el.setAttribute("id", "my.worker");
el2 = doc.getElementById("my.worker");
- Assertion.verify(el2 == el);
-
+ assertTrue("el2 == el", el2 == el);
+
el2 = doc.getElementById("one.worker");
- Assertion.verify(el2 == null);
+ assertTrue("el2 == null", el2 == null);
Review Comment:
assertNull with no message
##########
tests/dom/ids/Test.java:
##########
@@ -79,280 +79,94 @@ public class Test {
// Public methods
//
- /** Performs the actual test. */
- public void test(Document doc) {
-
+ public void testGetElementById() throws Exception {
System.out.println("DOM IDs Test...");
+
+ ParserWrapper parser = (ParserWrapper)
+ Class.forName(DEFAULT_PARSER_NAME).newInstance();
+
+ parser.setFeature(NAMESPACES_FEATURE_ID, DEFAULT_NAMESPACES);
+ parser.setFeature(VALIDATION_FEATURE_ID, DEFAULT_VALIDATION);
+ parser.setFeature(SCHEMA_VALIDATION_FEATURE_ID,
DEFAULT_SCHEMA_VALIDATION);
+ parser.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID,
DEFAULT_SCHEMA_FULL_CHECKING);
+
+ if (parser instanceof dom.wrappers.Xerces) {
+ parser.setFeature(DEFERRED_DOM_FEATURE_ID, DEFAULT_DEFERRED_DOM);
+ }
+
+ Document doc;
+ try {
+ doc = parser.parse("tests/dom/ids/input.xml");
+ }
+ catch (SAXParseException e) {
+ // ignore
+ return;
+ }
+
Element el = doc.getElementById("one.worker");
- Assertion.verify(el != null);
+ assertTrue("el != null", el != null);
Element el2 = doc.getElementById("one.worker there");
- Assertion.verify(el2 == null);
+ assertTrue("el2 == null", el2 == null);
if (el != null) {
- Assertion.equals(el.getAttribute("id"), "one.worker");
+ assertEquals("el.getAttribute(\"id\")", "one.worker",
el.getAttribute("id"));
el.setAttribute("id", "my.worker");
el2 = doc.getElementById("my.worker");
- Assertion.verify(el2 == el);
-
+ assertTrue("el2 == el", el2 == el);
+
el2 = doc.getElementById("one.worker");
- Assertion.verify(el2 == null);
+ assertTrue("el2 == null", el2 == null);
el.removeAttribute("id");
el2 = doc.getElementById("my.worker");
- Assertion.verify(el2 == null);
+ assertTrue("el2 == null", el2 == null);
}
// find default id attribute and check its value
NodeList elementList = doc.getElementsByTagName("person");
Element testEmployee = (Element)elementList.item(1);
Attr id = testEmployee.getAttributeNode("id2");
- Assertion.verify(id.getNodeValue().equals("id02"), "value == 'id02'");
-
+ assertEquals("value == 'id02'", "id02", id.getNodeValue());
Element elem = doc.getElementById("id02");
- Assertion.verify(elem.getNodeName().equals("person"), "return by id
'id02'");
-
- //
+ assertEquals("return by id 'id02'", "person", elem.getNodeName());
+
// remove default attribute and check on retrieval what its value
Attr removedAttr = testEmployee.removeAttributeNode(id);
String value = testEmployee.getAttribute("id2");
- Assertion.verify(value.equals("default.id"), "value='default.id'");
-
+ assertTrue("value='default.id'", value.equals("default.id"));
elem = doc.getElementById("default.id");
- Assertion.verify(elem !=null, "elem by id 'default.id'");
-
+ assertTrue("elem by id 'default.id'", elem != null);
elem = doc.getElementById("id02");
- Assertion.verify(elem ==null, "elem by id '02'");
-
+ assertTrue("elem by id '02'", elem == null);
Review Comment:
assertNull with no message
##########
tests/dom/ids/Test.java:
##########
@@ -79,280 +79,94 @@ public class Test {
// Public methods
//
- /** Performs the actual test. */
- public void test(Document doc) {
-
+ public void testGetElementById() throws Exception {
System.out.println("DOM IDs Test...");
+
+ ParserWrapper parser = (ParserWrapper)
+ Class.forName(DEFAULT_PARSER_NAME).newInstance();
+
+ parser.setFeature(NAMESPACES_FEATURE_ID, DEFAULT_NAMESPACES);
+ parser.setFeature(VALIDATION_FEATURE_ID, DEFAULT_VALIDATION);
+ parser.setFeature(SCHEMA_VALIDATION_FEATURE_ID,
DEFAULT_SCHEMA_VALIDATION);
+ parser.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID,
DEFAULT_SCHEMA_FULL_CHECKING);
+
+ if (parser instanceof dom.wrappers.Xerces) {
+ parser.setFeature(DEFERRED_DOM_FEATURE_ID, DEFAULT_DEFERRED_DOM);
+ }
+
+ Document doc;
+ try {
+ doc = parser.parse("tests/dom/ids/input.xml");
+ }
+ catch (SAXParseException e) {
+ // ignore
+ return;
+ }
+
Element el = doc.getElementById("one.worker");
- Assertion.verify(el != null);
+ assertTrue("el != null", el != null);
Element el2 = doc.getElementById("one.worker there");
- Assertion.verify(el2 == null);
+ assertTrue("el2 == null", el2 == null);
if (el != null) {
- Assertion.equals(el.getAttribute("id"), "one.worker");
+ assertEquals("el.getAttribute(\"id\")", "one.worker",
el.getAttribute("id"));
el.setAttribute("id", "my.worker");
el2 = doc.getElementById("my.worker");
- Assertion.verify(el2 == el);
-
+ assertTrue("el2 == el", el2 == el);
Review Comment:
assertEquals with no message
##########
tests/dom/ids/Test.java:
##########
@@ -79,280 +79,94 @@ public class Test {
// Public methods
//
- /** Performs the actual test. */
- public void test(Document doc) {
-
+ public void testGetElementById() throws Exception {
System.out.println("DOM IDs Test...");
+
+ ParserWrapper parser = (ParserWrapper)
+ Class.forName(DEFAULT_PARSER_NAME).newInstance();
+
+ parser.setFeature(NAMESPACES_FEATURE_ID, DEFAULT_NAMESPACES);
+ parser.setFeature(VALIDATION_FEATURE_ID, DEFAULT_VALIDATION);
+ parser.setFeature(SCHEMA_VALIDATION_FEATURE_ID,
DEFAULT_SCHEMA_VALIDATION);
+ parser.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID,
DEFAULT_SCHEMA_FULL_CHECKING);
+
+ if (parser instanceof dom.wrappers.Xerces) {
+ parser.setFeature(DEFERRED_DOM_FEATURE_ID, DEFAULT_DEFERRED_DOM);
+ }
+
+ Document doc;
+ try {
+ doc = parser.parse("tests/dom/ids/input.xml");
+ }
+ catch (SAXParseException e) {
+ // ignore
+ return;
+ }
+
Element el = doc.getElementById("one.worker");
- Assertion.verify(el != null);
+ assertTrue("el != null", el != null);
Element el2 = doc.getElementById("one.worker there");
- Assertion.verify(el2 == null);
+ assertTrue("el2 == null", el2 == null);
if (el != null) {
- Assertion.equals(el.getAttribute("id"), "one.worker");
+ assertEquals("el.getAttribute(\"id\")", "one.worker",
el.getAttribute("id"));
el.setAttribute("id", "my.worker");
el2 = doc.getElementById("my.worker");
- Assertion.verify(el2 == el);
-
+ assertTrue("el2 == el", el2 == el);
+
el2 = doc.getElementById("one.worker");
- Assertion.verify(el2 == null);
+ assertTrue("el2 == null", el2 == null);
el.removeAttribute("id");
el2 = doc.getElementById("my.worker");
- Assertion.verify(el2 == null);
+ assertTrue("el2 == null", el2 == null);
}
// find default id attribute and check its value
NodeList elementList = doc.getElementsByTagName("person");
Element testEmployee = (Element)elementList.item(1);
Attr id = testEmployee.getAttributeNode("id2");
- Assertion.verify(id.getNodeValue().equals("id02"), "value == 'id02'");
-
+ assertEquals("value == 'id02'", "id02", id.getNodeValue());
Element elem = doc.getElementById("id02");
- Assertion.verify(elem.getNodeName().equals("person"), "return by id
'id02'");
-
- //
+ assertEquals("return by id 'id02'", "person", elem.getNodeName());
+
// remove default attribute and check on retrieval what its value
Attr removedAttr = testEmployee.removeAttributeNode(id);
String value = testEmployee.getAttribute("id2");
- Assertion.verify(value.equals("default.id"), "value='default.id'");
-
+ assertTrue("value='default.id'", value.equals("default.id"));
elem = doc.getElementById("default.id");
- Assertion.verify(elem !=null, "elem by id 'default.id'");
-
+ assertTrue("elem by id 'default.id'", elem != null);
Review Comment:
assertNotNull with no message
##########
tests/dom/ids/Test.java:
##########
@@ -79,280 +79,94 @@ public class Test {
// Public methods
//
- /** Performs the actual test. */
- public void test(Document doc) {
-
+ public void testGetElementById() throws Exception {
System.out.println("DOM IDs Test...");
+
+ ParserWrapper parser = (ParserWrapper)
+ Class.forName(DEFAULT_PARSER_NAME).newInstance();
+
+ parser.setFeature(NAMESPACES_FEATURE_ID, DEFAULT_NAMESPACES);
+ parser.setFeature(VALIDATION_FEATURE_ID, DEFAULT_VALIDATION);
+ parser.setFeature(SCHEMA_VALIDATION_FEATURE_ID,
DEFAULT_SCHEMA_VALIDATION);
+ parser.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID,
DEFAULT_SCHEMA_FULL_CHECKING);
+
+ if (parser instanceof dom.wrappers.Xerces) {
+ parser.setFeature(DEFERRED_DOM_FEATURE_ID, DEFAULT_DEFERRED_DOM);
+ }
+
+ Document doc;
+ try {
+ doc = parser.parse("tests/dom/ids/input.xml");
+ }
+ catch (SAXParseException e) {
+ // ignore
+ return;
+ }
+
Element el = doc.getElementById("one.worker");
- Assertion.verify(el != null);
+ assertTrue("el != null", el != null);
Element el2 = doc.getElementById("one.worker there");
- Assertion.verify(el2 == null);
+ assertTrue("el2 == null", el2 == null);
if (el != null) {
- Assertion.equals(el.getAttribute("id"), "one.worker");
+ assertEquals("el.getAttribute(\"id\")", "one.worker",
el.getAttribute("id"));
el.setAttribute("id", "my.worker");
el2 = doc.getElementById("my.worker");
- Assertion.verify(el2 == el);
-
+ assertTrue("el2 == el", el2 == el);
+
el2 = doc.getElementById("one.worker");
- Assertion.verify(el2 == null);
+ assertTrue("el2 == null", el2 == null);
el.removeAttribute("id");
el2 = doc.getElementById("my.worker");
- Assertion.verify(el2 == null);
+ assertTrue("el2 == null", el2 == null);
Review Comment:
assertNull with no message
##########
tests/dom/ids/Test.java:
##########
@@ -79,280 +79,94 @@ public class Test {
// Public methods
//
- /** Performs the actual test. */
- public void test(Document doc) {
-
+ public void testGetElementById() throws Exception {
System.out.println("DOM IDs Test...");
+
+ ParserWrapper parser = (ParserWrapper)
+ Class.forName(DEFAULT_PARSER_NAME).newInstance();
+
+ parser.setFeature(NAMESPACES_FEATURE_ID, DEFAULT_NAMESPACES);
+ parser.setFeature(VALIDATION_FEATURE_ID, DEFAULT_VALIDATION);
+ parser.setFeature(SCHEMA_VALIDATION_FEATURE_ID,
DEFAULT_SCHEMA_VALIDATION);
+ parser.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID,
DEFAULT_SCHEMA_FULL_CHECKING);
+
+ if (parser instanceof dom.wrappers.Xerces) {
+ parser.setFeature(DEFERRED_DOM_FEATURE_ID, DEFAULT_DEFERRED_DOM);
+ }
+
+ Document doc;
+ try {
+ doc = parser.parse("tests/dom/ids/input.xml");
+ }
+ catch (SAXParseException e) {
+ // ignore
+ return;
+ }
+
Element el = doc.getElementById("one.worker");
- Assertion.verify(el != null);
+ assertTrue("el != null", el != null);
Element el2 = doc.getElementById("one.worker there");
- Assertion.verify(el2 == null);
+ assertTrue("el2 == null", el2 == null);
if (el != null) {
- Assertion.equals(el.getAttribute("id"), "one.worker");
+ assertEquals("el.getAttribute(\"id\")", "one.worker",
el.getAttribute("id"));
el.setAttribute("id", "my.worker");
el2 = doc.getElementById("my.worker");
- Assertion.verify(el2 == el);
-
+ assertTrue("el2 == el", el2 == el);
+
el2 = doc.getElementById("one.worker");
- Assertion.verify(el2 == null);
+ assertTrue("el2 == null", el2 == null);
el.removeAttribute("id");
el2 = doc.getElementById("my.worker");
- Assertion.verify(el2 == null);
+ assertTrue("el2 == null", el2 == null);
}
// find default id attribute and check its value
NodeList elementList = doc.getElementsByTagName("person");
Element testEmployee = (Element)elementList.item(1);
Attr id = testEmployee.getAttributeNode("id2");
- Assertion.verify(id.getNodeValue().equals("id02"), "value == 'id02'");
-
+ assertEquals("value == 'id02'", "id02", id.getNodeValue());
Element elem = doc.getElementById("id02");
- Assertion.verify(elem.getNodeName().equals("person"), "return by id
'id02'");
-
- //
+ assertEquals("return by id 'id02'", "person", elem.getNodeName());
+
// remove default attribute and check on retrieval what its value
Attr removedAttr = testEmployee.removeAttributeNode(id);
String value = testEmployee.getAttribute("id2");
- Assertion.verify(value.equals("default.id"), "value='default.id'");
-
+ assertTrue("value='default.id'", value.equals("default.id"));
elem = doc.getElementById("default.id");
- Assertion.verify(elem !=null, "elem by id 'default.id'");
-
+ assertTrue("elem by id 'default.id'", elem != null);
elem = doc.getElementById("id02");
- Assertion.verify(elem ==null, "elem by id '02'");
-
+ assertTrue("elem by id '02'", elem == null);
+
Element person = (Element)doc.getElementsByTagNameNS(null,
"person").item(0);
person.removeAttribute("id");
person.removeAttribute("id2");
person.setAttributeNS(null, "idAttr", "eb0009");
person.setIdAttribute("idAttr", true);
-
+
elem = doc.getElementById("eb0009");
- Assertion.verify(elem !=null, "elem by id 'eb0009'");
-
+ assertTrue("elem by id 'eb0009'", elem != null);
Review Comment:
in general here and following use assertEquals and assertNull and
assertNotNull and assertSame as appropriate rather than justa ssertTrrue
--
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]