mirror of https://github.com/grpc/grpc-java.git
interop-testing: fix ErrorProne and Unused
This commit is contained in:
parent
dba2323585
commit
80ac407c6c
|
@ -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 {
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue