Merge pull request #41 from spring-cloud/feature/13-support-r2dbc

Support r2dbc
This commit is contained in:
E Casey
2020-06-02 14:18:37 -04:00
committed by GitHub
11 changed files with 109 additions and 13 deletions

View File

@@ -71,6 +71,9 @@ Disable Property: `org.springframework.cloud.bindings.boot.db2.enable`
| `spring.datasource.password` | `{secret/password}`
| `spring.datasource.url` | `jdbc:db2://{secret/host}:{secret/port}/{secret/database}`
| `spring.datasource.username` | `{secret/username}`
| `spring.r2dbc.url` | `r2dbc:db2://{secret/host}:{secret/port}/{secret/database}`
| `spring.r2dbc.password` | `{secret/password}`
| `spring.r2dbc.username` | `{secret/username}`
### Elasticsearch
@@ -127,6 +130,9 @@ Disable Property: `org.springframework.cloud.bindings.boot.mysql.enable`
| `spring.datasource.password` | `{secret/password}`
| `spring.datasource.url` | `jdbc:mysql://{secret/host}:{secret/port}/{secret/database}`
| `spring.datasource.username` | `{secret/username}`
| `spring.r2dbc.url` | `r2dbc:mysql://{secret/host}:{secret/port}/{secret/database}`
| `spring.r2dbc.password` | `{secret/password}`
| `spring.r2dbc.username` | `{secret/username}`
### Neo4J
Kind: `Neo4J`
@@ -148,6 +154,9 @@ Disable Property: `org.springframework.cloud.bindings.boot.oracle.enable`
| `spring.datasource.password` | `{secret/password}`
| `spring.datasource.url` | `jdbc:oracle://{secret/host}:{secret/port}/{secret/database}`
| `spring.datasource.username` | `{secret/username}`
| `spring.r2dbc.url` | `r2dbc:oracle://{secret/host}:{secret/port}/{secret/database}`
| `spring.r2dbc.password` | `{secret/password}`
| `spring.r2dbc.username` | `{secret/username}`
### PostgreSQL RDBMS
Kind: `PostgreSQL`
@@ -159,6 +168,9 @@ Disable Property: `org.springframework.cloud.bindings.boot.postgresql.enable`
| `spring.datasource.password` | `{secret/password}`
| `spring.datasource.url` | `jdbc:postgres://{secret/host}:{secret/port}/{secret/database}`
| `spring.datasource.username` | `{secret/username}`
| `spring.r2dbc.url` | `r2dbc:postgres://{secret/host}:{secret/port}/{secret/database}`
| `spring.r2dbc.password` | `{secret/password}`
| `spring.r2dbc.username` | `{secret/username}`
### RabbitMQ RDBMS
Kind: `RabbitMQ`
@@ -201,6 +213,9 @@ Disable Property: `org.springframework.cloud.bindings.boot.sqlserver.enable`
| `spring.datasource.password` | `{secret/password}`
| `spring.datasource.url` | `jdbc:sqlserver://{secret/host}:{secret/port}/{secret/database}`
| `spring.datasource.username` | `{secret/username}`
| `spring.r2dbc.url` | `r2dbc:sqlserver://{secret/host}:{secret/port}/{secret/database}`
| `spring.r2dbc.password` | `{secret/password}`
| `spring.r2dbc.username` | `{secret/username}`
### Wavefront

View File

@@ -45,12 +45,19 @@ public final class Db2BindingsPropertiesProcessor implements BindingsPropertiesP
bindings.filterBindings(KIND).forEach(binding -> {
MapMapper map = new MapMapper(binding.getSecret(), properties);
//jdbc properties
map.from("password").to("spring.datasource.password");
map.from("host", "port", "database").to("spring.datasource.url",
(host, port, database) -> String.format("jdbc:db2://%s:%s/%s", host, port, database));
map.from("username").to("spring.datasource.username");
properties.put("spring.datasource.driver-class-name", "com.ibm.db2.jcc.DB2Driver");
//r2dbc properties
map.from("password").to("spring.r2dbc.password");
map.from("host", "port", "database").to("spring.r2dbc.url",
(host, port, database) -> String.format("r2dbc:db2://%s:%s/%s", host, port, database));
map.from("username").to("spring.r2dbc.username");
});
}

View File

@@ -45,14 +45,12 @@ public final class MySqlBindingsPropertiesProcessor implements BindingsPropertie
bindings.filterBindings(KIND).forEach(binding -> {
MapMapper map = new MapMapper(binding.getSecret(), properties);
//jdbc properties
map.from("password").to("spring.datasource.password");
map.from("host", "port", "database").to("spring.datasource.url",
(host, port, database) -> String.format("jdbc:mysql://%s:%s/%s", host, port, database));
map.from("username").to("spring.datasource.username");
Map<String, String> secret = binding.getSecret();
try {
Class.forName("org.mariadb.jdbc.Driver", false, getClass().getClassLoader());
properties.put("spring.datasource.driver-class-name", "org.mariadb.jdbc.Driver");
@@ -63,6 +61,12 @@ public final class MySqlBindingsPropertiesProcessor implements BindingsPropertie
} catch (ClassNotFoundException ignored) {
}
}
//r2dbc properties
map.from("password").to("spring.r2dbc.password");
map.from("host", "port", "database").to("spring.r2dbc.url",
(host, port, database) -> String.format("r2dbc:mysql://%s:%s/%s", host, port, database));
map.from("username").to("spring.r2dbc.username");
});
}

View File

@@ -45,12 +45,19 @@ public final class OracleBindingsPropertiesProcessor implements BindingsProperti
bindings.filterBindings(KIND).forEach(binding -> {
MapMapper map = new MapMapper(binding.getSecret(), properties);
//jdbc properties
map.from("password").to("spring.datasource.password");
map.from("host", "port", "database").to("spring.datasource.url",
(host, port, database) -> String.format("jdbc:oracle://%s:%s/%s", host, port, database));
map.from("username").to("spring.datasource.username");
properties.put("spring.datasource.driver-class-name", "oracle.jdbc.OracleDriver");
//r2dbc properties
map.from("password").to("spring.r2dbc.password");
map.from("host", "port", "database").to("spring.r2dbc.url",
(host, port, database) -> String.format("r2dbc:oracle://%s:%s/%s", host, port, database));
map.from("username").to("spring.r2dbc.username");
});
}

View File

@@ -45,12 +45,19 @@ public final class PostgreSqlBindingsPropertiesProcessor implements BindingsProp
bindings.filterBindings(KIND).forEach(binding -> {
MapMapper map = new MapMapper(binding.getSecret(), properties);
//jdbc properties
map.from("password").to("spring.datasource.password");
map.from("host", "port", "database").to("spring.datasource.url",
(host, port, database) -> String.format("jdbc:postgres://%s:%s/%s", host, port, database));
map.from("username").to("spring.datasource.username");
properties.put("spring.datasource.driver-class-name", "org.postgresql.Driver");
//r2dbc properties
map.from("password").to("spring.r2dbc.password");
map.from("host", "port", "database").to("spring.r2dbc.url",
(host, port, database) -> String.format("r2dbc:postgres://%s:%s/%s", host, port, database));
map.from("username").to("spring.r2dbc.username");
});
}

View File

@@ -45,12 +45,19 @@ public final class SqlServerBindingsPropertiesProcessor implements BindingsPrope
bindings.filterBindings(KIND).forEach(binding -> {
MapMapper map = new MapMapper(binding.getSecret(), properties);
//jdbc properties
map.from("password").to("spring.datasource.password");
map.from("host", "port", "database").to("spring.datasource.url",
(host, port, database) -> String.format("jdbc:sqlserver://%s:%s/%s", host, port, database));
map.from("username").to("spring.datasource.username");
properties.put("spring.datasource.driver-class-name", "com.microsoft.sqlserver.jdbc.SQLServerDriver");
//r2dbc properties
map.from("password").to("spring.r2dbc.password");
map.from("host", "port", "database").to("spring.r2dbc.url",
(host, port, database) -> String.format("r2dbc:sqlserver://%s:%s/%s", host, port, database));
map.from("username").to("spring.r2dbc.username");
});
}

View File

@@ -50,8 +50,8 @@ final class Db2BindingsPropertiesProcessorTest {
private final HashMap<String, Object> properties = new HashMap<>();
@Test
@DisplayName("contributes properties")
void test() {
@DisplayName("contributes jdbc properties")
void testJdbc() {
new Db2BindingsPropertiesProcessor().process(environment, bindings, properties);
assertThat(properties)
.containsEntry("spring.datasource.driver-class-name", "com.ibm.db2.jcc.DB2Driver")
@@ -60,6 +60,15 @@ final class Db2BindingsPropertiesProcessorTest {
.containsEntry("spring.datasource.username", "test-username");
}
@Test
@DisplayName("contributes r2dbc properties")
void testR2dbc() {
new Db2BindingsPropertiesProcessor().process(environment, bindings, properties);
assertThat(properties)
.containsEntry("spring.r2dbc.password", "test-password")
.containsEntry("spring.r2dbc.url", "r2dbc:db2://test-host:test-port/test-database")
.containsEntry("spring.r2dbc.username", "test-username"); }
@Test
@DisplayName("can be disabled")
void disabled() {

View File

@@ -50,8 +50,8 @@ final class MySqlBindingsPropertiesProcessorTest {
private final HashMap<String, Object> properties = new HashMap<>();
@Test
@DisplayName("contributes properties")
void test() {
@DisplayName("contributes jdbc properties")
void testJdbc() {
new MySqlBindingsPropertiesProcessor().process(environment, bindings, properties);
assertThat(properties)
.containsEntry("spring.datasource.driver-class-name", "org.mariadb.jdbc.Driver")
@@ -60,6 +60,16 @@ final class MySqlBindingsPropertiesProcessorTest {
.containsEntry("spring.datasource.username", "test-username");
}
@Test
@DisplayName("contributes r2dbc properties")
void testR2dbc() {
new MySqlBindingsPropertiesProcessor().process(environment, bindings, properties);
assertThat(properties)
.containsEntry("spring.r2dbc.password", "test-password")
.containsEntry("spring.r2dbc.url", "r2dbc:mysql://test-host:test-port/test-database")
.containsEntry("spring.r2dbc.username", "test-username");
}
@Test
@DisplayName("can be disabled")
void disabled() {

View File

@@ -50,8 +50,8 @@ final class OracleBindingsPropertiesProcessorTest {
private final HashMap<String, Object> properties = new HashMap<>();
@Test
@DisplayName("contributes properties")
void test() {
@DisplayName("contributes jdbc properties")
void testJdbc() {
new OracleBindingsPropertiesProcessor().process(environment, bindings, properties);
assertThat(properties)
.containsEntry("spring.datasource.driver-class-name", "oracle.jdbc.OracleDriver")
@@ -60,6 +60,16 @@ final class OracleBindingsPropertiesProcessorTest {
.containsEntry("spring.datasource.username", "test-username");
}
@Test
@DisplayName("contributes r2dbc properties")
void testR2dbc() {
new OracleBindingsPropertiesProcessor().process(environment, bindings, properties);
assertThat(properties)
.containsEntry("spring.r2dbc.password", "test-password")
.containsEntry("spring.r2dbc.url", "r2dbc:oracle://test-host:test-port/test-database")
.containsEntry("spring.r2dbc.username", "test-username");
}
@Test
@DisplayName("can be disabled")
void disabled() {

View File

@@ -50,8 +50,8 @@ final class PostgreSqlBindingsPropertiesProcessorTest {
private final HashMap<String, Object> properties = new HashMap<>();
@Test
@DisplayName("contributes properties")
void test() {
@DisplayName("contributes jdbc properties")
void testJdbc() {
new PostgreSqlBindingsPropertiesProcessor().process(environment, bindings, properties);
assertThat(properties)
.containsEntry("spring.datasource.driver-class-name", "org.postgresql.Driver")
@@ -60,6 +60,16 @@ final class PostgreSqlBindingsPropertiesProcessorTest {
.containsEntry("spring.datasource.username", "test-username");
}
@Test
@DisplayName("contributes r2dbc properties")
void testR2dbc() {
new PostgreSqlBindingsPropertiesProcessor().process(environment, bindings, properties);
assertThat(properties)
.containsEntry("spring.r2dbc.password", "test-password")
.containsEntry("spring.r2dbc.url", "r2dbc:postgres://test-host:test-port/test-database")
.containsEntry("spring.r2dbc.username", "test-username");
}
@Test
@DisplayName("can be disabled")
void disabled() {

View File

@@ -50,8 +50,8 @@ final class SqlServerBindingsPropertiesProcessorTest {
private final HashMap<String, Object> properties = new HashMap<>();
@Test
@DisplayName("contributes properties")
void test() {
@DisplayName("contributes jdbc properties")
void testJdbc() {
new SqlServerBindingsPropertiesProcessor().process(environment, bindings, properties);
assertThat(properties)
.containsEntry("spring.datasource.driver-class-name", "com.microsoft.sqlserver.jdbc.SQLServerDriver")
@@ -60,6 +60,16 @@ final class SqlServerBindingsPropertiesProcessorTest {
.containsEntry("spring.datasource.username", "test-username");
}
@Test
@DisplayName("contributes r2dbc properties")
void testR2dbc() {
new SqlServerBindingsPropertiesProcessor().process(environment, bindings, properties);
assertThat(properties)
.containsEntry("spring.r2dbc.password", "test-password")
.containsEntry("spring.r2dbc.url", "r2dbc:sqlserver://test-host:test-port/test-database")
.containsEntry("spring.r2dbc.username", "test-username");
}
@Test
@DisplayName("can be disabled")
void disabled() {