}
public static WildcardPattern[] createPatterns(String patterns) {
- return WildcardPattern.create(StringUtils.split(StringUtils.replace(patterns, ".", "/"), ','));
+ String[] p = StringUtils.split(patterns, ',');
+ WildcardPattern[] result = new WildcardPattern[p.length];
+ for (int i = 0; i < result.length; i++) {
+ result[i] = WildcardPattern.create(StringUtils.trim(StringUtils.replace(p[i], ".", "/")));
+ }
+ return result;
}
}
assertThat(patterns[0].match("org/sonar/Foo"), is(true));
assertThat(patterns[1].match("javax/Bar"), is(true));
}
+
+ /**
+ * See http://jira.codehaus.org/browse/SONAR-2303
+ */
+ @Test
+ public void shouldTrim() {
+ WildcardPattern[] patterns = PatternUtils.createPatterns("org.foo.*,\n org.bar.*");
+
+ assertThat(patterns[0].match("org/foo/Foo"), is(true));
+ assertThat(patterns[1].match("org/bar/Bar"), is(true));
+ }
+
}