From e85d088d17be113be8c4ee948b94e896122283c4 Mon Sep 17 00:00:00 2001 From: parthiv39731 <70740707+parthiv39731@users.noreply.github.com> Date: Wed, 11 Oct 2023 00:03:46 +0530 Subject: [PATCH] BAEL-6910 Spring Boot 3.1's ConnectionDetails abstraction --- spring-boot-modules/spring-boot-3-1/pom.xml | 263 ++++++++++++++++++ .../ConnectionDetailsApplication.java | 15 + .../adapter/VaultAdapter.java | 124 +++++++++ .../CustomCassandraConnectionDetails.java | 32 +++ ...ssandraConnectionDetailsConfiguration.java | 17 ++ .../CustomCouchBaseConnectionDetails.java | 21 ++ ...uchBaseConnectionDetailsConfiguration.java | 16 ++ .../CustomElasticsearchConnectionDetails.java | 29 ++ ...csearchConnectionDetailsConfiguration.java | 17 ++ .../CustomKafkaConnectionDetails.java | 13 + ...omKafkaConnectionDetailsConfiguration.java | 15 + .../CustomNeo4jConnectionDetails.java | 24 ++ ...omNeo4jConnectionDetailsConfiguration.java | 17 ++ .../CustomZipkinConnectionDetails.java | 11 + ...mZipkinConnectionDetailsConfiguration.java | 17 ++ .../JdbcConnectionDetailsConfiguration.java | 17 ++ .../MongoDBConnectionDetails.java | 14 + ...MongoDBConnectionDetailsConfiguration.java | 17 ++ .../PostgresConnectionDetails.java | 21 ++ .../R2dbcPostgresConnectionDetails.java | 22 ++ ...ostgresConnectionDetailsConfiguration.java | 17 ++ .../RabbitMQConnectionDetails.java | 34 +++ ...abbitMQConnectionDetailsConfiguration.java | 17 ++ .../RedisCacheConnectionDetails.java | 26 ++ .../RedisConnectionDetailsConfiguration.java | 17 ++ .../controller/ZipkinDemoController.java | 19 ++ .../entity/elastic/Person.java | 27 ++ .../entity/neo4j/Person.java | 27 ++ .../application-cassandra.properties | 11 + .../application-couch.properties | 8 + .../application-elastic.properties | 7 + .../application-jdbc.properties | 7 + .../application-kafka.properties | 7 + .../application-mongo.properties | 8 + .../application-neo4j.properties | 7 + .../application-r2dbc.properties | 7 + .../application-rabbitmq.properties | 7 + .../application-redis.properties | 7 + .../application-zipkin.properties | 9 + .../docker/docker-compose-cassandra.yml | 9 + .../docker/docker-compose-couch.yml | 12 + .../docker/docker-compose-elastic.yml | 12 + .../docker/docker-compose-jdbc.yml | 10 + .../docker/docker-compose-kafka.yml | 38 +++ .../docker/docker-compose-mongo.yml | 10 + .../docker/docker-compose-neo4j.yml | 8 + .../docker/docker-compose-rabbitmq.yml | 9 + .../docker/docker-compose-redis.yml | 8 + .../docker/docker-compose-zipkin.yml | 10 + ...ssandra-connection-details-class-diag.puml | 27 ++ .../connection-details-sequence-design.puml | 16 ++ .../couch_connection_details_class_diag.puml | 25 ++ ...csearch-connection-details-class-diag.puml | 25 ++ .../jdbcconnection-details-class-diag.puml | 25 ++ .../kafka-connectiondetails-class-diag.puml | 21 ++ ...mongodb-connection-details-class-diag.puml | 19 ++ .../neo4j-connection-details-class-diag.puml | 23 ++ .../r2dbcconnection-details-class-diag.puml | 21 ++ ...abbitmq-connection-details-class-diag.puml | 27 ++ ...edis-connection-details-class-diagram.puml | 23 ++ .../zipkin-connection-details-class-diag.puml | 21 ++ ...andraConnectionDetailsIntegrationTest.java | 37 +++ ...hbaseConnectionDetailsIntegrationTest.java | 30 ++ ...earchConnectionDetailsIntegrationTest.java | 45 +++ .../JdbcConnectionDetailsIntegrationTest.java | 38 +++ ...KafkaConnectionDetailsIntegrationTest.java | 32 +++ ...ngoDBConnectionDetailsIntegrationTest.java | 47 ++++ ...Neo4jConnectionDetailsIntegrationTest.java | 43 +++ ...R2dbcConnectionDetailsIntegrationTest.java | 39 +++ ...bitmqConnectionDetailsIntegrationTest.java | 62 +++++ ...acheConnnectionDetailsIntegrationTest.java | 34 +++ 71 files changed, 1797 insertions(+) create mode 100644 spring-boot-modules/spring-boot-3-1/pom.xml create mode 100644 spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/ConnectionDetailsApplication.java create mode 100644 spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/adapter/VaultAdapter.java create mode 100644 spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/CustomCassandraConnectionDetails.java create mode 100644 spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/CustomCassandraConnectionDetailsConfiguration.java create mode 100644 spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/CustomCouchBaseConnectionDetails.java create mode 100644 spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/CustomCouchBaseConnectionDetailsConfiguration.java create mode 100644 spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/CustomElasticsearchConnectionDetails.java create mode 100644 spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/CustomElasticsearchConnectionDetailsConfiguration.java create mode 100644 spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/CustomKafkaConnectionDetails.java create mode 100644 spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/CustomKafkaConnectionDetailsConfiguration.java create mode 100644 spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/CustomNeo4jConnectionDetails.java create mode 100644 spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/CustomNeo4jConnectionDetailsConfiguration.java create mode 100644 spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/CustomZipkinConnectionDetails.java create mode 100644 spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/CustomZipkinConnectionDetailsConfiguration.java create mode 100644 spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/JdbcConnectionDetailsConfiguration.java create mode 100644 spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/MongoDBConnectionDetails.java create mode 100644 spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/MongoDBConnectionDetailsConfiguration.java create mode 100644 spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/PostgresConnectionDetails.java create mode 100644 spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/R2dbcPostgresConnectionDetails.java create mode 100644 spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/R2dbcPostgresConnectionDetailsConfiguration.java create mode 100644 spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/RabbitMQConnectionDetails.java create mode 100644 spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/RabbitMQConnectionDetailsConfiguration.java create mode 100644 spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/RedisCacheConnectionDetails.java create mode 100644 spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/RedisConnectionDetailsConfiguration.java create mode 100644 spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/controller/ZipkinDemoController.java create mode 100644 spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/entity/elastic/Person.java create mode 100644 spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/entity/neo4j/Person.java create mode 100644 spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/application-cassandra.properties create mode 100644 spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/application-couch.properties create mode 100644 spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/application-elastic.properties create mode 100644 spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/application-jdbc.properties create mode 100644 spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/application-kafka.properties create mode 100644 spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/application-mongo.properties create mode 100644 spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/application-neo4j.properties create mode 100644 spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/application-r2dbc.properties create mode 100644 spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/application-rabbitmq.properties create mode 100644 spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/application-redis.properties create mode 100644 spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/application-zipkin.properties create mode 100644 spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/docker/docker-compose-cassandra.yml create mode 100644 spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/docker/docker-compose-couch.yml create mode 100644 spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/docker/docker-compose-elastic.yml create mode 100644 spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/docker/docker-compose-jdbc.yml create mode 100644 spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/docker/docker-compose-kafka.yml create mode 100644 spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/docker/docker-compose-mongo.yml create mode 100644 spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/docker/docker-compose-neo4j.yml create mode 100644 spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/docker/docker-compose-rabbitmq.yml create mode 100644 spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/docker/docker-compose-redis.yml create mode 100644 spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/docker/docker-compose-zipkin.yml create mode 100644 spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/plantuml/cassandra-connection-details-class-diag.puml create mode 100644 spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/plantuml/connection-details-sequence-design.puml create mode 100644 spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/plantuml/couch_connection_details_class_diag.puml create mode 100644 spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/plantuml/elasticsearch-connection-details-class-diag.puml create mode 100644 spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/plantuml/jdbcconnection-details-class-diag.puml create mode 100644 spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/plantuml/kafka-connectiondetails-class-diag.puml create mode 100644 spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/plantuml/mongodb-connection-details-class-diag.puml create mode 100644 spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/plantuml/neo4j-connection-details-class-diag.puml create mode 100644 spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/plantuml/r2dbcconnection-details-class-diag.puml create mode 100644 spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/plantuml/rabbitmq-connection-details-class-diag.puml create mode 100644 spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/plantuml/redis-connection-details-class-diagram.puml create mode 100644 spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/plantuml/zipkin-connection-details-class-diag.puml create mode 100644 spring-boot-modules/spring-boot-3-1/src/test/java/com/baeldung/connectiondetails/CassandraConnectionDetailsIntegrationTest.java create mode 100644 spring-boot-modules/spring-boot-3-1/src/test/java/com/baeldung/connectiondetails/CouchbaseConnectionDetailsIntegrationTest.java create mode 100644 spring-boot-modules/spring-boot-3-1/src/test/java/com/baeldung/connectiondetails/ElasticsearchConnectionDetailsIntegrationTest.java create mode 100644 spring-boot-modules/spring-boot-3-1/src/test/java/com/baeldung/connectiondetails/JdbcConnectionDetailsIntegrationTest.java create mode 100644 spring-boot-modules/spring-boot-3-1/src/test/java/com/baeldung/connectiondetails/KafkaConnectionDetailsIntegrationTest.java create mode 100644 spring-boot-modules/spring-boot-3-1/src/test/java/com/baeldung/connectiondetails/MongoDBConnectionDetailsIntegrationTest.java create mode 100644 spring-boot-modules/spring-boot-3-1/src/test/java/com/baeldung/connectiondetails/Neo4jConnectionDetailsIntegrationTest.java create mode 100644 spring-boot-modules/spring-boot-3-1/src/test/java/com/baeldung/connectiondetails/R2dbcConnectionDetailsIntegrationTest.java create mode 100644 spring-boot-modules/spring-boot-3-1/src/test/java/com/baeldung/connectiondetails/RabbitmqConnectionDetailsIntegrationTest.java create mode 100644 spring-boot-modules/spring-boot-3-1/src/test/java/com/baeldung/connectiondetails/RedisCacheConnnectionDetailsIntegrationTest.java diff --git a/spring-boot-modules/spring-boot-3-1/pom.xml b/spring-boot-modules/spring-boot-3-1/pom.xml new file mode 100644 index 0000000000..597f384ed8 --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/pom.xml @@ -0,0 +1,263 @@ + + + 4.0.0 + spring-boot-3-1 + 0.0.1-SNAPSHOT + spring-boot-3-1 + Demo project for Spring Boot + + + com.baeldung + parent-boot-3 + 0.0.1-SNAPSHOT + ../../parent-boot-3 + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-hateoas + + + org.springframework.boot + spring-boot-starter-validation + + + org.springframework.boot + spring-boot-starter-data-jpa + + + org.springframework.boot + spring-boot-starter-webflux + + + org.mock-server + mockserver-netty + ${mockserver.version} + + + + org.mock-server + mockserver-client-java + ${mockserver.version} + + + com.h2database + h2 + runtime + + + org.springframework.boot + spring-boot-devtools + runtime + true + + + org.springframework.boot + spring-boot-configuration-processor + true + + + org.springdoc + springdoc-openapi-starter-webmvc-ui + ${springdoc.version} + + + org.projectlombok + lombok + true + + + org.mapstruct + mapstruct + ${mapstruct.version} + true + + + org.springframework.boot + spring-boot-docker-compose + + + org.springframework.boot + spring-boot-starter-data-mongodb + + + org.springframework.boot + spring-boot-starter-actuator + + + org.springframework.boot + spring-boot-starter-test + + + org.postgresql + postgresql + runtime + + + org.springframework.boot + spring-boot-starter-amqp + + + org.springframework.amqp + spring-rabbit-test + test + + + org.springframework.data + spring-data-redis + + + redis.clients + jedis + jar + + + org.springframework.boot + spring-boot-starter-data-redis + + + org.postgresql + r2dbc-postgresql + runtime + + + org.springframework.boot + spring-boot-starter-data-r2dbc + + + io.projectreactor + reactor-test + test + + + org.springframework.boot + spring-boot-starter-data-elasticsearch + + + org.springframework.boot + spring-boot-starter-data-cassandra + + + org.springframework.boot + spring-boot-starter-data-neo4j + + + org.springframework.kafka + spring-kafka + + + org.springframework.kafka + spring-kafka-test + test + + + org.springframework.boot + spring-boot-starter-data-couchbase + + + io.micrometer + micrometer-tracing-bridge-brave + + + io.zipkin.reporter2 + zipkin-reporter-brave + + + io.zipkin.reporter2 + zipkin-sender-urlconnection + + + + + + + docker-compose + + + + org.springframework.boot + spring-boot-maven-plugin + + com.baeldung.dockercompose.DockerComposeApplication + + + + + + + connection-details + + + + org.springframework.boot + spring-boot-maven-plugin + + com.baeldung.connectiondetails.ConnectionDetailsApplication + + + + + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + + org.mapstruct + mapstruct-processor + ${mapstruct.version} + + + org.projectlombok + lombok + ${lombok.version} + + + + org.projectlombok + lombok-mapstruct-binding + ${lombok-mapstruct-binding.version} + + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + org.apache.maven.plugins + maven-compiler-plugin + + --enable-preview + + + + + + + 19 + 1.5.2.Final + 2.0.0 + 3.0.0-M7 + 5.14.0 + 0.2.0 + + + \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/ConnectionDetailsApplication.java b/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/ConnectionDetailsApplication.java new file mode 100644 index 0000000000..d32ae8c4fb --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/ConnectionDetailsApplication.java @@ -0,0 +1,15 @@ +package com.baeldung.connectiondetails; + + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +//@ComponentScan(basePackages = "com.baeldung.connectiondetails") +public class ConnectionDetailsApplication { + + public static void main(String[] args) { + SpringApplication.run(ConnectionDetailsApplication.class, args); + } + +} diff --git a/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/adapter/VaultAdapter.java b/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/adapter/VaultAdapter.java new file mode 100644 index 0000000000..e8319c7735 --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/adapter/VaultAdapter.java @@ -0,0 +1,124 @@ +package com.baeldung.connectiondetails.adapter; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class VaultAdapter { + private static final Logger logger = LoggerFactory.getLogger(VaultAdapter.class); + public static String getSecret(String secretKey) { + logger.info("call vault to get the secret of key: " + secretKey); + + //Postgres keys + if (secretKey.equalsIgnoreCase("postgres_secret_key")) { + return "postgres"; + } + if (secretKey.equalsIgnoreCase("postgres_user_key")) { + return "postgres"; + } + if (secretKey.equalsIgnoreCase("postgres_jdbc_url")) { + return "jdbc:postgresql://localhost:15432/postgresdb"; + } + //RabbitMQ Server Keys + if (secretKey.equalsIgnoreCase("rabbitmq_username")) { + return "rabbitmquser"; + } + if (secretKey.equalsIgnoreCase("rabbitmq_password")) { + return "rabbitmq"; + } + if (secretKey.equalsIgnoreCase("rabbitmq_port")) { + return "5672"; + } + if (secretKey.equalsIgnoreCase("rabbitmq_host")) { + return "localhost"; + } + //Redis Server Keys + if (secretKey.equalsIgnoreCase("redis_username")) { + return null; + } + if (secretKey.equalsIgnoreCase("redis_password")) { + return "redis"; + } + if (secretKey.equalsIgnoreCase("redis_port")) { + return "6379"; + } + if (secretKey.equalsIgnoreCase("redis_host")) { + return "localhost"; + } + //Mongo DB Keys + if (secretKey.equalsIgnoreCase("mongo_connection_string")) { + return "mongodb://localhost:27017/demodb"; + } + + //r2dbc Keys + if (secretKey.equalsIgnoreCase("r2dbc_postgres_user")) { + return "postgres"; + } + if (secretKey.equalsIgnoreCase("r2dbc_postgres_secret")) { + return "postgres"; + } + if (secretKey.equalsIgnoreCase("r2dbc_postgres_host")) { + return "localhost"; + } + if (secretKey.equalsIgnoreCase("r2dbc_postgres_port")) { + return "15432"; + } + if (secretKey.equalsIgnoreCase("r2dbc_postgres_database")) { + return "postgresdb"; + } + //Elastic Search Keys + if (secretKey.equalsIgnoreCase("elastic_user")) { + return "elastic"; + } + if (secretKey.equalsIgnoreCase("elastic_secret")) { + return "secret"; + } + if (secretKey.equalsIgnoreCase("elastic_host")) { + return "localhost"; + } + if (secretKey.equalsIgnoreCase("elastic_port1")) { + return "19200"; + } + if (secretKey.equalsIgnoreCase("elastic_port2")) { + return "19300"; + } + //Cassandra keys + if (secretKey.equalsIgnoreCase("cassandra_user")) { + return "cassandra"; + } + if (secretKey.equalsIgnoreCase("cassandra_secret")) { + return "secret"; + } + if (secretKey.equalsIgnoreCase("cassandra_host")) { + return "localhost"; + } + if (secretKey.equalsIgnoreCase("cassandra_port")) { + return "19042"; + } + //Neo4j Keys + if (secretKey.equalsIgnoreCase("neo4j_secret")) { + return "neo4j123"; + } + if (secretKey.equalsIgnoreCase("neo4j_uri")) { + return "bolt://localhost:17687"; + } + //Kafka Keys + if (secretKey.equalsIgnoreCase("kafka_servers")) { + return "localhost:19092"; + } + //Couchbase Keys + if(secretKey.equalsIgnoreCase("couch_user")) { + return "Administrator"; + } + if(secretKey.equalsIgnoreCase("couch_secret")) { + return "password"; + } + if(secretKey.equalsIgnoreCase("couch_connection_string")) { + return "couchbase://127.0.0.1:8092"; + } + //Zipkin Keys + if(secretKey.equalsIgnoreCase("zipkin_span_endpoint")) { + return "http://localhost:9411/api/v2/spans"; + } + return "secretVal"; + } +} diff --git a/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/CustomCassandraConnectionDetails.java b/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/CustomCassandraConnectionDetails.java new file mode 100644 index 0000000000..6a246cd9fc --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/CustomCassandraConnectionDetails.java @@ -0,0 +1,32 @@ +package com.baeldung.connectiondetails.configuration; + +import com.baeldung.connectiondetails.adapter.VaultAdapter; +import org.springframework.boot.autoconfigure.cassandra.CassandraConnectionDetails; + +import java.util.List; + +public class CustomCassandraConnectionDetails implements CassandraConnectionDetails { + @Override + public List getContactPoints() { + Node node = new Node( + VaultAdapter.getSecret("cassandra_host"), + Integer.parseInt(VaultAdapter.getSecret("cassandra_port")) + ); + return List.of(node); + } + + @Override + public String getUsername() { + return VaultAdapter.getSecret("cassandra_user"); + } + + @Override + public String getPassword() { + return VaultAdapter.getSecret("cassandra_secret"); + } + + @Override + public String getLocalDatacenter() { + return "datacenter-1"; + } +} diff --git a/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/CustomCassandraConnectionDetailsConfiguration.java b/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/CustomCassandraConnectionDetailsConfiguration.java new file mode 100644 index 0000000000..02ed8c0051 --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/CustomCassandraConnectionDetailsConfiguration.java @@ -0,0 +1,17 @@ +package com.baeldung.connectiondetails.configuration; + +import org.springframework.boot.autoconfigure.cassandra.CassandraConnectionDetails; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; +import org.springframework.context.annotation.Profile; + +@Configuration(proxyBeanMethods = false) +@Profile("cassandra") +public class CustomCassandraConnectionDetailsConfiguration { + @Bean + @Primary + public CassandraConnectionDetails getCustomCassandraConnectionDetails() { + return new CustomCassandraConnectionDetails(); + } +} diff --git a/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/CustomCouchBaseConnectionDetails.java b/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/CustomCouchBaseConnectionDetails.java new file mode 100644 index 0000000000..4fa0605cac --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/CustomCouchBaseConnectionDetails.java @@ -0,0 +1,21 @@ +package com.baeldung.connectiondetails.configuration; + +import com.baeldung.connectiondetails.adapter.VaultAdapter; +import org.springframework.boot.autoconfigure.couchbase.CouchbaseConnectionDetails; + +public class CustomCouchBaseConnectionDetails implements CouchbaseConnectionDetails { + @Override + public String getConnectionString() { + return VaultAdapter.getSecret("couch_connection_string"); + } + + @Override + public String getUsername() { + return VaultAdapter.getSecret("couch_user"); + } + + @Override + public String getPassword() { + return VaultAdapter.getSecret("couch_secret"); + } +} diff --git a/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/CustomCouchBaseConnectionDetailsConfiguration.java b/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/CustomCouchBaseConnectionDetailsConfiguration.java new file mode 100644 index 0000000000..96cc34f92e --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/CustomCouchBaseConnectionDetailsConfiguration.java @@ -0,0 +1,16 @@ +package com.baeldung.connectiondetails.configuration; + +import org.springframework.boot.autoconfigure.couchbase.CouchbaseConnectionDetails; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; + +@Configuration(proxyBeanMethods = false) +@Profile("couch") + +public class CustomCouchBaseConnectionDetailsConfiguration { + @Bean + public CouchbaseConnectionDetails getCouchBaseConnectionDetails() { + return new CustomCouchBaseConnectionDetails(); + } +} diff --git a/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/CustomElasticsearchConnectionDetails.java b/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/CustomElasticsearchConnectionDetails.java new file mode 100644 index 0000000000..0b45878bc9 --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/CustomElasticsearchConnectionDetails.java @@ -0,0 +1,29 @@ +package com.baeldung.connectiondetails.configuration; + +import com.baeldung.connectiondetails.adapter.VaultAdapter; +import org.springframework.boot.autoconfigure.elasticsearch.ElasticsearchConnectionDetails; + +import java.util.List; + +public class CustomElasticsearchConnectionDetails implements ElasticsearchConnectionDetails { + @Override + public List getNodes() { + Node node1 = new Node( + VaultAdapter.getSecret("elastic_host"), + Integer.parseInt(VaultAdapter.getSecret("elastic_port1")), + Node.Protocol.HTTP + ); + return List.of(node1); + } + + @Override + public String getUsername() { + return VaultAdapter.getSecret("elastic_user"); + } + + @Override + public String getPassword() { + return VaultAdapter.getSecret("elastic_secret"); + } + +} diff --git a/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/CustomElasticsearchConnectionDetailsConfiguration.java b/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/CustomElasticsearchConnectionDetailsConfiguration.java new file mode 100644 index 0000000000..a9b3da44fa --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/CustomElasticsearchConnectionDetailsConfiguration.java @@ -0,0 +1,17 @@ +package com.baeldung.connectiondetails.configuration; + +import org.springframework.boot.autoconfigure.elasticsearch.ElasticsearchConnectionDetails; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; +import org.springframework.context.annotation.Profile; + +@Configuration(proxyBeanMethods = false) +@Profile("elastic") +public class CustomElasticsearchConnectionDetailsConfiguration { + @Bean + @Primary + public ElasticsearchConnectionDetails getCustomElasticConnectionDetails() { + return new CustomElasticsearchConnectionDetails(); + } +} diff --git a/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/CustomKafkaConnectionDetails.java b/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/CustomKafkaConnectionDetails.java new file mode 100644 index 0000000000..6791ee6408 --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/CustomKafkaConnectionDetails.java @@ -0,0 +1,13 @@ +package com.baeldung.connectiondetails.configuration; + +import com.baeldung.connectiondetails.adapter.VaultAdapter; +import org.springframework.boot.autoconfigure.kafka.KafkaConnectionDetails; + +import java.util.List; + +public class CustomKafkaConnectionDetails implements KafkaConnectionDetails { + @Override + public List getBootstrapServers() { + return List.of(VaultAdapter.getSecret("kafka_servers")); + } +} diff --git a/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/CustomKafkaConnectionDetailsConfiguration.java b/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/CustomKafkaConnectionDetailsConfiguration.java new file mode 100644 index 0000000000..068281741a --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/CustomKafkaConnectionDetailsConfiguration.java @@ -0,0 +1,15 @@ +package com.baeldung.connectiondetails.configuration; + +import org.springframework.boot.autoconfigure.kafka.KafkaConnectionDetails; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; + +@Configuration(proxyBeanMethods = false) +@Profile("kafka") +public class CustomKafkaConnectionDetailsConfiguration { + @Bean + public KafkaConnectionDetails getKafkaConnectionDetails() { + return new CustomKafkaConnectionDetails(); + } +} diff --git a/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/CustomNeo4jConnectionDetails.java b/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/CustomNeo4jConnectionDetails.java new file mode 100644 index 0000000000..c0412fbb21 --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/CustomNeo4jConnectionDetails.java @@ -0,0 +1,24 @@ +package com.baeldung.connectiondetails.configuration; + +import com.baeldung.connectiondetails.adapter.VaultAdapter; +import org.neo4j.driver.AuthToken; +import org.neo4j.driver.AuthTokens; +import org.springframework.boot.autoconfigure.neo4j.Neo4jConnectionDetails; + +import java.net.URI; +import java.net.URISyntaxException; + +public class CustomNeo4jConnectionDetails implements Neo4jConnectionDetails { + @Override + public URI getUri() { + try { + return new URI(VaultAdapter.getSecret("neo4j_uri")); + } catch (URISyntaxException e) { + throw new RuntimeException(e); + } + } + @Override + public AuthToken getAuthToken() { + return AuthTokens.basic("neo4j", VaultAdapter.getSecret("neo4j_secret")); + } +} diff --git a/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/CustomNeo4jConnectionDetailsConfiguration.java b/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/CustomNeo4jConnectionDetailsConfiguration.java new file mode 100644 index 0000000000..aec8908c7d --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/CustomNeo4jConnectionDetailsConfiguration.java @@ -0,0 +1,17 @@ +package com.baeldung.connectiondetails.configuration; + +import org.springframework.boot.autoconfigure.neo4j.Neo4jConnectionDetails; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; +import org.springframework.context.annotation.Profile; + +@Configuration(proxyBeanMethods = false) +@Profile("neo4j") +public class CustomNeo4jConnectionDetailsConfiguration { + @Bean + @Primary + public Neo4jConnectionDetails getNeo4jConnectionDetails() { + return new CustomNeo4jConnectionDetails(); + } +} diff --git a/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/CustomZipkinConnectionDetails.java b/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/CustomZipkinConnectionDetails.java new file mode 100644 index 0000000000..c29408992a --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/CustomZipkinConnectionDetails.java @@ -0,0 +1,11 @@ +package com.baeldung.connectiondetails.configuration; + +import com.baeldung.connectiondetails.adapter.VaultAdapter; +import org.springframework.boot.actuate.autoconfigure.tracing.zipkin.ZipkinConnectionDetails; + +public class CustomZipkinConnectionDetails implements ZipkinConnectionDetails { + @Override + public String getSpanEndpoint() { + return VaultAdapter.getSecret("zipkin_span_endpoint"); + } +} diff --git a/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/CustomZipkinConnectionDetailsConfiguration.java b/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/CustomZipkinConnectionDetailsConfiguration.java new file mode 100644 index 0000000000..2f451a3850 --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/CustomZipkinConnectionDetailsConfiguration.java @@ -0,0 +1,17 @@ +package com.baeldung.connectiondetails.configuration; + +import org.springframework.boot.actuate.autoconfigure.tracing.zipkin.ZipkinConnectionDetails; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; +import org.springframework.context.annotation.Profile; + +@Configuration(proxyBeanMethods = false) +@Profile("zipkin") +public class CustomZipkinConnectionDetailsConfiguration { + @Bean + @Primary + public ZipkinConnectionDetails getZipkinConnectionDetails() { + return new CustomZipkinConnectionDetails(); + } +} diff --git a/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/JdbcConnectionDetailsConfiguration.java b/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/JdbcConnectionDetailsConfiguration.java new file mode 100644 index 0000000000..3387356366 --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/JdbcConnectionDetailsConfiguration.java @@ -0,0 +1,17 @@ +package com.baeldung.connectiondetails.configuration; + +import org.springframework.boot.autoconfigure.jdbc.JdbcConnectionDetails; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; +import org.springframework.context.annotation.Profile; + +@Configuration(proxyBeanMethods = false) +@Profile("jdbc") +public class JdbcConnectionDetailsConfiguration { + @Bean + @Primary + public JdbcConnectionDetails getPostgresConnection() { + return new PostgresConnectionDetails(); + } +} diff --git a/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/MongoDBConnectionDetails.java b/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/MongoDBConnectionDetails.java new file mode 100644 index 0000000000..df689d81b6 --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/MongoDBConnectionDetails.java @@ -0,0 +1,14 @@ +package com.baeldung.connectiondetails.configuration; + + +import com.baeldung.connectiondetails.adapter.VaultAdapter; +import com.mongodb.ConnectionString; +import org.springframework.boot.autoconfigure.mongo.MongoConnectionDetails; + +public class MongoDBConnectionDetails implements MongoConnectionDetails { + @Override + public ConnectionString getConnectionString() { + return new ConnectionString(VaultAdapter.getSecret("mongo_connection_string")); + } +} + diff --git a/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/MongoDBConnectionDetailsConfiguration.java b/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/MongoDBConnectionDetailsConfiguration.java new file mode 100644 index 0000000000..d455991d08 --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/MongoDBConnectionDetailsConfiguration.java @@ -0,0 +1,17 @@ +package com.baeldung.connectiondetails.configuration; + +import org.springframework.boot.autoconfigure.mongo.MongoConnectionDetails; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; +import org.springframework.context.annotation.Profile; + +@Configuration(proxyBeanMethods = false) +@Profile("mongo") +public class MongoDBConnectionDetailsConfiguration { + @Bean + @Primary + public MongoConnectionDetails getMongoConnectionDetails() { + return new MongoDBConnectionDetails(); + } +} diff --git a/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/PostgresConnectionDetails.java b/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/PostgresConnectionDetails.java new file mode 100644 index 0000000000..c9b213a8d3 --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/PostgresConnectionDetails.java @@ -0,0 +1,21 @@ +package com.baeldung.connectiondetails.configuration; + +import com.baeldung.connectiondetails.adapter.VaultAdapter; +import org.springframework.boot.autoconfigure.jdbc.JdbcConnectionDetails; + +public class PostgresConnectionDetails implements JdbcConnectionDetails { + @Override + public String getUsername() { + return VaultAdapter.getSecret("postgres_user_key"); + } + + @Override + public String getPassword() { + return VaultAdapter.getSecret("postgres_secret_key"); + } + + @Override + public String getJdbcUrl() { + return VaultAdapter.getSecret("postgres_jdbc_url"); + } +} diff --git a/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/R2dbcPostgresConnectionDetails.java b/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/R2dbcPostgresConnectionDetails.java new file mode 100644 index 0000000000..4ce6abc9d5 --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/R2dbcPostgresConnectionDetails.java @@ -0,0 +1,22 @@ +package com.baeldung.connectiondetails.configuration; + +import com.baeldung.connectiondetails.adapter.VaultAdapter; +import io.r2dbc.spi.ConnectionFactoryOptions; +import org.springframework.boot.autoconfigure.r2dbc.R2dbcConnectionDetails; + +public class R2dbcPostgresConnectionDetails implements R2dbcConnectionDetails { + @Override + public ConnectionFactoryOptions getConnectionFactoryOptions() { + + ConnectionFactoryOptions options = ConnectionFactoryOptions.builder() + .option(ConnectionFactoryOptions.DRIVER, "postgresql") + .option(ConnectionFactoryOptions.HOST, VaultAdapter.getSecret("r2dbc_postgres_host")) + .option(ConnectionFactoryOptions.PORT, Integer.valueOf(VaultAdapter.getSecret("r2dbc_postgres_port"))) + .option(ConnectionFactoryOptions.USER, VaultAdapter.getSecret("r2dbc_postgres_user")) + .option(ConnectionFactoryOptions.PASSWORD, VaultAdapter.getSecret("r2dbc_postgres_secret")) + .option(ConnectionFactoryOptions.DATABASE, VaultAdapter.getSecret("r2dbc_postgres_database")) + .build(); + + return options; + } +} diff --git a/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/R2dbcPostgresConnectionDetailsConfiguration.java b/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/R2dbcPostgresConnectionDetailsConfiguration.java new file mode 100644 index 0000000000..144355dce4 --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/R2dbcPostgresConnectionDetailsConfiguration.java @@ -0,0 +1,17 @@ +package com.baeldung.connectiondetails.configuration; + +import org.springframework.boot.autoconfigure.r2dbc.R2dbcConnectionDetails; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; +import org.springframework.context.annotation.Profile; + +@Configuration(proxyBeanMethods = false) +@Profile("r2dbc") +public class R2dbcPostgresConnectionDetailsConfiguration { + @Bean + @Primary + public R2dbcConnectionDetails getR2dbcPostgresConnectionDetails() { + return new R2dbcPostgresConnectionDetails(); + } +} diff --git a/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/RabbitMQConnectionDetails.java b/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/RabbitMQConnectionDetails.java new file mode 100644 index 0000000000..9dc4bdf33b --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/RabbitMQConnectionDetails.java @@ -0,0 +1,34 @@ +package com.baeldung.connectiondetails.configuration; + +import com.baeldung.connectiondetails.adapter.VaultAdapter; +import org.springframework.boot.autoconfigure.amqp.RabbitConnectionDetails; + +import java.util.List; + +public class RabbitMQConnectionDetails implements RabbitConnectionDetails { + @Override + public String getUsername() { + return VaultAdapter.getSecret("rabbitmq_username"); + } + + @Override + public String getPassword() { + return VaultAdapter.getSecret("rabbitmq_password"); + } + + @Override + public String getVirtualHost() { + return "/"; + } + + @Override + public List
getAddresses() { + return List.of(this.getFirstAddress()); + } + + @Override + public Address getFirstAddress() { + return new Address(VaultAdapter.getSecret("rabbitmq_host"), + Integer.parseInt(VaultAdapter.getSecret("rabbitmq_port"))); + } +} diff --git a/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/RabbitMQConnectionDetailsConfiguration.java b/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/RabbitMQConnectionDetailsConfiguration.java new file mode 100644 index 0000000000..237bec3fc4 --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/RabbitMQConnectionDetailsConfiguration.java @@ -0,0 +1,17 @@ +package com.baeldung.connectiondetails.configuration; + +import org.springframework.boot.autoconfigure.amqp.RabbitConnectionDetails; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; +import org.springframework.context.annotation.Profile; + +@Configuration(proxyBeanMethods = false) +@Profile("rabbitmq") +public class RabbitMQConnectionDetailsConfiguration { + @Primary + @Bean + public RabbitConnectionDetails getRabbitmqConnection() { + return new RabbitMQConnectionDetails(); + } +} diff --git a/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/RedisCacheConnectionDetails.java b/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/RedisCacheConnectionDetails.java new file mode 100644 index 0000000000..9485f22240 --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/RedisCacheConnectionDetails.java @@ -0,0 +1,26 @@ +package com.baeldung.connectiondetails.configuration; + +import com.baeldung.connectiondetails.adapter.VaultAdapter; +import org.springframework.boot.autoconfigure.data.redis.RedisConnectionDetails; + +public class RedisCacheConnectionDetails implements RedisConnectionDetails { + @Override + public String getPassword() { + return VaultAdapter.getSecret("redis_password"); + } + + @Override + public Standalone getStandalone() { + return new Standalone() { + @Override + public String getHost() { + return VaultAdapter.getSecret("redis_host"); + } + + @Override + public int getPort() { + return Integer.parseInt(VaultAdapter.getSecret("redis_port")); + } + }; + } +} diff --git a/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/RedisConnectionDetailsConfiguration.java b/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/RedisConnectionDetailsConfiguration.java new file mode 100644 index 0000000000..31816ff0b4 --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/configuration/RedisConnectionDetailsConfiguration.java @@ -0,0 +1,17 @@ +package com.baeldung.connectiondetails.configuration; + +import org.springframework.boot.autoconfigure.data.redis.RedisConnectionDetails; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; +import org.springframework.context.annotation.Profile; + +@Configuration(proxyBeanMethods = false) +@Profile("redis") +public class RedisConnectionDetailsConfiguration { + @Bean + @Primary + public RedisConnectionDetails getRedisCacheConnection() { + return new RedisCacheConnectionDetails(); + } +} diff --git a/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/controller/ZipkinDemoController.java b/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/controller/ZipkinDemoController.java new file mode 100644 index 0000000000..bba5607ccd --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/controller/ZipkinDemoController.java @@ -0,0 +1,19 @@ +package com.baeldung.connectiondetails.controller; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class ZipkinDemoController { + + Logger logger = LoggerFactory.getLogger(ZipkinDemoController.class); + + @GetMapping("/zipkin/test") + public @ResponseBody String testMethod() { + logger.info("This is a test"); + return "This is a test"; + } +} diff --git a/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/entity/elastic/Person.java b/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/entity/elastic/Person.java new file mode 100644 index 0000000000..851dbb7c90 --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/entity/elastic/Person.java @@ -0,0 +1,27 @@ +package com.baeldung.connectiondetails.entity.elastic; + +import org.springframework.data.annotation.Id; +import org.springframework.data.elasticsearch.annotations.Document; + +@Document(indexName = "person") +public class Person { + String name; + @Id + String ssn; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getSsn() { + return ssn; + } + + public void setSsn(String ssn) { + this.ssn = ssn; + } +} diff --git a/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/entity/neo4j/Person.java b/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/entity/neo4j/Person.java new file mode 100644 index 0000000000..63e88d0a41 --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/main/java/com/baeldung/connectiondetails/entity/neo4j/Person.java @@ -0,0 +1,27 @@ +package com.baeldung.connectiondetails.entity.neo4j; + +import org.springframework.data.neo4j.core.schema.Id; +import org.springframework.data.neo4j.core.schema.Node; + +@Node +public class Person { + @Id + String name; + String zipcode; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getZipcode() { + return zipcode; + } + + public void setZipcode(String zipcode) { + this.zipcode = zipcode; + } +} \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/application-cassandra.properties b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/application-cassandra.properties new file mode 100644 index 0000000000..4098206d21 --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/application-cassandra.properties @@ -0,0 +1,11 @@ +spring.docker.compose.enabled=true +spring.docker.compose.file=./connectiondetails/docker/docker-compose-cassandra.yml +spring.docker.compose.skip.in-tests=false +spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true +spring.mustache.check-template-location=false +spring.profiles.active=cassandra +spring.cassandra.local-datacenter=dc1 +#spring.cassandra.keyspace-name=spring_cassandra +#spring.cassandra.schema-action=CREATE_IF_NOT_EXISTS +spring.data.cassandra.request.timeout=20000 # Set your desired timeout in milliseconds +spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.data.mongo.MongoRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration, org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration, org.springframework.boot.autoconfigure.data.redis.RedisRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.data.r2dbc.R2dbcDataAutoConfiguration, org.springframework.boot.autoconfigure.data.r2dbc.R2dbcRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.r2dbc.R2dbcAutoConfiguration, org.springframework.boot.autoconfigure.data.neo4j.Neo4jDataAutoConfiguration, org.springframework.boot.autoconfigure.data.neo4j.Neo4jRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.neo4j.Neo4jAutoConfiguration, org.springframework.boot.autoconfigure.kafka.KafkaAutoConfiguration, org.springframework.boot.autoconfigure.couchbase.CouchbaseAutoConfiguration, org.springframework.boot.autoconfigure.data.couchbase.CouchbaseDataAutoConfiguration, org.springframework.boot.autoconfigure.data.couchbase.CouchbaseRepositoriesAutoConfiguration \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/application-couch.properties b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/application-couch.properties new file mode 100644 index 0000000000..ccce04c0b5 --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/application-couch.properties @@ -0,0 +1,8 @@ +spring.profiles.active=couch +spring.docker.compose.enabled=false +spring.docker.compose.file=./connectiondetails/docker/docker-compose-couch.yml +spring.docker.compose.skip.in-tests=false +spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true +spring.mustache.check-template-location=false +spring.couchbase.bucket.name=travel-sample +spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.data.mongo.MongoRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration, org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration, org.springframework.boot.autoconfigure.data.redis.RedisRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.data.r2dbc.R2dbcDataAutoConfiguration, org.springframework.boot.autoconfigure.data.r2dbc.R2dbcRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.r2dbc.R2dbcAutoConfiguration, org.springframework.boot.autoconfigure.data.neo4j.Neo4jDataAutoConfiguration, org.springframework.boot.autoconfigure.data.neo4j.Neo4jRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.neo4j.Neo4jAutoConfiguration, org.springframework.boot.autoconfigure.kafka.KafkaAutoConfiguration, org.springframework.boot.autoconfigure.data.cassandra.CassandraRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration, org.springframework.boot.autoconfigure.data.cassandra.CassandraDataAutoConfiguration, org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchDataAutoConfiguration, org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.data.elasticsearch.ReactiveElasticsearchRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.elasticsearch.ReactiveElasticsearchClientAutoConfiguration, org.springframework.boot.autoconfigure.data.cassandra.CassandraReactiveDataAutoConfiguration, org.springframework.boot.autoconfigure.data.cassandra.CassandraReactiveRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.data.neo4j.Neo4jReactiveDataAutoConfiguration, org.springframework.boot.autoconfigure.data.neo4j.Neo4jReactiveRepositoriesAutoConfiguration diff --git a/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/application-elastic.properties b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/application-elastic.properties new file mode 100644 index 0000000000..2149730517 --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/application-elastic.properties @@ -0,0 +1,7 @@ +spring.docker.compose.enabled=true +spring.docker.compose.file=./connectiondetails/docker/docker-compose-elastic.yml +spring.docker.compose.skip.in-tests=false +spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true +spring.mustache.check-template-location=false +spring.profiles.active=elastic +spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.data.mongo.MongoRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration, org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration, org.springframework.boot.autoconfigure.data.redis.RedisRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.data.r2dbc.R2dbcDataAutoConfiguration, org.springframework.boot.autoconfigure.data.r2dbc.R2dbcRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.r2dbc.R2dbcAutoConfiguration, org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration, org.springframework.boot.autoconfigure.data.cassandra.CassandraDataAutoConfiguration, org.springframework.boot.autoconfigure.data.cassandra.CassandraRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.data.neo4j.Neo4jDataAutoConfiguration, org.springframework.boot.autoconfigure.data.neo4j.Neo4jRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.neo4j.Neo4jAutoConfiguration, org.springframework.boot.autoconfigure.kafka.KafkaAutoConfiguration, org.springframework.boot.autoconfigure.couchbase.CouchbaseAutoConfiguration, org.springframework.boot.autoconfigure.data.couchbase.CouchbaseDataAutoConfiguration, org.springframework.boot.autoconfigure.data.couchbase.CouchbaseRepositoriesAutoConfiguration \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/application-jdbc.properties b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/application-jdbc.properties new file mode 100644 index 0000000000..b5a8a73bcf --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/application-jdbc.properties @@ -0,0 +1,7 @@ +spring.docker.compose.enabled=true +spring.docker.compose.file=./connectiondetails/docker/docker-compose-jdbc.yml +spring.docker.compose.skip.in-tests=false +spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true +spring.mustache.check-template-location=false +spring.profiles.active=jdbc +spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.data.mongo.MongoRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration, org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration, org.springframework.boot.autoconfigure.data.redis.RedisRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.data.r2dbc.R2dbcDataAutoConfiguration, org.springframework.boot.autoconfigure.data.r2dbc.R2dbcRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.r2dbc.R2dbcAutoConfiguration, org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchDataAutoConfiguration, org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration, org.springframework.boot.autoconfigure.data.cassandra.CassandraDataAutoConfiguration, org.springframework.boot.autoconfigure.data.cassandra.CassandraRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.data.neo4j.Neo4jDataAutoConfiguration, org.springframework.boot.autoconfigure.data.neo4j.Neo4jRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.neo4j.Neo4jAutoConfiguration, org.springframework.boot.autoconfigure.kafka.KafkaAutoConfiguration, org.springframework.boot.autoconfigure.couchbase.CouchbaseAutoConfiguration, org.springframework.boot.autoconfigure.data.couchbase.CouchbaseDataAutoConfiguration, org.springframework.boot.autoconfigure.data.couchbase.CouchbaseRepositoriesAutoConfiguration \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/application-kafka.properties b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/application-kafka.properties new file mode 100644 index 0000000000..9f756cfaf1 --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/application-kafka.properties @@ -0,0 +1,7 @@ +spring.docker.compose.enabled=true +spring.docker.compose.file=./connectiondetails/docker/docker-compose-kafka.yml +spring.docker.compose.skip.in-tests=false +spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true +spring.mustache.check-template-location=false +spring.profiles.active=kafka +spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.data.mongo.MongoRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration, org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration, org.springframework.boot.autoconfigure.data.redis.RedisRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.data.r2dbc.R2dbcDataAutoConfiguration, org.springframework.boot.autoconfigure.data.r2dbc.R2dbcRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.r2dbc.R2dbcAutoConfiguration, org.springframework.boot.autoconfigure.data.neo4j.Neo4jDataAutoConfiguration, org.springframework.boot.autoconfigure.data.neo4j.Neo4jRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.neo4j.Neo4jAutoConfiguration, org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration, org.springframework.boot.autoconfigure.data.cassandra.CassandraDataAutoConfiguration, org.springframework.boot.autoconfigure.data.cassandra.CassandraRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.couchbase.CouchbaseAutoConfiguration, org.springframework.boot.autoconfigure.data.couchbase.CouchbaseDataAutoConfiguration, org.springframework.boot.autoconfigure.data.couchbase.CouchbaseRepositoriesAutoConfiguration \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/application-mongo.properties b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/application-mongo.properties new file mode 100644 index 0000000000..31d828c5c9 --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/application-mongo.properties @@ -0,0 +1,8 @@ +spring.docker.compose.enabled=true +spring.docker.compose.file=./connectiondetails/docker/docker-compose-mongo.yml +spring.docker.compose.skip.in-tests=false +spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true +spring.mustache.check-template-location=false +spring.profiles.active=mongo +spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.data.mongo.MongoRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.data.redis.RedisRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.data.r2dbc.R2dbcDataAutoConfiguration, org.springframework.boot.autoconfigure.data.r2dbc.R2dbcRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.r2dbc.R2dbcAutoConfiguration, org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchDataAutoConfiguration, org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration, org.springframework.boot.autoconfigure.data.cassandra.CassandraDataAutoConfiguration, org.springframework.boot.autoconfigure.data.cassandra.CassandraRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.data.neo4j.Neo4jDataAutoConfiguration, org.springframework.boot.autoconfigure.data.neo4j.Neo4jRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.neo4j.Neo4jAutoConfiguration, org.springframework.boot.autoconfigure.kafka.KafkaAutoConfiguration, org.springframework.boot.autoconfigure.couchbase.CouchbaseAutoConfiguration, org.springframework.boot.autoconfigure.data.couchbase.CouchbaseDataAutoConfiguration, org.springframework.boot.autoconfigure.data.couchbase.CouchbaseRepositoriesAutoConfiguration +spring.data.mongodb.database=demodb \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/application-neo4j.properties b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/application-neo4j.properties new file mode 100644 index 0000000000..e2dc9e20bf --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/application-neo4j.properties @@ -0,0 +1,7 @@ +spring.docker.compose.enabled=true +spring.docker.compose.file=./connectiondetails/docker/docker-compose-neo4j.yml +spring.docker.compose.skip.in-tests=false +spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true +spring.mustache.check-template-location=false +spring.profiles.active=neo4j +spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration, org.springframework.boot.autoconfigure.data.mongo.MongoRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration, org.springframework.boot.autoconfigure.data.redis.RedisRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.data.r2dbc.R2dbcDataAutoConfiguration, org.springframework.boot.autoconfigure.data.r2dbc.R2dbcRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.r2dbc.R2dbcAutoConfiguration, org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchDataAutoConfiguration, org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration, org.springframework.boot.autoconfigure.data.cassandra.CassandraDataAutoConfiguration, org.springframework.boot.autoconfigure.data.cassandra.CassandraRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.kafka.KafkaAutoConfiguration, org.springframework.boot.autoconfigure.couchbase.CouchbaseAutoConfiguration, org.springframework.boot.autoconfigure.data.couchbase.CouchbaseDataAutoConfiguration, org.springframework.boot.autoconfigure.data.couchbase.CouchbaseRepositoriesAutoConfiguration \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/application-r2dbc.properties b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/application-r2dbc.properties new file mode 100644 index 0000000000..3fcaa4f746 --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/application-r2dbc.properties @@ -0,0 +1,7 @@ +spring.docker.compose.enabled=true +spring.docker.compose.file=./connectiondetails/docker/docker-compose-jdbc.yml +spring.docker.compose.skip.in-tests=false +spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true +spring.mustache.check-template-location=false +spring.profiles.active=r2dbc +spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.data.mongo.MongoRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration, org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration, org.springframework.boot.autoconfigure.data.redis.RedisRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.data.jdbc.JdbcRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.jdbc.JdbcTemplateAutoConfiguration, org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchDataAutoConfiguration, org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration, org.springframework.boot.autoconfigure.data.cassandra.CassandraDataAutoConfiguration, org.springframework.boot.autoconfigure.data.cassandra.CassandraRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.data.neo4j.Neo4jDataAutoConfiguration, org.springframework.boot.autoconfigure.data.neo4j.Neo4jRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.neo4j.Neo4jAutoConfiguration, org.springframework.boot.autoconfigure.kafka.KafkaAutoConfiguration, org.springframework.boot.autoconfigure.couchbase.CouchbaseAutoConfiguration, org.springframework.boot.autoconfigure.data.couchbase.CouchbaseDataAutoConfiguration, org.springframework.boot.autoconfigure.data.couchbase.CouchbaseRepositoriesAutoConfiguration \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/application-rabbitmq.properties b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/application-rabbitmq.properties new file mode 100644 index 0000000000..fa6b3f6608 --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/application-rabbitmq.properties @@ -0,0 +1,7 @@ +spring.docker.compose.enabled=true +spring.docker.compose.file=./connectiondetails/docker/docker-compose-rabbitmq.yml +spring.docker.compose.skip.in-tests=false +spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true +spring.mustache.check-template-location=false +spring.profiles.active=rabbitmq +spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.data.mongo.MongoRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration, org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration, org.springframework.boot.autoconfigure.data.redis.RedisRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.data.r2dbc.R2dbcDataAutoConfiguration, org.springframework.boot.autoconfigure.data.r2dbc.R2dbcRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.r2dbc.R2dbcAutoConfiguration, org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchDataAutoConfiguration, org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration, org.springframework.boot.autoconfigure.data.cassandra.CassandraDataAutoConfiguration, org.springframework.boot.autoconfigure.data.cassandra.CassandraRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.data.neo4j.Neo4jDataAutoConfiguration, org.springframework.boot.autoconfigure.data.neo4j.Neo4jRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.neo4j.Neo4jAutoConfiguration, org.springframework.boot.autoconfigure.kafka.KafkaAutoConfiguration, org.springframework.boot.autoconfigure.couchbase.CouchbaseAutoConfiguration, org.springframework.boot.autoconfigure.data.couchbase.CouchbaseDataAutoConfiguration, org.springframework.boot.autoconfigure.data.couchbase.CouchbaseRepositoriesAutoConfiguration \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/application-redis.properties b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/application-redis.properties new file mode 100644 index 0000000000..c12f20c773 --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/application-redis.properties @@ -0,0 +1,7 @@ +spring.docker.compose.enabled=true +spring.docker.compose.file=./connectiondetails/docker/docker-compose-redis.yml +spring.docker.compose.skip.in-tests=false +spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true +spring.mustache.check-template-location=false +spring.profiles.active=redis +spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.data.mongo.MongoRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration, org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration, org.springframework.boot.autoconfigure.data.redis.RedisRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.data.r2dbc.R2dbcDataAutoConfiguration, org.springframework.boot.autoconfigure.data.r2dbc.R2dbcRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.r2dbc.R2dbcAutoConfiguration, org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchDataAutoConfiguration, org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration, org.springframework.boot.autoconfigure.data.cassandra.CassandraDataAutoConfiguration, org.springframework.boot.autoconfigure.data.cassandra.CassandraRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.data.neo4j.Neo4jDataAutoConfiguration, org.springframework.boot.autoconfigure.data.neo4j.Neo4jRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.neo4j.Neo4jAutoConfiguration, org.springframework.boot.autoconfigure.kafka.KafkaAutoConfiguration, org.springframework.boot.autoconfigure.couchbase.CouchbaseAutoConfiguration, org.springframework.boot.autoconfigure.data.couchbase.CouchbaseDataAutoConfiguration, org.springframework.boot.autoconfigure.data.couchbase.CouchbaseRepositoriesAutoConfiguration \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/application-zipkin.properties b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/application-zipkin.properties new file mode 100644 index 0000000000..544a3c07b6 --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/application-zipkin.properties @@ -0,0 +1,9 @@ +spring.profiles.active=zipkin +spring.docker.compose.enabled=false +spring.docker.compose.file=./connectiondetails/docker/docker-compose-zipkin.yml +spring.docker.compose.skip.in-tests=false +spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true +spring.mustache.check-template-location=false +spring.application.name=baeldung +management.tracing.sampling.probability=1.0 +spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.data.mongo.MongoRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration, org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration, org.springframework.boot.autoconfigure.data.redis.RedisRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.data.r2dbc.R2dbcDataAutoConfiguration, org.springframework.boot.autoconfigure.data.r2dbc.R2dbcRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.r2dbc.R2dbcAutoConfiguration, org.springframework.boot.autoconfigure.data.neo4j.Neo4jDataAutoConfiguration, org.springframework.boot.autoconfigure.data.neo4j.Neo4jRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.neo4j.Neo4jAutoConfiguration, org.springframework.boot.autoconfigure.kafka.KafkaAutoConfiguration, org.springframework.boot.autoconfigure.data.cassandra.CassandraRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration, org.springframework.boot.autoconfigure.data.cassandra.CassandraDataAutoConfiguration, org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchDataAutoConfiguration, org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.data.elasticsearch.ReactiveElasticsearchRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.elasticsearch.ReactiveElasticsearchClientAutoConfiguration, org.springframework.boot.autoconfigure.data.cassandra.CassandraReactiveDataAutoConfiguration, org.springframework.boot.autoconfigure.data.cassandra.CassandraReactiveRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.data.neo4j.Neo4jReactiveDataAutoConfiguration, org.springframework.boot.autoconfigure.data.neo4j.Neo4jReactiveRepositoriesAutoConfiguration diff --git a/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/docker/docker-compose-cassandra.yml b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/docker/docker-compose-cassandra.yml new file mode 100644 index 0000000000..c593cbc73b --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/docker/docker-compose-cassandra.yml @@ -0,0 +1,9 @@ +version: '3.8' +services: + cassandra: + image: 'cassandra:latest' + environment: + - 'CASSANDRA_DC=datacenter-1' + - 'CASSANDRA_ENDPOINT_SNITCH=GossipingPropertyFileSnitch' + ports: + - '19042:9042' \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/docker/docker-compose-couch.yml b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/docker/docker-compose-couch.yml new file mode 100644 index 0000000000..edcf8e2e08 --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/docker/docker-compose-couch.yml @@ -0,0 +1,12 @@ +version: '3.8' +services: + couchbase: + image: couchbase/server-sandbox:7.0.0 + ports: + - "8091-8095:8091-8095" + - "9102:9102" + - "11210:11210" + expose: + - "8091" + - "8094" + container_name: couchbase-sandbox-7.0.0-mm \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/docker/docker-compose-elastic.yml b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/docker/docker-compose-elastic.yml new file mode 100644 index 0000000000..a6e51ee1a0 --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/docker/docker-compose-elastic.yml @@ -0,0 +1,12 @@ +version: '3.8' +services: + elasticsearch: + image: 'docker.elastic.co/elasticsearch/elasticsearch:7.17.10' + environment: + - 'ELASTIC_USERNAME=elastic' + - 'ELASTIC_PASSWORD=secret' + - 'discovery.type=single-node' + - 'xpack.security.enabled=false' + ports: + - '19200:9200' +# - '19300:9300' \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/docker/docker-compose-jdbc.yml b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/docker/docker-compose-jdbc.yml new file mode 100644 index 0000000000..65a8f135e8 --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/docker/docker-compose-jdbc.yml @@ -0,0 +1,10 @@ +version: '3.8' +services: + database: + image: 'postgres:13.1-alpine' + ports: + - '15432:5432' + environment: + - 'POSTGRES_USER=postgres' + - 'POSTGRES_DB=postgresdb' + - 'POSTGRES_PASSWORD=postgres' \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/docker/docker-compose-kafka.yml b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/docker/docker-compose-kafka.yml new file mode 100644 index 0000000000..5d13e6d6cc --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/docker/docker-compose-kafka.yml @@ -0,0 +1,38 @@ +version: '3' +services: + zookeeper: + image: confluentinc/cp-zookeeper:latest + container_name: zookeeper + environment: + ZOOKEEPER_CLIENT_PORT: 2181 + ZOOKEEPER_TICK_TIME: 2000 + ports: + - "2181:2181" + + schema-registry: + image: confluentinc/cp-schema-registry:latest + hostname: schema-registry + depends_on: + - kafka-broker-1 + ports: + - "8081:8081" + environment: + SCHEMA_REGISTRY_HOST_NAME: schema-registry + SCHEMA_REGISTRY_KAFKASTORE_CONNECTION_URL: 'zookeeper:2181' + SCHEMA_REGISTRY_LISTENERS: http://schema-registry:8081 + SCHEMA_REGISTRY_KAFKASTORE_BOOTSTRAP_SERVERS: PLAINTEXT://kafka-broker-1:9092,PLAINTEXT_INTERNAL://localhost:19092 + SCHEMA_REGISTRY_DEBUG: 'true' + + kafka-broker-1: + image: confluentinc/cp-kafka:latest + hostname: kafka-broker-1 + ports: + - "19092:19092" + depends_on: + - zookeeper + environment: + KAFKA_BROKER_ID: 1 + KAFKA_ZOOKEEPER_CONNECT: 'zookeeper:2181' + KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_INTERNAL:PLAINTEXT + KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka-broker-1:9092,PLAINTEXT_INTERNAL://localhost:19092 + KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1 \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/docker/docker-compose-mongo.yml b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/docker/docker-compose-mongo.yml new file mode 100644 index 0000000000..f12f5c3aa7 --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/docker/docker-compose-mongo.yml @@ -0,0 +1,10 @@ +version: '3.8' +services: + mongodb: + image: 'mongo:latest' + environment: + - 'MONGO_INITDB_DATABASE=demodb' +# - 'MONGO_INITDB_ROOT_PASSWORD=Mongo123' +# - 'MONGO_INITDB_ROOT_USERNAME=mongouser' + ports: + - '27017:27017' \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/docker/docker-compose-neo4j.yml b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/docker/docker-compose-neo4j.yml new file mode 100644 index 0000000000..611951e755 --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/docker/docker-compose-neo4j.yml @@ -0,0 +1,8 @@ +version: '3.8' +services: + neo4j: + image: 'neo4j:latest' + ports: + - '17687:7687' + environment: + NEO4J_AUTH: neo4j/neo4j123 \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/docker/docker-compose-rabbitmq.yml b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/docker/docker-compose-rabbitmq.yml new file mode 100644 index 0000000000..8abf19bd19 --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/docker/docker-compose-rabbitmq.yml @@ -0,0 +1,9 @@ +version: '3.8' +services: + rabbitmq: + image: 'rabbitmq:latest' + environment: + - 'RABBITMQ_DEFAULT_PASS=rabbitmq' + - 'RABBITMQ_DEFAULT_USER=rabbitmquser' + ports: + - '5672:5672' \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/docker/docker-compose-redis.yml b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/docker/docker-compose-redis.yml new file mode 100644 index 0000000000..c218cef998 --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/docker/docker-compose-redis.yml @@ -0,0 +1,8 @@ +version: '3.8' +services: + redis: + image: 'redis:latest' + ports: + - '6379:6379' + environment: + - 'REDIS_REQUIREPASS=redis' \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/docker/docker-compose-zipkin.yml b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/docker/docker-compose-zipkin.yml new file mode 100644 index 0000000000..363dd24a2b --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/docker/docker-compose-zipkin.yml @@ -0,0 +1,10 @@ +version: '3' +services: + zipkin: + image: 'openzipkin/zipkin:latest' + ports: + - "9411:9411" +# environment: +# - ZIPKIN_AUTH_USERNAME=your-username +# - ZIPKIN_AUTH_PASSWORD=your-password + # Add other necessary configurations here diff --git a/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/plantuml/cassandra-connection-details-class-diag.puml b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/plantuml/cassandra-connection-details-class-diag.puml new file mode 100644 index 0000000000..b16ef4d56e --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/plantuml/cassandra-connection-details-class-diag.puml @@ -0,0 +1,27 @@ +@startuml +'https://plantuml.com/class-diagram + +interface CassandraConnectionDetails { + +getUsername():String + +getPassword():String + +getContactPoints():List + +getLocalDatacenter():String +} +class CustomCouchBaseConnectionDetails { + +getUsername():String + +getPassword():String + +getContactPoints():List + +getLocalDatacenter():String +} +class VaultAdapter { + +getSecret(String secretKey):String +} +class CustomCassandraConnectionDetailsConfiguration { + +getCustomCassandraConnectionDetails():CassandraConnectionDetails +} +CustomCouchBaseConnectionDetails -left-> VaultAdapter:uses +CustomCouchBaseConnectionDetails -right-|> CassandraConnectionDetails : implements +CustomCassandraConnectionDetailsConfiguration -up-> CustomCassandraConnectionDetails:uses + + +@enduml \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/plantuml/connection-details-sequence-design.puml b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/plantuml/connection-details-sequence-design.puml new file mode 100644 index 0000000000..a2a917eea0 --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/plantuml/connection-details-sequence-design.puml @@ -0,0 +1,16 @@ +@startuml +'https://plantuml.com/sequence-diagram +skinparam sequenceMessageAlign direction +skinparam handwritten true +skinparam sequence { +ParticipantBackgroundColor beige +ParticipantPadding 50 +} +autonumber + +"Spring Boot" -[#63b175]> "Hashicorp Vault": Secret Request +"Hashicorp Vault" -[#63b175]-> "Spring Boot": Secret Response +"Spring Boot" -[#63b175]> "Remote Service": Connection Request + +"Remote Service" -[#63b175]-> "Spring Boot": Connection Response +@enduml \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/plantuml/couch_connection_details_class_diag.puml b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/plantuml/couch_connection_details_class_diag.puml new file mode 100644 index 0000000000..fd8dbd094b --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/plantuml/couch_connection_details_class_diag.puml @@ -0,0 +1,25 @@ +@startuml +'https://plantuml.com/class-diagram + +interface CouchbaseConnectionDetails { + +getUsername():String + +getPassword():String + +getConnectionString():String +} +class CustomCouchBaseConnectionDetails { + +getUsername():String + +getPassword():String + +getConnectionString():String +} +class VaultAdapter { + +getSecret(String secretKey):String +} +class CustomCouchBaseConnectionDetailsConfiguration { + +getCouchBaseConnectionDetails():CouchbaseConnectionDetails +} +CustomCouchBaseConnectionDetails -left-> VaultAdapter:uses +CustomCouchBaseConnectionDetails -right-|> CouchbaseConnectionDetails : implements +CustomCouchBaseConnectionDetailsConfiguration -up-> CustomCouchBaseConnectionDetails:uses + + +@enduml \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/plantuml/elasticsearch-connection-details-class-diag.puml b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/plantuml/elasticsearch-connection-details-class-diag.puml new file mode 100644 index 0000000000..48db0bcc4f --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/plantuml/elasticsearch-connection-details-class-diag.puml @@ -0,0 +1,25 @@ +@startuml +'https://plantuml.com/class-diagram + +interface ElasticsearchConnectionDetails { + +getUsername():String + +getPassword():String + +getNodes():List +} +class CustomElasticsearchConnectionDetails { + +getUsername():String + +getPassword():String + +getNodes():List +} +class VaultAdapter { + +getSecret(String secretKey):String +} +class CustomElasticsearchConnectionDetailsConfiguration { + +getCustomElasticConnectionDetails():ElasticsearchConnectionDetails +} +CustomElasticsearchConnectionDetails -left-> VaultAdapter:uses +CustomElasticsearchConnectionDetails -right-|> ElasticsearchConnectionDetails : implements +CustomElasticsearchConnectionDetailsConfiguration -up-> CustomElasticsearchConnectionDetails:uses + + +@enduml \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/plantuml/jdbcconnection-details-class-diag.puml b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/plantuml/jdbcconnection-details-class-diag.puml new file mode 100644 index 0000000000..88de5d607f --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/plantuml/jdbcconnection-details-class-diag.puml @@ -0,0 +1,25 @@ +@startuml +'https://plantuml.com/class-diagram + +interface JdbcConnectionDetails { + +getUsername():String + +getPassword():String + +getJdbcUrl():String +} +class PostgresConnectionDetails { + +getUsername():String + +getPassword():String + +getJdbcUrl():String +} +class VaultAdapter { + +getSecret(String secretKey):String +} +class JdbcConnectonDetailsConfiguration { + +getPostgresConnection():JdbcConnectionDetails +} +PostgresConnectionDetails -left-> VaultAdapter:uses +PostgresConnectionDetails -right-|> JdbcConnectionDetails : implements +JdbcConnectonDetailsConfiguration -up-> PostgresConnectionDetails:uses + + +@enduml \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/plantuml/kafka-connectiondetails-class-diag.puml b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/plantuml/kafka-connectiondetails-class-diag.puml new file mode 100644 index 0000000000..57df331bb2 --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/plantuml/kafka-connectiondetails-class-diag.puml @@ -0,0 +1,21 @@ +@startuml +'https://plantuml.com/class-diagram + +interface KafkaConnectionDetails { + +getBootstrapServers():List +} +class CustomKafkaConnectionDetails { ++getBootstrapServers():List +} +class VaultAdapter { + +getSecret(String secretKey):String +} +class CustomKafkaConnectionDetailsConfiguration { + +getKafkaConnectionDetails():KafkaConnectionDetails +} +CustomKafkaConnectionDetails -left-> VaultAdapter:uses +CustomKafkaConnectionDetails -right-|> KafkaConnectionDetails:implements +CustomKafkaConnectionDetailsConfiguration -up-> CustomKafkaConnectionDetails:uses + + +@enduml \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/plantuml/mongodb-connection-details-class-diag.puml b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/plantuml/mongodb-connection-details-class-diag.puml new file mode 100644 index 0000000000..974c6de601 --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/plantuml/mongodb-connection-details-class-diag.puml @@ -0,0 +1,19 @@ +@startuml +'https://plantuml.com/class-diagram + +interface MongoConnectionDetails { + getConnectionString():ConnectionString +} +class MongoDBConnectionDetails { + getConnectionString():ConnectionString +} +class VaultAdapter { + +getSecret(String secretKey):String +} +class MongoDBConnectionDetailsConfiguration { + +getMongoConnectionDetails() : MongoConnectionDetails +} +MongoDBConnectionDetails -left-> VaultAdapter:uses +MongoDBConnectionDetails -right-|> MongoConnectionDetails : implements +MongoDBConnectionDetailsConfiguration -up-> MongoDBConnectionDetails:uses +@enduml \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/plantuml/neo4j-connection-details-class-diag.puml b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/plantuml/neo4j-connection-details-class-diag.puml new file mode 100644 index 0000000000..5a3e8812f6 --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/plantuml/neo4j-connection-details-class-diag.puml @@ -0,0 +1,23 @@ +@startuml +'https://plantuml.com/class-diagram + +interface Neo4jConnectionDetails { + +getUri():URI + +getAuthToken():AuthToken +} +class CustomNeo4jConnectionDetails { + +getUri():URI + +getAuthToken():AuthToken +} +class VaultAdapter { + +getSecret(String secretKey):String +} +class CustomNeo4jConnectionDetailsConfiguration { + +getNeo4jConnectionDetails():Neo4jConnectionDetails +} +CustomNeo4jConnectionDetails -left-> VaultAdapter:uses +CustomNeo4jConnectionDetails -right-|> Neo4jConnectionDetails:implements +CustomNeo4jConnectionDetailsConfiguration -up-> CustomNeo4jConnectionDetails:uses + + +@enduml \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/plantuml/r2dbcconnection-details-class-diag.puml b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/plantuml/r2dbcconnection-details-class-diag.puml new file mode 100644 index 0000000000..ec69587ab9 --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/plantuml/r2dbcconnection-details-class-diag.puml @@ -0,0 +1,21 @@ +@startuml +'https://plantuml.com/class-diagram + +interface R2dbcConnectionDetails { + +getConnectionFactoryOptions():ConnectionFactoryOptions +} +class R2dbcPostgresConnectionDetails { + +getConnectionFactoryOptions():ConnectionFactoryOptions +} +class VaultAdapter { + +getSecret(String secretKey):String +} +class R2dbcPostgresConnectionDetailsConfiguration { + +getR2dbcPostgresConnectionDetails():R2dbcConnectionDetails +} +R2dbcPostgresConnectionDetails -right-> VaultAdapter:uses +R2dbcPostgresConnectionDetails -up-|> R2dbcConnectionDetails:implements +R2dbcPostgresConnectionDetailsConfiguration -up-> R2dbcPostgresConnectionDetails:uses + + +@enduml \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/plantuml/rabbitmq-connection-details-class-diag.puml b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/plantuml/rabbitmq-connection-details-class-diag.puml new file mode 100644 index 0000000000..0541e12915 --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/plantuml/rabbitmq-connection-details-class-diag.puml @@ -0,0 +1,27 @@ +@startuml +'https://plantuml.com/class-diagram + +interface RabbitConnectionDetails { + +getUsername():String + +getPassword():String + +getFirstAddress():Address + +getAddresses():List
+} +class RabbitMQConnectionDetails { + +getUsername():String + +getPassword():String + +getFirstAddress():Address + +getAddresses():List
+} +class VaultAdapter { + +getSecret(String secretKey):String +} +class RabbitMQConnectionDetailsConfiguration { + +getRabbitmqConnection() : RabbitConnectionDetails +} +RabbitMQConnectionDetails -left-> VaultAdapter:uses +RabbitMQConnectionDetails -right-|> RabbitConnectionDetails : implements +RabbitMQConnectionDetailsConfiguration -up-> RabbitMQConnectionDetails:uses + + +@enduml \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/plantuml/redis-connection-details-class-diagram.puml b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/plantuml/redis-connection-details-class-diagram.puml new file mode 100644 index 0000000000..a18c83a8be --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/plantuml/redis-connection-details-class-diagram.puml @@ -0,0 +1,23 @@ +@startuml +'https://plantuml.com/class-diagram + +interface RedisConnectionDetails { + +getPassword():String + +getStandalone():Standalone +} +class RedisCacheConnectionDetails { + +getPassword():String + +getStandalone():Standalone +} +class VaultAdapter { + +getSecret(String secretKey):String +} +class RedisConnectonDetailsConfiguration { + +getRedisCacheConnection():RedisConnectionDetails +} +RedisCacheConnectionDetails -left-> VaultAdapter:uses +RedisCacheConnectionDetails -right-|> RedisConnectionDetails : implements +RedisConnectonDetailsConfiguration -up-> RedisCacheConnectionDetails:uses + + +@enduml \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/plantuml/zipkin-connection-details-class-diag.puml b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/plantuml/zipkin-connection-details-class-diag.puml new file mode 100644 index 0000000000..0f185f9c12 --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/main/resources/connectiondetails/plantuml/zipkin-connection-details-class-diag.puml @@ -0,0 +1,21 @@ +@startuml +'https://plantuml.com/class-diagram + +interface ZipkinConnectionDetails { + +getSpanEndpoint():String +} +class CustomZipkinConnectionDetails { + +getSpanEndpoint():String +} +class VaultAdapter { + +getSecret(String secretKey):String +} +class CustomZipkinConnectionDetailsConfiguration { + +getZipkinConnectionDetails():ZipkinConnectionDetails +} +CustomZipkinConnectionDetails -left-> VaultAdapter:uses +CustomZipkinConnectionDetails -right-|> ZipkinConnectionDetails:implements +CustomZipkinConnectionDetailsConfiguration -up-> CustomZipkinConnectionDetails:uses + + +@enduml \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-3-1/src/test/java/com/baeldung/connectiondetails/CassandraConnectionDetailsIntegrationTest.java b/spring-boot-modules/spring-boot-3-1/src/test/java/com/baeldung/connectiondetails/CassandraConnectionDetailsIntegrationTest.java new file mode 100644 index 0000000000..4130b6cb6b --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/test/java/com/baeldung/connectiondetails/CassandraConnectionDetailsIntegrationTest.java @@ -0,0 +1,37 @@ +package com.baeldung.connectiondetails; + +import com.baeldung.connectiondetails.configuration.CustomCassandraConnectionDetailsConfiguration; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Import; +import org.springframework.data.cassandra.core.CassandraTemplate; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit4.SpringRunner; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = ConnectionDetailsApplication.class) +@Import(CustomCassandraConnectionDetailsConfiguration.class) +@ComponentScan(basePackages = "com.baeldung.connectiondetails") +@TestPropertySource(locations = {"classpath:connectiondetails/application-cassandra.properties"}) +@ActiveProfiles("cassandra") +public class CassandraConnectionDetailsIntegrationTest { + private static final Logger logger = LoggerFactory.getLogger(CassandraConnectionDetailsIntegrationTest.class); + @Autowired + private CassandraTemplate cassandraTemplate; + @Test + public void givenHashicorpVault_whenRunQuery_thenSuccess() { + boolean result = cassandraTemplate.getCqlOperations() + .execute("CREATE KEYSPACE IF NOT EXISTS spring_cassandra" + + " WITH replication = {'class':'SimpleStrategy', 'replication_factor':3}"); + logger.info("the result -" + result); + assertTrue(result); + } +} diff --git a/spring-boot-modules/spring-boot-3-1/src/test/java/com/baeldung/connectiondetails/CouchbaseConnectionDetailsIntegrationTest.java b/spring-boot-modules/spring-boot-3-1/src/test/java/com/baeldung/connectiondetails/CouchbaseConnectionDetailsIntegrationTest.java new file mode 100644 index 0000000000..454aad4c6c --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/test/java/com/baeldung/connectiondetails/CouchbaseConnectionDetailsIntegrationTest.java @@ -0,0 +1,30 @@ +package com.baeldung.connectiondetails; + +import com.baeldung.connectiondetails.configuration.CustomCouchBaseConnectionDetailsConfiguration; +import com.couchbase.client.java.Cluster; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Import; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit4.SpringRunner; + +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = ConnectionDetailsApplication.class) +@Import(CustomCouchBaseConnectionDetailsConfiguration.class) +@ComponentScan(basePackages = "com.baeldung.connectiondetails") +@TestPropertySource(locations = {"classpath:connectiondetails/application-couch.properties"}) +@ActiveProfiles("couch") +public class CouchbaseConnectionDetailsIntegrationTest { + @Autowired + private Cluster cluster; + @Test + public void givenSecretVault_whenConnectWithCouch_thenSuccess() { + assertDoesNotThrow(cluster.ping()::version); + } +} diff --git a/spring-boot-modules/spring-boot-3-1/src/test/java/com/baeldung/connectiondetails/ElasticsearchConnectionDetailsIntegrationTest.java b/spring-boot-modules/spring-boot-3-1/src/test/java/com/baeldung/connectiondetails/ElasticsearchConnectionDetailsIntegrationTest.java new file mode 100644 index 0000000000..ee698cd6ea --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/test/java/com/baeldung/connectiondetails/ElasticsearchConnectionDetailsIntegrationTest.java @@ -0,0 +1,45 @@ +package com.baeldung.connectiondetails; + +import com.baeldung.connectiondetails.configuration.CustomElasticsearchConnectionDetailsConfiguration; +import com.baeldung.connectiondetails.entity.elastic.Person; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Import; +import org.springframework.data.elasticsearch.client.elc.ElasticsearchTemplate; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit4.SpringRunner; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = ConnectionDetailsApplication.class) +@Import(CustomElasticsearchConnectionDetailsConfiguration.class) +@ComponentScan(basePackages = "com.baeldung.connectiondetails") +@TestPropertySource(locations = {"classpath:connectiondetails/application-elastic.properties"}) +@ActiveProfiles("elastic") +public class ElasticsearchConnectionDetailsIntegrationTest { + private static final Logger logger = LoggerFactory.getLogger(ElasticsearchConnectionDetailsIntegrationTest.class); + @Autowired + private ElasticsearchTemplate elasticsearchTemplate; + + @Before + public void prepare() { + if (elasticsearchTemplate.indexOps(Person.class).exists()) { + elasticsearchTemplate.indexOps(Person.class).delete(); + } + } + @Test + public void givenHashicorpVault_whenCreateIndexInElastic_thenSuccess() { + + boolean result = elasticsearchTemplate.indexOps(Person.class).create(); + logger.info("index created:" + result); + assertTrue(result); + } +} diff --git a/spring-boot-modules/spring-boot-3-1/src/test/java/com/baeldung/connectiondetails/JdbcConnectionDetailsIntegrationTest.java b/spring-boot-modules/spring-boot-3-1/src/test/java/com/baeldung/connectiondetails/JdbcConnectionDetailsIntegrationTest.java new file mode 100644 index 0000000000..748bc27b0b --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/test/java/com/baeldung/connectiondetails/JdbcConnectionDetailsIntegrationTest.java @@ -0,0 +1,38 @@ +package com.baeldung.connectiondetails; + +import com.baeldung.connectiondetails.configuration.JdbcConnectionDetailsConfiguration; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Import; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit4.SpringRunner; + +import java.sql.Date; +import java.time.LocalDate; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = ConnectionDetailsApplication.class) +@Import(JdbcConnectionDetailsConfiguration.class) +@ComponentScan(basePackages = "com.baeldung.connectiondetails") +@TestPropertySource(locations = {"classpath:connectiondetails/application-jdbc.properties"}) +@ActiveProfiles("jdbc") +public class JdbcConnectionDetailsIntegrationTest { + private static final Logger logger = LoggerFactory.getLogger(JdbcConnectionDetailsIntegrationTest.class); + @Autowired + private JdbcTemplate jdbcTemplate; + @Test + public void givenSecretVault_whenIntegrateWithPostgres_thenConnectionSuccessful() { + String sql = "select current_date;"; + Date date = jdbcTemplate.queryForObject(sql, Date.class); + assertEquals(LocalDate.now().toString(), date.toString()); + } +} diff --git a/spring-boot-modules/spring-boot-3-1/src/test/java/com/baeldung/connectiondetails/KafkaConnectionDetailsIntegrationTest.java b/spring-boot-modules/spring-boot-3-1/src/test/java/com/baeldung/connectiondetails/KafkaConnectionDetailsIntegrationTest.java new file mode 100644 index 0000000000..bc0e174b3f --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/test/java/com/baeldung/connectiondetails/KafkaConnectionDetailsIntegrationTest.java @@ -0,0 +1,32 @@ +package com.baeldung.connectiondetails; + +import com.baeldung.connectiondetails.configuration.CustomKafkaConnectionDetailsConfiguration; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Import; +import org.springframework.kafka.core.KafkaTemplate; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit4.SpringRunner; + +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; + + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = ConnectionDetailsApplication.class) +@Import(CustomKafkaConnectionDetailsConfiguration.class) +@ComponentScan(basePackages = "com.baeldung.connectiondetails") +@TestPropertySource(locations = {"classpath:connectiondetails/application-kafka.properties"}) +@ActiveProfiles("kafka") +public class KafkaConnectionDetailsIntegrationTest { + @Autowired + private KafkaTemplate kafkaTemplate; + + @Test + public void givenSecretVault_whenPublishMsgToKafkaQueue_thenSuccess() { + assertDoesNotThrow(kafkaTemplate::getDefaultTopic); + } +} diff --git a/spring-boot-modules/spring-boot-3-1/src/test/java/com/baeldung/connectiondetails/MongoDBConnectionDetailsIntegrationTest.java b/spring-boot-modules/spring-boot-3-1/src/test/java/com/baeldung/connectiondetails/MongoDBConnectionDetailsIntegrationTest.java new file mode 100644 index 0000000000..868ebfea98 --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/test/java/com/baeldung/connectiondetails/MongoDBConnectionDetailsIntegrationTest.java @@ -0,0 +1,47 @@ +package com.baeldung.connectiondetails; + +import com.baeldung.connectiondetails.configuration.MongoDBConnectionDetailsConfiguration; +import org.json.JSONException; +import org.json.JSONObject; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.data.r2dbc.R2dbcDataAutoConfiguration; +import org.springframework.boot.autoconfigure.data.r2dbc.R2dbcRepositoriesAutoConfiguration; +import org.springframework.boot.autoconfigure.r2dbc.R2dbcAutoConfiguration; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Import; +import org.springframework.data.mongodb.core.MongoTemplate; +import org.springframework.data.mongodb.core.query.Query; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit4.SpringRunner; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = ConnectionDetailsApplication.class) +@Import(MongoDBConnectionDetailsConfiguration.class) +@ComponentScan(basePackages = "com.baeldung.connectiondetails") +@TestPropertySource(locations = {"classpath:connectiondetails/application-mongo.properties"}) +@ActiveProfiles("mongo") +public class MongoDBConnectionDetailsIntegrationTest { + + @Autowired + private MongoTemplate mongoTemplate; + @Test + public void givenSecretVault_whenExecuteQueryOnMongoDB_ReturnResult() throws JSONException { + mongoTemplate.insert("{\"msg\":\"My First Entry in MongoDB\"}", "myDemoCollection"); + String result = mongoTemplate.find(new Query(), String.class, "myDemoCollection").get(0); + + JSONObject jsonObject = new JSONObject(result); + result = jsonObject.get("msg").toString(); + R2dbcAutoConfiguration r2dbcAutoConfiguration; + R2dbcDataAutoConfiguration r2dbcDataAutoConfiguration; + R2dbcRepositoriesAutoConfiguration r2dbcRepositoriesAutoConfiguration; + + assertEquals("My First Entry in MongoDB", result); + } +} + diff --git a/spring-boot-modules/spring-boot-3-1/src/test/java/com/baeldung/connectiondetails/Neo4jConnectionDetailsIntegrationTest.java b/spring-boot-modules/spring-boot-3-1/src/test/java/com/baeldung/connectiondetails/Neo4jConnectionDetailsIntegrationTest.java new file mode 100644 index 0000000000..943ed7bdea --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/test/java/com/baeldung/connectiondetails/Neo4jConnectionDetailsIntegrationTest.java @@ -0,0 +1,43 @@ +package com.baeldung.connectiondetails; + +import com.baeldung.connectiondetails.configuration.CustomNeo4jConnectionDetailsConfiguration; +import com.baeldung.connectiondetails.entity.neo4j.Person; +import org.junit.After; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Import; +import org.springframework.data.neo4j.core.Neo4jTemplate; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit4.SpringRunner; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = ConnectionDetailsApplication.class) +@Import(CustomNeo4jConnectionDetailsConfiguration.class) +@ComponentScan(basePackages = "com.baeldung.connectiondetails") +@TestPropertySource(locations = {"classpath:connectiondetails/application-neo4j.properties"}) +@ActiveProfiles("neo4j") +public class Neo4jConnectionDetailsIntegrationTest { + @Autowired + private Neo4jTemplate neo4jTemplate; + + @After + public void cleanup() { + neo4jTemplate.deleteAll(Person.class); + } + @Test + public void giveSecretVault_whenRunQuery_thenSuccess() { + Person person = new Person(); + person.setName("James"); + person.setZipcode("751003"); + + Person data = neo4jTemplate.save(person); + assertEquals("James", data.getName()); + } + +} diff --git a/spring-boot-modules/spring-boot-3-1/src/test/java/com/baeldung/connectiondetails/R2dbcConnectionDetailsIntegrationTest.java b/spring-boot-modules/spring-boot-3-1/src/test/java/com/baeldung/connectiondetails/R2dbcConnectionDetailsIntegrationTest.java new file mode 100644 index 0000000000..5f8c8349fb --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/test/java/com/baeldung/connectiondetails/R2dbcConnectionDetailsIntegrationTest.java @@ -0,0 +1,39 @@ +package com.baeldung.connectiondetails; + +import com.baeldung.connectiondetails.configuration.R2dbcPostgresConnectionDetailsConfiguration; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.annotation.Import; +import org.springframework.data.r2dbc.core.R2dbcEntityTemplate; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit4.SpringRunner; + +import java.util.List; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = ConnectionDetailsApplication.class) +@Import(R2dbcPostgresConnectionDetailsConfiguration.class) +@TestPropertySource(locations = {"classpath:connectiondetails/application-r2dbc.properties"}) +@ActiveProfiles("r2dbc") +public class R2dbcConnectionDetailsIntegrationTest { + Logger logger = LoggerFactory.getLogger(R2dbcConnectionDetailsIntegrationTest.class); + @Autowired + private R2dbcEntityTemplate r2dbcEntityTemplate; + + @Test + public void givenSecretVault_whenQueryPostgresReactive_thenSuccess() { + + String sql = "select * from information_schema.tables"; + + List result = r2dbcEntityTemplate.getDatabaseClient().sql(sql).fetch().all() + .map(r -> { + return "hello " + r.get("table_name").toString(); + }).collectList().block(); + logger.info("count ------" + result.size()); + } +} diff --git a/spring-boot-modules/spring-boot-3-1/src/test/java/com/baeldung/connectiondetails/RabbitmqConnectionDetailsIntegrationTest.java b/spring-boot-modules/spring-boot-3-1/src/test/java/com/baeldung/connectiondetails/RabbitmqConnectionDetailsIntegrationTest.java new file mode 100644 index 0000000000..9e10973ed7 --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/test/java/com/baeldung/connectiondetails/RabbitmqConnectionDetailsIntegrationTest.java @@ -0,0 +1,62 @@ +package com.baeldung.connectiondetails; + +import com.baeldung.connectiondetails.configuration.RabbitMQConnectionDetailsConfiguration; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.amqp.core.Queue; +import org.springframework.amqp.rabbit.connection.CachingConnectionFactory; +import org.springframework.amqp.rabbit.core.RabbitAdmin; +import org.springframework.amqp.rabbit.core.RabbitTemplate; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.annotation.Import; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit4.SpringRunner; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = ConnectionDetailsApplication.class) +@Import(RabbitMQConnectionDetailsConfiguration.class) +@TestPropertySource(locations = {"classpath:connectiondetails/application-rabbitmq.properties"}) +@ActiveProfiles("rabbitmq") +public class RabbitmqConnectionDetailsIntegrationTest { + + private static final Logger logger = LoggerFactory.getLogger(RabbitmqConnectionDetailsIntegrationTest.class); + + @Autowired + private RabbitTemplate rabbitTemplate; + + @Autowired + private CachingConnectionFactory connectionFactory; + + private final static String queueName = "Test_Queue"; + + RabbitAdmin rabbitAdmin; + + @Before + public void setup() { + logger.info("create new queue"); + rabbitAdmin = new RabbitAdmin(connectionFactory); + logger.info("creating queue: " + rabbitAdmin.declareQueue(new Queue(queueName))); + connectionFactory.destroy(); + } + + @After + public void cleanup() { + logger.info("delete queue"); + this.rabbitAdmin.deleteQueue(queueName, false, true); + } + @Test + public void givenSecretVault_whenPublishMessageToRabbitmq_thenSuccess() { + logger.info("sending message to queue " + queueName); + final String MSG = "this is a test message"; + this.rabbitTemplate.convertAndSend(queueName, MSG); + assertEquals(MSG, this.rabbitTemplate.receiveAndConvert(queueName)); + } +} diff --git a/spring-boot-modules/spring-boot-3-1/src/test/java/com/baeldung/connectiondetails/RedisCacheConnnectionDetailsIntegrationTest.java b/spring-boot-modules/spring-boot-3-1/src/test/java/com/baeldung/connectiondetails/RedisCacheConnnectionDetailsIntegrationTest.java new file mode 100644 index 0000000000..5dbd2d6c03 --- /dev/null +++ b/spring-boot-modules/spring-boot-3-1/src/test/java/com/baeldung/connectiondetails/RedisCacheConnnectionDetailsIntegrationTest.java @@ -0,0 +1,34 @@ +package com.baeldung.connectiondetails; + +import com.baeldung.connectiondetails.configuration.RedisConnectionDetailsConfiguration; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.annotation.Import; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit4.SpringRunner; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = ConnectionDetailsApplication.class) +@Import(RedisConnectionDetailsConfiguration.class) +@TestPropertySource(locations = {"classpath:connectiondetails/application-redis.properties"}) +@ActiveProfiles("redis") +public class RedisCacheConnnectionDetailsIntegrationTest { + private static final Logger logger = LoggerFactory.getLogger(RedisCacheConnnectionDetailsIntegrationTest.class); + + @Autowired + RedisTemplate redisTemplate; + + @Test + public void giveSecretVault_whenStoreInRedisCache_thenSuccess() { + redisTemplate.opsForValue().set("City", "New York"); + assertEquals("New York", redisTemplate.opsForValue().get("City")); + } +}