]> source.dussan.org Git - sonarqube.git/commitdiff
Fix tests on Windows
authorJulien HENRY <henryju@yahoo.fr>
Wed, 5 Jul 2017 12:32:37 +0000 (14:32 +0200)
committerJulien HENRY <henryju@yahoo.fr>
Wed, 5 Jul 2017 12:42:08 +0000 (14:42 +0200)
sonar-plugin-api/src/test/java/org/sonar/api/batch/fs/internal/DefaultInputFileTest.java
sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/filesystem/InputFileBuilderTest.java

index 139b9bf4e017a1bf7bbe0aebf4231bd59c904acf..0ae07c5e8d98a53f7f3362bb225489cc3453d829 100644 (file)
@@ -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 €";
index 4a7800668e31887d69ea25bf6054e5f608825a4d..bf8091f5853a0910e855450bf0f5b68b1cc7c5cd 100644 (file)
@@ -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();
   }