FEST

JTableFixture.cell(String value) expects a regex

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: FEST-Swing 1.2a3
  • Fix Version/s: FEST-Swing 1.2a4
  • Component/s: Swing
  • Labels:
    None
  • Testcase included:
    yes
  • Number of attachments :
    1

Description

I just stumpled upon some PatternSyntaxException when using the
JTableFixture.cell(String value).
The documentation says it can be a regex, so I expected this to be
only optional, but it must be.

Now I looked into the implementation and in the method
"org.fest.swing.util.Strings.areEqualOrMatch(String pattern, String s)
is a call to s.match(pattern), which requires a valid regexp to pass
in. So I expected the JTableFixture.cell(String value) to find by
plain string comparison like String.equals(...) or String.contains
(...) or it escapes any invalid regex which is passed in before doing
the match.

I can think about the following solution:

org.fest.swing.util.Strings.areEqualOrMatch(String pattern, String s) {
if (areEqual(pattern, s)) return true;
if (pattern != null && s != null)
try {
return s.matches(pattern);
catch (PatternSyntaxException notARegex) { return s.contains(pattern); }
return false;
}

Activity

There are no comments yet on this issue.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: