incrementAndGet(int delta);
37 | }
38 |
--------------------------------------------------------------------------------
/examples/src/main/java/io/dapr/examples/bindings/http/docker-compose-single-kafka.yml:
--------------------------------------------------------------------------------
1 | services:
2 | zookeeper:
3 | image: confluentinc/cp-zookeeper:7.4.4
4 | environment:
5 | ZOOKEEPER_CLIENT_PORT: 2181
6 | ZOOKEEPER_TICK_TIME: 2000
7 | ports:
8 | - 22181:2181
9 |
10 | kafka:
11 | image: confluentinc/cp-kafka:7.4.4
12 | depends_on:
13 | - zookeeper
14 | ports:
15 | - 9092:9092
16 | environment:
17 | KAFKA_BROKER_ID: 1
18 | KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
19 | KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:29092,PLAINTEXT_HOST://localhost:9092
20 | KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
21 | KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
22 | KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
--------------------------------------------------------------------------------
/examples/src/main/java/io/dapr/examples/jobs/DemoJobsSpringApplication.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021 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.examples.jobs;
15 |
16 | import org.springframework.boot.SpringApplication;
17 | import org.springframework.boot.autoconfigure.SpringBootApplication;
18 |
19 | /**
20 | * Spring Boot application to demonstrate Dapr Jobs callback API.
21 | *
22 | * This application demonstrates how to use Dapr Jobs API with Spring Boot.
23 | *
24 | */
25 | @SpringBootApplication
26 | public class DemoJobsSpringApplication {
27 |
28 | public static void main(String[] args) throws Exception {
29 | SpringApplication.run(DemoJobsSpringApplication.class, args);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/examples/src/main/java/io/dapr/examples/querystate/docker-compose-single-mongo.yml:
--------------------------------------------------------------------------------
1 | services:
2 | mongo:
3 | image: mongo
4 | ports:
5 | - "27017:27017"
--------------------------------------------------------------------------------
/examples/src/main/java/io/dapr/examples/secrets/config.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: dapr.io/v1alpha1
2 | kind: Configuration
3 | metadata:
4 | name: daprConfig
5 | spec:
6 | secrets:
7 | scopes:
8 | - storeName: "localSecretStore"
9 | defaultAccess: "deny"
10 | allowedSecrets: ["redisPassword"]
11 |
--------------------------------------------------------------------------------
/examples/src/main/java/io/dapr/examples/state/docker-compose-single-mongo.yml:
--------------------------------------------------------------------------------
1 | services:
2 | mongo:
3 | image: mongo
4 | ports:
5 | - "27017:27017"
--------------------------------------------------------------------------------
/examples/src/main/java/io/dapr/examples/workflows/chain/DemoChainWorkflow.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 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.examples.workflows.chain;
15 |
16 | import io.dapr.workflows.Workflow;
17 | import io.dapr.workflows.WorkflowStub;
18 |
19 | public class DemoChainWorkflow implements Workflow {
20 | @Override
21 | public WorkflowStub create() {
22 | return ctx -> {
23 | ctx.getLogger().info("Starting Workflow: " + ctx.getName());
24 |
25 | String result = "";
26 | result += ctx.callActivity(ToUpperCaseActivity.class.getName(), "Tokyo", String.class).await() + ", ";
27 | result += ctx.callActivity(ToUpperCaseActivity.class.getName(), "London", String.class).await() + ", ";
28 | result += ctx.callActivity(ToUpperCaseActivity.class.getName(), "Seattle", String.class).await();
29 |
30 | ctx.getLogger().info("Workflow finished with result: " + result);
31 | ctx.complete(result);
32 | };
33 | }
34 | }
--------------------------------------------------------------------------------
/examples/src/main/java/io/dapr/examples/workflows/chain/ToUpperCaseActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 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.examples.workflows.chain;
15 |
16 | import io.dapr.workflows.WorkflowActivity;
17 | import io.dapr.workflows.WorkflowActivityContext;
18 | import org.slf4j.Logger;
19 | import org.slf4j.LoggerFactory;
20 |
21 |
22 | public class ToUpperCaseActivity implements WorkflowActivity {
23 |
24 | @Override
25 | public Object run(WorkflowActivityContext ctx) {
26 | Logger logger = LoggerFactory.getLogger(ToUpperCaseActivity.class);
27 | logger.info("Starting Activity: " + ctx.getName());
28 |
29 | var message = ctx.getInput(String.class);
30 | var newMessage = message.toUpperCase();
31 |
32 | logger.info("Message Received from input: " + message);
33 | logger.info("Sending message to output: " + newMessage);
34 |
35 | return newMessage;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/examples/src/main/java/io/dapr/examples/workflows/childworkflow/DemoWorkflow.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 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.examples.workflows.childworkflow;
15 |
16 | import io.dapr.workflows.Workflow;
17 | import io.dapr.workflows.WorkflowStub;
18 |
19 | public class DemoWorkflow implements Workflow {
20 | @Override
21 | public WorkflowStub create() {
22 | return ctx -> {
23 | ctx.getLogger().info("Starting Workflow: " + ctx.getName());
24 |
25 | var childWorkflowInput = "Hello Dapr Workflow!";
26 | ctx.getLogger().info("calling childworkflow with input: " + childWorkflowInput);
27 |
28 | var childWorkflowOutput =
29 | ctx.callChildWorkflow(DemoChildWorkflow.class.getName(), childWorkflowInput, String.class).await();
30 |
31 | ctx.getLogger().info("childworkflow finished with: " + childWorkflowOutput);
32 | ctx.complete(childWorkflowOutput);
33 | };
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/examples/src/main/java/io/dapr/examples/workflows/childworkflow/ReverseActivity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 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.examples.workflows.childworkflow;
15 |
16 | import io.dapr.workflows.WorkflowActivity;
17 | import io.dapr.workflows.WorkflowActivityContext;
18 | import org.slf4j.Logger;
19 | import org.slf4j.LoggerFactory;
20 |
21 | public class ReverseActivity implements WorkflowActivity {
22 | @Override
23 | public Object run(WorkflowActivityContext ctx) {
24 | Logger logger = LoggerFactory.getLogger(ReverseActivity.class);
25 | logger.info("Starting Activity: " + ctx.getName());
26 |
27 | var message = ctx.getInput(String.class);
28 | var newMessage = new StringBuilder(message).reverse().toString();
29 |
30 | logger.info("Message Received from input: " + message);
31 | logger.info("Sending message to output: " + newMessage);
32 |
33 | return newMessage;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/examples/src/main/resources/img/intellij-integration-test.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dapr/java-sdk/f73d57eb27028bf41e9ab1fde3b50586ab5de919/examples/src/main/resources/img/intellij-integration-test.png
--------------------------------------------------------------------------------
/examples/src/main/resources/img/zipkin-bulk-publish-details.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dapr/java-sdk/f73d57eb27028bf41e9ab1fde3b50586ab5de919/examples/src/main/resources/img/zipkin-bulk-publish-details.png
--------------------------------------------------------------------------------
/examples/src/main/resources/img/zipkin-details.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dapr/java-sdk/f73d57eb27028bf41e9ab1fde3b50586ab5de919/examples/src/main/resources/img/zipkin-details.png
--------------------------------------------------------------------------------
/examples/src/main/resources/img/zipkin-landing.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dapr/java-sdk/f73d57eb27028bf41e9ab1fde3b50586ab5de919/examples/src/main/resources/img/zipkin-landing.png
--------------------------------------------------------------------------------
/examples/src/main/resources/img/zipkin-pubsub-details-custom-span.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dapr/java-sdk/f73d57eb27028bf41e9ab1fde3b50586ab5de919/examples/src/main/resources/img/zipkin-pubsub-details-custom-span.png
--------------------------------------------------------------------------------
/examples/src/main/resources/img/zipkin-pubsub-details.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dapr/java-sdk/f73d57eb27028bf41e9ab1fde3b50586ab5de919/examples/src/main/resources/img/zipkin-pubsub-details.png
--------------------------------------------------------------------------------
/examples/src/main/resources/img/zipkin-pubsub-landing.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dapr/java-sdk/f73d57eb27028bf41e9ab1fde3b50586ab5de919/examples/src/main/resources/img/zipkin-pubsub-landing.png
--------------------------------------------------------------------------------
/examples/src/main/resources/img/zipkin-pubsub-result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dapr/java-sdk/f73d57eb27028bf41e9ab1fde3b50586ab5de919/examples/src/main/resources/img/zipkin-pubsub-result.png
--------------------------------------------------------------------------------
/examples/src/main/resources/img/zipkin-result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dapr/java-sdk/f73d57eb27028bf41e9ab1fde3b50586ab5de919/examples/src/main/resources/img/zipkin-result.png
--------------------------------------------------------------------------------
/examples/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | %d {HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/sdk-actors/spotbugs-exclude.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/sdk-actors/src/main/java/io/dapr/actors/ActorType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021 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.actors;
15 |
16 | import java.lang.annotation.Documented;
17 | import java.lang.annotation.ElementType;
18 | import java.lang.annotation.Retention;
19 | import java.lang.annotation.RetentionPolicy;
20 | import java.lang.annotation.Target;
21 |
22 | /**
23 | * Annotation to define Actor class.
24 | */
25 | @Documented
26 | @Target({ElementType.TYPE_USE, ElementType.TYPE})
27 | @Retention(RetentionPolicy.RUNTIME)
28 | public @interface ActorType {
29 |
30 | /**
31 | * Overrides Actor's name.
32 | *
33 | * @return Actor's name.
34 | */
35 | String name();
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/sdk-actors/src/main/java/io/dapr/actors/Undefined.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021 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.actors;
15 |
16 | /**
17 | * Internal class to represent the undefined value for an optional Class attribute.
18 | */
19 | final class Undefined {
20 |
21 | private Undefined() {
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/sdk-actors/src/main/java/io/dapr/actors/client/DaprClient.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021 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.actors.client;
15 |
16 | import reactor.core.publisher.Mono;
17 |
18 | /**
19 | * Generic Client Adapter to be used regardless of the GRPC or the HTTP Client implementation required.
20 | */
21 | interface DaprClient {
22 |
23 | /**
24 | * Invokes an Actor method on Dapr.
25 | *
26 | * @param actorType Type of actor.
27 | * @param actorId Actor Identifier.
28 | * @param methodName Method name to invoke.
29 | * @param jsonPayload Serialized body.
30 | * @return Asynchronous result with the Actor's response.
31 | */
32 | Mono invoke(String actorType, String actorId, String methodName, byte[] jsonPayload);
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/sdk-actors/src/main/java/io/dapr/actors/runtime/ActorCallType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021 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.actors.runtime;
15 |
16 | /**
17 | * Represents the call-type associated with the method invoked by actor runtime.
18 | */
19 | enum ActorCallType {
20 |
21 | /**
22 | * Specifies that the method invoked is an actor interface method for a given
23 | * client request.
24 | */
25 | ACTOR_INTERFACE_METHOD,
26 | /**
27 | * Specifies that the method invoked is a timer callback method.
28 | */
29 | TIMER_METHOD,
30 | /**
31 | * Specifies that the method is when a reminder fires.
32 | */
33 | REMINDER_METHOD
34 | }
35 |
--------------------------------------------------------------------------------
/sdk-actors/src/main/java/io/dapr/actors/runtime/ActorFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021 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.actors.runtime;
15 |
16 | import io.dapr.actors.ActorId;
17 |
18 | /**
19 | * Creates an actor of a given type.
20 | *
21 | * @param Actor Type to be created.
22 | */
23 | @FunctionalInterface
24 | public interface ActorFactory {
25 |
26 | /**
27 | * Creates an Actor.
28 | *
29 | * @param actorRuntimeContext Actor type's context in the runtime.
30 | * @param actorId Actor Id.
31 | * @return Actor or null it failed.
32 | */
33 | T createActor(ActorRuntimeContext actorRuntimeContext, ActorId actorId);
34 | }
35 |
--------------------------------------------------------------------------------
/sdk-actors/src/test/java/io/dapr/actors/client/ActorProxyImplForTests.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021 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.actors.client;
15 |
16 | import io.dapr.actors.ActorId;
17 | import io.dapr.serializer.DaprObjectSerializer;
18 |
19 | public class ActorProxyImplForTests extends ActorProxyImpl {
20 |
21 | public ActorProxyImplForTests(String actorType, ActorId actorId, DaprObjectSerializer serializer, ActorClient actorClient) {
22 | super(actorType, actorId, serializer, actorClient);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/sdk-actors/src/test/java/io/dapr/actors/client/DaprClientStub.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021 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.actors.client;
15 |
16 | import reactor.core.publisher.Mono;
17 |
18 | public class DaprClientStub extends ActorClient implements DaprClient {
19 |
20 | @Override
21 | public Mono invoke(String actorType, String actorId, String methodName, byte[] jsonPayload) {
22 | return Mono.just(new byte[0]);
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/sdk-actors/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker:
--------------------------------------------------------------------------------
1 | mock-maker-inline
2 |
--------------------------------------------------------------------------------
/sdk-autogen/src/main/java/.keepme:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dapr/java-sdk/f73d57eb27028bf41e9ab1fde3b50586ab5de919/sdk-autogen/src/main/java/.keepme
--------------------------------------------------------------------------------
/sdk-autogen/src/test/java/.keepme:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dapr/java-sdk/f73d57eb27028bf41e9ab1fde3b50586ab5de919/sdk-autogen/src/test/java/.keepme
--------------------------------------------------------------------------------
/sdk-springboot/spotbugs-exclude.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/sdk-springboot/src/main/java/io/dapr/springboot/DaprAutoConfiguration.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021 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.springboot;
15 |
16 | import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
17 | import org.springframework.context.annotation.ComponentScan;
18 | import org.springframework.context.annotation.Configuration;
19 |
20 | /**
21 | * Dapr's Spring Boot AutoConfiguration.
22 | */
23 | @Configuration
24 | @ConditionalOnWebApplication
25 | @ComponentScan("io.dapr.springboot")
26 | public class DaprAutoConfiguration {
27 | }
28 |
--------------------------------------------------------------------------------
/sdk-springboot/src/main/java/io/dapr/springboot/DaprTopicRoutes.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 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.springboot;
15 |
16 | import com.fasterxml.jackson.annotation.JsonProperty;
17 |
18 | import java.util.List;
19 | import java.util.Optional;
20 |
21 | class DaprTopicRoutes {
22 | private final List rules;
23 | @JsonProperty("default")
24 | private final String defaultRoute;
25 |
26 | DaprTopicRoutes(List rules, String defaultRoute) {
27 | this.rules = rules;
28 | this.defaultRoute = defaultRoute;
29 | }
30 |
31 | public List getRules() {
32 | return rules;
33 | }
34 |
35 | public String getDefaultRoute() {
36 | return defaultRoute;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/sdk-springboot/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports:
--------------------------------------------------------------------------------
1 | io.dapr.springboot.DaprAutoConfiguration
--------------------------------------------------------------------------------
/sdk-springboot/src/test/java/io/dapr/springboot/MockStringValueResolver.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 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.springboot;
15 |
16 | import org.springframework.util.StringValueResolver;
17 |
18 | /**
19 | * MockStringValueResolver resolves a string value to return itself.
20 | */
21 | public class MockStringValueResolver implements StringValueResolver {
22 | @Override
23 | public String resolveStringValue(String s) {
24 | return s;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/sdk-tests/.hashicorp_vault_token:
--------------------------------------------------------------------------------
1 | myroot
2 |
--------------------------------------------------------------------------------
/sdk-tests/components/http_binding.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: dapr.io/v1alpha1
2 | kind: Component
3 | metadata:
4 | name: github-http-binding-404
5 | spec:
6 | type: bindings.http
7 | version: v1
8 | metadata:
9 | - name: url
10 | value: https://api.github.com/unknown_path
11 | scopes:
12 | - bindingit-httpoutputbinding-exception
13 | ---
14 | apiVersion: dapr.io/v1alpha1
15 | kind: Component
16 | metadata:
17 | name: github-http-binding-404-success
18 | spec:
19 | type: bindings.http
20 | version: v1
21 | metadata:
22 | - name: url
23 | value: https://api.github.com/unknown_path
24 | - name: errorIfNot2XX
25 | value: "false"
26 | scopes:
27 | - bindingit-httpoutputbinding-ignore-error
--------------------------------------------------------------------------------
/sdk-tests/components/kafka_bindings.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: dapr.io/v1alpha1
2 | kind: Component
3 | metadata:
4 | name: sample123
5 | spec:
6 | type: bindings.kafka
7 | version: v1
8 | metadata:
9 | # Kafka broker connection setting
10 | - name: brokers
11 | value: localhost:9092
12 | # consumer configuration: topic and consumer group
13 | - name: topics
14 | value: "topic-{appID}"
15 | - name: consumerGroup
16 | value: "{appID}"
17 | # publisher configuration: topic
18 | - name: publishTopic
19 | value: "topic-{appID}"
20 | - name: authRequired
21 | value: "false"
22 | - name: initialOffset
23 | value: oldest
24 | scopes:
25 | - bindingit-http-inputbindingservice
26 | - bindingit-grpc-inputbindingservice
--------------------------------------------------------------------------------
/sdk-tests/components/mongo-statestore.yml:
--------------------------------------------------------------------------------
1 | apiVersion: dapr.io/v1alpha1
2 | kind: Component
3 | metadata:
4 | name: mongo-statestore
5 | spec:
6 | type: state.mongodb
7 | version: v1
8 | metadata:
9 | - name: host
10 | value: localhost:27017
11 | - name: databaseName
12 | value: local
13 | - name: collectionName
14 | value: testCollection
15 | scopes:
16 | - grpcstateclientit
17 | - httpstateclientit
--------------------------------------------------------------------------------
/sdk-tests/components/pubsub.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: dapr.io/v1alpha1
2 | kind: Component
3 | metadata:
4 | name: messagebus
5 | spec:
6 | type: pubsub.redis
7 | version: v1
8 | metadata:
9 | - name: redisHost
10 | value: localhost:6379
11 | - name: redisPassword
12 | value: ""
13 |
--------------------------------------------------------------------------------
/sdk-tests/components/redisconfigstore.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: dapr.io/v1alpha1
2 | kind: Component
3 | metadata:
4 | name: redisconfigstore
5 | spec:
6 | type: configuration.redis
7 | version: v1
8 | metadata:
9 | - name: redisHost
10 | value: localhost:6379
11 | - name: redisPassword
12 | value: ""
13 |
--------------------------------------------------------------------------------
/sdk-tests/components/secret.json:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/sdk-tests/components/secretstore.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: dapr.io/v1alpha1
2 | kind: Component
3 | metadata:
4 | name: localSecretStore
5 | spec:
6 | type: secretstores.local.file
7 | version: v1
8 | metadata:
9 | - name: secretsFile
10 | value: "./components/secret.json"
11 | - name: nestedSeparator
12 | value: ":"
13 | - name: multiValued
14 | value: "true"
15 |
--------------------------------------------------------------------------------
/sdk-tests/components/statestore.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: dapr.io/v1alpha1
2 | kind: Component
3 | metadata:
4 | name: statestore
5 | spec:
6 | type: state.redis
7 | version: v1
8 | metadata:
9 | - name: redisHost
10 | value: localhost:6379
11 | - name: redisPassword
12 | value: ""
13 | - name: actorStateStore
14 | value: "true"
15 |
--------------------------------------------------------------------------------
/sdk-tests/configurations/configuration.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: dapr.io/v1alpha1
2 | kind: Configuration
3 | metadata:
4 | name: testconfiguration
5 | spec:
6 | tracing:
7 | samplingRate: "1"
8 | zipkin:
9 | endpointAddress: http://localhost:9411/api/v2/spans
--------------------------------------------------------------------------------
/sdk-tests/deploy/local-test.yml:
--------------------------------------------------------------------------------
1 | version: '3'
2 | services:
3 | zookeeper:
4 | image: confluentinc/cp-zookeeper:7.4.4
5 | environment:
6 | ZOOKEEPER_CLIENT_PORT: 2181
7 | ZOOKEEPER_TICK_TIME: 2000
8 | ports:
9 | - 2181:2181
10 |
11 | kafka:
12 | image: confluentinc/cp-kafka:7.4.4
13 | depends_on:
14 | - zookeeper
15 | ports:
16 | - "9092:9092"
17 | environment:
18 | KAFKA_BROKER_ID: 1
19 | KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
20 | KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:29092,PLAINTEXT_HOST://localhost:9092
21 | KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
22 | KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
23 | KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
24 |
25 | mongo:
26 | image: mongo
27 | ports:
28 | - "27017:27017"
29 |
--------------------------------------------------------------------------------
/sdk-tests/src/test/java/io/dapr/actors/runtime/DaprClientHttpUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021 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 | package io.dapr.actors.runtime;
14 |
15 | import io.grpc.ManagedChannel;
16 |
17 | /**
18 | * Exposes useful methods for IT in DaprClientHttp.
19 | */
20 | public class DaprClientHttpUtils {
21 |
22 | public static void unregisterActorReminder(
23 | ManagedChannel channel,
24 | String actorType,
25 | String actorId,
26 | String reminderName) {
27 | new DaprClientImpl(channel).unregisterReminder(actorType, actorId, reminderName).block();
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/sdk-tests/src/test/java/io/dapr/grpc/GrpcHealthCheckService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 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.grpc;
15 |
16 | import io.dapr.v1.AppCallbackHealthCheckGrpc;
17 | import io.dapr.v1.DaprAppCallbackProtos;
18 |
19 | /**
20 | * Handles apps' health check callback.
21 | */
22 | public class GrpcHealthCheckService extends AppCallbackHealthCheckGrpc.AppCallbackHealthCheckImplBase {
23 |
24 | /**
25 | * Handler for health check.
26 | * @param request Empty request.
27 | * @param responseObserver Response for gRPC response.
28 | */
29 | public void healthCheck(
30 | com.google.protobuf.Empty request,
31 | io.grpc.stub.StreamObserver responseObserver) {
32 | responseObserver.onNext(DaprAppCallbackProtos.HealthCheckResponse.newBuilder().build());
33 | responseObserver.onCompleted();
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/sdk-tests/src/test/java/io/dapr/it/DaprRunConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021 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.it;
15 |
16 | import java.lang.annotation.ElementType;
17 | import java.lang.annotation.Retention;
18 | import java.lang.annotation.RetentionPolicy;
19 | import java.lang.annotation.Target;
20 |
21 | /**
22 | * Customizes an app run for Dapr.
23 | */
24 | @Target(ElementType.TYPE)
25 | @Retention(RetentionPolicy.RUNTIME)
26 | public @interface DaprRunConfig {
27 |
28 | boolean enableAppHealthCheck() default false;
29 |
30 | boolean enableDaprApiToken() default true;
31 | }
32 |
--------------------------------------------------------------------------------
/sdk-tests/src/test/java/io/dapr/it/Retry.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021 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.it;
15 |
16 | public class Retry {
17 |
18 | private Retry() {}
19 |
20 | public static void callWithRetry(Runnable function, long retryTimeoutMilliseconds) throws InterruptedException {
21 | long started = System.currentTimeMillis();
22 | while (true) {
23 | Throwable exception;
24 | try {
25 | function.run();
26 | return;
27 | } catch (Exception e) {
28 | exception = e;
29 | } catch (AssertionError e) {
30 | exception = e;
31 | }
32 |
33 | if (System.currentTimeMillis() - started >= retryTimeoutMilliseconds) {
34 | throw new RuntimeException(exception);
35 | }
36 | Thread.sleep(1000);
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/sdk-tests/src/test/java/io/dapr/it/Stoppable.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021 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.it;
15 |
16 |
17 | import java.io.IOException;
18 |
19 | public interface Stoppable {
20 |
21 | void stop() throws InterruptedException, IOException;
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/sdk-tests/src/test/java/io/dapr/it/actors/app/MyActor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021 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.it.actors.app;
15 |
16 | import io.dapr.actors.ActorMethod;
17 |
18 | import java.util.ArrayList;
19 | import java.util.List;
20 |
21 | public interface MyActor {
22 | String say(String something);
23 |
24 | List retrieveActiveActors();
25 |
26 | void setReminderData(ActorReminderDataParam param);
27 |
28 | void startReminder(String name) throws Exception;
29 |
30 | void stopReminder(String name);
31 |
32 | void startTimer(String name);
33 |
34 | void stopTimer(String name);
35 |
36 | void clock(String message);
37 |
38 | ArrayList getCallLog();
39 |
40 | String getIdentifier();
41 |
42 | void throwException();
43 |
44 | @ActorMethod(name = "DotNetMethodAsync")
45 | boolean dotNetMethod();
46 | }
--------------------------------------------------------------------------------
/sdk-tests/src/test/java/io/dapr/it/actors/app/MyActorBinaryImpl.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021 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.it.actors.app;
15 |
16 | import io.dapr.actors.ActorId;
17 | import io.dapr.actors.ActorType;
18 | import io.dapr.actors.runtime.ActorRuntimeContext;
19 | import io.dapr.actors.runtime.Remindable;
20 | import io.dapr.utils.TypeRef;
21 |
22 | @ActorType(name = "MyActorBinaryTest")
23 | public class MyActorBinaryImpl extends MyActorBase implements MyActor, Remindable {
24 |
25 | public MyActorBinaryImpl(ActorRuntimeContext runtimeContext, ActorId id) {
26 | super(runtimeContext, id, TypeRef.BYTE_ARRAY);
27 | }
28 |
29 | }
--------------------------------------------------------------------------------
/sdk-tests/src/test/java/io/dapr/it/actors/app/MyActorObjectImpl.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021 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.it.actors.app;
15 |
16 | import io.dapr.actors.ActorId;
17 | import io.dapr.actors.ActorType;
18 | import io.dapr.actors.runtime.ActorRuntimeContext;
19 | import io.dapr.actors.runtime.Remindable;
20 | import io.dapr.utils.TypeRef;
21 |
22 | @ActorType(name = "MyActorObjectTest")
23 | public class MyActorObjectImpl extends MyActorBase implements MyActor, Remindable {
24 |
25 | public MyActorObjectImpl(ActorRuntimeContext runtimeContext, ActorId id) {
26 | super(runtimeContext, id, TypeRef.get(MyObject.class));
27 | }
28 |
29 | }
--------------------------------------------------------------------------------
/sdk-tests/src/test/java/io/dapr/it/actors/app/MyActorStringImpl.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021 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.it.actors.app;
15 |
16 | import io.dapr.actors.ActorId;
17 | import io.dapr.actors.ActorType;
18 | import io.dapr.actors.runtime.ActorRuntimeContext;
19 | import io.dapr.actors.runtime.Remindable;
20 | import io.dapr.utils.TypeRef;
21 |
22 | @ActorType(name = "MyActorTest")
23 | public class MyActorStringImpl extends MyActorBase implements MyActor, Remindable {
24 |
25 | public MyActorStringImpl(ActorRuntimeContext runtimeContext, ActorId id) {
26 | super(runtimeContext, id, TypeRef.STRING);
27 | }
28 |
29 | }
--------------------------------------------------------------------------------
/sdk-tests/src/test/java/io/dapr/it/actors/app/MyObject.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021 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.it.actors.app;
15 |
16 | /**
17 | * This class is for passing string or binary data to the Actor for registering reminder later on during test.
18 | */
19 | public class MyObject {
20 |
21 | private String name;
22 |
23 | private int age;
24 |
25 | public String getName() {
26 | return name;
27 | }
28 |
29 | public void setName(String name) {
30 | this.name = name;
31 | }
32 |
33 | public int getAge() {
34 | return age;
35 | }
36 |
37 | public void setAge(int age) {
38 | this.age = age;
39 | }
40 |
41 | public String toString() {
42 | return this.name + "," + this.age;
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/sdk-tests/src/test/java/io/dapr/it/actors/app/TestApplication.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021 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.it.actors.app;
15 |
16 | import org.springframework.boot.SpringApplication;
17 | import org.springframework.boot.autoconfigure.SpringBootApplication;
18 |
19 | /**
20 | * Dapr's HTTP callback implementation via SpringBoot.
21 | */
22 | @SpringBootApplication
23 | public class TestApplication {
24 | /**
25 | * Starts Dapr's callback in a given port.
26 | * @param port Port to listen to.
27 | */
28 | public static void start(long port) {
29 | SpringApplication.run(TestApplication.class, String.format("--server.port=%d", port));
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/sdk-tests/src/test/java/io/dapr/it/actors/services/springboot/DaprApplication.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021 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.it.actors.services.springboot;
15 |
16 | import org.springframework.boot.SpringApplication;
17 | import org.springframework.boot.autoconfigure.SpringBootApplication;
18 |
19 | /**
20 | * Dapr's HTTP callback implementation via SpringBoot.
21 | */
22 | @SpringBootApplication
23 | public class DaprApplication {
24 |
25 | /**
26 | * Starts Dapr's callback in a given port.
27 | *
28 | * @param port Port to listen to.
29 | */
30 | public static void start(long port) {
31 | SpringApplication app = new SpringApplication(DaprApplication.class);
32 | app.run(String.format("--server.port=%d", port));
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/sdk-tests/src/test/java/io/dapr/it/actors/services/springboot/DemoActor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021 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.it.actors.services.springboot;
15 |
16 | import io.dapr.actors.ActorType;
17 |
18 | import java.util.List;
19 |
20 | @ActorType(name = "DemoActorTest")
21 | public interface DemoActor {
22 | String say(String something);
23 |
24 | List retrieveActiveActors();
25 |
26 | void writeMessage(String something);
27 |
28 | String readMessage();
29 | }
30 |
--------------------------------------------------------------------------------
/sdk-tests/src/test/java/io/dapr/it/actors/services/springboot/StatefulActor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021 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.it.actors.services.springboot;
15 |
16 | public interface StatefulActor {
17 |
18 | void writeMessage(String something);
19 |
20 | String readMessage();
21 |
22 | void writeName(String something);
23 |
24 | String readName();
25 |
26 | void writeData(MyData something);
27 |
28 | MyData readData();
29 |
30 | void writeBytes(byte[] something);
31 |
32 | byte[] readBytes();
33 |
34 | class MyData {
35 | public String value;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/sdk-tests/src/test/java/io/dapr/it/api/ApiIT.java:
--------------------------------------------------------------------------------
1 | package io.dapr.it.api;
2 |
3 | import io.dapr.client.DaprClient;
4 | import io.dapr.client.DaprClientBuilder;
5 | import io.dapr.it.BaseIT;
6 | import io.dapr.it.DaprRun;
7 | import org.junit.jupiter.api.Test;
8 | import org.slf4j.Logger;
9 | import org.slf4j.LoggerFactory;
10 |
11 | public class ApiIT extends BaseIT {
12 |
13 | private static final Logger logger = LoggerFactory.getLogger(ApiIT.class);
14 | private static final int DEFAULT_TIMEOUT = 60000;
15 |
16 | @Test
17 | public void testShutdownAPI() throws Exception {
18 | DaprRun run = startDaprApp(this.getClass().getSimpleName(), DEFAULT_TIMEOUT);
19 |
20 | // TODO(artursouza): change this to wait for the sidecar to be healthy (new method needed in DaprClient).
21 | Thread.sleep(3000);
22 | try (DaprClient client = run.newDaprClientBuilder().build()) {
23 | logger.info("Sending shutdown request.");
24 | client.shutdown().block();
25 |
26 | logger.info("Ensuring dapr has stopped.");
27 | run.checkRunState(DEFAULT_TIMEOUT, false);
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/sdk-tests/src/test/java/io/dapr/it/methodinvoke/http/Person.java:
--------------------------------------------------------------------------------
1 | package io.dapr.it.methodinvoke.http;
2 |
3 | import java.util.Date;
4 |
5 | public class Person {
6 |
7 | private int id;
8 | private String name;
9 | private String lastName;
10 | private Date birthDate;
11 |
12 | @Override
13 | public String toString() {
14 | return "Person{" +
15 | "id=" + id +
16 | ", name='" + name + '\'' +
17 | ", lastName='" + lastName + '\'' +
18 | ", birthDate=" + birthDate +
19 | '}';
20 | }
21 |
22 | public int getId() {
23 | return id;
24 | }
25 |
26 | public void setId(int id) {
27 | this.id = id;
28 | }
29 |
30 | public String getName() {
31 | return name;
32 | }
33 |
34 | public void setName(String name) {
35 | this.name = name;
36 | }
37 |
38 | public String getLastName() {
39 | return lastName;
40 | }
41 |
42 | public void setLastName(String lastName) {
43 | this.lastName = lastName;
44 | }
45 |
46 | public Date getBirthDate() {
47 | return birthDate;
48 | }
49 |
50 | public void setBirthDate(Date birthDate) {
51 | this.birthDate = birthDate;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/sdk-tests/src/test/java/io/dapr/it/spring/data/CustomMySQLContainer.java:
--------------------------------------------------------------------------------
1 | package io.dapr.it.spring.data;
2 |
3 | import org.testcontainers.containers.MySQLContainer;
4 | import org.testcontainers.utility.DockerImageName;
5 |
6 | public class CustomMySQLContainer> extends MySQLContainer {
7 |
8 | public CustomMySQLContainer(String dockerImageName) {
9 | super(DockerImageName.parse(dockerImageName));
10 | }
11 |
12 | protected void waitUntilContainerStarted() {
13 | this.getWaitStrategy().waitUntilReady(this);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/sdk-tests/src/test/java/io/dapr/it/spring/data/DaprSpringDataConstants.java:
--------------------------------------------------------------------------------
1 | package io.dapr.it.spring.data;
2 |
3 | public class DaprSpringDataConstants {
4 | private DaprSpringDataConstants() {
5 | }
6 |
7 | public static final String STATE_STORE_NAME = "kvstore";
8 | public static final String BINDING_NAME = "kvbinding";
9 | }
10 |
--------------------------------------------------------------------------------
/sdk-tests/src/test/java/io/dapr/it/spring/data/TestDaprSpringDataConfiguration.java:
--------------------------------------------------------------------------------
1 | package io.dapr.it.spring.data;
2 |
3 | import com.fasterxml.jackson.databind.ObjectMapper;
4 | import io.dapr.client.DaprClient;
5 | import io.dapr.spring.boot.autoconfigure.client.DaprClientAutoConfiguration;
6 | import io.dapr.spring.data.DaprKeyValueAdapterResolver;
7 | import io.dapr.spring.data.DaprKeyValueTemplate;
8 | import io.dapr.spring.data.KeyValueAdapterResolver;
9 | import io.dapr.spring.data.repository.config.EnableDaprRepositories;
10 | import org.springframework.context.annotation.Bean;
11 | import org.springframework.context.annotation.Configuration;
12 | import org.springframework.context.annotation.Import;
13 |
14 | @Configuration
15 | @EnableDaprRepositories
16 | @Import(DaprClientAutoConfiguration.class)
17 | public class TestDaprSpringDataConfiguration {
18 | @Bean
19 | public ObjectMapper mapper() {
20 | return new ObjectMapper();
21 | }
22 |
23 |
24 | @Bean
25 | public KeyValueAdapterResolver keyValueAdapterResolver(DaprClient daprClient, ObjectMapper mapper) {
26 | String storeName = DaprSpringDataConstants.STATE_STORE_NAME;
27 | String bindingName = DaprSpringDataConstants.BINDING_NAME;
28 |
29 | return new DaprKeyValueAdapterResolver(daprClient, mapper, storeName, bindingName);
30 | }
31 |
32 | @Bean
33 | public DaprKeyValueTemplate daprKeyValueTemplate(KeyValueAdapterResolver keyValueAdapterResolver) {
34 | return new DaprKeyValueTemplate(keyValueAdapterResolver);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/sdk-tests/src/test/java/io/dapr/it/spring/data/TestTypeRepository.java:
--------------------------------------------------------------------------------
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.it.spring.data;
15 |
16 | import org.springframework.data.repository.CrudRepository;
17 | import org.springframework.stereotype.Repository;
18 |
19 | import java.util.List;
20 |
21 | @Repository
22 | public interface TestTypeRepository extends CrudRepository {
23 | List findByContent(String content);
24 | }
25 |
--------------------------------------------------------------------------------
/sdk-tests/src/test/java/io/dapr/it/testcontainers/ContainerConstants.java:
--------------------------------------------------------------------------------
1 | package io.dapr.it.testcontainers;
2 |
3 | import io.dapr.testcontainers.DaprContainerConstants;
4 |
5 | public interface ContainerConstants {
6 | String DAPR_RUNTIME_IMAGE_TAG = DaprContainerConstants.DAPR_RUNTIME_IMAGE_TAG;
7 | String DAPR_PLACEMENT_IMAGE_TAG = DaprContainerConstants.DAPR_PLACEMENT_IMAGE_TAG;
8 | String DAPR_SCHEDULER_IMAGE_TAG = DaprContainerConstants.DAPR_SCHEDULER_IMAGE_TAG;
9 | String TOXI_PROXY_IMAGE_TAG = "ghcr.io/shopify/toxiproxy:2.5.0";
10 | }
11 |
--------------------------------------------------------------------------------
/sdk-tests/src/test/java/io/dapr/it/testcontainers/DaprClientFactory.java:
--------------------------------------------------------------------------------
1 | package io.dapr.it.testcontainers;
2 |
3 | import io.dapr.client.DaprClientBuilder;
4 | import io.dapr.config.Properties;
5 | import io.dapr.testcontainers.DaprContainer;
6 |
7 | public interface DaprClientFactory {
8 |
9 | static DaprClientBuilder createDaprClientBuilder(DaprContainer daprContainer) {
10 | return new DaprClientBuilder()
11 | .withPropertyOverride(Properties.HTTP_ENDPOINT, "http://localhost:" + daprContainer.getHttpPort())
12 | .withPropertyOverride(Properties.GRPC_ENDPOINT, "http://localhost:" + daprContainer.getGrpcPort());
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/sdk-tests/src/test/java/io/dapr/it/testcontainers/actors/TestActor.java:
--------------------------------------------------------------------------------
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.it.testcontainers.actors;
15 | import io.dapr.actors.ActorMethod;
16 | import io.dapr.actors.ActorType;
17 |
18 | @ActorType(name = "TestActor")
19 | public interface TestActor {
20 | @ActorMethod(name = "echo_message")
21 | String echo(String message);
22 | }
23 |
--------------------------------------------------------------------------------
/sdk-tests/src/test/java/io/dapr/it/testcontainers/actors/TestActorImpl.java:
--------------------------------------------------------------------------------
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.it.testcontainers.actors;
15 |
16 | import io.dapr.actors.ActorId;
17 | import io.dapr.actors.runtime.AbstractActor;
18 | import io.dapr.actors.runtime.ActorRuntimeContext;
19 |
20 | public class TestActorImpl extends AbstractActor implements TestActor {
21 | public TestActorImpl(ActorRuntimeContext runtimeContext, ActorId id) {
22 | super(runtimeContext, id);
23 | }
24 |
25 | @Override
26 | public String echo(String message) {
27 | return message;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/sdk-tests/src/test/java/io/dapr/it/testcontainers/actors/TestActorsApplication.java:
--------------------------------------------------------------------------------
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.it.testcontainers.actors;
15 |
16 | import org.springframework.boot.SpringApplication;
17 | import org.springframework.boot.autoconfigure.SpringBootApplication;
18 | import org.springframework.web.bind.annotation.GetMapping;
19 | import org.springframework.web.bind.annotation.RestController;
20 |
21 | @SpringBootApplication
22 | @RestController
23 | public class TestActorsApplication {
24 |
25 | public static void main(String[] args) {
26 | SpringApplication.run(TestActorsApplication.class, args);
27 | }
28 |
29 | //Mocking the actuator health endpoint for the sidecar health check
30 | @GetMapping("/actuator/health")
31 | public String health(){
32 | return "OK";
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/sdk-tests/src/test/java/io/dapr/it/testcontainers/conversations/TestConversationApplication.java:
--------------------------------------------------------------------------------
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.it.testcontainers.conversations;
15 |
16 | import org.springframework.boot.SpringApplication;
17 | import org.springframework.boot.autoconfigure.SpringBootApplication;
18 |
19 | @SpringBootApplication
20 | public class TestConversationApplication {
21 |
22 | public static void main(String[] args) {
23 | SpringApplication.run(TestConversationApplication.class, args);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/sdk-tests/src/test/java/io/dapr/it/testcontainers/jobs/TestJobsApplication.java:
--------------------------------------------------------------------------------
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.it.testcontainers.jobs;
15 |
16 | import org.springframework.boot.SpringApplication;
17 | import org.springframework.boot.autoconfigure.SpringBootApplication;
18 |
19 | @SpringBootApplication
20 | public class TestJobsApplication {
21 |
22 | public static void main(String[] args) {
23 | SpringApplication.run(TestJobsApplication.class, args);
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/sdk-tests/src/test/java/io/dapr/it/testcontainers/pubsub/http/TestPubSubApplication.java:
--------------------------------------------------------------------------------
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 | package io.dapr.it.testcontainers.pubsub.http;
14 |
15 | import org.springframework.boot.SpringApplication;
16 | import org.springframework.boot.autoconfigure.SpringBootApplication;
17 |
18 | @SpringBootApplication
19 | public class TestPubSubApplication {
20 | public static void main(String[] args) {
21 | SpringApplication.run(TestPubSubApplication.class, args);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/sdk-tests/src/test/java/io/dapr/it/testcontainers/workflows/FirstActivity.java:
--------------------------------------------------------------------------------
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.it.testcontainers.workflows;
15 |
16 | import io.dapr.workflows.WorkflowActivity;
17 | import io.dapr.workflows.WorkflowActivityContext;
18 |
19 | public class FirstActivity implements WorkflowActivity {
20 |
21 | @Override
22 | public Object run(WorkflowActivityContext ctx) {
23 | TestWorkflowPayload workflowPayload = ctx.getInput(TestWorkflowPayload.class);
24 | workflowPayload.getPayloads().add("First Activity");
25 | return workflowPayload;
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/sdk-tests/src/test/java/io/dapr/it/testcontainers/workflows/SecondActivity.java:
--------------------------------------------------------------------------------
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.it.testcontainers.workflows;
15 |
16 | import io.dapr.workflows.WorkflowActivity;
17 | import io.dapr.workflows.WorkflowActivityContext;
18 |
19 | public class SecondActivity implements WorkflowActivity {
20 |
21 | @Override
22 | public Object run(WorkflowActivityContext ctx) {
23 | TestWorkflowPayload workflowPayload = ctx.getInput(TestWorkflowPayload.class);
24 | workflowPayload.getPayloads().add("Second Activity");
25 | return workflowPayload;
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/sdk-tests/src/test/java/io/dapr/it/testcontainers/workflows/TestWorkflowsApplication.java:
--------------------------------------------------------------------------------
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.it.testcontainers.workflows;
15 |
16 | import org.springframework.boot.SpringApplication;
17 | import org.springframework.boot.autoconfigure.SpringBootApplication;
18 |
19 | @SpringBootApplication
20 | public class TestWorkflowsApplication {
21 |
22 | public static void main(String[] args) {
23 | SpringApplication.run(TestWorkflowsApplication.class, args);
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/sdk-tests/src/test/java/io/dapr/it/tracing/http/Controller.java:
--------------------------------------------------------------------------------
1 | package io.dapr.it.tracing.http;
2 |
3 | import org.springframework.web.bind.annotation.GetMapping;
4 | import org.springframework.web.bind.annotation.PostMapping;
5 | import org.springframework.web.bind.annotation.RequestBody;
6 | import org.springframework.web.bind.annotation.RestController;
7 |
8 | /**
9 | * SpringBoot Controller to handle input binding.
10 | */
11 | @RestController
12 | public class Controller {
13 |
14 | @PostMapping(path = "/sleep")
15 | public void sleep(@RequestBody int seconds) throws InterruptedException {
16 | if (seconds < 0) {
17 | throw new IllegalArgumentException("Sleep time cannot be negative.");
18 | }
19 | Thread.sleep(seconds * 1000);
20 | }
21 |
22 | @GetMapping(path = "/health")
23 | public void health() {
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/sdk-tests/src/test/java/io/dapr/it/tracing/http/OpenTelemetryInterceptorConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021 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.it.tracing.http;
15 |
16 | import org.springframework.beans.factory.annotation.Autowired;
17 | import org.springframework.stereotype.Component;
18 | import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
19 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
20 |
21 | @Component
22 | public class OpenTelemetryInterceptorConfig extends WebMvcConfigurationSupport {
23 |
24 | @Autowired
25 | OpenTelemetryInterceptor interceptor;
26 |
27 | @Override
28 | public void addInterceptors(InterceptorRegistry registry) {
29 | registry.addInterceptor(interceptor);
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/sdk-tests/src/test/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/sdk-tests/src/test/resources/query.json:
--------------------------------------------------------------------------------
1 | {
2 | "filter": {
3 | "EQ": {
4 | "content": "test"
5 | }
6 | },
7 | "page": {
8 | "limit": 0,
9 | "token": "0"
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/sdk-workflows/spotbugs-exclude.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/sdk-workflows/src/main/java/io/dapr/workflows/Workflow.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 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.workflows;
15 |
16 | /**
17 | * Common interface for workflow implementations.
18 | */
19 | public interface Workflow {
20 | /**
21 | * Executes the workflow logic.
22 | *
23 | * @return A WorkflowStub.
24 | */
25 | WorkflowStub create();
26 |
27 | /**
28 | * Executes the workflow logic.
29 | *
30 | * @param ctx provides access to methods for scheduling durable tasks and
31 | * getting information about the current
32 | * workflow instance.
33 | */
34 | default void run(WorkflowContext ctx) {
35 | WorkflowStub stub = this.create();
36 |
37 | stub.run(ctx);
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/sdk-workflows/src/main/java/io/dapr/workflows/WorkflowActivityContext.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 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.workflows;
15 |
16 | public interface WorkflowActivityContext {
17 |
18 | String getName();
19 |
20 | T getInput(Class targetType);
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/sdk-workflows/src/main/java/io/dapr/workflows/WorkflowStub.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 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.workflows;
15 |
16 | @FunctionalInterface
17 | public interface WorkflowStub {
18 |
19 | void run(WorkflowContext ctx);
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/sdk-workflows/src/main/java/io/dapr/workflows/WorkflowTaskOptions.java:
--------------------------------------------------------------------------------
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.workflows;
15 |
16 | public class WorkflowTaskOptions {
17 |
18 | private final WorkflowTaskRetryPolicy retryPolicy;
19 | private final WorkflowTaskRetryHandler retryHandler;
20 |
21 | public WorkflowTaskOptions(WorkflowTaskRetryPolicy retryPolicy, WorkflowTaskRetryHandler retryHandler) {
22 | this.retryPolicy = retryPolicy;
23 | this.retryHandler = retryHandler;
24 | }
25 |
26 | public WorkflowTaskOptions(WorkflowTaskRetryPolicy retryPolicy) {
27 | this(retryPolicy, null);
28 | }
29 |
30 | public WorkflowTaskOptions(WorkflowTaskRetryHandler retryHandler) {
31 | this(null, retryHandler);
32 | }
33 |
34 | public WorkflowTaskRetryPolicy getRetryPolicy() {
35 | return retryPolicy;
36 | }
37 |
38 | public WorkflowTaskRetryHandler getRetryHandler() {
39 | return retryHandler;
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/sdk-workflows/src/main/java/io/dapr/workflows/WorkflowTaskRetryHandler.java:
--------------------------------------------------------------------------------
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.workflows;
15 |
16 | public interface WorkflowTaskRetryHandler {
17 |
18 | /**
19 | * Invokes retry handler logic. Return value indicates whether to continue retrying.
20 | *
21 | * @param retryContext The context of the retry
22 | * @return {@code true} to continue retrying or {@code false} to stop retrying.
23 | */
24 | boolean handle(WorkflowTaskRetryContext retryContext);
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/sdk-workflows/src/main/java/io/dapr/workflows/runtime/WorkflowInstanceWrapper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 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.workflows.runtime;
15 |
16 | import io.dapr.durabletask.TaskOrchestration;
17 | import io.dapr.durabletask.TaskOrchestrationFactory;
18 | import io.dapr.workflows.Workflow;
19 |
20 | /**
21 | * Wrapper for Durable Task Framework orchestration factory.
22 | */
23 | class WorkflowInstanceWrapper implements TaskOrchestrationFactory {
24 | private final T workflow;
25 | private final String name;
26 |
27 | public WorkflowInstanceWrapper(T instance) {
28 | this.name = instance.getClass().getCanonicalName();
29 | this.workflow = instance;
30 | }
31 |
32 | @Override
33 | public String getName() {
34 | return name;
35 | }
36 |
37 | @Override
38 | public TaskOrchestration create() {
39 | return ctx -> workflow.run(new DefaultWorkflowContext(ctx));
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/sdk-workflows/src/test/java/io/dapr/workflows/client/NewWorkflowOptionsTest.java:
--------------------------------------------------------------------------------
1 | package io.dapr.workflows.client;
2 |
3 | import org.junit.jupiter.api.Assertions;
4 | import org.junit.jupiter.api.Test;
5 |
6 | import java.time.Instant;
7 |
8 | public class NewWorkflowOptionsTest {
9 |
10 | @Test
11 | void testNewWorkflowOption() {
12 | NewWorkflowOptions workflowOption = new NewWorkflowOptions();
13 | String version = "v1";
14 | String instanceId = "123";
15 | Object input = new Object();
16 | Instant startTime = Instant.now();
17 |
18 | workflowOption.setVersion(version)
19 | .setInstanceId(instanceId)
20 | .setInput(input)
21 | .setStartTime(startTime);
22 |
23 | Assertions.assertEquals(version, workflowOption.getVersion());
24 | Assertions.assertEquals(instanceId, workflowOption.getInstanceId());
25 | Assertions.assertEquals(input, workflowOption.getInput());
26 | Assertions.assertEquals(startTime, workflowOption.getStartTime());
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/sdk/spotbugs-exclude.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/sdk/src/main/java/io/dapr/Rule.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 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;
15 |
16 | import java.lang.annotation.Documented;
17 | import java.lang.annotation.ElementType;
18 | import java.lang.annotation.Retention;
19 | import java.lang.annotation.RetentionPolicy;
20 | import java.lang.annotation.Target;
21 |
22 | @Documented
23 | @Target(ElementType.ANNOTATION_TYPE)
24 | @Retention(RetentionPolicy.RUNTIME)
25 | public @interface Rule {
26 | /**
27 | * The Common Expression Language (CEL) expression to use
28 | * to match the incoming cloud event.
29 | * Examples.
30 | * @return the CEL expression.
31 | */
32 | String match();
33 |
34 | /**
35 | * Priority of the rule used for ordering. Lowest numbers have higher priority.
36 | * @return the rule's priority.
37 | */
38 | int priority();
39 | }
40 |
--------------------------------------------------------------------------------
/sdk/src/main/java/io/dapr/client/Headers.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021 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.client;
15 |
16 | /**
17 | * Common headers for GRPC and HTTP communication.
18 | */
19 | public final class Headers {
20 |
21 | /**
22 | * OpenCensus's metadata for GRPC.
23 | */
24 | public static final String GRPC_TRACE_BIN = "grpc-trace-bin";
25 |
26 | /**
27 | * Token for authentication from Application to Dapr runtime.
28 | */
29 | public static final String DAPR_API_TOKEN = "dapr-api-token";
30 |
31 | /**
32 | * Header for Api Logging User-Agent.
33 | */
34 | public static final String DAPR_USER_AGENT = "User-Agent";
35 | }
36 |
--------------------------------------------------------------------------------
/sdk/src/main/java/io/dapr/client/domain/ActorMetadata.java:
--------------------------------------------------------------------------------
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.client.domain;
15 |
16 | /**
17 | * ActorMetadata describes a registered Dapr Actor.
18 | */
19 | public final class ActorMetadata {
20 | private final String type;
21 | private final int count;
22 |
23 | /**
24 | * Constructor for a ActorMetadata.
25 | *
26 | * @param type of the actor
27 | * @param count number of actors of a particular type
28 | */
29 | public ActorMetadata(String type, int count) {
30 | this.type = type;
31 | this.count = count;
32 | }
33 |
34 | public String getType() {
35 | return type;
36 | }
37 |
38 | public int getCount() {
39 | return count;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/sdk/src/main/java/io/dapr/client/domain/BulkSubscribeAppResponseStatus.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 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.client.domain;
15 |
16 | /**
17 | * Status of the message handled in bulk subscribe handler.
18 | */
19 | public enum BulkSubscribeAppResponseStatus {
20 | SUCCESS,
21 | RETRY,
22 | DROP
23 | }
24 |
--------------------------------------------------------------------------------
/sdk/src/main/java/io/dapr/client/domain/DeleteJobRequest.java:
--------------------------------------------------------------------------------
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.client.domain;
15 |
16 | /**
17 | * Represents a request to schedule a job in Dapr.
18 | */
19 | public class DeleteJobRequest {
20 | private final String name;
21 |
22 | /**
23 | * Constructor to create Delete Job Request.
24 | *
25 | * @param name of the job to delete.
26 | */
27 | public DeleteJobRequest(String name) {
28 | this.name = name;
29 | }
30 |
31 | /**
32 | * Gets the name of the job.
33 | *
34 | * @return The job name.
35 | */
36 | public String getName() {
37 | return name;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/sdk/src/main/java/io/dapr/client/domain/GetJobRequest.java:
--------------------------------------------------------------------------------
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.client.domain;
15 |
16 | /**
17 | * Represents a request to schedule a job in Dapr.
18 | */
19 | public class GetJobRequest {
20 | private final String name;
21 |
22 | /**
23 | * Constructor to create Get Job Request.
24 | *
25 | * @param name of the job to fetch..
26 | */
27 | public GetJobRequest(String name) {
28 | this.name = name;
29 | }
30 |
31 | /**
32 | * Gets the name of the job.
33 | *
34 | * @return The job name.
35 | */
36 | public String getName() {
37 | return name;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/sdk/src/main/java/io/dapr/client/domain/HttpEndpointMetadata.java:
--------------------------------------------------------------------------------
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.client.domain;
15 |
16 | /**
17 | * HttpEndpointMetadata describes a registered Dapr HTTP endpoint.
18 | */
19 | public final class HttpEndpointMetadata {
20 |
21 | private final String name;
22 |
23 | /**
24 | * Constructor for a HttpEndpointMetadata.
25 | *
26 | * @param name of the HTTP endpoint
27 | */
28 | public HttpEndpointMetadata(String name) {
29 | this.name = name;
30 | }
31 |
32 | public String getName() {
33 | return name;
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/sdk/src/main/java/io/dapr/client/domain/Metadata.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021 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.client.domain;
15 |
16 | /**
17 | * Enumerates commonly used metadata attributes.
18 | */
19 | public final class Metadata {
20 |
21 | public static final String CONTENT_TYPE = "content-type";
22 |
23 | public static final String TTL_IN_SECONDS = "ttlInSeconds";
24 |
25 | private Metadata() {
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/sdk/src/main/java/io/dapr/client/domain/RuleMetadata.java:
--------------------------------------------------------------------------------
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.client.domain;
15 |
16 | /**
17 | * RuleMetadata describes the Subscription Rule's Metadata.
18 | */
19 | public final class RuleMetadata {
20 |
21 | private final String match;
22 | private final String path;
23 |
24 | /**
25 | * Constructor for a RuleMetadata.
26 | *
27 | * @param match CEL expression to match the message
28 | * @param path path to route the message
29 | */
30 | public RuleMetadata(String match, String path) {
31 | this.match = match;
32 | this.path = path;
33 | }
34 |
35 | public String getMatch() {
36 | return match;
37 | }
38 |
39 | public String getPath() {
40 | return path;
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/sdk/src/main/java/io/dapr/client/domain/query/Pagination.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021 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.client.domain.query;
15 |
16 | import com.fasterxml.jackson.annotation.JsonInclude;
17 |
18 | @JsonInclude(JsonInclude.Include.NON_EMPTY)
19 | public class Pagination {
20 | private int limit;
21 | private String token;
22 |
23 | Pagination() {
24 | // For JSON
25 | }
26 |
27 | public Pagination(int limit, String token) {
28 | this.limit = limit;
29 | this.token = token;
30 | }
31 |
32 | public int getLimit() {
33 | return limit;
34 | }
35 |
36 | public String getToken() {
37 | return token;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/sdk/src/main/java/io/dapr/client/resiliency/ResiliencyOptions.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 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.client.resiliency;
15 |
16 | import java.time.Duration;
17 |
18 | /**
19 | * Resiliency policy for SDK communication to Dapr API.
20 | */
21 | public final class ResiliencyOptions {
22 |
23 | private Duration timeout;
24 |
25 | private Integer maxRetries;
26 |
27 | public Duration getTimeout() {
28 | return timeout;
29 | }
30 |
31 | public ResiliencyOptions setTimeout(Duration timeout) {
32 | this.timeout = timeout;
33 | return this;
34 | }
35 |
36 | public Integer getMaxRetries() {
37 | return maxRetries;
38 | }
39 |
40 | public ResiliencyOptions setMaxRetries(Integer maxRetries) {
41 | this.maxRetries = maxRetries;
42 | return this;
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/sdk/src/main/java/io/dapr/config/BooleanProperty.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021 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.config;
15 |
16 | /**
17 | * Boolean configuration property.
18 | */
19 | public class BooleanProperty extends Property {
20 |
21 | /**
22 | * {@inheritDoc}
23 | */
24 | BooleanProperty(String name, String envName, Boolean defaultValue) {
25 | super(name, envName, defaultValue);
26 | }
27 |
28 | /**
29 | * {@inheritDoc}
30 | */
31 | @Override
32 | protected Boolean parse(String value) {
33 | return Boolean.valueOf(value);
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/sdk/src/main/java/io/dapr/config/GenericProperty.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021 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.config;
15 |
16 | import java.util.function.Function;
17 |
18 | /**
19 | * Configuration property for any type.
20 | */
21 | public class GenericProperty extends Property {
22 |
23 | private final Function parser;
24 |
25 | /**
26 | * {@inheritDoc}
27 | */
28 | GenericProperty(String name, String envName, T defaultValue, Function parser) {
29 | super(name, envName, defaultValue);
30 | this.parser = parser;
31 | }
32 |
33 | /**
34 | * {@inheritDoc}
35 | */
36 | @Override
37 | protected T parse(String value) {
38 | return parser.apply(value);
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/sdk/src/main/java/io/dapr/config/IntegerProperty.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021 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.config;
15 |
16 | /**
17 | * Integer configuration property.
18 | */
19 | public class IntegerProperty extends Property {
20 |
21 | /**
22 | * {@inheritDoc}
23 | */
24 | IntegerProperty(String name, String envName, Integer defaultValue) {
25 | super(name, envName, defaultValue);
26 | }
27 |
28 | /**
29 | * {@inheritDoc}
30 | */
31 | @Override
32 | protected Integer parse(String value) {
33 | return Integer.valueOf(value);
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/sdk/src/main/java/io/dapr/config/MillisecondsDurationProperty.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2023 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.config;
15 |
16 | import java.time.Duration;
17 |
18 | /**
19 | * Integer configuration property.
20 | */
21 | public class MillisecondsDurationProperty extends Property {
22 |
23 | /**
24 | * {@inheritDoc}
25 | */
26 | MillisecondsDurationProperty(String name, String envName, Duration defaultValue) {
27 | super(name, envName, defaultValue);
28 | }
29 |
30 | /**
31 | * {@inheritDoc}
32 | */
33 | @Override
34 | protected Duration parse(String value) {
35 | long longValue = Long.parseLong(value);
36 | return Duration.ofMillis(longValue);
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/sdk/src/main/java/io/dapr/config/SecondsDurationProperty.java:
--------------------------------------------------------------------------------
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.config;
15 |
16 | import java.time.Duration;
17 |
18 | /**
19 | * Integer configuration property.
20 | */
21 | public class SecondsDurationProperty extends Property {
22 |
23 | /**
24 | * {@inheritDoc}
25 | */
26 | SecondsDurationProperty(String name, String envName, Duration defaultValue) {
27 | super(name, envName, defaultValue);
28 | }
29 |
30 | /**
31 | * {@inheritDoc}
32 | */
33 | @Override
34 | protected Duration parse(String value) {
35 | long longValue = Long.parseLong(value);
36 | return Duration.ofSeconds(longValue);
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/sdk/src/main/java/io/dapr/config/StringProperty.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021 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.config;
15 |
16 | /**
17 | * String configuration property.
18 | */
19 | public class StringProperty extends Property {
20 |
21 | /**
22 | * {@inheritDoc}
23 | */
24 | StringProperty(String name, String envName, String defaultValue) {
25 | super(name, envName, defaultValue);
26 | }
27 |
28 | /**
29 | * {@inheritDoc}
30 | */
31 | @Override
32 | protected String parse(String value) {
33 | return value;
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/sdk/src/main/java/io/dapr/serializer/CustomizableObjectSerializer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021 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.serializer;
15 |
16 | import com.fasterxml.jackson.databind.ObjectMapper;
17 | import io.dapr.client.ObjectSerializer;
18 |
19 | public class CustomizableObjectSerializer extends ObjectSerializer implements DaprObjectSerializer {
20 |
21 | private final ObjectMapper objectMapper;
22 |
23 | public CustomizableObjectSerializer(ObjectMapper objectMapper) {
24 | this.objectMapper = objectMapper;
25 | }
26 |
27 | @Override
28 | public ObjectMapper getObjectMapper() {
29 | return objectMapper;
30 | }
31 |
32 | @Override
33 | public String getContentType() {
34 | return "application/json";
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/sdk/src/main/resources/sdk_version.properties:
--------------------------------------------------------------------------------
1 | sdk_version=${project.version}
2 |
--------------------------------------------------------------------------------
/sdk/src/test/java/io/dapr/client/DaprClientTestBuilder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021 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.client;
15 |
16 | import io.dapr.serializer.DefaultObjectSerializer;
17 |
18 | /**
19 | * Builder for DaprClient used in tests only.
20 | */
21 | public class DaprClientTestBuilder {
22 |
23 | /**
24 | * Builds a DaprClient only for HTTP calls.
25 | * @param client DaprHttp used for http calls (can be mocked or stubbed)
26 | * @return New instance of DaprClient.
27 | */
28 | public static DaprClient buildClientForHttpOnly(DaprHttp client) {
29 | return new DaprClientImpl(null, null, client, new DefaultObjectSerializer(), new DefaultObjectSerializer());
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/sdk/src/test/java/io/dapr/client/domain/DeleteStateRequestTest.java:
--------------------------------------------------------------------------------
1 | package io.dapr.client.domain;
2 |
3 | import org.junit.jupiter.api.Assertions;
4 | import org.junit.jupiter.api.Test;
5 |
6 | import java.util.HashMap;
7 | import java.util.Map;
8 |
9 | import static org.junit.jupiter.api.Assertions.assertNull;
10 |
11 | public class DeleteStateRequestTest {
12 |
13 | private String STORE_NAME = "STORE";
14 | private String KEY = "KEY";
15 |
16 | @Test
17 | public void testSetMetadata(){
18 | DeleteStateRequest request = new DeleteStateRequest(STORE_NAME, KEY);
19 | // Null check
20 | request.setMetadata(null);
21 | assertNull(request.getMetadata());
22 | // Modifiability check
23 | Map metadata = new HashMap<>();
24 | metadata.put("test", "testval");
25 | request.setMetadata(metadata);
26 | Map initial = request.getMetadata();
27 | request.setMetadata(metadata);
28 | Assertions.assertNotSame(request.getMetadata(), initial, "Should not be same map");
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/sdk/src/test/java/io/dapr/client/domain/GetBulkSecretRequestTest.java:
--------------------------------------------------------------------------------
1 | package io.dapr.client.domain;
2 |
3 | import org.junit.jupiter.api.Test;
4 |
5 | import java.util.HashMap;
6 | import java.util.Map;
7 |
8 | import static org.junit.jupiter.api.Assertions.assertNotSame;
9 | import static org.junit.jupiter.api.Assertions.assertNull;
10 |
11 | public class GetBulkSecretRequestTest {
12 |
13 | private String STORE_NAME = "STORE";
14 |
15 | @Test
16 | public void testSetMetadata(){
17 | GetBulkSecretRequest request = new GetBulkSecretRequest(STORE_NAME);
18 | // Null check
19 | request.setMetadata(null);
20 | assertNull(request.getMetadata());
21 | // Modifiability check
22 | Map metadata = new HashMap<>();
23 | metadata.put("test", "testval");
24 | request.setMetadata(metadata);
25 | Map initial = request.getMetadata();
26 | request.setMetadata(metadata);
27 | assertNotSame(request.getMetadata(), initial, "Should not be same map");
28 | }
29 | }
--------------------------------------------------------------------------------
/sdk/src/test/java/io/dapr/client/domain/GetSecretRequestTest.java:
--------------------------------------------------------------------------------
1 | package io.dapr.client.domain;
2 |
3 | import org.junit.jupiter.api.Test;
4 |
5 | import java.util.HashMap;
6 | import java.util.Map;
7 |
8 | import static org.junit.jupiter.api.Assertions.assertNotSame;
9 | import static org.junit.jupiter.api.Assertions.assertNull;
10 |
11 | public class GetSecretRequestTest {
12 |
13 | private String STORE_NAME = "STORE";
14 |
15 | @Test
16 | public void testSetMetadata(){
17 | GetSecretRequest request = new GetSecretRequest(STORE_NAME, "key");
18 | // Null check
19 | request.setMetadata(null);
20 | assertNull(request.getMetadata());
21 | // Modifiability check
22 | Map metadata = new HashMap<>();
23 | metadata.put("test", "testval");
24 | request.setMetadata(metadata);
25 | Map initial = request.getMetadata();
26 | request.setMetadata(metadata);
27 | assertNotSame(request.getMetadata(), initial, "Should not be same map");
28 | }
29 | }
--------------------------------------------------------------------------------
/sdk/src/test/java/io/dapr/client/domain/GetStateRequestTest.java:
--------------------------------------------------------------------------------
1 | package io.dapr.client.domain;
2 |
3 | import org.junit.jupiter.api.Test;
4 |
5 | import java.util.HashMap;
6 | import java.util.Map;
7 |
8 | import static org.junit.jupiter.api.Assertions.assertNotSame;
9 | import static org.junit.jupiter.api.Assertions.assertNull;
10 |
11 | public class GetStateRequestTest {
12 |
13 | private String STORE_NAME = "STORE";
14 |
15 | @Test
16 | public void testSetMetadata(){
17 | GetStateRequest request = new GetStateRequest(STORE_NAME, "key");
18 | // Null check
19 | request.setMetadata(null);
20 | assertNull(request.getMetadata());
21 | // Modifiability check
22 | Map metadata = new HashMap<>();
23 | metadata.put("test", "testval");
24 | request.setMetadata(metadata);
25 | Map initial = request.getMetadata();
26 | request.setMetadata(metadata);
27 | assertNotSame(request.getMetadata(), initial, "Should not be same map");
28 | }
29 | }
--------------------------------------------------------------------------------
/sdk/src/test/java/io/dapr/client/domain/InvokeBindingRequestTest.java:
--------------------------------------------------------------------------------
1 | package io.dapr.client.domain;
2 |
3 | import org.junit.jupiter.api.Test;
4 |
5 | import java.util.HashMap;
6 | import java.util.Map;
7 |
8 | import static org.junit.jupiter.api.Assertions.assertNotSame;
9 | import static org.junit.jupiter.api.Assertions.assertNull;
10 |
11 | public class InvokeBindingRequestTest {
12 |
13 | private String BINDING_NAME = "STORE";
14 |
15 | @Test
16 | public void testSetMetadata(){
17 | InvokeBindingRequest request = new InvokeBindingRequest(BINDING_NAME, "operation");
18 | // Null check
19 | request.setMetadata(null);
20 | assertNull(request.getMetadata());
21 | // Modifiability check
22 | Map metadata = new HashMap<>();
23 | metadata.put("test", "testval");
24 | request.setMetadata(metadata);
25 | Map initial = request.getMetadata();
26 | request.setMetadata(metadata);
27 | assertNotSame(request.getMetadata(), initial, "Should not be same map");
28 | }
29 | }
--------------------------------------------------------------------------------
/sdk/src/test/java/io/dapr/client/domain/PublishEventRequestTest.java:
--------------------------------------------------------------------------------
1 | package io.dapr.client.domain;
2 |
3 | import org.junit.jupiter.api.Test;
4 |
5 | import java.util.HashMap;
6 | import java.util.Map;
7 |
8 | import static org.junit.jupiter.api.Assertions.assertEquals;
9 | import static org.junit.jupiter.api.Assertions.assertNotSame;
10 | import static org.junit.jupiter.api.Assertions.assertNull;
11 |
12 | public class PublishEventRequestTest {
13 |
14 | private String PUBSUB_NAME = "STORE";
15 |
16 | @Test
17 | public void testSetMetadata(){
18 | PublishEventRequest request = new PublishEventRequest(PUBSUB_NAME, "topic", "data");
19 | // Default empty HashMap metadata
20 | assertEquals(0, request.getMetadata().size());
21 | // Null check
22 | request.setMetadata(null);
23 | assertNull(request.getMetadata());
24 | // Modifiability check
25 | Map metadata = new HashMap<>();
26 | metadata.put("test", "testval");
27 | request.setMetadata(metadata);
28 | Map initial = request.getMetadata();
29 | request.setMetadata(metadata);
30 | assertNotSame(request.getMetadata(), initial, "Should not be same map");
31 | }
32 | }
--------------------------------------------------------------------------------
/sdk/src/test/java/io/dapr/runtime/MethodListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021 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.runtime;
15 |
16 | import reactor.core.publisher.Mono;
17 |
18 | import java.util.Map;
19 |
20 | /**
21 | * Processes a given API's method call.
22 | */
23 | public interface MethodListener {
24 |
25 | /**
26 | * Processes a given API's method call.
27 | * @param data Raw input payload.
28 | * @param metadata Header (or metadata).
29 | * @return Raw response or empty.
30 | * @throws Exception Any exception from user code.
31 | */
32 | Mono process(byte[] data, Map metadata) throws Exception;
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/sdk/src/test/java/io/dapr/runtime/TopicListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021 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.runtime;
15 |
16 | import io.dapr.client.domain.CloudEvent;
17 | import reactor.core.publisher.Mono;
18 |
19 | import java.util.Map;
20 |
21 | /**
22 | * Processes a given topic's message delivery.
23 | */
24 | public interface TopicListener {
25 |
26 | /**
27 | * Processes a given topic's message delivery.
28 | * @param message Message event to be processed.
29 | * @param metadata Headers (or metadata).
30 | * @return Empty response.
31 | * @throws Exception Any exception from user code.
32 | */
33 | Mono process(CloudEvent message, Map metadata) throws Exception;
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/sdk/src/test/java/io/dapr/utils/TypeRefTest.java:
--------------------------------------------------------------------------------
1 | package io.dapr.utils;
2 |
3 | import org.junit.jupiter.api.Assertions;
4 | import org.junit.jupiter.api.Test;
5 |
6 | public class TypeRefTest {
7 |
8 | @Test
9 | public void testTypeRefIsPrimitive() {
10 | Assertions.assertTrue(TypeRef.isPrimitive(TypeRef.BOOLEAN), "expected this to be true as boolean is primitive");
11 | Assertions.assertTrue(TypeRef.isPrimitive(TypeRef.SHORT), "expected this to be true as short is primitive");
12 | Assertions.assertTrue(TypeRef.isPrimitive(TypeRef.FLOAT), "expected this to be true as float is primitive");
13 | Assertions.assertTrue(TypeRef.isPrimitive(TypeRef.DOUBLE), "expected this to be true as double is primitive");
14 | Assertions.assertTrue(TypeRef.isPrimitive(TypeRef.INT), "expected this to be true as integer is primitive");
15 |
16 | Assertions.assertFalse(TypeRef.isPrimitive(TypeRef.STRING),
17 | "expected this to be false as string is not primitive");
18 | Assertions.assertFalse(TypeRef.isPrimitive(TypeRef.STRING_ARRAY),
19 | "expected this to be false as string array is not primitive");
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/sdk/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker:
--------------------------------------------------------------------------------
1 | mock-maker-inline
2 |
--------------------------------------------------------------------------------
/settings.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 | ossrh
11 | ${env.OSSRH_USER_TOKEN}
12 | ${env.OSSRH_PWD_TOKEN}
13 |
14 |
15 |
16 |
17 |
18 | true
19 |
20 |
21 | ${env.GPG_KEY}
22 | ${env.GPG_PWD}
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/spring-boot-examples/consumer-app/src/main/java/io/dapr/springboot/examples/consumer/ConsumerApplication.java:
--------------------------------------------------------------------------------
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.springboot.examples.consumer;
15 |
16 | import org.springframework.boot.SpringApplication;
17 | import org.springframework.boot.autoconfigure.SpringBootApplication;
18 |
19 | @SpringBootApplication
20 | public class ConsumerApplication {
21 |
22 | public static void main(String[] args) {
23 | SpringApplication.run(ConsumerApplication.class, args);
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/spring-boot-examples/consumer-app/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | dapr.pubsub.name=pubsub
2 | spring.application.name=consumer-app
3 | server.port=8081
4 |
5 |
--------------------------------------------------------------------------------
/spring-boot-examples/consumer-app/src/test/java/io/dapr/springboot/examples/consumer/TestConsumerApplication.java:
--------------------------------------------------------------------------------
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.springboot.examples.consumer;
15 |
16 | import org.springframework.boot.SpringApplication;
17 | import org.springframework.boot.autoconfigure.SpringBootApplication;
18 |
19 |
20 | @SpringBootApplication
21 | public class TestConsumerApplication {
22 |
23 | public static void main(String[] args) {
24 | SpringApplication.from(ConsumerApplication::main)
25 | .with(DaprTestContainersConfig.class)
26 | .run(args);
27 | org.testcontainers.Testcontainers.exposeHostPorts(8081);
28 | }
29 |
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/spring-boot-examples/consumer-app/src/test/resources/application.properties:
--------------------------------------------------------------------------------
1 | dapr.pubsub.name=pubsub
2 | server.port=8081
3 |
--------------------------------------------------------------------------------
/spring-boot-examples/kubernetes/consumer-app.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: v1
2 | kind: Service
3 | metadata:
4 | labels:
5 | app: consumer-app
6 | name: consumer-app
7 | spec:
8 | type: NodePort
9 | ports:
10 | - name: "consumer-app"
11 | port: 8081
12 | targetPort: 8081
13 | nodePort: 31001
14 | selector:
15 | app: consumer-app
16 |
17 | ---
18 |
19 | apiVersion: apps/v1
20 | kind: Deployment
21 | metadata:
22 | labels:
23 | app: consumer-app
24 | name: consumer-app
25 | spec:
26 | replicas: 1
27 | selector:
28 | matchLabels:
29 | app: consumer-app
30 | template:
31 | metadata:
32 | annotations:
33 | dapr.io/app-id: consumer-app
34 | dapr.io/app-port: "8081"
35 | dapr.io/enabled: "true"
36 | labels:
37 | app: consumer-app
38 | spec:
39 | containers:
40 | - image: localhost:5001/sb-consumer-app
41 | name: consumer-app
42 | imagePullPolicy: Always
43 | ports:
44 | - containerPort: 8081
45 | name: consumer-app
46 |
--------------------------------------------------------------------------------
/spring-boot-examples/kubernetes/kvbinding.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: dapr.io/v1alpha1
2 | kind: Component
3 | metadata:
4 | name: kvbinding
5 | spec:
6 | type: bindings.postgresql
7 | version: v1
8 | metadata:
9 | - name: connectionString
10 | value: host=postgresql.default.svc.cluster.local user=postgres password=password port=5432 connect_timeout=10
11 | database=dapr
12 | scopes:
13 | - producer-app
14 |
--------------------------------------------------------------------------------
/spring-boot-examples/kubernetes/kvstore.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: dapr.io/v1alpha1
2 | kind: Component
3 | metadata:
4 | name: kvstore
5 | spec:
6 | type: state.postgresql
7 | version: v1
8 | metadata:
9 | - name: keyPrefix
10 | value: name
11 | - name: actorStateStore
12 | value: 'true'
13 | - name: connectionString
14 | value: host=postgresql.default.svc.cluster.local user=postgres password=password port=5432 connect_timeout=10
15 | database=dapr
16 | scopes:
17 | - producer-app
18 |
--------------------------------------------------------------------------------
/spring-boot-examples/kubernetes/producer-app.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: v1
2 | kind: Service
3 | metadata:
4 | labels:
5 | app: producer-app
6 | name: producer-app
7 | spec:
8 | type: NodePort
9 | ports:
10 | - name: "producer-app"
11 | port: 8080
12 | targetPort: 8080
13 | nodePort: 31000
14 | selector:
15 | app: producer-app
16 |
17 | ---
18 |
19 | apiVersion: apps/v1
20 | kind: Deployment
21 | metadata:
22 | labels:
23 | app: producer-app
24 | name: producer-app
25 | spec:
26 | replicas: 1
27 | selector:
28 | matchLabels:
29 | app: producer-app
30 | template:
31 | metadata:
32 | annotations:
33 | dapr.io/app-id: producer-app
34 | dapr.io/app-port: "8080"
35 | dapr.io/enabled: "true"
36 | labels:
37 | app: producer-app
38 | spec:
39 | containers:
40 | - image: localhost:5001/sb-producer-app
41 | name: producer-app
42 | imagePullPolicy: Always
43 | ports:
44 | - containerPort: 8080
45 | name: producer-app
46 |
--------------------------------------------------------------------------------
/spring-boot-examples/kubernetes/pubsub.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: dapr.io/v1alpha1
2 | kind: Component
3 | metadata:
4 | name: pubsub
5 | spec:
6 | type: pubsub.rabbitmq
7 | version: v1
8 | metadata:
9 | - name: connectionString
10 | value: amqp://guest:guest@rabbitmq.default.svc.cluster.local:5672
11 | - name: user
12 | value: guest
13 | - name: password
14 | value: guest
15 |
--------------------------------------------------------------------------------
/spring-boot-examples/producer-app/src/main/java/io/dapr/springboot/examples/producer/CustomerStore.java:
--------------------------------------------------------------------------------
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.springboot.examples.producer;
15 |
16 | import org.springframework.stereotype.Component;
17 |
18 | import java.util.Collection;
19 | import java.util.HashMap;
20 | import java.util.Map;
21 |
22 | @Component
23 | public class CustomerStore {
24 | private Map customers = new HashMap<>();
25 |
26 | public void addCustomer(Customer customer) {
27 | customers.put(customer.getCustomerName(), customer);
28 | }
29 |
30 | public Customer getCustomer(String customerName) {
31 | return customers.get(customerName);
32 | }
33 |
34 | public Collection getCustomers() {
35 | return customers.values();
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/spring-boot-examples/producer-app/src/main/java/io/dapr/springboot/examples/producer/OrderRepository.java:
--------------------------------------------------------------------------------
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.springboot.examples.producer;
15 |
16 | import org.springframework.data.repository.CrudRepository;
17 |
18 | import java.util.List;
19 |
20 | public interface OrderRepository extends CrudRepository {
21 |
22 | List findByItem(String item);
23 |
24 | List findByAmount(Integer amount);
25 | }
26 |
--------------------------------------------------------------------------------
/spring-boot-examples/producer-app/src/main/java/io/dapr/springboot/examples/producer/ProducerApplication.java:
--------------------------------------------------------------------------------
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.springboot.examples.producer;
15 |
16 | import org.springframework.boot.SpringApplication;
17 | import org.springframework.boot.autoconfigure.SpringBootApplication;
18 |
19 |
20 | @SpringBootApplication
21 | public class ProducerApplication {
22 |
23 | public static void main(String[] args) {
24 | SpringApplication.run(ProducerApplication.class, args);
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/spring-boot-examples/producer-app/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=producer-app
2 | dapr.pubsub.name=pubsub
3 | dapr.statestore.name=kvstore
4 | dapr.statestore.binding=kvbinding
5 |
--------------------------------------------------------------------------------
/spring-boot-examples/producer-app/src/test/java/io/dapr/springboot/examples/producer/TestProducerApplication.java:
--------------------------------------------------------------------------------
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.springboot.examples.producer;
15 |
16 | import org.springframework.boot.SpringApplication;
17 | import org.springframework.boot.autoconfigure.SpringBootApplication;
18 |
19 |
20 | @SpringBootApplication
21 | public class TestProducerApplication {
22 |
23 | public static void main(String[] args) {
24 |
25 | SpringApplication.from(ProducerApplication::main)
26 | .with(DaprTestContainersConfig.class)
27 | .run(args);
28 | org.testcontainers.Testcontainers.exposeHostPorts(8080);
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/spring-boot-examples/producer-app/src/test/resources/application.properties:
--------------------------------------------------------------------------------
1 | dapr.statestore.name=kvstore
2 | dapr.statestore.binding=kvbinding
3 | dapr.pubsub.name=pubsub
4 |
--------------------------------------------------------------------------------
/spring-boot-examples/spotbugs-exclude.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/spring-boot-examples/workflows/body.json:
--------------------------------------------------------------------------------
1 | ["Hello, world!",
2 | "The quick brown fox jumps over the lazy dog.",
3 | "If a tree falls in the forest and there is no one there to hear it, does it make a sound?",
4 | "The greatest glory in living lies not in never falling, but in rising every time we fall.",
5 | "Always remember that you are absolutely unique. Just like everyone else."]
6 |
--------------------------------------------------------------------------------
/spring-boot-examples/workflows/src/main/java/io/dapr/springboot/examples/wfp/WorkflowPatternsApplication.java:
--------------------------------------------------------------------------------
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.springboot.examples.wfp;
15 |
16 | import org.springframework.boot.SpringApplication;
17 | import org.springframework.boot.autoconfigure.SpringBootApplication;
18 |
19 |
20 | @SpringBootApplication
21 | public class WorkflowPatternsApplication {
22 |
23 | public static void main(String[] args) {
24 | SpringApplication.run(WorkflowPatternsApplication.class, args);
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/spring-boot-examples/workflows/src/main/java/io/dapr/springboot/examples/wfp/WorkflowPatternsConfiguration.java:
--------------------------------------------------------------------------------
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.springboot.examples.wfp;
15 |
16 | import com.fasterxml.jackson.databind.ObjectMapper;
17 | import io.dapr.springboot.examples.wfp.continueasnew.CleanUpLog;
18 | import org.springframework.boot.web.client.RestTemplateBuilder;
19 | import org.springframework.context.annotation.Bean;
20 | import org.springframework.context.annotation.Configuration;
21 | import org.springframework.web.client.RestTemplate;
22 |
23 | @Configuration
24 | public class WorkflowPatternsConfiguration {
25 | @Bean
26 | public CleanUpLog cleanUpLog(){
27 | return new CleanUpLog();
28 | }
29 |
30 | @Bean
31 | public RestTemplate restTemplate() {
32 | return new RestTemplateBuilder().build();
33 | }
34 |
35 | @Bean
36 | public ObjectMapper mapper() {
37 | return new ObjectMapper();
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/spring-boot-examples/workflows/src/main/java/io/dapr/springboot/examples/wfp/continueasnew/CleanUpLog.java:
--------------------------------------------------------------------------------
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.springboot.examples.wfp.continueasnew;
15 |
16 | public class CleanUpLog {
17 | private Integer cleanUpTimes = 0;
18 |
19 | public CleanUpLog() {
20 | }
21 |
22 | public void increment() {
23 | this.cleanUpTimes += 1;
24 | }
25 |
26 | public Integer getCleanUpTimes() {
27 | return cleanUpTimes;
28 | }
29 |
30 | public void clearLog(){
31 | this.cleanUpTimes = 0;
32 | }
33 | }
34 |
35 |
--------------------------------------------------------------------------------
/spring-boot-examples/workflows/src/main/java/io/dapr/springboot/examples/wfp/externalevent/Decision.java:
--------------------------------------------------------------------------------
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.springboot.examples.wfp.externalevent;
15 |
16 | public class Decision {
17 | private Boolean approved;
18 |
19 | public Decision() {
20 | }
21 |
22 | public Decision(Boolean approved) {
23 | this.approved = approved;
24 | }
25 |
26 | public Boolean getApproved() {
27 | return approved;
28 | }
29 |
30 | public void setApproved(Boolean approved) {
31 | this.approved = approved;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/spring-boot-examples/workflows/src/main/java/io/dapr/springboot/examples/wfp/fanoutin/Result.java:
--------------------------------------------------------------------------------
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.springboot.examples.wfp.fanoutin;
15 |
16 | public class Result {
17 | private Integer wordCount;
18 |
19 | public Result() {
20 | }
21 |
22 | public Result(Integer wordCount) {
23 | this.wordCount = wordCount;
24 | }
25 |
26 | public Integer getWordCount() {
27 | return wordCount;
28 | }
29 |
30 | public void setWordCount(Integer wordCount) {
31 | this.wordCount = wordCount;
32 | }
33 | };
34 |
--------------------------------------------------------------------------------
/spring-boot-examples/workflows/src/main/java/io/dapr/springboot/examples/wfp/timer/TimerLogService.java:
--------------------------------------------------------------------------------
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 | package io.dapr.springboot.examples.wfp.timer;
14 |
15 | import org.springframework.stereotype.Component;
16 |
17 | import java.util.ArrayList;
18 | import java.util.Date;
19 | import java.util.List;
20 |
21 | @Component
22 | public class TimerLogService {
23 | private final List logDates = new ArrayList<>();
24 |
25 | public void logDate(Date date){
26 | logDates.add(date);
27 | }
28 |
29 | public void clearLog(){
30 | logDates.clear();
31 | }
32 |
33 | public List getLogDates(){
34 | return logDates;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/spring-boot-examples/workflows/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=workflow-patterns-app
2 |
--------------------------------------------------------------------------------
/spring-boot-examples/workflows/src/test/java/io/dapr/springboot/examples/wfp/TestWorkflowPatternsApplication.java:
--------------------------------------------------------------------------------
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.springboot.examples.wfp;
15 |
16 | import org.springframework.boot.SpringApplication;
17 | import org.springframework.boot.autoconfigure.SpringBootApplication;
18 |
19 |
20 | @SpringBootApplication
21 | public class TestWorkflowPatternsApplication {
22 |
23 | public static void main(String[] args) {
24 |
25 | SpringApplication.from(WorkflowPatternsApplication::main)
26 | .with(DaprTestContainersConfig.class)
27 | .run(args);
28 | org.testcontainers.Testcontainers.exposeHostPorts(8080);
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/spring-boot-examples/workflows/src/test/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=workflow-patterns-app
2 |
--------------------------------------------------------------------------------
/testcontainers-dapr/src/main/java/io/dapr/testcontainers/AppHttpPipeline.java:
--------------------------------------------------------------------------------
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 handlers;
21 |
22 | /**
23 | * Creates an AppHttpPipeline.
24 | *
25 | * @param handlers List of handlers for the AppHttpPipeline
26 | */
27 | public AppHttpPipeline(List handlers) {
28 | if (handlers != null) {
29 | this.handlers = Collections.unmodifiableList(handlers);
30 | }
31 | }
32 |
33 | public List getHandlers() {
34 | return handlers;
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/testcontainers-dapr/src/main/java/io/dapr/testcontainers/ConfigurationSettings.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021 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 | // This is a marker interface, so we could get
17 | // a list of all the configuration settings implementations
18 | public interface ConfigurationSettings {
19 | }
20 |
--------------------------------------------------------------------------------
/testcontainers-dapr/src/main/java/io/dapr/testcontainers/DaprContainerConstants.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021 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 interface DaprContainerConstants {
17 | String DAPR_VERSION = "1.15.4";
18 | String DAPR_RUNTIME_IMAGE_TAG = "daprio/daprd:" + DAPR_VERSION;
19 | String DAPR_PLACEMENT_IMAGE_TAG = "daprio/placement:" + DAPR_VERSION;
20 | String DAPR_SCHEDULER_IMAGE_TAG = "daprio/scheduler:" + DAPR_VERSION;
21 | }
22 |
--------------------------------------------------------------------------------
/testcontainers-dapr/src/main/java/io/dapr/testcontainers/DaprLogLevel.java:
--------------------------------------------------------------------------------
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 enum DaprLogLevel {
17 | ERROR,
18 | WARN,
19 | INFO,
20 | DEBUG
21 | }
22 |
--------------------------------------------------------------------------------
/testcontainers-dapr/src/main/java/io/dapr/testcontainers/DaprProtocol.java:
--------------------------------------------------------------------------------
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 enum DaprProtocol {
17 | HTTP("http"),
18 | GRPC("grpc");
19 |
20 | private final String name;
21 |
22 | DaprProtocol(String name) {
23 | this.name = name;
24 | }
25 |
26 | public String getName() {
27 | return name;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/testcontainers-dapr/src/main/java/io/dapr/testcontainers/HttpEndpoint.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021 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 HttpEndpoint {
17 | private String name;
18 | private String baseUrl;
19 |
20 | public HttpEndpoint(String name, String baseUrl) {
21 | this.name = name;
22 | this.baseUrl = baseUrl;
23 | }
24 |
25 | public String getName() {
26 | return name;
27 | }
28 |
29 | public String getBaseUrl() {
30 | return baseUrl;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/testcontainers-dapr/src/main/java/io/dapr/testcontainers/ListEntry.java:
--------------------------------------------------------------------------------
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 | }
41 |
--------------------------------------------------------------------------------
/testcontainers-dapr/src/main/java/io/dapr/testcontainers/MetadataEntry.java:
--------------------------------------------------------------------------------
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 MetadataEntry {
17 | private String name;
18 | private String value;
19 |
20 | public MetadataEntry(String name, String value) {
21 | this.name = name;
22 | this.value = value;
23 | }
24 |
25 | public String getName() {
26 | return name;
27 | }
28 |
29 | public String getValue() {
30 | return value;
31 | }
32 |
33 | public void setName(String name) {
34 | this.name = name;
35 | }
36 |
37 | public void setValue(String value) {
38 | this.value = value;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/testcontainers-dapr/src/main/java/io/dapr/testcontainers/ZipkinTracingConfigurationSettings.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021 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 | /**
17 | * Configuration settings for Zipkin tracing.
18 | */
19 | public class ZipkinTracingConfigurationSettings implements ConfigurationSettings {
20 | private final String endpointAddress;
21 |
22 | public ZipkinTracingConfigurationSettings(String endpointAddress) {
23 | this.endpointAddress = endpointAddress;
24 | }
25 |
26 | public String getEndpointAddress() {
27 | return endpointAddress;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/testcontainers-dapr/src/main/java/io/dapr/testcontainers/converter/YamlConverter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2021 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.converter;
15 |
16 | public interface YamlConverter {
17 | String convert(T value);
18 | }
19 |
--------------------------------------------------------------------------------
/testcontainers-dapr/src/test/resources/dapr-resources/statestore.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: dapr.io/v1alpha1
2 | kind: Component
3 | metadata:
4 | name: statestore
5 | spec:
6 | type: state.redis
7 | version: v1
8 | metadata:
9 | - name: keyPrefix
10 | value: name
11 | - name: redisHost
12 | value: redis:6379
13 | - name: redisPassword
14 | value: ""
15 |
--------------------------------------------------------------------------------