println(expectedStr);
}
final String compareForm = output.getAttribute("compare");
if("XML".equals(compareForm)) {
Diff diff = new Diff(expectedStr, resString);
if(diff.similar()) {
reportTestResult(testName, "pass", null);
break;
} else {
if(oi == lastoi) {
String errmsg = diff.toString();
reportTestResult(testName, "fail", errmsg);
Assert.fail(errmsg);
}
}
} else if("Fragment".equals(compareForm)) {
Document expectedDoc = _expectedDocumentCache.get(expFileName);
if(expectedDoc == null) {
expectedDoc = buildFragment(expectedStr);
_expectedDocumentCache.put(expFileName, expectedDoc);
}
String actual = "<doc>" + resString + "</doc>";
Document actualDoc = buildDocument(new ByteArrayInputStream(actual.getBytes("UTF-8")));
Diff diff = new Diff(expectedDoc, actualDoc);
if(diff.similar()) {
reportTestResult(testName, "pass", null);
break;
} else {
if(oi == lastoi) {
String errmsg = diff.toString();
reportTestResult(testName, "fail", errmsg);
Assert.fail(errmsg);
}
}
} else if("Text".equals(compareForm)) {
if(expectedStr.equals(resString)) {
reportTestResult(testName, "pass", null);
break;
} else {
Document expectedDoc = _expectedDocumentCache.get(expFileName);
if(expectedDoc == null) {
expectedDoc = buildFragment(expectedStr);
_expectedDocumentCache.put(expFileName, expectedDoc);
}
String actual = "<doc>" + XMLUtils.escapeXML(resString) + "</doc>";
Document actualDoc = buildDocument(new ByteArrayInputStream(actual.getBytes("UTF-8")));
Diff diff = new Diff(expectedDoc, actualDoc);
if(diff.identical()) {
reportTestResult(testName, "pass", null);
break;
} else {
if(oi == lastoi) {
String errmsg = new ComparisonFailure("[Text comparison]", expectedStr, resString).getMessage();
reportTestResult(testName, "fail", errmsg);
Assert.assertEquals("[Text comparison]", expectedStr, resString);
}
}
}
} else if("Ignore".equals(compareForm)) {
// no comparison needs to be applied; the result is always true
// if the implementation successfully executes the test case.
reportTestResult(testName, "pass", null);
break;
} else if("Inspect".equals(compareForm)) {
System.err.println("#" + i + " Inspection is required");
Document expectedDoc = _expectedDocumentCache.get(expFileName);
if(expectedDoc == null) {
expectedDoc = buildFragment(expectedStr);
_expectedDocumentCache.put(expFileName, expectedDoc);
}
String actual = "<doc>" + resString + "</doc>";
Document actualDoc = buildDocument(new ByteArrayInputStream(actual.getBytes("UTF-8")));
Diff diff = new Diff(expectedDoc, actualDoc);
if(diff.similar()) {
reportTestResult(testName, "pass", null);
break;
} else {
if(oi == lastoi) {
reportTestResult(testName, "not tested", "Inspectection is required");
}
}
if(ispect && !diff.similar()) {
if(oi == lastoi) {
Assert.fail("Inspectection is required: \n" + diff.toString());
}
}
} else {
String errmsg = "[BUG] could'nt compare in " + compareForm;
reportTestResult(testName, "fail", errmsg);