in java/src/org/apache/qetest/trax/LoggingURIResolver.java [255:327]
protected void checkExpected(String desc, String resolvedTo)
{
// Note the order of logging is important, which is why
// we store these values and then log them later
final int DONT_CARE = 0;
final int PASS = 1;
final int FAIL = 2;
int checkResult = DONT_CARE;
String checkDesc = null;
StringBuffer extraInfo = new StringBuffer("");
Hashtable attrs = new Hashtable();
attrs.put("source", "LoggingURIResolver");
attrs.put("counters", getQuickCounters());
attrs.put("resolvedTo", resolvedTo);
String tmp = getQuickCounters() + " " + desc;
if (expectedCtr > expected.length)
{
// Sanity check: prevent AIOOBE
expectedCtr = expected.length;
extraInfo.append(getQuickCounters()
+ " error: array overbounds " + expectedCtr + "\n");
}
// Either log the exception or call checkPass/checkFail
// as requested by setExpected for this type
if (ITEM_DONT_CARE == expected[expectedCtr])
{
// We don't care about this, just log it
extraInfo.append("ITEM_DONT_CARE(" + expectedCtr + ") " + tmp + "\n");
}
else if (ITEM_CHECKFAIL == expected[expectedCtr])
{
// We shouldn't have been called here, so fail
checkResult = FAIL;
checkDesc = tmp + " was unexpected";
}
else if ((null != desc)
&& (desc.indexOf(expected[expectedCtr]) > -1))
{
// We got a warning the user expected, so pass
checkResult = PASS;
checkDesc = tmp + " matched";
// Also reset this counter
expected[expectedCtr] = ITEM_DONT_CARE;
}
else
{
// We got a warning the user didn't expect, so fail
checkResult = FAIL;
checkDesc = tmp + " did not match";
// Also reset this counter
expected[expectedCtr] = ITEM_DONT_CARE;
}
// If we have a list of expected items, increment
if (expected.length > 1)
{
expectedCtr++;
// If we run off the end, reset all expected
if (expectedCtr >= expected.length)
{
extraInfo.append("Ran off end of expected items, resetting\n");
expected = new String[1];
expected[0] = ITEM_DONT_CARE;
expectedCtr = 0;
}
}
logger.logElement(level, "loggingHandler", attrs, extraInfo);
if (PASS == checkResult)
logger.checkPass(checkDesc);
else if (FAIL == checkResult)
logger.checkFail(checkDesc);
// else - DONT_CARE is no-op
}