Fix tests failing on windows (#1602)

* Fix tests failing on windows

Signed-off-by: Anders Alfredsson <andersb86@gmail.com>
This commit is contained in:
pacive 2020-08-22 23:03:06 +02:00 committed by GitHub
parent 0de7ed3f49
commit 0173e23759
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 6 deletions

View File

@ -26,7 +26,7 @@ public class ExecUtilTest {
@Test
public void testBasicExecuteCommandLine() {
if (isWindowsSystem()) {
ExecUtil.executeCommandLine("dir");
ExecUtil.executeCommandLine("cmd@@/c@@dir");
} else {
ExecUtil.executeCommandLine("ls");
}
@ -36,7 +36,7 @@ public class ExecUtilTest {
public void testBasicExecuteCommandLineAndWaitResponse() {
final String result;
if (isWindowsSystem()) {
result = ExecUtil.executeCommandLineAndWaitResponse("dir", 1000);
result = ExecUtil.executeCommandLineAndWaitResponse("cmd@@/c@@dir", 1000);
} else {
result = ExecUtil.executeCommandLineAndWaitResponse("ls", 1000);
}
@ -48,7 +48,7 @@ public class ExecUtilTest {
public void testExecuteCommandLineAndWaitResponseWithArguments() {
final String result;
if (isWindowsSystem()) {
result = ExecUtil.executeCommandLineAndWaitResponse("echo@@test", 1000);
result = ExecUtil.executeCommandLineAndWaitResponse("cmd@@/c@@echo@@test", 1000);
} else {
result = ExecUtil.executeCommandLineAndWaitResponse("echo@@'test'", 1000);
}

View File

@ -168,7 +168,8 @@ public class JSONResponse {
}
Thread writerThread = new Thread(() -> {
try (JsonWriter jsonWriter = new JsonWriter(new BufferedWriter(new OutputStreamWriter(out)))) {
try (JsonWriter jsonWriter = new JsonWriter(
new BufferedWriter(new OutputStreamWriter(out, StandardCharsets.UTF_8)))) {
gson.toJson(entity, entity.getClass(), jsonWriter);
jsonWriter.flush();
} catch (IOException | JsonIOException e) {

View File

@ -413,7 +413,10 @@ public class FolderObserverTest extends JavaOSGiTest {
File file = new File(UNWATCHED_DIRECTORY, filename);
file.createNewFile();
Files.setAttribute(file.toPath(), "dos:hidden", true);
Files.move(file.toPath(), EXISTING_SUBDIR_PATH.toPath());
try {
Files.move(file.toPath(), EXISTING_SUBDIR_PATH.toPath());
} catch (java.nio.file.FileAlreadyExistsException e) {
}
try (Stream<Path> walk = Files.walk(UNWATCHED_DIRECTORY.toPath())) {
walk.sorted(Comparator.reverseOrder()).map(Path::toFile).forEach(File::delete);
}

View File

@ -18,6 +18,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.io.ByteArrayInputStream;
import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;
import java.util.Collection;
import java.util.Iterator;
import java.util.Set;
@ -160,7 +161,8 @@ public class DSLRuleProviderTest extends JavaOSGiTest {
" logInfo('Test', 'Test')\n" + //
"end\n\n";
modelRepository.addOrRefreshModel(TESTMODEL_NAME, new ByteArrayInputStream(model.getBytes()));
modelRepository.addOrRefreshModel(TESTMODEL_NAME,
new ByteArrayInputStream(model.getBytes(StandardCharsets.UTF_8)));
Collection<Rule> actualRules = dslRuleProvider.getAll();
assertThat(actualRules.size(), is(1));