Merge branch '2.7.x' into 3.0.x

Closes gh-36785
pull/37018/head
Andy Wilkinson 1 year ago
commit 34b2de3095

@ -122,7 +122,7 @@ public abstract class AbstractScriptDatabaseInitializer implements ResourceLoade
location = location.substring(OPTIONAL_LOCATION_PREFIX.length());
}
for (Resource resource : doGetResources(location, locationResolver)) {
if (resource.exists()) {
if (resource.isReadable()) {
resources.add(resource);
}
else if (!optional) {

@ -44,6 +44,16 @@ public abstract class AbstractScriptDatabaseInitializerTests<T extends AbstractS
assertThat(numberOfEmbeddedRows("SELECT COUNT(*) FROM EXAMPLE")).isOne();
}
@Test
void whenDatabaseIsInitializedWithDirectoryLocationsThenFailureIsHelpful() {
DatabaseInitializationSettings settings = new DatabaseInitializationSettings();
settings.setSchemaLocations(Arrays.asList("/org/springframework/boot/sql/init"));
settings.setDataLocations(Arrays.asList("/org/springframework/boot/sql/init"));
T initializer = createEmbeddedDatabaseInitializer(settings);
assertThatIllegalStateException().isThrownBy(initializer::initializeDatabase)
.withMessage("No schema scripts found at location '/org/springframework/boot/sql/init'");
}
@Test
void whenContinueOnErrorIsFalseThenInitializationFailsOnError() {
DatabaseInitializationSettings settings = new DatabaseInitializationSettings();

Loading…
Cancel
Save