Browse Source

NO-JIRA fixed unit test that was not passing on windows

tags/9.2.0.49834
Lukasz Jarocki 2 years ago
parent
commit
e896520041

+ 1
- 1
server/sonar-webserver-api/src/test/java/org/sonar/server/plugins/PluginDownloaderTest.java View 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));

+ 6
- 4
sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/fs/internal/fs/DefaultInputModuleTest.java View 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();

+ 2
- 1
sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/fs/internal/fs/DefaultInputProjectTest.java View 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());

+ 2
- 1
sonar-plugin-api-impl/src/test/java/org/sonar/api/batch/fs/internal/fs/TestInputFileBuilderTest.java View 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));
}
}

Loading…
Cancel
Save