Commit a2d0b64e authored by Phillip Webb's avatar Phillip Webb

Test that empty property files can be used

Add an additional test to ensure that empty property files do not
throw ConfigDataLocationNotFoundException exceptions.

See gh-24499
See gh-24515
parent a67edfbe
...@@ -18,6 +18,7 @@ package org.springframework.boot.context.config; ...@@ -18,6 +18,7 @@ package org.springframework.boot.context.config;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
...@@ -56,6 +57,7 @@ import org.springframework.core.io.ByteArrayResource; ...@@ -56,6 +57,7 @@ import org.springframework.core.io.ByteArrayResource;
import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource; import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader; import org.springframework.core.io.ResourceLoader;
import org.springframework.util.FileCopyUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
...@@ -544,6 +546,15 @@ class ConfigDataEnvironmentPostProcessorIntegrationTests { ...@@ -544,6 +546,15 @@ class ConfigDataEnvironmentPostProcessorIntegrationTests {
.run("--spring.config.location=" + StringUtils.cleanPath(location.getAbsolutePath()) + "/")); .run("--spring.config.location=" + StringUtils.cleanPath(location.getAbsolutePath()) + "/"));
} }
@Test
void runWhenConfigLocationHasNonOptionalEmptyFileDoesNotThrowException() throws IOException {
File location = new File(this.temp, "application.properties");
FileCopyUtils.copy(new byte[0], location);
assertThatNoException()
.isThrownBy(() -> this.application.run("--spring.config.location=classpath:/application.properties,"
+ StringUtils.cleanPath(location.getAbsolutePath())));
}
@Test @Test
@Disabled("Disabled until spring.profiles suppport is dropped") @Disabled("Disabled until spring.profiles suppport is dropped")
void runWhenUsingInvalidPropertyThrowsException() { void runWhenUsingInvalidPropertyThrowsException() {
......
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