Commit 017dbe60 authored by Andy Wilkinson's avatar Andy Wilkinson

Merge pull request #25620 from uc4w6c

* gh-25620:
  Polish "Improve error message when no resources exist at a script location"
  Improve error message when no resources exist at a script location

Closes gh-25620
parents 226ee61d a832cc9c
/* /*
* Copyright 2012-2020 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -161,7 +161,7 @@ class DataSourceInitializer { ...@@ -161,7 +161,7 @@ class DataSourceInitializer {
} }
else if (validate) { else if (validate) {
throw new InvalidConfigurationPropertyValueException(propertyName, resource, throw new InvalidConfigurationPropertyValueException(propertyName, resource,
"The specified resource does not exist."); "No resources were found at location '" + location + "'.");
} }
} }
} }
......
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -221,8 +221,10 @@ class DataSourceInitializerInvokerTests { ...@@ -221,8 +221,10 @@ class DataSourceInitializerInvokerTests {
"spring.datasource.schema:classpath:does/not/exist.sql").run((context) -> { "spring.datasource.schema:classpath:does/not/exist.sql").run((context) -> {
assertThat(context).hasFailed(); assertThat(context).hasFailed();
assertThat(context.getStartupFailure()).isInstanceOf(BeanCreationException.class); assertThat(context.getStartupFailure()).isInstanceOf(BeanCreationException.class);
assertThat(context.getStartupFailure()).hasMessageContaining("does/not/exist.sql"); assertThat(context.getStartupFailure()).hasMessageContaining("[does/not/exist.sql]");
assertThat(context.getStartupFailure()).hasMessageContaining("spring.datasource.schema"); assertThat(context.getStartupFailure()).hasMessageContaining("spring.datasource.schema");
assertThat(context.getStartupFailure()).hasMessageContaining(
"No resources were found at location 'classpath:does/not/exist.sql'.");
}); });
} }
...@@ -233,8 +235,10 @@ class DataSourceInitializerInvokerTests { ...@@ -233,8 +235,10 @@ class DataSourceInitializerInvokerTests {
"spring.datasource.data:classpath:does/not/exist.sql").run((context) -> { "spring.datasource.data:classpath:does/not/exist.sql").run((context) -> {
assertThat(context).hasFailed(); assertThat(context).hasFailed();
assertThat(context.getStartupFailure()).isInstanceOf(BeanCreationException.class); assertThat(context.getStartupFailure()).isInstanceOf(BeanCreationException.class);
assertThat(context.getStartupFailure()).hasMessageContaining("does/not/exist.sql"); assertThat(context.getStartupFailure()).hasMessageContaining("[does/not/exist.sql]");
assertThat(context.getStartupFailure()).hasMessageContaining("spring.datasource.data"); assertThat(context.getStartupFailure()).hasMessageContaining("spring.datasource.data");
assertThat(context.getStartupFailure()).hasMessageContaining(
"No resources were found at location 'classpath:does/not/exist.sql'.");
}); });
} }
......
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