Skip to content

Commit 3622f13

Browse files
Merge branch 'master' into users/svegiraju/cron-2
2 parents 6f6f207 + bc2b04f commit 3622f13

File tree

8 files changed

+187
-11
lines changed

8 files changed

+187
-11
lines changed

CONTRIBUTING.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ This project has adopted the [Contributor Covenant Code of Conduct](https://gith
1212

1313
Contributions come in many forms: submitting issues, writing code, participating in discussions and community calls.
1414

15+
To learn more about becoming a contributor and the different roles within the Dapr community (Contributor, Approver, Maintainer), please refer to our [Community Membership](https://github.com/dapr/community/blob/master/community-membership.md) documentation.
16+
1517
This document provides the guidelines for how to contribute to the Dapr project.
1618

1719
## Issues
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright 2025 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.testcontainers;
15+
16+
import java.util.Collections;
17+
import java.util.List;
18+
19+
public class AppHttpPipeline implements ConfigurationSettings {
20+
private List<ListEntry> handlers;
21+
22+
/**
23+
* Creates an AppHttpPipeline.
24+
*
25+
* @param handlers List of handlers for the AppHttpPipeline
26+
*/
27+
public AppHttpPipeline(List<ListEntry> handlers) {
28+
if (handlers != null) {
29+
this.handlers = Collections.unmodifiableList(handlers);
30+
}
31+
}
32+
33+
public List<ListEntry> getHandlers() {
34+
return handlers;
35+
}
36+
37+
}

testcontainers-dapr/src/main/java/io/dapr/testcontainers/Configuration.java

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,28 @@
1919
public class Configuration {
2020
private final String name;
2121
private final TracingConfigurationSettings tracing;
22+
private final AppHttpPipeline appHttpPipeline;
2223

23-
//@TODO: add httpPipeline
24-
//@TODO: add secrets
25-
//@TODO: add components
26-
//@TODO: add accessControl
24+
// @TODO: add secrets https://github.com/dapr/java-sdk/issues/1280
25+
// @TODO: add metrics https://github.com/dapr/java-sdk/issues/1281
26+
// @TODO: add logging https://github.com/dapr/java-sdk/issues/1282
27+
// @TODO: add middleware httpPipeline https://github.com/dapr/java-sdk/issues/1283
28+
// @TODO: add nameResolution https://github.com/dapr/java-sdk/issues/1284
29+
// @TODO: add disallow components https://github.com/dapr/java-sdk/issues/1285
30+
// @TODO: add mtls https://github.com/dapr/java-sdk/issues/1286
2731

2832
/**
2933
* Creates a new configuration.
30-
* @param name Configuration name.
31-
* @param tracing TracingConfigParameters tracing configuration parameters.
34+
*
35+
* @param name Configuration name.
36+
* @param tracing TracingConfigParameters tracing configuration
37+
* parameters.
38+
* @param appHttpPipeline AppHttpPipeline middleware configuration.
3239
*/
33-
public Configuration(String name, TracingConfigurationSettings tracing) {
40+
public Configuration(String name, TracingConfigurationSettings tracing, AppHttpPipeline appHttpPipeline) {
3441
this.name = name;
3542
this.tracing = tracing;
43+
this.appHttpPipeline = appHttpPipeline;
3644
}
3745

3846
public String getName() {
@@ -42,4 +50,8 @@ public String getName() {
4250
public TracingConfigurationSettings getTracing() {
4351
return tracing;
4452
}
53+
54+
public AppHttpPipeline getAppHttpPipeline() {
55+
return appHttpPipeline;
56+
}
4557
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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.testcontainers;
15+
16+
public class ListEntry {
17+
private String name;
18+
private String type;
19+
20+
public ListEntry(String name, String type) {
21+
this.name = name;
22+
this.type = type;
23+
}
24+
25+
public String getName() {
26+
return name;
27+
}
28+
29+
public String getType() {
30+
return type;
31+
}
32+
33+
public void setName(String name) {
34+
this.name = name;
35+
}
36+
37+
public void setType(String type) {
38+
this.type = type;
39+
}
40+
}

testcontainers-dapr/src/main/java/io/dapr/testcontainers/converter/ConfigurationYamlConverter.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
package io.dapr.testcontainers.converter;
22

3+
import io.dapr.testcontainers.AppHttpPipeline;
34
import io.dapr.testcontainers.Configuration;
5+
import io.dapr.testcontainers.ListEntry;
46
import io.dapr.testcontainers.OtelTracingConfigurationSettings;
57
import io.dapr.testcontainers.TracingConfigurationSettings;
68
import io.dapr.testcontainers.ZipkinTracingConfigurationSettings;
79
import org.yaml.snakeyaml.Yaml;
810

911
import java.util.LinkedHashMap;
12+
import java.util.List;
1013
import java.util.Map;
1114

1215
public class ConfigurationYamlConverter implements YamlConverter<Configuration> {
@@ -58,6 +61,17 @@ public String convert(Configuration configuration) {
5861
}
5962

6063
configurationSpec.put("tracing", tracingMap);
64+
65+
}
66+
67+
AppHttpPipeline appHttpPipeline = configuration.getAppHttpPipeline();
68+
if (appHttpPipeline != null) {
69+
70+
Map<String, Object> appHttpPipelineMap = new LinkedHashMap<>();
71+
List<ListEntry> handlers = appHttpPipeline.getHandlers();
72+
appHttpPipelineMap.put("handlers", handlers);
73+
configurationSpec.put("appHttpPipeline", appHttpPipelineMap);
74+
6175
}
6276

6377
configurationProps.put("spec", configurationSpec);

testcontainers-dapr/src/main/java/io/dapr/testcontainers/converter/YamlMapperFactory.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.dapr.testcontainers.converter;
22

3+
import io.dapr.testcontainers.ListEntry;
34
import io.dapr.testcontainers.MetadataEntry;
45
import org.yaml.snakeyaml.DumperOptions;
56
import org.yaml.snakeyaml.Yaml;
@@ -21,6 +22,7 @@ public static Yaml create() {
2122
options.setPrettyFlow(true);
2223
Representer representer = new Representer(options);
2324
representer.addClassTag(MetadataEntry.class, Tag.MAP);
25+
representer.addClassTag(ListEntry.class, Tag.MAP);
2426
return new Yaml(representer);
2527
}
2628
}

testcontainers-dapr/src/test/java/io/dapr/testcontainers/converter/ComponentYamlConverterTest.java

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ public void testComponentToYaml() {
3434
assertFalse(kvstore.getMetadata().isEmpty());
3535

3636
String componentYaml = converter.convert(kvstore);
37-
String expectedComponentYaml =
38-
"apiVersion: dapr.io/v1alpha1\n"
37+
String expectedComponentYaml = "apiVersion: dapr.io/v1alpha1\n"
3938
+ "kind: Component\n"
4039
+ "metadata:\n"
4140
+ " name: statestore\n"
@@ -48,4 +47,46 @@ public void testComponentToYaml() {
4847

4948
assertEquals(expectedComponentYaml, componentYaml);
5049
}
50+
51+
@Test
52+
public void testComponentWithInLineStringToYaml() {
53+
DaprContainer dapr = new DaprContainer("daprio/daprd")
54+
.withAppName("dapr-app")
55+
.withAppPort(8081)
56+
.withComponent(new Component(
57+
"alias",
58+
"middleware.http.routeralias",
59+
"v1",
60+
Map.of("routes", "{\n" +
61+
" \"/mall/activity/info\": \"/v1.0/invoke/srv.default/method/mall/activity/info\",\n" +
62+
" \"/hello/activity/{id}/info\": \"/v1.0/invoke/srv.default/method/hello/activity/info\",\n" + //
63+
" \"/hello/activity/{id}/user\": \"/v1.0/invoke/srv.default/method/hello/activity/user\"\n" + //
64+
"}")))
65+
.withAppChannelAddress("host.testcontainers.internal");
66+
67+
Set<Component> components = dapr.getComponents();
68+
assertEquals(1, components.size());
69+
70+
Component kvstore = components.iterator().next();
71+
assertFalse(kvstore.getMetadata().isEmpty());
72+
73+
String componentYaml = converter.convert(kvstore);
74+
String expectedComponentYaml = "apiVersion: dapr.io/v1alpha1\n"
75+
+ "kind: Component\n"
76+
+ "metadata:\n"
77+
+ " name: alias\n"
78+
+ "spec:\n"
79+
+ " type: middleware.http.routeralias\n"
80+
+ " version: v1\n"
81+
+ " metadata:\n"
82+
+ " - name: routes\n"
83+
+ " value: |-\n"
84+
+ " {\n"
85+
+ " \"/mall/activity/info\": \"/v1.0/invoke/srv.default/method/mall/activity/info\",\n"
86+
+ " \"/hello/activity/{id}/info\": \"/v1.0/invoke/srv.default/method/hello/activity/info\",\n"
87+
+ " \"/hello/activity/{id}/user\": \"/v1.0/invoke/srv.default/method/hello/activity/user\"\n"
88+
+ " }\n";
89+
90+
assertEquals(expectedComponentYaml, componentYaml);
91+
}
5192
}

testcontainers-dapr/src/test/java/io/dapr/testcontainers/converter/ConfigurationYamlConverterTest.java

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
1+
/*
2+
* Copyright 2025 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+
114
package io.dapr.testcontainers.converter;
215

16+
import io.dapr.testcontainers.AppHttpPipeline;
317
import io.dapr.testcontainers.Configuration;
418
import io.dapr.testcontainers.DaprContainer;
19+
import io.dapr.testcontainers.ListEntry;
520
import io.dapr.testcontainers.OtelTracingConfigurationSettings;
621
import io.dapr.testcontainers.TracingConfigurationSettings;
722
import org.junit.jupiter.api.Test;
@@ -10,6 +25,9 @@
1025
import static org.junit.jupiter.api.Assertions.assertEquals;
1126
import static org.junit.jupiter.api.Assertions.assertNotNull;
1227

28+
import java.util.ArrayList;
29+
import java.util.List;
30+
1331
class ConfigurationYamlConverterTest {
1432
private final Yaml MAPPER = YamlMapperFactory.create();
1533
private final ConfigurationYamlConverter converter = new ConfigurationYamlConverter(MAPPER);
@@ -28,10 +46,16 @@ public void testConfigurationToYaml() {
2846
null
2947
);
3048

49+
50+
List<ListEntry> handlers = new ArrayList<>();
51+
handlers.add(new ListEntry("alias", "middleware.http.routeralias"));
52+
53+
AppHttpPipeline appHttpPipeline = new AppHttpPipeline(handlers);
54+
3155
DaprContainer dapr = new DaprContainer("daprio/daprd")
3256
.withAppName("dapr-app")
3357
.withAppPort(8081)
34-
.withConfiguration(new Configuration("my-config", tracing))
58+
.withConfiguration(new Configuration("my-config", tracing, appHttpPipeline))
3559
.withAppChannelAddress("host.testcontainers.internal");
3660

3761
Configuration configuration = dapr.getConfiguration();
@@ -50,7 +74,11 @@ public void testConfigurationToYaml() {
5074
+ " otel:\n"
5175
+ " endpointAddress: localhost:4317\n"
5276
+ " isSecure: false\n"
53-
+ " protocol: grpc\n";
77+
+ " protocol: grpc\n"
78+
+ " appHttpPipeline:\n"
79+
+ " handlers:\n"
80+
+ " - name: alias\n"
81+
+ " type: middleware.http.routeralias\n";
5482

5583
assertEquals(expectedConfigurationYaml, configurationYaml);
5684
}

0 commit comments

Comments
 (0)