Skip to content

Commit

Permalink
Improve error message for non-options-capable ConnectionFactory
Browse files Browse the repository at this point in the history
Fixes gh-26977
  • Loading branch information
wilkinsona committed Jul 8, 2021
1 parent de26014 commit 283b4a6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Expand Up @@ -101,7 +101,9 @@ public static boolean isEmbedded(ConnectionFactory connectionFactory) {
OptionsCapableConnectionFactory optionsCapable = OptionsCapableConnectionFactory.unwrapFrom(connectionFactory);
if (optionsCapable == null) {
throw new IllegalArgumentException(
"Cannot determine database's type as ConnectionFactory is not options-capable");
"Cannot determine database's type as ConnectionFactory is not options-capable. To be "
+ "options-capable, a ConnectionFactory should be created with "
+ ConnectionFactoryBuilder.class.getName());
}
ConnectionFactoryOptions options = optionsCapable.getOptions();
for (EmbeddedDatabaseConnection candidate : values()) {
Expand Down
Expand Up @@ -89,7 +89,9 @@ void whenConnectionFactoryIsNotOptionsCapableThenIsEmbeddedThrows() {
assertThatIllegalArgumentException()
.isThrownBy(() -> EmbeddedDatabaseConnection
.isEmbedded(ConnectionFactories.get("r2dbc:pool:h2:mem:///" + UUID.randomUUID())))
.withMessage("Cannot determine database's type as ConnectionFactory is not options-capable");
.withMessage("Cannot determine database's type as ConnectionFactory is not options-capable. To be "
+ "options-capable, a ConnectionFactory should be created with "
+ "org.springframework.boot.r2dbc.ConnectionFactoryBuilder");
}

static Stream<Arguments> urlParameters() {
Expand Down

0 comments on commit 283b4a6

Please sign in to comment.