mirror of https://github.com/dapr/java-sdk.git
Migrate to Junit5 (#910)
* Migrating to Junit5 Signed-off-by: Emanuel Alves <emanuel.j.b.alves@gmail.com> * Fix spotbugs errors Signed-off-by: Emanuel Alves <emanuel.j.b.alves@gmail.com> * Fix spotbugs errors Signed-off-by: Emanuel Alves <emanuel.j.b.alves@gmail.com> * remove unreachable code due to expected exception being thrown Signed-off-by: Emanuel Alves <emanuel.j.b.alves@gmail.com> * Increase daprRun timeout Signed-off-by: Emanuel Alves <emanuel.j.b.alves@gmail.com> * wait 5 secs before launching toxiproxy Signed-off-by: Emanuel Alves <emanuel.j.b.alves@gmail.com> * Rollback spotbugs bump version Signed-off-by: Emanuel Alves <emanuel.j.b.alves@gmail.com> * extract junit-bom version to a property Signed-off-by: Emanuel Alves <emanuel.j.b.alves@gmail.com> * Change settings in SdkResiliencyIT to reduce flakiness. Signed-off-by: Artur Souza <asouza.pro@gmail.com> * Wait for sidecar in SDKResiliencyIT Signed-off-by: Artur Souza <asouza.pro@gmail.com> --------- Signed-off-by: Emanuel Alves <emanuel.j.b.alves@gmail.com> Signed-off-by: Artur Souza <asouza.pro@gmail.com> Co-authored-by: Artur Souza <artursouza.ms@outlook.com> Co-authored-by: Artur Souza <asouza.pro@gmail.com>
This commit is contained in:
parent
86893a0742
commit
56d9270a0a
|
@ -96,6 +96,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.junit.jupiter</groupId>
|
<groupId>org.junit.jupiter</groupId>
|
||||||
<artifactId>junit-jupiter</artifactId>
|
<artifactId>junit-jupiter</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mockito</groupId>
|
<groupId>org.mockito</groupId>
|
||||||
|
|
69
pom.xml
69
pom.xml
|
@ -37,6 +37,9 @@
|
||||||
<spotbugs.exclude.filter.file>../spotbugs-exclude.xml</spotbugs.exclude.filter.file>
|
<spotbugs.exclude.filter.file>../spotbugs-exclude.xml</spotbugs.exclude.filter.file>
|
||||||
<springboot.version>2.7.8</springboot.version>
|
<springboot.version>2.7.8</springboot.version>
|
||||||
<argLine>--add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED</argLine>
|
<argLine>--add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED</argLine>
|
||||||
|
<failsafe.version>3.1.2</failsafe.version>
|
||||||
|
<surefire.version>3.1.2</surefire.version>
|
||||||
|
<junit-bom.version>5.7.2</junit-bom.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<distributionManagement>
|
<distributionManagement>
|
||||||
|
@ -70,16 +73,11 @@
|
||||||
<version>${grpc.version}</version>
|
<version>${grpc.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>org.junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit-bom</artifactId>
|
||||||
<version>4.13.2</version>
|
<version>${junit-bom.version}</version>
|
||||||
<scope>test</scope>
|
<scope>import</scope>
|
||||||
</dependency>
|
<type>pom</type>
|
||||||
<dependency>
|
|
||||||
<groupId>org.junit.jupiter</groupId>
|
|
||||||
<artifactId>junit-jupiter</artifactId>
|
|
||||||
<version>5.7.2</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mockito</groupId>
|
<groupId>org.mockito</groupId>
|
||||||
|
@ -91,6 +89,33 @@
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
<pluginManagement>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<version>${surefire.version}</version>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-failsafe-plugin</artifactId>
|
||||||
|
<version>${failsafe.version}</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>integration-test</goal>
|
||||||
|
<goal>verify</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<!--suppress UnresolvedMavenProperty -->
|
||||||
|
<skip>${skipITs}</skip>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</pluginManagement>
|
||||||
|
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.jacoco</groupId>
|
<groupId>org.jacoco</groupId>
|
||||||
|
@ -102,13 +127,6 @@
|
||||||
<goal>prepare-agent</goal>
|
<goal>prepare-agent</goal>
|
||||||
</goals>
|
</goals>
|
||||||
</execution>
|
</execution>
|
||||||
<execution>
|
|
||||||
<id>report</id>
|
|
||||||
<phase>test</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>report</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
@ -165,23 +183,6 @@
|
||||||
<autoReleaseAfterClose>true</autoReleaseAfterClose>
|
<autoReleaseAfterClose>true</autoReleaseAfterClose>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
|
||||||
<groupId>org.codehaus.mojo</groupId>
|
|
||||||
<artifactId>failsafe-maven-plugin</artifactId>
|
|
||||||
<version>2.4.3-alpha-1</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<goals>
|
|
||||||
<goal>integration-test</goal>
|
|
||||||
<goal>verify</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<!--suppress UnresolvedMavenProperty -->
|
|
||||||
<skip>${skipITs}</skip>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-checkstyle-plugin</artifactId>
|
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||||
|
|
|
@ -27,11 +27,6 @@
|
||||||
<artifactId>dapr-sdk</artifactId>
|
<artifactId>dapr-sdk</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>junit</groupId>
|
|
||||||
<artifactId>junit</artifactId>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mockito</groupId>
|
<groupId>org.mockito</groupId>
|
||||||
<artifactId>mockito-core</artifactId>
|
<artifactId>mockito-core</artifactId>
|
||||||
|
@ -45,8 +40,7 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.junit.jupiter</groupId>
|
<groupId>org.junit.jupiter</groupId>
|
||||||
<artifactId>junit-jupiter-api</artifactId>
|
<artifactId>junit-jupiter</artifactId>
|
||||||
<version>5.5.2</version>
|
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -12,41 +12,44 @@ limitations under the License.
|
||||||
*/
|
*/
|
||||||
package io.dapr.actors;
|
package io.dapr.actors;
|
||||||
|
|
||||||
import org.junit.Assert;
|
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unit tests for ActorId.
|
* Unit tests for ActorId.
|
||||||
*/
|
*/
|
||||||
public class ActorIdTest {
|
public class ActorIdTest {
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test
|
||||||
public void initializeNewActorIdObjectWithNullId() {
|
public void initializeNewActorIdObjectWithNullId() {
|
||||||
ActorId actorId = new ActorId(null);
|
assertThrows(IllegalArgumentException.class, () ->{ActorId actorId = new ActorId(null);});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getId() {
|
public void getId() {
|
||||||
String id = "123";
|
String id = "123";
|
||||||
ActorId actorId = new ActorId(id);
|
ActorId actorId = new ActorId(id);
|
||||||
Assert.assertEquals(id, actorId.toString());
|
assertEquals(id, actorId.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void verifyToString() {
|
public void verifyToString() {
|
||||||
String id = "123";
|
String id = "123";
|
||||||
ActorId actorId = new ActorId(id);
|
ActorId actorId = new ActorId(id);
|
||||||
Assert.assertEquals(id, actorId.toString());
|
assertEquals(id, actorId.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void verifyEqualsByObject() {
|
public void verifyEqualsByObject() {
|
||||||
List<Wrapper> values = createEqualsTestValues();
|
List<Wrapper> values = createEqualsTestValues();
|
||||||
for (Wrapper w : values) {
|
for (Wrapper w : values) {
|
||||||
Assert.assertEquals(w.expectedResult, w.item1.equals(w.item2));
|
assertEquals(w.expectedResult, w.item1.equals(w.item2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +59,7 @@ public class ActorIdTest {
|
||||||
for (Wrapper w : values) {
|
for (Wrapper w : values) {
|
||||||
ActorId a1 = (ActorId) w.item1;
|
ActorId a1 = (ActorId) w.item1;
|
||||||
Object a2 = w.item2;
|
Object a2 = w.item2;
|
||||||
Assert.assertEquals(w.expectedResult, a1.equals(a2));
|
assertEquals(w.expectedResult, a1.equals(a2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,7 +69,7 @@ public class ActorIdTest {
|
||||||
for (Wrapper w : values) {
|
for (Wrapper w : values) {
|
||||||
ActorId a1 = (ActorId) w.item1;
|
ActorId a1 = (ActorId) w.item1;
|
||||||
ActorId a2 = (ActorId) w.item2;
|
ActorId a2 = (ActorId) w.item2;
|
||||||
Assert.assertEquals(w.expectedResult, a1.compareTo(a2));
|
assertEquals(w.expectedResult, a1.compareTo(a2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,51 +15,53 @@ package io.dapr.actors.client;
|
||||||
|
|
||||||
import io.dapr.actors.ActorId;
|
import io.dapr.actors.ActorId;
|
||||||
import io.dapr.actors.ActorType;
|
import io.dapr.actors.ActorType;
|
||||||
import org.junit.AfterClass;
|
import org.junit.jupiter.api.AfterAll;
|
||||||
import org.junit.Assert;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
|
||||||
public class ActorProxyBuilderTest {
|
public class ActorProxyBuilderTest {
|
||||||
|
|
||||||
private static ActorClient actorClient;
|
private static ActorClient actorClient;
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeAll
|
||||||
public static void initClass() {
|
public static void initClass() {
|
||||||
actorClient = new ActorClient();
|
actorClient = new ActorClient();
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterAll
|
||||||
public static void tearDownClass() {
|
public static void tearDownClass() {
|
||||||
actorClient.close();
|
actorClient.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test
|
||||||
public void buildWithNullActorId() {
|
public void buildWithNullActorId() {
|
||||||
new ActorProxyBuilder("test", Object.class, actorClient)
|
assertThrows(IllegalArgumentException.class, () -> new ActorProxyBuilder("test", Object.class, actorClient)
|
||||||
.build(null);
|
.build(null));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test
|
||||||
public void buildWithEmptyActorType() {
|
public void buildWithEmptyActorType() {
|
||||||
new ActorProxyBuilder("", Object.class, actorClient);
|
assertThrows(IllegalArgumentException.class, () -> new ActorProxyBuilder("", Object.class, actorClient));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test
|
||||||
public void buildWithNullActorType() {
|
public void buildWithNullActorType() {
|
||||||
new ActorProxyBuilder(null, Object.class, actorClient);
|
assertThrows(IllegalArgumentException.class, () -> new ActorProxyBuilder(null, Object.class, actorClient));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test
|
||||||
public void buildWithNullSerializer() {
|
public void buildWithNullSerializer() {
|
||||||
new ActorProxyBuilder("MyActor", Object.class, actorClient)
|
assertThrows(IllegalArgumentException.class, () -> new ActorProxyBuilder("MyActor", Object.class, actorClient)
|
||||||
.withObjectSerializer(null)
|
.withObjectSerializer(null)
|
||||||
.build(new ActorId("100"));
|
.build(new ActorId("100")));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test
|
||||||
public void buildWithNullClient() {
|
public void buildWithNullClient() {
|
||||||
new ActorProxyBuilder("MyActor", Object.class, null);
|
assertThrows(IllegalArgumentException.class, () -> new ActorProxyBuilder("MyActor", Object.class, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test()
|
@Test()
|
||||||
|
@ -67,9 +69,9 @@ public class ActorProxyBuilderTest {
|
||||||
ActorProxyBuilder<ActorProxy> builder = new ActorProxyBuilder("test", ActorProxy.class, actorClient);
|
ActorProxyBuilder<ActorProxy> builder = new ActorProxyBuilder("test", ActorProxy.class, actorClient);
|
||||||
ActorProxy actorProxy = builder.build(new ActorId("100"));
|
ActorProxy actorProxy = builder.build(new ActorId("100"));
|
||||||
|
|
||||||
Assert.assertNotNull(actorProxy);
|
Assertions.assertNotNull(actorProxy);
|
||||||
Assert.assertEquals("test", actorProxy.getActorType());
|
Assertions.assertEquals("test", actorProxy.getActorType());
|
||||||
Assert.assertEquals("100", actorProxy.getActorId().toString());
|
Assertions.assertEquals("100", actorProxy.getActorId().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test()
|
@Test()
|
||||||
|
@ -77,7 +79,7 @@ public class ActorProxyBuilderTest {
|
||||||
ActorProxyBuilder<MyActor> builder = new ActorProxyBuilder(MyActor.class, actorClient);
|
ActorProxyBuilder<MyActor> builder = new ActorProxyBuilder(MyActor.class, actorClient);
|
||||||
MyActor actorProxy = builder.build(new ActorId("100"));
|
MyActor actorProxy = builder.build(new ActorId("100"));
|
||||||
|
|
||||||
Assert.assertNotNull(actorProxy);
|
Assertions.assertNotNull(actorProxy);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test()
|
@Test()
|
||||||
|
@ -85,7 +87,7 @@ public class ActorProxyBuilderTest {
|
||||||
ActorProxyBuilder<ActorWithDefaultName> builder = new ActorProxyBuilder(ActorWithDefaultName.class, actorClient);
|
ActorProxyBuilder<ActorWithDefaultName> builder = new ActorProxyBuilder(ActorWithDefaultName.class, actorClient);
|
||||||
ActorWithDefaultName actorProxy = builder.build(new ActorId("100"));
|
ActorWithDefaultName actorProxy = builder.build(new ActorId("100"));
|
||||||
|
|
||||||
Assert.assertNotNull(actorProxy);
|
Assertions.assertNotNull(actorProxy);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ActorType(name = "MyActor")
|
@ActorType(name = "MyActor")
|
||||||
|
|
|
@ -18,11 +18,12 @@ import io.dapr.actors.ActorMethod;
|
||||||
import io.dapr.exceptions.DaprException;
|
import io.dapr.exceptions.DaprException;
|
||||||
import io.dapr.serializer.DaprObjectSerializer;
|
import io.dapr.serializer.DaprObjectSerializer;
|
||||||
import io.dapr.serializer.DefaultObjectSerializer;
|
import io.dapr.serializer.DefaultObjectSerializer;
|
||||||
import org.junit.Assert;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
import static org.mockito.ArgumentMatchers.anyString;
|
import static org.mockito.ArgumentMatchers.anyString;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
@ -38,8 +39,8 @@ public class ActorProxyImplTest {
|
||||||
new ActorId("100"),
|
new ActorId("100"),
|
||||||
serializer,
|
serializer,
|
||||||
daprClient);
|
daprClient);
|
||||||
Assert.assertEquals(actorProxy.getActorId().toString(), "100");
|
Assertions.assertEquals(actorProxy.getActorId().toString(), "100");
|
||||||
Assert.assertEquals(actorProxy.getActorType(), "myActorType");
|
Assertions.assertEquals(actorProxy.getActorType(), "myActorType");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test()
|
@Test()
|
||||||
|
@ -59,9 +60,9 @@ public class ActorProxyImplTest {
|
||||||
|
|
||||||
Mono<MyData> result = actorProxy.invokeMethod("getData", MyData.class);
|
Mono<MyData> result = actorProxy.invokeMethod("getData", MyData.class);
|
||||||
MyData myData = result.block();
|
MyData myData = result.block();
|
||||||
Assert.assertNotNull(myData);
|
Assertions.assertNotNull(myData);
|
||||||
Assert.assertEquals("valueA", myData.getPropertyA());
|
Assertions.assertEquals("valueA", myData.getPropertyA());
|
||||||
Assert.assertEquals("valueB", myData.getPropertyB());// propertyB=null
|
Assertions.assertEquals("valueB", myData.getPropertyB());// propertyB=null
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test()
|
@Test()
|
||||||
|
@ -80,9 +81,9 @@ public class ActorProxyImplTest {
|
||||||
daprClient);
|
daprClient);
|
||||||
|
|
||||||
MyData myData = (MyData) actorProxy.invoke(actorProxy, Actor.class.getMethod("getData"), null);
|
MyData myData = (MyData) actorProxy.invoke(actorProxy, Actor.class.getMethod("getData"), null);
|
||||||
Assert.assertNotNull(myData);
|
Assertions.assertNotNull(myData);
|
||||||
Assert.assertEquals("valueA", myData.getPropertyA());
|
Assertions.assertEquals("valueA", myData.getPropertyA());
|
||||||
Assert.assertEquals("valueB", myData.getPropertyB());// propertyB=null
|
Assertions.assertEquals("valueB", myData.getPropertyB());// propertyB=null
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test()
|
@Test()
|
||||||
|
@ -101,11 +102,11 @@ public class ActorProxyImplTest {
|
||||||
daprClient);
|
daprClient);
|
||||||
|
|
||||||
Mono<MyData> res = (Mono<MyData>) actorProxy.invoke(actorProxy, Actor.class.getMethod("getDataMono"), null);
|
Mono<MyData> res = (Mono<MyData>) actorProxy.invoke(actorProxy, Actor.class.getMethod("getDataMono"), null);
|
||||||
Assert.assertNotNull(res);
|
Assertions.assertNotNull(res);
|
||||||
MyData myData = res.block();
|
MyData myData = res.block();
|
||||||
Assert.assertNotNull(myData);
|
Assertions.assertNotNull(myData);
|
||||||
Assert.assertEquals("valueA", myData.getPropertyA());
|
Assertions.assertEquals("valueA", myData.getPropertyA());
|
||||||
Assert.assertEquals("valueB", myData.getPropertyB());// propertyB=null
|
Assertions.assertEquals("valueB", myData.getPropertyB());// propertyB=null
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test()
|
@Test()
|
||||||
|
@ -128,7 +129,7 @@ public class ActorProxyImplTest {
|
||||||
Actor.class.getMethod("echo", String.class),
|
Actor.class.getMethod("echo", String.class),
|
||||||
new Object[] { "hello world" } );
|
new Object[] { "hello world" } );
|
||||||
|
|
||||||
Assert.assertEquals("OK", res);
|
Assertions.assertEquals("OK", res);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test()
|
@Test()
|
||||||
|
@ -151,8 +152,8 @@ public class ActorProxyImplTest {
|
||||||
Actor.class.getMethod("echoMono", String.class),
|
Actor.class.getMethod("echoMono", String.class),
|
||||||
new Object[] { "hello world" } );
|
new Object[] { "hello world" } );
|
||||||
|
|
||||||
Assert.assertNotNull(res);
|
Assertions.assertNotNull(res);
|
||||||
Assert.assertEquals("OK", res.block());
|
Assertions.assertEquals("OK", res.block());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test()
|
@Test()
|
||||||
|
@ -170,7 +171,7 @@ public class ActorProxyImplTest {
|
||||||
daprClient);
|
daprClient);
|
||||||
|
|
||||||
Object myData = actorProxy.invoke(actorProxy, Actor.class.getMethod("doSomething"), null);
|
Object myData = actorProxy.invoke(actorProxy, Actor.class.getMethod("doSomething"), null);
|
||||||
Assert.assertNull(myData);
|
Assertions.assertNull(myData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test()
|
@Test()
|
||||||
|
@ -188,8 +189,8 @@ public class ActorProxyImplTest {
|
||||||
daprClient);
|
daprClient);
|
||||||
|
|
||||||
Mono<Void> myData = (Mono<Void>)actorProxy.invoke(actorProxy, Actor.class.getMethod("doSomethingMono"), null);
|
Mono<Void> myData = (Mono<Void>)actorProxy.invoke(actorProxy, Actor.class.getMethod("doSomethingMono"), null);
|
||||||
Assert.assertNotNull(myData);
|
Assertions.assertNotNull(myData);
|
||||||
Assert.assertNull(myData.block());
|
Assertions.assertNull(myData.block());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test()
|
@Test()
|
||||||
|
@ -211,11 +212,11 @@ public class ActorProxyImplTest {
|
||||||
Actor.class.getMethod("doSomethingMonoWithArg", String.class),
|
Actor.class.getMethod("doSomethingMonoWithArg", String.class),
|
||||||
new Object[] { "hello world" });
|
new Object[] { "hello world" });
|
||||||
|
|
||||||
Assert.assertNotNull(myData);
|
Assertions.assertNotNull(myData);
|
||||||
Assert.assertNull(myData.block());
|
Assertions.assertNull(myData.block());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = UnsupportedOperationException.class)
|
@Test
|
||||||
public void invokeActorMethodWithTooManyArgsViaReflection() throws NoSuchMethodException {
|
public void invokeActorMethodWithTooManyArgsViaReflection() throws NoSuchMethodException {
|
||||||
final ActorClient daprClient = mock(ActorClient.class);
|
final ActorClient daprClient = mock(ActorClient.class);
|
||||||
|
|
||||||
|
@ -225,13 +226,10 @@ public class ActorProxyImplTest {
|
||||||
new DefaultObjectSerializer(),
|
new DefaultObjectSerializer(),
|
||||||
daprClient);
|
daprClient);
|
||||||
|
|
||||||
Mono<Void> myData = (Mono<Void>)actorProxy.invoke(
|
assertThrows(UnsupportedOperationException.class, () -> actorProxy.invoke(
|
||||||
actorProxy,
|
actorProxy,
|
||||||
Actor.class.getMethod("tooManyArgs", String.class, String.class),
|
Actor.class.getMethod("tooManyArgs", String.class, String.class),
|
||||||
new Object[] { "hello", "world" });
|
new Object[] { "hello", "world" }));
|
||||||
|
|
||||||
Assert.assertNotNull(myData);
|
|
||||||
Assert.assertNull(myData.block());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test()
|
@Test()
|
||||||
|
@ -253,7 +251,7 @@ public class ActorProxyImplTest {
|
||||||
Actor.class.getMethod("process", String.class),
|
Actor.class.getMethod("process", String.class),
|
||||||
new Object[] { "hello world" } );
|
new Object[] { "hello world" } );
|
||||||
|
|
||||||
Assert.assertNull(res);
|
Assertions.assertNull(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test()
|
@Test()
|
||||||
|
@ -270,10 +268,10 @@ public class ActorProxyImplTest {
|
||||||
|
|
||||||
Mono<MyData> result = actorProxy.invokeMethod("getData", MyData.class);
|
Mono<MyData> result = actorProxy.invokeMethod("getData", MyData.class);
|
||||||
MyData myData = result.block();
|
MyData myData = result.block();
|
||||||
Assert.assertNull(myData);
|
Assertions.assertNull(myData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = RuntimeException.class)
|
@Test
|
||||||
public void invokeActorMethodWithIncorrectReturnType() {
|
public void invokeActorMethodWithIncorrectReturnType() {
|
||||||
final ActorClient daprClient = mock(ActorClient.class);
|
final ActorClient daprClient = mock(ActorClient.class);
|
||||||
when(daprClient.invoke(anyString(), anyString(), anyString(), Mockito.isNull()))
|
when(daprClient.invoke(anyString(), anyString(), anyString(), Mockito.isNull()))
|
||||||
|
@ -287,10 +285,7 @@ public class ActorProxyImplTest {
|
||||||
|
|
||||||
Mono<MyData> result = actorProxy.invokeMethod("getData", MyData.class);
|
Mono<MyData> result = actorProxy.invokeMethod("getData", MyData.class);
|
||||||
|
|
||||||
result.doOnSuccess(x ->
|
assertThrows(DaprException.class, () ->result.block());
|
||||||
Assert.fail("Not exception was throw"))
|
|
||||||
.doOnError(Throwable::printStackTrace
|
|
||||||
).block();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test()
|
@Test()
|
||||||
|
@ -312,13 +307,13 @@ public class ActorProxyImplTest {
|
||||||
|
|
||||||
Mono<MyData> result = actorProxy.invokeMethod("getData", saveData, MyData.class);
|
Mono<MyData> result = actorProxy.invokeMethod("getData", saveData, MyData.class);
|
||||||
MyData myData = result.block();
|
MyData myData = result.block();
|
||||||
Assert.assertNotNull(myData);
|
Assertions.assertNotNull(myData);
|
||||||
Assert.assertEquals("valueA", myData.getPropertyA());
|
Assertions.assertEquals("valueA", myData.getPropertyA());
|
||||||
Assert.assertEquals("valueB", myData.getPropertyB());//propertyB=null
|
Assertions.assertEquals("valueB", myData.getPropertyB());//propertyB=null
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = DaprException.class)
|
@Test
|
||||||
public void invokeActorMethodSavingDataWithIncorrectReturnType() {
|
public void invokeActorMethodSavingDataWithIncorrectReturnType() {
|
||||||
final ActorClient daprClient = mock(ActorClient.class);
|
final ActorClient daprClient = mock(ActorClient.class);
|
||||||
when(daprClient.invoke(anyString(), anyString(), anyString(), Mockito.isNotNull()))
|
when(daprClient.invoke(anyString(), anyString(), anyString(), Mockito.isNotNull()))
|
||||||
|
@ -335,10 +330,7 @@ public class ActorProxyImplTest {
|
||||||
saveData.setPropertyB("valueB");
|
saveData.setPropertyB("valueB");
|
||||||
|
|
||||||
Mono<MyData> result = actorProxy.invokeMethod("getData", saveData, MyData.class);
|
Mono<MyData> result = actorProxy.invokeMethod("getData", saveData, MyData.class);
|
||||||
result.doOnSuccess(x ->
|
assertThrows(DaprException.class, () ->result.block());
|
||||||
Assert.fail("Not exception was throw"))
|
|
||||||
.doOnError(Throwable::printStackTrace
|
|
||||||
).block();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -360,11 +352,11 @@ public class ActorProxyImplTest {
|
||||||
|
|
||||||
Mono<MyData> result = actorProxy.invokeMethod("getData", saveData, MyData.class);
|
Mono<MyData> result = actorProxy.invokeMethod("getData", saveData, MyData.class);
|
||||||
MyData myData = result.block();
|
MyData myData = result.block();
|
||||||
Assert.assertNull(myData);
|
Assertions.assertNull(myData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test(expected = DaprException.class)
|
@Test
|
||||||
public void invokeActorMethodSavingDataWithIncorrectInputType() {
|
public void invokeActorMethodSavingDataWithIncorrectInputType() {
|
||||||
final ActorClient daprClient = mock(ActorClient.class);
|
final ActorClient daprClient = mock(ActorClient.class);
|
||||||
when(daprClient.invoke(anyString(), anyString(), anyString(), Mockito.isNotNull()))
|
when(daprClient.invoke(anyString(), anyString(), anyString(), Mockito.isNotNull()))
|
||||||
|
@ -381,12 +373,7 @@ public class ActorProxyImplTest {
|
||||||
saveData.setPropertyB("valueB");
|
saveData.setPropertyB("valueB");
|
||||||
saveData.setMyData(saveData);
|
saveData.setMyData(saveData);
|
||||||
|
|
||||||
Mono<MyData> result = actorProxy.invokeMethod("getData", saveData, MyData.class);
|
assertThrows(DaprException.class, () -> actorProxy.invokeMethod("getData", saveData, MyData.class));
|
||||||
result.doOnSuccess(x ->
|
|
||||||
Assert.fail("Not exception was throw"))
|
|
||||||
.doOnError(Throwable::printStackTrace
|
|
||||||
).block();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test()
|
@Test()
|
||||||
|
@ -407,11 +394,11 @@ public class ActorProxyImplTest {
|
||||||
|
|
||||||
Mono<Void> result = actorProxy.invokeMethod("getData", saveData);
|
Mono<Void> result = actorProxy.invokeMethod("getData", saveData);
|
||||||
Void emptyResponse = result.block();
|
Void emptyResponse = result.block();
|
||||||
Assert.assertNull(emptyResponse);
|
Assertions.assertNull(emptyResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test(expected = DaprException.class)
|
@Test
|
||||||
public void invokeActorMethodWithDataWithVoidIncorrectInputType() {
|
public void invokeActorMethodWithDataWithVoidIncorrectInputType() {
|
||||||
MyData saveData = new MyData();
|
MyData saveData = new MyData();
|
||||||
saveData.setPropertyA("valueA");
|
saveData.setPropertyA("valueA");
|
||||||
|
@ -428,9 +415,7 @@ public class ActorProxyImplTest {
|
||||||
new DefaultObjectSerializer(),
|
new DefaultObjectSerializer(),
|
||||||
daprClient);
|
daprClient);
|
||||||
|
|
||||||
Mono<Void> result = actorProxy.invokeMethod("getData", saveData);
|
assertThrows(DaprException.class, () -> actorProxy.invokeMethod("getData", saveData));
|
||||||
Void emptyResponse = result.doOnError(Throwable::printStackTrace).block();
|
|
||||||
Assert.assertNull(emptyResponse);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test()
|
@Test()
|
||||||
|
@ -447,7 +432,7 @@ public class ActorProxyImplTest {
|
||||||
|
|
||||||
Mono<Void> result = actorProxy.invokeMethod("getData");
|
Mono<Void> result = actorProxy.invokeMethod("getData");
|
||||||
Void emptyResponse = result.block();
|
Void emptyResponse = result.block();
|
||||||
Assert.assertNull(emptyResponse);
|
Assertions.assertNull(emptyResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Actor {
|
interface Actor {
|
||||||
|
|
|
@ -23,16 +23,16 @@ import io.grpc.inprocess.InProcessChannelBuilder;
|
||||||
import io.grpc.inprocess.InProcessServerBuilder;
|
import io.grpc.inprocess.InProcessServerBuilder;
|
||||||
import io.grpc.stub.StreamObserver;
|
import io.grpc.stub.StreamObserver;
|
||||||
import io.grpc.testing.GrpcCleanupRule;
|
import io.grpc.testing.GrpcCleanupRule;
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
import static io.dapr.actors.TestUtils.assertThrowsDaprException;
|
import static io.dapr.actors.TestUtils.assertThrowsDaprException;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
import static org.mockito.AdditionalAnswers.delegatesTo;
|
import static org.mockito.AdditionalAnswers.delegatesTo;
|
||||||
import static org.mockito.Mockito.*;
|
import static org.mockito.Mockito.*;
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ public class DaprGrpcClientTest {
|
||||||
|
|
||||||
private DaprGrpcClient client;
|
private DaprGrpcClient client;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setup() throws IOException {
|
public void setup() throws IOException {
|
||||||
// Generate a unique in-process server name.
|
// Generate a unique in-process server name.
|
||||||
String serverName = InProcessServerBuilder.generateName();
|
String serverName = InProcessServerBuilder.generateName();
|
||||||
|
|
|
@ -21,11 +21,12 @@ import okhttp3.mock.Behavior;
|
||||||
import okhttp3.mock.MediaTypes;
|
import okhttp3.mock.MediaTypes;
|
||||||
import okhttp3.mock.MockInterceptor;
|
import okhttp3.mock.MockInterceptor;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
import static io.dapr.actors.TestUtils.assertThrowsDaprException;
|
import static io.dapr.actors.TestUtils.assertThrowsDaprException;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
public class DaprHttpClientTest {
|
public class DaprHttpClientTest {
|
||||||
|
|
||||||
|
@ -37,7 +38,7 @@ public class DaprHttpClientTest {
|
||||||
|
|
||||||
private final String EXPECTED_RESULT = "{\"data\":\"ewoJCSJwcm9wZXJ0eUEiOiAidmFsdWVBIiwKCQkicHJvcGVydHlCIjogInZhbHVlQiIKCX0=\"}";
|
private final String EXPECTED_RESULT = "{\"data\":\"ewoJCSJwcm9wZXJ0eUEiOiAidmFsdWVBIiwKCQkicHJvcGVydHlCIjogInZhbHVlQiIKCX0=\"}";
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
mockInterceptor = new MockInterceptor(Behavior.UNORDERED);
|
mockInterceptor = new MockInterceptor(Behavior.UNORDERED);
|
||||||
okHttpClient = new OkHttpClient.Builder().addInterceptor(mockInterceptor).build();
|
okHttpClient = new OkHttpClient.Builder().addInterceptor(mockInterceptor).build();
|
||||||
|
|
|
@ -19,8 +19,8 @@ import io.dapr.actors.client.ActorProxy;
|
||||||
import io.dapr.actors.client.ActorProxyImplForTests;
|
import io.dapr.actors.client.ActorProxyImplForTests;
|
||||||
import io.dapr.actors.client.DaprClientStub;
|
import io.dapr.actors.client.DaprClientStub;
|
||||||
import io.dapr.serializer.DaprObjectSerializer;
|
import io.dapr.serializer.DaprObjectSerializer;
|
||||||
import org.junit.Assert;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
@ -108,8 +108,8 @@ public class ActorCustomSerializerTest {
|
||||||
|
|
||||||
MyData response = actorProxy.invokeMethod("classInClassOut", d, MyData.class).block();
|
MyData response = actorProxy.invokeMethod("classInClassOut", d, MyData.class).block();
|
||||||
|
|
||||||
Assert.assertEquals("hihi", response.getName());
|
Assertions.assertEquals("hihi", response.getName());
|
||||||
Assert.assertEquals(6, response.getNum());
|
Assertions.assertEquals(6, response.getNum());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -117,7 +117,7 @@ public class ActorCustomSerializerTest {
|
||||||
ActorProxy actorProxy = createActorProxy();
|
ActorProxy actorProxy = createActorProxy();
|
||||||
String response = actorProxy.invokeMethod("stringInStringOut", "oi", String.class).block();
|
String response = actorProxy.invokeMethod("stringInStringOut", "oi", String.class).block();
|
||||||
|
|
||||||
Assert.assertEquals("oioi", response);
|
Assertions.assertEquals("oioi", response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -125,7 +125,7 @@ public class ActorCustomSerializerTest {
|
||||||
ActorProxy actorProxy = createActorProxy();
|
ActorProxy actorProxy = createActorProxy();
|
||||||
int response = actorProxy.invokeMethod("intInIntOut", 2, int.class).block();
|
int response = actorProxy.invokeMethod("intInIntOut", 2, int.class).block();
|
||||||
|
|
||||||
Assert.assertEquals(4, response);
|
Assertions.assertEquals(4, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ActorId newActorId() {
|
private static ActorId newActorId() {
|
||||||
|
|
|
@ -17,8 +17,8 @@ import io.dapr.actors.ActorId;
|
||||||
import io.dapr.actors.ActorType;
|
import io.dapr.actors.ActorType;
|
||||||
import io.dapr.serializer.DefaultObjectSerializer;
|
import io.dapr.serializer.DefaultObjectSerializer;
|
||||||
import io.dapr.utils.TypeRef;
|
import io.dapr.utils.TypeRef;
|
||||||
import org.junit.Assert;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@ import java.io.IOException;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
@ -120,11 +121,13 @@ public class ActorManagerTest {
|
||||||
|
|
||||||
private ActorManager<MyActorImpl> manager = new ActorManager<>(context);
|
private ActorManager<MyActorImpl> manager = new ActorManager<>(context);
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test
|
||||||
public void invokeBeforeActivate() throws Exception {
|
public void invokeBeforeActivate() throws Exception {
|
||||||
ActorId actorId = newActorId();
|
ActorId actorId = newActorId();
|
||||||
String message = "something";
|
String message = "something";
|
||||||
this.manager.invokeMethod(actorId, "say", message.getBytes()).block();
|
|
||||||
|
assertThrows(IllegalArgumentException.class, () ->
|
||||||
|
this.manager.invokeMethod(actorId, "say", message.getBytes()).block());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -133,7 +136,7 @@ public class ActorManagerTest {
|
||||||
byte[] message = this.context.getObjectSerializer().serialize("something");
|
byte[] message = this.context.getObjectSerializer().serialize("something");
|
||||||
this.manager.activateActor(actorId).block();
|
this.manager.activateActor(actorId).block();
|
||||||
byte[] response = this.manager.invokeMethod(actorId, "say", message).block();
|
byte[] response = this.manager.invokeMethod(actorId, "say", message).block();
|
||||||
Assert.assertEquals(executeSayMethod(
|
Assertions.assertEquals(executeSayMethod(
|
||||||
this.context.getObjectSerializer().deserialize(message, TypeRef.STRING)),
|
this.context.getObjectSerializer().deserialize(message, TypeRef.STRING)),
|
||||||
this.context.getObjectSerializer().deserialize(response, TypeRef.STRING));
|
this.context.getObjectSerializer().deserialize(response, TypeRef.STRING));
|
||||||
}
|
}
|
||||||
|
@ -143,7 +146,7 @@ public class ActorManagerTest {
|
||||||
ActorId actorId = newActorId();
|
ActorId actorId = newActorId();
|
||||||
this.manager.activateActor(actorId).block();
|
this.manager.activateActor(actorId).block();
|
||||||
|
|
||||||
Assertions.assertThrows(RuntimeException.class, () -> {
|
assertThrows(RuntimeException.class, () -> {
|
||||||
this.manager.invokeMethod(actorId, "throwsException", null).block();
|
this.manager.invokeMethod(actorId, "throwsException", null).block();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -162,7 +165,7 @@ public class ActorManagerTest {
|
||||||
ActorId actorId = newActorId();
|
ActorId actorId = newActorId();
|
||||||
this.manager.activateActor(actorId).block();
|
this.manager.activateActor(actorId).block();
|
||||||
|
|
||||||
Assertions.assertThrows(RuntimeException.class, () -> {
|
assertThrows(RuntimeException.class, () -> {
|
||||||
this.manager.invokeMethod(actorId, "throwsExceptionHotMono", null).block();
|
this.manager.invokeMethod(actorId, "throwsExceptionHotMono", null).block();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -181,7 +184,7 @@ public class ActorManagerTest {
|
||||||
ActorId actorId = newActorId();
|
ActorId actorId = newActorId();
|
||||||
this.manager.activateActor(actorId).block();
|
this.manager.activateActor(actorId).block();
|
||||||
|
|
||||||
Assertions.assertThrows(RuntimeException.class, () -> {
|
assertThrows(RuntimeException.class, () -> {
|
||||||
this.manager.invokeMethod(actorId, "throwsExceptionMono", null).block();
|
this.manager.invokeMethod(actorId, "throwsExceptionMono", null).block();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -195,18 +198,19 @@ public class ActorManagerTest {
|
||||||
this.manager.invokeMethod(actorId, "throwsExceptionMono", null);
|
this.manager.invokeMethod(actorId, "throwsExceptionMono", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test
|
||||||
public void activateInvokeDeactivateThenInvoke() throws Exception {
|
public void activateInvokeDeactivateThenInvoke() throws Exception {
|
||||||
ActorId actorId = newActorId();
|
ActorId actorId = newActorId();
|
||||||
byte[] message = this.context.getObjectSerializer().serialize("something");
|
byte[] message = this.context.getObjectSerializer().serialize("something");
|
||||||
this.manager.activateActor(actorId).block();
|
this.manager.activateActor(actorId).block();
|
||||||
byte[] response = this.manager.invokeMethod(actorId, "say", message).block();
|
byte[] response = this.manager.invokeMethod(actorId, "say", message).block();
|
||||||
Assert.assertEquals(executeSayMethod(
|
Assertions.assertEquals(executeSayMethod(
|
||||||
this.context.getObjectSerializer().deserialize(message, TypeRef.STRING)),
|
this.context.getObjectSerializer().deserialize(message, TypeRef.STRING)),
|
||||||
this.context.getObjectSerializer().deserialize(response, TypeRef.STRING));
|
this.context.getObjectSerializer().deserialize(response, TypeRef.STRING));
|
||||||
|
|
||||||
this.manager.deactivateActor(actorId).block();
|
this.manager.deactivateActor(actorId).block();
|
||||||
this.manager.invokeMethod(actorId, "say", message).block();
|
assertThrows(IllegalArgumentException.class, () ->
|
||||||
|
this.manager.invokeMethod(actorId, "say", message).block());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -217,10 +221,11 @@ public class ActorManagerTest {
|
||||||
manager.invokeReminder(actorId, "myremind", createReminderParams("hello")).block();
|
manager.invokeReminder(actorId, "myremind", createReminderParams("hello")).block();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test
|
||||||
public void invokeReminderBeforeActivate() throws Exception {
|
public void invokeReminderBeforeActivate() throws Exception {
|
||||||
ActorId actorId = newActorId();
|
ActorId actorId = newActorId();
|
||||||
this.manager.invokeReminder(actorId, "myremind", createReminderParams("hello")).block();
|
assertThrows(IllegalArgumentException.class, () ->
|
||||||
|
this.manager.invokeReminder(actorId, "myremind", createReminderParams("hello")).block());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -230,18 +235,21 @@ public class ActorManagerTest {
|
||||||
this.manager.invokeReminder(actorId, "myremind", createReminderParams("hello")).block();
|
this.manager.invokeReminder(actorId, "myremind", createReminderParams("hello")).block();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test
|
||||||
public void activateDeactivateThenInvokeReminder() throws Exception {
|
public void activateDeactivateThenInvokeReminder() throws Exception {
|
||||||
ActorId actorId = newActorId();
|
ActorId actorId = newActorId();
|
||||||
this.manager.activateActor(actorId).block();
|
this.manager.activateActor(actorId).block();
|
||||||
this.manager.deactivateActor(actorId).block();;
|
this.manager.deactivateActor(actorId).block();;
|
||||||
this.manager.invokeReminder(actorId, "myremind", createReminderParams("hello")).block();
|
|
||||||
|
assertThrows(IllegalArgumentException.class, () -> this.manager.invokeReminder(actorId, "myremind", createReminderParams("hello")).block());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test
|
||||||
public void invokeTimerBeforeActivate() throws IOException {
|
public void invokeTimerBeforeActivate() throws IOException {
|
||||||
ActorId actorId = newActorId();
|
ActorId actorId = newActorId();
|
||||||
this.manager.invokeTimer(actorId, "count", createTimerParams("incrementCount", 2)).block();
|
|
||||||
|
assertThrows(IllegalArgumentException.class, () ->
|
||||||
|
this.manager.invokeTimer(actorId, "count", createTimerParams("incrementCount", 2)).block());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -257,19 +265,19 @@ public class ActorManagerTest {
|
||||||
this.manager.activateActor(actorId).block();
|
this.manager.activateActor(actorId).block();
|
||||||
this.manager.invokeTimer(actorId, "count", createTimerParams("incrementCount", 2)).block();
|
this.manager.invokeTimer(actorId, "count", createTimerParams("incrementCount", 2)).block();
|
||||||
byte[] response = this.manager.invokeMethod(actorId, "getCount", null).block();
|
byte[] response = this.manager.invokeMethod(actorId, "getCount", null).block();
|
||||||
Assert.assertEquals("2", new String(response));
|
Assertions.assertEquals("2", new String(response));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test
|
||||||
public void activateInvokeTimerDeactivateThenInvokeTimer() throws IOException {
|
public void activateInvokeTimerDeactivateThenInvokeTimer() throws IOException {
|
||||||
ActorId actorId = newActorId();
|
ActorId actorId = newActorId();
|
||||||
this.manager.activateActor(actorId).block();
|
this.manager.activateActor(actorId).block();
|
||||||
this.manager.invokeTimer(actorId, "count", createTimerParams("incrementCount", 2)).block();
|
this.manager.invokeTimer(actorId, "count", createTimerParams("incrementCount", 2)).block();
|
||||||
byte[] response = this.manager.invokeMethod(actorId, "getCount", null).block();
|
byte[] response = this.manager.invokeMethod(actorId, "getCount", null).block();
|
||||||
Assert.assertEquals("2", new String(response));
|
Assertions.assertEquals("2", new String(response));
|
||||||
|
|
||||||
this.manager.deactivateActor(actorId).block();
|
this.manager.deactivateActor(actorId).block();
|
||||||
this.manager.invokeTimer(actorId, "count", createTimerParams("incrementCount", 2)).block();
|
assertThrows(IllegalArgumentException.class, () -> this.manager.invokeTimer(actorId, "count", createTimerParams("incrementCount", 2)).block());
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte[] createReminderParams(String data) throws IOException {
|
private byte[] createReminderParams(String data) throws IOException {
|
||||||
|
|
|
@ -13,13 +13,15 @@ limitations under the License.
|
||||||
|
|
||||||
package io.dapr.actors.runtime;
|
package io.dapr.actors.runtime;
|
||||||
|
|
||||||
import org.junit.Assert;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.Parameter;
|
import java.lang.reflect.Parameter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unit tests for ActorMethodInfoMap.
|
* Unit tests for ActorMethodInfoMap.
|
||||||
*/
|
*/
|
||||||
|
@ -33,23 +35,24 @@ public class ActorMethodInfoMapTest {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Method m1 = m.get("getData");
|
Method m1 = m.get("getData");
|
||||||
Assert.assertEquals("getData", m1.getName());
|
Assertions.assertEquals("getData", m1.getName());
|
||||||
Class c = m1.getReturnType();
|
Class c = m1.getReturnType();
|
||||||
Assert.assertEquals(c.getClass(), String.class.getClass());
|
Assertions.assertEquals(c.getClass(), String.class.getClass());
|
||||||
Parameter[] p = m1.getParameters();
|
Parameter[] p = m1.getParameters();
|
||||||
Assert.assertEquals(p[0].getType().getClass(), String.class.getClass());
|
Assertions.assertEquals(p[0].getType().getClass(), String.class.getClass());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Assert.fail("Exception not expected.");
|
Assertions.fail("Exception not expected.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = NoSuchMethodException.class)
|
@Test
|
||||||
public void lookUpNonExistingMethod() throws NoSuchMethodException {
|
public void lookUpNonExistingMethod() throws NoSuchMethodException {
|
||||||
ArrayList<Class<?>> interfaceTypes = new ArrayList<>();
|
ArrayList<Class<?>> interfaceTypes = new ArrayList<>();
|
||||||
interfaceTypes.add(TestActor.class);
|
interfaceTypes.add(TestActor.class);
|
||||||
ActorMethodInfoMap m = new ActorMethodInfoMap(interfaceTypes);
|
ActorMethodInfoMap m = new ActorMethodInfoMap(interfaceTypes);
|
||||||
|
|
||||||
m.get("thisMethodDoesNotExist");
|
assertThrows(NoSuchMethodException.class, () ->
|
||||||
|
m.get("thisMethodDoesNotExist"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -20,14 +20,15 @@ import io.dapr.actors.client.ActorProxy;
|
||||||
import io.dapr.actors.client.ActorProxyImplForTests;
|
import io.dapr.actors.client.ActorProxyImplForTests;
|
||||||
import io.dapr.actors.client.DaprClientStub;
|
import io.dapr.actors.client.DaprClientStub;
|
||||||
import io.dapr.serializer.DefaultObjectSerializer;
|
import io.dapr.serializer.DefaultObjectSerializer;
|
||||||
import org.junit.Assert;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
import java.lang.reflect.Proxy;
|
import java.lang.reflect.Proxy;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.ArgumentMatchers.eq;
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
@ -153,7 +154,7 @@ public class ActorNoStateTest {
|
||||||
public void actorId() {
|
public void actorId() {
|
||||||
ActorProxy proxy = createActorProxy();
|
ActorProxy proxy = createActorProxy();
|
||||||
|
|
||||||
Assert.assertEquals(
|
Assertions.assertEquals(
|
||||||
proxy.getActorId().toString(),
|
proxy.getActorId().toString(),
|
||||||
proxy.invokeMethod("getMyId", String.class).block());
|
proxy.invokeMethod("getMyId", String.class).block());
|
||||||
}
|
}
|
||||||
|
@ -163,7 +164,7 @@ public class ActorNoStateTest {
|
||||||
ActorProxy proxy = createActorProxy();
|
ActorProxy proxy = createActorProxy();
|
||||||
|
|
||||||
// these should only call the actor methods for ActorChild. The implementations in ActorParent will throw.
|
// these should only call the actor methods for ActorChild. The implementations in ActorParent will throw.
|
||||||
Assert.assertEquals(
|
Assertions.assertEquals(
|
||||||
"abcabc",
|
"abcabc",
|
||||||
proxy.invokeMethod("stringInStringOut", "abc", String.class).block());
|
proxy.invokeMethod("stringInStringOut", "abc", String.class).block());
|
||||||
}
|
}
|
||||||
|
@ -173,21 +174,22 @@ public class ActorNoStateTest {
|
||||||
ActorProxy proxy = createActorProxy();
|
ActorProxy proxy = createActorProxy();
|
||||||
|
|
||||||
// these should only call the actor methods for ActorChild. The implementations in ActorParent will throw.
|
// these should only call the actor methods for ActorChild. The implementations in ActorParent will throw.
|
||||||
Assert.assertEquals(
|
Assertions.assertEquals(
|
||||||
false,
|
false,
|
||||||
proxy.invokeMethod("stringInBooleanOut", "hello world", Boolean.class).block());
|
proxy.invokeMethod("stringInBooleanOut", "hello world", Boolean.class).block());
|
||||||
|
|
||||||
Assert.assertEquals(
|
Assertions.assertEquals(
|
||||||
true,
|
true,
|
||||||
proxy.invokeMethod("stringInBooleanOut", "true", Boolean.class).block());
|
proxy.invokeMethod("stringInBooleanOut", "true", Boolean.class).block());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalMonitorStateException.class)
|
@Test
|
||||||
public void stringInVoidOutIntentionallyThrows() {
|
public void stringInVoidOutIntentionallyThrows() {
|
||||||
ActorProxy actorProxy = createActorProxy();
|
ActorProxy actorProxy = createActorProxy();
|
||||||
|
|
||||||
// these should only call the actor methods for ActorChild. The implementations in ActorParent will throw.
|
// these should only call the actor methods for ActorChild. The implementations in ActorParent will throw.
|
||||||
actorProxy.invokeMethod("stringInVoidOutIntentionallyThrows", "hello world").block();
|
assertThrows(IllegalMonitorStateException.class, () ->
|
||||||
|
actorProxy.invokeMethod("stringInVoidOutIntentionallyThrows", "hello world").block());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -204,30 +206,31 @@ public class ActorNoStateTest {
|
||||||
// this should only call the actor methods for ActorChild. The implementations in ActorParent will throw.
|
// this should only call the actor methods for ActorChild. The implementations in ActorParent will throw.
|
||||||
MyData response = actorProxy.invokeMethod("classInClassOut", d, MyData.class).block();
|
MyData response = actorProxy.invokeMethod("classInClassOut", d, MyData.class).block();
|
||||||
|
|
||||||
Assert.assertEquals(
|
Assertions.assertEquals(
|
||||||
"hihi",
|
"hihi",
|
||||||
response.getName());
|
response.getName());
|
||||||
Assert.assertEquals(
|
Assertions.assertEquals(
|
||||||
6,
|
6,
|
||||||
response.getNum());
|
response.getNum());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test
|
||||||
public void testBadTimerCallbackName() {
|
public void testBadTimerCallbackName() {
|
||||||
MyActor actor = createActorProxy(MyActor.class);
|
MyActor actor = createActorProxy(MyActor.class);
|
||||||
actor.registerBadCallbackName().block();
|
|
||||||
|
assertThrows(IllegalArgumentException.class, () -> actor.registerBadCallbackName().block());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAutoTimerName() {
|
public void testAutoTimerName() {
|
||||||
MyActor actor = createActorProxy(MyActor.class);
|
MyActor actor = createActorProxy(MyActor.class);
|
||||||
String firstTimer = actor.registerTimerAutoName();
|
String firstTimer = actor.registerTimerAutoName();
|
||||||
Assert.assertTrue((firstTimer != null) && !firstTimer.isEmpty());
|
Assertions.assertTrue((firstTimer != null) && !firstTimer.isEmpty());
|
||||||
|
|
||||||
String secondTimer = actor.registerTimerAutoName();
|
String secondTimer = actor.registerTimerAutoName();
|
||||||
Assert.assertTrue((secondTimer != null) && !secondTimer.isEmpty());
|
Assertions.assertTrue((secondTimer != null) && !secondTimer.isEmpty());
|
||||||
|
|
||||||
Assert.assertNotEquals(firstTimer, secondTimer);
|
Assertions.assertNotEquals(firstTimer, secondTimer);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ActorId newActorId() {
|
private static ActorId newActorId() {
|
||||||
|
|
|
@ -13,18 +13,20 @@ limitations under the License.
|
||||||
|
|
||||||
package io.dapr.actors.runtime;
|
package io.dapr.actors.runtime;
|
||||||
|
|
||||||
import org.junit.Assert;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
|
||||||
public class ActorReminderParamsTest {
|
public class ActorReminderParamsTest {
|
||||||
|
|
||||||
private static final ActorObjectSerializer SERIALIZER = new ActorObjectSerializer();
|
private static final ActorObjectSerializer SERIALIZER = new ActorObjectSerializer();
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test
|
||||||
public void outOfRangeDueTime() {
|
public void outOfRangeDueTime() {
|
||||||
ActorReminderParams info = new ActorReminderParams(null, Duration.ZERO.plusSeconds(-10), Duration.ZERO.plusMinutes(1));
|
assertThrows(IllegalArgumentException.class, () -> new ActorReminderParams(null, Duration.ZERO.plusSeconds(-10), Duration.ZERO.plusMinutes(1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -33,9 +35,9 @@ public class ActorReminderParamsTest {
|
||||||
ActorReminderParams info = new ActorReminderParams(null, Duration.ZERO.plusMinutes(1), Duration.ZERO.plusMillis(-1));
|
ActorReminderParams info = new ActorReminderParams(null, Duration.ZERO.plusMinutes(1), Duration.ZERO.plusMillis(-1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test
|
||||||
public void outOfRangePeriod() {
|
public void outOfRangePeriod() {
|
||||||
ActorReminderParams info = new ActorReminderParams(null, Duration.ZERO.plusMinutes(1), Duration.ZERO.plusMinutes(-10));
|
assertThrows(IllegalArgumentException.class, () ->new ActorReminderParams(null, Duration.ZERO.plusMinutes(1), Duration.ZERO.plusMinutes(-10)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -48,12 +50,12 @@ public class ActorReminderParamsTest {
|
||||||
}
|
}
|
||||||
catch(Exception e) {
|
catch(Exception e) {
|
||||||
System.out.println("The error is: " + e);
|
System.out.println("The error is: " + e);
|
||||||
Assert.fail();
|
Assertions.fail();
|
||||||
}
|
}
|
||||||
|
|
||||||
Assert.assertArrayEquals(original.getData(), recreated.getData());
|
Assertions.assertArrayEquals(original.getData(), recreated.getData());
|
||||||
Assert.assertEquals(original.getDueTime(), recreated.getDueTime());
|
Assertions.assertEquals(original.getDueTime(), recreated.getDueTime());
|
||||||
Assert.assertEquals(original.getPeriod(), recreated.getPeriod());
|
Assertions.assertEquals(original.getPeriod(), recreated.getPeriod());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -66,11 +68,11 @@ public class ActorReminderParamsTest {
|
||||||
}
|
}
|
||||||
catch(Exception e) {
|
catch(Exception e) {
|
||||||
System.out.println("The error is: " + e);
|
System.out.println("The error is: " + e);
|
||||||
Assert.fail();
|
Assertions.fail();
|
||||||
}
|
}
|
||||||
|
|
||||||
Assert.assertArrayEquals(original.getData(), recreated.getData());
|
Assertions.assertArrayEquals(original.getData(), recreated.getData());
|
||||||
Assert.assertEquals(original.getDueTime(), recreated.getDueTime());
|
Assertions.assertEquals(original.getDueTime(), recreated.getDueTime());
|
||||||
Assert.assertEquals(original.getPeriod(), recreated.getPeriod());
|
Assertions.assertEquals(original.getPeriod(), recreated.getPeriod());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,10 +16,10 @@ package io.dapr.actors.runtime;
|
||||||
import io.dapr.actors.ActorId;
|
import io.dapr.actors.ActorId;
|
||||||
import io.dapr.actors.ActorType;
|
import io.dapr.actors.ActorType;
|
||||||
import io.dapr.serializer.DefaultObjectSerializer;
|
import io.dapr.serializer.DefaultObjectSerializer;
|
||||||
import org.junit.Assert;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
|
@ -27,6 +27,7 @@ import java.time.Duration;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
|
||||||
public class ActorRuntimeTest {
|
public class ActorRuntimeTest {
|
||||||
|
@ -100,7 +101,7 @@ public class ActorRuntimeTest {
|
||||||
|
|
||||||
private ActorRuntime runtime;
|
private ActorRuntime runtime;
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeAll
|
||||||
public static void beforeAll() throws Exception {
|
public static void beforeAll() throws Exception {
|
||||||
constructor =
|
constructor =
|
||||||
(Constructor<ActorRuntime>) Arrays.stream(ActorRuntime.class.getDeclaredConstructors())
|
(Constructor<ActorRuntime>) Arrays.stream(ActorRuntime.class.getDeclaredConstructors())
|
||||||
|
@ -110,67 +111,67 @@ public class ActorRuntimeTest {
|
||||||
}).findFirst().get();
|
}).findFirst().get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setup() throws Exception {
|
public void setup() throws Exception {
|
||||||
this.mockDaprClient = mock(DaprClient.class);
|
this.mockDaprClient = mock(DaprClient.class);
|
||||||
this.runtime = constructor.newInstance(null, this.mockDaprClient);
|
this.runtime = constructor.newInstance(null, this.mockDaprClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test
|
||||||
public void registerActorNullClass() {
|
public void registerActorNullClass() {
|
||||||
this.runtime.registerActor(null);
|
assertThrows(IllegalArgumentException.class, () -> this.runtime.registerActor(null));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test
|
||||||
public void registerActorNullFactory() {
|
public void registerActorNullFactory() {
|
||||||
this.runtime.registerActor(MyActorImpl.class, null, new DefaultObjectSerializer(),
|
assertThrows(IllegalArgumentException.class, () -> this.runtime.registerActor(MyActorImpl.class, null, new DefaultObjectSerializer(),
|
||||||
new DefaultObjectSerializer());
|
new DefaultObjectSerializer()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test
|
||||||
public void registerActorNullSerializer() {
|
public void registerActorNullSerializer() {
|
||||||
this.runtime.registerActor(MyActorImpl.class, new DefaultActorFactory<>(), null,
|
assertThrows(IllegalArgumentException.class, () -> this.runtime.registerActor(MyActorImpl.class, new DefaultActorFactory<>(), null,
|
||||||
new DefaultObjectSerializer());
|
new DefaultObjectSerializer()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test
|
||||||
public void registerActorNullStateSerializer() {
|
public void registerActorNullStateSerializer() {
|
||||||
this.runtime.registerActor(MyActorImpl.class, new DefaultActorFactory<>(),
|
assertThrows(IllegalArgumentException.class, () -> this.runtime.registerActor(MyActorImpl.class, new DefaultActorFactory<>(),
|
||||||
new DefaultObjectSerializer(), null);
|
new DefaultObjectSerializer(), null));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void setActorIdleTimeout() throws Exception {
|
public void setActorIdleTimeout() throws Exception {
|
||||||
this.runtime.getConfig().setActorIdleTimeout(Duration.ofSeconds(123));
|
this.runtime.getConfig().setActorIdleTimeout(Duration.ofSeconds(123));
|
||||||
Assert.assertEquals("{\"entities\":[],\"actorIdleTimeout\":\"0h2m3s0ms\"}",
|
Assertions.assertEquals("{\"entities\":[],\"actorIdleTimeout\":\"0h2m3s0ms\"}",
|
||||||
new String(this.runtime.serializeConfig()));
|
new String(this.runtime.serializeConfig()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void setActorScanInterval() throws Exception {
|
public void setActorScanInterval() throws Exception {
|
||||||
this.runtime.getConfig().setActorScanInterval(Duration.ofSeconds(123));
|
this.runtime.getConfig().setActorScanInterval(Duration.ofSeconds(123));
|
||||||
Assert.assertEquals("{\"entities\":[],\"actorScanInterval\":\"0h2m3s0ms\"}",
|
Assertions.assertEquals("{\"entities\":[],\"actorScanInterval\":\"0h2m3s0ms\"}",
|
||||||
new String(this.runtime.serializeConfig()));
|
new String(this.runtime.serializeConfig()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void setDrainBalancedActors() throws Exception {
|
public void setDrainBalancedActors() throws Exception {
|
||||||
this.runtime.getConfig().setDrainBalancedActors(true);
|
this.runtime.getConfig().setDrainBalancedActors(true);
|
||||||
Assert.assertEquals("{\"entities\":[],\"drainBalancedActors\":true}",
|
Assertions.assertEquals("{\"entities\":[],\"drainBalancedActors\":true}",
|
||||||
new String(this.runtime.serializeConfig()));
|
new String(this.runtime.serializeConfig()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void setDrainOngoingCallTimeout() throws Exception {
|
public void setDrainOngoingCallTimeout() throws Exception {
|
||||||
this.runtime.getConfig().setDrainOngoingCallTimeout(Duration.ofSeconds(123));
|
this.runtime.getConfig().setDrainOngoingCallTimeout(Duration.ofSeconds(123));
|
||||||
Assert.assertEquals("{\"entities\":[],\"drainOngoingCallTimeout\":\"0h2m3s0ms\"}",
|
Assertions.assertEquals("{\"entities\":[],\"drainOngoingCallTimeout\":\"0h2m3s0ms\"}",
|
||||||
new String(this.runtime.serializeConfig()));
|
new String(this.runtime.serializeConfig()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void setRemindersStoragePartitions() throws Exception {
|
public void setRemindersStoragePartitions() throws Exception {
|
||||||
this.runtime.getConfig().setRemindersStoragePartitions(12);
|
this.runtime.getConfig().setRemindersStoragePartitions(12);
|
||||||
Assert.assertEquals("{\"entities\":[],\"remindersStoragePartitions\":12}",
|
Assertions.assertEquals("{\"entities\":[],\"remindersStoragePartitions\":12}",
|
||||||
new String(this.runtime.serializeConfig()));
|
new String(this.runtime.serializeConfig()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,15 +182,15 @@ public class ActorRuntimeTest {
|
||||||
|
|
||||||
byte[] response = this.runtime.invoke(ACTOR_NAME, actorId, "say", null).block();
|
byte[] response = this.runtime.invoke(ACTOR_NAME, actorId, "say", null).block();
|
||||||
String message = ACTOR_STATE_SERIALIZER.deserialize(response, String.class);
|
String message = ACTOR_STATE_SERIALIZER.deserialize(response, String.class);
|
||||||
Assert.assertEquals("Nothing to say.", message);
|
Assertions.assertEquals("Nothing to say.", message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test
|
||||||
public void invokeUnknownActor() {
|
public void invokeUnknownActor() {
|
||||||
String actorId = UUID.randomUUID().toString();
|
String actorId = UUID.randomUUID().toString();
|
||||||
this.runtime.registerActor(MyActorImpl.class);
|
this.runtime.registerActor(MyActorImpl.class);
|
||||||
|
|
||||||
this.runtime.invoke("UnknownActor", actorId, "say", null).block();
|
assertThrows(IllegalArgumentException.class, () -> this.runtime.invoke("UnknownActor", actorId, "say", null).block());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -211,8 +212,8 @@ public class ActorRuntimeTest {
|
||||||
deactivateCall.block();
|
deactivateCall.block();
|
||||||
|
|
||||||
this.runtime.invoke(ACTOR_NAME, actorId, "say", null)
|
this.runtime.invoke(ACTOR_NAME, actorId, "say", null)
|
||||||
.doOnError(e -> Assert.assertTrue(e.getMessage().contains("Could not find actor")))
|
.doOnError(e -> Assertions.assertTrue(e.getMessage().contains("Could not find actor")))
|
||||||
.doOnSuccess(s -> Assert.fail()).onErrorReturn("".getBytes()).block();
|
.doOnSuccess(s -> Assertions.fail()).onErrorReturn("".getBytes()).block();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -224,13 +225,13 @@ public class ActorRuntimeTest {
|
||||||
|
|
||||||
byte[] response = this.runtime.invoke(ACTOR_NAME, actorId, "count", null).block();
|
byte[] response = this.runtime.invoke(ACTOR_NAME, actorId, "count", null).block();
|
||||||
int count = ACTOR_STATE_SERIALIZER.deserialize(response, Integer.class);
|
int count = ACTOR_STATE_SERIALIZER.deserialize(response, Integer.class);
|
||||||
Assert.assertEquals(0, count);
|
Assertions.assertEquals(0, count);
|
||||||
|
|
||||||
invokeCall.block();
|
invokeCall.block();
|
||||||
|
|
||||||
response = this.runtime.invoke(ACTOR_NAME, actorId, "count", null).block();
|
response = this.runtime.invoke(ACTOR_NAME, actorId, "count", null).block();
|
||||||
count = ACTOR_STATE_SERIALIZER.deserialize(response, Integer.class);
|
count = ACTOR_STATE_SERIALIZER.deserialize(response, Integer.class);
|
||||||
Assert.assertEquals(1, count);
|
Assertions.assertEquals(1, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,8 +20,8 @@ import io.dapr.actors.client.ActorProxyImplForTests;
|
||||||
import io.dapr.actors.client.DaprClientStub;
|
import io.dapr.actors.client.DaprClientStub;
|
||||||
import io.dapr.serializer.DefaultObjectSerializer;
|
import io.dapr.serializer.DefaultObjectSerializer;
|
||||||
import io.dapr.utils.TypeRef;
|
import io.dapr.utils.TypeRef;
|
||||||
import org.junit.Assert;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -33,6 +33,7 @@ import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.ArgumentMatchers.eq;
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
@ -296,28 +297,28 @@ public class ActorStatefulTest {
|
||||||
@Test
|
@Test
|
||||||
public void happyGetSetDeleteContains() {
|
public void happyGetSetDeleteContains() {
|
||||||
ActorProxy proxy = newActorProxy();
|
ActorProxy proxy = newActorProxy();
|
||||||
Assert.assertEquals(
|
Assertions.assertEquals(
|
||||||
proxy.getActorId().toString(), proxy.invokeMethod("getIdString", String.class).block());
|
proxy.getActorId().toString(), proxy.invokeMethod("getIdString", String.class).block());
|
||||||
Assert.assertFalse(proxy.invokeMethod("hasMessage", Boolean.class).block());
|
Assertions.assertFalse(proxy.invokeMethod("hasMessage", Boolean.class).block());
|
||||||
|
|
||||||
proxy.invokeMethod("setMessage", "hello world").block();
|
proxy.invokeMethod("setMessage", "hello world").block();
|
||||||
Assert.assertTrue(proxy.invokeMethod("hasMessage", Boolean.class).block());
|
Assertions.assertTrue(proxy.invokeMethod("hasMessage", Boolean.class).block());
|
||||||
|
|
||||||
Assert.assertEquals(
|
Assertions.assertEquals(
|
||||||
"hello world", proxy.invokeMethod("getMessage", String.class).block());
|
"hello world", proxy.invokeMethod("getMessage", String.class).block());
|
||||||
|
|
||||||
Assert.assertEquals(
|
Assertions.assertEquals(
|
||||||
executeSayMethod("hello world"),
|
executeSayMethod("hello world"),
|
||||||
proxy.invokeMethod("setMessage", "hello world", String.class).block());
|
proxy.invokeMethod("setMessage", "hello world", String.class).block());
|
||||||
|
|
||||||
proxy.invokeMethod("deleteMessage").block();
|
proxy.invokeMethod("deleteMessage").block();
|
||||||
Assert.assertFalse(proxy.invokeMethod("hasMessage", Boolean.class).block());
|
Assertions.assertFalse(proxy.invokeMethod("hasMessage", Boolean.class).block());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalStateException.class)
|
@Test
|
||||||
public void lazyGet() {
|
public void lazyGet() {
|
||||||
ActorProxy proxy = newActorProxy();
|
ActorProxy proxy = newActorProxy();
|
||||||
Assert.assertFalse(proxy.invokeMethod("hasMessage", Boolean.class).block());
|
Assertions.assertFalse(proxy.invokeMethod("hasMessage", Boolean.class).block());
|
||||||
proxy.invokeMethod("setMessage", "first message").block();
|
proxy.invokeMethod("setMessage", "first message").block();
|
||||||
|
|
||||||
// Creates the mono plan but does not call it yet.
|
// Creates the mono plan but does not call it yet.
|
||||||
|
@ -326,30 +327,30 @@ public class ActorStatefulTest {
|
||||||
proxy.invokeMethod("deleteMessage").block();
|
proxy.invokeMethod("deleteMessage").block();
|
||||||
|
|
||||||
// Call should fail because the message was deleted.
|
// Call should fail because the message was deleted.
|
||||||
getMessageCall.block();
|
assertThrows(IllegalStateException.class, () -> getMessageCall.block());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void lazySet() {
|
public void lazySet() {
|
||||||
ActorProxy proxy = newActorProxy();
|
ActorProxy proxy = newActorProxy();
|
||||||
Assert.assertFalse(proxy.invokeMethod("hasMessage", Boolean.class).block());
|
Assertions.assertFalse(proxy.invokeMethod("hasMessage", Boolean.class).block());
|
||||||
|
|
||||||
// Creates the mono plan but does not call it yet.
|
// Creates the mono plan but does not call it yet.
|
||||||
Mono<Void> setMessageCall = proxy.invokeMethod("setMessage", "first message");
|
Mono<Void> setMessageCall = proxy.invokeMethod("setMessage", "first message");
|
||||||
|
|
||||||
// No call executed yet, so message should not be set.
|
// No call executed yet, so message should not be set.
|
||||||
Assert.assertFalse(proxy.invokeMethod("hasMessage", Boolean.class).block());
|
Assertions.assertFalse(proxy.invokeMethod("hasMessage", Boolean.class).block());
|
||||||
|
|
||||||
setMessageCall.block();
|
setMessageCall.block();
|
||||||
|
|
||||||
// Now the message has been set.
|
// Now the message has been set.
|
||||||
Assert.assertTrue(proxy.invokeMethod("hasMessage", Boolean.class).block());
|
Assertions.assertTrue(proxy.invokeMethod("hasMessage", Boolean.class).block());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void lazyContains() {
|
public void lazyContains() {
|
||||||
ActorProxy proxy = newActorProxy();
|
ActorProxy proxy = newActorProxy();
|
||||||
Assert.assertFalse(proxy.invokeMethod("hasMessage", Boolean.class).block());
|
Assertions.assertFalse(proxy.invokeMethod("hasMessage", Boolean.class).block());
|
||||||
|
|
||||||
// Creates the mono plan but does not call it yet.
|
// Creates the mono plan but does not call it yet.
|
||||||
Mono<Boolean> hasMessageCall = proxy.invokeMethod("hasMessage", Boolean.class);
|
Mono<Boolean> hasMessageCall = proxy.invokeMethod("hasMessage", Boolean.class);
|
||||||
|
@ -361,46 +362,46 @@ public class ActorStatefulTest {
|
||||||
hasMessageCall.block();
|
hasMessageCall.block();
|
||||||
|
|
||||||
// Now the message should be set.
|
// Now the message should be set.
|
||||||
Assert.assertTrue(proxy.invokeMethod("hasMessage", Boolean.class).block());
|
Assertions.assertTrue(proxy.invokeMethod("hasMessage", Boolean.class).block());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void lazyDelete() {
|
public void lazyDelete() {
|
||||||
ActorProxy proxy = newActorProxy();
|
ActorProxy proxy = newActorProxy();
|
||||||
Assert.assertFalse(proxy.invokeMethod("hasMessage", Boolean.class).block());
|
Assertions.assertFalse(proxy.invokeMethod("hasMessage", Boolean.class).block());
|
||||||
|
|
||||||
proxy.invokeMethod("setMessage", "first message").block();
|
proxy.invokeMethod("setMessage", "first message").block();
|
||||||
|
|
||||||
// Message is set.
|
// Message is set.
|
||||||
Assert.assertTrue(proxy.invokeMethod("hasMessage", Boolean.class).block());
|
Assertions.assertTrue(proxy.invokeMethod("hasMessage", Boolean.class).block());
|
||||||
|
|
||||||
// Created the mono plan but does not execute it yet.
|
// Created the mono plan but does not execute it yet.
|
||||||
Mono<Void> deleteMessageCall = proxy.invokeMethod("deleteMessage");
|
Mono<Void> deleteMessageCall = proxy.invokeMethod("deleteMessage");
|
||||||
|
|
||||||
// Message is still set.
|
// Message is still set.
|
||||||
Assert.assertTrue(proxy.invokeMethod("hasMessage", Boolean.class).block());
|
Assertions.assertTrue(proxy.invokeMethod("hasMessage", Boolean.class).block());
|
||||||
|
|
||||||
deleteMessageCall.block();
|
deleteMessageCall.block();
|
||||||
|
|
||||||
// Now message is not set.
|
// Now message is not set.
|
||||||
Assert.assertFalse(proxy.invokeMethod("hasMessage", Boolean.class).block());
|
Assertions.assertFalse(proxy.invokeMethod("hasMessage", Boolean.class).block());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void lazyAdd() {
|
public void lazyAdd() {
|
||||||
ActorProxy proxy = newActorProxy();
|
ActorProxy proxy = newActorProxy();
|
||||||
Assert.assertFalse(proxy.invokeMethod("hasMessage", Boolean.class).block());
|
Assertions.assertFalse(proxy.invokeMethod("hasMessage", Boolean.class).block());
|
||||||
|
|
||||||
proxy.invokeMethod("setMessage", "first message").block();
|
proxy.invokeMethod("setMessage", "first message").block();
|
||||||
|
|
||||||
// Message is set.
|
// Message is set.
|
||||||
Assert.assertTrue(proxy.invokeMethod("hasMessage", Boolean.class).block());
|
Assertions.assertTrue(proxy.invokeMethod("hasMessage", Boolean.class).block());
|
||||||
|
|
||||||
// Created the mono plan but does not execute it yet.
|
// Created the mono plan but does not execute it yet.
|
||||||
Mono<Void> addMessageCall = proxy.invokeMethod("addMessage", "second message");
|
Mono<Void> addMessageCall = proxy.invokeMethod("addMessage", "second message");
|
||||||
|
|
||||||
// Message is still set.
|
// Message is still set.
|
||||||
Assert.assertEquals("first message",
|
Assertions.assertEquals("first message",
|
||||||
proxy.invokeMethod("getMessage", String.class).block());
|
proxy.invokeMethod("getMessage", String.class).block());
|
||||||
|
|
||||||
// Delete message
|
// Delete message
|
||||||
|
@ -410,7 +411,7 @@ public class ActorStatefulTest {
|
||||||
addMessageCall.block();
|
addMessageCall.block();
|
||||||
|
|
||||||
// New message is still set.
|
// New message is still set.
|
||||||
Assert.assertEquals("second message",
|
Assertions.assertEquals("second message",
|
||||||
proxy.invokeMethod("getMessage", String.class).block());
|
proxy.invokeMethod("getMessage", String.class).block());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -418,14 +419,14 @@ public class ActorStatefulTest {
|
||||||
public void onActivateAndOnDeactivate() {
|
public void onActivateAndOnDeactivate() {
|
||||||
ActorProxy proxy = newActorProxy();
|
ActorProxy proxy = newActorProxy();
|
||||||
|
|
||||||
Assert.assertTrue(proxy.invokeMethod("isActive", Boolean.class).block());
|
Assertions.assertTrue(proxy.invokeMethod("isActive", Boolean.class).block());
|
||||||
Assert.assertFalse(DEACTIVATED_ACTOR_IDS.contains(proxy.getActorId().toString()));
|
Assertions.assertFalse(DEACTIVATED_ACTOR_IDS.contains(proxy.getActorId().toString()));
|
||||||
|
|
||||||
proxy.invokeMethod("hasMessage", Boolean.class).block();
|
proxy.invokeMethod("hasMessage", Boolean.class).block();
|
||||||
|
|
||||||
this.manager.deactivateActor(proxy.getActorId()).block();
|
this.manager.deactivateActor(proxy.getActorId()).block();
|
||||||
|
|
||||||
Assert.assertTrue(DEACTIVATED_ACTOR_IDS.contains(proxy.getActorId().toString()));
|
Assertions.assertTrue(DEACTIVATED_ACTOR_IDS.contains(proxy.getActorId().toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -436,13 +437,13 @@ public class ActorStatefulTest {
|
||||||
|
|
||||||
MyMethodContext preContext =
|
MyMethodContext preContext =
|
||||||
proxy.invokeMethod("getPreCallMethodContext", MyMethodContext.class).block();
|
proxy.invokeMethod("getPreCallMethodContext", MyMethodContext.class).block();
|
||||||
Assert.assertEquals("hasMessage", preContext.getName());
|
Assertions.assertEquals("hasMessage", preContext.getName());
|
||||||
Assert.assertEquals(ActorCallType.ACTOR_INTERFACE_METHOD.toString(), preContext.getType());
|
Assertions.assertEquals(ActorCallType.ACTOR_INTERFACE_METHOD.toString(), preContext.getType());
|
||||||
|
|
||||||
MyMethodContext postContext =
|
MyMethodContext postContext =
|
||||||
proxy.invokeMethod("getPostCallMethodContext", MyMethodContext.class).block();
|
proxy.invokeMethod("getPostCallMethodContext", MyMethodContext.class).block();
|
||||||
Assert.assertEquals("hasMessage", postContext.getName());
|
Assertions.assertEquals("hasMessage", postContext.getName());
|
||||||
Assert.assertEquals(ActorCallType.ACTOR_INTERFACE_METHOD.toString(), postContext.getType());
|
Assertions.assertEquals(ActorCallType.ACTOR_INTERFACE_METHOD.toString(), postContext.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -453,22 +454,23 @@ public class ActorStatefulTest {
|
||||||
|
|
||||||
MyMethodContext preContext =
|
MyMethodContext preContext =
|
||||||
proxy.invokeMethod("getPreCallMethodContext", MyMethodContext.class).block();
|
proxy.invokeMethod("getPreCallMethodContext", MyMethodContext.class).block();
|
||||||
Assert.assertEquals("mytimer", preContext.getName());
|
Assertions.assertEquals("mytimer", preContext.getName());
|
||||||
Assert.assertEquals(ActorCallType.TIMER_METHOD.toString(), preContext.getType());
|
Assertions.assertEquals(ActorCallType.TIMER_METHOD.toString(), preContext.getType());
|
||||||
|
|
||||||
MyMethodContext postContext =
|
MyMethodContext postContext =
|
||||||
proxy.invokeMethod("getPostCallMethodContext", MyMethodContext.class).block();
|
proxy.invokeMethod("getPostCallMethodContext", MyMethodContext.class).block();
|
||||||
Assert.assertEquals("mytimer", postContext.getName());
|
Assertions.assertEquals("mytimer", postContext.getName());
|
||||||
Assert.assertEquals(ActorCallType.TIMER_METHOD.toString(), postContext.getType());
|
Assertions.assertEquals(ActorCallType.TIMER_METHOD.toString(), postContext.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test
|
||||||
public void invokeTimerAfterDeactivate() {
|
public void invokeTimerAfterDeactivate() {
|
||||||
ActorProxy proxy = newActorProxy();
|
ActorProxy proxy = newActorProxy();
|
||||||
|
|
||||||
this.manager.deactivateActor(proxy.getActorId()).block();
|
this.manager.deactivateActor(proxy.getActorId()).block();
|
||||||
|
|
||||||
this.manager.invokeTimer(proxy.getActorId(), "mytimer", "{ \"callback\": \"hasMessage\" }".getBytes()).block();
|
assertThrows(IllegalArgumentException.class, () ->
|
||||||
|
this.manager.invokeTimer(proxy.getActorId(), "mytimer", "{ \"callback\": \"hasMessage\" }".getBytes()).block());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -499,16 +501,16 @@ public class ActorStatefulTest {
|
||||||
|
|
||||||
MyMethodContext preContext =
|
MyMethodContext preContext =
|
||||||
proxy.invokeMethod("getPreCallMethodContext", MyMethodContext.class).block();
|
proxy.invokeMethod("getPreCallMethodContext", MyMethodContext.class).block();
|
||||||
Assert.assertEquals("myreminder", preContext.getName());
|
Assertions.assertEquals("myreminder", preContext.getName());
|
||||||
Assert.assertEquals(ActorCallType.REMINDER_METHOD.toString(), preContext.getType());
|
Assertions.assertEquals(ActorCallType.REMINDER_METHOD.toString(), preContext.getType());
|
||||||
|
|
||||||
MyMethodContext postContext =
|
MyMethodContext postContext =
|
||||||
proxy.invokeMethod("getPostCallMethodContext", MyMethodContext.class).block();
|
proxy.invokeMethod("getPostCallMethodContext", MyMethodContext.class).block();
|
||||||
Assert.assertEquals("myreminder", postContext.getName());
|
Assertions.assertEquals("myreminder", postContext.getName());
|
||||||
Assert.assertEquals(ActorCallType.REMINDER_METHOD.toString(), postContext.getType());
|
Assertions.assertEquals(ActorCallType.REMINDER_METHOD.toString(), postContext.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test
|
||||||
public void invokeReminderAfterDeactivate() throws Exception {
|
public void invokeReminderAfterDeactivate() throws Exception {
|
||||||
ActorProxy proxy = newActorProxy();
|
ActorProxy proxy = newActorProxy();
|
||||||
|
|
||||||
|
@ -516,7 +518,7 @@ public class ActorStatefulTest {
|
||||||
|
|
||||||
byte[] params = createReminderParams("anything");
|
byte[] params = createReminderParams("anything");
|
||||||
|
|
||||||
this.manager.invokeReminder(proxy.getActorId(), "myreminder", params).block();
|
assertThrows(IllegalArgumentException.class, () -> this.manager.invokeReminder(proxy.getActorId(), "myreminder", params).block());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -528,58 +530,60 @@ public class ActorStatefulTest {
|
||||||
proxy.invokeMethod("setMethodContext", expectedContext).block();
|
proxy.invokeMethod("setMethodContext", expectedContext).block();
|
||||||
MyMethodContext context = proxy.invokeMethod("getMethodContext", MyMethodContext.class).block();
|
MyMethodContext context = proxy.invokeMethod("getMethodContext", MyMethodContext.class).block();
|
||||||
|
|
||||||
Assert.assertEquals(expectedContext.getName(), context.getName());
|
Assertions.assertEquals(expectedContext.getName(), context.getName());
|
||||||
Assert.assertEquals(expectedContext.getType(), context.getType());
|
Assertions.assertEquals(expectedContext.getType(), context.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void intTypeRequestResponseInStateStore() {
|
public void intTypeRequestResponseInStateStore() {
|
||||||
ActorProxy proxy = newActorProxy();
|
ActorProxy proxy = newActorProxy();
|
||||||
|
|
||||||
Assert.assertEquals(1, (int)proxy.invokeMethod("incrementAndGetCount", 1, int.class).block());
|
Assertions.assertEquals(1, (int)proxy.invokeMethod("incrementAndGetCount", 1, int.class).block());
|
||||||
Assert.assertEquals(6, (int)proxy.invokeMethod("incrementAndGetCount", 5, int.class).block());
|
Assertions.assertEquals(6, (int)proxy.invokeMethod("incrementAndGetCount", 5, int.class).block());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = NumberFormatException.class)
|
@Test
|
||||||
public void intTypeWithMethodException() {
|
public void intTypeWithMethodException() {
|
||||||
ActorProxy proxy = newActorProxy();
|
ActorProxy proxy = newActorProxy();
|
||||||
|
|
||||||
// Zero is a magic input that will make method throw an exception.
|
// Zero is a magic input that will make method throw an exception.
|
||||||
proxy.invokeMethod("incrementAndGetCount", 0, int.class).block();
|
assertThrows(NumberFormatException.class, () -> proxy.invokeMethod("incrementAndGetCount", 0, int.class).block());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalStateException.class)
|
@Test
|
||||||
public void intTypeWithRuntimeException() {
|
public void intTypeWithRuntimeException() {
|
||||||
ActorProxy proxy = newActorProxy();
|
ActorProxy proxy = newActorProxy();
|
||||||
|
|
||||||
proxy.invokeMethod("getCountButThrowsException", int.class).block();
|
assertThrows(RuntimeException.class, () ->
|
||||||
|
proxy.invokeMethod("getCountButThrowsException", int.class).block());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalStateException.class)
|
@Test
|
||||||
public void actorRuntimeException() {
|
public void actorRuntimeException() {
|
||||||
ActorProxy proxy = newActorProxy();
|
ActorProxy proxy = newActorProxy();
|
||||||
|
|
||||||
Assert.assertFalse(proxy.invokeMethod("hasMessage", Boolean.class).block());
|
Assertions.assertFalse(proxy.invokeMethod("hasMessage", Boolean.class).block());
|
||||||
|
|
||||||
proxy.invokeMethod("forceDuplicateException").block();
|
assertThrows(RuntimeException.class, () ->
|
||||||
|
proxy.invokeMethod("forceDuplicateException").block());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalCharsetNameException.class)
|
@Test
|
||||||
public void actorMethodException() {
|
public void actorMethodException() {
|
||||||
ActorProxy proxy = newActorProxy();
|
ActorProxy proxy = newActorProxy();
|
||||||
|
|
||||||
Assert.assertFalse(proxy.invokeMethod("hasMessage", Boolean.class).block());
|
Assertions.assertFalse(proxy.invokeMethod("hasMessage", Boolean.class).block());
|
||||||
|
|
||||||
proxy.invokeMethod("throwsWithoutSaving").block();
|
assertThrows(IllegalCharsetNameException.class, () -> proxy.invokeMethod("throwsWithoutSaving").block());
|
||||||
|
|
||||||
Assert.assertFalse(proxy.invokeMethod("hasMessage", Boolean.class).block());
|
Assertions.assertFalse(proxy.invokeMethod("hasMessage", Boolean.class).block());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void rollbackChanges() {
|
public void rollbackChanges() {
|
||||||
ActorProxy proxy = newActorProxy();
|
ActorProxy proxy = newActorProxy();
|
||||||
|
|
||||||
Assert.assertFalse(proxy.invokeMethod("hasMessage", Boolean.class).block());
|
Assertions.assertFalse(proxy.invokeMethod("hasMessage", Boolean.class).block());
|
||||||
|
|
||||||
// Runs a method that will add one message but fail because tries to add a second one.
|
// Runs a method that will add one message but fail because tries to add a second one.
|
||||||
proxy.invokeMethod("forceDuplicateException")
|
proxy.invokeMethod("forceDuplicateException")
|
||||||
|
@ -587,14 +591,14 @@ public class ActorStatefulTest {
|
||||||
.block();
|
.block();
|
||||||
|
|
||||||
// No message is set
|
// No message is set
|
||||||
Assert.assertFalse(proxy.invokeMethod("hasMessage", Boolean.class).block());
|
Assertions.assertFalse(proxy.invokeMethod("hasMessage", Boolean.class).block());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void partialChanges() {
|
public void partialChanges() {
|
||||||
ActorProxy proxy = newActorProxy();
|
ActorProxy proxy = newActorProxy();
|
||||||
|
|
||||||
Assert.assertFalse(proxy.invokeMethod("hasMessage", Boolean.class).block());
|
Assertions.assertFalse(proxy.invokeMethod("hasMessage", Boolean.class).block());
|
||||||
|
|
||||||
// Runs a method that will add one message, commit but fail because tries to add a second one.
|
// Runs a method that will add one message, commit but fail because tries to add a second one.
|
||||||
proxy.invokeMethod("forcePartialChange")
|
proxy.invokeMethod("forcePartialChange")
|
||||||
|
@ -602,10 +606,10 @@ public class ActorStatefulTest {
|
||||||
.block();
|
.block();
|
||||||
|
|
||||||
// Message is set.
|
// Message is set.
|
||||||
Assert.assertTrue(proxy.invokeMethod("hasMessage", Boolean.class).block());
|
Assertions.assertTrue(proxy.invokeMethod("hasMessage", Boolean.class).block());
|
||||||
|
|
||||||
// It is first message and not the second due to a save() in the middle but an exception in the end.
|
// It is first message and not the second due to a save() in the middle but an exception in the end.
|
||||||
Assert.assertEquals("first message",
|
Assertions.assertEquals("first message",
|
||||||
proxy.invokeMethod("getMessage", String.class).block());
|
proxy.invokeMethod("getMessage", String.class).block());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,8 @@ limitations under the License.
|
||||||
package io.dapr.actors.runtime;
|
package io.dapr.actors.runtime;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import org.junit.Assert;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
@ -43,7 +43,7 @@ public class ActorTimerTest {
|
||||||
|
|
||||||
String expected = "{\"period\":\"1h0m3s0ms\",\"dueTime\":\"0h7m17s0ms\", \"callback\": \"myfunction\"}";
|
String expected = "{\"period\":\"1h0m3s0ms\",\"dueTime\":\"0h7m17s0ms\", \"callback\": \"myfunction\"}";
|
||||||
// Deep comparison via JsonNode.equals method.
|
// Deep comparison via JsonNode.equals method.
|
||||||
Assert.assertEquals(OBJECT_MAPPER.readTree(expected), OBJECT_MAPPER.readTree(s));
|
Assertions.assertEquals(OBJECT_MAPPER.readTree(expected), OBJECT_MAPPER.readTree(s));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -67,6 +67,6 @@ public class ActorTimerTest {
|
||||||
// A negative period will be serialized to an empty string which is interpreted by Dapr to mean fire once only.
|
// A negative period will be serialized to an empty string which is interpreted by Dapr to mean fire once only.
|
||||||
String expected = "{\"period\":\"\",\"dueTime\":\"0h7m17s0ms\", \"callback\": \"myfunction\"}";
|
String expected = "{\"period\":\"\",\"dueTime\":\"0h7m17s0ms\", \"callback\": \"myfunction\"}";
|
||||||
// Deep comparison via JsonNode.equals method.
|
// Deep comparison via JsonNode.equals method.
|
||||||
Assert.assertEquals(OBJECT_MAPPER.readTree(expected), OBJECT_MAPPER.readTree(s));
|
Assertions.assertEquals(OBJECT_MAPPER.readTree(expected), OBJECT_MAPPER.readTree(s));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,8 +15,8 @@ package io.dapr.actors.runtime;
|
||||||
|
|
||||||
import io.dapr.actors.ActorType;
|
import io.dapr.actors.ActorType;
|
||||||
import io.dapr.utils.TypeRef;
|
import io.dapr.utils.TypeRef;
|
||||||
import org.junit.Assert;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
@ -52,13 +52,13 @@ public class ActorTypeInformationTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
ActorTypeInformation info = ActorTypeInformation.create(A.class);
|
ActorTypeInformation info = ActorTypeInformation.create(A.class);
|
||||||
Assert.assertNotNull(info);
|
Assertions.assertNotNull(info);
|
||||||
Assert.assertEquals("A", info.getName());
|
Assertions.assertEquals("A", info.getName());
|
||||||
Assert.assertEquals(A.class, info.getImplementationClass());
|
Assertions.assertEquals(A.class, info.getImplementationClass());
|
||||||
Assert.assertFalse(info.isAbstractClass());
|
Assertions.assertFalse(info.isAbstractClass());
|
||||||
Assert.assertFalse(info.isRemindable());
|
Assertions.assertFalse(info.isRemindable());
|
||||||
Assert.assertEquals(1, info.getInterfaces().size());
|
Assertions.assertEquals(1, info.getInterfaces().size());
|
||||||
Assert.assertTrue(info.getInterfaces().contains(MyActor.class));
|
Assertions.assertTrue(info.getInterfaces().contains(MyActor.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -84,14 +84,14 @@ public class ActorTypeInformationTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
ActorTypeInformation info = ActorTypeInformation.create(A.class);
|
ActorTypeInformation info = ActorTypeInformation.create(A.class);
|
||||||
Assert.assertNotNull(info);
|
Assertions.assertNotNull(info);
|
||||||
Assert.assertEquals("A", info.getName());
|
Assertions.assertEquals("A", info.getName());
|
||||||
Assert.assertEquals(A.class, info.getImplementationClass());
|
Assertions.assertEquals(A.class, info.getImplementationClass());
|
||||||
Assert.assertFalse(info.isAbstractClass());
|
Assertions.assertFalse(info.isAbstractClass());
|
||||||
Assert.assertTrue(info.isRemindable());
|
Assertions.assertTrue(info.isRemindable());
|
||||||
Assert.assertEquals(2, info.getInterfaces().size());
|
Assertions.assertEquals(2, info.getInterfaces().size());
|
||||||
Assert.assertTrue(info.getInterfaces().contains(Remindable.class));
|
Assertions.assertTrue(info.getInterfaces().contains(Remindable.class));
|
||||||
Assert.assertTrue(info.getInterfaces().contains(MyActor.class));
|
Assertions.assertTrue(info.getInterfaces().contains(MyActor.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -107,13 +107,13 @@ public class ActorTypeInformationTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
ActorTypeInformation info = ActorTypeInformation.create(A.class);
|
ActorTypeInformation info = ActorTypeInformation.create(A.class);
|
||||||
Assert.assertNotNull(info);
|
Assertions.assertNotNull(info);
|
||||||
Assert.assertEquals("B", info.getName());
|
Assertions.assertEquals("B", info.getName());
|
||||||
Assert.assertEquals(A.class, info.getImplementationClass());
|
Assertions.assertEquals(A.class, info.getImplementationClass());
|
||||||
Assert.assertFalse(info.isAbstractClass());
|
Assertions.assertFalse(info.isAbstractClass());
|
||||||
Assert.assertFalse(info.isRemindable());
|
Assertions.assertFalse(info.isRemindable());
|
||||||
Assert.assertEquals(1, info.getInterfaces().size());
|
Assertions.assertEquals(1, info.getInterfaces().size());
|
||||||
Assert.assertTrue(info.getInterfaces().contains(MyActor.class));
|
Assertions.assertTrue(info.getInterfaces().contains(MyActor.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -128,13 +128,13 @@ public class ActorTypeInformationTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
ActorTypeInformation info = ActorTypeInformation.create(A.class);
|
ActorTypeInformation info = ActorTypeInformation.create(A.class);
|
||||||
Assert.assertNotNull(info);
|
Assertions.assertNotNull(info);
|
||||||
Assert.assertEquals("MyActorWithAnnotation", info.getName());
|
Assertions.assertEquals("MyActorWithAnnotation", info.getName());
|
||||||
Assert.assertEquals(A.class, info.getImplementationClass());
|
Assertions.assertEquals(A.class, info.getImplementationClass());
|
||||||
Assert.assertFalse(info.isAbstractClass());
|
Assertions.assertFalse(info.isAbstractClass());
|
||||||
Assert.assertFalse(info.isRemindable());
|
Assertions.assertFalse(info.isRemindable());
|
||||||
Assert.assertEquals(1, info.getInterfaces().size());
|
Assertions.assertEquals(1, info.getInterfaces().size());
|
||||||
Assert.assertTrue(info.getInterfaces().contains(MyActorAnnotated.class));
|
Assertions.assertTrue(info.getInterfaces().contains(MyActorAnnotated.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -149,6 +149,6 @@ public class ActorTypeInformationTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
ActorTypeInformation info = ActorTypeInformation.tryCreate(A.class);
|
ActorTypeInformation info = ActorTypeInformation.tryCreate(A.class);
|
||||||
Assert.assertNull(info);
|
Assertions.assertNull(info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,14 +14,14 @@ package io.dapr.actors.runtime;
|
||||||
|
|
||||||
import io.dapr.actors.ActorId;
|
import io.dapr.actors.ActorId;
|
||||||
import io.dapr.utils.TypeRef;
|
import io.dapr.utils.TypeRef;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
import java.io.Closeable;
|
import java.io.Closeable;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
public class ActorTypeUtilitiesTest {
|
public class ActorTypeUtilitiesTest {
|
||||||
|
|
||||||
|
|
|
@ -27,9 +27,9 @@ import io.grpc.inprocess.InProcessChannelBuilder;
|
||||||
import io.grpc.inprocess.InProcessServerBuilder;
|
import io.grpc.inprocess.InProcessServerBuilder;
|
||||||
import io.grpc.stub.StreamObserver;
|
import io.grpc.stub.StreamObserver;
|
||||||
import io.grpc.testing.GrpcCleanupRule;
|
import io.grpc.testing.GrpcCleanupRule;
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -39,7 +39,7 @@ import java.util.List;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
import static io.dapr.actors.TestUtils.assertThrowsDaprException;
|
import static io.dapr.actors.TestUtils.assertThrowsDaprException;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
|
||||||
public class DaprGrpcClientTest {
|
public class DaprGrpcClientTest {
|
||||||
|
@ -71,7 +71,7 @@ public class DaprGrpcClientTest {
|
||||||
@Rule
|
@Rule
|
||||||
public final GrpcCleanupRule grpcCleanup = new GrpcCleanupRule();
|
public final GrpcCleanupRule grpcCleanup = new GrpcCleanupRule();
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setup() throws IOException {
|
public void setup() throws IOException {
|
||||||
// Generate a unique in-process server name.
|
// Generate a unique in-process server name.
|
||||||
String serverName = InProcessServerBuilder.generateName();
|
String serverName = InProcessServerBuilder.generateName();
|
||||||
|
|
|
@ -24,8 +24,8 @@ import okhttp3.mock.Behavior;
|
||||||
import okhttp3.mock.MockInterceptor;
|
import okhttp3.mock.MockInterceptor;
|
||||||
import okhttp3.mock.RuleAnswer;
|
import okhttp3.mock.RuleAnswer;
|
||||||
import okio.Buffer;
|
import okio.Buffer;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -35,8 +35,8 @@ import java.util.Base64;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
import static org.junit.jupiter.api.Assertions.fail;
|
import static org.junit.jupiter.api.Assertions.fail;
|
||||||
|
|
||||||
public class DaprHttpClientTest {
|
public class DaprHttpClientTest {
|
||||||
|
@ -49,7 +49,7 @@ public class DaprHttpClientTest {
|
||||||
|
|
||||||
private final String EXPECTED_RESULT = "{\"data\":\"ewoJCSJwcm9wZXJ0eUEiOiAidmFsdWVBIiwKCQkicHJvcGVydHlCIjogInZhbHVlQiIKCX0=\"}";
|
private final String EXPECTED_RESULT = "{\"data\":\"ewoJCSJwcm9wZXJ0eUEiOiAidmFsdWVBIiwKCQkicHJvcGVydHlCIjogInZhbHVlQiIKCX0=\"}";
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
mockInterceptor = new MockInterceptor(Behavior.UNORDERED);
|
mockInterceptor = new MockInterceptor(Behavior.UNORDERED);
|
||||||
okHttpClient = new OkHttpClient.Builder().addInterceptor(mockInterceptor).build();
|
okHttpClient = new OkHttpClient.Builder().addInterceptor(mockInterceptor).build();
|
||||||
|
|
|
@ -18,8 +18,8 @@ import io.dapr.actors.ActorId;
|
||||||
import io.dapr.serializer.DaprObjectSerializer;
|
import io.dapr.serializer.DaprObjectSerializer;
|
||||||
import io.dapr.serializer.DefaultObjectSerializer;
|
import io.dapr.serializer.DefaultObjectSerializer;
|
||||||
import io.dapr.utils.TypeRef;
|
import io.dapr.utils.TypeRef;
|
||||||
import org.junit.Assert;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -180,28 +180,28 @@ public class DaprStateAsyncProviderTest {
|
||||||
|
|
||||||
DaprStateAsyncProvider provider = new DaprStateAsyncProvider(daprClient, SERIALIZER);
|
DaprStateAsyncProvider provider = new DaprStateAsyncProvider(daprClient, SERIALIZER);
|
||||||
|
|
||||||
Assert.assertEquals("Jon Doe",
|
Assertions.assertEquals("Jon Doe",
|
||||||
provider.load("MyActor", new ActorId("123"), "name", TypeRef.STRING).block());
|
provider.load("MyActor", new ActorId("123"), "name", TypeRef.STRING).block());
|
||||||
Assert.assertEquals(98021,
|
Assertions.assertEquals(98021,
|
||||||
(int) provider.load("MyActor", new ActorId("123"), "zipcode", TypeRef.INT).block());
|
(int) provider.load("MyActor", new ActorId("123"), "zipcode", TypeRef.INT).block());
|
||||||
Assert.assertEquals(98,
|
Assertions.assertEquals(98,
|
||||||
(int) provider.load("MyActor", new ActorId("123"), "goals", TypeRef.INT).block());
|
(int) provider.load("MyActor", new ActorId("123"), "goals", TypeRef.INT).block());
|
||||||
Assert.assertEquals(98,
|
Assertions.assertEquals(98,
|
||||||
(int) provider.load("MyActor", new ActorId("123"), "goals", TypeRef.INT).block());
|
(int) provider.load("MyActor", new ActorId("123"), "goals", TypeRef.INT).block());
|
||||||
Assert.assertEquals(46.55,
|
Assertions.assertEquals(46.55,
|
||||||
(double) provider.load("MyActor", new ActorId("123"), "balance", TypeRef.DOUBLE).block(),
|
(double) provider.load("MyActor", new ActorId("123"), "balance", TypeRef.DOUBLE).block(),
|
||||||
EPSILON);
|
EPSILON);
|
||||||
Assert.assertEquals(true,
|
Assertions.assertEquals(true,
|
||||||
(boolean) provider.load("MyActor", new ActorId("123"), "active", TypeRef.BOOLEAN).block());
|
(boolean) provider.load("MyActor", new ActorId("123"), "active", TypeRef.BOOLEAN).block());
|
||||||
Assert.assertEquals(new Customer().setId(1000).setName("Roxane"),
|
Assertions.assertEquals(new Customer().setId(1000).setName("Roxane"),
|
||||||
provider.load("MyActor", new ActorId("123"), "customer", TypeRef.get(Customer.class)).block());
|
provider.load("MyActor", new ActorId("123"), "customer", TypeRef.get(Customer.class)).block());
|
||||||
Assert.assertNotEquals(new Customer().setId(1000).setName("Roxane"),
|
Assertions.assertNotEquals(new Customer().setId(1000).setName("Roxane"),
|
||||||
provider.load("MyActor", new ActorId("123"), "anotherCustomer", TypeRef.get(Customer.class)).block());
|
provider.load("MyActor", new ActorId("123"), "anotherCustomer", TypeRef.get(Customer.class)).block());
|
||||||
Assert.assertNull(
|
Assertions.assertNull(
|
||||||
provider.load("MyActor", new ActorId("123"), "nullCustomer", TypeRef.get(Customer.class)).block());
|
provider.load("MyActor", new ActorId("123"), "nullCustomer", TypeRef.get(Customer.class)).block());
|
||||||
Assert.assertArrayEquals("A".getBytes(),
|
Assertions.assertArrayEquals("A".getBytes(),
|
||||||
provider.load("MyActor", new ActorId("123"), "bytes", TypeRef.get(byte[].class)).block());
|
provider.load("MyActor", new ActorId("123"), "bytes", TypeRef.get(byte[].class)).block());
|
||||||
Assert.assertNull(
|
Assertions.assertNull(
|
||||||
provider.load("MyActor", new ActorId("123"), "emptyBytes", TypeRef.get(byte[].class)).block());
|
provider.load("MyActor", new ActorId("123"), "emptyBytes", TypeRef.get(byte[].class)).block());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,15 +242,15 @@ public class DaprStateAsyncProviderTest {
|
||||||
|
|
||||||
DaprStateAsyncProvider provider = new DaprStateAsyncProvider(daprClient, SERIALIZER);
|
DaprStateAsyncProvider provider = new DaprStateAsyncProvider(daprClient, SERIALIZER);
|
||||||
|
|
||||||
Assert.assertTrue(provider.contains("MyActor", new ActorId("123"), "name").block());
|
Assertions.assertTrue(provider.contains("MyActor", new ActorId("123"), "name").block());
|
||||||
Assert.assertFalse(provider.contains("MyActor", new ActorId("123"), "NAME").block());
|
Assertions.assertFalse(provider.contains("MyActor", new ActorId("123"), "NAME").block());
|
||||||
Assert.assertTrue(provider.contains("MyActor", new ActorId("123"), "zipcode").block());
|
Assertions.assertTrue(provider.contains("MyActor", new ActorId("123"), "zipcode").block());
|
||||||
Assert.assertTrue(provider.contains("MyActor", new ActorId("123"), "goals").block());
|
Assertions.assertTrue(provider.contains("MyActor", new ActorId("123"), "goals").block());
|
||||||
Assert.assertTrue(provider.contains("MyActor", new ActorId("123"), "balance").block());
|
Assertions.assertTrue(provider.contains("MyActor", new ActorId("123"), "balance").block());
|
||||||
Assert.assertTrue(provider.contains("MyActor", new ActorId("123"), "active").block());
|
Assertions.assertTrue(provider.contains("MyActor", new ActorId("123"), "active").block());
|
||||||
Assert.assertTrue(provider.contains("MyActor", new ActorId("123"), "customer").block());
|
Assertions.assertTrue(provider.contains("MyActor", new ActorId("123"), "customer").block());
|
||||||
Assert.assertFalse(provider.contains("MyActor", new ActorId("123"), "Does not exist").block());
|
Assertions.assertFalse(provider.contains("MyActor", new ActorId("123"), "Does not exist").block());
|
||||||
Assert.assertFalse(provider.contains("MyActor", new ActorId("123"), null).block());
|
Assertions.assertFalse(provider.contains("MyActor", new ActorId("123"), null).block());
|
||||||
}
|
}
|
||||||
|
|
||||||
private final <T> ActorStateChange createInsertChange(String name, T value) {
|
private final <T> ActorStateChange createInsertChange(String name, T value) {
|
||||||
|
|
|
@ -15,9 +15,10 @@ package io.dapr.actors.runtime;
|
||||||
|
|
||||||
import io.dapr.actors.ActorId;
|
import io.dapr.actors.ActorId;
|
||||||
import io.dapr.serializer.DaprObjectSerializer;
|
import io.dapr.serializer.DaprObjectSerializer;
|
||||||
import org.junit.Assert;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -60,20 +61,21 @@ public class DefaultActorFactoryTest {
|
||||||
ActorId actorId = ActorId.createRandom();
|
ActorId actorId = ActorId.createRandom();
|
||||||
MyActor actor = factory.createActor(createActorRuntimeContext(MyActor.class), actorId);
|
MyActor actor = factory.createActor(createActorRuntimeContext(MyActor.class), actorId);
|
||||||
|
|
||||||
Assert.assertEquals(actorId, actor.actorId);
|
Assertions.assertEquals(actorId, actor.actorId);
|
||||||
Assert.assertNotNull(actor.context);
|
Assertions.assertNotNull(actor.context);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class is not an actor.
|
* Class is not an actor.
|
||||||
*/
|
*/
|
||||||
@Test(expected = RuntimeException.class)
|
@Test
|
||||||
public void noValidConstructor() {
|
public void noValidConstructor() {
|
||||||
DefaultActorFactory<InvalidActor> factory = new DefaultActorFactory<>();
|
DefaultActorFactory<InvalidActor> factory = new DefaultActorFactory<>();
|
||||||
|
|
||||||
ActorId actorId = ActorId.createRandom();
|
ActorId actorId = ActorId.createRandom();
|
||||||
|
|
||||||
factory.createActor(createActorRuntimeContext(InvalidActor.class), actorId);
|
assertThrows(RuntimeException.class, () ->
|
||||||
|
factory.createActor(createActorRuntimeContext(InvalidActor.class), actorId));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <T extends AbstractActor> ActorRuntimeContext<T> createActorRuntimeContext(Class<T> clazz) {
|
private static <T extends AbstractActor> ActorRuntimeContext<T> createActorRuntimeContext(Class<T> clazz) {
|
||||||
|
|
|
@ -19,12 +19,13 @@ import io.dapr.actors.client.ActorProxy;
|
||||||
import io.dapr.actors.client.ActorProxyImplForTests;
|
import io.dapr.actors.client.ActorProxyImplForTests;
|
||||||
import io.dapr.actors.client.DaprClientStub;
|
import io.dapr.actors.client.DaprClientStub;
|
||||||
import io.dapr.serializer.DefaultObjectSerializer;
|
import io.dapr.serializer.DefaultObjectSerializer;
|
||||||
import org.junit.Assert;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.ArgumentMatchers.eq;
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
@ -229,7 +230,7 @@ public class DerivedActorTest {
|
||||||
ActorProxy proxy = createActorProxyForActorChild();
|
ActorProxy proxy = createActorProxyForActorChild();
|
||||||
|
|
||||||
// these should only call the actor methods for ActorChild. The implementations in ActorParent will throw.
|
// these should only call the actor methods for ActorChild. The implementations in ActorParent will throw.
|
||||||
Assert.assertEquals(
|
Assertions.assertEquals(
|
||||||
"abcabc",
|
"abcabc",
|
||||||
proxy.invokeMethod("stringInStringOut", "abc", String.class).block());
|
proxy.invokeMethod("stringInStringOut", "abc", String.class).block());
|
||||||
}
|
}
|
||||||
|
@ -239,11 +240,11 @@ public class DerivedActorTest {
|
||||||
ActorProxy proxy = createActorProxyForActorChild();
|
ActorProxy proxy = createActorProxyForActorChild();
|
||||||
|
|
||||||
// these should only call the actor methods for ActorChild. The implementations in ActorParent will throw.
|
// these should only call the actor methods for ActorChild. The implementations in ActorParent will throw.
|
||||||
Assert.assertEquals(
|
Assertions.assertEquals(
|
||||||
false,
|
false,
|
||||||
proxy.invokeMethod("stringInBooleanOut", "hello world", Boolean.class).block());
|
proxy.invokeMethod("stringInBooleanOut", "hello world", Boolean.class).block());
|
||||||
|
|
||||||
Assert.assertEquals(
|
Assertions.assertEquals(
|
||||||
true,
|
true,
|
||||||
proxy.invokeMethod("stringInBooleanOut", "true", Boolean.class).block());
|
proxy.invokeMethod("stringInBooleanOut", "true", Boolean.class).block());
|
||||||
}
|
}
|
||||||
|
@ -253,24 +254,26 @@ public class DerivedActorTest {
|
||||||
ActorProxy actorProxy = createActorProxyForActorChild();
|
ActorProxy actorProxy = createActorProxyForActorChild();
|
||||||
|
|
||||||
// stringInVoidOut() has not been invoked so this is false
|
// stringInVoidOut() has not been invoked so this is false
|
||||||
Assert.assertEquals(
|
Assertions.assertEquals(
|
||||||
false,
|
false,
|
||||||
actorProxy.invokeMethod("methodReturningVoidInvoked", Boolean.class).block());
|
actorProxy.invokeMethod("methodReturningVoidInvoked", Boolean.class).block());
|
||||||
|
|
||||||
// these should only call the actor methods for ActorChild. The implementations in ActorParent will throw.
|
// these should only call the actor methods for ActorChild. The implementations in ActorParent will throw.
|
||||||
actorProxy.invokeMethod("stringInVoidOut", "hello world").block();
|
actorProxy.invokeMethod("stringInVoidOut", "hello world").block();
|
||||||
|
|
||||||
Assert.assertEquals(
|
Assertions.assertEquals(
|
||||||
true,
|
true,
|
||||||
actorProxy.invokeMethod("methodReturningVoidInvoked", Boolean.class).block());
|
actorProxy.invokeMethod("methodReturningVoidInvoked", Boolean.class).block());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalMonitorStateException.class)
|
@Test
|
||||||
public void stringInVoidOutIntentionallyThrows() {
|
public void stringInVoidOutIntentionallyThrows() {
|
||||||
ActorProxy actorProxy = createActorProxyForActorChild();
|
ActorProxy actorProxy = createActorProxyForActorChild();
|
||||||
|
|
||||||
// these should only call the actor methods for ActorChild. The implementations in ActorParent will throw.
|
// these should only call the actor methods for ActorChild. The implementations in ActorParent will throw.
|
||||||
actorProxy.invokeMethod("stringInVoidOutIntentionallyThrows", "hello world").block();
|
|
||||||
|
assertThrows(IllegalMonitorStateException.class, () ->
|
||||||
|
actorProxy.invokeMethod("stringInVoidOutIntentionallyThrows", "hello world").block());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -281,10 +284,10 @@ public class DerivedActorTest {
|
||||||
// this should only call the actor methods for ActorChild. The implementations in ActorParent will throw.
|
// this should only call the actor methods for ActorChild. The implementations in ActorParent will throw.
|
||||||
MyData response = actorProxy.invokeMethod("classInClassOut", d, MyData.class).block();
|
MyData response = actorProxy.invokeMethod("classInClassOut", d, MyData.class).block();
|
||||||
|
|
||||||
Assert.assertEquals(
|
Assertions.assertEquals(
|
||||||
"hihi",
|
"hihi",
|
||||||
response.getName());
|
response.getName());
|
||||||
Assert.assertEquals(
|
Assertions.assertEquals(
|
||||||
6,
|
6,
|
||||||
response.getNum());
|
response.getNum());
|
||||||
}
|
}
|
||||||
|
@ -294,33 +297,33 @@ public class DerivedActorTest {
|
||||||
public void testInheritedActorMethods() {
|
public void testInheritedActorMethods() {
|
||||||
ActorProxy actorProxy = createActorProxyForActorChild();
|
ActorProxy actorProxy = createActorProxyForActorChild();
|
||||||
|
|
||||||
Assert.assertEquals(
|
Assertions.assertEquals(
|
||||||
"www",
|
"www",
|
||||||
actorProxy.invokeMethod("onlyImplementedInParentStringInStringOut", "w", String.class).block());
|
actorProxy.invokeMethod("onlyImplementedInParentStringInStringOut", "w", String.class).block());
|
||||||
|
|
||||||
Assert.assertEquals(
|
Assertions.assertEquals(
|
||||||
true,
|
true,
|
||||||
actorProxy.invokeMethod("onlyImplementedInParentStringInBooleanOut", "icecream", Boolean.class).block());
|
actorProxy.invokeMethod("onlyImplementedInParentStringInBooleanOut", "icecream", Boolean.class).block());
|
||||||
|
|
||||||
// onlyImplementedInParentStringInVoidOut() has not been invoked so this is false
|
// onlyImplementedInParentStringInVoidOut() has not been invoked so this is false
|
||||||
Assert.assertEquals(
|
Assertions.assertEquals(
|
||||||
false,
|
false,
|
||||||
actorProxy.invokeMethod("methodReturningVoidInvoked", Boolean.class).block());
|
actorProxy.invokeMethod("methodReturningVoidInvoked", Boolean.class).block());
|
||||||
|
|
||||||
actorProxy.invokeMethod("onlyImplementedInParentStringInVoidOut", "icecream", Boolean.class).block();
|
actorProxy.invokeMethod("onlyImplementedInParentStringInVoidOut", "icecream", Boolean.class).block();
|
||||||
|
|
||||||
// now it should return true.
|
// now it should return true.
|
||||||
Assert.assertEquals(
|
Assertions.assertEquals(
|
||||||
true,
|
true,
|
||||||
actorProxy.invokeMethod("methodReturningVoidInvoked", Boolean.class).block());
|
actorProxy.invokeMethod("methodReturningVoidInvoked", Boolean.class).block());
|
||||||
|
|
||||||
MyData d = new MyData("hi", 3);
|
MyData d = new MyData("hi", 3);
|
||||||
MyData response = actorProxy.invokeMethod("onlyImplementedInParentClassInClassOut", d, MyData.class).block();
|
MyData response = actorProxy.invokeMethod("onlyImplementedInParentClassInClassOut", d, MyData.class).block();
|
||||||
|
|
||||||
Assert.assertEquals(
|
Assertions.assertEquals(
|
||||||
"hihihi",
|
"hihihi",
|
||||||
response.getName());
|
response.getName());
|
||||||
Assert.assertEquals(
|
Assertions.assertEquals(
|
||||||
9,
|
9,
|
||||||
response.getNum());
|
response.getNum());
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,12 +19,13 @@ import io.dapr.actors.client.ActorProxy;
|
||||||
import io.dapr.actors.client.ActorProxyImplForTests;
|
import io.dapr.actors.client.ActorProxyImplForTests;
|
||||||
import io.dapr.actors.client.DaprClientStub;
|
import io.dapr.actors.client.DaprClientStub;
|
||||||
import io.dapr.serializer.DefaultObjectSerializer;
|
import io.dapr.serializer.DefaultObjectSerializer;
|
||||||
import org.junit.Assert;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.ArgumentMatchers.eq;
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
@ -122,25 +123,23 @@ public class ThrowFromPreAndPostActorMethodsTest {
|
||||||
|
|
||||||
// IllegalMonitorStateException should be intentionally thrown. This type was chosen for this test just because
|
// IllegalMonitorStateException should be intentionally thrown. This type was chosen for this test just because
|
||||||
// it is unlikely to collide.
|
// it is unlikely to collide.
|
||||||
@Test(expected = IllegalMonitorStateException.class)
|
@Test
|
||||||
public void stringInBooleanOut1() {
|
public void stringInBooleanOut1() {
|
||||||
ActorProxy proxy = createActorProxyForActorChild();
|
ActorProxy proxy = createActorProxyForActorChild();
|
||||||
|
|
||||||
// these should only call the actor methods for ActorChild. The implementations in ActorParent will throw.
|
// these should only call the actor methods for ActorChild. The implementations in ActorParent will throw.
|
||||||
Assert.assertEquals(
|
assertThrows(IllegalMonitorStateException.class, () ->
|
||||||
false,
|
|
||||||
proxy.invokeMethod("stringInBooleanOut", "hello world", Boolean.class).block());
|
proxy.invokeMethod("stringInBooleanOut", "hello world", Boolean.class).block());
|
||||||
}
|
}
|
||||||
|
|
||||||
// IllegalMonitorStateException should be intentionally thrown. This type was chosen for this test just because
|
// IllegalMonitorStateException should be intentionally thrown. This type was chosen for this test just because
|
||||||
// it is unlikely to collide.
|
// it is unlikely to collide.
|
||||||
@Test(expected = IllegalMonitorStateException.class)
|
@Test
|
||||||
public void stringInBooleanOut2() {
|
public void stringInBooleanOut2() {
|
||||||
ActorProxy proxy = createActorProxyForActorChild();
|
ActorProxy proxy = createActorProxyForActorChild();
|
||||||
|
|
||||||
// these should only call the actor methods for ActorChild. The implementations in ActorParent will throw.
|
// these should only call the actor methods for ActorChild. The implementations in ActorParent will throw.
|
||||||
Assert.assertEquals(
|
assertThrows(IllegalMonitorStateException.class, () ->
|
||||||
true,
|
|
||||||
proxy.invokeMethod("stringInBooleanOut", "true", Boolean.class).block());
|
proxy.invokeMethod("stringInBooleanOut", "true", Boolean.class).block());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -87,8 +87,13 @@
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>org.junit.jupiter</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit-jupiter</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.junit.jupiter</groupId>
|
||||||
|
<artifactId>junit-jupiter-params</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
|
@ -13,8 +13,8 @@
|
||||||
|
|
||||||
package io.dapr.springboot;
|
package io.dapr.springboot;
|
||||||
|
|
||||||
import org.junit.Assert;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.util.StringValueResolver;
|
import org.springframework.util.StringValueResolver;
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
|
@ -42,7 +42,7 @@ public class DaprBeanPostProcessorSubscribeTest {
|
||||||
DaprTopicSubscription[] topicSubscriptions = runtime.listSubscribedTopics();
|
DaprTopicSubscription[] topicSubscriptions = runtime.listSubscribedTopics();
|
||||||
|
|
||||||
// There should be three subscriptions.
|
// There should be three subscriptions.
|
||||||
Assert.assertEquals(2, topicSubscriptions.length);
|
Assertions.assertEquals(2, topicSubscriptions.length);
|
||||||
|
|
||||||
DaprTopicSubscription[] expectedDaprTopicSubscriptions = getTestDaprTopicSubscriptions();
|
DaprTopicSubscription[] expectedDaprTopicSubscriptions = getTestDaprTopicSubscriptions();
|
||||||
|
|
||||||
|
@ -55,16 +55,16 @@ public class DaprBeanPostProcessorSubscribeTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertTopicSubscriptionEquality(DaprTopicSubscription s1, DaprTopicSubscription s2) {
|
private void assertTopicSubscriptionEquality(DaprTopicSubscription s1, DaprTopicSubscription s2) {
|
||||||
Assert.assertEquals(s1.getPubsubName(), s2.getPubsubName());
|
Assertions.assertEquals(s1.getPubsubName(), s2.getPubsubName());
|
||||||
Assert.assertEquals(s1.getTopic(), s2.getTopic());
|
Assertions.assertEquals(s1.getTopic(), s2.getTopic());
|
||||||
Assert.assertEquals(s1.getRoute(), s2.getRoute());
|
Assertions.assertEquals(s1.getRoute(), s2.getRoute());
|
||||||
Assert.assertEquals(s1.getMetadata(), s2.getMetadata());
|
Assertions.assertEquals(s1.getMetadata(), s2.getMetadata());
|
||||||
if (s1.getBulkSubscribe() == null) {
|
if (s1.getBulkSubscribe() == null) {
|
||||||
Assert.assertNull(s2.getBulkSubscribe());
|
Assertions.assertNull(s2.getBulkSubscribe());
|
||||||
} else {
|
} else {
|
||||||
Assert.assertEquals(s1.getBulkSubscribe().isEnabled(), s2.getBulkSubscribe().isEnabled());
|
Assertions.assertEquals(s1.getBulkSubscribe().isEnabled(), s2.getBulkSubscribe().isEnabled());
|
||||||
Assert.assertEquals(s1.getBulkSubscribe().getMaxAwaitDurationMs(), s2.getBulkSubscribe().getMaxAwaitDurationMs());
|
Assertions.assertEquals(s1.getBulkSubscribe().getMaxAwaitDurationMs(), s2.getBulkSubscribe().getMaxAwaitDurationMs());
|
||||||
Assert.assertEquals(s1.getBulkSubscribe().getMaxMessagesCount(), s2.getBulkSubscribe().getMaxMessagesCount());
|
Assertions.assertEquals(s1.getBulkSubscribe().getMaxMessagesCount(), s2.getBulkSubscribe().getMaxMessagesCount());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,54 +13,41 @@
|
||||||
|
|
||||||
package io.dapr.springboot;
|
package io.dapr.springboot;
|
||||||
|
|
||||||
import org.junit.Assert;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.jupiter.params.provider.Arguments;
|
||||||
import org.junit.runners.Parameterized;
|
import org.junit.jupiter.params.provider.MethodSource;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
@RunWith(Parameterized.class)
|
|
||||||
public class DaprBeanPostProcessorTest {
|
public class DaprBeanPostProcessorTest {
|
||||||
|
|
||||||
private final Class<?> clazzToBeTested;
|
|
||||||
private final String methodToBeTested;
|
|
||||||
private final String[] expected;
|
|
||||||
private final boolean expectedResult;
|
|
||||||
private static final String TOPIC_NAME = "topicName1";
|
private static final String TOPIC_NAME = "topicName1";
|
||||||
|
|
||||||
public DaprBeanPostProcessorTest(Class<?> clazzToBeTested, String methodToBeTested, String[] expected,
|
public static Stream<Arguments> routesTester() {
|
||||||
boolean expectedResult) {
|
return Stream.of(
|
||||||
this.clazzToBeTested = clazzToBeTested;
|
Arguments.of(MockController.class, "testMethod1", new String[] {"v1", "v2", "v1/page1", "v2/page1", "v1/page2", "v2/page2"},
|
||||||
this.methodToBeTested = methodToBeTested;
|
true),
|
||||||
this.expected = expected;
|
Arguments.of(MockController.class, "testMethod2", new String[] {"v1", "v2", "v1/page3", "v2/page3", "v1/page4", "v2/page4"},
|
||||||
this.expectedResult = expectedResult;
|
true),
|
||||||
|
Arguments.of(MockController.class, "testMethod3", new String[] {"v1/foo", "v2/foo"}, true),
|
||||||
|
Arguments.of(MockController.class, "testMethod4", new String[] {"v1/foo1", "v2/foo1", "v1/foo2", "v2/foo2"}, true),
|
||||||
|
Arguments.of(MockController.class, "testMethod5", new String[] {"v1/" + TOPIC_NAME, "v2/" + TOPIC_NAME}, true),
|
||||||
|
Arguments.of(MockControllerNoClazzAnnotation.class, "testMethod1", new String[] {"", "page1", "page2"}, true),
|
||||||
|
Arguments.of(MockControllerNoClazzAnnotation.class, "testMethod2", new String[] {"", "page3", "page4"}, true),
|
||||||
|
Arguments.of(MockControllerNoClazzAnnotation.class, "testMethod3", new String[] {"foo"}, true),
|
||||||
|
Arguments.of(MockControllerNoClazzAnnotation.class, "testMethod4", new String[] {"foo1", "foo2"}, true),
|
||||||
|
Arguments.of(MockControllerNoClazzAnnotation.class, "testMethod5", new String[] {TOPIC_NAME}, true)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Parameterized.Parameters
|
@ParameterizedTest
|
||||||
public static Collection<?> routesTester() {
|
@MethodSource("routesTester")
|
||||||
return Arrays.asList(new Object[][] {
|
public void testAllPostRoutesGeneration(Class<?> clazzToBeTested, String methodToBeTested, String[] expected,
|
||||||
{MockController.class, "testMethod1", new String[] {"v1", "v2", "v1/page1", "v2/page1", "v1/page2", "v2/page2"},
|
boolean expectedResult) throws NoSuchMethodException {
|
||||||
true},
|
|
||||||
{MockController.class, "testMethod2", new String[] {"v1", "v2", "v1/page3", "v2/page3", "v1/page4", "v2/page4"},
|
|
||||||
true},
|
|
||||||
{MockController.class, "testMethod3", new String[] {"v1/foo", "v2/foo"}, true},
|
|
||||||
{MockController.class, "testMethod4", new String[] {"v1/foo1", "v2/foo1", "v1/foo2", "v2/foo2"}, true},
|
|
||||||
{MockController.class, "testMethod5", new String[] {"v1/" + TOPIC_NAME, "v2/" + TOPIC_NAME}, true},
|
|
||||||
{MockControllerNoClazzAnnotation.class, "testMethod1", new String[] {"", "page1", "page2"}, true},
|
|
||||||
{MockControllerNoClazzAnnotation.class, "testMethod2", new String[] {"", "page3", "page4"}, true},
|
|
||||||
{MockControllerNoClazzAnnotation.class, "testMethod3", new String[] {"foo"}, true},
|
|
||||||
{MockControllerNoClazzAnnotation.class, "testMethod4", new String[] {"foo1", "foo2"}, true},
|
|
||||||
{MockControllerNoClazzAnnotation.class, "testMethod5", new String[] {TOPIC_NAME}, true}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testAllPostRoutesGeneration() throws NoSuchMethodException {
|
|
||||||
Method allPostRoutesMethod = DaprBeanPostProcessor.class.
|
Method allPostRoutesMethod = DaprBeanPostProcessor.class.
|
||||||
getDeclaredMethod("getAllCompleteRoutesForPost", Class.class, Method.class, String.class);
|
getDeclaredMethod("getAllCompleteRoutesForPost", Class.class, Method.class, String.class);
|
||||||
allPostRoutesMethod.setAccessible(true);
|
allPostRoutesMethod.setAccessible(true);
|
||||||
|
@ -71,7 +58,7 @@ public class DaprBeanPostProcessorTest {
|
||||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
Assert.assertEquals(expectedResult,
|
Assertions.assertEquals(expectedResult,
|
||||||
testingListForOrderAgnosticEquality(Arrays.asList(expected), routesArrayTestMethod1));
|
testingListForOrderAgnosticEquality(Arrays.asList(expected), routesArrayTestMethod1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
package io.dapr.springboot;
|
package io.dapr.springboot;
|
||||||
|
|
||||||
import io.dapr.Rule;
|
import io.dapr.Rule;
|
||||||
import org.junit.Assert;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.lang.annotation.Annotation;
|
import java.lang.annotation.Annotation;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
|
||||||
public class DaprRuntimeTest {
|
public class DaprRuntimeTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -33,7 +35,7 @@ public class DaprRuntimeTest {
|
||||||
};
|
};
|
||||||
|
|
||||||
DaprRuntime runtime = DaprRuntime.getInstance();
|
DaprRuntime runtime = DaprRuntime.getInstance();
|
||||||
Assert.assertNotNull(runtime);
|
Assertions.assertNotNull(runtime);
|
||||||
|
|
||||||
// We should be able to register the same route multiple times
|
// We should be able to register the same route multiple times
|
||||||
runtime.addSubscribedTopic(
|
runtime.addSubscribedTopic(
|
||||||
|
@ -42,7 +44,7 @@ public class DaprRuntimeTest {
|
||||||
pubSubName, topicName, match, rule.priority(), route,deadLetterTopic, metadata);
|
pubSubName, topicName, match, rule.priority(), route,deadLetterTopic, metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = RuntimeException.class)
|
@Test
|
||||||
public void testPubsubDefaultPathDifferentRegistration() {
|
public void testPubsubDefaultPathDifferentRegistration() {
|
||||||
String pubSubName = "pubsub";
|
String pubSubName = "pubsub";
|
||||||
String topicName = "topic";
|
String topicName = "topic";
|
||||||
|
@ -70,14 +72,13 @@ public class DaprRuntimeTest {
|
||||||
|
|
||||||
DaprRuntime runtime = DaprRuntime.getInstance();
|
DaprRuntime runtime = DaprRuntime.getInstance();
|
||||||
|
|
||||||
Assert.assertNotNull(runtime);
|
Assertions.assertNotNull(runtime);
|
||||||
runtime.addSubscribedTopic(
|
runtime.addSubscribedTopic(
|
||||||
pubSubName, topicName, match, rule.priority(), firstRoute, deadLetterTopic, metadata);
|
pubSubName, topicName, match, rule.priority(), firstRoute, deadLetterTopic, metadata);
|
||||||
|
|
||||||
// Supplying the same pubsub bits but a different route should fail
|
// Supplying the same pubsub bits but a different route should fail
|
||||||
runtime.addSubscribedTopic(
|
assertThrows(RuntimeException.class, () -> runtime.addSubscribedTopic(
|
||||||
pubSubName, topicName, match, rule.priority(), secondRoute, deadLetterTopic, metadata);
|
pubSubName, topicName, match, rule.priority(), secondRoute, deadLetterTopic, metadata));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,8 +13,8 @@
|
||||||
|
|
||||||
package io.dapr.springboot;
|
package io.dapr.springboot;
|
||||||
|
|
||||||
import org.junit.Assert;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -26,12 +26,12 @@ public class DaprTopicBulkSubscribeTest {
|
||||||
bulkSubscribe.setMaxMessagesCount(100);
|
bulkSubscribe.setMaxMessagesCount(100);
|
||||||
bulkSubscribe.setMaxAwaitDurationMs(200);
|
bulkSubscribe.setMaxAwaitDurationMs(200);
|
||||||
|
|
||||||
Assert.assertTrue(bulkSubscribe.isEnabled());
|
Assertions.assertTrue(bulkSubscribe.isEnabled());
|
||||||
Assert.assertEquals(100, bulkSubscribe.getMaxMessagesCount().longValue());
|
Assertions.assertEquals(100, bulkSubscribe.getMaxMessagesCount().longValue());
|
||||||
Assert.assertEquals(200, bulkSubscribe.getMaxAwaitDurationMs().longValue());
|
Assertions.assertEquals(200, bulkSubscribe.getMaxAwaitDurationMs().longValue());
|
||||||
|
|
||||||
bulkSubscribe.setEnabled(false);
|
bulkSubscribe.setEnabled(false);
|
||||||
Assert.assertFalse(bulkSubscribe.isEnabled());
|
Assertions.assertFalse(bulkSubscribe.isEnabled());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -48,9 +48,9 @@ public class DaprTopicBulkSubscribeTest {
|
||||||
for (Map.Entry<Integer, Boolean> testCase: testCases.entrySet()) {
|
for (Map.Entry<Integer, Boolean> testCase: testCases.entrySet()) {
|
||||||
try {
|
try {
|
||||||
bulkSubscribe.setMaxMessagesCount(testCase.getKey());
|
bulkSubscribe.setMaxMessagesCount(testCase.getKey());
|
||||||
Assert.assertFalse(testCase.getValue());
|
Assertions.assertFalse(testCase.getValue());
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
Assert.assertTrue(testCase.getValue());
|
Assertions.assertTrue(testCase.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,9 +69,9 @@ public class DaprTopicBulkSubscribeTest {
|
||||||
for (Map.Entry<Integer, Boolean> testCase: testCases.entrySet()) {
|
for (Map.Entry<Integer, Boolean> testCase: testCases.entrySet()) {
|
||||||
try {
|
try {
|
||||||
bulkSubscribe.setMaxAwaitDurationMs(testCase.getKey());
|
bulkSubscribe.setMaxAwaitDurationMs(testCase.getKey());
|
||||||
Assert.assertFalse(testCase.getValue());
|
Assertions.assertFalse(testCase.getValue());
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
Assert.assertTrue(testCase.getValue());
|
Assertions.assertTrue(testCase.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,13 @@
|
||||||
<type>pom</type>
|
<type>pom</type>
|
||||||
<scope>import</scope>
|
<scope>import</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.junit</groupId>
|
||||||
|
<artifactId>junit-bom</artifactId>
|
||||||
|
<version>5.7.2</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
|
@ -101,15 +108,13 @@
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>org.junit.jupiter</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit-jupiter</artifactId>
|
||||||
<version>4.13.2</version>
|
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.junit.jupiter</groupId>
|
<groupId>org.junit.jupiter</groupId>
|
||||||
<artifactId>junit-jupiter-engine</artifactId>
|
<artifactId>junit-jupiter-params</artifactId>
|
||||||
<version>5.5.2</version>
|
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -201,9 +206,9 @@
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.codehaus.mojo</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>failsafe-maven-plugin</artifactId>
|
<artifactId>maven-failsafe-plugin</artifactId>
|
||||||
<version>2.4.3-alpha-1</version>
|
<version>3.1.2</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<goals>
|
<goals>
|
||||||
|
|
|
@ -17,7 +17,7 @@ import io.dapr.actors.client.ActorClient;
|
||||||
import io.dapr.client.DaprApiProtocol;
|
import io.dapr.client.DaprApiProtocol;
|
||||||
import io.dapr.client.resiliency.ResiliencyOptions;
|
import io.dapr.client.resiliency.ResiliencyOptions;
|
||||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||||
import org.junit.AfterClass;
|
import org.junit.jupiter.api.AfterAll;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
@ -184,7 +184,7 @@ public abstract class BaseIT {
|
||||||
return runs;
|
return runs;
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterAll
|
||||||
public static void cleanUp() throws Exception {
|
public static void cleanUp() throws Exception {
|
||||||
while (!TO_BE_CLOSED.isEmpty()) {
|
while (!TO_BE_CLOSED.isEmpty()) {
|
||||||
TO_BE_CLOSED.remove().close();
|
TO_BE_CLOSED.remove().close();
|
||||||
|
|
|
@ -18,7 +18,7 @@ import io.dapr.actors.client.ActorProxyBuilder;
|
||||||
import io.dapr.it.BaseIT;
|
import io.dapr.it.BaseIT;
|
||||||
import io.dapr.it.actors.services.springboot.DemoActor;
|
import io.dapr.it.actors.services.springboot.DemoActor;
|
||||||
import io.dapr.it.actors.services.springboot.DemoActorService;
|
import io.dapr.it.actors.services.springboot.DemoActorService;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -26,9 +26,9 @@ import java.util.List;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
import static io.dapr.it.Retry.callWithRetry;
|
import static io.dapr.it.Retry.callWithRetry;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
public class ActivationDeactivationIT extends BaseIT {
|
public class ActivationDeactivationIT extends BaseIT {
|
||||||
|
|
||||||
|
@ -62,14 +62,14 @@ public class ActivationDeactivationIT extends BaseIT {
|
||||||
logger.debug("Retrieving active Actors");
|
logger.debug("Retrieving active Actors");
|
||||||
List<String> activeActors = proxy.retrieveActiveActors();
|
List<String> activeActors = proxy.retrieveActiveActors();
|
||||||
logger.debug("Active actors: [" + activeActors.toString() + "]");
|
logger.debug("Active actors: [" + activeActors.toString() + "]");
|
||||||
assertTrue("Expecting actorId:[" + actorId1.toString() + "]", activeActors.contains(actorId1.toString()));
|
assertTrue(activeActors.contains(actorId1.toString()),"Expecting actorId:[" + actorId1.toString() + "]");
|
||||||
|
|
||||||
ActorId actorId2 = new ActorId(Integer.toString(atomicInteger.getAndIncrement()));
|
ActorId actorId2 = new ActorId(Integer.toString(atomicInteger.getAndIncrement()));
|
||||||
DemoActor proxy2 = proxyBuilder.build(actorId2);
|
DemoActor proxy2 = proxyBuilder.build(actorId2);
|
||||||
callWithRetry(() -> {
|
callWithRetry(() -> {
|
||||||
List<String> activeActorsSecondTry = proxy2.retrieveActiveActors();
|
List<String> activeActorsSecondTry = proxy2.retrieveActiveActors();
|
||||||
logger.debug("Active actors: [" + activeActorsSecondTry.toString() + "]");
|
logger.debug("Active actors: [" + activeActorsSecondTry.toString() + "]");
|
||||||
assertFalse("NOT Expecting actorId:[" + actorId1.toString() + "]", activeActorsSecondTry.contains(actorId1.toString()));
|
assertFalse(activeActorsSecondTry.contains(actorId1.toString()), "NOT Expecting actorId:[" + actorId1.toString() + "]");
|
||||||
}, 15000);
|
}, 15000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,22 +14,17 @@ limitations under the License.
|
||||||
package io.dapr.it.actors;
|
package io.dapr.it.actors;
|
||||||
|
|
||||||
import io.dapr.actors.ActorId;
|
import io.dapr.actors.ActorId;
|
||||||
import io.dapr.actors.client.ActorProxy;
|
|
||||||
import io.dapr.actors.client.ActorProxyBuilder;
|
import io.dapr.actors.client.ActorProxyBuilder;
|
||||||
import io.dapr.it.BaseIT;
|
import io.dapr.it.BaseIT;
|
||||||
import io.dapr.it.actors.app.MyActor;
|
import io.dapr.it.actors.app.MyActor;
|
||||||
import io.dapr.it.actors.app.MyActorService;
|
import io.dapr.it.actors.app.MyActorService;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
|
|
||||||
import static io.dapr.it.Retry.callWithRetry;
|
import static io.dapr.it.Retry.callWithRetry;
|
||||||
import static io.dapr.it.TestUtils.assertThrowsDaprException;
|
|
||||||
import static io.dapr.it.TestUtils.assertThrowsDaprExceptionSubstring;
|
import static io.dapr.it.TestUtils.assertThrowsDaprExceptionSubstring;
|
||||||
import static org.junit.Assert.assertNotNull;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
public class ActorExceptionIT extends BaseIT {
|
public class ActorExceptionIT extends BaseIT {
|
||||||
|
|
||||||
|
@ -59,8 +54,5 @@ public class ActorExceptionIT extends BaseIT {
|
||||||
"INTERNAL: error invoke actor method: error from actor service",
|
"INTERNAL: error invoke actor method: error from actor service",
|
||||||
() -> proxy.throwException());
|
() -> proxy.throwException());
|
||||||
}, 5000);
|
}, 5000);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,12 +19,12 @@ import io.dapr.actors.client.ActorProxyBuilder;
|
||||||
import io.dapr.it.BaseIT;
|
import io.dapr.it.BaseIT;
|
||||||
import io.dapr.it.actors.app.MyActor;
|
import io.dapr.it.actors.app.MyActor;
|
||||||
import io.dapr.it.actors.app.MyActorService;
|
import io.dapr.it.actors.app.MyActorService;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import static io.dapr.it.Retry.callWithRetry;
|
import static io.dapr.it.Retry.callWithRetry;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
public class ActorMethodNameIT extends BaseIT {
|
public class ActorMethodNameIT extends BaseIT {
|
||||||
|
|
||||||
|
|
|
@ -19,9 +19,9 @@ import io.dapr.actors.client.ActorProxyBuilder;
|
||||||
import io.dapr.it.BaseIT;
|
import io.dapr.it.BaseIT;
|
||||||
import io.dapr.it.DaprRun;
|
import io.dapr.it.DaprRun;
|
||||||
import io.dapr.it.actors.app.MyActorService;
|
import io.dapr.it.actors.app.MyActorService;
|
||||||
import org.junit.After;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ import java.util.UUID;
|
||||||
import static io.dapr.it.actors.MyActorTestUtils.countMethodCalls;
|
import static io.dapr.it.actors.MyActorTestUtils.countMethodCalls;
|
||||||
import static io.dapr.it.actors.MyActorTestUtils.fetchMethodCallLogs;
|
import static io.dapr.it.actors.MyActorTestUtils.fetchMethodCallLogs;
|
||||||
import static io.dapr.it.actors.MyActorTestUtils.validateMethodCalls;
|
import static io.dapr.it.actors.MyActorTestUtils.validateMethodCalls;
|
||||||
import static org.junit.Assert.assertNotEquals;
|
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||||
|
|
||||||
public class ActorReminderFailoverIT extends BaseIT {
|
public class ActorReminderFailoverIT extends BaseIT {
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ public class ActorReminderFailoverIT extends BaseIT {
|
||||||
|
|
||||||
private DaprRun clientAppRun;
|
private DaprRun clientAppRun;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void init() throws Exception {
|
public void init() throws Exception {
|
||||||
firstAppRun = startDaprApp(
|
firstAppRun = startDaprApp(
|
||||||
ActorReminderFailoverIT.class.getSimpleName() + "One",
|
ActorReminderFailoverIT.class.getSimpleName() + "One",
|
||||||
|
@ -78,7 +78,7 @@ public class ActorReminderFailoverIT extends BaseIT {
|
||||||
proxy = proxyBuilder.build(actorId);
|
proxy = proxyBuilder.build(actorId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@AfterEach
|
||||||
public void tearDown() {
|
public void tearDown() {
|
||||||
// call unregister
|
// call unregister
|
||||||
logger.debug("Calling actor method 'stopReminder' to unregister reminder");
|
logger.debug("Calling actor method 'stopReminder' to unregister reminder");
|
||||||
|
|
|
@ -22,21 +22,23 @@ import io.dapr.it.DaprRun;
|
||||||
import io.dapr.it.actors.app.ActorReminderDataParam;
|
import io.dapr.it.actors.app.ActorReminderDataParam;
|
||||||
import io.dapr.it.actors.app.MyActorService;
|
import io.dapr.it.actors.app.MyActorService;
|
||||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||||
import org.junit.After;
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
|
import org.junit.jupiter.params.provider.Arguments;
|
||||||
|
import org.junit.jupiter.params.provider.MethodSource;
|
||||||
import org.junit.runners.Parameterized;
|
import org.junit.runners.Parameterized;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import static io.dapr.it.Retry.callWithRetry;
|
import static io.dapr.it.Retry.callWithRetry;
|
||||||
import static io.dapr.it.actors.MyActorTestUtils.*;
|
import static io.dapr.it.actors.MyActorTestUtils.*;
|
||||||
|
|
||||||
@RunWith(Parameterized.class)
|
|
||||||
public class ActorReminderRecoveryIT extends BaseIT {
|
public class ActorReminderRecoveryIT extends BaseIT {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(ActorReminderRecoveryIT.class);
|
private static final Logger logger = LoggerFactory.getLogger(ActorReminderRecoveryIT.class);
|
||||||
|
@ -49,38 +51,30 @@ public class ActorReminderRecoveryIT extends BaseIT {
|
||||||
*
|
*
|
||||||
* @return Collection of parameter tuples.
|
* @return Collection of parameter tuples.
|
||||||
*/
|
*/
|
||||||
@Parameterized.Parameters
|
public static Stream<Arguments> data() {
|
||||||
public static Collection<Object[]> data() {
|
return Stream.of(Arguments.of(
|
||||||
return Arrays.asList(new Object[][] {
|
|
||||||
{
|
|
||||||
"MyActorTest",
|
"MyActorTest",
|
||||||
new ActorReminderDataParam("36", "String"),
|
new ActorReminderDataParam("36", "String"),
|
||||||
"36"
|
"36"
|
||||||
},
|
),
|
||||||
{
|
Arguments.of(
|
||||||
"MyActorTest",
|
"MyActorTest",
|
||||||
new ActorReminderDataParam("\"my_text\"", "String"),
|
new ActorReminderDataParam("\"my_text\"", "String"),
|
||||||
"\"my_text\""
|
"\"my_text\""
|
||||||
},
|
),
|
||||||
{
|
Arguments.of(
|
||||||
"MyActorBinaryTest",
|
"MyActorBinaryTest",
|
||||||
new ActorReminderDataParam(new byte[]{0, 1}, "Binary"),
|
new ActorReminderDataParam(new byte[]{0, 1}, "Binary"),
|
||||||
"AAE="
|
"AAE="
|
||||||
},
|
),
|
||||||
{
|
Arguments.of(
|
||||||
"MyActorObjectTest",
|
"MyActorObjectTest",
|
||||||
new ActorReminderDataParam("{\"name\":\"abc\",\"age\":30}", "Object"),
|
new ActorReminderDataParam("{\"name\":\"abc\",\"age\":30}", "Object"),
|
||||||
"abc,30"
|
"abc,30"
|
||||||
},
|
)
|
||||||
});
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String actorType;
|
|
||||||
|
|
||||||
public ActorReminderDataParam reminderDataParam;
|
|
||||||
|
|
||||||
public String expectedReminderStateText;
|
|
||||||
|
|
||||||
public String reminderName = UUID.randomUUID().toString();
|
public String reminderName = UUID.randomUUID().toString();
|
||||||
|
|
||||||
private ActorProxy proxy;
|
private ActorProxy proxy;
|
||||||
|
@ -89,17 +83,7 @@ public class ActorReminderRecoveryIT extends BaseIT {
|
||||||
|
|
||||||
private DaprRun clientRun;
|
private DaprRun clientRun;
|
||||||
|
|
||||||
public ActorReminderRecoveryIT(
|
public void setup(String actorType) throws Exception {
|
||||||
String actorType,
|
|
||||||
ActorReminderDataParam reminderDataParam,
|
|
||||||
String expectedReminderStateText) {
|
|
||||||
this.actorType = actorType;
|
|
||||||
this.reminderDataParam = reminderDataParam;
|
|
||||||
this.expectedReminderStateText = expectedReminderStateText;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void init() throws Exception {
|
|
||||||
runs = startSplitDaprAndApp(
|
runs = startSplitDaprAndApp(
|
||||||
ActorReminderRecoveryIT.class.getSimpleName(),
|
ActorReminderRecoveryIT.class.getSimpleName(),
|
||||||
"Started MyActorService",
|
"Started MyActorService",
|
||||||
|
@ -118,13 +102,13 @@ public class ActorReminderRecoveryIT extends BaseIT {
|
||||||
logger.debug("Creating proxy builder");
|
logger.debug("Creating proxy builder");
|
||||||
|
|
||||||
ActorProxyBuilder<ActorProxy> proxyBuilder =
|
ActorProxyBuilder<ActorProxy> proxyBuilder =
|
||||||
new ActorProxyBuilder(this.actorType, ActorProxy.class, newActorClient());
|
new ActorProxyBuilder(actorType, ActorProxy.class, newActorClient());
|
||||||
logger.debug("Creating actorId");
|
logger.debug("Creating actorId");
|
||||||
logger.debug("Building proxy");
|
logger.debug("Building proxy");
|
||||||
proxy = proxyBuilder.build(actorId);
|
proxy = proxyBuilder.build(actorId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@AfterEach
|
||||||
public void tearDown() {
|
public void tearDown() {
|
||||||
// call unregister
|
// call unregister
|
||||||
logger.debug("Calling actor method 'stopReminder' to unregister reminder");
|
logger.debug("Calling actor method 'stopReminder' to unregister reminder");
|
||||||
|
@ -135,12 +119,19 @@ public class ActorReminderRecoveryIT extends BaseIT {
|
||||||
* Create an actor, register a reminder, validates its content, restarts the runtime and confirms reminder continues.
|
* Create an actor, register a reminder, validates its content, restarts the runtime and confirms reminder continues.
|
||||||
* @throws Exception This test is not expected to throw. Thrown exceptions are bugs.
|
* @throws Exception This test is not expected to throw. Thrown exceptions are bugs.
|
||||||
*/
|
*/
|
||||||
@Test
|
@ParameterizedTest
|
||||||
public void reminderRecoveryTest() throws Exception {
|
@MethodSource("data")
|
||||||
logger.debug("Invoking actor method 'startReminder' which will register a reminder");
|
public void reminderRecoveryTest(
|
||||||
proxy.invokeMethod("setReminderData", this.reminderDataParam).block();
|
String actorType,
|
||||||
|
ActorReminderDataParam reminderDataParam,
|
||||||
|
String expectedReminderStateText
|
||||||
|
) throws Exception {
|
||||||
|
setup(actorType);
|
||||||
|
|
||||||
proxy.invokeMethod("startReminder", this.reminderName).block();
|
logger.debug("Invoking actor method 'startReminder' which will register a reminder");
|
||||||
|
proxy.invokeMethod("setReminderData", reminderDataParam).block();
|
||||||
|
|
||||||
|
proxy.invokeMethod("startReminder", reminderName).block();
|
||||||
|
|
||||||
logger.debug("Pausing 7 seconds to allow reminder to fire");
|
logger.debug("Pausing 7 seconds to allow reminder to fire");
|
||||||
Thread.sleep(7000);
|
Thread.sleep(7000);
|
||||||
|
@ -150,7 +141,7 @@ public class ActorReminderRecoveryIT extends BaseIT {
|
||||||
logs.clear();
|
logs.clear();
|
||||||
logs.addAll(fetchMethodCallLogs(proxy));
|
logs.addAll(fetchMethodCallLogs(proxy));
|
||||||
validateMethodCalls(logs, METHOD_NAME, 3);
|
validateMethodCalls(logs, METHOD_NAME, 3);
|
||||||
validateMessageContent(logs, METHOD_NAME, this.expectedReminderStateText);
|
validateMessageContent(logs, METHOD_NAME, expectedReminderStateText);
|
||||||
}, 5000);
|
}, 5000);
|
||||||
|
|
||||||
// Restarts runtime only.
|
// Restarts runtime only.
|
||||||
|
@ -172,7 +163,7 @@ public class ActorReminderRecoveryIT extends BaseIT {
|
||||||
logger.info("Fetching logs for " + METHOD_NAME);
|
logger.info("Fetching logs for " + METHOD_NAME);
|
||||||
List<MethodEntryTracker> newLogs = fetchMethodCallLogs(proxy);
|
List<MethodEntryTracker> newLogs = fetchMethodCallLogs(proxy);
|
||||||
validateMethodCalls(newLogs, METHOD_NAME, 1);
|
validateMethodCalls(newLogs, METHOD_NAME, 1);
|
||||||
validateMessageContent(newLogs, METHOD_NAME, this.expectedReminderStateText);
|
validateMessageContent(newLogs, METHOD_NAME, expectedReminderStateText);
|
||||||
|
|
||||||
logger.info("Pausing 10 seconds to allow reminder to fire a few times");
|
logger.info("Pausing 10 seconds to allow reminder to fire a few times");
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -23,17 +23,17 @@ import io.dapr.it.DaprRun;
|
||||||
import io.dapr.it.ToxiProxyRun;
|
import io.dapr.it.ToxiProxyRun;
|
||||||
import io.dapr.it.actors.services.springboot.DemoActor;
|
import io.dapr.it.actors.services.springboot.DemoActor;
|
||||||
import io.dapr.it.actors.services.springboot.DemoActorService;
|
import io.dapr.it.actors.services.springboot.DemoActorService;
|
||||||
import org.junit.AfterClass;
|
import org.junit.jupiter.api.AfterAll;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
import org.junit.Ignore;
|
import org.junit.jupiter.api.Disabled;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test SDK resiliency.
|
* Test SDK resiliency.
|
||||||
|
@ -66,7 +66,7 @@ public class ActorSdkResiliencytIT extends BaseIT {
|
||||||
|
|
||||||
private static DemoActor oneRetryDemoActor;
|
private static DemoActor oneRetryDemoActor;
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeAll
|
||||||
public static void init() throws Exception {
|
public static void init() throws Exception {
|
||||||
daprRun = startDaprApp(
|
daprRun = startDaprApp(
|
||||||
ActorSdkResiliencytIT.class.getSimpleName(),
|
ActorSdkResiliencytIT.class.getSimpleName(),
|
||||||
|
@ -98,7 +98,7 @@ public class ActorSdkResiliencytIT extends BaseIT {
|
||||||
return builder.build(ACTOR_ID);
|
return builder.build(ACTOR_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterAll
|
||||||
public static void tearDown() throws Exception {
|
public static void tearDown() throws Exception {
|
||||||
if (toxiProxyRun != null) {
|
if (toxiProxyRun != null) {
|
||||||
toxiProxyRun.stop();
|
toxiProxyRun.stop();
|
||||||
|
@ -106,7 +106,7 @@ public class ActorSdkResiliencytIT extends BaseIT {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore("Flaky when running on GitHub actions")
|
@Disabled("Flaky when running on GitHub actions")
|
||||||
public void retryAndTimeout() {
|
public void retryAndTimeout() {
|
||||||
AtomicInteger toxiClientErrorCount = new AtomicInteger();
|
AtomicInteger toxiClientErrorCount = new AtomicInteger();
|
||||||
AtomicInteger retryOneClientErrorCount = new AtomicInteger();
|
AtomicInteger retryOneClientErrorCount = new AtomicInteger();
|
||||||
|
|
|
@ -21,21 +21,19 @@ import io.dapr.it.BaseIT;
|
||||||
import io.dapr.it.DaprRun;
|
import io.dapr.it.DaprRun;
|
||||||
import io.dapr.it.actors.services.springboot.StatefulActor;
|
import io.dapr.it.actors.services.springboot.StatefulActor;
|
||||||
import io.dapr.it.actors.services.springboot.StatefulActorService;
|
import io.dapr.it.actors.services.springboot.StatefulActorService;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.jupiter.params.provider.Arguments;
|
||||||
import org.junit.runners.Parameterized;
|
import org.junit.jupiter.params.provider.MethodSource;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.stream.Stream;
|
||||||
import java.util.Collection;
|
|
||||||
|
|
||||||
import static io.dapr.it.Retry.callWithRetry;
|
import static io.dapr.it.Retry.callWithRetry;
|
||||||
import static org.junit.Assert.assertArrayEquals;
|
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
|
|
||||||
@RunWith(Parameterized.class)
|
|
||||||
public class ActorStateIT extends BaseIT {
|
public class ActorStateIT extends BaseIT {
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory.getLogger(ActorStateIT.class);
|
private static Logger logger = LoggerFactory.getLogger(ActorStateIT.class);
|
||||||
|
@ -45,24 +43,18 @@ public class ActorStateIT extends BaseIT {
|
||||||
* Param #1: useGrpc.
|
* Param #1: useGrpc.
|
||||||
* @return Collection of parameter tuples.
|
* @return Collection of parameter tuples.
|
||||||
*/
|
*/
|
||||||
@Parameterized.Parameters
|
public static Stream<Arguments> data() {
|
||||||
public static Collection<Object[]> data() {
|
return Stream.of(
|
||||||
return Arrays.asList(new Object[][] {
|
Arguments.of(DaprApiProtocol.HTTP, DaprApiProtocol.HTTP ),
|
||||||
{ DaprApiProtocol.HTTP, DaprApiProtocol.HTTP },
|
Arguments.of(DaprApiProtocol.HTTP, DaprApiProtocol.GRPC ),
|
||||||
{ DaprApiProtocol.HTTP, DaprApiProtocol.GRPC },
|
Arguments.of(DaprApiProtocol.GRPC, DaprApiProtocol.HTTP ),
|
||||||
{ DaprApiProtocol.GRPC, DaprApiProtocol.HTTP },
|
Arguments.of(DaprApiProtocol.GRPC, DaprApiProtocol.GRPC )
|
||||||
{ DaprApiProtocol.GRPC, DaprApiProtocol.GRPC },
|
);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Parameterized.Parameter(0)
|
@ParameterizedTest
|
||||||
public DaprApiProtocol daprClientProtocol;
|
@MethodSource("data")
|
||||||
|
public void writeReadState(DaprApiProtocol daprClientProtocol, DaprApiProtocol serviceAppProtocol) throws Exception {
|
||||||
@Parameterized.Parameter(1)
|
|
||||||
public DaprApiProtocol serviceAppProtocol;
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void writeReadState() throws Exception {
|
|
||||||
logger.debug("Starting actor runtime ...");
|
logger.debug("Starting actor runtime ...");
|
||||||
// The call below will fail if service cannot start successfully.
|
// The call below will fail if service cannot start successfully.
|
||||||
DaprRun runtime = startDaprApp(
|
DaprRun runtime = startDaprApp(
|
||||||
|
@ -73,13 +65,13 @@ public class ActorStateIT extends BaseIT {
|
||||||
60000,
|
60000,
|
||||||
serviceAppProtocol);
|
serviceAppProtocol);
|
||||||
|
|
||||||
runtime.switchToProtocol(this.daprClientProtocol);
|
runtime.switchToProtocol(daprClientProtocol);
|
||||||
|
|
||||||
String message = "This is a message to be saved and retrieved.";
|
String message = "This is a message to be saved and retrieved.";
|
||||||
String name = "Jon Doe";
|
String name = "Jon Doe";
|
||||||
byte[] bytes = new byte[] { 0x1 };
|
byte[] bytes = new byte[] { 0x1 };
|
||||||
ActorId actorId = new ActorId(
|
ActorId actorId = new ActorId(
|
||||||
String.format("%d-%b-%b", System.currentTimeMillis(), this.daprClientProtocol, this.serviceAppProtocol));
|
String.format("%d-%b-%b", System.currentTimeMillis(), daprClientProtocol, serviceAppProtocol));
|
||||||
String actorType = "StatefulActorTest";
|
String actorType = "StatefulActorTest";
|
||||||
logger.debug("Building proxy ...");
|
logger.debug("Building proxy ...");
|
||||||
ActorProxyBuilder<ActorProxy> proxyBuilder =
|
ActorProxyBuilder<ActorProxy> proxyBuilder =
|
||||||
|
@ -166,7 +158,7 @@ public class ActorStateIT extends BaseIT {
|
||||||
60000,
|
60000,
|
||||||
serviceAppProtocol);
|
serviceAppProtocol);
|
||||||
|
|
||||||
runtime.switchToProtocol(this.daprClientProtocol);
|
runtime.switchToProtocol(daprClientProtocol);
|
||||||
|
|
||||||
// Need new proxy builder because the proxy builder holds the channel.
|
// Need new proxy builder because the proxy builder holds the channel.
|
||||||
proxyBuilder = new ActorProxyBuilder(actorType, ActorProxy.class, newActorClient());
|
proxyBuilder = new ActorProxyBuilder(actorType, ActorProxy.class, newActorClient());
|
||||||
|
|
|
@ -21,7 +21,7 @@ import io.dapr.it.BaseIT;
|
||||||
import io.dapr.it.DaprRun;
|
import io.dapr.it.DaprRun;
|
||||||
import io.dapr.it.actors.app.MyActorService;
|
import io.dapr.it.actors.app.MyActorService;
|
||||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ import static io.dapr.it.Retry.callWithRetry;
|
||||||
import static io.dapr.it.actors.MyActorTestUtils.fetchMethodCallLogs;
|
import static io.dapr.it.actors.MyActorTestUtils.fetchMethodCallLogs;
|
||||||
import static io.dapr.it.actors.MyActorTestUtils.validateMethodCalls;
|
import static io.dapr.it.actors.MyActorTestUtils.validateMethodCalls;
|
||||||
import static io.dapr.it.actors.MyActorTestUtils.validateMessageContent;
|
import static io.dapr.it.actors.MyActorTestUtils.validateMessageContent;
|
||||||
import static org.junit.Assert.assertNotEquals;
|
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||||
|
|
||||||
public class ActorTimerRecoveryIT extends BaseIT {
|
public class ActorTimerRecoveryIT extends BaseIT {
|
||||||
|
|
||||||
|
|
|
@ -21,9 +21,9 @@ import io.dapr.client.DaprHttp;
|
||||||
import io.dapr.client.DaprHttpBuilder;
|
import io.dapr.client.DaprHttpBuilder;
|
||||||
import io.dapr.it.BaseIT;
|
import io.dapr.it.BaseIT;
|
||||||
import io.dapr.it.actors.app.MyActorService;
|
import io.dapr.it.actors.app.MyActorService;
|
||||||
import org.junit.After;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.Assert;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -32,11 +32,10 @@ import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
import static io.dapr.it.Retry.callWithRetry;
|
|
||||||
import static io.dapr.it.actors.MyActorTestUtils.fetchMethodCallLogs;
|
import static io.dapr.it.actors.MyActorTestUtils.fetchMethodCallLogs;
|
||||||
import static io.dapr.it.actors.MyActorTestUtils.validateMethodCalls;
|
import static io.dapr.it.actors.MyActorTestUtils.validateMethodCalls;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
public class ActorTurnBasedConcurrencyIT extends BaseIT {
|
public class ActorTurnBasedConcurrencyIT extends BaseIT {
|
||||||
|
|
||||||
|
@ -52,7 +51,7 @@ public class ActorTurnBasedConcurrencyIT extends BaseIT {
|
||||||
|
|
||||||
private static final String ACTOR_ID = "1";
|
private static final String ACTOR_ID = "1";
|
||||||
|
|
||||||
@After
|
@AfterEach
|
||||||
public void cleanUpTestCase() {
|
public void cleanUpTestCase() {
|
||||||
// Delete the reminder in case the test failed, otherwise it may interfere with future tests since it is persisted.
|
// Delete the reminder in case the test failed, otherwise it may interfere with future tests since it is persisted.
|
||||||
DaprHttp client = new DaprHttpBuilder().build();
|
DaprHttp client = new DaprHttpBuilder().build();
|
||||||
|
@ -185,7 +184,7 @@ public class ActorTurnBasedConcurrencyIT extends BaseIT {
|
||||||
} else {
|
} else {
|
||||||
String msg = "Error - Enter and Exit should alternate. Incorrect entry: " + s.toString();
|
String msg = "Error - Enter and Exit should alternate. Incorrect entry: " + s.toString();
|
||||||
System.out.println(msg);
|
System.out.println(msg);
|
||||||
Assert.fail(msg);
|
Assertions.fail(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility class for tests that use MyActor class.
|
* Utility class for tests that use MyActor class.
|
||||||
|
|
|
@ -5,7 +5,9 @@ import io.dapr.client.DaprClientBuilder;
|
||||||
import io.dapr.it.BaseIT;
|
import io.dapr.it.BaseIT;
|
||||||
import io.dapr.it.DaprRun;
|
import io.dapr.it.DaprRun;
|
||||||
import io.dapr.it.actors.ActorReminderRecoveryIT;
|
import io.dapr.it.actors.ActorReminderRecoveryIT;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
|
import org.junit.jupiter.params.provider.ValueSource;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.Parameterized;
|
import org.junit.runners.Parameterized;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -14,31 +16,17 @@ import org.slf4j.LoggerFactory;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
@RunWith(Parameterized.class)
|
|
||||||
public class ApiIT extends BaseIT {
|
public class ApiIT extends BaseIT {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(ApiIT.class);
|
private static final Logger logger = LoggerFactory.getLogger(ApiIT.class);
|
||||||
private static final int DEFAULT_TIMEOUT = 60000;
|
private static final int DEFAULT_TIMEOUT = 60000;
|
||||||
|
|
||||||
/**
|
@ParameterizedTest
|
||||||
* Parameters for this test.
|
@ValueSource(booleans = {true, false})
|
||||||
* Param #1: useGrpc.
|
public void testShutdownAPI(boolean useGrpc) throws Exception {
|
||||||
*
|
|
||||||
* @return Collection of parameter tuples.
|
|
||||||
*/
|
|
||||||
@Parameterized.Parameters
|
|
||||||
public static Collection<Object[]> data() {
|
|
||||||
return Arrays.asList(new Object[][]{{false}, {true}});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Parameterized.Parameter
|
|
||||||
public boolean useGrpc;
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testShutdownAPI() throws Exception {
|
|
||||||
DaprRun run = startDaprApp(this.getClass().getSimpleName(), DEFAULT_TIMEOUT);
|
DaprRun run = startDaprApp(this.getClass().getSimpleName(), DEFAULT_TIMEOUT);
|
||||||
|
|
||||||
if (this.useGrpc) {
|
if (useGrpc) {
|
||||||
run.switchToGRPC();
|
run.switchToGRPC();
|
||||||
} else {
|
} else {
|
||||||
run.switchToHTTP();
|
run.switchToHTTP();
|
||||||
|
|
|
@ -19,24 +19,20 @@ import io.dapr.client.DaprClientBuilder;
|
||||||
import io.dapr.client.domain.HttpExtension;
|
import io.dapr.client.domain.HttpExtension;
|
||||||
import io.dapr.it.BaseIT;
|
import io.dapr.it.BaseIT;
|
||||||
import io.dapr.it.DaprRun;
|
import io.dapr.it.DaprRun;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
import org.junit.runners.Parameterized;
|
import org.junit.jupiter.params.provider.ValueSource;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
import static io.dapr.it.Retry.callWithRetry;
|
import static io.dapr.it.Retry.callWithRetry;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.jupiter.api.Assertions.fail;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service for input and output binding example.
|
* Service for input and output binding example.
|
||||||
*/
|
*/
|
||||||
@RunWith(Parameterized.class)
|
|
||||||
public class BindingIT extends BaseIT {
|
public class BindingIT extends BaseIT {
|
||||||
|
|
||||||
private static final String BINDING_NAME = "sample123";
|
private static final String BINDING_NAME = "sample123";
|
||||||
|
@ -50,23 +46,11 @@ public class BindingIT extends BaseIT {
|
||||||
public String message;
|
public String message;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@ParameterizedTest
|
||||||
* Parameters for this test.
|
@ValueSource(booleans = {true, false})
|
||||||
* Param #1: useGrpc.
|
public void inputOutputBinding(boolean useGrpc) throws Exception {
|
||||||
* @return Collection of parameter tuples.
|
|
||||||
*/
|
|
||||||
@Parameterized.Parameters
|
|
||||||
public static Collection<Object[]> data() {
|
|
||||||
return Arrays.asList(new Object[][] { { false }, { true } });
|
|
||||||
}
|
|
||||||
|
|
||||||
@Parameterized.Parameter
|
|
||||||
public boolean useGrpc;
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void inputOutputBinding() throws Exception {
|
|
||||||
System.out.println("Working Directory = " + System.getProperty("user.dir"));
|
System.out.println("Working Directory = " + System.getProperty("user.dir"));
|
||||||
String serviceNameVariant = this.useGrpc ? "-grpc" : "-http";
|
String serviceNameVariant = useGrpc ? "-grpc" : "-http";
|
||||||
|
|
||||||
DaprRun daprRun = startDaprApp(
|
DaprRun daprRun = startDaprApp(
|
||||||
this.getClass().getSimpleName() + serviceNameVariant,
|
this.getClass().getSimpleName() + serviceNameVariant,
|
||||||
|
@ -75,7 +59,7 @@ public class BindingIT extends BaseIT {
|
||||||
true,
|
true,
|
||||||
60000);
|
60000);
|
||||||
// At this point, it is guaranteed that the service above is running and all ports being listened to.
|
// At this point, it is guaranteed that the service above is running and all ports being listened to.
|
||||||
if (this.useGrpc) {
|
if (useGrpc) {
|
||||||
daprRun.switchToGRPC();
|
daprRun.switchToGRPC();
|
||||||
} else {
|
} else {
|
||||||
daprRun.switchToHTTP();
|
daprRun.switchToHTTP();
|
||||||
|
|
|
@ -21,7 +21,10 @@ import io.dapr.client.domain.UnsubscribeConfigurationResponse;
|
||||||
import io.dapr.it.BaseIT;
|
import io.dapr.it.BaseIT;
|
||||||
import io.dapr.it.DaprRun;
|
import io.dapr.it.DaprRun;
|
||||||
|
|
||||||
import org.junit.*;
|
import org.junit.jupiter.api.AfterAll;
|
||||||
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
import reactor.core.Disposable;
|
import reactor.core.Disposable;
|
||||||
import reactor.core.publisher.Flux;
|
import reactor.core.publisher.Flux;
|
||||||
|
|
||||||
|
@ -29,7 +32,7 @@ import java.io.IOException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
public class ConfigurationClientIT extends BaseIT {
|
public class ConfigurationClientIT extends BaseIT {
|
||||||
|
|
||||||
|
@ -59,19 +62,19 @@ public class ConfigurationClientIT extends BaseIT {
|
||||||
"myconfigkey3", "update_myconfigvalue3||2"
|
"myconfigkey3", "update_myconfigvalue3||2"
|
||||||
};
|
};
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeAll
|
||||||
public static void init() throws Exception {
|
public static void init() throws Exception {
|
||||||
daprRun = startDaprApp(ConfigurationClientIT.class.getSimpleName(), 5000);
|
daprRun = startDaprApp(ConfigurationClientIT.class.getSimpleName(), 5000);
|
||||||
daprRun.switchToGRPC();
|
daprRun.switchToGRPC();
|
||||||
daprClient = new DaprClientBuilder().build();
|
daprClient = new DaprClientBuilder().build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterAll
|
||||||
public static void tearDown() throws Exception {
|
public static void tearDown() throws Exception {
|
||||||
daprClient.close();
|
daprClient.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setupConfigStore() {
|
public void setupConfigStore() {
|
||||||
executeDockerCommand(insertCmd);
|
executeDockerCommand(insertCmd);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,16 +5,17 @@ import io.dapr.client.DaprClientBuilder;
|
||||||
import io.dapr.client.domain.ConfigurationItem;
|
import io.dapr.client.domain.ConfigurationItem;
|
||||||
import io.dapr.it.BaseIT;
|
import io.dapr.it.BaseIT;
|
||||||
import io.dapr.it.DaprRun;
|
import io.dapr.it.DaprRun;
|
||||||
import org.junit.AfterClass;
|
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.AfterAll;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
public class ConfigurationIT extends BaseIT {
|
public class ConfigurationIT extends BaseIT {
|
||||||
private static final String CONFIG_STORE_NAME = "redisconfigstore";
|
private static final String CONFIG_STORE_NAME = "redisconfigstore";
|
||||||
|
@ -35,19 +36,19 @@ public class ConfigurationIT extends BaseIT {
|
||||||
"myconfigkey3", "myconfigvalue3||1"
|
"myconfigkey3", "myconfigvalue3||1"
|
||||||
};
|
};
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeAll
|
||||||
public static void init() throws Exception {
|
public static void init() throws Exception {
|
||||||
daprRun = startDaprApp(ConfigurationIT.class.getSimpleName(), 5000);
|
daprRun = startDaprApp(ConfigurationIT.class.getSimpleName(), 5000);
|
||||||
daprRun.switchToHTTP();
|
daprRun.switchToHTTP();
|
||||||
daprClient = new DaprClientBuilder().build();
|
daprClient = new DaprClientBuilder().build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterAll
|
||||||
public static void tearDown() throws Exception {
|
public static void tearDown() throws Exception {
|
||||||
daprClient.close();
|
daprClient.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setupConfigStore() {
|
public void setupConfigStore() {
|
||||||
executeDockerCommand(insertCmd);
|
executeDockerCommand(insertCmd);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,17 +6,17 @@ import io.dapr.client.domain.SubscribeConfigurationResponse;
|
||||||
import io.dapr.client.domain.UnsubscribeConfigurationResponse;
|
import io.dapr.client.domain.UnsubscribeConfigurationResponse;
|
||||||
import io.dapr.it.BaseIT;
|
import io.dapr.it.BaseIT;
|
||||||
import io.dapr.it.DaprRun;
|
import io.dapr.it.DaprRun;
|
||||||
import org.junit.AfterClass;
|
import org.junit.jupiter.api.AfterAll;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import reactor.core.publisher.Flux;
|
import reactor.core.publisher.Flux;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
public class ConfigurationSubscribeIT extends BaseIT {
|
public class ConfigurationSubscribeIT extends BaseIT {
|
||||||
private static final String CONFIG_STORE_NAME = "redisconfigstore";
|
private static final String CONFIG_STORE_NAME = "redisconfigstore";
|
||||||
|
@ -37,7 +37,7 @@ public class ConfigurationSubscribeIT extends BaseIT {
|
||||||
"myconfigkey3", "myconfigvalue3||1"
|
"myconfigkey3", "myconfigvalue3||1"
|
||||||
};
|
};
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeAll
|
||||||
public static void init() throws Exception {
|
public static void init() throws Exception {
|
||||||
daprRun = startDaprApp(
|
daprRun = startDaprApp(
|
||||||
ConfigurationIT.class.getSimpleName(),
|
ConfigurationIT.class.getSimpleName(),
|
||||||
|
@ -49,12 +49,12 @@ public class ConfigurationSubscribeIT extends BaseIT {
|
||||||
daprClient = new DaprClientBuilder().build();
|
daprClient = new DaprClientBuilder().build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterAll
|
||||||
public static void tearDown() throws Exception {
|
public static void tearDown() throws Exception {
|
||||||
daprClient.close();
|
daprClient.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setupConfigStore() {
|
public void setupConfigStore() {
|
||||||
executeDockerCommand(insertCmd);
|
executeDockerCommand(insertCmd);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,8 +7,8 @@ import io.dapr.client.domain.HttpExtension;
|
||||||
import io.dapr.exceptions.DaprException;
|
import io.dapr.exceptions.DaprException;
|
||||||
import io.dapr.it.BaseIT;
|
import io.dapr.it.BaseIT;
|
||||||
import io.dapr.it.DaprRun;
|
import io.dapr.it.DaprRun;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -18,9 +18,9 @@ import static io.dapr.it.MethodInvokeServiceProtos.GetMessagesRequest;
|
||||||
import static io.dapr.it.MethodInvokeServiceProtos.GetMessagesResponse;
|
import static io.dapr.it.MethodInvokeServiceProtos.GetMessagesResponse;
|
||||||
import static io.dapr.it.MethodInvokeServiceProtos.PostMessageRequest;
|
import static io.dapr.it.MethodInvokeServiceProtos.PostMessageRequest;
|
||||||
import static io.dapr.it.MethodInvokeServiceProtos.SleepRequest;
|
import static io.dapr.it.MethodInvokeServiceProtos.SleepRequest;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertThrows;
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
public class MethodInvokeIT extends BaseIT {
|
public class MethodInvokeIT extends BaseIT {
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ public class MethodInvokeIT extends BaseIT {
|
||||||
*/
|
*/
|
||||||
private DaprRun daprRun = null;
|
private DaprRun daprRun = null;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void init() throws Exception {
|
public void init() throws Exception {
|
||||||
daprRun = startDaprApp(
|
daprRun = startDaprApp(
|
||||||
MethodInvokeIT.class.getSimpleName(),
|
MethodInvokeIT.class.getSimpleName(),
|
||||||
|
|
|
@ -7,8 +7,8 @@ import io.dapr.exceptions.DaprException;
|
||||||
import io.dapr.it.BaseIT;
|
import io.dapr.it.BaseIT;
|
||||||
import io.dapr.it.DaprRun;
|
import io.dapr.it.DaprRun;
|
||||||
import io.dapr.it.MethodInvokeServiceProtos;
|
import io.dapr.it.MethodInvokeServiceProtos;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -17,10 +17,10 @@ import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
import static org.junit.Assert.assertThrows;
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
public class MethodInvokeIT extends BaseIT {
|
public class MethodInvokeIT extends BaseIT {
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ public class MethodInvokeIT extends BaseIT {
|
||||||
*/
|
*/
|
||||||
private DaprRun daprRun = null;
|
private DaprRun daprRun = null;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void init() throws Exception {
|
public void init() throws Exception {
|
||||||
daprRun = startDaprApp(
|
daprRun = startDaprApp(
|
||||||
MethodInvokeIT.class.getSimpleName(),
|
MethodInvokeIT.class.getSimpleName(),
|
||||||
|
|
|
@ -33,8 +33,11 @@ import io.dapr.it.DaprRun;
|
||||||
import io.dapr.serializer.DaprObjectSerializer;
|
import io.dapr.serializer.DaprObjectSerializer;
|
||||||
import io.dapr.utils.TypeRef;
|
import io.dapr.utils.TypeRef;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Assert;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Assertions;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
|
import org.junit.jupiter.params.provider.ValueSource;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.Parameterized;
|
import org.junit.runners.Parameterized;
|
||||||
|
|
||||||
|
@ -53,14 +56,13 @@ import java.util.Set;
|
||||||
|
|
||||||
import static io.dapr.it.Retry.callWithRetry;
|
import static io.dapr.it.Retry.callWithRetry;
|
||||||
import static io.dapr.it.TestUtils.assertThrowsDaprException;
|
import static io.dapr.it.TestUtils.assertThrowsDaprException;
|
||||||
import static org.junit.Assert.assertArrayEquals;
|
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
|
||||||
@RunWith(Parameterized.class)
|
|
||||||
public class PubSubIT extends BaseIT {
|
public class PubSubIT extends BaseIT {
|
||||||
|
|
||||||
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
|
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
|
||||||
|
@ -88,21 +90,6 @@ public class PubSubIT extends BaseIT {
|
||||||
// Topic to test bulk subscribe.
|
// Topic to test bulk subscribe.
|
||||||
private static final String BULK_SUB_TOPIC_NAME = "topicBulkSub";
|
private static final String BULK_SUB_TOPIC_NAME = "topicBulkSub";
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Parameters for this test.
|
|
||||||
* Param #1: useGrpc.
|
|
||||||
*
|
|
||||||
* @return Collection of parameter tuples.
|
|
||||||
*/
|
|
||||||
@Parameterized.Parameters
|
|
||||||
public static Collection<Object[]> data() {
|
|
||||||
return Arrays.asList(new Object[][]{{false}, {true}});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Parameterized.Parameter
|
|
||||||
public boolean useGrpc;
|
|
||||||
|
|
||||||
private final List<DaprRun> runs = new ArrayList<>();
|
private final List<DaprRun> runs = new ArrayList<>();
|
||||||
|
|
||||||
private DaprRun closeLater(DaprRun run) {
|
private DaprRun closeLater(DaprRun run) {
|
||||||
|
@ -110,19 +97,20 @@ public class PubSubIT extends BaseIT {
|
||||||
return run;
|
return run;
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@AfterEach
|
||||||
public void tearDown() throws Exception {
|
public void tearDown() throws Exception {
|
||||||
for (DaprRun run : runs) {
|
for (DaprRun run : runs) {
|
||||||
run.stop();
|
run.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@ParameterizedTest
|
||||||
public void publishPubSubNotFound() throws Exception {
|
@ValueSource(booleans = {true, false})
|
||||||
|
public void publishPubSubNotFound(boolean useGrpc) throws Exception {
|
||||||
DaprRun daprRun = closeLater(startDaprApp(
|
DaprRun daprRun = closeLater(startDaprApp(
|
||||||
this.getClass().getSimpleName(),
|
this.getClass().getSimpleName(),
|
||||||
60000));
|
60000));
|
||||||
if (this.useGrpc) {
|
if (useGrpc) {
|
||||||
daprRun.switchToGRPC();
|
daprRun.switchToGRPC();
|
||||||
} else {
|
} else {
|
||||||
daprRun.switchToHTTP();
|
daprRun.switchToHTTP();
|
||||||
|
@ -130,7 +118,7 @@ public class PubSubIT extends BaseIT {
|
||||||
|
|
||||||
try (DaprClient client = new DaprClientBuilder().build()) {
|
try (DaprClient client = new DaprClientBuilder().build()) {
|
||||||
|
|
||||||
if (this.useGrpc) {
|
if (useGrpc) {
|
||||||
assertThrowsDaprException(
|
assertThrowsDaprException(
|
||||||
"INVALID_ARGUMENT",
|
"INVALID_ARGUMENT",
|
||||||
"INVALID_ARGUMENT: pubsub unknown pubsub not found",
|
"INVALID_ARGUMENT: pubsub unknown pubsub not found",
|
||||||
|
@ -144,12 +132,13 @@ public class PubSubIT extends BaseIT {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@ParameterizedTest
|
||||||
public void testBulkPublishPubSubNotFound() throws Exception {
|
@ValueSource(booleans = {true, false})
|
||||||
|
public void testBulkPublishPubSubNotFound(boolean useGrpc) throws Exception {
|
||||||
DaprRun daprRun = closeLater(startDaprApp(
|
DaprRun daprRun = closeLater(startDaprApp(
|
||||||
this.getClass().getSimpleName(),
|
this.getClass().getSimpleName(),
|
||||||
60000));
|
60000));
|
||||||
if (this.useGrpc) {
|
if (useGrpc) {
|
||||||
daprRun.switchToGRPC();
|
daprRun.switchToGRPC();
|
||||||
} else {
|
} else {
|
||||||
// No HTTP implementation for bulk publish
|
// No HTTP implementation for bulk publish
|
||||||
|
@ -165,8 +154,9 @@ public class PubSubIT extends BaseIT {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@ParameterizedTest
|
||||||
public void testBulkPublish() throws Exception {
|
@ValueSource(booleans = {true, false})
|
||||||
|
public void testBulkPublish(boolean useGrpc) throws Exception {
|
||||||
final DaprRun daprRun = closeLater(startDaprApp(
|
final DaprRun daprRun = closeLater(startDaprApp(
|
||||||
this.getClass().getSimpleName(),
|
this.getClass().getSimpleName(),
|
||||||
SubscriberService.SUCCESS_MESSAGE,
|
SubscriberService.SUCCESS_MESSAGE,
|
||||||
|
@ -174,7 +164,7 @@ public class PubSubIT extends BaseIT {
|
||||||
true,
|
true,
|
||||||
60000));
|
60000));
|
||||||
// At this point, it is guaranteed that the service above is running and all ports being listened to.
|
// At this point, it is guaranteed that the service above is running and all ports being listened to.
|
||||||
if (this.useGrpc) {
|
if (useGrpc) {
|
||||||
daprRun.switchToGRPC();
|
daprRun.switchToGRPC();
|
||||||
} else {
|
} else {
|
||||||
System.out.println("HTTP BulkPublish is not implemented. So skipping tests");
|
System.out.println("HTTP BulkPublish is not implemented. So skipping tests");
|
||||||
|
@ -208,8 +198,8 @@ public class PubSubIT extends BaseIT {
|
||||||
BulkPublishResponse response = previewClient.publishEvents(PUBSUB_NAME, TOPIC_BULK, "", messages).block();
|
BulkPublishResponse response = previewClient.publishEvents(PUBSUB_NAME, TOPIC_BULK, "", messages).block();
|
||||||
System.out.println(String.format("Published %d messages to topic '%s' pubsub_name '%s'",
|
System.out.println(String.format("Published %d messages to topic '%s' pubsub_name '%s'",
|
||||||
NUM_MESSAGES, TOPIC_BULK, PUBSUB_NAME));
|
NUM_MESSAGES, TOPIC_BULK, PUBSUB_NAME));
|
||||||
assertNotNull("expected not null bulk publish response", response);
|
assertNotNull(response, "expected not null bulk publish response");
|
||||||
Assert.assertEquals("expected no failures in the response", 0, response.getFailedEntries().size());
|
assertEquals( 0, response.getFailedEntries().size(), "expected no failures in the response");
|
||||||
|
|
||||||
//Publishing an object.
|
//Publishing an object.
|
||||||
MyObject object = new MyObject();
|
MyObject object = new MyObject();
|
||||||
|
@ -217,16 +207,16 @@ public class PubSubIT extends BaseIT {
|
||||||
response = previewClient.publishEvents(PUBSUB_NAME, TOPIC_BULK,
|
response = previewClient.publishEvents(PUBSUB_NAME, TOPIC_BULK,
|
||||||
"application/json", Collections.singletonList(object)).block();
|
"application/json", Collections.singletonList(object)).block();
|
||||||
System.out.println("Published one object.");
|
System.out.println("Published one object.");
|
||||||
assertNotNull("expected not null bulk publish response", response);
|
assertNotNull(response, "expected not null bulk publish response");
|
||||||
Assert.assertEquals("expected no failures in the response", 0, response.getFailedEntries().size());
|
assertEquals(0, response.getFailedEntries().size(), "expected no failures in the response");
|
||||||
|
|
||||||
//Publishing a single byte: Example of non-string based content published
|
//Publishing a single byte: Example of non-string based content published
|
||||||
previewClient.publishEvents(PUBSUB_NAME, TOPIC_BULK, "",
|
previewClient.publishEvents(PUBSUB_NAME, TOPIC_BULK, "",
|
||||||
Collections.singletonList(new byte[]{1})).block();
|
Collections.singletonList(new byte[]{1})).block();
|
||||||
System.out.println("Published one byte.");
|
System.out.println("Published one byte.");
|
||||||
|
|
||||||
assertNotNull("expected not null bulk publish response", response);
|
assertNotNull(response, "expected not null bulk publish response");
|
||||||
Assert.assertEquals("expected no failures in the response", 0, response.getFailedEntries().size());
|
assertEquals(0, response.getFailedEntries().size(), "expected no failures in the response");
|
||||||
|
|
||||||
CloudEvent cloudEvent = new CloudEvent();
|
CloudEvent cloudEvent = new CloudEvent();
|
||||||
cloudEvent.setId("1234");
|
cloudEvent.setId("1234");
|
||||||
|
@ -242,8 +232,8 @@ public class PubSubIT extends BaseIT {
|
||||||
|
|
||||||
//Publishing a cloud event.
|
//Publishing a cloud event.
|
||||||
previewClient.publishEvents(req).block();
|
previewClient.publishEvents(req).block();
|
||||||
assertNotNull("expected not null bulk publish response", response);
|
assertNotNull(response, "expected not null bulk publish response");
|
||||||
Assert.assertEquals("expected no failures in the response", 0, response.getFailedEntries().size());
|
assertEquals(0, response.getFailedEntries().size(), "expected no failures in the response");
|
||||||
|
|
||||||
System.out.println("Published one cloud event.");
|
System.out.println("Published one cloud event.");
|
||||||
|
|
||||||
|
@ -260,48 +250,49 @@ public class PubSubIT extends BaseIT {
|
||||||
null,
|
null,
|
||||||
HttpExtension.GET,
|
HttpExtension.GET,
|
||||||
CLOUD_EVENT_LIST_TYPE_REF).block();
|
CLOUD_EVENT_LIST_TYPE_REF).block();
|
||||||
assertEquals("expected 13 messages to be received on subscribe", 13, cloudEventMessages.size());
|
assertEquals(13, cloudEventMessages.size(), "expected 13 messages to be received on subscribe");
|
||||||
for (int i = 0; i < NUM_MESSAGES; i++) {
|
for (int i = 0; i < NUM_MESSAGES; i++) {
|
||||||
final int messageId = i;
|
final int messageId = i;
|
||||||
assertTrue("expected data content to match", cloudEventMessages
|
assertTrue(cloudEventMessages
|
||||||
.stream()
|
.stream()
|
||||||
.filter(m -> m.getData() != null)
|
.filter(m -> m.getData() != null)
|
||||||
.map(m -> m.getData())
|
.map(m -> m.getData())
|
||||||
.filter(m -> m.equals(String.format("This is message #%d on topic %s", messageId, TOPIC_BULK)))
|
.filter(m -> m.equals(String.format("This is message #%d on topic %s", messageId, TOPIC_BULK)))
|
||||||
.count() == 1);
|
.count() == 1, "expected data content to match");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate object payload.
|
// Validate object payload.
|
||||||
assertTrue("expected data content 123 to match", cloudEventMessages
|
assertTrue(cloudEventMessages
|
||||||
.stream()
|
.stream()
|
||||||
.filter(m -> m.getData() != null)
|
.filter(m -> m.getData() != null)
|
||||||
.filter(m -> m.getData() instanceof LinkedHashMap)
|
.filter(m -> m.getData() instanceof LinkedHashMap)
|
||||||
.map(m -> (LinkedHashMap) m.getData())
|
.map(m -> (LinkedHashMap) m.getData())
|
||||||
.filter(m -> "123".equals(m.get("id")))
|
.filter(m -> "123".equals(m.get("id")))
|
||||||
.count() == 1);
|
.count() == 1, "expected data content 123 to match");
|
||||||
|
|
||||||
// Validate byte payload.
|
// Validate byte payload.
|
||||||
assertTrue("expected bin data to match", cloudEventMessages
|
assertTrue(cloudEventMessages
|
||||||
.stream()
|
.stream()
|
||||||
.filter(m -> m.getData() != null)
|
.filter(m -> m.getData() != null)
|
||||||
.map(m -> m.getData())
|
.map(m -> m.getData())
|
||||||
.filter(m -> "AQ==".equals(m))
|
.filter(m -> "AQ==".equals(m))
|
||||||
.count() == 1);
|
.count() == 1, "expected bin data to match");
|
||||||
|
|
||||||
// Validate cloudevent payload.
|
// Validate cloudevent payload.
|
||||||
assertTrue("expected data to match",cloudEventMessages
|
assertTrue( cloudEventMessages
|
||||||
.stream()
|
.stream()
|
||||||
.filter(m -> m.getData() != null)
|
.filter(m -> m.getData() != null)
|
||||||
.map(m -> m.getData())
|
.map(m -> m.getData())
|
||||||
.filter(m -> "message from cloudevent".equals(m))
|
.filter(m -> "message from cloudevent".equals(m))
|
||||||
.count() == 1);
|
.count() == 1, "expected data to match");
|
||||||
}, 2000);
|
}, 2000);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@ParameterizedTest
|
||||||
public void testPubSub() throws Exception {
|
@ValueSource(booleans = {true, false})
|
||||||
|
public void testPubSub(boolean useGrpc) throws Exception {
|
||||||
final DaprRun daprRun = closeLater(startDaprApp(
|
final DaprRun daprRun = closeLater(startDaprApp(
|
||||||
this.getClass().getSimpleName(),
|
this.getClass().getSimpleName(),
|
||||||
SubscriberService.SUCCESS_MESSAGE,
|
SubscriberService.SUCCESS_MESSAGE,
|
||||||
|
@ -309,7 +300,7 @@ public class PubSubIT extends BaseIT {
|
||||||
true,
|
true,
|
||||||
60000));
|
60000));
|
||||||
// At this point, it is guaranteed that the service above is running and all ports being listened to.
|
// At this point, it is guaranteed that the service above is running and all ports being listened to.
|
||||||
if (this.useGrpc) {
|
if (useGrpc) {
|
||||||
daprRun.switchToGRPC();
|
daprRun.switchToGRPC();
|
||||||
} else {
|
} else {
|
||||||
daprRun.switchToHTTP();
|
daprRun.switchToHTTP();
|
||||||
|
@ -520,8 +511,9 @@ public class PubSubIT extends BaseIT {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@ParameterizedTest
|
||||||
public void testPubSubBinary() throws Exception {
|
@ValueSource(booleans = {true, false})
|
||||||
|
public void testPubSubBinary(boolean useGrpc) throws Exception {
|
||||||
final DaprRun daprRun = closeLater(startDaprApp(
|
final DaprRun daprRun = closeLater(startDaprApp(
|
||||||
this.getClass().getSimpleName(),
|
this.getClass().getSimpleName(),
|
||||||
SubscriberService.SUCCESS_MESSAGE,
|
SubscriberService.SUCCESS_MESSAGE,
|
||||||
|
@ -529,7 +521,7 @@ public class PubSubIT extends BaseIT {
|
||||||
true,
|
true,
|
||||||
60000));
|
60000));
|
||||||
// At this point, it is guaranteed that the service above is running and all ports being listened to.
|
// At this point, it is guaranteed that the service above is running and all ports being listened to.
|
||||||
if (this.useGrpc) {
|
if (useGrpc) {
|
||||||
daprRun.switchToGRPC();
|
daprRun.switchToGRPC();
|
||||||
} else {
|
} else {
|
||||||
daprRun.switchToHTTP();
|
daprRun.switchToHTTP();
|
||||||
|
@ -576,12 +568,13 @@ public class PubSubIT extends BaseIT {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@ParameterizedTest
|
||||||
public void testPubSubTTLMetadata() throws Exception {
|
@ValueSource(booleans = {true, false})
|
||||||
|
public void testPubSubTTLMetadata(boolean useGrpc) throws Exception {
|
||||||
DaprRun daprRun = closeLater(startDaprApp(
|
DaprRun daprRun = closeLater(startDaprApp(
|
||||||
this.getClass().getSimpleName(),
|
this.getClass().getSimpleName(),
|
||||||
60000));
|
60000));
|
||||||
if (this.useGrpc) {
|
if (useGrpc) {
|
||||||
daprRun.switchToGRPC();
|
daprRun.switchToGRPC();
|
||||||
} else {
|
} else {
|
||||||
daprRun.switchToHTTP();
|
daprRun.switchToHTTP();
|
||||||
|
@ -612,7 +605,7 @@ public class PubSubIT extends BaseIT {
|
||||||
SubscriberService.class,
|
SubscriberService.class,
|
||||||
true,
|
true,
|
||||||
60000));
|
60000));
|
||||||
if (this.useGrpc) {
|
if (useGrpc) {
|
||||||
daprRun.switchToGRPC();
|
daprRun.switchToGRPC();
|
||||||
} else {
|
} else {
|
||||||
daprRun.switchToHTTP();
|
daprRun.switchToHTTP();
|
||||||
|
@ -633,15 +626,16 @@ public class PubSubIT extends BaseIT {
|
||||||
daprRun.stop();
|
daprRun.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@ParameterizedTest
|
||||||
public void testPubSubBulkSubscribe() throws Exception {
|
@ValueSource(booleans = {true, false})
|
||||||
|
public void testPubSubBulkSubscribe(boolean useGrpc) throws Exception {
|
||||||
DaprRun daprRun = closeLater(startDaprApp(
|
DaprRun daprRun = closeLater(startDaprApp(
|
||||||
this.getClass().getSimpleName(),
|
this.getClass().getSimpleName(),
|
||||||
SubscriberService.SUCCESS_MESSAGE,
|
SubscriberService.SUCCESS_MESSAGE,
|
||||||
SubscriberService.class,
|
SubscriberService.class,
|
||||||
true,
|
true,
|
||||||
60000));
|
60000));
|
||||||
if (this.useGrpc) {
|
if (useGrpc) {
|
||||||
daprRun.switchToGRPC();
|
daprRun.switchToGRPC();
|
||||||
} else {
|
} else {
|
||||||
daprRun.switchToHTTP();
|
daprRun.switchToHTTP();
|
||||||
|
@ -695,8 +689,9 @@ public class PubSubIT extends BaseIT {
|
||||||
daprRun.stop();
|
daprRun.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@ParameterizedTest
|
||||||
public void testLongValues() throws Exception {
|
@ValueSource(booleans = {true, false})
|
||||||
|
public void testLongValues(boolean useGrpc) throws Exception {
|
||||||
final DaprRun daprRun = closeLater(startDaprApp(
|
final DaprRun daprRun = closeLater(startDaprApp(
|
||||||
this.getClass().getSimpleName(),
|
this.getClass().getSimpleName(),
|
||||||
SubscriberService.SUCCESS_MESSAGE,
|
SubscriberService.SUCCESS_MESSAGE,
|
||||||
|
@ -704,7 +699,7 @@ public class PubSubIT extends BaseIT {
|
||||||
true,
|
true,
|
||||||
60000));
|
60000));
|
||||||
// At this point, it is guaranteed that the service above is running and all ports being listened to.
|
// At this point, it is guaranteed that the service above is running and all ports being listened to.
|
||||||
if (this.useGrpc) {
|
if (useGrpc) {
|
||||||
daprRun.switchToGRPC();
|
daprRun.switchToGRPC();
|
||||||
} else {
|
} else {
|
||||||
daprRun.switchToHTTP();
|
daprRun.switchToHTTP();
|
||||||
|
@ -755,7 +750,7 @@ public class PubSubIT extends BaseIT {
|
||||||
for (CloudEvent<ConvertToLong> message : messages) {
|
for (CloudEvent<ConvertToLong> message : messages) {
|
||||||
actual.add(message.getData());
|
actual.add(message.getData());
|
||||||
}
|
}
|
||||||
Assert.assertEquals(values, actual);
|
Assertions.assertEquals(values, actual);
|
||||||
}, 2000);
|
}, 2000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,9 +20,9 @@ import io.dapr.client.resiliency.ResiliencyOptions;
|
||||||
import io.dapr.it.BaseIT;
|
import io.dapr.it.BaseIT;
|
||||||
import io.dapr.it.DaprRun;
|
import io.dapr.it.DaprRun;
|
||||||
import io.dapr.it.ToxiProxyRun;
|
import io.dapr.it.ToxiProxyRun;
|
||||||
import org.junit.AfterClass;
|
import org.junit.jupiter.api.AfterAll;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
@ -30,15 +30,15 @@ import java.util.Base64;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test SDK resiliency.
|
* Test SDK resiliency.
|
||||||
*/
|
*/
|
||||||
public class SdkResiliencytIT extends BaseIT {
|
public class SdkResiliencytIT extends BaseIT {
|
||||||
|
|
||||||
private static final int NUM_ITERATIONS = 20;
|
private static final int NUM_ITERATIONS = 25;
|
||||||
|
|
||||||
private static final Duration TIMEOUT = Duration.ofMillis(100);
|
private static final Duration TIMEOUT = Duration.ofMillis(100);
|
||||||
|
|
||||||
|
@ -62,16 +62,18 @@ public class SdkResiliencytIT extends BaseIT {
|
||||||
|
|
||||||
private final String randomStateKeyPrefix = UUID.randomUUID().toString();
|
private final String randomStateKeyPrefix = UUID.randomUUID().toString();
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeAll
|
||||||
public static void init() throws Exception {
|
public static void init() throws Exception {
|
||||||
daprRun = startDaprApp(SdkResiliencytIT.class.getSimpleName(), 5000);
|
daprRun = startDaprApp(SdkResiliencytIT.class.getSimpleName(), 5000);
|
||||||
// HTTP client is deprecated, so SDK resiliency is for gRPC client only.
|
// HTTP client is deprecated, so SDK resiliency is for gRPC client only.
|
||||||
daprRun.switchToGRPC();
|
daprRun.switchToGRPC();
|
||||||
daprClient = new DaprClientBuilder().build();
|
daprClient = new DaprClientBuilder().build();
|
||||||
|
daprClient.waitForSidecar(8000).block();
|
||||||
|
|
||||||
toxiProxyRun = new ToxiProxyRun(daprRun, LATENCY, JITTER);
|
toxiProxyRun = new ToxiProxyRun(daprRun, LATENCY, JITTER);
|
||||||
toxiProxyRun.start();
|
toxiProxyRun.start();
|
||||||
toxiProxyRun.use();
|
toxiProxyRun.use();
|
||||||
|
|
||||||
daprToxiClient = new DaprClientBuilder()
|
daprToxiClient = new DaprClientBuilder()
|
||||||
.withResiliencyOptions(
|
.withResiliencyOptions(
|
||||||
new ResiliencyOptions().setTimeout(TIMEOUT))
|
new ResiliencyOptions().setTimeout(TIMEOUT))
|
||||||
|
@ -91,7 +93,7 @@ public class SdkResiliencytIT extends BaseIT {
|
||||||
assertTrue(daprRetriesOnceClient instanceof DaprClientGrpc);
|
assertTrue(daprRetriesOnceClient instanceof DaprClientGrpc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterAll
|
||||||
public static void tearDown() throws Exception {
|
public static void tearDown() throws Exception {
|
||||||
if (daprClient != null) {
|
if (daprClient != null) {
|
||||||
daprClient.close();
|
daprClient.close();
|
||||||
|
|
|
@ -22,7 +22,12 @@ import org.apache.commons.io.IOUtils;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
|
import org.junit.jupiter.params.provider.ValueSource;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.Parameterized;
|
import org.junit.runners.Parameterized;
|
||||||
|
|
||||||
|
@ -35,15 +40,15 @@ import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test Secrets Store APIs using local file.
|
* Test Secrets Store APIs using local file.
|
||||||
*
|
*
|
||||||
* 1. create secret file locally:
|
* 1. create secret file locally:
|
||||||
*/
|
*/
|
||||||
@RunWith(Parameterized.class)
|
|
||||||
public class SecretsClientIT extends BaseIT {
|
public class SecretsClientIT extends BaseIT {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -61,24 +66,12 @@ public class SecretsClientIT extends BaseIT {
|
||||||
|
|
||||||
private static DaprRun daprRun;
|
private static DaprRun daprRun;
|
||||||
|
|
||||||
/**
|
|
||||||
* Parameters for this test.
|
|
||||||
* Param #1: useGrpc.
|
|
||||||
* @return Collection of parameter tuples.
|
|
||||||
*/
|
|
||||||
@Parameterized.Parameters
|
|
||||||
public static Collection<Object[]> data() {
|
|
||||||
return Arrays.asList(new Object[][] { { false }, { true } });
|
|
||||||
}
|
|
||||||
|
|
||||||
@Parameterized.Parameter
|
|
||||||
public boolean useGrpc = true;
|
|
||||||
|
|
||||||
private DaprClient daprClient;
|
private DaprClient daprClient;
|
||||||
|
|
||||||
private static File localSecretFile;
|
private static File localSecretFile;
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeAll
|
||||||
public static void init() throws Exception {
|
public static void init() throws Exception {
|
||||||
|
|
||||||
localSecretFile = new File(LOCAL_SECRET_FILE_PATH);
|
localSecretFile = new File(LOCAL_SECRET_FILE_PATH);
|
||||||
|
@ -89,9 +82,8 @@ public class SecretsClientIT extends BaseIT {
|
||||||
daprRun = startDaprApp(SecretsClientIT.class.getSimpleName(), 5000);
|
daprRun = startDaprApp(SecretsClientIT.class.getSimpleName(), 5000);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
public void setup(boolean useGrpc) {
|
||||||
public void setup() {
|
if (useGrpc) {
|
||||||
if (this.useGrpc) {
|
|
||||||
daprRun.switchToGRPC();
|
daprRun.switchToGRPC();
|
||||||
} else {
|
} else {
|
||||||
daprRun.switchToHTTP();
|
daprRun.switchToHTTP();
|
||||||
|
@ -100,14 +92,16 @@ public class SecretsClientIT extends BaseIT {
|
||||||
this.daprClient = new DaprClientBuilder().build();
|
this.daprClient = new DaprClientBuilder().build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@AfterEach
|
||||||
public void tearDown() throws Exception {
|
public void tearDown() throws Exception {
|
||||||
daprClient.close();
|
daprClient.close();
|
||||||
clearSecretFile();
|
clearSecretFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@ParameterizedTest
|
||||||
public void getSecret() throws Exception {
|
@ValueSource(booleans = {true, false})
|
||||||
|
public void getSecret(boolean useGrpc) throws Exception {
|
||||||
|
setup(useGrpc);
|
||||||
|
|
||||||
Map<String, String> data = daprClient.getSecret(SECRETS_STORE_NAME, KEY1).block();
|
Map<String, String> data = daprClient.getSecret(SECRETS_STORE_NAME, KEY1).block();
|
||||||
assertEquals(2, data.size());
|
assertEquals(2, data.size());
|
||||||
|
@ -115,8 +109,10 @@ public class SecretsClientIT extends BaseIT {
|
||||||
assertEquals("2020", data.get("year"));
|
assertEquals("2020", data.get("year"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@ParameterizedTest
|
||||||
public void getBulkSecret() throws Exception {
|
@ValueSource(booleans = {true, false})
|
||||||
|
public void getBulkSecret(boolean useGrpc) throws Exception {
|
||||||
|
setup(useGrpc);
|
||||||
|
|
||||||
Map<String, Map<String, String>> data = daprClient.getBulkSecret(SECRETS_STORE_NAME).block();
|
Map<String, Map<String, String>> data = daprClient.getBulkSecret(SECRETS_STORE_NAME).block();
|
||||||
// There can be other keys from other runs or test cases, so we are good with at least two.
|
// There can be other keys from other runs or test cases, so we are good with at least two.
|
||||||
|
@ -128,14 +124,20 @@ public class SecretsClientIT extends BaseIT {
|
||||||
assertEquals("Jon Doe", data.get(KYE2).get("name"));
|
assertEquals("Jon Doe", data.get(KYE2).get("name"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = RuntimeException.class)
|
@ParameterizedTest
|
||||||
public void getSecretKeyNotFound() {
|
@ValueSource(booleans = {true, false})
|
||||||
daprClient.getSecret(SECRETS_STORE_NAME, "unknownKey").block();
|
public void getSecretKeyNotFound(boolean useGrpc) {
|
||||||
|
setup(useGrpc);
|
||||||
|
|
||||||
|
assertThrows(RuntimeException.class, () -> daprClient.getSecret(SECRETS_STORE_NAME, "unknownKey").block());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = RuntimeException.class)
|
@ParameterizedTest
|
||||||
public void getSecretStoreNotFound() throws Exception {
|
@ValueSource(booleans = {true, false})
|
||||||
daprClient.getSecret("unknownStore", "unknownKey").block();
|
public void getSecretStoreNotFound(boolean useGrpc) throws Exception {
|
||||||
|
setup(useGrpc);
|
||||||
|
|
||||||
|
assertThrows(RuntimeException.class, () -> daprClient.getSecret("unknownStore", "unknownKey").block());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void initSecretFile() throws Exception {
|
private static void initSecretFile() throws Exception {
|
||||||
|
|
|
@ -28,7 +28,7 @@ import io.dapr.client.domain.query.Sorting;
|
||||||
import io.dapr.client.domain.query.filters.EqFilter;
|
import io.dapr.client.domain.query.filters.EqFilter;
|
||||||
import io.dapr.exceptions.DaprException;
|
import io.dapr.exceptions.DaprException;
|
||||||
import io.dapr.it.BaseIT;
|
import io.dapr.it.BaseIT;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -39,13 +39,13 @@ import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.Assert.assertNotEquals;
|
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
import static org.junit.Assert.assertThrows;
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Common test cases for Dapr client (GRPC and HTTP).
|
* Common test cases for Dapr client (GRPC and HTTP).
|
||||||
|
@ -244,7 +244,7 @@ public abstract class AbstractStateClientIT extends BaseIT {
|
||||||
State<MyData> myDataResponse = response.block();
|
State<MyData> myDataResponse = response.block();
|
||||||
|
|
||||||
//review that the update was success action
|
//review that the update was success action
|
||||||
assertNotNull("expected non null response", myDataResponse);
|
assertNotNull(myDataResponse, "expected non null response");
|
||||||
assertEquals("data in property A", myDataResponse.getValue().getPropertyA());
|
assertEquals("data in property A", myDataResponse.getValue().getPropertyA());
|
||||||
assertEquals("data in property B2", myDataResponse.getValue().getPropertyB());
|
assertEquals("data in property B2", myDataResponse.getValue().getPropertyB());
|
||||||
}
|
}
|
||||||
|
@ -391,7 +391,7 @@ public abstract class AbstractStateClientIT extends BaseIT {
|
||||||
assertEquals(0, stateNullValue.getMetadata().size());
|
assertEquals(0, stateNullValue.getMetadata().size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = RuntimeException.class)
|
@Test
|
||||||
public void saveUpdateAndGetStateWithWrongEtag() {
|
public void saveUpdateAndGetStateWithWrongEtag() {
|
||||||
final String stateKey = "keyToBeUpdatedWithWrongEtag";
|
final String stateKey = "keyToBeUpdatedWithWrongEtag";
|
||||||
|
|
||||||
|
@ -402,7 +402,7 @@ public abstract class AbstractStateClientIT extends BaseIT {
|
||||||
data.setPropertyA("data in property A");
|
data.setPropertyA("data in property A");
|
||||||
data.setPropertyB("data in property B");
|
data.setPropertyB("data in property B");
|
||||||
|
|
||||||
//Create deferred action to save the sate
|
//Create deferred action to save the state
|
||||||
Mono<Void> saveResponse = daprClient.saveState(STATE_STORE_NAME, stateKey, null, data, null);
|
Mono<Void> saveResponse = daprClient.saveState(STATE_STORE_NAME, stateKey, null, data, null);
|
||||||
//execute the save state action
|
//execute the save state action
|
||||||
saveResponse.block();
|
saveResponse.block();
|
||||||
|
@ -427,21 +427,9 @@ public abstract class AbstractStateClientIT extends BaseIT {
|
||||||
data.setPropertyB("data in property B2");
|
data.setPropertyB("data in property B2");
|
||||||
//Create deferred action to update the data using the incorrect etag
|
//Create deferred action to update the data using the incorrect etag
|
||||||
saveResponse = daprClient.saveState(STATE_STORE_NAME, stateKey, "99999999999999", data, null);
|
saveResponse = daprClient.saveState(STATE_STORE_NAME, stateKey, "99999999999999", data, null);
|
||||||
saveResponse.block();
|
|
||||||
|
|
||||||
|
Mono<Void> finalSaveResponse = saveResponse;
|
||||||
response = daprClient.getState(STATE_STORE_NAME, new State<>(stateKey, (MyData) null, null), MyData.class);
|
assertThrows(RuntimeException.class, finalSaveResponse::block);
|
||||||
//retrive the data wihout any etag
|
|
||||||
myDataResponse = response.block();
|
|
||||||
|
|
||||||
//review that state value changes
|
|
||||||
assertNotNull(myDataResponse.getEtag());
|
|
||||||
//review that the etag changes after an update
|
|
||||||
assertNotEquals(firstETag, myDataResponse.getEtag());
|
|
||||||
assertNotNull(myDataResponse.getKey());
|
|
||||||
assertNotNull(myDataResponse.getValue());
|
|
||||||
assertEquals("data in property A2", myDataResponse.getValue().getPropertyA());
|
|
||||||
assertEquals("data in property B2", myDataResponse.getValue().getPropertyB());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -484,7 +472,7 @@ public abstract class AbstractStateClientIT extends BaseIT {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test(expected = RuntimeException.class)
|
@Test
|
||||||
public void saveAndDeleteStateWithWrongEtag() {
|
public void saveAndDeleteStateWithWrongEtag() {
|
||||||
final String stateKey = "myeKeyToBeDeletedWithWrongEtag";
|
final String stateKey = "myeKeyToBeDeletedWithWrongEtag";
|
||||||
|
|
||||||
|
@ -513,18 +501,11 @@ public abstract class AbstractStateClientIT extends BaseIT {
|
||||||
|
|
||||||
//Create deferred action to delete an state sending the incorrect etag
|
//Create deferred action to delete an state sending the incorrect etag
|
||||||
Mono<Void> deleteResponse = daprClient.deleteState(STATE_STORE_NAME, stateKey, "99999999999", null);
|
Mono<Void> deleteResponse = daprClient.deleteState(STATE_STORE_NAME, stateKey, "99999999999", null);
|
||||||
//execute the delete of the state, this should trhow an exception
|
//execute the delete of the state, this should throw an exception
|
||||||
deleteResponse.block();
|
assertThrows(RuntimeException.class, deleteResponse::block);
|
||||||
|
|
||||||
//Create deferred action to get the sate without an etag
|
|
||||||
response = daprClient.getState(STATE_STORE_NAME, new State(stateKey), MyData.class);
|
|
||||||
myDataResponse = response.block();
|
|
||||||
|
|
||||||
//Review that the response is null, because the state was deleted
|
|
||||||
assertNull(myDataResponse.getValue());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = RuntimeException.class)
|
@Test
|
||||||
public void saveUpdateAndGetStateWithEtagAndStateOptionsFirstWrite() {
|
public void saveUpdateAndGetStateWithEtagAndStateOptionsFirstWrite() {
|
||||||
final String stateKey = "keyToBeUpdatedWithEtagAndOptions";
|
final String stateKey = "keyToBeUpdatedWithEtagAndOptions";
|
||||||
|
|
||||||
|
@ -545,7 +526,7 @@ public abstract class AbstractStateClientIT extends BaseIT {
|
||||||
saveResponse.block();
|
saveResponse.block();
|
||||||
|
|
||||||
|
|
||||||
//crate deferred action to retrieve the state
|
//create deferred action to retrieve the state
|
||||||
Mono<State<MyData>> response = daprClient.getState(STATE_STORE_NAME, new State(stateKey, null, stateOptions),
|
Mono<State<MyData>> response = daprClient.getState(STATE_STORE_NAME, new State(stateKey, null, stateOptions),
|
||||||
MyData.class);
|
MyData.class);
|
||||||
//execute the retrieve of the state using options
|
//execute the retrieve of the state using options
|
||||||
|
@ -557,7 +538,7 @@ public abstract class AbstractStateClientIT extends BaseIT {
|
||||||
assertEquals("data in property A", myDataResponse.getValue().getPropertyA());
|
assertEquals("data in property A", myDataResponse.getValue().getPropertyA());
|
||||||
assertEquals("data in property B", myDataResponse.getValue().getPropertyB());
|
assertEquals("data in property B", myDataResponse.getValue().getPropertyB());
|
||||||
|
|
||||||
//change data to be udpated
|
//change data to be updated
|
||||||
data.setPropertyA("data in property A2");
|
data.setPropertyA("data in property A2");
|
||||||
data.setPropertyB("data in property B2");
|
data.setPropertyB("data in property B2");
|
||||||
//create deferred action to update the action with options
|
//create deferred action to update the action with options
|
||||||
|
@ -570,8 +551,10 @@ public abstract class AbstractStateClientIT extends BaseIT {
|
||||||
data.setPropertyB("data in property B2");
|
data.setPropertyB("data in property B2");
|
||||||
//create deferred action to update the action with the same etag
|
//create deferred action to update the action with the same etag
|
||||||
saveResponse = daprClient.saveState(STATE_STORE_NAME, stateKey, myDataResponse.getEtag(), data, stateOptions);
|
saveResponse = daprClient.saveState(STATE_STORE_NAME, stateKey, myDataResponse.getEtag(), data, stateOptions);
|
||||||
//throws an exception, the state was already udpated
|
//throws an exception, the state was already updated
|
||||||
saveResponse.block();
|
|
||||||
|
Mono<Void> finalSaveResponse2 = saveResponse;
|
||||||
|
assertThrows(RuntimeException.class, () -> finalSaveResponse2.block());
|
||||||
|
|
||||||
response = daprClient.getState(STATE_STORE_NAME, new State(stateKey, null, stateOptions), MyData.class);
|
response = daprClient.getState(STATE_STORE_NAME, new State(stateKey, null, stateOptions), MyData.class);
|
||||||
State<MyData> myLastDataResponse = response.block();
|
State<MyData> myLastDataResponse = response.block();
|
||||||
|
|
|
@ -17,9 +17,9 @@ import io.dapr.client.DaprClient;
|
||||||
import io.dapr.client.DaprClientBuilder;
|
import io.dapr.client.DaprClientBuilder;
|
||||||
import io.dapr.client.domain.State;
|
import io.dapr.client.domain.State;
|
||||||
import io.dapr.it.DaprRun;
|
import io.dapr.it.DaprRun;
|
||||||
import org.junit.AfterClass;
|
import org.junit.jupiter.api.AfterAll;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
|
@ -34,14 +34,14 @@ public class GRPCStateClientIT extends AbstractStateClientIT {
|
||||||
|
|
||||||
private static DaprClient daprClient;
|
private static DaprClient daprClient;
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeAll
|
||||||
public static void init() throws Exception {
|
public static void init() throws Exception {
|
||||||
daprRun = startDaprApp(GRPCStateClientIT.class.getSimpleName(), 5000);
|
daprRun = startDaprApp(GRPCStateClientIT.class.getSimpleName(), 5000);
|
||||||
daprRun.switchToGRPC();
|
daprRun.switchToGRPC();
|
||||||
daprClient = new DaprClientBuilder().build();
|
daprClient = new DaprClientBuilder().build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterAll
|
||||||
public static void tearDown() throws Exception {
|
public static void tearDown() throws Exception {
|
||||||
daprClient.close();
|
daprClient.close();
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,8 +19,8 @@ import io.dapr.v1.DaprGrpc;
|
||||||
import io.dapr.v1.DaprProtos;
|
import io.dapr.v1.DaprProtos;
|
||||||
import io.grpc.ManagedChannel;
|
import io.grpc.ManagedChannel;
|
||||||
import io.grpc.ManagedChannelBuilder;
|
import io.grpc.ManagedChannelBuilder;
|
||||||
import org.junit.Assert;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
public class HelloWorldClientIT extends BaseIT {
|
public class HelloWorldClientIT extends BaseIT {
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ public class HelloWorldClientIT extends BaseIT {
|
||||||
DaprProtos.GetStateResponse response = client.getState(req);
|
DaprProtos.GetStateResponse response = client.getState(req);
|
||||||
String value = response.getData().toStringUtf8();
|
String value = response.getData().toStringUtf8();
|
||||||
System.out.println("Got: " + value);
|
System.out.println("Got: " + value);
|
||||||
Assert.assertEquals("Hello World", value);
|
Assertions.assertEquals("Hello World", value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Then, delete it.
|
// Then, delete it.
|
||||||
|
@ -70,7 +70,7 @@ public class HelloWorldClientIT extends BaseIT {
|
||||||
DaprProtos.GetStateResponse response = client.getState(req);
|
DaprProtos.GetStateResponse response = client.getState(req);
|
||||||
String value = response.getData().toStringUtf8();
|
String value = response.getData().toStringUtf8();
|
||||||
System.out.println("Got: " + value);
|
System.out.println("Got: " + value);
|
||||||
Assert.assertEquals("", value);
|
Assertions.assertEquals("", value);
|
||||||
}
|
}
|
||||||
channel.shutdown();
|
channel.shutdown();
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,14 +18,14 @@ import io.dapr.client.DaprClientBuilder;
|
||||||
import io.dapr.client.DaprClientHttp;
|
import io.dapr.client.DaprClientHttp;
|
||||||
import io.dapr.client.domain.State;
|
import io.dapr.client.domain.State;
|
||||||
import io.dapr.it.DaprRun;
|
import io.dapr.it.DaprRun;
|
||||||
import org.junit.AfterClass;
|
import org.junit.jupiter.api.AfterAll;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
import static io.dapr.it.TestUtils.assertThrowsDaprException;
|
import static io.dapr.it.TestUtils.assertThrowsDaprException;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test State HTTP DAPR capabilities using a DAPR instance with an empty service running
|
* Test State HTTP DAPR capabilities using a DAPR instance with an empty service running
|
||||||
|
@ -36,7 +36,7 @@ public class HttpStateClientIT extends AbstractStateClientIT {
|
||||||
|
|
||||||
private static DaprClient daprClient;
|
private static DaprClient daprClient;
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeAll
|
||||||
public static void init() throws Exception {
|
public static void init() throws Exception {
|
||||||
daprRun = startDaprApp(HttpStateClientIT.class.getSimpleName(), 5000);
|
daprRun = startDaprApp(HttpStateClientIT.class.getSimpleName(), 5000);
|
||||||
daprRun.switchToHTTP();
|
daprRun.switchToHTTP();
|
||||||
|
@ -44,7 +44,7 @@ public class HttpStateClientIT extends AbstractStateClientIT {
|
||||||
assertTrue(daprClient instanceof DaprClientHttp);
|
assertTrue(daprClient instanceof DaprClientHttp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterAll
|
||||||
public static void tearDown() throws Exception {
|
public static void tearDown() throws Exception {
|
||||||
daprClient.close();
|
daprClient.close();
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,8 +21,8 @@ import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
|
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class used to verify that traces are present as expected.
|
* Class used to verify that traces are present as expected.
|
||||||
|
|
|
@ -13,7 +13,11 @@ import io.opentelemetry.api.trace.Tracer;
|
||||||
import io.opentelemetry.context.Scope;
|
import io.opentelemetry.context.Scope;
|
||||||
import io.opentelemetry.sdk.OpenTelemetrySdk;
|
import io.opentelemetry.sdk.OpenTelemetrySdk;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
|
import org.junit.jupiter.params.provider.MethodSource;
|
||||||
|
import org.junit.jupiter.params.provider.ValueSource;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.Parameterized;
|
import org.junit.runners.Parameterized;
|
||||||
|
|
||||||
|
@ -27,29 +31,14 @@ import static io.dapr.it.tracing.OpenTelemetry.getReactorContext;
|
||||||
import static org.junit.runners.Parameterized.Parameter;
|
import static org.junit.runners.Parameterized.Parameter;
|
||||||
import static org.junit.runners.Parameterized.Parameters;
|
import static org.junit.runners.Parameterized.Parameters;
|
||||||
|
|
||||||
@RunWith(Parameterized.class)
|
|
||||||
public class TracingIT extends BaseIT {
|
public class TracingIT extends BaseIT {
|
||||||
|
|
||||||
/**
|
|
||||||
* Parameters for this test.
|
|
||||||
* Param #1: useGrpc.
|
|
||||||
* @return Collection of parameter tuples.
|
|
||||||
*/
|
|
||||||
@Parameters
|
|
||||||
public static Collection<Object[]> data() {
|
|
||||||
return Arrays.asList(new Object[][] { { false }, { true } });
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run of a Dapr application.
|
* Run of a Dapr application.
|
||||||
*/
|
*/
|
||||||
private DaprRun daprRun = null;
|
private DaprRun daprRun = null;
|
||||||
|
|
||||||
@Parameter
|
public void setup(boolean useGrpc) throws Exception {
|
||||||
public boolean useGrpc;
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void init() throws Exception {
|
|
||||||
daprRun = startDaprApp(
|
daprRun = startDaprApp(
|
||||||
TracingIT.class.getSimpleName(),
|
TracingIT.class.getSimpleName(),
|
||||||
Service.SUCCESS_MESSAGE,
|
Service.SUCCESS_MESSAGE,
|
||||||
|
@ -57,7 +46,7 @@ public class TracingIT extends BaseIT {
|
||||||
DaprApiProtocol.GRPC, // appProtocol
|
DaprApiProtocol.GRPC, // appProtocol
|
||||||
60000);
|
60000);
|
||||||
|
|
||||||
if (this.useGrpc) {
|
if (useGrpc) {
|
||||||
daprRun.switchToGRPC();
|
daprRun.switchToGRPC();
|
||||||
} else {
|
} else {
|
||||||
daprRun.switchToHTTP();
|
daprRun.switchToHTTP();
|
||||||
|
@ -67,8 +56,11 @@ public class TracingIT extends BaseIT {
|
||||||
Thread.sleep(2000);
|
Thread.sleep(2000);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@ParameterizedTest
|
||||||
public void testInvoke() throws Exception {
|
@ValueSource(booleans = {true, false})
|
||||||
|
public void testInvoke(boolean useGrpc) throws Exception {
|
||||||
|
setup(useGrpc);
|
||||||
|
|
||||||
final OpenTelemetry openTelemetry = createOpenTelemetry("service over grpc");
|
final OpenTelemetry openTelemetry = createOpenTelemetry("service over grpc");
|
||||||
final Tracer tracer = openTelemetry.getTracer("grpc integration test tracer");
|
final Tracer tracer = openTelemetry.getTracer("grpc integration test tracer");
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,9 @@ import io.opentelemetry.api.trace.Tracer;
|
||||||
import io.opentelemetry.context.Scope;
|
import io.opentelemetry.context.Scope;
|
||||||
import io.opentelemetry.sdk.OpenTelemetrySdk;
|
import io.opentelemetry.sdk.OpenTelemetrySdk;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
|
import org.junit.jupiter.params.provider.ValueSource;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.Parameterized;
|
import org.junit.runners.Parameterized;
|
||||||
|
|
||||||
|
@ -25,29 +27,14 @@ import static io.dapr.it.tracing.OpenTelemetry.getReactorContext;
|
||||||
import static org.junit.runners.Parameterized.Parameter;
|
import static org.junit.runners.Parameterized.Parameter;
|
||||||
import static org.junit.runners.Parameterized.Parameters;
|
import static org.junit.runners.Parameterized.Parameters;
|
||||||
|
|
||||||
@RunWith(Parameterized.class)
|
|
||||||
public class TracingIT extends BaseIT {
|
public class TracingIT extends BaseIT {
|
||||||
|
|
||||||
/**
|
|
||||||
* Parameters for this test.
|
|
||||||
* Param #1: useGrpc.
|
|
||||||
* @return Collection of parameter tuples.
|
|
||||||
*/
|
|
||||||
@Parameters
|
|
||||||
public static Collection<Object[]> data() {
|
|
||||||
return Arrays.asList(new Object[][] { { false }, { true } });
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run of a Dapr application.
|
* Run of a Dapr application.
|
||||||
*/
|
*/
|
||||||
private DaprRun daprRun = null;
|
private DaprRun daprRun = null;
|
||||||
|
|
||||||
@Parameter
|
public void setup(boolean useGrpc) throws Exception {
|
||||||
public boolean useGrpc;
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void init() throws Exception {
|
|
||||||
daprRun = startDaprApp(
|
daprRun = startDaprApp(
|
||||||
TracingIT.class.getSimpleName(),
|
TracingIT.class.getSimpleName(),
|
||||||
Service.SUCCESS_MESSAGE,
|
Service.SUCCESS_MESSAGE,
|
||||||
|
@ -55,7 +42,7 @@ public class TracingIT extends BaseIT {
|
||||||
true,
|
true,
|
||||||
30000);
|
30000);
|
||||||
|
|
||||||
if (this.useGrpc) {
|
if (useGrpc) {
|
||||||
daprRun.switchToGRPC();
|
daprRun.switchToGRPC();
|
||||||
} else {
|
} else {
|
||||||
daprRun.switchToHTTP();
|
daprRun.switchToHTTP();
|
||||||
|
@ -65,8 +52,11 @@ public class TracingIT extends BaseIT {
|
||||||
Thread.sleep(2000);
|
Thread.sleep(2000);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@ParameterizedTest
|
||||||
public void testInvoke() throws Exception {
|
@ValueSource(booleans = {true, false})
|
||||||
|
public void testInvoke(boolean useGrpc) throws Exception {
|
||||||
|
setup(useGrpc);
|
||||||
|
|
||||||
final OpenTelemetry openTelemetry = createOpenTelemetry(OpenTelemetryConfig.SERVICE_NAME);
|
final OpenTelemetry openTelemetry = createOpenTelemetry(OpenTelemetryConfig.SERVICE_NAME);
|
||||||
final Tracer tracer = openTelemetry.getTracer(OpenTelemetryConfig.TRACER_NAME);
|
final Tracer tracer = openTelemetry.getTracer(OpenTelemetryConfig.TRACER_NAME);
|
||||||
|
|
||||||
|
|
|
@ -26,11 +26,6 @@
|
||||||
<artifactId>dapr-sdk</artifactId>
|
<artifactId>dapr-sdk</artifactId>
|
||||||
<version>${project.parent.version}</version>
|
<version>${project.parent.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>junit</groupId>
|
|
||||||
<artifactId>junit</artifactId>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mockito</groupId>
|
<groupId>org.mockito</groupId>
|
||||||
<artifactId>mockito-core</artifactId>
|
<artifactId>mockito-core</artifactId>
|
||||||
|
|
|
@ -17,8 +17,9 @@ import com.microsoft.durabletask.RetryPolicy;
|
||||||
import com.microsoft.durabletask.Task;
|
import com.microsoft.durabletask.Task;
|
||||||
import com.microsoft.durabletask.TaskOptions;
|
import com.microsoft.durabletask.TaskOptions;
|
||||||
import com.microsoft.durabletask.TaskOrchestrationContext;
|
import com.microsoft.durabletask.TaskOrchestrationContext;
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
@ -31,12 +32,13 @@ import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.times;
|
import static org.mockito.Mockito.times;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
|
||||||
public class DaprWorkflowContextImplTest {
|
public class DaprWorkflowContextImplTest {
|
||||||
private DaprWorkflowContextImpl context;
|
private DaprWorkflowContextImpl context;
|
||||||
private TaskOrchestrationContext mockInnerContext;
|
private TaskOrchestrationContext mockInnerContext;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
mockInnerContext = mock(TaskOrchestrationContext.class);
|
mockInnerContext = mock(TaskOrchestrationContext.class);
|
||||||
context = new DaprWorkflowContextImpl(mockInnerContext);
|
context = new DaprWorkflowContextImpl(mockInnerContext);
|
||||||
|
@ -87,15 +89,17 @@ public class DaprWorkflowContextImplTest {
|
||||||
verify(mockInnerContext, times(1)).callActivity(expectedName, expectedInput, null, String.class);
|
verify(mockInnerContext, times(1)).callActivity(expectedName, expectedInput, null, String.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
@Test(expected = IllegalArgumentException.class)
|
|
||||||
public void DaprWorkflowContextWithEmptyInnerContext() {
|
public void DaprWorkflowContextWithEmptyInnerContext() {
|
||||||
context = new DaprWorkflowContextImpl(mockInnerContext, null);
|
assertThrows(IllegalArgumentException.class, () -> {
|
||||||
}
|
context = new DaprWorkflowContextImpl(mockInnerContext, null);
|
||||||
|
}); }
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test
|
||||||
public void DaprWorkflowContextWithEmptyLogger() {
|
public void DaprWorkflowContextWithEmptyLogger() {
|
||||||
context = new DaprWorkflowContextImpl(null, null);
|
assertThrows(IllegalArgumentException.class, () -> {
|
||||||
|
context = new DaprWorkflowContextImpl(null, null);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -170,9 +174,9 @@ public class DaprWorkflowContextImplTest {
|
||||||
verify(mockInnerContext, times(1)).createTimer(Duration.ofSeconds(10));
|
verify(mockInnerContext, times(1)).createTimer(Duration.ofSeconds(10));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = UnsupportedOperationException.class)
|
@Test
|
||||||
public void createTimerWithZonedDateTimeThrowsTest() {
|
public void createTimerWithZonedDateTimeThrowsTest() {
|
||||||
context.createTimer(ZonedDateTime.now());
|
assertThrows(UnsupportedOperationException.class, () -> context.createTimer(ZonedDateTime.now()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -20,17 +20,17 @@ import io.dapr.workflows.Workflow;
|
||||||
import io.dapr.workflows.WorkflowContext;
|
import io.dapr.workflows.WorkflowContext;
|
||||||
import io.dapr.workflows.WorkflowStub;
|
import io.dapr.workflows.WorkflowStub;
|
||||||
import io.grpc.ManagedChannel;
|
import io.grpc.ManagedChannel;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertNotEquals;
|
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.times;
|
import static org.mockito.Mockito.times;
|
||||||
|
@ -50,7 +50,7 @@ public class DaprWorkflowClientTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeAll
|
||||||
public static void beforeAll() {
|
public static void beforeAll() {
|
||||||
constructor =
|
constructor =
|
||||||
Constructor.class.cast(Arrays.stream(DaprWorkflowClient.class.getDeclaredConstructors())
|
Constructor.class.cast(Arrays.stream(DaprWorkflowClient.class.getDeclaredConstructors())
|
||||||
|
@ -60,7 +60,7 @@ public class DaprWorkflowClientTest {
|
||||||
}).findFirst().get());
|
}).findFirst().get());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
mockInnerClient = mock(DurableTaskClient.class);
|
mockInnerClient = mock(DurableTaskClient.class);
|
||||||
mockGrpcChannel = mock(ManagedChannel.class);
|
mockGrpcChannel = mock(ManagedChannel.class);
|
||||||
|
|
|
@ -18,8 +18,8 @@ import com.microsoft.durabletask.TaskOrchestrationContext;
|
||||||
import io.dapr.workflows.Workflow;
|
import io.dapr.workflows.Workflow;
|
||||||
import io.dapr.workflows.WorkflowContext;
|
import io.dapr.workflows.WorkflowContext;
|
||||||
import io.dapr.workflows.WorkflowStub;
|
import io.dapr.workflows.WorkflowStub;
|
||||||
import org.junit.Assert;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.times;
|
import static org.mockito.Mockito.times;
|
||||||
|
@ -37,7 +37,7 @@ public class OrchestratorWrapperTest {
|
||||||
@Test
|
@Test
|
||||||
public void getName() {
|
public void getName() {
|
||||||
OrchestratorWrapper<TestWorkflow> wrapper = new OrchestratorWrapper<>(TestWorkflow.class);
|
OrchestratorWrapper<TestWorkflow> wrapper = new OrchestratorWrapper<>(TestWorkflow.class);
|
||||||
Assert.assertEquals(
|
Assertions.assertEquals(
|
||||||
"io.dapr.workflows.runtime.OrchestratorWrapperTest.TestWorkflow",
|
"io.dapr.workflows.runtime.OrchestratorWrapperTest.TestWorkflow",
|
||||||
wrapper.getName()
|
wrapper.getName()
|
||||||
);
|
);
|
||||||
|
|
|
@ -3,7 +3,7 @@ package io.dapr.workflows.runtime;
|
||||||
|
|
||||||
import io.dapr.workflows.Workflow;
|
import io.dapr.workflows.Workflow;
|
||||||
import io.dapr.workflows.WorkflowStub;
|
import io.dapr.workflows.WorkflowStub;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ import com.microsoft.durabletask.DurableTaskGrpcWorker;
|
||||||
import com.microsoft.durabletask.DurableTaskGrpcWorkerBuilder;
|
import com.microsoft.durabletask.DurableTaskGrpcWorkerBuilder;
|
||||||
import io.dapr.workflows.Workflow;
|
import io.dapr.workflows.Workflow;
|
||||||
import io.dapr.workflows.WorkflowStub;
|
import io.dapr.workflows.WorkflowStub;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||||
|
|
||||||
|
|
29
sdk/pom.xml
29
sdk/pom.xml
|
@ -46,16 +46,16 @@
|
||||||
<artifactId>reactor-core</artifactId>
|
<artifactId>reactor-core</artifactId>
|
||||||
<version>3.5.0</version>
|
<version>3.5.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.projectreactor</groupId>
|
||||||
|
<artifactId>reactor-test</artifactId>
|
||||||
|
<version>3.5.0</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.squareup.okhttp3</groupId>
|
<groupId>com.squareup.okhttp3</groupId>
|
||||||
<artifactId>okhttp</artifactId>
|
<artifactId>okhttp</artifactId>
|
||||||
<version>4.9.0</version>
|
<version>4.9.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>junit</groupId>
|
|
||||||
<artifactId>junit</artifactId>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mockito</groupId>
|
<groupId>org.mockito</groupId>
|
||||||
<artifactId>mockito-core</artifactId>
|
<artifactId>mockito-core</artifactId>
|
||||||
|
@ -87,8 +87,12 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.junit.jupiter</groupId>
|
<groupId>org.junit.jupiter</groupId>
|
||||||
<artifactId>junit-jupiter-engine</artifactId>
|
<artifactId>junit-jupiter</artifactId>
|
||||||
<version>5.7.0</version>
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.junit.jupiter</groupId>
|
||||||
|
<artifactId>junit-jupiter-params</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -109,6 +113,17 @@
|
||||||
<version>${grpc.version}</version>
|
<version>${grpc.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>uk.org.webcompere</groupId>
|
||||||
|
<artifactId>system-stubs-jupiter</artifactId>
|
||||||
|
<version>2.1.1</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.junit.jupiter</groupId>
|
||||||
|
<artifactId>junit-jupiter-migrationsupport</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
@ -102,7 +102,7 @@ public class DaprHttp implements AutoCloseable {
|
||||||
*/
|
*/
|
||||||
public Response(byte[] body, Map<String, String> headers, int statusCode) {
|
public Response(byte[] body, Map<String, String> headers, int statusCode) {
|
||||||
this.body = body == null ? EMPTY_BYTES : Arrays.copyOf(body, body.length);
|
this.body = body == null ? EMPTY_BYTES : Arrays.copyOf(body, body.length);
|
||||||
this.headers = headers;
|
this.headers = headers == null ? null : Collections.unmodifiableMap(headers);
|
||||||
this.statusCode = statusCode;
|
this.statusCode = statusCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ import com.fasterxml.jackson.annotation.JsonCreator;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -32,8 +33,7 @@ public final class BulkSubscribeAppResponse {
|
||||||
@JsonCreator
|
@JsonCreator
|
||||||
public BulkSubscribeAppResponse(
|
public BulkSubscribeAppResponse(
|
||||||
@JsonProperty("statuses") List<BulkSubscribeAppResponseEntry> statuses) {
|
@JsonProperty("statuses") List<BulkSubscribeAppResponseEntry> statuses) {
|
||||||
this.statuses = new ArrayList<>();
|
this.statuses = Collections.unmodifiableList(statuses);
|
||||||
this.statuses.addAll(statuses);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<BulkSubscribeAppResponseEntry> getStatuses() {
|
public List<BulkSubscribeAppResponseEntry> getStatuses() {
|
||||||
|
|
|
@ -27,7 +27,7 @@ public class GetBulkStateRequest {
|
||||||
|
|
||||||
private final List<String> keys;
|
private final List<String> keys;
|
||||||
|
|
||||||
private Map<String, String> metadata;
|
private Map<String, String> metadata = Collections.emptyMap();
|
||||||
|
|
||||||
private int parallelism = 1;
|
private int parallelism = 1;
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class GetConfigurationRequest {
|
||||||
*/
|
*/
|
||||||
public GetConfigurationRequest(String storeName, List<String> keys) {
|
public GetConfigurationRequest(String storeName, List<String> keys) {
|
||||||
this.storeName = storeName;
|
this.storeName = storeName;
|
||||||
this.keys = keys == null ? Collections.EMPTY_LIST : Collections.unmodifiableList(keys);
|
this.keys = keys == null ? Collections.emptyList() : Collections.unmodifiableList(keys);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GetConfigurationRequest setMetadata(Map<String, String> metadata) {
|
public GetConfigurationRequest setMetadata(Map<String, String> metadata) {
|
||||||
|
|
|
@ -30,7 +30,7 @@ public class PublishEventRequest {
|
||||||
|
|
||||||
private String contentType;
|
private String contentType;
|
||||||
|
|
||||||
private Map<String, String> metadata = new HashMap<>();
|
private Map<String, String> metadata = Collections.emptyMap();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for PublishEventRequest.
|
* Constructor for PublishEventRequest.
|
||||||
|
|
|
@ -13,6 +13,7 @@ limitations under the License.
|
||||||
|
|
||||||
package io.dapr.client.domain;
|
package io.dapr.client.domain;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -116,7 +117,7 @@ public class State<T> {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
this.key = key;
|
this.key = key;
|
||||||
this.etag = etag;
|
this.etag = etag;
|
||||||
this.metadata = metadata;
|
this.metadata = metadata == null ? null : Collections.unmodifiableMap(metadata);
|
||||||
this.options = options;
|
this.options = options;
|
||||||
this.error = null;
|
this.error = null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class SubscribeConfigurationRequest {
|
||||||
*/
|
*/
|
||||||
public SubscribeConfigurationRequest(String storeName, List<String> keys) {
|
public SubscribeConfigurationRequest(String storeName, List<String> keys) {
|
||||||
this.storeName = storeName;
|
this.storeName = storeName;
|
||||||
this.keys = keys == null ? Collections.EMPTY_LIST : Collections.unmodifiableList(keys);
|
this.keys = keys == null ? Collections.emptyList() : Collections.unmodifiableList(keys);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SubscribeConfigurationRequest setMetadata(Map<String, String> metadata) {
|
public SubscribeConfigurationRequest setMetadata(Map<String, String> metadata) {
|
||||||
|
|
|
@ -39,12 +39,12 @@ public class TransactionalStateRequest<T> {
|
||||||
* @param metadata Metadata used for transactional operations.
|
* @param metadata Metadata used for transactional operations.
|
||||||
*/
|
*/
|
||||||
public TransactionalStateRequest(List<TransactionalStateOperation<T>> operations, Map<String, String> metadata) {
|
public TransactionalStateRequest(List<TransactionalStateOperation<T>> operations, Map<String, String> metadata) {
|
||||||
this.operations = operations;
|
this.operations = operations == null ? null : Collections.unmodifiableList(operations);
|
||||||
this.metadata = metadata;
|
this.metadata = metadata == null ? null : Collections.unmodifiableMap(metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<TransactionalStateOperation<T>> getOperations() {
|
public List<TransactionalStateOperation<T>> getOperations() {
|
||||||
return Collections.unmodifiableList(operations);
|
return operations;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, String> getMetadata() {
|
public Map<String, String> getMetadata() {
|
||||||
|
|
|
@ -13,11 +13,11 @@ limitations under the License.
|
||||||
|
|
||||||
package io.dapr.client;
|
package io.dapr.client;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.junit.Assert.assertArrayEquals;
|
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
|
|
||||||
import io.dapr.serializer.DaprObjectSerializer;
|
import io.dapr.serializer.DaprObjectSerializer;
|
||||||
import io.dapr.serializer.DefaultObjectSerializer;
|
import io.dapr.serializer.DefaultObjectSerializer;
|
||||||
|
|
|
@ -15,11 +15,11 @@ package io.dapr.client;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import io.dapr.client.domain.CloudEvent;
|
import io.dapr.client.domain.CloudEvent;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.junit.Assert.assertArrayEquals;
|
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
|
|
||||||
public class CloudEventTest {
|
public class CloudEventTest {
|
||||||
|
|
||||||
|
|
|
@ -14,9 +14,11 @@ limitations under the License.
|
||||||
package io.dapr.client;
|
package io.dapr.client;
|
||||||
|
|
||||||
import io.dapr.serializer.DaprObjectSerializer;
|
import io.dapr.serializer.DaprObjectSerializer;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
@ -34,19 +36,19 @@ public class DaprClientBuilderTest {
|
||||||
assertNotNull(daprClient);
|
assertNotNull(daprClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test
|
||||||
public void noObjectSerializer() {
|
public void noObjectSerializer() {
|
||||||
new DaprClientBuilder().withObjectSerializer(null);
|
assertThrows(IllegalArgumentException.class, () -> { new DaprClientBuilder().withObjectSerializer(null);});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test
|
||||||
public void blankContentTypeInObjectSerializer() {
|
public void blankContentTypeInObjectSerializer() {
|
||||||
new DaprClientBuilder().withObjectSerializer(mock(DaprObjectSerializer.class));
|
assertThrows(IllegalArgumentException.class, () -> { new DaprClientBuilder().withObjectSerializer(mock(DaprObjectSerializer.class));});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test
|
||||||
public void noStateSerializer() {
|
public void noStateSerializer() {
|
||||||
new DaprClientBuilder().withStateSerializer(null);
|
assertThrows(IllegalArgumentException.class, () -> { new DaprClientBuilder().withStateSerializer(null);});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,26 +29,26 @@ import io.grpc.ServerServiceDefinition;
|
||||||
import io.grpc.inprocess.InProcessChannelBuilder;
|
import io.grpc.inprocess.InProcessChannelBuilder;
|
||||||
import io.grpc.inprocess.InProcessServerBuilder;
|
import io.grpc.inprocess.InProcessServerBuilder;
|
||||||
import io.grpc.testing.GrpcCleanupRule;
|
import io.grpc.testing.GrpcCleanupRule;
|
||||||
import org.junit.After;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||||
import org.junit.runners.Parameterized;
|
import org.junit.jupiter.migrationsupport.rules.EnableRuleMigrationSupport;
|
||||||
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
|
import org.junit.jupiter.params.provider.Arguments;
|
||||||
|
import org.junit.jupiter.params.provider.MethodSource;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
import reactor.util.context.Context;
|
import reactor.util.context.Context;
|
||||||
|
|
||||||
import java.io.Closeable;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.stream.Stream;
|
||||||
import java.util.Collection;
|
|
||||||
import reactor.util.context.ContextView;
|
import reactor.util.context.ContextView;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
@RunWith(Parameterized.class)
|
@EnableRuleMigrationSupport
|
||||||
public class DaprClientGrpcTelemetryTest {
|
public class DaprClientGrpcTelemetryTest {
|
||||||
|
|
||||||
private static final Metadata.Key<byte[]> GRPC_TRACE_BIN_KEY = Metadata.Key.of(Headers.GRPC_TRACE_BIN,
|
private static final Metadata.Key<byte[]> GRPC_TRACE_BIN_KEY = Metadata.Key.of(Headers.GRPC_TRACE_BIN,
|
||||||
|
@ -69,62 +69,42 @@ public class DaprClientGrpcTelemetryTest {
|
||||||
|
|
||||||
private DaprClient client;
|
private DaprClient client;
|
||||||
|
|
||||||
@Parameterized.Parameter
|
public static Stream<Arguments> data() {
|
||||||
public Scenario scenario;
|
return Stream.of(
|
||||||
|
Arguments.of(
|
||||||
@Parameterized.Parameters
|
"00-0af7651916cd43dd8448eb211c80319c-b9c7c989f97918e1-01",
|
||||||
public static Collection<Scenario[]> data() {
|
"congo=ucfJifl5GOE,rojo=00f067aa0ba902b7",
|
||||||
return Arrays.asList(new Scenario[][]{
|
true
|
||||||
{
|
),
|
||||||
new Scenario() {{
|
Arguments.of(
|
||||||
traceparent = "00-0af7651916cd43dd8448eb211c80319c-b9c7c989f97918e1-01";
|
null,
|
||||||
tracestate = "congo=ucfJifl5GOE,rojo=00f067aa0ba902b7";
|
null,
|
||||||
expectGrpcTraceBin = true;
|
false
|
||||||
}}
|
),
|
||||||
},
|
Arguments.of(
|
||||||
{
|
null,
|
||||||
new Scenario() {{
|
"congo=ucfJifl5GOE,rojo=00f067aa0ba902b7",
|
||||||
traceparent = null;
|
false
|
||||||
tracestate = null;
|
),
|
||||||
expectGrpcTraceBin = false;
|
Arguments.of(
|
||||||
}}
|
"00-0af7651916cd43dd8448eb211c80319c-b9c7c989f97918e1-01",
|
||||||
},
|
null,
|
||||||
{
|
true
|
||||||
new Scenario() {{
|
),
|
||||||
traceparent = null;
|
Arguments.of(
|
||||||
tracestate = "congo=ucfJifl5GOE,rojo=00f067aa0ba902b7";
|
"BAD FORMAT",
|
||||||
expectGrpcTraceBin = false;
|
null,
|
||||||
}}
|
false
|
||||||
},
|
),
|
||||||
{
|
Arguments.of(
|
||||||
new Scenario() {{
|
"00-0af7651916cd43dd8448eb211c80319c-b9c7c989f97918e1-01",
|
||||||
traceparent = "00-0af7651916cd43dd8448eb211c80319c-b9c7c989f97918e1-01";
|
"INVALID",
|
||||||
tracestate = null;
|
false
|
||||||
expectGrpcTraceBin = true;
|
)
|
||||||
}},
|
);
|
||||||
},
|
|
||||||
{
|
|
||||||
new Scenario() {{
|
|
||||||
traceparent = "BAD FORMAT";
|
|
||||||
tracestate = null;
|
|
||||||
expectGrpcTraceBin = false;
|
|
||||||
}},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
new Scenario() {{
|
|
||||||
traceparent = "00-0af7651916cd43dd8448eb211c80319c-b9c7c989f97918e1-01";
|
|
||||||
tracestate = "INVALID";
|
|
||||||
expectGrpcTraceBin = false;
|
|
||||||
}},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
null
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
public void setup(String traceparent, String tracestate, boolean expectGrpcTraceBin) throws IOException {
|
||||||
public void setup() throws IOException {
|
|
||||||
DaprGrpc.DaprImplBase daprImplBase = new DaprGrpc.DaprImplBase() {
|
DaprGrpc.DaprImplBase daprImplBase = new DaprGrpc.DaprImplBase() {
|
||||||
|
|
||||||
public void invokeService(io.dapr.v1.DaprProtos.InvokeServiceRequest request,
|
public void invokeService(io.dapr.v1.DaprProtos.InvokeServiceRequest request,
|
||||||
|
@ -140,16 +120,10 @@ public class DaprClientGrpcTelemetryTest {
|
||||||
public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall(ServerCall<ReqT, RespT> serverCall,
|
public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall(ServerCall<ReqT, RespT> serverCall,
|
||||||
Metadata metadata,
|
Metadata metadata,
|
||||||
ServerCallHandler<ReqT, RespT> serverCallHandler) {
|
ServerCallHandler<ReqT, RespT> serverCallHandler) {
|
||||||
if (scenario == null) {
|
|
||||||
assertNull(metadata.get(TRACEPARENT_KEY));
|
|
||||||
assertNull(metadata.get(TRACESTATE_KEY));
|
|
||||||
assertNull(metadata.get(GRPC_TRACE_BIN_KEY));
|
|
||||||
return serverCallHandler.startCall(serverCall, metadata);
|
|
||||||
}
|
|
||||||
|
|
||||||
assertEquals(scenario.traceparent, metadata.get(TRACEPARENT_KEY));
|
assertEquals(traceparent, metadata.get(TRACEPARENT_KEY));
|
||||||
assertEquals(scenario.tracestate, metadata.get(TRACESTATE_KEY));
|
assertEquals(tracestate, metadata.get(TRACESTATE_KEY));
|
||||||
assertTrue((metadata.get(GRPC_TRACE_BIN_KEY) != null) == scenario.expectGrpcTraceBin);
|
assertEquals((metadata.get(GRPC_TRACE_BIN_KEY) != null), expectGrpcTraceBin);
|
||||||
return serverCallHandler.startCall(serverCall, metadata);
|
return serverCallHandler.startCall(serverCall, metadata);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -168,35 +142,81 @@ public class DaprClientGrpcTelemetryTest {
|
||||||
new GrpcChannelFacade(channel), asyncStub, new DefaultObjectSerializer(), new DefaultObjectSerializer());
|
new GrpcChannelFacade(channel), asyncStub, new DefaultObjectSerializer(), new DefaultObjectSerializer());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
public void setup() throws IOException {
|
||||||
public void invokeServiceVoidWithTracingTest() {
|
DaprGrpc.DaprImplBase daprImplBase = new DaprGrpc.DaprImplBase() {
|
||||||
Context context = null;
|
|
||||||
if (scenario != null) {
|
public void invokeService(io.dapr.v1.DaprProtos.InvokeServiceRequest request,
|
||||||
context = Context.empty();
|
io.grpc.stub.StreamObserver<io.dapr.v1.CommonProtos.InvokeResponse> responseObserver) {
|
||||||
if (scenario.traceparent != null) {
|
responseObserver.onNext(CommonProtos.InvokeResponse.getDefaultInstance());
|
||||||
context = context.put("traceparent", scenario.traceparent);
|
responseObserver.onCompleted();
|
||||||
}
|
}
|
||||||
if (scenario.tracestate != null) {
|
|
||||||
context = context.put("tracestate", scenario.tracestate);
|
};
|
||||||
|
|
||||||
|
ServerServiceDefinition service = ServerInterceptors.intercept(daprImplBase, new ServerInterceptor() {
|
||||||
|
@Override
|
||||||
|
public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall(ServerCall<ReqT, RespT> serverCall,
|
||||||
|
Metadata metadata,
|
||||||
|
ServerCallHandler<ReqT, RespT> serverCallHandler) {
|
||||||
|
|
||||||
|
assertNull(metadata.get(TRACEPARENT_KEY));
|
||||||
|
assertNull(metadata.get(TRACESTATE_KEY));
|
||||||
|
assertNull(metadata.get(GRPC_TRACE_BIN_KEY));
|
||||||
|
return serverCallHandler.startCall(serverCall, metadata);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
|
// Generate a unique in-process server name.
|
||||||
|
String serverName = InProcessServerBuilder.generateName();
|
||||||
|
// Create a server, add service, start, and register for automatic graceful shutdown.
|
||||||
|
grpcCleanup.register(InProcessServerBuilder.forName(serverName).directExecutor()
|
||||||
|
.addService(service)
|
||||||
|
.build().start());
|
||||||
|
|
||||||
|
// Create a client channel and register for automatic graceful shutdown.
|
||||||
|
ManagedChannel channel = InProcessChannelBuilder.forName(serverName).directExecutor().build();
|
||||||
|
DaprGrpc.DaprStub asyncStub = DaprGrpc.newStub(channel);
|
||||||
|
client = new DaprClientGrpc(
|
||||||
|
new GrpcChannelFacade(channel), asyncStub, new DefaultObjectSerializer(), new DefaultObjectSerializer());
|
||||||
|
}
|
||||||
|
|
||||||
|
@ParameterizedTest
|
||||||
|
@MethodSource("data")
|
||||||
|
public void invokeServiceVoidWithTracingTest(String traceparent, String tracestate, boolean expectGrpcTraceBin) throws IOException {
|
||||||
|
// setup server
|
||||||
|
setup(traceparent, tracestate, expectGrpcTraceBin);
|
||||||
|
|
||||||
|
Context context = Context.empty();
|
||||||
|
if (traceparent != null) {
|
||||||
|
context = context.put("traceparent", traceparent);
|
||||||
|
}
|
||||||
|
if (tracestate != null) {
|
||||||
|
context = context.put("tracestate", tracestate);
|
||||||
|
}
|
||||||
|
|
||||||
final Context contextCopy = context;
|
final Context contextCopy = context;
|
||||||
InvokeMethodRequest req = new InvokeMethodRequest("appId", "method")
|
InvokeMethodRequest req = new InvokeMethodRequest("appId", "method")
|
||||||
.setBody("request")
|
.setBody("request")
|
||||||
.setHttpExtension(HttpExtension.NONE);
|
.setHttpExtension(HttpExtension.NONE);
|
||||||
Mono<Void> result = this.client.invokeMethod(req, TypeRef.get(Void.class))
|
Mono<Void> result = this.client.invokeMethod(req, TypeRef.get(Void.class))
|
||||||
.contextWrite(it -> it.putAll(contextCopy == null ? (ContextView) Context.empty() : contextCopy));
|
.contextWrite(it -> it.putAll(contextCopy));
|
||||||
result.block();
|
result.block();
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@Test
|
||||||
public void tearDown() throws Exception {
|
public void invokeServiceVoidWithTracingTestAndEmptyContext() throws IOException {
|
||||||
client.close();
|
// setup server
|
||||||
}
|
setup();
|
||||||
|
|
||||||
public static class Scenario {
|
Context context = null;
|
||||||
public String traceparent;
|
|
||||||
public String tracestate;
|
final Context contextCopy = context;
|
||||||
public boolean expectGrpcTraceBin;
|
InvokeMethodRequest req = new InvokeMethodRequest("appId", "method")
|
||||||
|
.setBody("request")
|
||||||
|
.setHttpExtension(HttpExtension.NONE);
|
||||||
|
Mono<Void> result = this.client.invokeMethod(req, TypeRef.get(Void.class))
|
||||||
|
.contextWrite(it -> it.putAll(contextCopy == null ? (ContextView) Context.empty() : contextCopy));
|
||||||
|
result.block();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,9 +38,9 @@ import io.dapr.v1.DaprProtos;
|
||||||
import io.grpc.Status;
|
import io.grpc.Status;
|
||||||
import io.grpc.StatusRuntimeException;
|
import io.grpc.StatusRuntimeException;
|
||||||
import io.grpc.stub.StreamObserver;
|
import io.grpc.stub.StreamObserver;
|
||||||
import org.junit.After;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.mockito.ArgumentCaptor;
|
import org.mockito.ArgumentCaptor;
|
||||||
import org.mockito.ArgumentMatcher;
|
import org.mockito.ArgumentMatcher;
|
||||||
import org.mockito.ArgumentMatchers;
|
import org.mockito.ArgumentMatchers;
|
||||||
|
@ -62,8 +62,14 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static io.dapr.utils.TestUtils.assertThrowsDaprException;
|
import static io.dapr.utils.TestUtils.assertThrowsDaprException;
|
||||||
import static org.junit.Assert.*;
|
import static io.dapr.utils.TestUtils.findFreePort;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.Mockito.*;
|
import static org.mockito.Mockito.*;
|
||||||
|
|
||||||
|
@ -80,7 +86,7 @@ public class DaprClientGrpcTest {
|
||||||
private DaprClient client;
|
private DaprClient client;
|
||||||
private ObjectSerializer serializer;
|
private ObjectSerializer serializer;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setup() throws IOException {
|
public void setup() throws IOException {
|
||||||
channel = mock(GrpcChannelFacade.class);
|
channel = mock(GrpcChannelFacade.class);
|
||||||
daprStub = mock(DaprGrpc.DaprStub.class);
|
daprStub = mock(DaprGrpc.DaprStub.class);
|
||||||
|
@ -92,7 +98,7 @@ public class DaprClientGrpcTest {
|
||||||
doNothing().when(channel).close();
|
doNothing().when(channel).close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@AfterEach
|
||||||
public void tearDown() throws Exception {
|
public void tearDown() throws Exception {
|
||||||
client.close();
|
client.close();
|
||||||
verify(channel).close();
|
verify(channel).close();
|
||||||
|
@ -583,7 +589,7 @@ public class DaprClientGrpcTest {
|
||||||
.build();
|
.build();
|
||||||
String expected = "Value";
|
String expected = "Value";
|
||||||
|
|
||||||
doAnswer((Answer<Void>) invocation -> {
|
doAnswer(invocation -> {
|
||||||
StreamObserver<CommonProtos.InvokeResponse> observer = (StreamObserver<CommonProtos.InvokeResponse>) invocation.getArguments()[1];
|
StreamObserver<CommonProtos.InvokeResponse> observer = (StreamObserver<CommonProtos.InvokeResponse>) invocation.getArguments()[1];
|
||||||
observer.onNext(CommonProtos.InvokeResponse.newBuilder().setData(getAny(expected)).build());
|
observer.onNext(CommonProtos.InvokeResponse.newBuilder().setData(getAny(expected)).build());
|
||||||
observer.onCompleted();
|
observer.onCompleted();
|
||||||
|
@ -909,7 +915,7 @@ public class DaprClientGrpcTest {
|
||||||
String expectedValue = "Expected state";
|
String expectedValue = "Expected state";
|
||||||
State<String> expectedState = buildStateKey(expectedValue, key, etag, new HashMap<>(), null);
|
State<String> expectedState = buildStateKey(expectedValue, key, etag, new HashMap<>(), null);
|
||||||
DaprProtos.GetStateResponse responseEnvelope = buildGetStateResponse(expectedValue, etag);
|
DaprProtos.GetStateResponse responseEnvelope = buildGetStateResponse(expectedValue, etag);
|
||||||
doAnswer((Answer<Void>) invocation -> {
|
doAnswer(invocation -> {
|
||||||
StreamObserver<DaprProtos.GetStateResponse> observer = (StreamObserver<DaprProtos.GetStateResponse>) invocation.getArguments()[1];
|
StreamObserver<DaprProtos.GetStateResponse> observer = (StreamObserver<DaprProtos.GetStateResponse>) invocation.getArguments()[1];
|
||||||
observer.onNext(responseEnvelope);
|
observer.onNext(responseEnvelope);
|
||||||
observer.onCompleted();
|
observer.onCompleted();
|
||||||
|
@ -2127,10 +2133,10 @@ public class DaprClientGrpcTest {
|
||||||
|
|
||||||
Map<String, ConfigurationItem> cis = client.getConfiguration(CONFIG_STORE_NAME, "configkey1","configkey2").block();
|
Map<String, ConfigurationItem> cis = client.getConfiguration(CONFIG_STORE_NAME, "configkey1","configkey2").block();
|
||||||
assertEquals(2, cis.size());
|
assertEquals(2, cis.size());
|
||||||
assertTrue("configkey1", cis.containsKey("configkey1"));
|
assertTrue(cis.containsKey("configkey1"), "configkey1");
|
||||||
assertEquals("configvalue1", cis.get("configkey1").getValue());
|
assertEquals("configvalue1", cis.get("configkey1").getValue());
|
||||||
assertEquals("1", cis.get("configkey1").getVersion());
|
assertEquals("1", cis.get("configkey1").getVersion());
|
||||||
assertTrue("configkey2", cis.containsKey("configkey2"));
|
assertTrue(cis.containsKey("configkey2"), "configkey2");
|
||||||
assertEquals("configvalue2", cis.get("configkey2").getValue());
|
assertEquals("configvalue2", cis.get("configkey2").getValue());
|
||||||
assertEquals("1", cis.get("configkey2").getVersion());
|
assertEquals("1", cis.get("configkey2").getVersion());
|
||||||
}
|
}
|
||||||
|
@ -2150,7 +2156,7 @@ public class DaprClientGrpcTest {
|
||||||
List<String> keys = Arrays.asList("configkey1","configkey2");
|
List<String> keys = Arrays.asList("configkey1","configkey2");
|
||||||
Map<String, ConfigurationItem> cis = client.getConfiguration(CONFIG_STORE_NAME, keys, reqMetadata).block();
|
Map<String, ConfigurationItem> cis = client.getConfiguration(CONFIG_STORE_NAME, keys, reqMetadata).block();
|
||||||
assertEquals(2, cis.size());
|
assertEquals(2, cis.size());
|
||||||
assertTrue("configkey1", cis.containsKey("configkey1"));
|
assertTrue(cis.containsKey("configkey1"), "configkey1");
|
||||||
assertEquals("configvalue1", cis.get("configkey1").getValue());
|
assertEquals("configvalue1", cis.get("configkey1").getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,8 +41,8 @@ import okhttp3.mock.MockInterceptor;
|
||||||
import okhttp3.mock.matchers.Matcher;
|
import okhttp3.mock.matchers.Matcher;
|
||||||
import okio.Buffer;
|
import okio.Buffer;
|
||||||
import okio.BufferedSink;
|
import okio.BufferedSink;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
import reactor.util.context.Context;
|
import reactor.util.context.Context;
|
||||||
|
@ -62,11 +62,11 @@ import reactor.util.context.ContextView;
|
||||||
|
|
||||||
import static io.dapr.utils.TestUtils.assertThrowsDaprException;
|
import static io.dapr.utils.TestUtils.assertThrowsDaprException;
|
||||||
import static io.dapr.utils.TestUtils.findFreePort;
|
import static io.dapr.utils.TestUtils.findFreePort;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ public class DaprClientHttpTest {
|
||||||
|
|
||||||
private MockInterceptor mockInterceptor;
|
private MockInterceptor mockInterceptor;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
mockInterceptor = new MockInterceptor(Behavior.UNORDERED);
|
mockInterceptor = new MockInterceptor(Behavior.UNORDERED);
|
||||||
okHttpClient = new OkHttpClient.Builder().addInterceptor(mockInterceptor).build();
|
okHttpClient = new OkHttpClient.Builder().addInterceptor(mockInterceptor).build();
|
||||||
|
|
|
@ -13,7 +13,7 @@ limitations under the License.
|
||||||
package io.dapr.client;
|
package io.dapr.client;
|
||||||
|
|
||||||
import io.dapr.client.domain.HttpExtension;
|
import io.dapr.client.domain.HttpExtension;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
|
|
@ -14,12 +14,12 @@ limitations under the License.
|
||||||
package io.dapr.client;
|
package io.dapr.client;
|
||||||
|
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
import static org.junit.Assert.assertSame;
|
import static org.junit.jupiter.api.Assertions.assertSame;
|
||||||
|
|
||||||
public class DaprHttpBuilderTest {
|
public class DaprHttpBuilderTest {
|
||||||
|
|
||||||
|
|
|
@ -14,17 +14,20 @@ package io.dapr.client;
|
||||||
|
|
||||||
import io.dapr.config.Properties;
|
import io.dapr.config.Properties;
|
||||||
import io.dapr.exceptions.DaprException;
|
import io.dapr.exceptions.DaprException;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
|
import reactor.test.StepVerifier;
|
||||||
import reactor.util.context.Context;
|
import reactor.util.context.Context;
|
||||||
import okhttp3.MediaType;
|
import okhttp3.MediaType;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.ResponseBody;
|
import okhttp3.ResponseBody;
|
||||||
import okhttp3.mock.Behavior;
|
import okhttp3.mock.Behavior;
|
||||||
import okhttp3.mock.MockInterceptor;
|
import okhttp3.mock.MockInterceptor;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.Rule;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.contrib.java.lang.system.EnvironmentVariables;
|
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
|
import uk.org.webcompere.systemstubs.environment.EnvironmentVariables;
|
||||||
|
import uk.org.webcompere.systemstubs.jupiter.SystemStub;
|
||||||
|
import uk.org.webcompere.systemstubs.jupiter.SystemStubsExtension;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -32,14 +35,15 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
import static org.junit.jupiter.api.Assertions.fail;
|
||||||
|
|
||||||
|
@ExtendWith(SystemStubsExtension.class)
|
||||||
public class DaprHttpTest {
|
public class DaprHttpTest {
|
||||||
|
|
||||||
@Rule
|
@SystemStub
|
||||||
public final EnvironmentVariables environmentVariables = new EnvironmentVariables();
|
public final EnvironmentVariables environmentVariables = new EnvironmentVariables();
|
||||||
|
|
||||||
private static final String STATE_PATH = DaprHttp.API_VERSION + "/state";
|
private static final String STATE_PATH = DaprHttp.API_VERSION + "/state";
|
||||||
|
@ -53,7 +57,7 @@ public class DaprHttpTest {
|
||||||
|
|
||||||
private ObjectSerializer serializer = new ObjectSerializer();
|
private ObjectSerializer serializer = new ObjectSerializer();
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
mockInterceptor = new MockInterceptor(Behavior.UNORDERED);
|
mockInterceptor = new MockInterceptor(Behavior.UNORDERED);
|
||||||
okHttpClient = new OkHttpClient.Builder().addInterceptor(mockInterceptor).build();
|
okHttpClient = new OkHttpClient.Builder().addInterceptor(mockInterceptor).build();
|
||||||
|
@ -164,7 +168,7 @@ public class DaprHttpTest {
|
||||||
assertEquals(EXPECTED_RESULT, body);
|
assertEquals(EXPECTED_RESULT, body);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = RuntimeException.class)
|
@Test
|
||||||
public void invokePostMethodRuntime() throws IOException {
|
public void invokePostMethodRuntime() throws IOException {
|
||||||
mockInterceptor.addRule()
|
mockInterceptor.addRule()
|
||||||
.post("http://127.0.0.1:3500/v1.0/state")
|
.post("http://127.0.0.1:3500/v1.0/state")
|
||||||
|
@ -172,26 +176,21 @@ public class DaprHttpTest {
|
||||||
DaprHttp daprHttp = new DaprHttp(Properties.SIDECAR_IP.get(), 3500, okHttpClient);
|
DaprHttp daprHttp = new DaprHttp(Properties.SIDECAR_IP.get(), 3500, okHttpClient);
|
||||||
Mono<DaprHttp.Response> mono =
|
Mono<DaprHttp.Response> mono =
|
||||||
daprHttp.invokeApi("POST", "v1.0/state".split("/"), null, null, Context.empty());
|
daprHttp.invokeApi("POST", "v1.0/state".split("/"), null, null, Context.empty());
|
||||||
DaprHttp.Response response = mono.block();
|
StepVerifier.create(mono).expectError(RuntimeException.class);
|
||||||
String body = serializer.deserialize(response.getBody(), String.class);
|
|
||||||
assertEquals(EXPECTED_RESULT, body);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = RuntimeException.class)
|
@Test
|
||||||
public void invokePostDaprError() throws IOException {
|
public void invokePostDaprError() throws IOException {
|
||||||
|
|
||||||
mockInterceptor.addRule()
|
mockInterceptor.addRule()
|
||||||
.post("http://127.0.0.1:3500/v1.0/state")
|
.post("http://127.0.0.1:3500/v1.0/state")
|
||||||
.respond(500, ResponseBody.create(MediaType.parse("text"),
|
.respond(500, ResponseBody.create(MediaType.parse("text"),
|
||||||
"{\"errorCode\":null,\"message\":null}"));
|
"{\"errorCode\":null,\"message\":null}"));
|
||||||
DaprHttp daprHttp = new DaprHttp(Properties.SIDECAR_IP.get(), 3500, okHttpClient);
|
DaprHttp daprHttp = new DaprHttp(Properties.SIDECAR_IP.get(), 3500, okHttpClient);
|
||||||
Mono<DaprHttp.Response> mono = daprHttp.invokeApi("POST", "v1.0/state".split("/"), null, null, Context.empty());
|
Mono<DaprHttp.Response> mono = daprHttp.invokeApi("POST", "v1.0/state".split("/"), null, null, Context.empty());
|
||||||
DaprHttp.Response response = mono.block();
|
StepVerifier.create(mono).expectError(RuntimeException.class);
|
||||||
String body = serializer.deserialize(response.getBody(), String.class);
|
|
||||||
assertEquals(EXPECTED_RESULT, body);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = RuntimeException.class)
|
@Test
|
||||||
public void invokePostMethodUnknownError() throws IOException {
|
public void invokePostMethodUnknownError() throws IOException {
|
||||||
mockInterceptor.addRule()
|
mockInterceptor.addRule()
|
||||||
.post("http://127.0.0.1:3500/v1.0/state")
|
.post("http://127.0.0.1:3500/v1.0/state")
|
||||||
|
@ -199,9 +198,7 @@ public class DaprHttpTest {
|
||||||
"{\"errorCode\":\"null\",\"message\":\"null\"}"));
|
"{\"errorCode\":\"null\",\"message\":\"null\"}"));
|
||||||
DaprHttp daprHttp = new DaprHttp(Properties.SIDECAR_IP.get(), 3500, okHttpClient);
|
DaprHttp daprHttp = new DaprHttp(Properties.SIDECAR_IP.get(), 3500, okHttpClient);
|
||||||
Mono<DaprHttp.Response> mono = daprHttp.invokeApi("POST", "v1.0/state".split("/"), null, null, Context.empty());
|
Mono<DaprHttp.Response> mono = daprHttp.invokeApi("POST", "v1.0/state".split("/"), null, null, Context.empty());
|
||||||
DaprHttp.Response response = mono.block();
|
StepVerifier.create(mono).expectError(RuntimeException.class);
|
||||||
String body = serializer.deserialize(response.getBody(), String.class);
|
|
||||||
assertEquals(EXPECTED_RESULT, body);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -32,15 +32,14 @@ import io.dapr.v1.DaprProtos;
|
||||||
import io.grpc.Status;
|
import io.grpc.Status;
|
||||||
import io.grpc.StatusRuntimeException;
|
import io.grpc.StatusRuntimeException;
|
||||||
import io.grpc.stub.StreamObserver;
|
import io.grpc.stub.StreamObserver;
|
||||||
import org.junit.After;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.Assert;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.mockito.ArgumentMatchers;
|
import org.mockito.ArgumentMatchers;
|
||||||
import org.mockito.stubbing.Answer;
|
import org.mockito.stubbing.Answer;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
import java.io.Closeable;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -50,8 +49,8 @@ import java.util.Map;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
import static io.dapr.utils.TestUtils.assertThrowsDaprException;
|
import static io.dapr.utils.TestUtils.assertThrowsDaprException;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.Mockito.doAnswer;
|
import static org.mockito.Mockito.doAnswer;
|
||||||
|
@ -64,16 +63,20 @@ import static org.mockito.Mockito.when;
|
||||||
public class DaprPreviewClientGrpcTest {
|
public class DaprPreviewClientGrpcTest {
|
||||||
|
|
||||||
private static final ObjectMapper MAPPER = new ObjectMapper();
|
private static final ObjectMapper MAPPER = new ObjectMapper();
|
||||||
|
|
||||||
private static final String QUERY_STORE_NAME = "testQueryStore";
|
private static final String QUERY_STORE_NAME = "testQueryStore";
|
||||||
|
|
||||||
private static final String PUBSUB_NAME = "testPubsub";
|
private static final String PUBSUB_NAME = "testPubsub";
|
||||||
|
|
||||||
private static final String TOPIC_NAME = "testTopic";
|
private static final String TOPIC_NAME = "testTopic";
|
||||||
|
|
||||||
private static final String LOCK_STORE_NAME = "MyLockStore";
|
private static final String LOCK_STORE_NAME = "MyLockStore";
|
||||||
|
|
||||||
private GrpcChannelFacade channel;
|
private GrpcChannelFacade channel;
|
||||||
private DaprGrpc.DaprStub daprStub;
|
private DaprGrpc.DaprStub daprStub;
|
||||||
private DaprPreviewClient previewClient;
|
private DaprPreviewClient previewClient;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setup() throws IOException {
|
public void setup() throws IOException {
|
||||||
channel = mock(GrpcChannelFacade.class);
|
channel = mock(GrpcChannelFacade.class);
|
||||||
daprStub = mock(DaprGrpc.DaprStub.class);
|
daprStub = mock(DaprGrpc.DaprStub.class);
|
||||||
|
@ -83,7 +86,7 @@ public class DaprPreviewClientGrpcTest {
|
||||||
doNothing().when(channel).close();
|
doNothing().when(channel).close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@AfterEach
|
||||||
public void tearDown() throws Exception {
|
public void tearDown() throws Exception {
|
||||||
previewClient.close();
|
previewClient.close();
|
||||||
verify(channel).close();
|
verify(channel).close();
|
||||||
|
@ -121,7 +124,7 @@ public class DaprPreviewClientGrpcTest {
|
||||||
Collections.EMPTY_LIST)).block());
|
Collections.EMPTY_LIST)).block());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test
|
||||||
public void publishEventsContentTypeMismatchException() throws IOException {
|
public void publishEventsContentTypeMismatchException() throws IOException {
|
||||||
DaprObjectSerializer mockSerializer = mock(DaprObjectSerializer.class);
|
DaprObjectSerializer mockSerializer = mock(DaprObjectSerializer.class);
|
||||||
doAnswer((Answer<Void>) invocation -> {
|
doAnswer((Answer<Void>) invocation -> {
|
||||||
|
@ -137,7 +140,8 @@ public class DaprPreviewClientGrpcTest {
|
||||||
, "application/octet-stream", null);
|
, "application/octet-stream", null);
|
||||||
BulkPublishRequest<String> wrongReq = new BulkPublishRequest<>(PUBSUB_NAME, TOPIC_NAME,
|
BulkPublishRequest<String> wrongReq = new BulkPublishRequest<>(PUBSUB_NAME, TOPIC_NAME,
|
||||||
Collections.singletonList(entry));
|
Collections.singletonList(entry));
|
||||||
previewClient.publishEvents(wrongReq).block();
|
|
||||||
|
assertThrows(IllegalArgumentException.class, () -> previewClient.publishEvents(wrongReq).block());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -182,8 +186,8 @@ public class DaprPreviewClientGrpcTest {
|
||||||
Collections.singletonList(entry));
|
Collections.singletonList(entry));
|
||||||
Mono<BulkPublishResponse<String>> result = previewClient.publishEvents(req);
|
Mono<BulkPublishResponse<String>> result = previewClient.publishEvents(req);
|
||||||
BulkPublishResponse res = result.block();
|
BulkPublishResponse res = result.block();
|
||||||
Assert.assertNotNull(res);
|
Assertions.assertNotNull(res);
|
||||||
assertEquals("expected no entry in failed entries list", 0, res.getFailedEntries().size());
|
assertEquals( 0, res.getFailedEntries().size(), "expected no entry in failed entries list");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -200,8 +204,8 @@ public class DaprPreviewClientGrpcTest {
|
||||||
Mono<BulkPublishResponse<String>> result = previewClient.publishEvents(PUBSUB_NAME, TOPIC_NAME,
|
Mono<BulkPublishResponse<String>> result = previewClient.publishEvents(PUBSUB_NAME, TOPIC_NAME,
|
||||||
"text/plain", Collections.singletonList("test"));
|
"text/plain", Collections.singletonList("test"));
|
||||||
BulkPublishResponse<String> res = result.block();
|
BulkPublishResponse<String> res = result.block();
|
||||||
Assert.assertNotNull(res);
|
Assertions.assertNotNull(res);
|
||||||
assertEquals("expected no entries in failed entries list", 0, res.getFailedEntries().size());
|
assertEquals( 0, res.getFailedEntries().size(), "expected no entries in failed entries list");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -220,8 +224,8 @@ public class DaprPreviewClientGrpcTest {
|
||||||
put("ttlInSeconds", "123");
|
put("ttlInSeconds", "123");
|
||||||
}}, Collections.singletonList("test"));
|
}}, Collections.singletonList("test"));
|
||||||
BulkPublishResponse<String> res = result.block();
|
BulkPublishResponse<String> res = result.block();
|
||||||
Assert.assertNotNull(res);
|
Assertions.assertNotNull(res);
|
||||||
assertEquals("expected no entry in failed entries list", 0, res.getFailedEntries().size());
|
assertEquals( 0, res.getFailedEntries().size(), "expected no entry in failed entries list");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -252,8 +256,8 @@ public class DaprPreviewClientGrpcTest {
|
||||||
BulkPublishRequest<DaprClientGrpcTest.MyObject> req = new BulkPublishRequest<>(PUBSUB_NAME, TOPIC_NAME,
|
BulkPublishRequest<DaprClientGrpcTest.MyObject> req = new BulkPublishRequest<>(PUBSUB_NAME, TOPIC_NAME,
|
||||||
Collections.singletonList(entry));
|
Collections.singletonList(entry));
|
||||||
BulkPublishResponse<DaprClientGrpcTest.MyObject> result = previewClient.publishEvents(req).block();
|
BulkPublishResponse<DaprClientGrpcTest.MyObject> result = previewClient.publishEvents(req).block();
|
||||||
Assert.assertNotNull(result);
|
Assertions.assertNotNull(result);
|
||||||
Assert.assertEquals("expected no entries to be failed", 0, result.getFailedEntries().size());
|
Assertions.assertEquals(0, result.getFailedEntries().size(), "expected no entries to be failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -281,8 +285,8 @@ public class DaprPreviewClientGrpcTest {
|
||||||
BulkPublishRequest<String> req = new BulkPublishRequest<>(PUBSUB_NAME, TOPIC_NAME,
|
BulkPublishRequest<String> req = new BulkPublishRequest<>(PUBSUB_NAME, TOPIC_NAME,
|
||||||
Collections.singletonList(entry));
|
Collections.singletonList(entry));
|
||||||
BulkPublishResponse<String> result = previewClient.publishEvents(req).block();
|
BulkPublishResponse<String> result = previewClient.publishEvents(req).block();
|
||||||
Assert.assertNotNull(result);
|
Assertions.assertNotNull(result);
|
||||||
Assert.assertEquals("expected no entries to be failed", 0, result.getFailedEntries().size());
|
Assertions.assertEquals( 0, result.getFailedEntries().size(), "expected no entries to be failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -312,8 +316,8 @@ public class DaprPreviewClientGrpcTest {
|
||||||
List<QueryStateItem<?>> resp = new ArrayList<>();
|
List<QueryStateItem<?>> resp = new ArrayList<>();
|
||||||
resp.add(new QueryStateItem<Object>("1", (Object)"testData", "6f54ad94-dfb9-46f0-a371-e42d550adb7d"));
|
resp.add(new QueryStateItem<Object>("1", (Object)"testData", "6f54ad94-dfb9-46f0-a371-e42d550adb7d"));
|
||||||
DaprProtos.QueryStateResponse responseEnvelope = buildQueryStateResponse(resp, "");
|
DaprProtos.QueryStateResponse responseEnvelope = buildQueryStateResponse(resp, "");
|
||||||
doAnswer((Answer<Void>) invocation -> {
|
doAnswer(invocation -> {
|
||||||
DaprProtos.QueryStateRequest req = invocation.getArgument(0);
|
DaprProtos.QueryStateRequest req = (DaprProtos.QueryStateRequest) invocation.getArgument(0);
|
||||||
assertEquals(QUERY_STORE_NAME, req.getStoreName());
|
assertEquals(QUERY_STORE_NAME, req.getStoreName());
|
||||||
assertEquals("query", req.getQuery());
|
assertEquals("query", req.getQuery());
|
||||||
assertEquals(0, req.getMetadataCount());
|
assertEquals(0, req.getMetadataCount());
|
||||||
|
@ -327,10 +331,10 @@ public class DaprPreviewClientGrpcTest {
|
||||||
|
|
||||||
QueryStateResponse<String> response = previewClient.queryState(QUERY_STORE_NAME, "query", String.class).block();
|
QueryStateResponse<String> response = previewClient.queryState(QUERY_STORE_NAME, "query", String.class).block();
|
||||||
assertNotNull(response);
|
assertNotNull(response);
|
||||||
assertEquals("result size must be 1", 1, response.getResults().size());
|
assertEquals(1, response.getResults().size(), "result size must be 1");
|
||||||
assertEquals("result must be same", "1", response.getResults().get(0).getKey());
|
assertEquals("1", response.getResults().get(0).getKey(), "result must be same");
|
||||||
assertEquals("result must be same", "testData", response.getResults().get(0).getValue());
|
assertEquals("testData", response.getResults().get(0).getValue(), "result must be same");
|
||||||
assertEquals("result must be same", "6f54ad94-dfb9-46f0-a371-e42d550adb7d", response.getResults().get(0).getEtag());
|
assertEquals("6f54ad94-dfb9-46f0-a371-e42d550adb7d", response.getResults().get(0).getEtag(), "result must be same");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -338,8 +342,8 @@ public class DaprPreviewClientGrpcTest {
|
||||||
List<QueryStateItem<?>> resp = new ArrayList<>();
|
List<QueryStateItem<?>> resp = new ArrayList<>();
|
||||||
resp.add(new QueryStateItem<Object>("1", null, "error data"));
|
resp.add(new QueryStateItem<Object>("1", null, "error data"));
|
||||||
DaprProtos.QueryStateResponse responseEnvelope = buildQueryStateResponse(resp, "");
|
DaprProtos.QueryStateResponse responseEnvelope = buildQueryStateResponse(resp, "");
|
||||||
doAnswer((Answer<Void>) invocation -> {
|
doAnswer(invocation -> {
|
||||||
DaprProtos.QueryStateRequest req = invocation.getArgument(0);
|
DaprProtos.QueryStateRequest req = (DaprProtos.QueryStateRequest) invocation.getArgument(0);
|
||||||
assertEquals(QUERY_STORE_NAME, req.getStoreName());
|
assertEquals(QUERY_STORE_NAME, req.getStoreName());
|
||||||
assertEquals("query", req.getQuery());
|
assertEquals("query", req.getQuery());
|
||||||
assertEquals(1, req.getMetadataCount());
|
assertEquals(1, req.getMetadataCount());
|
||||||
|
@ -355,9 +359,9 @@ public class DaprPreviewClientGrpcTest {
|
||||||
QueryStateResponse<String> response = previewClient.queryState(QUERY_STORE_NAME, "query",
|
QueryStateResponse<String> response = previewClient.queryState(QUERY_STORE_NAME, "query",
|
||||||
new HashMap<String, String>(){{ put("key", "error"); }}, String.class).block();
|
new HashMap<String, String>(){{ put("key", "error"); }}, String.class).block();
|
||||||
assertNotNull(response);
|
assertNotNull(response);
|
||||||
assertEquals("result size must be 1", 1, response.getResults().size());
|
assertEquals(1, response.getResults().size(), "result size must be 1");
|
||||||
assertEquals("result must be same", "1", response.getResults().get(0).getKey());
|
assertEquals( "1", response.getResults().get(0).getKey(), "result must be same");
|
||||||
assertEquals("result must be same", "error data", response.getResults().get(0).getError());
|
assertEquals( "error data", response.getResults().get(0).getError(), "result must be same");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -24,13 +24,13 @@ import io.dapr.utils.TypeRef;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.mock.Behavior;
|
import okhttp3.mock.Behavior;
|
||||||
import okhttp3.mock.MockInterceptor;
|
import okhttp3.mock.MockInterceptor;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
|
||||||
public class DaprPreviewClientHttpTest {
|
public class DaprPreviewClientHttpTest {
|
||||||
|
@ -45,7 +45,7 @@ public class DaprPreviewClientHttpTest {
|
||||||
|
|
||||||
private MockInterceptor mockInterceptor;
|
private MockInterceptor mockInterceptor;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
mockInterceptor = new MockInterceptor(Behavior.UNORDERED);
|
mockInterceptor = new MockInterceptor(Behavior.UNORDERED);
|
||||||
okHttpClient = new OkHttpClient.Builder().addInterceptor(mockInterceptor).build();
|
okHttpClient = new OkHttpClient.Builder().addInterceptor(mockInterceptor).build();
|
||||||
|
@ -99,10 +99,10 @@ public class DaprPreviewClientHttpTest {
|
||||||
+ "\"etag\": \"6f54ad94-dfb9-46f0-a371-e42d550adb7d\"}]}");
|
+ "\"etag\": \"6f54ad94-dfb9-46f0-a371-e42d550adb7d\"}]}");
|
||||||
QueryStateResponse<String> response = daprPreviewClientHttp.queryState("testStore", "query", String.class).block();
|
QueryStateResponse<String> response = daprPreviewClientHttp.queryState("testStore", "query", String.class).block();
|
||||||
assertNotNull(response);
|
assertNotNull(response);
|
||||||
assertEquals("result size must be 1", 1, response.getResults().size());
|
assertEquals(1, response.getResults().size(), "result size must be 1");
|
||||||
assertEquals("result must be same", "1", response.getResults().get(0).getKey());
|
assertEquals( "1", response.getResults().get(0).getKey(), "result must be same");
|
||||||
assertEquals("result must be same", "testData", response.getResults().get(0).getValue());
|
assertEquals("testData", response.getResults().get(0).getValue(), "result must be same");
|
||||||
assertEquals("result must be same", "6f54ad94-dfb9-46f0-a371-e42d550adb7d", response.getResults().get(0).getEtag());
|
assertEquals( "6f54ad94-dfb9-46f0-a371-e42d550adb7d", response.getResults().get(0).getEtag(), "result must be same");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -13,8 +13,8 @@ limitations under the License.
|
||||||
|
|
||||||
package io.dapr.client.domain;
|
package io.dapr.client.domain;
|
||||||
|
|
||||||
import org.junit.Assert;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -22,7 +22,7 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
|
|
||||||
public class BulkPublishRequestTest {
|
public class BulkPublishRequestTest {
|
||||||
|
|
||||||
|
@ -38,6 +38,6 @@ public class BulkPublishRequestTest {
|
||||||
request.setMetadata(metadata);
|
request.setMetadata(metadata);
|
||||||
Map<String, String> initial = request.getMetadata();
|
Map<String, String> initial = request.getMetadata();
|
||||||
request.setMetadata(metadata);
|
request.setMetadata(metadata);
|
||||||
Assert.assertNotSame("Should not be same map", request.getMetadata(), initial);
|
Assertions.assertNotSame( request.getMetadata(), initial, "Should not be same map");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package io.dapr.client.domain;
|
package io.dapr.client.domain;
|
||||||
|
|
||||||
import org.junit.Assert;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
|
|
||||||
public class DeleteStateRequestTest {
|
public class DeleteStateRequestTest {
|
||||||
|
|
||||||
|
@ -26,6 +26,6 @@ public class DeleteStateRequestTest {
|
||||||
request.setMetadata(metadata);
|
request.setMetadata(metadata);
|
||||||
Map<String, String> initial = request.getMetadata();
|
Map<String, String> initial = request.getMetadata();
|
||||||
request.setMetadata(metadata);
|
request.setMetadata(metadata);
|
||||||
Assert.assertNotSame("Should not be same map", request.getMetadata(), initial);
|
Assertions.assertNotSame(request.getMetadata(), initial, "Should not be same map");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
package io.dapr.client.domain;
|
package io.dapr.client.domain;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static org.junit.Assert.assertNotSame;
|
import static org.junit.jupiter.api.Assertions.assertNotSame;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
|
|
||||||
public class ExecuteStateTransactionRequestTest {
|
public class ExecuteStateTransactionRequestTest {
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ public class ExecuteStateTransactionRequestTest {
|
||||||
request.setMetadata(metadata);
|
request.setMetadata(metadata);
|
||||||
Map<String, String> initial = request.getMetadata();
|
Map<String, String> initial = request.getMetadata();
|
||||||
request.setMetadata(metadata);
|
request.setMetadata(metadata);
|
||||||
assertNotSame("Should not be same map", request.getMetadata(), initial);
|
assertNotSame(request.getMetadata(), initial, "Should not be same map");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -41,6 +41,6 @@ public class ExecuteStateTransactionRequestTest {
|
||||||
request.setOperations(operations);
|
request.setOperations(operations);
|
||||||
List<TransactionalStateOperation<?>> initial = request.getOperations();
|
List<TransactionalStateOperation<?>> initial = request.getOperations();
|
||||||
request.setOperations(operations);
|
request.setOperations(operations);
|
||||||
assertNotSame("Should not be same list", request.getOperations(), initial);
|
assertNotSame(request.getOperations(), initial, "Should not be same list");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
package io.dapr.client.domain;
|
package io.dapr.client.domain;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static org.junit.Assert.assertNotSame;
|
import static org.junit.jupiter.api.Assertions.assertNotSame;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
|
|
||||||
public class GetBulkSecretRequestTest {
|
public class GetBulkSecretRequestTest {
|
||||||
|
|
||||||
|
@ -24,6 +24,6 @@ public class GetBulkSecretRequestTest {
|
||||||
request.setMetadata(metadata);
|
request.setMetadata(metadata);
|
||||||
Map<String, String> initial = request.getMetadata();
|
Map<String, String> initial = request.getMetadata();
|
||||||
request.setMetadata(metadata);
|
request.setMetadata(metadata);
|
||||||
assertNotSame("Should not be same map", request.getMetadata(), initial);
|
assertNotSame(request.getMetadata(), initial, "Should not be same map");
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,14 +1,17 @@
|
||||||
package io.dapr.client.domain;
|
package io.dapr.client.domain;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertNotSame;
|
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.jupiter.api.Assertions.assertNotSame;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
|
||||||
|
|
||||||
public class GetBulkStateRequestTest {
|
public class GetBulkStateRequestTest {
|
||||||
|
|
||||||
|
@ -32,7 +35,7 @@ public class GetBulkStateRequestTest {
|
||||||
request.setMetadata(metadata);
|
request.setMetadata(metadata);
|
||||||
Map<String, String> initial = request.getMetadata();
|
Map<String, String> initial = request.getMetadata();
|
||||||
request.setMetadata(metadata);
|
request.setMetadata(metadata);
|
||||||
assertNotSame("Should not be same map", request.getMetadata(), initial);
|
assertNotSame(request.getMetadata(), initial, "Should not be same map");
|
||||||
|
|
||||||
// Var args constructor
|
// Var args constructor
|
||||||
request = new GetBulkStateRequest(STORE_NAME, "test var key");
|
request = new GetBulkStateRequest(STORE_NAME, "test var key");
|
||||||
|
@ -53,6 +56,6 @@ public class GetBulkStateRequestTest {
|
||||||
request.setMetadata(metadata);
|
request.setMetadata(metadata);
|
||||||
initial = request.getMetadata();
|
initial = request.getMetadata();
|
||||||
request.setMetadata(metadata);
|
request.setMetadata(metadata);
|
||||||
assertNotSame("Should not be same map", request.getMetadata(), initial);
|
assertNotSame( request.getMetadata(), initial, "Should not be same map");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
package io.dapr.client.domain;
|
package io.dapr.client.domain;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
import static org.junit.Assert.assertNotSame;
|
import static org.junit.jupiter.api.Assertions.assertNotSame;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
import static org.junit.Assert.assertSame;
|
import static org.junit.jupiter.api.Assertions.assertSame;
|
||||||
|
|
||||||
public class GetSecretRequestTest {
|
public class GetSecretRequestTest {
|
||||||
|
|
||||||
|
@ -27,6 +27,6 @@ public class GetSecretRequestTest {
|
||||||
request.setMetadata(metadata);
|
request.setMetadata(metadata);
|
||||||
Map<String, String> initial = request.getMetadata();
|
Map<String, String> initial = request.getMetadata();
|
||||||
request.setMetadata(metadata);
|
request.setMetadata(metadata);
|
||||||
assertNotSame("Should not be same map", request.getMetadata(), initial);
|
assertNotSame(request.getMetadata(), initial, "Should not be same map");
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,12 +1,12 @@
|
||||||
package io.dapr.client.domain;
|
package io.dapr.client.domain;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static org.junit.Assert.assertNotSame;
|
import static org.junit.jupiter.api.Assertions.assertNotSame;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
|
|
||||||
public class GetStateRequestTest {
|
public class GetStateRequestTest {
|
||||||
|
|
||||||
|
@ -24,6 +24,6 @@ public class GetStateRequestTest {
|
||||||
request.setMetadata(metadata);
|
request.setMetadata(metadata);
|
||||||
Map<String, String> initial = request.getMetadata();
|
Map<String, String> initial = request.getMetadata();
|
||||||
request.setMetadata(metadata);
|
request.setMetadata(metadata);
|
||||||
assertNotSame("Should not be same map", request.getMetadata(), initial);
|
assertNotSame(request.getMetadata(), initial, "Should not be same map");
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,12 +1,12 @@
|
||||||
package io.dapr.client.domain;
|
package io.dapr.client.domain;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static org.junit.Assert.assertNotSame;
|
import static org.junit.jupiter.api.Assertions.assertNotSame;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
|
|
||||||
public class InvokeBindingRequestTest {
|
public class InvokeBindingRequestTest {
|
||||||
|
|
||||||
|
@ -24,6 +24,6 @@ public class InvokeBindingRequestTest {
|
||||||
request.setMetadata(metadata);
|
request.setMetadata(metadata);
|
||||||
Map<String, String> initial = request.getMetadata();
|
Map<String, String> initial = request.getMetadata();
|
||||||
request.setMetadata(metadata);
|
request.setMetadata(metadata);
|
||||||
assertNotSame("Should not be same map", request.getMetadata(), initial);
|
assertNotSame(request.getMetadata(), initial, "Should not be same map");
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,13 +1,13 @@
|
||||||
package io.dapr.client.domain;
|
package io.dapr.client.domain;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertNotSame;
|
import static org.junit.jupiter.api.Assertions.assertNotSame;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
|
|
||||||
public class PublishEventRequestTest {
|
public class PublishEventRequestTest {
|
||||||
|
|
||||||
|
@ -27,6 +27,6 @@ public class PublishEventRequestTest {
|
||||||
request.setMetadata(metadata);
|
request.setMetadata(metadata);
|
||||||
Map<String, String> initial = request.getMetadata();
|
Map<String, String> initial = request.getMetadata();
|
||||||
request.setMetadata(metadata);
|
request.setMetadata(metadata);
|
||||||
assertNotSame("Should not be same map", request.getMetadata(), initial);
|
assertNotSame(request.getMetadata(), initial, "Should not be same map");
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -2,13 +2,14 @@ package io.dapr.client.domain;
|
||||||
|
|
||||||
import io.dapr.client.domain.query.Query;
|
import io.dapr.client.domain.query.Query;
|
||||||
import io.dapr.client.domain.query.filters.EqFilter;
|
import io.dapr.client.domain.query.filters.EqFilter;
|
||||||
import org.junit.Assert;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
|
||||||
public class QueryStateRequestTest {
|
public class QueryStateRequestTest {
|
||||||
|
|
||||||
|
@ -27,20 +28,20 @@ public class QueryStateRequestTest {
|
||||||
request.setMetadata(metadata);
|
request.setMetadata(metadata);
|
||||||
Map<String, String> initial = request.getMetadata();
|
Map<String, String> initial = request.getMetadata();
|
||||||
request.setMetadata(metadata);
|
request.setMetadata(metadata);
|
||||||
Assert.assertNotSame("Should not be same map", request.getMetadata(), initial);
|
Assertions.assertNotSame(request.getMetadata(), initial, "Should not be same map");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test
|
||||||
public void testSetNullQuery() {
|
public void testSetNullQuery() {
|
||||||
QueryStateRequest request = new QueryStateRequest(STORE_NAME);
|
QueryStateRequest request = new QueryStateRequest(STORE_NAME);
|
||||||
request.setQuery(null);
|
assertThrows(IllegalArgumentException.class, () -> request.setQuery(null));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test
|
||||||
public void testSetNullFilterQuery() {
|
public void testSetNullFilterQuery() {
|
||||||
QueryStateRequest request = new QueryStateRequest(STORE_NAME);
|
QueryStateRequest request = new QueryStateRequest(STORE_NAME);
|
||||||
Query query = new Query();
|
Query query = new Query();
|
||||||
request.setQuery(query);
|
assertThrows(IllegalArgumentException.class, () -> request.setQuery(query));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -49,6 +50,6 @@ public class QueryStateRequestTest {
|
||||||
Query query = new Query();
|
Query query = new Query();
|
||||||
query.setFilter(new EqFilter<>("key", "value"));
|
query.setFilter(new EqFilter<>("key", "value"));
|
||||||
request.setQuery(query);
|
request.setQuery(query);
|
||||||
Assert.assertEquals(query, request.getQuery());
|
Assertions.assertEquals(query, request.getQuery());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package io.dapr.client.domain;
|
package io.dapr.client.domain;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertNotSame;
|
import static org.junit.jupiter.api.Assertions.assertNotSame;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
|
|
||||||
public class SaveStateRequestTest {
|
public class SaveStateRequestTest {
|
||||||
|
|
||||||
|
@ -24,11 +24,11 @@ public class SaveStateRequestTest {
|
||||||
request.setStates(states);
|
request.setStates(states);
|
||||||
List<State<?>> initial = request.getStates();
|
List<State<?>> initial = request.getStates();
|
||||||
request.setStates(states);
|
request.setStates(states);
|
||||||
assertNotSame("Should not be same list", request.getStates(), initial);
|
assertNotSame( request.getStates(), initial, "Should not be same list");
|
||||||
|
|
||||||
// With var args method
|
// With var args method
|
||||||
request.setStates(new State<>("test var args 1"), new State<>("test var args 2"));
|
request.setStates(new State<>("test var args 1"), new State<>("test var args 2"));
|
||||||
assertEquals("Value incorrectly set", "test var args 1", request.getStates().get(0).getKey());
|
assertEquals("test var args 1", request.getStates().get(0).getKey(), "Value incorrectly set");
|
||||||
assertEquals("Value incorrectly set", "test var args 2", request.getStates().get(1).getKey());
|
assertEquals("test var args 2", request.getStates().get(1).getKey(), "Value incorrectly set");
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,14 +1,14 @@
|
||||||
package io.dapr.client.domain;
|
package io.dapr.client.domain;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertNotEquals;
|
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
|
|
||||||
public class StateTest {
|
public class StateTest {
|
||||||
|
|
||||||
|
|
|
@ -3,11 +3,13 @@ package io.dapr.client.domain.query;
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import io.dapr.client.domain.query.filters.*;
|
import io.dapr.client.domain.query.filters.*;
|
||||||
import org.junit.Assert;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
|
||||||
public class QueryTest {
|
public class QueryTest {
|
||||||
|
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
@ -35,7 +37,7 @@ public class QueryTest {
|
||||||
q.setPagination(new Pagination(10, "test-token"));
|
q.setPagination(new Pagination(10, "test-token"));
|
||||||
q.setSort(Arrays.asList(new Sorting("value.person.org", Sorting.Order.ASC),
|
q.setSort(Arrays.asList(new Sorting("value.person.org", Sorting.Order.ASC),
|
||||||
new Sorting("value.state", Sorting.Order.DESC)));
|
new Sorting("value.state", Sorting.Order.DESC)));
|
||||||
Assert.assertEquals(json, mapper.writeValueAsString(q));
|
Assertions.assertEquals(json, mapper.writeValueAsString(q));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -44,61 +46,61 @@ public class QueryTest {
|
||||||
|
|
||||||
|
|
||||||
Query query = mapper.readValue(json, Query.class);
|
Query query = mapper.readValue(json, Query.class);
|
||||||
Assert.assertNotNull(query.getPagination());
|
Assertions.assertNotNull(query.getPagination());
|
||||||
Assert.assertNotNull(query.getFilter());
|
Assertions.assertNotNull(query.getFilter());
|
||||||
Assert.assertNotNull(query.getSort());
|
Assertions.assertNotNull(query.getSort());
|
||||||
|
|
||||||
// Assert Pagination
|
// Assert Pagination
|
||||||
Assert.assertEquals(10, query.getPagination().getLimit());
|
Assertions.assertEquals(10, query.getPagination().getLimit());
|
||||||
Assert.assertEquals("test-token", query.getPagination().getToken());
|
Assertions.assertEquals("test-token", query.getPagination().getToken());
|
||||||
|
|
||||||
// Assert Sort
|
// Assert Sort
|
||||||
Assert.assertEquals(2, query.getSort().size());
|
Assertions.assertEquals(2, query.getSort().size());
|
||||||
Assert.assertEquals("value.person.org", query.getSort().get(0).getKey());
|
Assertions.assertEquals("value.person.org", query.getSort().get(0).getKey());
|
||||||
Assert.assertEquals(Sorting.Order.ASC, query.getSort().get(0).getOrder());
|
Assertions.assertEquals(Sorting.Order.ASC, query.getSort().get(0).getOrder());
|
||||||
Assert.assertEquals("value.state", query.getSort().get(1).getKey());
|
Assertions.assertEquals("value.state", query.getSort().get(1).getKey());
|
||||||
Assert.assertEquals(Sorting.Order.DESC, query.getSort().get(1).getOrder());
|
Assertions.assertEquals(Sorting.Order.DESC, query.getSort().get(1).getOrder());
|
||||||
|
|
||||||
// Assert Filter
|
// Assert Filter
|
||||||
// Top level AND filter
|
// Top level AND filter
|
||||||
Assert.assertEquals("AND", query.getFilter().getName());
|
Assertions.assertEquals("AND", query.getFilter().getName());
|
||||||
// Type cast to AND filter
|
// Type cast to AND filter
|
||||||
AndFilter filter = (AndFilter) query.getFilter();
|
AndFilter filter = (AndFilter) query.getFilter();
|
||||||
// Assert 3 AND clauses
|
// Assert 3 AND clauses
|
||||||
Assert.assertEquals(3, filter.getClauses().length);
|
Assertions.assertEquals(3, filter.getClauses().length);
|
||||||
Filter<?>[] andClauses = filter.getClauses();
|
Filter<?>[] andClauses = filter.getClauses();
|
||||||
// First EQ
|
// First EQ
|
||||||
Assert.assertEquals("EQ", andClauses[0].getName());
|
Assertions.assertEquals("EQ", andClauses[0].getName());
|
||||||
Assert.assertSame(EqFilter.class, andClauses[0].getClass());
|
Assertions.assertSame(EqFilter.class, andClauses[0].getClass());
|
||||||
EqFilter<?> eq = (EqFilter<?>) andClauses[0];
|
EqFilter<?> eq = (EqFilter<?>) andClauses[0];
|
||||||
Assert.assertEquals("key", eq.getKey());
|
Assertions.assertEquals("key", eq.getKey());
|
||||||
Assert.assertEquals("value", eq.getValue());
|
Assertions.assertEquals("value", eq.getValue());
|
||||||
// Second IN
|
// Second IN
|
||||||
Assert.assertEquals("IN", andClauses[1].getName());
|
Assertions.assertEquals("IN", andClauses[1].getName());
|
||||||
Assert.assertSame(InFilter.class, andClauses[1].getClass());
|
Assertions.assertSame(InFilter.class, andClauses[1].getClass());
|
||||||
InFilter<?> in = (InFilter<?>) andClauses[1];
|
InFilter<?> in = (InFilter<?>) andClauses[1];
|
||||||
Assert.assertEquals("key2", in.getKey());
|
Assertions.assertEquals("key2", in.getKey());
|
||||||
Assert.assertArrayEquals(new String[]{ "v1", "v2" }, in.getValues().toArray());
|
Assertions.assertArrayEquals(new String[]{ "v1", "v2" }, in.getValues().toArray());
|
||||||
// Third OR
|
// Third OR
|
||||||
Assert.assertEquals("OR", andClauses[2].getName());
|
Assertions.assertEquals("OR", andClauses[2].getName());
|
||||||
Assert.assertSame(OrFilter.class, andClauses[2].getClass());
|
Assertions.assertSame(OrFilter.class, andClauses[2].getClass());
|
||||||
OrFilter orFilter = (OrFilter) andClauses[2];
|
OrFilter orFilter = (OrFilter) andClauses[2];
|
||||||
Filter<?>[] orClauses = orFilter.getClauses();
|
Filter<?>[] orClauses = orFilter.getClauses();
|
||||||
// First EQ in OR
|
// First EQ in OR
|
||||||
Assert.assertEquals("EQ", orClauses[0].getName());
|
Assertions.assertEquals("EQ", orClauses[0].getName());
|
||||||
Assert.assertSame(EqFilter.class, orClauses[0].getClass());
|
Assertions.assertSame(EqFilter.class, orClauses[0].getClass());
|
||||||
eq = (EqFilter<?>) orClauses[0];
|
eq = (EqFilter<?>) orClauses[0];
|
||||||
Assert.assertEquals("v2", eq.getKey());
|
Assertions.assertEquals("v2", eq.getKey());
|
||||||
Assert.assertEquals(true, eq.getValue());
|
Assertions.assertEquals(true, eq.getValue());
|
||||||
// Second IN in OR
|
// Second IN in OR
|
||||||
Assert.assertEquals("IN", orClauses[1].getName());
|
Assertions.assertEquals("IN", orClauses[1].getName());
|
||||||
Assert.assertSame(InFilter.class, orClauses[1].getClass());
|
Assertions.assertSame(InFilter.class, orClauses[1].getClass());
|
||||||
in = (InFilter<?>) orClauses[1];
|
in = (InFilter<?>) orClauses[1];
|
||||||
Assert.assertEquals("v3", in.getKey());
|
Assertions.assertEquals("v3", in.getKey());
|
||||||
Assert.assertArrayEquals(new Double[]{ 1.3, 1.5 }, in.getValues().toArray());
|
Assertions.assertArrayEquals(new Double[]{ 1.3, 1.5 }, in.getValues().toArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test
|
||||||
public void testQueryInValidFilter() throws JsonProcessingException {
|
public void testQueryInValidFilter() throws JsonProcessingException {
|
||||||
Query q = new Query();
|
Query q = new Query();
|
||||||
|
|
||||||
|
@ -113,6 +115,6 @@ public class QueryTest {
|
||||||
filter.addClause((Filter<?>) orFilter);
|
filter.addClause((Filter<?>) orFilter);
|
||||||
|
|
||||||
// Add Filter
|
// Add Filter
|
||||||
q.setFilter(filter);
|
assertThrows(IllegalArgumentException.class, () -> q.setFilter(filter));
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -2,8 +2,8 @@ package io.dapr.client.domain.query.filters;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import org.junit.Assert;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
public class AndFilterTest {
|
public class AndFilterTest {
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ public class AndFilterTest {
|
||||||
filter.addClause(new EqFilter<>("key", "value"));
|
filter.addClause(new EqFilter<>("key", "value"));
|
||||||
filter.addClause(new InFilter<>("key2", "v1", "v2"));
|
filter.addClause(new InFilter<>("key2", "v1", "v2"));
|
||||||
|
|
||||||
Assert.assertEquals(json, MAPPER.writeValueAsString((Filter) filter));
|
Assertions.assertEquals(json, MAPPER.writeValueAsString((Filter) filter));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -26,34 +26,34 @@ public class AndFilterTest {
|
||||||
Filter<?> res = MAPPER.readValue(json, Filter.class);
|
Filter<?> res = MAPPER.readValue(json, Filter.class);
|
||||||
|
|
||||||
// Check for AndFilter
|
// Check for AndFilter
|
||||||
Assert.assertEquals("AND", res.getName());
|
Assertions.assertEquals("AND", res.getName());
|
||||||
Assert.assertSame(AndFilter.class, res.getClass());
|
Assertions.assertSame(AndFilter.class, res.getClass());
|
||||||
|
|
||||||
AndFilter filter = (AndFilter) res;
|
AndFilter filter = (AndFilter) res;
|
||||||
// Check 2 clauses
|
// Check 2 clauses
|
||||||
Assert.assertEquals(2, filter.getClauses().length);
|
Assertions.assertEquals(2, filter.getClauses().length);
|
||||||
// First EQ
|
// First EQ
|
||||||
Assert.assertSame(EqFilter.class, filter.getClauses()[0].getClass());
|
Assertions.assertSame(EqFilter.class, filter.getClauses()[0].getClass());
|
||||||
EqFilter<?> eq = (EqFilter<?>) filter.getClauses()[0];
|
EqFilter<?> eq = (EqFilter<?>) filter.getClauses()[0];
|
||||||
Assert.assertEquals("key", eq.getKey());
|
Assertions.assertEquals("key", eq.getKey());
|
||||||
Assert.assertEquals("value", eq.getValue());
|
Assertions.assertEquals("value", eq.getValue());
|
||||||
// Second IN
|
// Second IN
|
||||||
Assert.assertSame(InFilter.class, filter.getClauses()[1].getClass());
|
Assertions.assertSame(InFilter.class, filter.getClauses()[1].getClass());
|
||||||
InFilter<?> in = (InFilter<?>) filter.getClauses()[1];
|
InFilter<?> in = (InFilter<?>) filter.getClauses()[1];
|
||||||
Assert.assertEquals("key2", in.getKey());
|
Assertions.assertEquals("key2", in.getKey());
|
||||||
Assert.assertArrayEquals(new String[]{ "v1", "v2" }, in.getValues().toArray());
|
Assertions.assertArrayEquals(new String[]{ "v1", "v2" }, in.getValues().toArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testValidation() {
|
public void testValidation() {
|
||||||
AndFilter filter = new AndFilter();
|
AndFilter filter = new AndFilter();
|
||||||
Assert.assertFalse(filter.isValid());
|
Assertions.assertFalse(filter.isValid());
|
||||||
|
|
||||||
filter.addClause(new EqFilter<>("key1", "v2"));
|
filter.addClause(new EqFilter<>("key1", "v2"));
|
||||||
Assert.assertFalse(filter.isValid());
|
Assertions.assertFalse(filter.isValid());
|
||||||
|
|
||||||
filter.addClause(new EqFilter<>("key2", "v3"));
|
filter.addClause(new EqFilter<>("key2", "v3"));
|
||||||
Assert.assertTrue(filter.isValid());
|
Assertions.assertTrue(filter.isValid());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,8 @@ package io.dapr.client.domain.query.filters;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import org.junit.Assert;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
public class EqFilterTest {
|
public class EqFilterTest {
|
||||||
private static final ObjectMapper MAPPER = new ObjectMapper();
|
private static final ObjectMapper MAPPER = new ObjectMapper();
|
||||||
|
@ -14,32 +14,32 @@ public class EqFilterTest {
|
||||||
public void testSerialization() throws JsonProcessingException {
|
public void testSerialization() throws JsonProcessingException {
|
||||||
EqFilter<?> filter = new EqFilter<>("key", 1.5);
|
EqFilter<?> filter = new EqFilter<>("key", 1.5);
|
||||||
|
|
||||||
Assert.assertEquals(json, MAPPER.writeValueAsString(filter));
|
Assertions.assertEquals(json, MAPPER.writeValueAsString(filter));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDeserialization() throws JsonProcessingException {
|
public void testDeserialization() throws JsonProcessingException {
|
||||||
EqFilter<?> filter = MAPPER.readValue(json, EqFilter.class);
|
EqFilter<?> filter = MAPPER.readValue(json, EqFilter.class);
|
||||||
Assert.assertEquals("key", filter.getKey());
|
Assertions.assertEquals("key", filter.getKey());
|
||||||
Assert.assertEquals(1.5, filter.getValue());
|
Assertions.assertEquals(1.5, filter.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testValidation() {
|
public void testValidation() {
|
||||||
EqFilter<?> filter = new EqFilter<>(null, "val");
|
EqFilter<?> filter = new EqFilter<>(null, "val");
|
||||||
Assert.assertFalse(filter.isValid());
|
Assertions.assertFalse(filter.isValid());
|
||||||
|
|
||||||
|
|
||||||
filter = new EqFilter<>("", "");
|
filter = new EqFilter<>("", "");
|
||||||
Assert.assertFalse(filter.isValid());
|
Assertions.assertFalse(filter.isValid());
|
||||||
|
|
||||||
filter = new EqFilter<>("", true);
|
filter = new EqFilter<>("", true);
|
||||||
Assert.assertFalse(filter.isValid());
|
Assertions.assertFalse(filter.isValid());
|
||||||
|
|
||||||
filter = new EqFilter<>(" ", "valid");
|
filter = new EqFilter<>(" ", "valid");
|
||||||
Assert.assertFalse(filter.isValid());
|
Assertions.assertFalse(filter.isValid());
|
||||||
|
|
||||||
filter = new EqFilter<>("valid", "");
|
filter = new EqFilter<>("valid", "");
|
||||||
Assert.assertTrue(filter.isValid());
|
Assertions.assertTrue(filter.isValid());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,8 @@ package io.dapr.client.domain.query.filters;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import org.junit.Assert;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
public class InFilterTest {
|
public class InFilterTest {
|
||||||
private static final ObjectMapper MAPPER = new ObjectMapper();
|
private static final ObjectMapper MAPPER = new ObjectMapper();
|
||||||
|
@ -14,35 +14,35 @@ public class InFilterTest {
|
||||||
public void testSerialization() throws JsonProcessingException {
|
public void testSerialization() throws JsonProcessingException {
|
||||||
InFilter<?> filter = new InFilter<>("key", 1.5, 44.0);
|
InFilter<?> filter = new InFilter<>("key", 1.5, 44.0);
|
||||||
|
|
||||||
Assert.assertEquals(json, MAPPER.writeValueAsString(filter));
|
Assertions.assertEquals(json, MAPPER.writeValueAsString(filter));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDeserialization() throws JsonProcessingException {
|
public void testDeserialization() throws JsonProcessingException {
|
||||||
InFilter<?> filter = MAPPER.readValue(json, InFilter.class);
|
InFilter<?> filter = MAPPER.readValue(json, InFilter.class);
|
||||||
Assert.assertEquals("key", filter.getKey());
|
Assertions.assertEquals("key", filter.getKey());
|
||||||
Assert.assertArrayEquals(new Double[]{ 1.5, 44.0 }, filter.getValues().toArray());
|
Assertions.assertArrayEquals(new Double[]{ 1.5, 44.0 }, filter.getValues().toArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testValidation() {
|
public void testValidation() {
|
||||||
InFilter<?> filter = new InFilter<>(null, "val");
|
InFilter<?> filter = new InFilter<>(null, "val");
|
||||||
Assert.assertFalse(filter.isValid());
|
Assertions.assertFalse(filter.isValid());
|
||||||
|
|
||||||
|
|
||||||
filter = new InFilter<>("", "");
|
filter = new InFilter<>("", "");
|
||||||
Assert.assertFalse(filter.isValid());
|
Assertions.assertFalse(filter.isValid());
|
||||||
|
|
||||||
filter = new InFilter<>("", true);
|
filter = new InFilter<>("", true);
|
||||||
Assert.assertFalse(filter.isValid());
|
Assertions.assertFalse(filter.isValid());
|
||||||
|
|
||||||
filter = new InFilter<>(" ", "valid");
|
filter = new InFilter<>(" ", "valid");
|
||||||
Assert.assertFalse(filter.isValid());
|
Assertions.assertFalse(filter.isValid());
|
||||||
|
|
||||||
filter = new InFilter<>("valid", "");
|
filter = new InFilter<>("valid", "");
|
||||||
Assert.assertTrue(filter.isValid());
|
Assertions.assertTrue(filter.isValid());
|
||||||
|
|
||||||
filter = new InFilter<>("valid", "1.5", "2.5");
|
filter = new InFilter<>("valid", "1.5", "2.5");
|
||||||
Assert.assertTrue(filter.isValid());
|
Assertions.assertTrue(filter.isValid());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue