Skip to content

Commit d1d6eb0

Browse files
committed
Fix GenericApplicationContextTests on Microsoft Windows (round 2)
The previous change to the tests resulted in a failure on Windows when using the DefaultResourceLoader by expecting an exception when no exception is thrown. This commit narrows the scope of the if-clause to expect an exception only when using the FileSystemResourceLoader on Windows. See gh-28703, gh-28746
1 parent f732fab commit d1d6eb0

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

spring-context/src/test/java/org/springframework/context/support/GenericApplicationContextTests.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,9 +249,13 @@ private void assertGetResourceSemantics(ResourceLoader resourceLoader, Class<? e
249249
resource = context.getResource(fileLocation);
250250
assertThat(resource).isInstanceOf(FileUrlResource.class);
251251

252-
if (OS.WINDOWS.isCurrentOs()) {
253-
// On Windows we expect an error similar to the following.
254-
// java.nio.file.InvalidPathException: Illegal char <:> at index 4: ping:foo
252+
// If we are using a FileSystemResourceLoader on Windows, we expect an error
253+
// similar to the following since "ping:foo" is not a valid file name in the
254+
// Windows file system and since the PingPongProtocolResolver has not yet been
255+
// registered.
256+
//
257+
// java.nio.file.InvalidPathException: Illegal char <:> at index 4: ping:foo
258+
if (resourceLoader instanceof FileSystemResourceLoader && OS.WINDOWS.isCurrentOs()) {
255259
assertThatExceptionOfType(InvalidPathException.class)
256260
.isThrownBy(() -> context.getResource(pingLocation))
257261
.withMessageContaining(pingLocation);

0 commit comments

Comments
 (0)