From 44023b33d97d874e79ecd11efe745f004063e8b7 Mon Sep 17 00:00:00 2001 From: Julien HENRY Date: Wed, 5 Jul 2017 14:32:37 +0200 Subject: [PATCH] Fix tests on Windows --- .../sonar/api/batch/fs/internal/DefaultInputFileTest.java | 5 +++-- .../sonar/scanner/scan/filesystem/InputFileBuilderTest.java | 2 +- 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(); } -- 2.39.5