Skip to content

Commit 661a14a

Browse files
Improve handle grpc runtime exception test
1 parent d440b55 commit 661a14a

File tree

1 file changed

+5
-2
lines changed
  • spring-cloud-gateway-integration-tests/grpc/src/test/java/org/springframework/cloud/gateway/tests/grpc

1 file changed

+5
-2
lines changed

spring-cloud-gateway-integration-tests/grpc/src/test/java/org/springframework/cloud/gateway/tests/grpc/GRPCApplicationTests.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,18 @@ private ManagedChannel createSecuredChannel(int port) throws SSLException {
7676
@Test
7777
public void gRPCUnaryCallShouldHandleRuntimeException() throws SSLException {
7878
ManagedChannel channel = createSecuredChannel(gatewayPort);
79+
boolean thrown = false;
7980

8081
try {
8182
HelloServiceGrpc.newBlockingStub(channel)
8283
.hello(HelloRequest.newBuilder().setFirstName("failWithRuntimeException!").build());
8384
}
8485
catch (StatusRuntimeException e) {
85-
Assertions.assertThat(FAILED_PRECONDITION.getCode()).isEqualTo(e.getStatus().getCode());
86-
Assertions.assertThat("Invalid firstName").isEqualTo(e.getStatus().getDescription());
86+
thrown = true;
87+
Assertions.assertThat(e.getStatus().getCode()).isEqualTo(FAILED_PRECONDITION.getCode());
88+
Assertions.assertThat(e.getStatus().getDescription()).isEqualTo("Invalid firstName");
8789
}
90+
Assertions.assertThat(thrown).withFailMessage("Expected exception not thrown!").isTrue();
8891
}
8992

9093
@Test

0 commit comments

Comments
 (0)