aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien HENRY <henryju@yahoo.fr>2017-07-05 14:32:37 +0200
committerJulien HENRY <henryju@yahoo.fr>2017-07-05 14:42:08 +0200
commit44023b33d97d874e79ecd11efe745f004063e8b7 (patch)
tree0c997f06fa62ab24c0c8e101c2124f4000c1944a
parentcf0653f726df89776688bb25ca8a3b34dec685ec (diff)
downloadsonarqube-44023b33d97d874e79ecd11efe745f004063e8b7.tar.gz
sonarqube-44023b33d97d874e79ecd11efe745f004063e8b7.zip
Fix tests on Windows
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/batch/fs/internal/DefaultInputFileTest.java5
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/InputFileBuilderTest.java2
2 files changed, 4 insertions, 3 deletions
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/batch/fs/internal/DefaultInputFileTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/batch/fs/internal/DefaultInputFileTest.java
index 139b9bf4e01..0ae07c5e8d9 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/batch/fs/internal/DefaultInputFileTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/batch/fs/internal/DefaultInputFileTest.java
@@ -22,10 +22,11 @@ package org.sonar.api.batch.fs.internal;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
-import java.io.FileWriter;
+import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
import java.io.StringReader;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
@@ -99,7 +100,7 @@ public class DefaultInputFileTest {
Path baseDir = temp.newFolder().toPath();
Path testFile = baseDir.resolve("src").resolve("Foo.php");
Files.createDirectories(testFile.getParent());
- try (BufferedWriter out = new BufferedWriter(new FileWriter(testFile.toFile()))) {
+ try (BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(testFile.toFile()), StandardCharsets.UTF_8))) {
out.write('\ufeff');
}
String content = "test é string €";
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/InputFileBuilderTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/InputFileBuilderTest.java
index 4a7800668e3..bf8091f5853 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/InputFileBuilderTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/InputFileBuilderTest.java
@@ -64,7 +64,7 @@ public class InputFileBuilderTest {
DefaultInputFile inputFile = builder.create(filePath, Type.MAIN, StandardCharsets.UTF_8);
assertThat(inputFile.moduleKey()).isEqualTo("module1");
- assertThat(inputFile.absolutePath()).isEqualTo(filePath.toString());
+ assertThat(inputFile.absolutePath()).isEqualTo(filePath.toString().replaceAll("\\\\", "/"));
assertThat(inputFile.key()).isEqualTo("module1:src/File1.xoo");
assertThat(inputFile.publish()).isFalse();
}