AbstractSelectStep.doMatch(String,String) failed when the second parameter is
null
----------------------------------------------------------------------------------
Key: WT-356
URL: http://webtest-community.canoo.com/jira/browse/WT-356
Project: WebTest
Type: Bug
Versions: 2.5
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
Reporter: Florent Blondeau
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);
}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://webtest-community.canoo.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
_______________________________________________
WebTest mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/webtest