diff --git a/interop-testing/src/main/java/io/grpc/testing/integration/AbstractInteropTest.java b/interop-testing/src/main/java/io/grpc/testing/integration/AbstractInteropTest.java index a8e5f69648..c9f16218a7 100644 --- a/interop-testing/src/main/java/io/grpc/testing/integration/AbstractInteropTest.java +++ b/interop-testing/src/main/java/io/grpc/testing/integration/AbstractInteropTest.java @@ -27,7 +27,6 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.timeout; -import static org.mockito.Mockito.times; import com.google.auth.oauth2.AccessToken; import com.google.auth.oauth2.ComputeEngineCredentials; @@ -1658,10 +1657,6 @@ public abstract class AbstractInteropTest { } } - private static T verify(T mock) { - return verify(mock, times(1)); - } - /** * Wrapper around {@link Mockito#verify}, to keep log spam down on failure. */ @@ -1702,7 +1697,6 @@ public abstract class AbstractInteropTest { TestClientStreamTracer tracer = clientStreamTracers.poll(); assertNotNull(tracer); assertTrue(tracer.getOutboundHeaders()); - ArgumentCaptor statusCaptor = ArgumentCaptor.forClass(Status.class); // assertClientMetrics() is called right after application receives status, // but streamClosed() may be called slightly later than that. So we need a timeout. try { @@ -1727,6 +1721,7 @@ public abstract class AbstractInteropTest { assertClientMetrics(method, status, null, null); } + @SuppressWarnings("AssertionFailureIgnored") // Failure is checked in the end by the passed flag. private void assertServerMetrics(String method, Status.Code code, Collection requests, Collection responses) { AssertionError checkFailure = null; @@ -1777,7 +1772,6 @@ public abstract class AbstractInteropTest { try { assertEquals(method, tracerInfo.fullMethodName); assertNotNull(tracerInfo.tracer.contextCapture); - ArgumentCaptor statusCaptor = ArgumentCaptor.forClass(Status.class); // On the server, streamClosed() may be called after the client receives the final status. // So we use a timeout. try { diff --git a/interop-testing/src/test/java/io/grpc/testing/integration/Http2OkHttpTest.java b/interop-testing/src/test/java/io/grpc/testing/integration/Http2OkHttpTest.java index 68082f4c5a..ba6f0fa1c4 100644 --- a/interop-testing/src/test/java/io/grpc/testing/integration/Http2OkHttpTest.java +++ b/interop-testing/src/test/java/io/grpc/testing/integration/Http2OkHttpTest.java @@ -17,8 +17,8 @@ package io.grpc.testing.integration; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; import com.google.common.base.Throwables; import com.google.protobuf.EmptyProtos.Empty; @@ -42,7 +42,6 @@ import java.io.IOException; import javax.net.ssl.HostnameVerifier; import javax.net.ssl.SSLPeerUnverifiedException; import javax.net.ssl.SSLSession; - import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; @@ -150,14 +149,16 @@ public class Http2OkHttpTest extends AbstractInteropTest { TestServiceGrpc.TestServiceBlockingStub blockingStub = TestServiceGrpc.newBlockingStub(channel); + Throwable actualThrown = null; try { blockingStub.emptyCall(Empty.getDefaultInstance()); - fail("The rpc should have been failed due to hostname verification"); } catch (Throwable t) { - Throwable cause = Throwables.getRootCause(t); - assertTrue("Failed by unexpected exception: " + cause, - cause instanceof SSLPeerUnverifiedException); + actualThrown = t; } + assertNotNull("The rpc should have been failed due to hostname verification", actualThrown); + Throwable cause = Throwables.getRootCause(actualThrown); + assertTrue( + "Failed by unexpected exception: " + cause, cause instanceof SSLPeerUnverifiedException); channel.shutdown(); } @@ -196,14 +197,16 @@ public class Http2OkHttpTest extends AbstractInteropTest { TestServiceGrpc.TestServiceBlockingStub blockingStub = TestServiceGrpc.newBlockingStub(channel); + Throwable actualThrown = null; try { blockingStub.emptyCall(Empty.getDefaultInstance()); - fail("The rpc should have been failed due to hostname verification"); } catch (Throwable t) { - Throwable cause = Throwables.getRootCause(t); - assertTrue("Failed by unexpected exception: " + cause, - cause instanceof SSLPeerUnverifiedException); + actualThrown = t; } + assertNotNull("The rpc should have been failed due to hostname verification", actualThrown); + Throwable cause = Throwables.getRootCause(actualThrown); + assertTrue( + "Failed by unexpected exception: " + cause, cause instanceof SSLPeerUnverifiedException); channel.shutdown(); } }