Merge branch '29-per-kind-disabling'
Signed-off-by: Ben Hale <bhale@vmware.com>
This commit is contained in:
17
README.md
17
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
|
||||
| -------- | -----
|
||||
|
||||
17
pom.xml
17
pom.xml
@@ -8,9 +8,9 @@
|
||||
<artifactId>bindings</artifactId>
|
||||
<version>0.0.1.BUILD-SNAPSHOT</version>
|
||||
|
||||
<name>Cloud Native Buildpacks Bindings</name>
|
||||
<description>Java Library for Accessing CNB Bindings</description>
|
||||
<url>https://github.com/spring-cloud-incubator/bindings</url>
|
||||
<name>Spring Cloud Cloud Native Buildpacks Bindings</name>
|
||||
<description>Java Library and Auto-configuration for Cloud Native Buildpack Bindings</description>
|
||||
<url>https://github.com/spring-cloud/spring-cloud-bindings</url>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
@@ -20,14 +20,13 @@
|
||||
</licenses>
|
||||
|
||||
<scm>
|
||||
<url>https://github.com/spring-cloud-incubator/bindings</url>
|
||||
<connection>scm:git:git://github.com/spring-cloud-incubator/bindings.git</connection>
|
||||
<developerConnection>scm:git:ssh://git@github.com/spring-cloud-incubator/bindings.git</developerConnection>
|
||||
<url>https://github.com/spring-cloud/spring-cloud-bindings</url>
|
||||
</scm>
|
||||
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<jetbrains-annotations.version>19.0.0</jetbrains-annotations.version>
|
||||
<junit-pioneer.version>0.6.0</junit-pioneer.version>
|
||||
<spring-boot.version>2.2.7.RELEASE</spring-boot.version>
|
||||
|
||||
<!-- Plugins -->
|
||||
@@ -66,6 +65,12 @@
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.junit-pioneer</groupId>
|
||||
<artifactId>junit-pioneer</artifactId>
|
||||
<version>${junit-pioneer.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mariadb.jdbc</groupId>
|
||||
<artifactId>mariadb-java-client</artifactId>
|
||||
|
||||
@@ -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<String, Object> properties) {
|
||||
if (!isKindEnabled(KIND)) {
|
||||
return;
|
||||
}
|
||||
|
||||
bindings.filterBindings(KIND).forEach(binding -> {
|
||||
Map<String, String> secret = binding.getSecret();
|
||||
|
||||
|
||||
@@ -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<String, Object> properties) {
|
||||
if (!isKindEnabled(KIND)) {
|
||||
return;
|
||||
}
|
||||
|
||||
bindings.filterBindings(KIND).forEach(binding -> {
|
||||
Map<String, String> secret = binding.getSecret();
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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<String, Object> properties) {
|
||||
if (!isKindEnabled(KIND)) {
|
||||
return;
|
||||
}
|
||||
|
||||
bindings.filterBindings(KIND).forEach(binding -> {
|
||||
Map<String, String> secret = binding.getSecret();
|
||||
|
||||
|
||||
@@ -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<String, Object> properties) {
|
||||
if (!isKindEnabled(KIND)) {
|
||||
return;
|
||||
}
|
||||
|
||||
bindings.filterBindings(KIND).forEach(binding -> {
|
||||
Map<String, String> secret = binding.getSecret();
|
||||
|
||||
|
||||
@@ -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<String, Object> properties) {
|
||||
if (!isKindEnabled(KIND)) {
|
||||
return;
|
||||
}
|
||||
|
||||
bindings.filterBindings(KIND).forEach(binding -> {
|
||||
Map<String, String> secret = binding.getSecret();
|
||||
|
||||
|
||||
@@ -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<String, Object> properties) {
|
||||
if (!isKindEnabled(KIND)) {
|
||||
return;
|
||||
}
|
||||
|
||||
bindings.filterBindings(KIND).forEach(binding -> {
|
||||
Map<String, String> secret = binding.getSecret();
|
||||
|
||||
|
||||
@@ -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<String, Object> properties) {
|
||||
if (!isKindEnabled(KIND)) {
|
||||
return;
|
||||
}
|
||||
|
||||
bindings.filterBindings(KIND).forEach(binding -> {
|
||||
Map<String, String> secret = binding.getSecret();
|
||||
|
||||
|
||||
@@ -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<String, Object> properties) {
|
||||
if (!isKindEnabled(KIND)) {
|
||||
return;
|
||||
}
|
||||
|
||||
bindings.filterBindings(KIND).forEach(binding -> {
|
||||
Map<String, String> secret = binding.getSecret();
|
||||
|
||||
|
||||
@@ -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<String, Object> properties = new HashMap<>();
|
||||
|
||||
@Test
|
||||
@DisplayName("contributes properties")
|
||||
void test() {
|
||||
HashMap<String, Object> 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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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<String, Object> properties = new HashMap<>();
|
||||
|
||||
@Test
|
||||
@DisplayName("contributes properties")
|
||||
void test() {
|
||||
HashMap<String, Object> 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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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<String, Object> properties = new HashMap<>();
|
||||
|
||||
@Test
|
||||
@DisplayName("contributes properties")
|
||||
void test() {
|
||||
HashMap<String, Object> 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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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<String, Object> properties = new HashMap<>();
|
||||
|
||||
@Test
|
||||
@DisplayName("contributes properties")
|
||||
void test() {
|
||||
HashMap<String, Object> 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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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<String, Object> properties = new HashMap<>();
|
||||
|
||||
@Test
|
||||
@DisplayName("contributes properties")
|
||||
void test() {
|
||||
HashMap<String, Object> 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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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<String, Object> properties = new HashMap<>();
|
||||
|
||||
@Test
|
||||
@DisplayName("contributes properties")
|
||||
void test() {
|
||||
HashMap<String, Object> 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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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<String, Object> properties = new HashMap<>();
|
||||
|
||||
@Test
|
||||
@DisplayName("contributes properties")
|
||||
void test() {
|
||||
HashMap<String, Object> 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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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<String, Object> properties = new HashMap<>();
|
||||
|
||||
@Test
|
||||
@DisplayName("contributes properties")
|
||||
void test() {
|
||||
HashMap<String, Object> 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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user