mirror of https://github.com/dapr/java-sdk.git
Remove EmptyService and use dapr run -- instead. (#321)
This commit is contained in:
parent
8e68127809
commit
811728133d
|
@ -28,6 +28,12 @@ public abstract class BaseIT {
|
|||
return startDaprApp(testName, successMessage, serviceClass, useAppPort, true, maxWaitMilliseconds);
|
||||
}
|
||||
|
||||
protected static DaprRun startDaprApp(
|
||||
String testName,
|
||||
int maxWaitMilliseconds) throws Exception {
|
||||
return startDaprApp(testName, "You're up and running!", null, false, true, maxWaitMilliseconds);
|
||||
}
|
||||
|
||||
protected static DaprRun startDaprApp(
|
||||
String testName,
|
||||
String successMessage,
|
||||
|
@ -39,8 +45,7 @@ public abstract class BaseIT {
|
|||
testName,
|
||||
() -> DaprPorts.build(useAppPort, useDaprPorts, useDaprPorts),
|
||||
successMessage,
|
||||
serviceClass,
|
||||
maxWaitMilliseconds);
|
||||
maxWaitMilliseconds).withServiceClass(serviceClass);
|
||||
DaprRun run = builder.build();
|
||||
DAPR_RUNS.add(run);
|
||||
DAPR_RUN_BUILDERS.put(run.getAppName(), builder);
|
||||
|
|
|
@ -40,7 +40,7 @@ public class DaprRun {
|
|||
Class serviceClass,
|
||||
int maxWaitMilliseconds) {
|
||||
// The app name needs to be deterministic since we depend on it to kill previous runs.
|
||||
this.appName = String.format("%s_%s", testName, serviceClass.getSimpleName());
|
||||
this.appName = String.format("%s_%s", testName, serviceClass == null ? "" : serviceClass.getSimpleName());
|
||||
this.startCommand =
|
||||
new Command(successMessage, buildDaprCommand(this.appName, serviceClass, ports));
|
||||
this.listCommand = new Command(
|
||||
|
@ -162,8 +162,9 @@ public class DaprRun {
|
|||
.append(ports.getAppPort() != null ? " --app-port " + ports.getAppPort() : "")
|
||||
.append(ports.getHttpPort() != null ? " --dapr-http-port " + ports.getHttpPort() : "")
|
||||
.append(ports.getGrpcPort() != null ? " --dapr-grpc-port " + ports.getGrpcPort() : "")
|
||||
.append(String.format(DAPR_COMMAND, serviceClass.getCanonicalName(),
|
||||
ports.getAppPort() != null ? ports.getAppPort().toString() : ""));
|
||||
.append(serviceClass == null ? "" :
|
||||
String.format(DAPR_COMMAND, serviceClass.getCanonicalName(),
|
||||
ports.getAppPort() != null ? ports.getAppPort().toString() : ""));
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
|
||||
|
@ -189,23 +190,26 @@ public class DaprRun {
|
|||
|
||||
private final String successMessage;
|
||||
|
||||
private final Class serviceClass;
|
||||
|
||||
private final int maxWaitMilliseconds;
|
||||
|
||||
private Class serviceClass;
|
||||
|
||||
Builder(
|
||||
String testName,
|
||||
Supplier<DaprPorts> portsSupplier,
|
||||
String successMessage,
|
||||
Class serviceClass,
|
||||
int maxWaitMilliseconds) {
|
||||
this.testName = testName;
|
||||
this.portsSupplier = portsSupplier;
|
||||
this.successMessage = successMessage;
|
||||
this.serviceClass = serviceClass;
|
||||
this.maxWaitMilliseconds = maxWaitMilliseconds;
|
||||
}
|
||||
|
||||
public Builder withServiceClass(Class serviceClass) {
|
||||
this.serviceClass = serviceClass;
|
||||
return this;
|
||||
}
|
||||
|
||||
DaprRun build() {
|
||||
return new DaprRun(
|
||||
this.testName,
|
||||
|
|
|
@ -6,20 +6,17 @@
|
|||
package io.dapr.it.actors;
|
||||
|
||||
import io.dapr.actors.ActorId;
|
||||
import io.dapr.actors.client.ActorProxy;
|
||||
import io.dapr.actors.client.ActorProxyBuilder;
|
||||
import io.dapr.it.BaseIT;
|
||||
import io.dapr.it.actors.services.springboot.DemoActor;
|
||||
import io.dapr.it.actors.services.springboot.DemoActorService;
|
||||
import io.dapr.it.services.EmptyService;
|
||||
import io.dapr.serializer.DefaultObjectSerializer;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import static io.dapr.it.Retry.callWithRetry;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
|
|
@ -10,11 +10,8 @@ import io.dapr.actors.client.ActorProxy;
|
|||
import io.dapr.actors.client.ActorProxyBuilder;
|
||||
import io.dapr.it.BaseIT;
|
||||
import io.dapr.it.DaprRun;
|
||||
import io.dapr.it.actors.services.springboot.DemoActorService;
|
||||
import io.dapr.it.actors.services.springboot.StatefulActor;
|
||||
import io.dapr.it.actors.services.springboot.StatefulActorService;
|
||||
import io.dapr.it.services.EmptyService;
|
||||
import io.dapr.serializer.DefaultObjectSerializer;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
|
|
@ -13,7 +13,6 @@ import io.dapr.client.DaprClientGrpc;
|
|||
import io.dapr.client.DaprClientHttp;
|
||||
import io.dapr.it.BaseIT;
|
||||
import io.dapr.it.DaprRun;
|
||||
import io.dapr.it.services.EmptyService;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
|
@ -22,9 +21,13 @@ import org.junit.runner.RunWith;
|
|||
import org.junit.runners.Parameterized;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Test Secrets Store APIs using Harshicorp's vault.
|
||||
|
@ -66,13 +69,7 @@ public class SecretsClientIT extends BaseIT {
|
|||
|
||||
@BeforeClass
|
||||
public static void init() throws Exception {
|
||||
daprRun = startDaprApp(
|
||||
SecretsClientIT.class.getSimpleName(),
|
||||
EmptyService.SUCCESS_MESSAGE,
|
||||
EmptyService.class,
|
||||
false,
|
||||
5000
|
||||
);
|
||||
daprRun = startDaprApp(SecretsClientIT.class.getSimpleName(), 5000);
|
||||
|
||||
VaultConfig vaultConfig = new VaultConfig()
|
||||
.address(LOCAL_VAULT_ADDRESS)
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) Microsoft Corporation.
|
||||
* Licensed under the MIT License.
|
||||
*/
|
||||
|
||||
package io.dapr.it.services;
|
||||
|
||||
/**
|
||||
* Use this class in order to run DAPR with any needed services, like states.
|
||||
* <p>
|
||||
* To run manually, from repo root:
|
||||
* 1. mvn clean install
|
||||
* 2. dapr run --components-path ./components --dapr-grpc-port 41707 --dapr-http-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 final String SUCCESS_MESSAGE = "Hello from " + EmptyService.class.getSimpleName();
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
System.out.println(SUCCESS_MESSAGE);
|
||||
}
|
||||
}
|
|
@ -12,7 +12,6 @@ import io.dapr.client.domain.State;
|
|||
import io.dapr.client.domain.StateOptions;
|
||||
import io.dapr.it.BaseIT;
|
||||
import io.dapr.it.DaprRun;
|
||||
import io.dapr.it.services.EmptyService;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
|
@ -20,9 +19,12 @@ import org.junit.Test;
|
|||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.Duration;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* Test State GRPC DAPR capabilities using a DAPR instance with an empty service running
|
||||
|
@ -35,13 +37,7 @@ public class GRPCStateClientIT extends BaseIT {
|
|||
|
||||
@BeforeClass
|
||||
public static void init() throws Exception {
|
||||
daprRun = startDaprApp(
|
||||
GRPCStateClientIT.class.getSimpleName(),
|
||||
EmptyService.SUCCESS_MESSAGE,
|
||||
EmptyService.class,
|
||||
false,
|
||||
5000
|
||||
);
|
||||
daprRun = startDaprApp(GRPCStateClientIT.class.getSimpleName(), 5000);
|
||||
daprRun.switchToGRPC();
|
||||
daprClient = new DaprClientBuilder().build();
|
||||
|
||||
|
|
|
@ -11,16 +11,11 @@ import io.dapr.client.domain.State;
|
|||
import io.dapr.client.domain.StateOptions;
|
||||
import io.dapr.it.BaseIT;
|
||||
import io.dapr.it.DaprRun;
|
||||
import io.dapr.it.services.EmptyService;
|
||||
import io.dapr.serializer.DefaultObjectSerializer;
|
||||
import org.junit.Assert;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
/**
|
||||
* Test State HTTP DAPR capabilities using a DAPR instance with an empty service running
|
||||
*/
|
||||
|
@ -30,13 +25,7 @@ public class HttpStateClientIT extends BaseIT {
|
|||
|
||||
@BeforeClass
|
||||
public static void init() throws Exception {
|
||||
daprRun = startDaprApp(
|
||||
HttpStateClientIT.class.getSimpleName(),
|
||||
EmptyService.SUCCESS_MESSAGE,
|
||||
EmptyService.class,
|
||||
false,
|
||||
1000
|
||||
);
|
||||
daprRun = startDaprApp(HttpStateClientIT.class.getSimpleName(), 1000);
|
||||
daprRun.switchToHTTP();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue