Skip to content

Commit a2d0b64

Browse files
committed
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
1 parent a67edfb commit a2d0b64

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigDataEnvironmentPostProcessorIntegrationTests.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import java.io.File;
2020
import java.io.FileOutputStream;
21+
import java.io.IOException;
2122
import java.io.OutputStream;
2223
import java.util.ArrayList;
2324
import java.util.Collections;
@@ -56,6 +57,7 @@
5657
import org.springframework.core.io.ClassPathResource;
5758
import org.springframework.core.io.Resource;
5859
import org.springframework.core.io.ResourceLoader;
60+
import org.springframework.util.FileCopyUtils;
5961
import org.springframework.util.StringUtils;
6062

6163
import static org.assertj.core.api.Assertions.assertThat;
@@ -544,6 +546,15 @@ void runWhenConfigLocationHasNonOptionalEmptyFileDirectoryDoesNotThrowException(
544546
.run("--spring.config.location=" + StringUtils.cleanPath(location.getAbsolutePath()) + "/"));
545547
}
546548

549+
@Test
550+
void runWhenConfigLocationHasNonOptionalEmptyFileDoesNotThrowException() throws IOException {
551+
File location = new File(this.temp, "application.properties");
552+
FileCopyUtils.copy(new byte[0], location);
553+
assertThatNoException()
554+
.isThrownBy(() -> this.application.run("--spring.config.location=classpath:/application.properties,"
555+
+ StringUtils.cleanPath(location.getAbsolutePath())));
556+
}
557+
547558
@Test
548559
@Disabled("Disabled until spring.profiles suppport is dropped")
549560
void runWhenUsingInvalidPropertyThrowsException() {

0 commit comments

Comments
 (0)