From: Lukasz Jarocki Date: Wed, 10 Nov 2021 13:13:01 +0000 (+0100) Subject: NO-JIRA fixed unit test that was not passing on windows X-Git-Tag: 9.2.0.49834~50 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=e8965200411f841753e50d1c5eb9af537d2dc1cb;p=sonarqube.git NO-JIRA fixed unit test that was not passing on windows --- diff --git a/server/sonar-webserver-api/src/test/java/org/sonar/server/plugins/PluginDownloaderTest.java b/server/sonar-webserver-api/src/test/java/org/sonar/server/plugins/PluginDownloaderTest.java index 50bb1bca588..c21aa93a676 100644 --- a/server/sonar-webserver-api/src/test/java/org/sonar/server/plugins/PluginDownloaderTest.java +++ b/server/sonar-webserver-api/src/test/java/org/sonar/server/plugins/PluginDownloaderTest.java @@ -188,7 +188,7 @@ public class PluginDownloaderTest { Plugin test = Plugin.factory("test"); File file = testFolder.newFile("test-1.0.jar"); file.createNewFile(); - Release test10 = new Release(test, "1.0").setDownloadUrl("file://" + separatorsToUnix(file.getCanonicalPath())); + Release test10 = new Release(test, "1.0").setDownloadUrl("file://" + separatorsToUnix(file.getAbsolutePath())); test.addRelease(test10); when(updateCenter.findInstallablePlugins("foo", create("1.0"))).thenReturn(newArrayList(test10)); diff --git a/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/fs/internal/fs/DefaultInputModuleTest.java b/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/fs/internal/fs/DefaultInputModuleTest.java index 6f34ee4132c..3c492c03cb0 100644 --- a/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/fs/internal/fs/DefaultInputModuleTest.java +++ b/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/fs/internal/fs/DefaultInputModuleTest.java @@ -23,6 +23,7 @@ import java.io.File; import java.io.IOException; import java.nio.charset.Charset; import java.nio.file.Files; +import java.nio.file.LinkOption; import java.nio.file.Path; import org.junit.Rule; import org.junit.Test; @@ -57,11 +58,12 @@ public class DefaultInputModuleTest { assertThat(module.key()).isEqualTo("moduleKey"); assertThat(module.definition()).isEqualTo(def); - assertThat(module.getBaseDir()).isEqualTo(baseDir.toPath()); + assertThat(module.getBaseDir()) + .isEqualTo(baseDir.toPath().toRealPath(LinkOption.NOFOLLOW_LINKS)); assertThat(module.getWorkDir()).isEqualTo(workDir.toPath()); assertThat(module.getEncoding()).isEqualTo(Charset.defaultCharset()); - assertThat(module.getSourceDirsOrFiles().get()).containsExactlyInAnyOrder(src); - assertThat(module.getTestDirsOrFiles().get()).containsExactlyInAnyOrder(test); + assertThat(module.getSourceDirsOrFiles().get()).containsExactlyInAnyOrder(src.toRealPath(LinkOption.NOFOLLOW_LINKS)); + assertThat(module.getTestDirsOrFiles().get()).containsExactlyInAnyOrder(test.toRealPath(LinkOption.NOFOLLOW_LINKS)); assertThat(module.getEncoding()).isEqualTo(Charset.defaultCharset()); assertThat(module.isFile()).isFalse(); @@ -83,7 +85,7 @@ public class DefaultInputModuleTest { assertThat(module.key()).isEqualTo("moduleKey"); assertThat(module.definition()).isEqualTo(def); - assertThat(module.getBaseDir()).isEqualTo(baseDir.toPath()); + assertThat(module.getBaseDir()).isEqualTo(baseDir.toPath().toRealPath(LinkOption.NOFOLLOW_LINKS)); assertThat(module.getWorkDir()).isEqualTo(workDir.toPath()); assertThat(module.getEncoding()).isEqualTo(Charset.defaultCharset()); assertThat(module.getSourceDirsOrFiles()).isNotPresent(); diff --git a/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/fs/internal/fs/DefaultInputProjectTest.java b/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/fs/internal/fs/DefaultInputProjectTest.java index 97bead3be26..e21ce8487be 100644 --- a/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/fs/internal/fs/DefaultInputProjectTest.java +++ b/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/fs/internal/fs/DefaultInputProjectTest.java @@ -23,6 +23,7 @@ import java.io.File; import java.io.IOException; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; +import java.nio.file.LinkOption; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; @@ -55,7 +56,7 @@ public class DefaultInputProjectTest { assertThat(project.getName()).isEqualTo("projectName"); assertThat(project.getOriginalName()).isEqualTo("projectName"); assertThat(project.definition()).isEqualTo(def); - assertThat(project.getBaseDir()).isEqualTo(baseDir.toPath()); + assertThat(project.getBaseDir()).isEqualTo(baseDir.toPath().toRealPath(LinkOption.NOFOLLOW_LINKS)); assertThat(project.getDescription()).isEqualTo("desc"); assertThat(project.getWorkDir()).isEqualTo(workDir.toPath()); assertThat(project.getEncoding()).isEqualTo(Charset.defaultCharset()); diff --git a/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/fs/internal/fs/TestInputFileBuilderTest.java b/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/fs/internal/fs/TestInputFileBuilderTest.java index 5d555d66ed3..114eb98b4b0 100644 --- a/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/fs/internal/fs/TestInputFileBuilderTest.java +++ b/sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/fs/internal/fs/TestInputFileBuilderTest.java @@ -22,6 +22,7 @@ package org.sonar.api.batch.fs.internal.fs; import java.io.File; import java.io.IOException; import java.nio.charset.StandardCharsets; +import java.nio.file.LinkOption; import org.apache.commons.io.IOUtils; import org.junit.Rule; import org.junit.Test; @@ -70,6 +71,6 @@ public class TestInputFileBuilderTest { File baseDir = temp.newFolder(); AbstractProjectOrModule module = TestInputFileBuilder.newDefaultInputModule("key", baseDir); assertThat(module.key()).isEqualTo("key"); - assertThat(module.getBaseDir()).isEqualTo(baseDir.toPath()); + assertThat(module.getBaseDir()).isEqualTo(baseDir.toPath().toRealPath(LinkOption.NOFOLLOW_LINKS)); } }