aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-runner-batch
diff options
context:
space:
mode:
authorSimonBrandhof <simon.brandhof@gmail.com>2013-04-09 15:11:30 +0200
committerSimonBrandhof <simon.brandhof@gmail.com>2013-04-09 15:11:30 +0200
commitcc1fcfa7ef85d9da399f77058faa9f6dc8d42760 (patch)
treec707775fbea59d9d7efdd448167f21b963a4af39 /sonar-runner-batch
parentdee520098e4765da4181b6a3f705d1d6d5b3af85 (diff)
downloadsonar-scanner-cli-cc1fcfa7ef85d9da399f77058faa9f6dc8d42760.tar.gz
sonar-scanner-cli-cc1fcfa7ef85d9da399f77058faa9f6dc8d42760.zip
Fix test on Windows
Diffstat (limited to 'sonar-runner-batch')
-rw-r--r--sonar-runner-batch/src/test/java/org/sonar/runner/batch/FilePatternTest.java20
1 files changed, 14 insertions, 6 deletions
diff --git a/sonar-runner-batch/src/test/java/org/sonar/runner/batch/FilePatternTest.java b/sonar-runner-batch/src/test/java/org/sonar/runner/batch/FilePatternTest.java
index d1cea9e..d6e1aa6 100644
--- a/sonar-runner-batch/src/test/java/org/sonar/runner/batch/FilePatternTest.java
+++ b/sonar-runner-batch/src/test/java/org/sonar/runner/batch/FilePatternTest.java
@@ -19,10 +19,12 @@
*/
package org.sonar.runner.batch;
+import org.apache.commons.io.FilenameUtils;
import org.junit.Before;
import org.junit.Test;
import java.io.File;
+import java.io.IOException;
import java.util.Collection;
import static org.fest.assertions.Assertions.assertThat;
@@ -30,12 +32,14 @@ import static org.fest.assertions.Assertions.assertThat;
public class FilePatternTest {
File basedir, rootFile, subFile;
+ String basePath;
@Before
public void init() throws Exception {
rootFile = new File(getClass().getResource("/org/sonar/runner/batch/FilePatternTest/root.txt").toURI());
subFile = new File(getClass().getResource("/org/sonar/runner/batch/FilePatternTest/subdir/subfile.txt").toURI());
basedir = rootFile.getParentFile();
+ basePath = path(basedir);
}
@Test
@@ -56,12 +60,12 @@ public class FilePatternTest {
@Test
public void should_list_files_by_absolute_path() throws Exception {
- assertOnly(new FilePattern().listFiles(basedir, basedir.getCanonicalPath() + "/*.txt"), rootFile);
- assertOnly(new FilePattern().listFiles(basedir, basedir.getCanonicalPath() + "/**/subdir/*"), subFile);
- assertOnly(new FilePattern().listFiles(basedir, rootFile.getCanonicalPath()), rootFile);
- assertOnly(new FilePattern().listFiles(basedir, basedir.getCanonicalPath() + "/*/subfile.txt"), subFile);
- assertThat(new FilePattern().listFiles(basedir, basedir.getCanonicalPath() + "/**/*.txt")).containsOnly(subFile, rootFile);
- assertThat(new FilePattern().listFiles(basedir, basedir.getCanonicalPath() + "/ElseWhere/**/*.txt")).isEmpty();
+ assertOnly(new FilePattern().listFiles(basedir, basePath + "/*.txt"), rootFile);
+ assertOnly(new FilePattern().listFiles(basedir, basePath + "/**/subdir/*"), subFile);
+ assertOnly(new FilePattern().listFiles(basedir, path(rootFile)), rootFile);
+ assertOnly(new FilePattern().listFiles(basedir, path(basedir) + "/*/subfile.txt"), subFile);
+ assertThat(new FilePattern().listFiles(basedir, path(basedir) + "/**/*.txt")).containsOnly(subFile, rootFile);
+ assertThat(new FilePattern().listFiles(basedir, path(basedir) + "/ElseWhere/**/*.txt")).isEmpty();
assertThat(new FilePattern().listFiles(basedir, "/ElseWhere/**/*.txt")).isEmpty();
}
@@ -69,4 +73,8 @@ public class FilePatternTest {
assertThat(files).hasSize(1);
assertThat(files.iterator().next().getCanonicalPath()).isEqualTo(file.getCanonicalPath());
}
+
+ private String path(File f) throws IOException {
+ return FilenameUtils.separatorsToUnix(f.getCanonicalPath());
+ }
}