diff --git a/showcase/gapic-showcase/pom.xml b/showcase/gapic-showcase/pom.xml index 3ff935c1de..96b4045ebd 100644 --- a/showcase/gapic-showcase/pom.xml +++ b/showcase/gapic-showcase/pom.xml @@ -165,7 +165,6 @@ junit test - com.google.truth truth diff --git a/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITUnaryCallable.java b/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITUnaryCallable.java index 82fb80be0e..1d1ccd1bec 100644 --- a/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITUnaryCallable.java +++ b/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITUnaryCallable.java @@ -100,11 +100,29 @@ public void testGrpc_shutdown() { } @Test - public void testHttpJson() { + public void testHttpJson_receiveContent() { assertThat(echoHttpJson("http-echo?")).isEqualTo("http-echo?"); assertThat(echoHttpJson("http-echo!")).isEqualTo("http-echo!"); } + @Test + public void testHttpJson_serverResponseError_throwsException() { + EchoRequest requestWithServerError = + EchoRequest.newBuilder() + .setError(Status.newBuilder().setCode(StatusCode.Code.CANCELLED.ordinal()).build()) + .build(); + CancelledException exception = + assertThrows(CancelledException.class, () -> httpJsonClient.echo(requestWithServerError)); + assertThat(exception.getStatusCode().getCode()).isEqualTo(StatusCode.Code.CANCELLED); + } + + @Test + public void testHttpJson_shutdown() { + assertThat(httpJsonClient.isShutdown()).isFalse(); + httpJsonClient.shutdown(); + assertThat(httpJsonClient.isShutdown()).isTrue(); + } + private String echoGrpc(String value) { EchoResponse response = grpcClient.echo(EchoRequest.newBuilder().setContent(value).build()); return response.getContent();