diff --git a/README.md b/README.md
index f1432c8..c517ed2 100644
--- a/README.md
+++ b/README.md
@@ -30,10 +30,11 @@ The more common usage of the library is opt-in automatic Spring Boot configurati
* Adds a `PropertySource` with binding-specific Spring Boot configuration properties.
## Auto-Configurations
+Each auto-configuration is triggered by the kind of binding. Each auto-configuration can be disabled using a System Property specific to that kind and defaults to enable.
### Cassandra
Kind: `cassandra`
-Property: `org.springframework.cloud.bindings.boot.cassandra.enabled`
+Disable Property: `org.springframework.cloud.bindings.boot.cassandra.enable`
| Property | Value
| -------- | -----
@@ -44,7 +45,7 @@ Property: `org.springframework.cloud.bindings.boot.cassandra.enabled`
### DB2 RDBMS
Kind: `DB2`
-Property: `org.springframework.cloud.bindings.boot.db2.enabled`
+Disable Property: `org.springframework.cloud.bindings.boot.db2.enable`
| Property | Value
| -------- | -----
@@ -55,7 +56,7 @@ Property: `org.springframework.cloud.bindings.boot.db2.enabled`
### MongoDB
Kind: `MongoDB`
-Property: `org.springframework.cloud.bindings.boot.mongodb.enabled`
+Disable Property: `org.springframework.cloud.bindings.boot.mongodb.enable`
| Property | Value
| -------- | -----
@@ -63,7 +64,7 @@ Property: `org.springframework.cloud.bindings.boot.mongodb.enabled`
### MySQL RDBMS
Kind: `MySQL`
-Property: `org.springframework.cloud.bindings.boot.mysql.enabled`
+Disable Property: `org.springframework.cloud.bindings.boot.mysql.enable`
| Property | Value
| -------- | -----
@@ -74,7 +75,7 @@ Property: `org.springframework.cloud.bindings.boot.mysql.enabled`
### Oracle RDBMS
Kind: `Oracle`
-Property: `org.springframework.cloud.bindings.boot.oracle.enabled`
+Disable Property: `org.springframework.cloud.bindings.boot.oracle.enable`
| Property | Value
| -------- | -----
@@ -85,7 +86,7 @@ Property: `org.springframework.cloud.bindings.boot.oracle.enabled`
### PostgreSQL RDBMS
Kind: `PostgreSQL`
-Property: `org.springframework.cloud.bindings.boot.postgresql.enabled`
+Disable Property: `org.springframework.cloud.bindings.boot.postgresql.enable`
| Property | Value
| -------- | -----
@@ -96,7 +97,7 @@ Property: `org.springframework.cloud.bindings.boot.postgresql.enabled`
### Redis RDBMS
Kind: `Redis`
-Property: `org.springframework.cloud.bindings.boot.redis.enabled`
+Disable Property: `org.springframework.cloud.bindings.boot.redis.enable`
| Property | Value
| -------- | -----
@@ -106,7 +107,7 @@ Property: `org.springframework.cloud.bindings.boot.redis.enabled`
### Oracle RDBMS
Kind: `SQLServer`
-Property: `org.springframework.cloud.bindings.boot.sqlserver.enabled`
+Disable Property: `org.springframework.cloud.bindings.boot.sqlserver.enable`
| Property | Value
| -------- | -----
diff --git a/pom.xml b/pom.xml
index c758463..10fe53a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -8,9 +8,9 @@
bindings
0.0.1.BUILD-SNAPSHOT
- Cloud Native Buildpacks Bindings
- Java Library for Accessing CNB Bindings
- https://github.com/spring-cloud-incubator/bindings
+ Spring Cloud Cloud Native Buildpacks Bindings
+ Java Library and Auto-configuration for Cloud Native Buildpack Bindings
+ https://github.com/spring-cloud/spring-cloud-bindings
@@ -20,14 +20,13 @@
- https://github.com/spring-cloud-incubator/bindings
- scm:git:git://github.com/spring-cloud-incubator/bindings.git
- scm:git:ssh://git@github.com/spring-cloud-incubator/bindings.git
+ https://github.com/spring-cloud/spring-cloud-bindings
1.8
19.0.0
+ 0.6.0
2.2.7.RELEASE
@@ -66,6 +65,12 @@
provided
+
+ org.junit-pioneer
+ junit-pioneer
+ ${junit-pioneer.version}
+ test
+
org.mariadb.jdbc
mariadb-java-client
diff --git a/src/main/java/org/springframework/cloud/bindings/boot/CassandraBindingsPropertiesProcessor.java b/src/main/java/org/springframework/cloud/bindings/boot/CassandraBindingsPropertiesProcessor.java
index 9a2322c..1c2bcd5 100644
--- a/src/main/java/org/springframework/cloud/bindings/boot/CassandraBindingsPropertiesProcessor.java
+++ b/src/main/java/org/springframework/cloud/bindings/boot/CassandraBindingsPropertiesProcessor.java
@@ -23,6 +23,8 @@ import org.springframework.lang.NonNull;
import java.util.Map;
+import static org.springframework.cloud.bindings.boot.KindGuard.isKindEnabled;
+
/**
* An implementation of {@link BindingsPropertiesProcessor} that detects {@link Binding}s of kind: {@value KIND}.
*/
@@ -35,6 +37,10 @@ public final class CassandraBindingsPropertiesProcessor implements BindingsPrope
@Override
public void process(@NonNull Bindings bindings, @NotNull Map properties) {
+ if (!isKindEnabled(KIND)) {
+ return;
+ }
+
bindings.filterBindings(KIND).forEach(binding -> {
Map secret = binding.getSecret();
diff --git a/src/main/java/org/springframework/cloud/bindings/boot/Db2BindingsPropertiesProcessor.java b/src/main/java/org/springframework/cloud/bindings/boot/Db2BindingsPropertiesProcessor.java
index 8fdcb10..51d7879 100644
--- a/src/main/java/org/springframework/cloud/bindings/boot/Db2BindingsPropertiesProcessor.java
+++ b/src/main/java/org/springframework/cloud/bindings/boot/Db2BindingsPropertiesProcessor.java
@@ -23,6 +23,8 @@ import org.springframework.lang.NonNull;
import java.util.Map;
+import static org.springframework.cloud.bindings.boot.KindGuard.isKindEnabled;
+
/**
* An implementation of {@link BindingsPropertiesProcessor} that detects {@link Binding}s of kind: {@value KIND}.
*
@@ -37,6 +39,10 @@ public final class Db2BindingsPropertiesProcessor implements BindingsPropertiesP
@Override
public void process(@NonNull Bindings bindings, @NotNull Map properties) {
+ if (!isKindEnabled(KIND)) {
+ return;
+ }
+
bindings.filterBindings(KIND).forEach(binding -> {
Map secret = binding.getSecret();
diff --git a/src/main/java/org/springframework/cloud/bindings/boot/KindGuard.java b/src/main/java/org/springframework/cloud/bindings/boot/KindGuard.java
new file mode 100644
index 0000000..f7f8937
--- /dev/null
+++ b/src/main/java/org/springframework/cloud/bindings/boot/KindGuard.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2020 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.cloud.bindings.boot;
+
+import org.jetbrains.annotations.NotNull;
+
+final class KindGuard {
+
+ static boolean isKindEnabled(@NotNull String kind) {
+ String property = String.format("org.springframework.cloud.bindings.boot.%s.enable", kind.toLowerCase());
+ String value = System.getProperty(property, "true");
+ return Boolean.parseBoolean(value);
+ }
+
+}
diff --git a/src/main/java/org/springframework/cloud/bindings/boot/MongoDbBindingsPropertiesProcessor.java b/src/main/java/org/springframework/cloud/bindings/boot/MongoDbBindingsPropertiesProcessor.java
index fc375c5..6a3ac3a 100644
--- a/src/main/java/org/springframework/cloud/bindings/boot/MongoDbBindingsPropertiesProcessor.java
+++ b/src/main/java/org/springframework/cloud/bindings/boot/MongoDbBindingsPropertiesProcessor.java
@@ -22,6 +22,8 @@ import org.springframework.lang.NonNull;
import java.util.Map;
+import static org.springframework.cloud.bindings.boot.KindGuard.isKindEnabled;
+
/**
* An implementation of {@link BindingsPropertiesProcessor} that detects {@link Binding}s of kind: {@value KIND}.
*/
@@ -34,6 +36,10 @@ public final class MongoDbBindingsPropertiesProcessor implements BindingsPropert
@Override
public void process(@NonNull Bindings bindings, @NonNull Map properties) {
+ if (!isKindEnabled(KIND)) {
+ return;
+ }
+
bindings.filterBindings(KIND).forEach(binding -> {
Map secret = binding.getSecret();
diff --git a/src/main/java/org/springframework/cloud/bindings/boot/MySqlBindingsPropertiesProcessor.java b/src/main/java/org/springframework/cloud/bindings/boot/MySqlBindingsPropertiesProcessor.java
index 2c66aab..c34f58e 100644
--- a/src/main/java/org/springframework/cloud/bindings/boot/MySqlBindingsPropertiesProcessor.java
+++ b/src/main/java/org/springframework/cloud/bindings/boot/MySqlBindingsPropertiesProcessor.java
@@ -23,6 +23,8 @@ import org.springframework.lang.NonNull;
import java.util.Map;
+import static org.springframework.cloud.bindings.boot.KindGuard.isKindEnabled;
+
/**
* An implementation of {@link BindingsPropertiesProcessor} that detects {@link Binding}s of kind: {@value KIND}.
*
@@ -37,6 +39,10 @@ public final class MySqlBindingsPropertiesProcessor implements BindingsPropertie
@Override
public void process(@NonNull Bindings bindings, @NotNull Map properties) {
+ if (!isKindEnabled(KIND)) {
+ return;
+ }
+
bindings.filterBindings(KIND).forEach(binding -> {
Map secret = binding.getSecret();
diff --git a/src/main/java/org/springframework/cloud/bindings/boot/OracleBindingsPropertiesProcessor.java b/src/main/java/org/springframework/cloud/bindings/boot/OracleBindingsPropertiesProcessor.java
index 11fe915..634830f 100644
--- a/src/main/java/org/springframework/cloud/bindings/boot/OracleBindingsPropertiesProcessor.java
+++ b/src/main/java/org/springframework/cloud/bindings/boot/OracleBindingsPropertiesProcessor.java
@@ -23,6 +23,8 @@ import org.springframework.lang.NonNull;
import java.util.Map;
+import static org.springframework.cloud.bindings.boot.KindGuard.isKindEnabled;
+
/**
* An implementation of {@link BindingsPropertiesProcessor} that detects {@link Binding}s of kind: {@value KIND}.
*
@@ -37,6 +39,10 @@ public final class OracleBindingsPropertiesProcessor implements BindingsProperti
@Override
public void process(@NonNull Bindings bindings, @NotNull Map properties) {
+ if (!isKindEnabled(KIND)) {
+ return;
+ }
+
bindings.filterBindings(KIND).forEach(binding -> {
Map secret = binding.getSecret();
diff --git a/src/main/java/org/springframework/cloud/bindings/boot/PostgreSqlBindingsPropertiesProcessor.java b/src/main/java/org/springframework/cloud/bindings/boot/PostgreSqlBindingsPropertiesProcessor.java
index 119dc40..a4d61ca 100644
--- a/src/main/java/org/springframework/cloud/bindings/boot/PostgreSqlBindingsPropertiesProcessor.java
+++ b/src/main/java/org/springframework/cloud/bindings/boot/PostgreSqlBindingsPropertiesProcessor.java
@@ -23,6 +23,8 @@ import org.springframework.lang.NonNull;
import java.util.Map;
+import static org.springframework.cloud.bindings.boot.KindGuard.isKindEnabled;
+
/**
* An implementation of {@link BindingsPropertiesProcessor} that detects {@link Binding}s of kind: {@value KIND}.
*
@@ -37,6 +39,10 @@ public final class PostgreSqlBindingsPropertiesProcessor implements BindingsProp
@Override
public void process(@NonNull Bindings bindings, @NotNull Map properties) {
+ if (!isKindEnabled(KIND)) {
+ return;
+ }
+
bindings.filterBindings(KIND).forEach(binding -> {
Map secret = binding.getSecret();
diff --git a/src/main/java/org/springframework/cloud/bindings/boot/RedisBindingsPropertiesProcessor.java b/src/main/java/org/springframework/cloud/bindings/boot/RedisBindingsPropertiesProcessor.java
index 4b8b768..af1d564 100644
--- a/src/main/java/org/springframework/cloud/bindings/boot/RedisBindingsPropertiesProcessor.java
+++ b/src/main/java/org/springframework/cloud/bindings/boot/RedisBindingsPropertiesProcessor.java
@@ -23,6 +23,8 @@ import org.springframework.lang.NonNull;
import java.util.Map;
+import static org.springframework.cloud.bindings.boot.KindGuard.isKindEnabled;
+
/**
* An implementation of {@link BindingsPropertiesProcessor} that detects {@link Binding}s of kind: {@value KIND}.
*/
@@ -35,6 +37,10 @@ public final class RedisBindingsPropertiesProcessor implements BindingsPropertie
@Override
public void process(@NonNull Bindings bindings, @NotNull Map properties) {
+ if (!isKindEnabled(KIND)) {
+ return;
+ }
+
bindings.filterBindings(KIND).forEach(binding -> {
Map secret = binding.getSecret();
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 eade996..93ae0d3 100644
--- a/src/main/java/org/springframework/cloud/bindings/boot/SqlServerBindingsPropertiesProcessor.java
+++ b/src/main/java/org/springframework/cloud/bindings/boot/SqlServerBindingsPropertiesProcessor.java
@@ -23,6 +23,8 @@ import org.springframework.lang.NonNull;
import java.util.Map;
+import static org.springframework.cloud.bindings.boot.KindGuard.isKindEnabled;
+
/**
* An implementation of {@link BindingsPropertiesProcessor} that detects {@link Binding}s of kind: {@value KIND}.
*
@@ -37,6 +39,10 @@ public final class SqlServerBindingsPropertiesProcessor implements BindingsPrope
@Override
public void process(@NonNull Bindings bindings, @NotNull Map properties) {
+ if (!isKindEnabled(KIND)) {
+ return;
+ }
+
bindings.filterBindings(KIND).forEach(binding -> {
Map secret = binding.getSecret();
diff --git a/src/test/java/org/springframework/cloud/bindings/boot/CassandraBindingsPropertiesProcessorTest.java b/src/test/java/org/springframework/cloud/bindings/boot/CassandraBindingsPropertiesProcessorTest.java
index 8590f3c..975ee2b 100644
--- a/src/test/java/org/springframework/cloud/bindings/boot/CassandraBindingsPropertiesProcessorTest.java
+++ b/src/test/java/org/springframework/cloud/bindings/boot/CassandraBindingsPropertiesProcessorTest.java
@@ -18,6 +18,7 @@ package org.springframework.cloud.bindings.boot;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
+import org.junitpioneer.jupiter.SetSystemProperty;
import org.springframework.cloud.bindings.Binding;
import org.springframework.cloud.bindings.Bindings;
import org.springframework.cloud.bindings.FluentMap;
@@ -32,22 +33,23 @@ import static org.springframework.cloud.bindings.boot.CassandraBindingsPropertie
@DisplayName("Cassandra BindingsPropertiesProcessor")
final class CassandraBindingsPropertiesProcessorTest {
+ private final Bindings bindings = new Bindings(
+ new Binding("test-name", Paths.get("test-path"),
+ Collections.singletonMap("kind", KIND),
+ new FluentMap()
+ .withEntry("node_ips", "test-node-ips")
+ .withEntry("password", "test-password")
+ .withEntry("port", "test-port")
+ .withEntry("username", "test-username")
+ )
+ );
+
+ private final HashMap properties = new HashMap<>();
+
@Test
@DisplayName("contributes properties")
void test() {
- HashMap properties = new HashMap<>();
-
- new CassandraBindingsPropertiesProcessor().process(new Bindings(
- new Binding("test-name", Paths.get("test-path"),
- Collections.singletonMap("kind", KIND),
- new FluentMap()
- .withEntry("node_ips", "test-node-ips")
- .withEntry("password", "test-password")
- .withEntry("port", "test-port")
- .withEntry("username", "test-username")
- )
- ), properties);
-
+ new CassandraBindingsPropertiesProcessor().process(bindings, properties);
assertThat(properties)
.containsEntry("spring.data.cassandra.contact-points", "test-node-ips")
.containsEntry("spring.data.cassandra.password", "test-password")
@@ -55,4 +57,12 @@ final class CassandraBindingsPropertiesProcessorTest {
.containsEntry("spring.data.cassandra.username", "test-username");
}
+ @Test
+ @DisplayName("can be disabled")
+ @SetSystemProperty(key = "org.springframework.cloud.bindings.boot.cassandra.enable", value = "false")
+ void disabled() {
+ new CassandraBindingsPropertiesProcessor().process(bindings, properties);
+ assertThat(properties).isEmpty();
+ }
+
}
diff --git a/src/test/java/org/springframework/cloud/bindings/boot/Db2BindingsPropertiesProcessorTest.java b/src/test/java/org/springframework/cloud/bindings/boot/Db2BindingsPropertiesProcessorTest.java
index 7df433e..a11d610 100644
--- a/src/test/java/org/springframework/cloud/bindings/boot/Db2BindingsPropertiesProcessorTest.java
+++ b/src/test/java/org/springframework/cloud/bindings/boot/Db2BindingsPropertiesProcessorTest.java
@@ -18,6 +18,7 @@ package org.springframework.cloud.bindings.boot;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
+import org.junitpioneer.jupiter.SetSystemProperty;
import org.springframework.cloud.bindings.Binding;
import org.springframework.cloud.bindings.Bindings;
import org.springframework.cloud.bindings.FluentMap;
@@ -32,23 +33,24 @@ import static org.springframework.cloud.bindings.boot.Db2BindingsPropertiesProce
@DisplayName("DB2 BindingsPropertiesProcessor")
final class Db2BindingsPropertiesProcessorTest {
+ private final Bindings bindings = new Bindings(
+ new Binding("test-name", Paths.get("test-path"),
+ Collections.singletonMap("kind", KIND),
+ new FluentMap()
+ .withEntry("database", "test-database")
+ .withEntry("host", "test-host")
+ .withEntry("password", "test-password")
+ .withEntry("port", "test-port")
+ .withEntry("username", "test-username")
+ )
+ );
+
+ private final HashMap properties = new HashMap<>();
+
@Test
@DisplayName("contributes properties")
void test() {
- HashMap properties = new HashMap<>();
-
- new Db2BindingsPropertiesProcessor().process(new Bindings(
- new Binding("test-name", Paths.get("test-path"),
- Collections.singletonMap("kind", KIND),
- new FluentMap()
- .withEntry("database", "test-database")
- .withEntry("host", "test-host")
- .withEntry("password", "test-password")
- .withEntry("port", "test-port")
- .withEntry("username", "test-username")
- )
- ), properties);
-
+ new Db2BindingsPropertiesProcessor().process(bindings, properties);
assertThat(properties)
.containsEntry("spring.datasource.driver-class-name", "com.ibm.db2.jcc.DB2Driver")
.containsEntry("spring.datasource.password", "test-password")
@@ -56,4 +58,12 @@ final class Db2BindingsPropertiesProcessorTest {
.containsEntry("spring.datasource.username", "test-username");
}
+ @Test
+ @DisplayName("can be disabled")
+ @SetSystemProperty(key = "org.springframework.cloud.bindings.boot.db2.enable", value = "false")
+ void disabled() {
+ new Db2BindingsPropertiesProcessor().process(bindings, properties);
+ assertThat(properties).isEmpty();
+ }
+
}
diff --git a/src/test/java/org/springframework/cloud/bindings/boot/KindGuardTest.java b/src/test/java/org/springframework/cloud/bindings/boot/KindGuardTest.java
new file mode 100644
index 0000000..204748c
--- /dev/null
+++ b/src/test/java/org/springframework/cloud/bindings/boot/KindGuardTest.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2020 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.cloud.bindings.boot;
+
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+import org.junitpioneer.jupiter.SetSystemProperty;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.springframework.cloud.bindings.boot.KindGuard.isKindEnabled;
+
+@DisplayName("Kind Guard")
+final class KindGuardTest {
+
+ @Test
+ @DisplayName("returns true if unset")
+ void unset() {
+ assertThat(isKindEnabled("Test")).isTrue();
+ }
+
+ @Test
+ @DisplayName("returns the set value of true")
+ @SetSystemProperty(key = "org.springframework.cloud.bindings.boot.test.enable", value = "true")
+ void setTrue() {
+ assertThat(isKindEnabled("Test")).isTrue();
+ }
+
+ @Test
+ @DisplayName("returns the set value of false")
+ @SetSystemProperty(key = "org.springframework.cloud.bindings.boot.test.enable", value = "false")
+ void setFalse() {
+ assertThat(isKindEnabled("Test")).isFalse();
+ }
+
+}
diff --git a/src/test/java/org/springframework/cloud/bindings/boot/MongoDbBindingsPropertiesProcessorTest.java b/src/test/java/org/springframework/cloud/bindings/boot/MongoDbBindingsPropertiesProcessorTest.java
index 3d04c73..f2a7398 100644
--- a/src/test/java/org/springframework/cloud/bindings/boot/MongoDbBindingsPropertiesProcessorTest.java
+++ b/src/test/java/org/springframework/cloud/bindings/boot/MongoDbBindingsPropertiesProcessorTest.java
@@ -18,6 +18,7 @@ package org.springframework.cloud.bindings.boot;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
+import org.junitpioneer.jupiter.SetSystemProperty;
import org.springframework.cloud.bindings.Binding;
import org.springframework.cloud.bindings.Bindings;
import org.springframework.cloud.bindings.FluentMap;
@@ -32,21 +33,30 @@ import static org.springframework.cloud.bindings.boot.MongoDbBindingsPropertiesP
@DisplayName("MongoDB BindingsPropertiesProcessor")
final class MongoDbBindingsPropertiesProcessorTest {
+ private final Bindings bindings = new Bindings(
+ new Binding("test-name", Paths.get("test-path"),
+ Collections.singletonMap("kind", KIND),
+ new FluentMap()
+ .withEntry("uri", "test-uri")
+ )
+ );
+
+ private final HashMap properties = new HashMap<>();
+
@Test
@DisplayName("contributes properties")
void test() {
- HashMap properties = new HashMap<>();
-
- new MongoDbBindingsPropertiesProcessor().process(new Bindings(
- new Binding("test-name", Paths.get("test-path"),
- Collections.singletonMap("kind", KIND),
- new FluentMap()
- .withEntry("uri", "test-uri")
- )
- ), properties);
-
+ new MongoDbBindingsPropertiesProcessor().process(bindings, properties);
assertThat(properties)
.containsEntry("spring.mongodb.uri", "test-uri");
}
+ @Test
+ @DisplayName("can be disabled")
+ @SetSystemProperty(key = "org.springframework.cloud.bindings.boot.mongodb.enable", value = "false")
+ void disabled() {
+ new MongoDbBindingsPropertiesProcessor().process(bindings, properties);
+ assertThat(properties).isEmpty();
+ }
+
}
diff --git a/src/test/java/org/springframework/cloud/bindings/boot/MySqlBindingsPropertiesProcessorTest.java b/src/test/java/org/springframework/cloud/bindings/boot/MySqlBindingsPropertiesProcessorTest.java
index 71fcb0c..353013d 100644
--- a/src/test/java/org/springframework/cloud/bindings/boot/MySqlBindingsPropertiesProcessorTest.java
+++ b/src/test/java/org/springframework/cloud/bindings/boot/MySqlBindingsPropertiesProcessorTest.java
@@ -18,6 +18,7 @@ package org.springframework.cloud.bindings.boot;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
+import org.junitpioneer.jupiter.SetSystemProperty;
import org.springframework.cloud.bindings.Binding;
import org.springframework.cloud.bindings.Bindings;
import org.springframework.cloud.bindings.FluentMap;
@@ -32,23 +33,24 @@ import static org.springframework.cloud.bindings.boot.MySqlBindingsPropertiesPro
@DisplayName("MySQL BindingsPropertiesProcessor")
final class MySqlBindingsPropertiesProcessorTest {
+ private final Bindings bindings = new Bindings(
+ new Binding("test-name", Paths.get("test-path"),
+ Collections.singletonMap("kind", KIND),
+ new FluentMap()
+ .withEntry("database", "test-database")
+ .withEntry("host", "test-host")
+ .withEntry("password", "test-password")
+ .withEntry("port", "test-port")
+ .withEntry("username", "test-username")
+ )
+ );
+
+ private final HashMap properties = new HashMap<>();
+
@Test
@DisplayName("contributes properties")
void test() {
- HashMap properties = new HashMap<>();
-
- new MySqlBindingsPropertiesProcessor().process(new Bindings(
- new Binding("test-name", Paths.get("test-path"),
- Collections.singletonMap("kind", KIND),
- new FluentMap()
- .withEntry("database", "test-database")
- .withEntry("host", "test-host")
- .withEntry("password", "test-password")
- .withEntry("port", "test-port")
- .withEntry("username", "test-username")
- )
- ), properties);
-
+ new MySqlBindingsPropertiesProcessor().process(bindings, properties);
assertThat(properties)
.containsEntry("spring.datasource.driver-class-name", "org.mariadb.jdbc.Driver")
.containsEntry("spring.datasource.password", "test-password")
@@ -56,4 +58,12 @@ final class MySqlBindingsPropertiesProcessorTest {
.containsEntry("spring.datasource.username", "test-username");
}
+ @Test
+ @DisplayName("can be disabled")
+ @SetSystemProperty(key = "org.springframework.cloud.bindings.boot.mysql.enable", value = "false")
+ void disabled() {
+ new MySqlBindingsPropertiesProcessor().process(bindings, properties);
+ assertThat(properties).isEmpty();
+ }
+
}
diff --git a/src/test/java/org/springframework/cloud/bindings/boot/OracleBindingsPropertiesProcessorTest.java b/src/test/java/org/springframework/cloud/bindings/boot/OracleBindingsPropertiesProcessorTest.java
index 1968f3c..d3c46c5 100644
--- a/src/test/java/org/springframework/cloud/bindings/boot/OracleBindingsPropertiesProcessorTest.java
+++ b/src/test/java/org/springframework/cloud/bindings/boot/OracleBindingsPropertiesProcessorTest.java
@@ -18,6 +18,7 @@ package org.springframework.cloud.bindings.boot;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
+import org.junitpioneer.jupiter.SetSystemProperty;
import org.springframework.cloud.bindings.Binding;
import org.springframework.cloud.bindings.Bindings;
import org.springframework.cloud.bindings.FluentMap;
@@ -32,23 +33,24 @@ import static org.springframework.cloud.bindings.boot.OracleBindingsPropertiesPr
@DisplayName("Oracle BindingsPropertiesProcessor")
final class OracleBindingsPropertiesProcessorTest {
+ private final Bindings bindings = new Bindings(
+ new Binding("test-name", Paths.get("test-path"),
+ Collections.singletonMap("kind", KIND),
+ new FluentMap()
+ .withEntry("database", "test-database")
+ .withEntry("host", "test-host")
+ .withEntry("password", "test-password")
+ .withEntry("port", "test-port")
+ .withEntry("username", "test-username")
+ )
+ );
+
+ private final HashMap properties = new HashMap<>();
+
@Test
@DisplayName("contributes properties")
void test() {
- HashMap properties = new HashMap<>();
-
- new OracleBindingsPropertiesProcessor().process(new Bindings(
- new Binding("test-name", Paths.get("test-path"),
- Collections.singletonMap("kind", KIND),
- new FluentMap()
- .withEntry("database", "test-database")
- .withEntry("host", "test-host")
- .withEntry("password", "test-password")
- .withEntry("port", "test-port")
- .withEntry("username", "test-username")
- )
- ), properties);
-
+ new OracleBindingsPropertiesProcessor().process(bindings, properties);
assertThat(properties)
.containsEntry("spring.datasource.driver-class-name", "oracle.jdbc.OracleDriver")
.containsEntry("spring.datasource.password", "test-password")
@@ -56,4 +58,12 @@ final class OracleBindingsPropertiesProcessorTest {
.containsEntry("spring.datasource.username", "test-username");
}
+ @Test
+ @DisplayName("can be disabled")
+ @SetSystemProperty(key = "org.springframework.cloud.bindings.boot.oracle.enable", value = "false")
+ void disabled() {
+ new OracleBindingsPropertiesProcessor().process(bindings, properties);
+ assertThat(properties).isEmpty();
+ }
+
}
diff --git a/src/test/java/org/springframework/cloud/bindings/boot/PostgreSqlBindingsPropertiesProcessorTest.java b/src/test/java/org/springframework/cloud/bindings/boot/PostgreSqlBindingsPropertiesProcessorTest.java
index f44efb6..2638d95 100644
--- a/src/test/java/org/springframework/cloud/bindings/boot/PostgreSqlBindingsPropertiesProcessorTest.java
+++ b/src/test/java/org/springframework/cloud/bindings/boot/PostgreSqlBindingsPropertiesProcessorTest.java
@@ -18,6 +18,7 @@ package org.springframework.cloud.bindings.boot;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
+import org.junitpioneer.jupiter.SetSystemProperty;
import org.springframework.cloud.bindings.Binding;
import org.springframework.cloud.bindings.Bindings;
import org.springframework.cloud.bindings.FluentMap;
@@ -32,23 +33,24 @@ import static org.springframework.cloud.bindings.boot.PostgreSqlBindingsProperti
@DisplayName("PostgreSQL BindingsPropertiesProcessor")
final class PostgreSqlBindingsPropertiesProcessorTest {
+ private final Bindings bindings = new Bindings(
+ new Binding("test-name", Paths.get("test-path"),
+ Collections.singletonMap("kind", KIND),
+ new FluentMap()
+ .withEntry("database", "test-database")
+ .withEntry("host", "test-host")
+ .withEntry("password", "test-password")
+ .withEntry("port", "test-port")
+ .withEntry("username", "test-username")
+ )
+ );
+
+ private final HashMap properties = new HashMap<>();
+
@Test
@DisplayName("contributes properties")
void test() {
- HashMap properties = new HashMap<>();
-
- new PostgreSqlBindingsPropertiesProcessor().process(new Bindings(
- new Binding("test-name", Paths.get("test-path"),
- Collections.singletonMap("kind", KIND),
- new FluentMap()
- .withEntry("database", "test-database")
- .withEntry("host", "test-host")
- .withEntry("password", "test-password")
- .withEntry("port", "test-port")
- .withEntry("username", "test-username")
- )
- ), properties);
-
+ new PostgreSqlBindingsPropertiesProcessor().process(bindings, properties);
assertThat(properties)
.containsEntry("spring.datasource.driver-class-name", "org.postgresql.Driver")
.containsEntry("spring.datasource.password", "test-password")
@@ -56,4 +58,12 @@ final class PostgreSqlBindingsPropertiesProcessorTest {
.containsEntry("spring.datasource.username", "test-username");
}
+ @Test
+ @DisplayName("can be disabled")
+ @SetSystemProperty(key = "org.springframework.cloud.bindings.boot.postgresql.enable", value = "false")
+ void disabled() {
+ new PostgreSqlBindingsPropertiesProcessor().process(bindings, properties);
+ assertThat(properties).isEmpty();
+ }
+
}
diff --git a/src/test/java/org/springframework/cloud/bindings/boot/RedisBindingsPropertiesProcessorTest.java b/src/test/java/org/springframework/cloud/bindings/boot/RedisBindingsPropertiesProcessorTest.java
index c94d642..d88bc23 100644
--- a/src/test/java/org/springframework/cloud/bindings/boot/RedisBindingsPropertiesProcessorTest.java
+++ b/src/test/java/org/springframework/cloud/bindings/boot/RedisBindingsPropertiesProcessorTest.java
@@ -18,6 +18,7 @@ package org.springframework.cloud.bindings.boot;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
+import org.junitpioneer.jupiter.SetSystemProperty;
import org.springframework.cloud.bindings.Binding;
import org.springframework.cloud.bindings.Bindings;
import org.springframework.cloud.bindings.FluentMap;
@@ -32,25 +33,34 @@ import static org.springframework.cloud.bindings.boot.RedisBindingsPropertiesPro
@DisplayName("Redis BindingsPropertiesProcessor")
final class RedisBindingsPropertiesProcessorTest {
+ private final Bindings bindings = new Bindings(
+ new Binding("test-name", Paths.get("test-path"),
+ Collections.singletonMap("kind", KIND),
+ new FluentMap()
+ .withEntry("host", "test-host")
+ .withEntry("password", "test-password")
+ .withEntry("port", "test-port")
+ )
+ );
+
+ private final HashMap properties = new HashMap<>();
+
@Test
@DisplayName("contributes properties")
void test() {
- HashMap properties = new HashMap<>();
-
- new RedisBindingsPropertiesProcessor().process(new Bindings(
- new Binding("test-name", Paths.get("test-path"),
- Collections.singletonMap("kind", KIND),
- new FluentMap()
- .withEntry("host", "test-host")
- .withEntry("password", "test-password")
- .withEntry("port", "test-port")
- )
- ), properties);
-
+ new RedisBindingsPropertiesProcessor().process(bindings, properties);
assertThat(properties)
.containsEntry("spring.redis.host", "test-host")
.containsEntry("spring.redis.password", "test-password")
.containsEntry("spring.redis.port", "test-port");
}
+ @Test
+ @DisplayName("can be disabled")
+ @SetSystemProperty(key = "org.springframework.cloud.bindings.boot.redis.enable", value = "false")
+ void disabled() {
+ new RedisBindingsPropertiesProcessor().process(bindings, properties);
+ assertThat(properties).isEmpty();
+ }
+
}
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 001e14a..05b96d7 100644
--- a/src/test/java/org/springframework/cloud/bindings/boot/SqlServerBindingsPropertiesProcessorTest.java
+++ b/src/test/java/org/springframework/cloud/bindings/boot/SqlServerBindingsPropertiesProcessorTest.java
@@ -18,6 +18,7 @@ package org.springframework.cloud.bindings.boot;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
+import org.junitpioneer.jupiter.SetSystemProperty;
import org.springframework.cloud.bindings.Binding;
import org.springframework.cloud.bindings.Bindings;
import org.springframework.cloud.bindings.FluentMap;
@@ -32,23 +33,24 @@ import static org.springframework.cloud.bindings.boot.SqlServerBindingsPropertie
@DisplayName("SQLServer BindingsPropertiesProcessor")
final class SqlServerBindingsPropertiesProcessorTest {
+ private final Bindings bindings = new Bindings(
+ new Binding("test-name", Paths.get("test-path"),
+ Collections.singletonMap("kind", KIND),
+ new FluentMap()
+ .withEntry("database", "test-database")
+ .withEntry("host", "test-host")
+ .withEntry("password", "test-password")
+ .withEntry("port", "test-port")
+ .withEntry("username", "test-username")
+ )
+ );
+
+ private final HashMap properties = new HashMap<>();
+
@Test
@DisplayName("contributes properties")
void test() {
- HashMap properties = new HashMap<>();
-
- new SqlServerBindingsPropertiesProcessor().process(new Bindings(
- new Binding("test-name", Paths.get("test-path"),
- Collections.singletonMap("kind", KIND),
- new FluentMap()
- .withEntry("database", "test-database")
- .withEntry("host", "test-host")
- .withEntry("password", "test-password")
- .withEntry("port", "test-port")
- .withEntry("username", "test-username")
- )
- ), properties);
-
+ new SqlServerBindingsPropertiesProcessor().process(bindings, properties);
assertThat(properties)
.containsEntry("spring.datasource.driver-class-name", "com.microsoft.sqlserver.jdbc.SQLServerDriver")
.containsEntry("spring.datasource.password", "test-password")
@@ -56,4 +58,12 @@ final class SqlServerBindingsPropertiesProcessorTest {
.containsEntry("spring.datasource.username", "test-username");
}
+ @Test
+ @DisplayName("can be disabled")
+ @SetSystemProperty(key = "org.springframework.cloud.bindings.boot.sqlserver.enable", value = "false")
+ void disabled() {
+ new SqlServerBindingsPropertiesProcessor().process(bindings, properties);
+ assertThat(properties).isEmpty();
+ }
+
}