Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions sdk/src/test/java/io/dapr/it/DaprIntegrationTestingRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,14 @@ public DaprFreePorts initializeDapr() throws Exception {
}

private static final String DAPR_RUN = "dapr run --app-id %s ";
private static final String DAPR_COMMAND = " -- mvn exec:java -D exec.mainClass=%s -D exec.classpathScope=\"test\" -Dexec.args=\"-p %d -grpcPort %d -httpPort %d\"";

// the arg in -Dexec.args is the app's port
private static final String DAPR_COMMAND = " -- mvn exec:java -Dexec.mainClass=%s -Dexec.classpathScope=test -Dexec.args=\"%d\"";

private String buildDaprCommand(){
StringBuilder stringBuilder= new StringBuilder(String.format(DAPR_RUN, this.appName))
.append(this.useAppPort ? "--app-port " + this.DAPR_FREEPORTS.appPort : "")
.append(" --grpc-port ")
.append(this.DAPR_FREEPORTS.grpcPort)
.append(" --port ")
.append(this.DAPR_FREEPORTS.httpPort)
.append(String.format(DAPR_COMMAND, this.serviceClass.getCanonicalName(),this.DAPR_FREEPORTS.appPort, this.DAPR_FREEPORTS.grpcPort, this.DAPR_FREEPORTS.httpPort));
.append(String.format(DAPR_COMMAND, this.serviceClass.getCanonicalName(),this.DAPR_FREEPORTS.appPort));
return stringBuilder.toString();
}

Expand Down
6 changes: 5 additions & 1 deletion sdk/src/test/java/io/dapr/it/services/EmptyService.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@

/**
* Use this class in order to run DAPR with any needed services, like states.
*
* To run manually, from repo root:
* 1. mvn clean install
* 2. dapr run --grpc-port 41707 --port 32851 -- mvn exec:java -Dexec.mainClass=io.dapr.it.services.EmptyService -Dexec.classpathScope="test" -Dexec.args="-p 44511 -grpcPort 41707 -httpPort 32851" -pl=sdk
*/
public class EmptyService {
public static void main(String[] args) {

System.out.println("Hello from EmptyService");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,19 @@


/**
* Simple example, to run:
* mvn clean install
* dapr run --grpc-port 50001 -- mvn exec:java -pl=examples -Dexec.mainClass=io.dapr.examples.Example
* Simple example.
* To run manually, from repo root:
* 1. mvn clean install
* 2. dapr run --grpc-port 50001 -- mvn exec:java -Dexec.mainClass=io.dapr.it.services.HelloWorldGrpcStateService -Dexec.classpathScope="test" -pl=sdk
*/
public class HelloWorldGrpcStateService {

public static void main(String[] args) throws ParseException {
Options options = new Options();
options.addRequiredOption("grpcPort", "grpcPort", true, "Dapr GRPC.");
options.addRequiredOption("httpPort", "httpPort", true, "Dapr HTTP port.");
options.addRequiredOption("p", "port", true, "Port Dapr will listen to.");

CommandLineParser parser = new DefaultParser();
CommandLine cmd = parser.parse(options, args);
String grpcPort = System.getenv("DAPR_GRPC_PORT");

// If port string is not valid, it will throw an exception.
int port = Integer.parseInt(cmd.getOptionValue("grpcPort"));
ManagedChannel channel = ManagedChannelBuilder.forAddress("localhost", port).usePlaintext().build();
int grpcPortInt = Integer.parseInt(grpcPort);
ManagedChannel channel = ManagedChannelBuilder.forAddress("localhost", grpcPortInt).usePlaintext().build();
DaprBlockingStub client = DaprGrpc.newBlockingStub(channel);

String key = "mykey";
Expand Down