
|
If you were logged in you would be able to see more operations.
|
|
WebTest
Created: 28/Nov/07 14:19:25
Updated: 28/Nov/07 17:05:06
|
|
| Affects Version/s: |
2.5
|
| Fix Version/s: |
2.6
|
|
|
Environment:
|
tested on Java JDK 1.6.0_02 / Debian 4.2.2-3 on Linux Kernel 2.6.23 with Groovy 1.0.0
should behave the same way on other platforms
|
|
If getSubject() returns null on a Message (I encountered that on an IMAP box),
doMatch(getSubject(), message.getSubject()) called in AbstractSelectStep.messageMatches fails with a NullPointerException with stack trace like :
java.lang.NullPointerException
at java.util.regex.Matcher.getTextLength(Matcher.java:1140)
at java.util.regex.Matcher.reset(Matcher.java:291)
at java.util.regex.Matcher.<init>(Matcher.java:211)
at java.util.regex.Pattern.matcher(Pattern.java:888)
at com.canoo.webtest.engine.RegExStringVerifier.verifyStrings(RegExStringVerifier.java:28)
at com.canoo.webtest.plugins.emailtest.AbstractSelectStep.doMatch(AbstractSelectStep.java:149)
at com.canoo.webtest.plugins.emailtest.AbstractSelectStep.messageMatches(AbstractSelectStep.java:128)
The code tests if the expected String is null, but not if the actual String is null. Code could be fix like below :
static boolean doMatch(final String expected, final String actual) {
// semantics are: if no expectation then match
if (StringUtils.isEmpty(expected)) {
return true;
}
/* new part */
//semantics are: if no actual string then no match
if (StringUtils.isEmpty(actual)){
return false;
}
/* end of new part */
if (isRegexMatch(expected)) {
return getVerifier(true).verifyStrings(expected.substring(1, expected.length() - 1), actual);
}
return getVerifier(false).verifyStrings(expected, actual);
}
|
Actually, before fixing like above, we should ask ourselves how the cases where both strings are either null or "" should be handled
This will determine the tests to perform, and the order in which they have to be done
Fixed in build 1642.
I've decided to handle null like empty string as it is not clear when Message instance returns null.
|
|