#655 Contains assertion substring match issue

v1.0 (example)
open
nobody
None
5
2014-03-07
2013-09-05
Keith Tyler
No

When a Contains Assertion is used in normal mode, it performs a substring match on the source property (e.g. a message response). But when "Use regular expression" is checked, it does a full-string match on the source property. With no wildcards or character classes (etc.) in the test string, the same string should work whether or not regular expression mode is on, but it doesn't. The same string that works in non-regex mode has to be bookended with ".*"s in order to work in regex mode. This is inconsistent, and violates the functional description of the assertion type: "Searches for the existence of a string in the property value". That is also normal behavior for all well-known regular expression applications e.g. grep, sed, preg_match, etc.

Looking at Java specifics on regular expressions, the underlying issue is probably that Contains Assertion in regex mode uses return $sourceProperty.matches($testStr). Instead, it should do:

Pattern p = Pattern.compile($testStr);
Matcher m = p.matcher($sourceProperty);
return m.find();

SoapUI version: Pro 4.5.2
java.runtime.version=1.7.0_15-b03
os.arch=amd64
os.name=Windows 7

Discussion