aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZHANG Dapeng <zdapeng@google.com>2017-10-05 14:15:43 -0700
committerGitHub <noreply@github.com>2017-10-05 14:15:43 -0700
commit80ac407c6c59fe9833f8f25f3876becbce245ab0 (patch)
tree639b89f9f61ddcf1b1abdfc951fede6b01044001
parentdba2323585061f8634e37de7c757330826567a9d (diff)
downloadgrpc-grpc-java-80ac407c6c59fe9833f8f25f3876becbce245ab0.tar.gz
interop-testing: fix ErrorProne and Unused
-rw-r--r--interop-testing/src/main/java/io/grpc/testing/integration/AbstractInteropTest.java8
-rw-r--r--interop-testing/src/test/java/io/grpc/testing/integration/Http2OkHttpTest.java23
2 files changed, 14 insertions, 17 deletions
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 a8e5f6964..c9f16218a 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> 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<Status> 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<? extends MessageLite> requests, Collection<? extends MessageLite> responses) {
AssertionError checkFailure = null;
@@ -1777,7 +1772,6 @@ public abstract class AbstractInteropTest {
try {
assertEquals(method, tracerInfo.fullMethodName);
assertNotNull(tracerInfo.tracer.contextCapture);
- ArgumentCaptor<Status> 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 68082f4c5..ba6f0fa1c 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();
}
}