diff --git a/dapr-spring/dapr-spring-boot-autoconfigure/pom.xml b/dapr-spring/dapr-spring-boot-autoconfigure/pom.xml
index 2c43bf8cc..5cbcba6ae 100644
--- a/dapr-spring/dapr-spring-boot-autoconfigure/pom.xml
+++ b/dapr-spring/dapr-spring-boot-autoconfigure/pom.xml
@@ -15,12 +15,6 @@
jar
-
- io.dapr.spring
- dapr-spring-core
- ${project.parent.version}
- true
-
io.dapr.spring
dapr-spring-data
diff --git a/dapr-spring/dapr-spring-boot-autoconfigure/src/main/java/io/dapr/spring/boot/autoconfigure/client/DaprClientAutoConfiguration.java b/dapr-spring/dapr-spring-boot-autoconfigure/src/main/java/io/dapr/spring/boot/autoconfigure/client/DaprClientAutoConfiguration.java
index 67b31816b..3aa422cf1 100644
--- a/dapr-spring/dapr-spring-boot-autoconfigure/src/main/java/io/dapr/spring/boot/autoconfigure/client/DaprClientAutoConfiguration.java
+++ b/dapr-spring/dapr-spring-boot-autoconfigure/src/main/java/io/dapr/spring/boot/autoconfigure/client/DaprClientAutoConfiguration.java
@@ -15,34 +15,33 @@
import io.dapr.client.DaprClient;
import io.dapr.client.DaprClientBuilder;
-import io.dapr.spring.core.client.DaprClientCustomizer;
-import org.springframework.beans.factory.ObjectProvider;
+import io.dapr.config.Properties;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
-import java.util.stream.Collectors;
-
@AutoConfiguration
@ConditionalOnClass(DaprClient.class)
+@EnableConfigurationProperties(DaprClientProperties.class)
public class DaprClientAutoConfiguration {
@Bean
- @ConditionalOnMissingBean
- DaprClientBuilderConfigurer daprClientBuilderConfigurer(ObjectProvider customizerProvider) {
- DaprClientBuilderConfigurer configurer = new DaprClientBuilderConfigurer();
- configurer.setDaprClientCustomizer(customizerProvider.orderedStream().collect(Collectors.toList()));
-
- return configurer;
+ @ConditionalOnMissingBean(DaprConnectionDetails.class)
+ DaprConnectionDetails daprConnectionDetails(DaprClientProperties properties) {
+ return new PropertiesDaprConnectionDetails(properties);
}
@Bean
@ConditionalOnMissingBean
- DaprClientBuilder daprClientBuilder(DaprClientBuilderConfigurer daprClientBuilderConfigurer) {
+ DaprClientBuilder daprClientBuilder(DaprConnectionDetails daprConnectionDetails) {
DaprClientBuilder builder = new DaprClientBuilder();
-
- return daprClientBuilderConfigurer.configure(builder);
+ builder.withPropertyOverride(Properties.HTTP_ENDPOINT, daprConnectionDetails.httpEndpoint());
+ builder.withPropertyOverride(Properties.GRPC_ENDPOINT, daprConnectionDetails.grpcEndpoint());
+ builder.withPropertyOverride(Properties.HTTP_PORT, String.valueOf(daprConnectionDetails.httpPort()));
+ builder.withPropertyOverride(Properties.GRPC_PORT, String.valueOf(daprConnectionDetails.grpcPort()));
+ return builder;
}
@Bean
diff --git a/dapr-spring/dapr-spring-boot-autoconfigure/src/main/java/io/dapr/spring/boot/autoconfigure/client/DaprClientBuilderConfigurer.java b/dapr-spring/dapr-spring-boot-autoconfigure/src/main/java/io/dapr/spring/boot/autoconfigure/client/DaprClientBuilderConfigurer.java
deleted file mode 100644
index ca83ab4fd..000000000
--- a/dapr-spring/dapr-spring-boot-autoconfigure/src/main/java/io/dapr/spring/boot/autoconfigure/client/DaprClientBuilderConfigurer.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright 2024 The Dapr Authors
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package io.dapr.spring.boot.autoconfigure.client;
-
-import io.dapr.client.DaprClientBuilder;
-import io.dapr.spring.core.client.DaprClientCustomizer;
-
-import java.util.List;
-
-/**
- * Builder for configuring a {@link DaprClientBuilder}.
- */
-public class DaprClientBuilderConfigurer {
-
- private List customizers;
-
- void setDaprClientCustomizer(List customizers) {
- this.customizers = List.copyOf(customizers);
- }
-
- /**
- * Configure the specified {@link DaprClientBuilder}. The builder can be further
- * tuned and default settings can be overridden.
- *
- * @param builder the {@link DaprClientBuilder} instance to configure
- * @return the configured builder
- */
- public DaprClientBuilder configure(DaprClientBuilder builder) {
- applyCustomizers(builder);
- return builder;
- }
-
- private void applyCustomizers(DaprClientBuilder builder) {
- if (this.customizers != null) {
- for (DaprClientCustomizer customizer : this.customizers) {
- customizer.customize(builder);
- }
- }
- }
-
-}
diff --git a/dapr-spring/dapr-spring-boot-autoconfigure/src/main/java/io/dapr/spring/boot/autoconfigure/client/DaprClientProperties.java b/dapr-spring/dapr-spring-boot-autoconfigure/src/main/java/io/dapr/spring/boot/autoconfigure/client/DaprClientProperties.java
new file mode 100644
index 000000000..135416946
--- /dev/null
+++ b/dapr-spring/dapr-spring-boot-autoconfigure/src/main/java/io/dapr/spring/boot/autoconfigure/client/DaprClientProperties.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2024 The Dapr Authors
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package io.dapr.spring.boot.autoconfigure.client;
+
+import io.dapr.spring.data.DaprKeyValueAdapterResolver;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+
+@ConfigurationProperties(prefix = "dapr.client")
+public class DaprClientProperties {
+ private String httpEndpoint;
+ private String grpcEndpoint;
+ private Integer httpPort;
+ private Integer grpcPort;
+
+
+ /**
+ * Constructs a {@link DaprClientProperties}.
+ */
+ public DaprClientProperties() {
+ }
+
+ /**
+ * Constructs a {@link DaprClientProperties}.
+ * @param httpEndpoint http endpoint to interact with the Dapr Sidecar
+ * @param grpcEndpoint grpc endpoint to interact with the Dapr Sidecar
+ * @param httpPort http port to interact with the Dapr Sidecar
+ * @param grpcPort grpc port to interact with the Dapr Sidecar
+ */
+ public DaprClientProperties(String httpEndpoint, String grpcEndpoint, Integer httpPort, Integer grpcPort) {
+ this.httpEndpoint = httpEndpoint;
+ this.grpcEndpoint = grpcEndpoint;
+ this.httpPort = httpPort;
+ this.grpcPort = grpcPort;
+ }
+
+ public String getHttpEndpoint() {
+ return httpEndpoint;
+ }
+
+ public String getGrpcEndpoint() {
+ return grpcEndpoint;
+ }
+
+ public Integer getHttpPort() {
+ return httpPort;
+ }
+
+ public Integer getGrpcPort() {
+ return grpcPort;
+ }
+
+ public void setHttpEndpoint(String httpEndpoint) {
+ this.httpEndpoint = httpEndpoint;
+ }
+
+ public void setGrpcEndpoint(String grpcEndpoint) {
+ this.grpcEndpoint = grpcEndpoint;
+ }
+
+ public void setHttpPort(Integer httpPort) {
+ this.httpPort = httpPort;
+ }
+
+ public void setGrpcPort(Integer grpcPort) {
+ this.grpcPort = grpcPort;
+ }
+}
diff --git a/dapr-spring/dapr-spring-core/src/main/java/io/dapr/spring/core/client/DaprClientCustomizer.java b/dapr-spring/dapr-spring-boot-autoconfigure/src/main/java/io/dapr/spring/boot/autoconfigure/client/DaprConnectionDetails.java
similarity index 58%
rename from dapr-spring/dapr-spring-core/src/main/java/io/dapr/spring/core/client/DaprClientCustomizer.java
rename to dapr-spring/dapr-spring-boot-autoconfigure/src/main/java/io/dapr/spring/boot/autoconfigure/client/DaprConnectionDetails.java
index 425d7cbf8..4a95af014 100644
--- a/dapr-spring/dapr-spring-core/src/main/java/io/dapr/spring/core/client/DaprClientCustomizer.java
+++ b/dapr-spring/dapr-spring-boot-autoconfigure/src/main/java/io/dapr/spring/boot/autoconfigure/client/DaprConnectionDetails.java
@@ -11,21 +11,16 @@
limitations under the License.
*/
-package io.dapr.spring.core.client;
+package io.dapr.spring.boot.autoconfigure.client;
-import io.dapr.client.DaprClientBuilder;
+import org.springframework.boot.autoconfigure.service.connection.ConnectionDetails;
-/**
- * Callback interface that can be used to customize a {@link DaprClientBuilder}.
- */
-@FunctionalInterface
-public interface DaprClientCustomizer {
+public interface DaprConnectionDetails extends ConnectionDetails {
+ String httpEndpoint();
- /**
- * Callback to customize a {@link DaprClientBuilder} instance.
- *
- * @param daprClientBuilder the client builder to customize
- */
- void customize(DaprClientBuilder daprClientBuilder);
+ String grpcEndpoint();
+ Integer httpPort();
+
+ Integer grpcPort();
}
diff --git a/dapr-spring/dapr-spring-boot-autoconfigure/src/main/java/io/dapr/spring/boot/autoconfigure/client/PropertiesDaprConnectionDetails.java b/dapr-spring/dapr-spring-boot-autoconfigure/src/main/java/io/dapr/spring/boot/autoconfigure/client/PropertiesDaprConnectionDetails.java
new file mode 100644
index 000000000..e7b98b102
--- /dev/null
+++ b/dapr-spring/dapr-spring-boot-autoconfigure/src/main/java/io/dapr/spring/boot/autoconfigure/client/PropertiesDaprConnectionDetails.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2024 The Dapr Authors
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package io.dapr.spring.boot.autoconfigure.client;
+
+class PropertiesDaprConnectionDetails implements DaprConnectionDetails {
+
+ private final DaprClientProperties daprClientProperties;
+
+ public PropertiesDaprConnectionDetails(DaprClientProperties daprClientProperties) {
+ this.daprClientProperties = daprClientProperties;
+ }
+
+ @Override
+ public String httpEndpoint() {
+ return this.daprClientProperties.getHttpEndpoint();
+ }
+
+ @Override
+ public String grpcEndpoint() {
+ return this.daprClientProperties.getGrpcEndpoint();
+ }
+
+ @Override
+ public Integer httpPort() {
+ return this.daprClientProperties.getHttpPort();
+ }
+
+ @Override
+ public Integer grpcPort() {
+ return this.daprClientProperties.getGrpcPort();
+ }
+}
diff --git a/dapr-spring/dapr-spring-boot-autoconfigure/src/test/java/io/dapr/spring/boot/autoconfigure/client/DaprClientAutoConfigurationTests.java b/dapr-spring/dapr-spring-boot-autoconfigure/src/test/java/io/dapr/spring/boot/autoconfigure/client/DaprClientAutoConfigurationTests.java
index 5124e6064..0545df178 100644
--- a/dapr-spring/dapr-spring-boot-autoconfigure/src/test/java/io/dapr/spring/boot/autoconfigure/client/DaprClientAutoConfigurationTests.java
+++ b/dapr-spring/dapr-spring-boot-autoconfigure/src/test/java/io/dapr/spring/boot/autoconfigure/client/DaprClientAutoConfigurationTests.java
@@ -29,11 +29,6 @@ class DaprClientAutoConfigurationTests {
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(DaprClientAutoConfiguration.class));
- @Test
- void daprClientBuilderConfigurer() {
- contextRunner.run(context -> assertThat(context).hasSingleBean(DaprClientBuilderConfigurer.class));
- }
-
@Test
void daprClientBuilder() {
contextRunner.run(context -> assertThat(context).hasSingleBean(DaprClientBuilder.class));
diff --git a/dapr-spring/dapr-spring-boot-starters/dapr-spring-boot-starter-test/pom.xml b/dapr-spring/dapr-spring-boot-starters/dapr-spring-boot-starter-test/pom.xml
new file mode 100644
index 000000000..04713caba
--- /dev/null
+++ b/dapr-spring/dapr-spring-boot-starters/dapr-spring-boot-starter-test/pom.xml
@@ -0,0 +1,44 @@
+
+
+ 4.0.0
+
+
+ io.dapr.spring
+ dapr-spring-parent
+ 0.13.0-SNAPSHOT
+ ../../pom.xml
+
+
+ dapr-spring-boot-starter-test
+ dapr-spring-boot-starter-test
+ Dapr Spring Boot Starter Tests (with Testcontainers Support)
+ jar
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+
+
+ io.dapr.spring
+ dapr-spring-boot-tests
+ ${project.parent.version}
+
+
+ io.dapr
+ testcontainers-dapr
+ ${project.parent.version}
+
+
+ org.springframework.boot
+ spring-boot-testcontainers
+
+
+ org.testcontainers
+ junit-jupiter
+ true
+
+
+
+
diff --git a/dapr-spring/dapr-spring-boot-starters/dapr-spring-boot-starter/pom.xml b/dapr-spring/dapr-spring-boot-starters/dapr-spring-boot-starter/pom.xml
index 89480c795..d06998b45 100644
--- a/dapr-spring/dapr-spring-boot-starters/dapr-spring-boot-starter/pom.xml
+++ b/dapr-spring/dapr-spring-boot-starters/dapr-spring-boot-starter/pom.xml
@@ -12,7 +12,7 @@
dapr-spring-boot-starter
dapr-spring-boot-starter
- Dapr Client Spring Boot Starter
+ Dapr Spring Boot Starter
jar
@@ -20,14 +20,24 @@
org.springframework.boot
spring-boot-starter
+
+ io.dapr
+ dapr-sdk-springboot
+ ${dapr.sdk.version}
+
io.dapr.spring
- dapr-spring-core
+ dapr-spring-boot-autoconfigure
${project.parent.version}
io.dapr.spring
- dapr-spring-boot-autoconfigure
+ dapr-spring-data
+ ${project.parent.version}
+
+
+ io.dapr.spring
+ dapr-spring-messaging
${project.parent.version}
diff --git a/dapr-spring/dapr-spring-boot-tests/pom.xml b/dapr-spring/dapr-spring-boot-tests/pom.xml
new file mode 100644
index 000000000..eec82d696
--- /dev/null
+++ b/dapr-spring/dapr-spring-boot-tests/pom.xml
@@ -0,0 +1,45 @@
+
+
+ 4.0.0
+
+
+ io.dapr.spring
+ dapr-spring-parent
+ 0.13.0-SNAPSHOT
+
+
+ dapr-spring-boot-tests
+ dapr-spring-boot-tests
+ Dapr Spring Boot Tests
+ jar
+
+
+
+ org.springframework.boot
+ spring-boot-testcontainers
+
+
+ io.dapr.spring
+ dapr-spring-boot-autoconfigure
+ ${project.parent.version}
+
+
+ org.testcontainers
+ junit-jupiter
+ test
+
+
+ com.vaadin.external.google
+ android-json
+
+
+
+
+ io.dapr
+ testcontainers-dapr
+ ${dapr.sdk.alpha.version}
+
+
+
+
diff --git a/dapr-spring/dapr-spring-boot-tests/src/main/java/io/dapr/spring/boot/testcontainers/service/connection/DaprContainerConnectionDetailsFactory.java b/dapr-spring/dapr-spring-boot-tests/src/main/java/io/dapr/spring/boot/testcontainers/service/connection/DaprContainerConnectionDetailsFactory.java
new file mode 100644
index 000000000..4b4f9c1a7
--- /dev/null
+++ b/dapr-spring/dapr-spring-boot-tests/src/main/java/io/dapr/spring/boot/testcontainers/service/connection/DaprContainerConnectionDetailsFactory.java
@@ -0,0 +1,45 @@
+package io.dapr.spring.boot.testcontainers.service.connection;
+
+import io.dapr.spring.boot.autoconfigure.client.DaprConnectionDetails;
+import io.dapr.testcontainers.DaprContainer;
+import org.springframework.boot.testcontainers.service.connection.ContainerConnectionDetailsFactory;
+import org.springframework.boot.testcontainers.service.connection.ContainerConnectionSource;
+
+public class DaprContainerConnectionDetailsFactory
+ extends ContainerConnectionDetailsFactory {
+
+ DaprContainerConnectionDetailsFactory() {
+ }
+
+ protected DaprConnectionDetails getContainerConnectionDetails(ContainerConnectionSource source) {
+ return new DaprContainerConnectionDetails(source);
+ }
+
+ private static final class DaprContainerConnectionDetails
+ extends ContainerConnectionDetailsFactory.ContainerConnectionDetails
+ implements DaprConnectionDetails {
+ private DaprContainerConnectionDetails(ContainerConnectionSource source) {
+ super(source);
+ }
+
+ @Override
+ public String httpEndpoint() {
+ return getContainer().getHttpEndpoint();
+ }
+
+ @Override
+ public String grpcEndpoint() {
+ return getContainer().getGrpcEndpoint();
+ }
+
+ @Override
+ public Integer httpPort() {
+ return getContainer().getHttpPort();
+ }
+
+ @Override
+ public Integer grpcPort() {
+ return getContainer().getGrpcPort();
+ }
+ }
+}
diff --git a/dapr-spring/dapr-spring-boot-tests/src/main/resources/META-INF/spring.factories b/dapr-spring/dapr-spring-boot-tests/src/main/resources/META-INF/spring.factories
new file mode 100644
index 000000000..880886030
--- /dev/null
+++ b/dapr-spring/dapr-spring-boot-tests/src/main/resources/META-INF/spring.factories
@@ -0,0 +1,2 @@
+org.springframework.boot.autoconfigure.service.connection.ConnectionDetailsFactory=\
+io.dapr.spring.boot.testcontainers.service.connection.DaprContainerConnectionDetailsFactory
diff --git a/dapr-spring/dapr-spring-core/pom.xml b/dapr-spring/dapr-spring-core/pom.xml
deleted file mode 100644
index e3b037135..000000000
--- a/dapr-spring/dapr-spring-core/pom.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
- 4.0.0
-
-
- io.dapr.spring
- dapr-spring-parent
- 0.13.0-SNAPSHOT
-
-
- dapr-spring-core
- dapr-spring-core
- Dapr Spring Core
- jar
-
-
diff --git a/dapr-spring/pom.xml b/dapr-spring/pom.xml
index 6f6083abd..b6cb7b4a2 100644
--- a/dapr-spring/pom.xml
+++ b/dapr-spring/pom.xml
@@ -18,11 +18,12 @@
SDK extension for Spring and Spring Boot
- dapr-spring-core
dapr-spring-data
dapr-spring-messaging
dapr-spring-boot-autoconfigure
+ dapr-spring-boot-tests
dapr-spring-boot-starters/dapr-spring-boot-starter
+ dapr-spring-boot-starters/dapr-spring-boot-starter-test
diff --git a/sdk-tests/pom.xml b/sdk-tests/pom.xml
index 679c3821a..7c4997024 100644
--- a/sdk-tests/pom.xml
+++ b/sdk-tests/pom.xml
@@ -146,35 +146,20 @@
${dapr.sdk.alpha.version}
test
-
- io.dapr
- dapr-sdk-springboot
- ${dapr.sdk.version}
- test
-
io.dapr.spring
- dapr-spring-core
+ dapr-spring-boot-starter
${dapr.sdk.alpha.version}
- test
io.dapr.spring
- dapr-spring-data
+ dapr-spring-boot-starter-test
${dapr.sdk.alpha.version}
test
- io.dapr.spring
- dapr-spring-messaging
- ${dapr.sdk.alpha.version}
- test
-
-
- io.dapr.spring
- dapr-spring-boot-autoconfigure
- ${dapr.sdk.alpha.version}
- test
+ org.testcontainers
+ junit-jupiter
org.springframework.data
@@ -185,11 +170,6 @@
spring-boot-starter-test
test
-
- org.springframework.boot
- spring-boot-testcontainers
- test
-
org.wiremock
wiremock-standalone
@@ -219,17 +199,6 @@
3.9
test
-
- io.dapr
- testcontainers-dapr
- ${dapr.sdk.alpha.version}
-
-
- org.testcontainers
- junit-jupiter
- ${testcontainers-test.version}
- test
-
org.testcontainers
postgresql
diff --git a/sdk-tests/src/test/java/io/dapr/it/spring/data/DaprKeyValueRepositoryIT.java b/sdk-tests/src/test/java/io/dapr/it/spring/data/DaprKeyValueRepositoryIT.java
index b1eaa8aad..c2a09e9e6 100644
--- a/sdk-tests/src/test/java/io/dapr/it/spring/data/DaprKeyValueRepositoryIT.java
+++ b/sdk-tests/src/test/java/io/dapr/it/spring/data/DaprKeyValueRepositoryIT.java
@@ -21,9 +21,8 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.DynamicPropertyRegistry;
-import org.springframework.test.context.DynamicPropertySource;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.testcontainers.containers.Network;
import org.testcontainers.containers.PostgreSQLContainer;
@@ -65,6 +64,7 @@ public class DaprKeyValueRepositoryIT {
.withNetwork(DAPR_NETWORK);
@Container
+ @ServiceConnection
private static final DaprContainer DAPR_CONTAINER = new DaprContainer("daprio/daprd:1.13.2")
.withAppName("postgresql-repository-dapr-app")
.withNetwork(DAPR_NETWORK)
@@ -74,12 +74,6 @@ public class DaprKeyValueRepositoryIT {
.withLogConsumer(outputFrame -> System.out.println(outputFrame.getUtf8String()))
.dependsOn(POSTGRE_SQL_CONTAINER);
- @DynamicPropertySource
- static void daprProperties(DynamicPropertyRegistry registry) {
- registry.add("dapr.http.endpoint", DAPR_CONTAINER::getHttpEndpoint);
- registry.add("dapr.grpc.endpoint", DAPR_CONTAINER::getGrpcEndpoint);
- }
-
private static Map createStateStoreProperties() {
Map result = new HashMap<>();
diff --git a/sdk-tests/src/test/java/io/dapr/it/spring/data/MySQLDaprKeyValueTemplateIT.java b/sdk-tests/src/test/java/io/dapr/it/spring/data/MySQLDaprKeyValueTemplateIT.java
index 42e0df70d..f5d145b90 100644
--- a/sdk-tests/src/test/java/io/dapr/it/spring/data/MySQLDaprKeyValueTemplateIT.java
+++ b/sdk-tests/src/test/java/io/dapr/it/spring/data/MySQLDaprKeyValueTemplateIT.java
@@ -23,6 +23,7 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
import org.springframework.data.keyvalue.core.query.KeyValueQuery;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.DynamicPropertyRegistry;
@@ -80,6 +81,7 @@ public class MySQLDaprKeyValueTemplateIT {
.waitingFor(MYSQL_WAIT_STRATEGY);
@Container
+ @ServiceConnection
private static final DaprContainer DAPR_CONTAINER = new DaprContainer("daprio/daprd:1.13.2")
.withAppName("mysql-dapr-app")
.withNetwork(DAPR_NETWORK)
@@ -88,12 +90,7 @@ public class MySQLDaprKeyValueTemplateIT {
.withDaprLogLevel(DaprLogLevel.DEBUG)
.withLogConsumer(outputFrame -> System.out.println(outputFrame.getUtf8String()))
.dependsOn(MY_SQL_CONTAINER);
-
- @DynamicPropertySource
- static void daprProperties(DynamicPropertyRegistry registry) {
- registry.add("dapr.http.endpoint", DAPR_CONTAINER::getHttpEndpoint);
- registry.add("dapr.grpc.endpoint", DAPR_CONTAINER::getGrpcEndpoint);
- }
+
private static Map createStateStoreProperties() {
Map result = new HashMap<>();
diff --git a/sdk-tests/src/test/java/io/dapr/it/spring/data/PostgreSQLDaprKeyValueTemplateIT.java b/sdk-tests/src/test/java/io/dapr/it/spring/data/PostgreSQLDaprKeyValueTemplateIT.java
index 677a8e729..1d2ef4de8 100644
--- a/sdk-tests/src/test/java/io/dapr/it/spring/data/PostgreSQLDaprKeyValueTemplateIT.java
+++ b/sdk-tests/src/test/java/io/dapr/it/spring/data/PostgreSQLDaprKeyValueTemplateIT.java
@@ -23,6 +23,7 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
import org.springframework.data.keyvalue.core.query.KeyValueQuery;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.DynamicPropertyRegistry;
@@ -66,6 +67,7 @@ public class PostgreSQLDaprKeyValueTemplateIT {
.withNetwork(DAPR_NETWORK);
@Container
+ @ServiceConnection
private static final DaprContainer DAPR_CONTAINER = new DaprContainer("daprio/daprd:1.13.2")
.withAppName("postgresql-dapr-app")
.withNetwork(DAPR_NETWORK)
@@ -75,11 +77,6 @@ public class PostgreSQLDaprKeyValueTemplateIT {
.withLogConsumer(outputFrame -> System.out.println(outputFrame.getUtf8String()))
.dependsOn(POSTGRE_SQL_CONTAINER);
- @DynamicPropertySource
- static void daprProperties(DynamicPropertyRegistry registry) {
- registry.add("dapr.http.endpoint", DAPR_CONTAINER::getHttpEndpoint);
- registry.add("dapr.grpc.endpoint", DAPR_CONTAINER::getGrpcEndpoint);
- }
private static Map createStateStoreProperties() {
Map result = new HashMap<>();
diff --git a/sdk-tests/src/test/java/io/dapr/it/spring/data/TestDaprSpringDataConfiguration.java b/sdk-tests/src/test/java/io/dapr/it/spring/data/TestDaprSpringDataConfiguration.java
index e4b456f72..6be91f364 100644
--- a/sdk-tests/src/test/java/io/dapr/it/spring/data/TestDaprSpringDataConfiguration.java
+++ b/sdk-tests/src/test/java/io/dapr/it/spring/data/TestDaprSpringDataConfiguration.java
@@ -3,13 +3,10 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import io.dapr.client.DaprClient;
import io.dapr.spring.boot.autoconfigure.client.DaprClientAutoConfiguration;
-import io.dapr.spring.core.client.DaprClientCustomizer;
import io.dapr.spring.data.DaprKeyValueAdapterResolver;
import io.dapr.spring.data.DaprKeyValueTemplate;
import io.dapr.spring.data.KeyValueAdapterResolver;
import io.dapr.spring.data.repository.config.EnableDaprRepositories;
-import io.dapr.testcontainers.TestcontainersDaprClientCustomizer;
-import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
@@ -23,13 +20,6 @@ public ObjectMapper mapper() {
return new ObjectMapper();
}
- @Bean
- public DaprClientCustomizer daprClientCustomizer(
- @Value("${dapr.http.endpoint}") String daprHttpEndpoint,
- @Value("${dapr.grpc.endpoint}") String daprGrpcEndpoint
- ){
- return new TestcontainersDaprClientCustomizer(daprHttpEndpoint, daprGrpcEndpoint);
- }
@Bean
public KeyValueAdapterResolver keyValueAdapterResolver(DaprClient daprClient, ObjectMapper mapper) {
diff --git a/sdk-tests/src/test/java/io/dapr/it/spring/messaging/DaprSpringMessagingIT.java b/sdk-tests/src/test/java/io/dapr/it/spring/messaging/DaprSpringMessagingIT.java
index 94b00e8d9..19b6e3252 100644
--- a/sdk-tests/src/test/java/io/dapr/it/spring/messaging/DaprSpringMessagingIT.java
+++ b/sdk-tests/src/test/java/io/dapr/it/spring/messaging/DaprSpringMessagingIT.java
@@ -19,6 +19,8 @@
import io.dapr.testcontainers.Component;
import io.dapr.testcontainers.DaprContainer;
import io.dapr.testcontainers.DaprLogLevel;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
@@ -26,6 +28,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
+import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
import org.springframework.test.context.DynamicPropertyRegistry;
import org.springframework.test.context.DynamicPropertySource;
import org.testcontainers.containers.Network;
@@ -56,6 +59,7 @@ public class DaprSpringMessagingIT {
private static final Network DAPR_NETWORK = Network.newNetwork();
@Container
+ @ServiceConnection
private static final DaprContainer DAPR_CONTAINER = new DaprContainer("daprio/daprd:1.13.2")
.withAppName("messaging-dapr-app")
.withNetwork(DAPR_NETWORK)
@@ -65,22 +69,17 @@ public class DaprSpringMessagingIT {
.withLogConsumer(outputFrame -> System.out.println(outputFrame.getUtf8String()))
.withAppChannelAddress("host.testcontainers.internal");
- @DynamicPropertySource
- static void daprProperties(DynamicPropertyRegistry registry) {
- org.testcontainers.Testcontainers.exposeHostPorts(8080);
-
- registry.add("dapr.http.endpoint", DAPR_CONTAINER::getHttpEndpoint);
- registry.add("dapr.grpc.endpoint", DAPR_CONTAINER::getGrpcEndpoint);
- registry.add("dapr.grpc.port", DAPR_CONTAINER::getGrpcPort);
- registry.add("dapr.http.port", DAPR_CONTAINER::getHttpPort);
- }
-
@Autowired
private DaprMessagingTemplate messagingTemplate;
@Autowired
private TestRestController testRestController;
+ @BeforeAll
+ public static void setup(){
+ org.testcontainers.Testcontainers.exposeHostPorts(8080);
+ }
+
@Test
public void testDaprMessagingTemplate() throws InterruptedException {
for (int i = 0; i < 10; i++) {
diff --git a/sdk-tests/src/test/java/io/dapr/it/spring/messaging/TestApplication.java b/sdk-tests/src/test/java/io/dapr/it/spring/messaging/TestApplication.java
index 038a9bd9b..b9c34c136 100644
--- a/sdk-tests/src/test/java/io/dapr/it/spring/messaging/TestApplication.java
+++ b/sdk-tests/src/test/java/io/dapr/it/spring/messaging/TestApplication.java
@@ -15,10 +15,7 @@
import io.dapr.client.DaprClient;
import io.dapr.spring.boot.autoconfigure.pubsub.DaprPubSubProperties;
-import io.dapr.spring.core.client.DaprClientCustomizer;
import io.dapr.spring.messaging.DaprMessagingTemplate;
-import io.dapr.testcontainers.TestcontainersDaprClientCustomizer;
-import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
@@ -35,14 +32,6 @@ public static void main(String[] args) {
@EnableConfigurationProperties(DaprPubSubProperties.class)
static class DaprSpringMessagingConfiguration {
- @Bean
- public DaprClientCustomizer daprClientCustomizer(
- @Value("${dapr.http.endpoint}") String daprHttpEndpoint,
- @Value("${dapr.grpc.endpoint}") String daprGrpcEndpoint
- ){
- return new TestcontainersDaprClientCustomizer(daprHttpEndpoint, daprGrpcEndpoint);
- }
-
@Bean
public DaprMessagingTemplate messagingTemplate(DaprClient daprClient,
DaprPubSubProperties daprPubSubProperties) {
diff --git a/testcontainers-dapr/pom.xml b/testcontainers-dapr/pom.xml
index 106ea507e..46b40b1fa 100644
--- a/testcontainers-dapr/pom.xml
+++ b/testcontainers-dapr/pom.xml
@@ -41,12 +41,6 @@
${project.parent.version}
compile
-
- io.dapr.spring
- dapr-spring-core
- ${project.version}
- compile
-
diff --git a/testcontainers-dapr/src/main/java/io/dapr/testcontainers/TestcontainersDaprClientCustomizer.java b/testcontainers-dapr/src/main/java/io/dapr/testcontainers/TestcontainersDaprClientCustomizer.java
deleted file mode 100644
index fdd7c63ef..000000000
--- a/testcontainers-dapr/src/main/java/io/dapr/testcontainers/TestcontainersDaprClientCustomizer.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package io.dapr.testcontainers;
-
-import io.dapr.client.DaprClientBuilder;
-import io.dapr.config.Properties;
-import io.dapr.spring.core.client.DaprClientCustomizer;
-
-public class TestcontainersDaprClientCustomizer implements DaprClientCustomizer {
-
- private String httpEndpoint;
- private String grpcEndpoint;
- private Integer daprHttpPort;
- private Integer daprGrpcPort;
-
- /**
- * Constructor for TestcontainersDaprClientCustomizer.
- * @param httpEndpoint HTTP endpoint.
- * @param grpcEndpoint GRPC endpoint.
- */
- public TestcontainersDaprClientCustomizer(String httpEndpoint, String grpcEndpoint) {
- this.httpEndpoint = httpEndpoint;
- this.grpcEndpoint = grpcEndpoint;
- }
-
- /**
- * Constructor for TestcontainersDaprClientCustomizer.
- * @param daprHttpPort Dapr HTTP port.
- * @param daprGrpcPort Dapr GRPC port.
- */
- public TestcontainersDaprClientCustomizer(int daprHttpPort, int daprGrpcPort) {
- this.daprHttpPort = daprHttpPort;
- this.daprGrpcPort = daprGrpcPort;
- }
-
- @Override
- public void customize(DaprClientBuilder daprClientBuilder) {
- if (httpEndpoint != null) {
- daprClientBuilder.withPropertyOverride(Properties.HTTP_ENDPOINT, httpEndpoint);
- }
-
- if (grpcEndpoint != null) {
- daprClientBuilder.withPropertyOverride(Properties.GRPC_ENDPOINT, grpcEndpoint);
- }
-
- if (daprHttpPort != null) {
- daprClientBuilder.withPropertyOverride(Properties.HTTP_PORT, String.valueOf(daprHttpPort));
- }
-
- if (daprGrpcPort != null) {
- daprClientBuilder.withPropertyOverride(Properties.GRPC_PORT, String.valueOf(daprGrpcPort));
- }
- }
-}
diff --git a/testcontainers-dapr/src/test/java/io/dapr/testcontainers/TestcontainersDaprClientCustomizerTest.java b/testcontainers-dapr/src/test/java/io/dapr/testcontainers/TestcontainersDaprClientCustomizerTest.java
deleted file mode 100644
index 2aa139113..000000000
--- a/testcontainers-dapr/src/test/java/io/dapr/testcontainers/TestcontainersDaprClientCustomizerTest.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package io.dapr.testcontainers;
-
-import io.dapr.client.DaprClientBuilder;
-import io.dapr.config.Properties;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-
-class TestcontainersDaprClientCustomizerTest {
- private static final int HTTP_PORT = 3500;
- private static final int GRPC_PORT = 50001;
- private static final String HTTP_ENDPOINT = "http://localhost:" + HTTP_PORT;
- private static final String GRPC_ENDPOINT = "localhost:" + GRPC_PORT;
-
- private DaprClientBuilder daprClientBuilder;
-
- @BeforeEach
- void setUp() {
- daprClientBuilder = mock(DaprClientBuilder.class);
- }
-
- @Test
- void testCustomizeWithEndpointOverrides() {
- TestcontainersDaprClientCustomizer customizer = new TestcontainersDaprClientCustomizer(HTTP_ENDPOINT, GRPC_ENDPOINT);
- customizer.customize(daprClientBuilder);
-
- verify(daprClientBuilder).withPropertyOverride(Properties.HTTP_ENDPOINT, HTTP_ENDPOINT);
- verify(daprClientBuilder).withPropertyOverride(Properties.GRPC_ENDPOINT, GRPC_ENDPOINT);
- }
-
- @Test
- void testCustomizeWithPortOverrides() {
- TestcontainersDaprClientCustomizer customizer = new TestcontainersDaprClientCustomizer(HTTP_PORT, GRPC_PORT);
- customizer.customize(daprClientBuilder);
-
- verify(daprClientBuilder).withPropertyOverride(Properties.HTTP_PORT, String.valueOf(HTTP_PORT));
- verify(daprClientBuilder).withPropertyOverride(Properties.GRPC_PORT, String.valueOf(GRPC_PORT));
- }
-}