diff --git a/spring-boot-project/spring-boot-tools/spring-boot-jarmode-layertools/src/test/java/org/springframework/boot/jarmode/layertools/IndexedLayersTests.java b/spring-boot-project/spring-boot-tools/spring-boot-jarmode-layertools/src/test/java/org/springframework/boot/jarmode/layertools/IndexedLayersTests.java index b4bc1e3a0b..937c85c234 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-jarmode-layertools/src/test/java/org/springframework/boot/jarmode/layertools/IndexedLayersTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-jarmode-layertools/src/test/java/org/springframework/boot/jarmode/layertools/IndexedLayersTests.java @@ -76,6 +76,12 @@ class IndexedLayersTests { assertThat(layers.getLayer(mockEntry("META-INF/a/sub/folder/and/a/file"))).isEqualTo("application"); } + @Test + void getLayerWhenFileHasSpaceReturnsLayer() throws Exception { + IndexedLayers layers = new IndexedLayers(getIndex()); + assertThat(layers.getLayer(mockEntry("a b/c d"))).isEqualTo("application"); + } + private String getIndex() throws Exception { ClassPathResource resource = new ClassPathResource("test-layers.idx", getClass()); InputStreamReader reader = new InputStreamReader(resource.getInputStream()); diff --git a/spring-boot-project/spring-boot-tools/spring-boot-jarmode-layertools/src/test/resources/org/springframework/boot/jarmode/layertools/test-layers.idx b/spring-boot-project/spring-boot-tools/spring-boot-jarmode-layertools/src/test/resources/org/springframework/boot/jarmode/layertools/test-layers.idx index 9825466349..0fcde4fdd1 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-jarmode-layertools/src/test/resources/org/springframework/boot/jarmode/layertools/test-layers.idx +++ b/spring-boot-project/spring-boot-tools/spring-boot-jarmode-layertools/src/test/resources/org/springframework/boot/jarmode/layertools/test-layers.idx @@ -4,3 +4,4 @@ - "application": - "BOOT-INF/classes/Demo.class" - "META-INF/" + - "a b/c d" diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/test/java/org/springframework/boot/loader/tools/LayersIndexTests.java b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/test/java/org/springframework/boot/loader/tools/LayersIndexTests.java index c162cf4ae0..d5878ca9a5 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/test/java/org/springframework/boot/loader/tools/LayersIndexTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/test/java/org/springframework/boot/loader/tools/LayersIndexTests.java @@ -104,7 +104,15 @@ class LayersIndexTests { index.add(LAYER_A, "a2/b1"); index.add(LAYER_B, "a2/b2"); assertThatIndex(index).writesExpectedContent(); + } + @Test + void writeToWhenSpaceInFileName() { + LayersIndex index = new LayersIndex(LAYER_A); + index.add(LAYER_A, "a b"); + index.add(LAYER_A, "a b/c"); + index.add(LAYER_A, "a b/d"); + assertThatIndex(index).writesExpectedContent(); } private LayersIndexAssert assertThatIndex(LayersIndex index) { diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/test/resources/org/springframework/boot/loader/tools/LayersIndexTests-writeToWhenSpaceInFileName.txt b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/test/resources/org/springframework/boot/loader/tools/LayersIndexTests-writeToWhenSpaceInFileName.txt new file mode 100644 index 0000000000..4b3e278897 --- /dev/null +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/test/resources/org/springframework/boot/loader/tools/LayersIndexTests-writeToWhenSpaceInFileName.txt @@ -0,0 +1,3 @@ +- "a": + - "a b" + - "a b/"