Skip to content

Commit f60f4bf

Browse files
author
Artur Ciocanu
committed
Adding Spring Boot enhancements, Sring Data Repository, Testcontainers
Signed-off-by: Artur Ciocanu <[email protected]>
1 parent a6923ed commit f60f4bf

File tree

61 files changed

+4074
-71
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+4074
-71
lines changed

.github/workflows/build.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,12 @@ jobs:
117117
uses: codecov/[email protected]
118118
- name: Install jars
119119
run: ./mvnw install -q -B -DskipTests
120+
- name: Integration tests with testcontainers using spring boot version ${{ matrix.spring-boot-version }}
121+
id: integration_tests_testcontainers
122+
run: PRODUCT_SPRING_BOOT_VERSION=${{ matrix.spring-boot-version }} ./mvnw -B -f sdk-tests/pom.xml verify -Dtest.groups=testcontainers
120123
- name: Integration tests using spring boot version ${{ matrix.spring-boot-version }}
121124
id: integration_tests
122-
run: PRODUCT_SPRING_BOOT_VERSION=${{ matrix.spring-boot-version }} ./mvnw -B -f sdk-tests/pom.xml verify
125+
run: PRODUCT_SPRING_BOOT_VERSION=${{ matrix.spring-boot-version }} ./mvnw -B -f sdk-tests/pom.xml verify -Dtest.excluded.groups=testcontainers
123126
- name: Upload test report for sdk
124127
uses: actions/upload-artifact@v4
125128
with:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<parent>
7+
<groupId>io.dapr.spring</groupId>
8+
<artifactId>dapr-spring-parent</artifactId>
9+
<version>0.13.0-SNAPSHOT</version>
10+
</parent>
11+
12+
<artifactId>dapr-spring-boot-autoconfigure</artifactId>
13+
<name>dapr-spring-boot-autoconfigure</name>
14+
<description>Dapr Spring Boot Autoconfigure</description>
15+
<packaging>jar</packaging>
16+
17+
<dependencies>
18+
<dependency>
19+
<groupId>io.dapr.spring</groupId>
20+
<artifactId>dapr-spring-core</artifactId>
21+
<version>${project.parent.version}</version>
22+
<optional>true</optional>
23+
</dependency>
24+
<dependency>
25+
<groupId>io.dapr.spring</groupId>
26+
<artifactId>dapr-spring-data</artifactId>
27+
<version>${project.parent.version}</version>
28+
<optional>true</optional>
29+
</dependency>
30+
<dependency>
31+
<groupId>io.dapr.spring</groupId>
32+
<artifactId>dapr-spring-messaging</artifactId>
33+
<version>${project.parent.version}</version>
34+
<optional>true</optional>
35+
</dependency>
36+
<dependency>
37+
<groupId>org.springframework.boot</groupId>
38+
<artifactId>spring-boot-starter</artifactId>
39+
</dependency>
40+
<dependency>
41+
<groupId>org.springframework.boot</groupId>
42+
<artifactId>spring-boot-autoconfigure-processor</artifactId>
43+
<optional>true</optional>
44+
</dependency>
45+
<dependency>
46+
<groupId>org.springframework.data</groupId>
47+
<artifactId>spring-data-keyvalue</artifactId>
48+
<optional>true</optional>
49+
</dependency>
50+
<dependency>
51+
<groupId>org.springframework.boot</groupId>
52+
<artifactId>spring-boot-starter-web</artifactId>
53+
<scope>test</scope>
54+
</dependency>
55+
<dependency>
56+
<groupId>org.testcontainers</groupId>
57+
<artifactId>testcontainers</artifactId>
58+
<scope>test</scope>
59+
</dependency>
60+
<dependency>
61+
<groupId>org.testcontainers</groupId>
62+
<artifactId>junit-jupiter</artifactId>
63+
<scope>test</scope>
64+
<exclusions>
65+
<exclusion>
66+
<groupId>com.vaadin.external.google</groupId>
67+
<artifactId>android-json</artifactId>
68+
</exclusion>
69+
</exclusions>
70+
</dependency>
71+
<dependency>
72+
<groupId>io.dapr</groupId>
73+
<artifactId>testcontainers-dapr</artifactId>
74+
<version>${dapr.sdk.alpha.version}</version>
75+
<scope>test</scope>
76+
</dependency>
77+
</dependencies>
78+
79+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Copyright 2024 The Dapr Authors
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
* Unless required by applicable law or agreed to in writing, software
8+
* distributed under the License is distributed on an "AS IS" BASIS,
9+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
* See the License for the specific language governing permissions and
11+
limitations under the License.
12+
*/
13+
14+
package io.dapr.spring.boot.autoconfigure.client;
15+
16+
import io.dapr.client.DaprClient;
17+
import io.dapr.client.DaprClientBuilder;
18+
import io.dapr.spring.core.client.DaprClientCustomizer;
19+
import org.springframework.beans.factory.ObjectProvider;
20+
import org.springframework.boot.autoconfigure.AutoConfiguration;
21+
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
22+
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
23+
import org.springframework.context.annotation.Bean;
24+
25+
import java.util.stream.Collectors;
26+
27+
@AutoConfiguration
28+
@ConditionalOnClass(DaprClient.class)
29+
public class DaprClientAutoConfiguration {
30+
31+
@Bean
32+
@ConditionalOnMissingBean
33+
DaprClientBuilderConfigurer daprClientBuilderConfigurer(ObjectProvider<DaprClientCustomizer> customizerProvider) {
34+
DaprClientBuilderConfigurer configurer = new DaprClientBuilderConfigurer();
35+
configurer.setDaprClientCustomizer(customizerProvider.orderedStream().collect(Collectors.toList()));
36+
37+
return configurer;
38+
}
39+
40+
@Bean
41+
@ConditionalOnMissingBean
42+
DaprClientBuilder daprClientBuilder(DaprClientBuilderConfigurer daprClientBuilderConfigurer) {
43+
DaprClientBuilder builder = new DaprClientBuilder();
44+
45+
return daprClientBuilderConfigurer.configure(builder);
46+
}
47+
48+
@Bean
49+
@ConditionalOnMissingBean
50+
DaprClient daprClient(DaprClientBuilder daprClientBuilder) {
51+
return daprClientBuilder.build();
52+
}
53+
54+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Copyright 2024 The Dapr Authors
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
* Unless required by applicable law or agreed to in writing, software
8+
* distributed under the License is distributed on an "AS IS" BASIS,
9+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
* See the License for the specific language governing permissions and
11+
limitations under the License.
12+
*/
13+
14+
package io.dapr.spring.boot.autoconfigure.client;
15+
16+
import io.dapr.client.DaprClientBuilder;
17+
import io.dapr.spring.core.client.DaprClientCustomizer;
18+
19+
import java.util.List;
20+
21+
/**
22+
* Builder for configuring a {@link DaprClientBuilder}.
23+
*/
24+
public class DaprClientBuilderConfigurer {
25+
26+
private List<DaprClientCustomizer> customizers;
27+
28+
void setDaprClientCustomizer(List<DaprClientCustomizer> customizers) {
29+
this.customizers = List.copyOf(customizers);
30+
}
31+
32+
/**
33+
* Configure the specified {@link DaprClientBuilder}. The builder can be further
34+
* tuned and default settings can be overridden.
35+
*
36+
* @param builder the {@link DaprClientBuilder} instance to configure
37+
* @return the configured builder
38+
*/
39+
public DaprClientBuilder configure(DaprClientBuilder builder) {
40+
applyCustomizers(builder);
41+
return builder;
42+
}
43+
44+
private void applyCustomizers(DaprClientBuilder builder) {
45+
if (this.customizers != null) {
46+
for (DaprClientCustomizer customizer : this.customizers) {
47+
customizer.customize(builder);
48+
}
49+
}
50+
}
51+
52+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright 2024 The Dapr Authors
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
* Unless required by applicable law or agreed to in writing, software
8+
* distributed under the License is distributed on an "AS IS" BASIS,
9+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
* See the License for the specific language governing permissions and
11+
limitations under the License.
12+
*/
13+
14+
package io.dapr.spring.boot.autoconfigure.pubsub;
15+
16+
import org.springframework.boot.context.properties.ConfigurationProperties;
17+
18+
19+
@ConfigurationProperties(prefix = DaprPubSubProperties.CONFIG_PREFIX)
20+
public class DaprPubSubProperties {
21+
22+
public static final String CONFIG_PREFIX = "dapr.pubsub";
23+
24+
/**
25+
* Name of the PubSub Dapr component.
26+
*/
27+
private String name;
28+
29+
public String getName() {
30+
return name;
31+
}
32+
33+
public void setName(String name) {
34+
this.name = name;
35+
}
36+
37+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright 2024 The Dapr Authors
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
* Unless required by applicable law or agreed to in writing, software
8+
* distributed under the License is distributed on an "AS IS" BASIS,
9+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
* See the License for the specific language governing permissions and
11+
limitations under the License.
12+
*/
13+
14+
package io.dapr.spring.boot.autoconfigure.statestore;
15+
16+
import org.springframework.boot.context.properties.ConfigurationProperties;
17+
18+
@ConfigurationProperties(prefix = DaprStateStoreProperties.CONFIG_PREFIX)
19+
public class DaprStateStoreProperties {
20+
21+
public static final String CONFIG_PREFIX = "dapr.statestore";
22+
23+
/**
24+
* Name of the StateStore Dapr component.
25+
*/
26+
private String name;
27+
private String binding;
28+
29+
public String getName() {
30+
return name;
31+
}
32+
33+
public void setName(String name) {
34+
this.name = name;
35+
}
36+
37+
public String getBinding() {
38+
return binding;
39+
}
40+
41+
public void setBinding(String binding) {
42+
this.binding = binding;
43+
}
44+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
io.dapr.spring.boot.autoconfigure.client.DaprClientAutoConfiguration
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright 2024 The Dapr Authors
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
* Unless required by applicable law or agreed to in writing, software
8+
* distributed under the License is distributed on an "AS IS" BASIS,
9+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
* See the License for the specific language governing permissions and
11+
limitations under the License.
12+
*/
13+
14+
package io.dapr.spring.boot.autoconfigure.client;
15+
16+
import io.dapr.client.DaprClient;
17+
import io.dapr.client.DaprClientBuilder;
18+
import org.junit.jupiter.api.Test;
19+
import org.springframework.boot.autoconfigure.AutoConfigurations;
20+
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
21+
22+
import static org.assertj.core.api.Assertions.assertThat;
23+
24+
/**
25+
* Unit tests for {@link DaprClientAutoConfiguration}.
26+
*/
27+
class DaprClientAutoConfigurationTests {
28+
29+
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
30+
.withConfiguration(AutoConfigurations.of(DaprClientAutoConfiguration.class));
31+
32+
@Test
33+
void daprClientBuilderConfigurer() {
34+
contextRunner.run(context -> assertThat(context).hasSingleBean(DaprClientBuilderConfigurer.class));
35+
}
36+
37+
@Test
38+
void daprClientBuilder() {
39+
contextRunner.run(context -> assertThat(context).hasSingleBean(DaprClientBuilder.class));
40+
}
41+
42+
@Test
43+
void daprClient() {
44+
contextRunner.run(context -> assertThat(context).hasSingleBean(DaprClient.class));
45+
}
46+
47+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<parent>
7+
<groupId>io.dapr.spring</groupId>
8+
<artifactId>dapr-spring-parent</artifactId>
9+
<version>0.13.0-SNAPSHOT</version>
10+
<relativePath>../../pom.xml</relativePath>
11+
</parent>
12+
13+
<artifactId>dapr-spring-boot-starter</artifactId>
14+
<name>dapr-spring-boot-starter</name>
15+
<description>Dapr Client Spring Boot Starter</description>
16+
<packaging>jar</packaging>
17+
18+
<dependencies>
19+
<dependency>
20+
<groupId>org.springframework.boot</groupId>
21+
<artifactId>spring-boot-starter</artifactId>
22+
</dependency>
23+
<dependency>
24+
<groupId>io.dapr.spring</groupId>
25+
<artifactId>dapr-spring-core</artifactId>
26+
<version>${project.parent.version}</version>
27+
</dependency>
28+
<dependency>
29+
<groupId>io.dapr.spring</groupId>
30+
<artifactId>dapr-spring-boot-autoconfigure</artifactId>
31+
<version>${project.parent.version}</version>
32+
</dependency>
33+
</dependencies>
34+
35+
</project>

dapr-spring/dapr-spring-core/pom.xml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<parent>
7+
<groupId>io.dapr.spring</groupId>
8+
<artifactId>dapr-spring-parent</artifactId>
9+
<version>0.13.0-SNAPSHOT</version>
10+
</parent>
11+
12+
<artifactId>dapr-spring-core</artifactId>
13+
<name>dapr-spring-core</name>
14+
<description>Dapr Spring Core</description>
15+
<packaging>jar</packaging>
16+
17+
</project>

0 commit comments

Comments
 (0)