]> source.dussan.org Git - sonarqube.git/commitdiff
NO-JIRA fixed unit test that was not passing on windows
authorLukasz Jarocki <lukasz.jarocki@sonarsource.com>
Wed, 10 Nov 2021 13:13:01 +0000 (14:13 +0100)
committersonartech <sonartech@sonarsource.com>
Wed, 10 Nov 2021 20:03:43 +0000 (20:03 +0000)
server/sonar-webserver-api/src/test/java/org/sonar/server/plugins/PluginDownloaderTest.java
sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/fs/internal/fs/DefaultInputModuleTest.java
sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/fs/internal/fs/DefaultInputProjectTest.java
sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/fs/internal/fs/TestInputFileBuilderTest.java

index 50bb1bca588e0901f2aa6b953263932aef0761da..c21aa93a6760d4078df75b7af9d24222773559df 100644 (file)
@@ -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));
index 6f34ee4132ce3ce1cc5aa078ce64d0fd42a8d0e0..3c492c03cb02ee105c1d575bd91aa4893809ca09 100644 (file)
@@ -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();
index 97bead3be26afaf38777e03f6397f8d4a925a0bb..e21ce8487bee2213c592fb93e3b93c0369a92a51 100644 (file)
@@ -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());
index 5d555d66ed3d8db60d7a6cf080d3fdd640b85ed9..114eb98b4b0c9edfc632ae8a47632ca2ed1c8b30 100644 (file)
@@ -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));
   }
 }