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