}
private void verifyResult(String testName, SPFResult res) {
String resultSPF = res.getResult();
HashMap currentTest = (HashMap) data.getTests().get(testName);
Logger testLogger = log.getChildLogger(testName+"-verify");
if (currentTest.get("result") instanceof String) {
assertEquals("Test "+testName+" ("+currentTest.get("description")+") failed. Returned: "+resultSPF+" Expected: "+currentTest.get("result")+" [["+resultSPF+"||"+res.getHeaderText()+"]]", currentTest.get("result"), resultSPF);
} else {
ArrayList results = (ArrayList) currentTest.get("result");
boolean match = false;
for (int i = 0; i < results.size(); i++) {
if (results.get(i).equals(resultSPF)) match = true;
// testLogger.debug("checking "+resultSPF+" against allowed result "+results.get(i));
}
assertTrue("Test "+testName+" ("+currentTest.get("description")+") failed. Returned: "+resultSPF+" Expected: "+results, match);
}
if (currentTest.get("explanation") != null) {
// Check for our default explanation!
if (currentTest.get("explanation").equals("DEFAULT")) {
assertTrue(res.getExplanation().startsWith("http://www.openspf.org/why.html?sender="));
} else if (currentTest.get("explanation").equals("cafe:babe::1 is queried as 1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.E.B.A.B.E.F.A.C.ip6.arpa")) {
// See http://java.sun.com/j2se/1.4.2/docs/api/java/net/Inet6Address.html
// For methods that return a textual representation as output value, the full form is used.
// Inet6Address will return the full form because it is unambiguous when used in combination with other textual data.
assertTrue(res.getExplanation().equals("cafe:babe:0:0:0:0:0:1 is queried as 1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.E.B.A.B.E.F.A.C.ip6.arpa"));
} else {
assertEquals(currentTest.get("explanation"),res.getExplanation());
}
}
testLogger.info("PASSED. Result="+resultSPF+" Explanation="+res.getExplanation()+" Header="+res.getHeaderText());
}