From 77f87732efb9a939003e7c277cc6250e62cc45fa Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Wed, 25 Oct 2017 22:36:53 -0400 Subject: [PATCH] Adjust .DS_Store test assertions on Windows Windows handles trying to read a file that does not exist because a component of the path is not a directory differently than other OS handle this situation. This commit adjusts these assertions for Windows. --- .../org/elasticsearch/plugins/PluginsServiceTests.java | 7 ++++++- .../elasticsearch/bootstrap/SpawnerNoBootstrapTests.java | 8 +++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/core/src/test/java/org/elasticsearch/plugins/PluginsServiceTests.java b/core/src/test/java/org/elasticsearch/plugins/PluginsServiceTests.java index e00f1773c2b9..2f4644c85893 100644 --- a/core/src/test/java/org/elasticsearch/plugins/PluginsServiceTests.java +++ b/core/src/test/java/org/elasticsearch/plugins/PluginsServiceTests.java @@ -30,6 +30,7 @@ import org.elasticsearch.test.ESTestCase; import java.io.IOException; import java.nio.file.FileSystemException; import java.nio.file.Files; +import java.nio.file.NoSuchFileException; import java.nio.file.Path; import java.util.Arrays; import java.util.Collection; @@ -145,7 +146,11 @@ public class PluginsServiceTests extends ESTestCase { assertThat(e, hasToString(containsString("Could not load plugin descriptor for existing plugin [.DS_Store]"))); assertNotNull(e.getCause()); assertThat(e.getCause(), instanceOf(FileSystemException.class)); - assertThat(e.getCause(), hasToString(containsString("Not a directory"))); + if (Constants.WINDOWS) { + assertThat(e.getCause(), instanceOf(NoSuchFileException.class)); + } else { + assertThat(e.getCause(), hasToString(containsString("Not a directory"))); + } } } diff --git a/qa/no-bootstrap-tests/src/test/java/org/elasticsearch/bootstrap/SpawnerNoBootstrapTests.java b/qa/no-bootstrap-tests/src/test/java/org/elasticsearch/bootstrap/SpawnerNoBootstrapTests.java index 2435c17f4c33..f4e2f0cb7b0c 100644 --- a/qa/no-bootstrap-tests/src/test/java/org/elasticsearch/bootstrap/SpawnerNoBootstrapTests.java +++ b/qa/no-bootstrap-tests/src/test/java/org/elasticsearch/bootstrap/SpawnerNoBootstrapTests.java @@ -33,6 +33,7 @@ import java.io.InputStreamReader; import java.nio.charset.StandardCharsets; import java.nio.file.FileSystemException; import java.nio.file.Files; +import java.nio.file.NoSuchFileException; import java.nio.file.Path; import java.nio.file.attribute.PosixFileAttributeView; import java.nio.file.attribute.PosixFilePermission; @@ -45,6 +46,7 @@ import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.hasToString; +import static org.hamcrest.Matchers.instanceOf; /** * Create a simple "daemon controller", put it in the right place and check that it runs. @@ -211,7 +213,11 @@ public class SpawnerNoBootstrapTests extends LuceneTestCase { // we do not ignore these files on non-macOS systems final FileSystemException e = expectThrows(FileSystemException.class, () -> spawner.spawnNativePluginControllers(environment)); - assertThat(e, hasToString(containsString("Not a directory"))); + if (Constants.WINDOWS) { + assertThat(e, instanceOf(NoSuchFileException.class)); + } else { + assertThat(e, hasToString(containsString("Not a directory"))); + } } }