aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch
diff options
context:
space:
mode:
authorEvgeny Mandrikov <mandrikov@gmail.com>2011-04-28 18:46:35 +0400
committerEvgeny Mandrikov <mandrikov@gmail.com>2011-04-29 01:16:09 +0400
commitf33d88a2158097053b9451905efb1cefdba8b180 (patch)
tree0fe6ed6182778adf1a4d9bfed72eecbdb08ce70b /sonar-batch
parent04b6ae40d1d27fe040484c578b642af6dfe21d56 (diff)
downloadsonarqube-f33d88a2158097053b9451905efb1cefdba8b180.tar.gz
sonarqube-f33d88a2158097053b9451905efb1cefdba8b180.zip
SONAR-2261 Exclusion patterns must be trimmed
Trim them on Java and Ruby side.
Diffstat (limited to 'sonar-batch')
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/ProjectBuilder.java3
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/ProjectBuilderTest.java29
2 files changed, 26 insertions, 6 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/ProjectBuilder.java b/sonar-batch/src/main/java/org/sonar/batch/ProjectBuilder.java
index 5d3fba87331..b281c467154 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/ProjectBuilder.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/ProjectBuilder.java
@@ -102,6 +102,9 @@ public class ProjectBuilder {
if (exclusionPatterns == null) {
exclusionPatterns = new String[0];
}
+ for (int i = 0; i < exclusionPatterns.length; i++) {
+ exclusionPatterns[i] = StringUtils.trim(exclusionPatterns[i]);
+ }
return exclusionPatterns;
}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/ProjectBuilderTest.java b/sonar-batch/src/test/java/org/sonar/batch/ProjectBuilderTest.java
index ffa872b0e1b..18c42efa52f 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/ProjectBuilderTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/ProjectBuilderTest.java
@@ -19,22 +19,22 @@
*/
package org.sonar.batch;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
import org.apache.commons.configuration.PropertiesConfiguration;
import org.junit.Before;
import org.junit.Test;
import org.sonar.api.CoreProperties;
-import org.sonar.jpa.test.AbstractDbUnitTestCase;
import org.sonar.api.resources.Java;
import org.sonar.api.resources.Project;
+import org.sonar.jpa.test.AbstractDbUnitTestCase;
import java.text.SimpleDateFormat;
import java.util.Date;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
public class ProjectBuilderTest extends AbstractDbUnitTestCase {
private ProjectBuilder builder = null;
@@ -66,6 +66,23 @@ public class ProjectBuilderTest extends AbstractDbUnitTestCase {
assertThat(project.getExclusionPatterns()[2], is("*/bar"));
}
+ /**
+ * See http://jira.codehaus.org/browse/SONAR-2261
+ * Note that several exclusions separated by comma would be correctly trimmed by commons-configuration library.
+ * So issue is only with a single pattern, which contains spaces.
+ */
+ @Test
+ public void trimExclusionPatterns() {
+ PropertiesConfiguration configuration = new PropertiesConfiguration();
+ configuration.setProperty(CoreProperties.PROJECT_EXCLUSIONS_PROPERTY, " foo ");
+
+ Project project = new Project("key");
+ builder.configure(project, configuration);
+
+ assertThat(project.getExclusionPatterns().length, is(1));
+ assertThat(project.getExclusionPatterns()[0], is("foo"));
+ }
+
@Test
public void getLanguageFromConfiguration() {
PropertiesConfiguration configuration = new PropertiesConfiguration();