From 6c51ac5712c1197d3748d9a5a2ecc063d005eb6b Mon Sep 17 00:00:00 2001 From: Ben Hale Date: Mon, 11 May 2020 08:55:29 -0700 Subject: [PATCH] SQLServer JDBC Format [resolves #11] Signed-off-by: Ben Hale --- .../boot/SqlServerBindingsPropertiesProcessor.java | 7 ++++--- .../boot/SqlServerBindingsPropertiesProcessorTest.java | 5 ++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/springframework/cloud/bindings/boot/SqlServerBindingsPropertiesProcessor.java b/src/main/java/org/springframework/cloud/bindings/boot/SqlServerBindingsPropertiesProcessor.java index 7234ac6..eade996 100644 --- a/src/main/java/org/springframework/cloud/bindings/boot/SqlServerBindingsPropertiesProcessor.java +++ b/src/main/java/org/springframework/cloud/bindings/boot/SqlServerBindingsPropertiesProcessor.java @@ -25,6 +25,8 @@ import java.util.Map; /** * An implementation of {@link BindingsPropertiesProcessor} that detects {@link Binding}s of kind: {@value KIND}. + * + * @see JDBC URL Format */ public final class SqlServerBindingsPropertiesProcessor implements BindingsPropertiesProcessor { @@ -40,9 +42,8 @@ public final class SqlServerBindingsPropertiesProcessor implements BindingsPrope properties.put("spring.datasource.driver-class-name", "com.microsoft.sqlserver.jdbc.SQLServerDriver"); properties.put("spring.datasource.password", secret.get("password")); - properties.put("spring.datasource.url", String.format("jdbc:sqlserver://%s:%s/%s?user=%s&password=%s", - secret.get("host"), secret.get("port"), secret.get("db"), secret.get("username"), - secret.get("password"))); + properties.put("spring.datasource.url", String.format("jdbc:sqlserver://%s:%s/%s", + secret.get("host"), secret.get("port"), secret.get("database"))); properties.put("spring.datasource.username", secret.get("username")); }); } diff --git a/src/test/java/org/springframework/cloud/bindings/boot/SqlServerBindingsPropertiesProcessorTest.java b/src/test/java/org/springframework/cloud/bindings/boot/SqlServerBindingsPropertiesProcessorTest.java index 1f3b256..001e14a 100644 --- a/src/test/java/org/springframework/cloud/bindings/boot/SqlServerBindingsPropertiesProcessorTest.java +++ b/src/test/java/org/springframework/cloud/bindings/boot/SqlServerBindingsPropertiesProcessorTest.java @@ -41,7 +41,7 @@ final class SqlServerBindingsPropertiesProcessorTest { new Binding("test-name", Paths.get("test-path"), Collections.singletonMap("kind", KIND), new FluentMap() - .withEntry("db", "test-db") + .withEntry("database", "test-database") .withEntry("host", "test-host") .withEntry("password", "test-password") .withEntry("port", "test-port") @@ -52,8 +52,7 @@ final class SqlServerBindingsPropertiesProcessorTest { assertThat(properties) .containsEntry("spring.datasource.driver-class-name", "com.microsoft.sqlserver.jdbc.SQLServerDriver") .containsEntry("spring.datasource.password", "test-password") - .containsEntry("spring.datasource.url", - "jdbc:sqlserver://test-host:test-port/test-db?user=test-username&password=test-password") + .containsEntry("spring.datasource.url", "jdbc:sqlserver://test-host:test-port/test-database") .containsEntry("spring.datasource.username", "test-username"); }