Add reactive test
This commit is contained in:
@@ -17,9 +17,9 @@ java {
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
mavenLocal()
|
||||
maven { url 'https://repo.spring.io/milestone' }
|
||||
maven { url 'https://repo.spring.io/snapshot' }
|
||||
mavenLocal()
|
||||
}
|
||||
|
||||
dependencyManagement {
|
||||
|
||||
@@ -74,6 +74,10 @@
|
||||
<groupId>io.projectreactor</groupId>
|
||||
<artifactId>reactor-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.projectreactor</groupId>
|
||||
<artifactId>reactor-test</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.salesforce.servicelibs</groupId>
|
||||
<artifactId>reactor-grpc-stub</artifactId>
|
||||
|
||||
@@ -14,11 +14,16 @@ import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.grpc.client.GrpcChannelFactory;
|
||||
import org.springframework.grpc.sample.proto.HelloReply;
|
||||
import org.springframework.grpc.sample.proto.HelloRequest;
|
||||
import org.springframework.grpc.sample.proto.ReactorSimpleGrpc;
|
||||
import org.springframework.grpc.sample.proto.ReactorSimpleGrpc.ReactorSimpleStub;
|
||||
import org.springframework.grpc.sample.proto.SimpleGrpc;
|
||||
import org.springframework.grpc.test.AutoConfigureInProcessTransport;
|
||||
import org.springframework.grpc.test.LocalGrpcPort;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
@SpringBootTest
|
||||
@AutoConfigureInProcessTransport
|
||||
public class GrpcServerApplicationTests {
|
||||
@@ -30,7 +35,7 @@ public class GrpcServerApplicationTests {
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private SimpleGrpc.SimpleBlockingStub stub;
|
||||
private ReactorSimpleStub stub;
|
||||
|
||||
@Test
|
||||
@DirtiesContext
|
||||
@@ -41,8 +46,10 @@ public class GrpcServerApplicationTests {
|
||||
@DirtiesContext
|
||||
void serverResponds() {
|
||||
log.info("Testing");
|
||||
HelloReply response = stub.sayHello(HelloRequest.newBuilder().setName("Alien").build());
|
||||
assertEquals("Hello ==> Alien", response.getMessage());
|
||||
Mono<HelloReply> reply = stub.sayHello(HelloRequest.newBuilder().setName("Alien").build());
|
||||
StepVerifier.create(reply.map(response -> response.getMessage()))
|
||||
.expectNext("Hello ==> Alien")
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@TestConfiguration
|
||||
@@ -50,8 +57,8 @@ public class GrpcServerApplicationTests {
|
||||
|
||||
@Bean
|
||||
@Lazy
|
||||
SimpleGrpc.SimpleBlockingStub stub(GrpcChannelFactory channels, @LocalGrpcPort int port) {
|
||||
return SimpleGrpc.newBlockingStub(channels.createChannel("0.0.0.0:" + port));
|
||||
ReactorSimpleStub stub(GrpcChannelFactory channels, @LocalGrpcPort int port) {
|
||||
return ReactorSimpleGrpc.newReactorStub(channels.createChannel("0.0.0.0:" + port));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user