juergen 2003/09/03 08:29:35
Modified:
testsuite/testsuite/junit/src/org/apache/slide/testsuite/testtools/tprocessor
XMLResponseBodyAssert.java
Log:
1) implement the star operator for xml element list comparison
2) fixed a bug in list repair
3) better display names for method name
Revision Changes Path
1.24 +42 -37
jakarta-slide/testsuite/testsuite/junit/src/org/apache/slide/testsuite/testtools/tprocessor/XMLResponseBodyAssert.java
Index: XMLResponseBodyAssert.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/testsuite/testsuite/junit/src/org/apache/slide/testsuite/testtools/tprocessor/XMLResponseBodyAssert.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- XMLResponseBodyAssert.java 8 Aug 2003 10:37:16 -0000 1.23
+++ XMLResponseBodyAssert.java 3 Sep 2003 15:29:35 -0000 1.24
@@ -152,8 +152,8 @@
// check if either expected and received bodies are not available and
// the expected response code list does not contain more than one response
code
if ( (expectedXmlTree == null ||
- responseDocument() == null ||
- responseDocument().getRootElement()== null)) {
+ responseDocument() == null ||
+ responseDocument().getRootElement()== null)) {
if (expectedResponseCodes.size() <= 1) {
xmlresult.writeElementStart("XMLValueError");
@@ -184,7 +184,7 @@
boolean result = true;
-//System.out.println("########## comparing now " + element1 + " with " +
element2);
+ //System.out.println("########## comparing now " + element1 + " with " +
element2);
// check the name of the element
@@ -213,7 +213,10 @@
// check the count of children
if (children1.size() != children2.size()){
- reportDifferentSizeError(children1, children2, pathName, elementName);
+ if (!element1.getTextTrim().equals("*")) {
+ reportDifferentSizeError(children1, children2, pathName,
elementName);
+ result = false;
+ }
List children1Result = repairElementList(children1, children2,
getPathName(pathName, elementName));
children2 = repairElementList(children2, children1,
getPathName(pathName, elementName));
children1 = children1Result;
@@ -224,22 +227,22 @@
return false;
}
-// if (children1.size() > 3) {
+ // if (children1.size() > 3) {
//
-// Iterator iter = children1.iterator();
-// while (iter.hasNext())
-// {
-// Element element = (Element)iter.next();
-// System.out.println(" element1: " + getDisplayName(element,
elementName));
-// }
-// System.out.println();
-// Iterator iter2 = children2.iterator();
-// while (iter2.hasNext())
-// {
-// Element element = (Element)iter2.next();
-// System.out.println(" element2: " + getDisplayName(element,
elementName));
-// }
-// }
+ // Iterator iter = children1.iterator();
+ // while (iter.hasNext())
+ // {
+ // Element element = (Element)iter.next();
+ // System.out.println(" element1: " +
getDisplayName(element, elementName));
+ // }
+ // System.out.println();
+ // Iterator iter2 = children2.iterator();
+ // while (iter2.hasNext())
+ // {
+ // Element element = (Element)iter2.next();
+ // System.out.println(" element2: " +
getDisplayName(element, elementName));
+ // }
+ // }
// finally check all children too via recursion
@@ -298,26 +301,26 @@
List result = list1;
- List elementNamesToBeRemoved = getChildNames(list2, pathName);
- elementNamesToBeRemoved.removeAll(getChildNames(list1, pathName));
+ List elementNamesToBeRemoved = getChildNames(list1, pathName);
+ elementNamesToBeRemoved.removeAll(getChildNames(list2, pathName));
result = elementsMinusDisplaynames(result, elementNamesToBeRemoved,
pathName);
- //System.out.println("############# list1 " + list1);
- //System.out.println("############# list2 " + list2);
- //System.out.println("############# Set1 " + getChildNames(list1,
pathName));
- //System.out.println("############# Set2 " + getChildNames(list2,
pathName));
- //System.out.println("############# to remove " + elementNamesToBeRemoved);
- //List res = getChildNames(list1, pathName);
- //res.removeAll(elementNamesToBeRemoved);
- //System.out.println("############# expected " + res);
- //System.out.println("############# result " + result);
+//System.out.println("############# list1 " + list1);
+//System.out.println("############# list2 " + list2);
+//System.out.println("############# Set1 " + getChildNames(list1, pathName));
+//System.out.println("############# Set2 " + getChildNames(list2, pathName));
+//System.out.println("############# to remove " + elementNamesToBeRemoved);
+//List res = getChildNames(list1, pathName);
+//res.removeAll(elementNamesToBeRemoved);
+//System.out.println("############# expected " + res);
+//System.out.println("############# result " + result);
List onlyLegalNames = removeLegalNamesFromList(pathName,
getChildNames(result, pathName));
result = elementsRetainDisplaynames(result, onlyLegalNames, pathName);
result = sort(result, pathName);
- //System.out.println("#### repaired list = " + getChildNames(result,
pathName));
+//System.out.println("#### repaired list = " + getChildNames(result, pathName));
return result;
@@ -389,7 +392,7 @@
}
// now perform the check and print out the error message
- if (!expectedValue.equals("*") &&
+ if (!expectedValue.trim().equals("*") &&
!doCompareValues(getPathName(path, name), expectedValue, receivedValue)
){
xmlresult.writeElementStart("XMLValueError");
xmlresult.writeElement("path", getPathName(path, name));
@@ -457,10 +460,12 @@
result = getPathName("/multistatus/response/propstat/status",
e.getChildText("status",e.getNamespace()));
} else if
(fullPathName.equals("/multistatus/response/propstat/prop/supported-report-set/supported-report")
&& e.getChild("report",e.getNamespace()) != null && e.getChildren().size() == 1) {
result =
getPathName("/multistatus/response/propstat/prop/supported-report-set/supported-report/report",
-
((Element)e.getChild("report",e.getNamespace()).getChildren().get(0)).getName());
+
((Element)e.getChild("report",e.getNamespace()).getChildren().get(0)).getName());
} else if
(fullPathName.equals("/multistatus/response/propstat/prop/supported-live-property-set/supported-live-property")
&& e.getChild("prop",e.getNamespace()) != null && e.getChildren().size() == 1) {
result =
getPathName("/multistatus/response/propstat/prop/supported-live-property-set/supported-live-property/prop",
-
((Element)e.getChild("prop",e.getNamespace()).getChildren().get(0)).getName());
+
((Element)e.getChild("prop",e.getNamespace()).getChildren().get(0)).getName());
+ } else if
(fullPathName.equals("/multistatus/response/propstat/prop/supported-method-set/supported-method")
&& e.getAttribute("name") != null) {
+ result = getPathName(fullPathName, e.getAttributeValue("name"));
} else {
result = e.getName();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]