mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-07-02 21:18:05 +02:00
Fix bugs in unit tests which occur on Windows only (#1927)
On Windows it is much more necessary to close files to avoid locked files which prevent deleting a temporary file or folder. Also paths need to be handled differently because of the drive letter and colon appearing on Windows.
This commit is contained in:
committed by
GitHub
parent
63ec4e6172
commit
0f01bb82c6
@@ -160,11 +160,12 @@ class FullScmRepositoryImporterTest {
|
||||
void shouldNotImportRepositoryIfFileNotExists(@TempDir Path temp) throws IOException {
|
||||
Path emptyFile = temp.resolve("empty");
|
||||
Files.createFile(emptyFile);
|
||||
FileInputStream inputStream = new FileInputStream(emptyFile.toFile());
|
||||
assertThrows(
|
||||
ImportFailedException.class,
|
||||
() -> fullImporter.importFromStream(REPOSITORY, inputStream, "")
|
||||
);
|
||||
try (FileInputStream inputStream = new FileInputStream(emptyFile.toFile())) {
|
||||
assertThrows(
|
||||
ImportFailedException.class,
|
||||
() -> fullImporter.importFromStream(REPOSITORY, inputStream, "")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
package sonia.scm.lifecycle;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.condition.DisabledOnOs;
|
||||
import org.junit.jupiter.api.condition.OS;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Captor;
|
||||
@@ -61,6 +63,7 @@ class DefaultRestarterTest {
|
||||
assertThat(restarter.isSupported()).isFalse();
|
||||
}
|
||||
|
||||
@DisabledOnOs(OS.WINDOWS)
|
||||
@Test
|
||||
void shouldReturnTrueIfRestartStrategyIsAvailable() {
|
||||
DefaultRestarter restarter = new DefaultRestarter();
|
||||
|
||||
@@ -50,6 +50,7 @@ import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
@@ -60,6 +61,7 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
@@ -127,11 +129,10 @@ class I18nServletTest {
|
||||
private Cache<String, JsonNode> cache;
|
||||
|
||||
@Test
|
||||
void shouldNotHaveInvalidPluginsJsonFiles() throws IOException {
|
||||
String path = getClass().getClassLoader().getResource("locales/en/plugins.json").getPath();
|
||||
assertThat(path).isNotNull();
|
||||
void shouldNotHaveInvalidPluginsJsonFiles() throws Exception {
|
||||
URI uri = Objects.requireNonNull(getClass().getClassLoader().getResource("locales/en/plugins.json")).toURI();
|
||||
|
||||
Path filePath = Paths.get(path);
|
||||
Path filePath = Paths.get(uri);
|
||||
Path translationRootPath = filePath.getParent().getParent();
|
||||
assertThat(translationRootPath).isDirectoryContaining("glob:**/en");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user