Merge branch '4-db2'

Signed-off-by: Ben Hale <bhale@vmware.com>
This commit is contained in:
Ben Hale
2020-05-11 08:45:22 -07:00
3 changed files with 8 additions and 7 deletions

View File

@@ -25,6 +25,8 @@ import java.util.Map;
/**
* An implementation of {@link BindingsPropertiesProcessor} that detects {@link Binding}s of kind: {@value KIND}.
*
* @see <a href="https://www.ibm.com/support/knowledgecenter/SSEPGG_11.5.0/com.ibm.db2.luw.apdv.java.doc/src/tpc/imjcc_r0052342.html">JDBC URL Format</a>
*/
public final class Db2BindingsPropertiesProcessor implements BindingsPropertiesProcessor {
@@ -40,9 +42,8 @@ public final class Db2BindingsPropertiesProcessor implements BindingsPropertiesP
properties.put("spring.datasource.driver-class-name", "com.ibm.db2.jcc.DB2Driver");
properties.put("spring.datasource.password", secret.get("password"));
properties.put("spring.datasource.url", String.format("jdbc:db2://%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:db2://%s:%s/%s",
secret.get("host"), secret.get("port"), secret.get("database")));
properties.put("spring.datasource.username", secret.get("username"));
});
}

View File

@@ -41,7 +41,7 @@ final class Db2BindingsPropertiesProcessorTest {
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")
@@ -53,7 +53,7 @@ final class Db2BindingsPropertiesProcessorTest {
.containsEntry("spring.datasource.driver-class-name", "com.ibm.db2.jcc.DB2Driver")
.containsEntry("spring.datasource.password", "test-password")
.containsEntry("spring.datasource.url",
"jdbc:db2://test-host:test-port/test-db?user=test-username&password=test-password")
"jdbc:db2://test-host:test-port/test-database")
.containsEntry("spring.datasource.username", "test-username");
}

View File

@@ -41,14 +41,14 @@ final class RedisBindingsPropertiesProcessorTest {
new Binding("test-name", Paths.get("test-path"),
Collections.singletonMap("kind", KIND),
new FluentMap()
.withEntry("hostname", "test-hostname")
.withEntry("host", "test-host")
.withEntry("password", "test-password")
.withEntry("port", "test-port")
)
), properties);
assertThat(properties)
.containsEntry("spring.redis.host", "test-hostname")
.containsEntry("spring.redis.host", "test-host")
.containsEntry("spring.redis.password", "test-password")
.containsEntry("spring.redis.port", "test-port");
}