Remove locale-dependent string checking
We were checking if an exception was caused by a specific reason "Not a directory". Alas, this reason is locale-dependent and can fail on systems that are not set to en_US.UTF-8. This commit addresses this by deriving what the locale-dependent error message would be and using that for comparison with the actual exception thrown. Relates #41689
This commit is contained in:
parent
f22dcfb9da
commit
61c6a26b31
|
@ -171,7 +171,15 @@ public class PluginsServiceTests extends ESTestCase {
|
||||||
if (Constants.WINDOWS) {
|
if (Constants.WINDOWS) {
|
||||||
assertThat(e.getCause(), instanceOf(NoSuchFileException.class));
|
assertThat(e.getCause(), instanceOf(NoSuchFileException.class));
|
||||||
} else {
|
} else {
|
||||||
assertThat(e.getCause(), hasToString(containsString("Not a directory")));
|
// force a "Not a directory" exception to be thrown so that we can extract the locale-dependent message
|
||||||
|
final String expected;
|
||||||
|
try (InputStream ignored = Files.newInputStream(desktopServicesStore.resolve("not-a-directory"))) {
|
||||||
|
throw new AssertionError();
|
||||||
|
} catch (final FileSystemException inner) {
|
||||||
|
// locale-dependent translation of "Not a directory"
|
||||||
|
expected = inner.getReason();
|
||||||
|
}
|
||||||
|
assertThat(e.getCause(), hasToString(containsString(expected)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue