Commit 951a3e78 authored by Phillip Webb's avatar Phillip Webb

Test layer index can contain filenames with spaces

Add tests to ensure that the layer index can support filenames that
contain spaces.

Closes gh-20827
parent 464c15e5
...@@ -76,6 +76,12 @@ class IndexedLayersTests { ...@@ -76,6 +76,12 @@ class IndexedLayersTests {
assertThat(layers.getLayer(mockEntry("META-INF/a/sub/folder/and/a/file"))).isEqualTo("application"); 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 { private String getIndex() throws Exception {
ClassPathResource resource = new ClassPathResource("test-layers.idx", getClass()); ClassPathResource resource = new ClassPathResource("test-layers.idx", getClass());
InputStreamReader reader = new InputStreamReader(resource.getInputStream()); InputStreamReader reader = new InputStreamReader(resource.getInputStream());
......
...@@ -4,3 +4,4 @@ ...@@ -4,3 +4,4 @@
- "application": - "application":
- "BOOT-INF/classes/Demo.class" - "BOOT-INF/classes/Demo.class"
- "META-INF/" - "META-INF/"
- "a b/c d"
...@@ -104,7 +104,15 @@ class LayersIndexTests { ...@@ -104,7 +104,15 @@ class LayersIndexTests {
index.add(LAYER_A, "a2/b1"); index.add(LAYER_A, "a2/b1");
index.add(LAYER_B, "a2/b2"); index.add(LAYER_B, "a2/b2");
assertThatIndex(index).writesExpectedContent(); 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) { private LayersIndexAssert assertThatIndex(LayersIndex index) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment