Skip to content

Commit

Permalink
Test that empty property files can be used
Browse files Browse the repository at this point in the history
Add an additional test to ensure that empty property files do not
throw ConfigDataLocationNotFoundException exceptions.

See gh-24499
See gh-24515
  • Loading branch information
philwebb committed Dec 15, 2020
1 parent a67edfb commit a2d0b64
Showing 1 changed file with 11 additions and 0 deletions.
Expand Up @@ -18,6 +18,7 @@

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Collections;
Expand Down Expand Up @@ -56,6 +57,7 @@
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.util.FileCopyUtils;
import org.springframework.util.StringUtils;

import static org.assertj.core.api.Assertions.assertThat;
Expand Down Expand Up @@ -544,6 +546,15 @@ void runWhenConfigLocationHasNonOptionalEmptyFileDirectoryDoesNotThrowException(
.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
@Disabled("Disabled until spring.profiles suppport is dropped")
void runWhenUsingInvalidPropertyThrowsException() {
Expand Down

0 comments on commit a2d0b64

Please sign in to comment.