Try to fix Windows-specific CI failures

This commit is contained in:
Andy Wilkinson 2020-07-31 16:02:14 +01:00
parent 8b40427402
commit 6c67c5d763
4 changed files with 25 additions and 28 deletions

View File

@ -16,6 +16,7 @@
package org.springframework.boot.context.config; package org.springframework.boot.context.config;
import java.io.File;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -80,8 +81,8 @@ public class ResourceConfigDataLocationResolverTests {
String location = "file:src/test/resources/configdata/properties/application.properties"; String location = "file:src/test/resources/configdata/properties/application.properties";
List<ResourceConfigDataLocation> locations = this.resolver.resolve(this.context, location); List<ResourceConfigDataLocation> locations = this.resolver.resolve(this.context, location);
assertThat(locations.size()).isEqualTo(1); assertThat(locations.size()).isEqualTo(1);
assertThat(locations).extracting(Object::toString) assertThat(locations).extracting(Object::toString).containsExactly(
.containsExactly("file [src/test/resources/configdata/properties/application.properties]"); filePath("src", "test", "resources", "configdata", "properties", "application.properties"));
} }
@Test @Test
@ -131,9 +132,9 @@ public class ResourceConfigDataLocationResolverTests {
List<ResourceConfigDataLocation> locations = this.resolver.resolve(this.context, location); List<ResourceConfigDataLocation> locations = this.resolver.resolve(this.context, location);
assertThat(locations.size()).isEqualTo(3); assertThat(locations.size()).isEqualTo(3);
assertThat(locations).extracting(Object::toString) assertThat(locations).extracting(Object::toString)
.contains("file [src/test/resources/config/1-first/testproperties.properties]") .contains(filePath("src", "test", "resources", "config", "1-first", "testproperties.properties"))
.contains("file [src/test/resources/config/2-second/testproperties.properties]") .contains(filePath("src", "test", "resources", "config", "2-second", "testproperties.properties"))
.doesNotContain("file [src/test/resources/config/nested/3-third/testproperties.properties]"); .doesNotContain(filePath("src", "test", "resources", "config", "3-third", "testproperties.properties"));
} }
@Test @Test
@ -143,9 +144,9 @@ public class ResourceConfigDataLocationResolverTests {
this.resolver = new ResourceConfigDataLocationResolver(null, this.environmentBinder, this.resourceLoader); this.resolver = new ResourceConfigDataLocationResolver(null, this.environmentBinder, this.resourceLoader);
List<ResourceConfigDataLocation> locations = this.resolver.resolve(this.context, location); List<ResourceConfigDataLocation> locations = this.resolver.resolve(this.context, location);
assertThat(locations).extracting(Object::toString).containsExactly( assertThat(locations).extracting(Object::toString).containsExactly(
"file [src/test/resources/config/0-empty/testproperties.properties]", filePath("src", "test", "resources", "config", "0-empty", "testproperties.properties"),
"file [src/test/resources/config/1-first/testproperties.properties]", filePath("src", "test", "resources", "config", "1-first", "testproperties.properties"),
"file [src/test/resources/config/2-second/testproperties.properties]"); filePath("src", "test", "resources", "config", "2-second", "testproperties.properties"));
} }
@Test @Test
@ -154,9 +155,10 @@ public class ResourceConfigDataLocationResolverTests {
List<ResourceConfigDataLocation> locations = this.resolver.resolve(this.context, location); List<ResourceConfigDataLocation> locations = this.resolver.resolve(this.context, location);
assertThat(locations.size()).isEqualTo(3); assertThat(locations.size()).isEqualTo(3);
assertThat(locations).extracting(Object::toString) assertThat(locations).extracting(Object::toString)
.contains("file [src/test/resources/config/1-first/testproperties.properties]") .contains(filePath("src", "test", "resources", "config", "1-first", "testproperties.properties"))
.contains("file [src/test/resources/config/2-second/testproperties.properties]") .contains(filePath("src", "test", "resources", "config", "2-second", "testproperties.properties"))
.doesNotContain("file [src/test/resources/config/nested/3-third/testproperties.properties]"); .doesNotContain(filePath("src", "test", "resources", "config", "nested", "3-third",
"testproperties.properties"));
} }
@Test @Test
@ -227,4 +229,8 @@ public class ResourceConfigDataLocationResolverTests {
assertThat(locations).isEmpty(); assertThat(locations).isEmpty();
} }
private String filePath(String... components) {
return "file [" + String.join(File.separator, components) + "]";
}
} }

View File

@ -16,6 +16,7 @@
package org.springframework.boot.context.config; package org.springframework.boot.context.config;
import java.io.File;
import java.util.List; import java.util.List;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -50,7 +51,8 @@ class VolumeMountConfigDataLocationResolverTests {
void resolveReturnsConfigVolumeMountLocation() { void resolveReturnsConfigVolumeMountLocation() {
List<VolumeMountConfigDataLocation> locations = this.resolver.resolve(this.context, "volumemount:/etc/config"); List<VolumeMountConfigDataLocation> locations = this.resolver.resolve(this.context, "volumemount:/etc/config");
assertThat(locations.size()).isEqualTo(1); assertThat(locations.size()).isEqualTo(1);
assertThat(locations).extracting(Object::toString).containsExactly("volume mount [/etc/config]"); assertThat(locations).extracting(Object::toString)
.containsExactly("volume mount [" + new File("/etc/config").getAbsolutePath() + "]");
} }
} }

View File

@ -16,6 +16,8 @@
package org.springframework.boot.context.config; package org.springframework.boot.context.config;
import java.io.File;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
@ -52,7 +54,7 @@ public class VolumeMountConfigDataLocationTests {
@Test @Test
void toStringReturnsDescriptiveString() { void toStringReturnsDescriptiveString() {
VolumeMountConfigDataLocation location = new VolumeMountConfigDataLocation("/etc/config"); VolumeMountConfigDataLocation location = new VolumeMountConfigDataLocation("/etc/config");
assertThat(location.toString()).isEqualTo("volume mount [/etc/config]"); assertThat(location.toString()).isEqualTo("volume mount [" + new File("/etc/config").getAbsolutePath() + "]");
} }
} }

View File

@ -16,19 +16,15 @@
package org.springframework.boot.liquibase; package org.springframework.boot.liquibase;
import java.io.File;
import javax.sql.DataSource; import javax.sql.DataSource;
import liquibase.integration.spring.SpringLiquibase; import liquibase.integration.spring.SpringLiquibase;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.BeanCreationException;
import org.springframework.boot.diagnostics.FailureAnalysis; import org.springframework.boot.diagnostics.FailureAnalysis;
import org.springframework.boot.jdbc.DataSourceBuilder; import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.boot.testsupport.classpath.ClassPathExclusions;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -40,18 +36,9 @@ import static org.assertj.core.api.Assertions.assertThat;
* *
* @author Sebastiaan Fernandez * @author Sebastiaan Fernandez
*/ */
@ClassPathExclusions("derby-*")
class LiquibaseChangelogMissingFailureAnalyzerTests { class LiquibaseChangelogMissingFailureAnalyzerTests {
@BeforeAll
static void configureDerbyLogLocation(@TempDir File temp) {
System.setProperty("derby.stream.error.file", new File(temp, "derby.log").getAbsolutePath());
}
@AfterAll
static void clearDerbyLogLocation() {
System.clearProperty("derby.stream.error.file");
}
@Test @Test
void changelogParseExceptionDueToChangelogNotPresent() { void changelogParseExceptionDueToChangelogNotPresent() {
FailureAnalysis analysis = performAnalysis(); FailureAnalysis analysis = performAnalysis();