Skip to content

Commit 77f8773

Browse files
committed
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.
1 parent 17d6820 commit 77f8773

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

core/src/test/java/org/elasticsearch/plugins/PluginsServiceTests.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import java.io.IOException;
3131
import java.nio.file.FileSystemException;
3232
import java.nio.file.Files;
33+
import java.nio.file.NoSuchFileException;
3334
import java.nio.file.Path;
3435
import java.util.Arrays;
3536
import java.util.Collection;
@@ -145,7 +146,11 @@ public void testDesktopServicesStoreFiles() throws IOException {
145146
assertThat(e, hasToString(containsString("Could not load plugin descriptor for existing plugin [.DS_Store]")));
146147
assertNotNull(e.getCause());
147148
assertThat(e.getCause(), instanceOf(FileSystemException.class));
148-
assertThat(e.getCause(), hasToString(containsString("Not a directory")));
149+
if (Constants.WINDOWS) {
150+
assertThat(e.getCause(), instanceOf(NoSuchFileException.class));
151+
} else {
152+
assertThat(e.getCause(), hasToString(containsString("Not a directory")));
153+
}
149154
}
150155
}
151156

qa/no-bootstrap-tests/src/test/java/org/elasticsearch/bootstrap/SpawnerNoBootstrapTests.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import java.nio.charset.StandardCharsets;
3434
import java.nio.file.FileSystemException;
3535
import java.nio.file.Files;
36+
import java.nio.file.NoSuchFileException;
3637
import java.nio.file.Path;
3738
import java.nio.file.attribute.PosixFileAttributeView;
3839
import java.nio.file.attribute.PosixFilePermission;
@@ -45,6 +46,7 @@
4546
import static org.hamcrest.Matchers.equalTo;
4647
import static org.hamcrest.Matchers.hasSize;
4748
import static org.hamcrest.Matchers.hasToString;
49+
import static org.hamcrest.Matchers.instanceOf;
4850

4951
/**
5052
* Create a simple "daemon controller", put it in the right place and check that it runs.
@@ -211,7 +213,11 @@ public void testSpawnerHandlingOfDesktopServicesStoreFiles() throws IOException
211213
// we do not ignore these files on non-macOS systems
212214
final FileSystemException e =
213215
expectThrows(FileSystemException.class, () -> spawner.spawnNativePluginControllers(environment));
214-
assertThat(e, hasToString(containsString("Not a directory")));
216+
if (Constants.WINDOWS) {
217+
assertThat(e, instanceOf(NoSuchFileException.class));
218+
} else {
219+
assertThat(e, hasToString(containsString("Not a directory")));
220+
}
215221
}
216222
}
217223

0 commit comments

Comments
 (0)