Skip to content

Commit 0ba7448

Browse files
committed
setting default props for dapr client
Signed-off-by: salaboy <[email protected]>
1 parent a7d426a commit 0ba7448

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

dapr-spring/dapr-spring-boot-autoconfigure/src/main/java/io/dapr/spring/boot/autoconfigure/client/DaprClientProperties.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717

1818
@ConfigurationProperties(prefix = "dapr.client")
1919
public class DaprClientProperties {
20-
private String httpEndpoint;
21-
private String grpcEndpoint;
22-
private Integer httpPort;
23-
private Integer grpcPort;
20+
private String httpEndpoint = "http://localhost";
21+
private String grpcEndpoint = "localhost";
22+
private Integer httpPort = 3500;
23+
private Integer grpcPort = 50001;
2424
private String apiToken;
2525

2626
/**

dapr-spring/dapr-spring-boot-autoconfigure/src/test/java/io/dapr/spring/boot/autoconfigure/client/DaprClientPropertiesTest.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,21 @@ public void shouldSetDaprClientPropertiesCorrectly() {
6464
});
6565
}
6666

67+
@Test
68+
@DisplayName("Should create DaprClientProperties default values correctly")
69+
public void shouldSetDaprClientDefaultPropertiesCorrectly() {
70+
71+
DaprClientProperties properties = new DaprClientProperties();
72+
73+
SoftAssertions.assertSoftly(softAssertions -> {
74+
softAssertions.assertThat(properties.getGrpcEndpoint()).isEqualTo("localhost");
75+
softAssertions.assertThat(properties.getHttpEndpoint()).isEqualTo("http://localhost");
76+
softAssertions.assertThat(properties.getHttpPort()).isEqualTo(3500);
77+
softAssertions.assertThat(properties.getGrpcPort()).isEqualTo(50001);
78+
softAssertions.assertThat(properties.getApiToken()).isNull();
79+
});
80+
}
81+
6782
@Test
6883
@DisplayName("Should map DaprClient properties correctly")
6984
public void shouldMapDaprClientProperties() {
@@ -105,6 +120,8 @@ public void shouldMapDaprClientPropertiesCamelCase() {
105120
});
106121
}
107122

123+
124+
108125
@EnableConfigurationProperties(DaprClientProperties.class)
109126
static class EnableDaprClientProperties {
110127

0 commit comments

Comments
 (0)