mirror of https://github.com/grpc/grpc-java.git
Prepare for JUnit 4.13
It deprecates ExpectedException and Assert.assertThat(T, org.hamcrest.Matcher). Without Java 8 we don't want to migrate away from ExpectedException at this time. We tend to prefer Truth over Hamcrest, so I swapped the one instance of Assert.assertThat() to use Truth. With this change we get a warning-less build with JUnit 4.13. We don't yet upgrade because we still need to support JUnit 4.12 for some use-cases, but will be able to upgrade to 4.13 soon when they upgrade.
This commit is contained in:
parent
2adeff56fe
commit
4c1bab9ed5
|
|
@ -16,15 +16,14 @@
|
|||
|
||||
package io.grpc;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static io.grpc.Contexts.interceptCall;
|
||||
import static io.grpc.Contexts.statusFromCancelled;
|
||||
import static org.hamcrest.core.IsInstanceOf.instanceOf;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
|
|
@ -240,7 +239,7 @@ public class ContextsTest {
|
|||
executorService.command.run();
|
||||
|
||||
assertTrue(cancellableContext.isCancelled());
|
||||
assertThat(cancellableContext.cancellationCause(), instanceOf(TimeoutException.class));
|
||||
assertThat(cancellableContext.cancellationCause()).isInstanceOf(TimeoutException.class);
|
||||
|
||||
Status status = statusFromCancelled(cancellableContext);
|
||||
assertNotNull(status);
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ import org.junit.runners.JUnit4;
|
|||
@RunWith(JUnit4.class)
|
||||
public class MetadataTest {
|
||||
|
||||
@SuppressWarnings("deprecation") // https://github.com/grpc/grpc-java/issues/7467
|
||||
@Rule public final ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
private static final Metadata.BinaryMarshaller<Fish> FISH_MARSHALLER =
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ import org.junit.runners.JUnit4;
|
|||
*/
|
||||
@RunWith(JUnit4.class)
|
||||
public class MethodDescriptorTest {
|
||||
@SuppressWarnings("deprecation") // https://github.com/grpc/grpc-java/issues/7467
|
||||
@Rule
|
||||
public final ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ public class ServerInterceptorsTest {
|
|||
@Rule
|
||||
public final MockitoRule mocks = MockitoJUnit.rule();
|
||||
|
||||
@SuppressWarnings("deprecation") // https://github.com/grpc/grpc-java/issues/7467
|
||||
@Rule
|
||||
public final ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ public class ServerServiceDefinitionTest {
|
|||
= ServerMethodDefinition.create(method1, methodHandler1);
|
||||
private ServerMethodDefinition<String, Integer> methodDef2
|
||||
= ServerMethodDefinition.create(method2, methodHandler2);
|
||||
@SuppressWarnings("deprecation") // https://github.com/grpc/grpc-java/issues/7467
|
||||
@Rule
|
||||
public ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ import org.junit.runners.JUnit4;
|
|||
@RunWith(JUnit4.class)
|
||||
public class ServiceDescriptorTest {
|
||||
|
||||
@SuppressWarnings("deprecation") // https://github.com/grpc/grpc-java/issues/7467
|
||||
@Rule
|
||||
public final ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
|
|
|
|||
|
|
@ -75,6 +75,7 @@ import org.mockito.stubbing.Answer;
|
|||
public class AbstractClientStreamTest {
|
||||
|
||||
@Rule public final MockitoRule mocks = MockitoJUnit.rule();
|
||||
@SuppressWarnings("deprecation") // https://github.com/grpc/grpc-java/issues/7467
|
||||
@Rule public final ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
private final StatsTraceContext statsTraceCtx = StatsTraceContext.NOOP;
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ public class AbstractServerStreamTest {
|
|||
private static final int TIMEOUT_MS = 1000;
|
||||
private static final int MAX_MESSAGE_SIZE = 100;
|
||||
|
||||
@SuppressWarnings("deprecation") // https://github.com/grpc/grpc-java/issues/7467
|
||||
@Rule public final ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
private final WritableBufferAllocator allocator = new WritableBufferAllocator() {
|
||||
|
|
|
|||
|
|
@ -224,6 +224,7 @@ public abstract class AbstractTransportTest {
|
|||
}
|
||||
}));
|
||||
|
||||
@SuppressWarnings("deprecation") // https://github.com/grpc/grpc-java/issues/7467
|
||||
@Rule
|
||||
public ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ import org.junit.runners.JUnit4;
|
|||
*/
|
||||
@RunWith(JUnit4.class)
|
||||
public class ConnectivityStateManagerTest {
|
||||
@SuppressWarnings("deprecation") // https://github.com/grpc/grpc-java/issues/7467
|
||||
@Rule
|
||||
public final ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
|
|
|
|||
|
|
@ -98,6 +98,7 @@ public class DnsNameResolverTest {
|
|||
|
||||
@Rule public final TestRule globalTimeout = new DisableOnDebug(Timeout.seconds(10));
|
||||
@Rule public final MockitoRule mocks = MockitoJUnit.rule();
|
||||
@SuppressWarnings("deprecation") // https://github.com/grpc/grpc-java/issues/7467
|
||||
@Rule public final ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
private final Map<String, ?> serviceConfig = new LinkedHashMap<>();
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ import org.junit.runners.JUnit4;
|
|||
@RunWith(JUnit4.class)
|
||||
public class GrpcUtilTest {
|
||||
|
||||
@SuppressWarnings("deprecation") // https://github.com/grpc/grpc-java/issues/7467
|
||||
@Rule public final ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -77,6 +77,7 @@ import org.mockito.junit.MockitoRule;
|
|||
public class InternalSubchannelTest {
|
||||
@Rule
|
||||
public final MockitoRule mocks = MockitoJUnit.rule();
|
||||
@SuppressWarnings("deprecation") // https://github.com/grpc/grpc-java/issues/7467
|
||||
@Rule
|
||||
public final ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ import org.junit.runners.JUnit4;
|
|||
@RunWith(JUnit4.class)
|
||||
public class JsonParserTest {
|
||||
|
||||
@SuppressWarnings("deprecation") // https://github.com/grpc/grpc-java/issues/7467
|
||||
@Rule
|
||||
public final ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
|
|
|
|||
|
|
@ -80,6 +80,7 @@ public class ManagedChannelImplBuilderTest {
|
|||
};
|
||||
|
||||
@Rule public final MockitoRule mocks = MockitoJUnit.rule();
|
||||
@SuppressWarnings("deprecation") // https://github.com/grpc/grpc-java/issues/7467
|
||||
@Rule public final ExpectedException thrown = ExpectedException.none();
|
||||
@Rule public final GrpcCleanupRule grpcCleanupRule = new GrpcCleanupRule();
|
||||
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ import org.junit.runners.JUnit4;
|
|||
@RunWith(JUnit4.class)
|
||||
public class ManagedChannelServiceConfigTest {
|
||||
|
||||
@SuppressWarnings("deprecation") // https://github.com/grpc/grpc-java/issues/7467
|
||||
@Rule
|
||||
public final ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
|
|
|
|||
|
|
@ -337,6 +337,7 @@ public class MessageDeframerTest {
|
|||
|
||||
@RunWith(JUnit4.class)
|
||||
public static class SizeEnforcingInputStreamTests {
|
||||
@SuppressWarnings("deprecation") // https://github.com/grpc/grpc-java/issues/7467
|
||||
@Rule
|
||||
public final ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ import org.mockito.MockitoAnnotations;
|
|||
|
||||
@RunWith(JUnit4.class)
|
||||
public class ServerCallImplTest {
|
||||
@SuppressWarnings("deprecation") // https://github.com/grpc/grpc-java/issues/7467
|
||||
@Rule public final ExpectedException thrown = ExpectedException.none();
|
||||
@Mock private ServerStream stream;
|
||||
@Mock private ServerCall.Listener<Long> callListener;
|
||||
|
|
|
|||
|
|
@ -139,6 +139,7 @@ public class ServerImplTest {
|
|||
};
|
||||
private static final String AUTHORITY = "some_authority";
|
||||
|
||||
@SuppressWarnings("deprecation") // https://github.com/grpc/grpc-java/issues/7467
|
||||
@Rule public final ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
@BeforeClass
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ import org.mockito.InOrder;
|
|||
*/
|
||||
@RunWith(JUnit4.class)
|
||||
public class GracefulSwitchLoadBalancerTest {
|
||||
@SuppressWarnings("deprecation") // https://github.com/grpc/grpc-java/issues/7467
|
||||
@Rule
|
||||
public final ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ import org.junit.runners.JUnit4;
|
|||
@RunWith(JUnit4.class)
|
||||
public class NettyChannelBuilderTest {
|
||||
|
||||
@SuppressWarnings("deprecation") // https://github.com/grpc/grpc-java/issues/7467
|
||||
@Rule public final ExpectedException thrown = ExpectedException.none();
|
||||
private final SslContext noSslContext = null;
|
||||
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ import org.junit.runners.JUnit4;
|
|||
@RunWith(JUnit4.class)
|
||||
public class NettyServerBuilderTest {
|
||||
|
||||
@SuppressWarnings("deprecation") // https://github.com/grpc/grpc-java/issues/7467
|
||||
@Rule public final ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
private NettyServerBuilder builder = NettyServerBuilder.forPort(8080);
|
||||
|
|
|
|||
|
|
@ -122,6 +122,7 @@ public class ProtocolNegotiatorsTest {
|
|||
|
||||
private static final int TIMEOUT_SECONDS = 60;
|
||||
@Rule public final TestRule globalTimeout = new DisableOnDebug(Timeout.seconds(TIMEOUT_SECONDS));
|
||||
@SuppressWarnings("deprecation") // https://github.com/grpc/grpc-java/issues/7467
|
||||
@Rule public final ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
private final EventLoopGroup group = new DefaultEventLoop();
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ import org.junit.runners.JUnit4;
|
|||
@RunWith(JUnit4.class)
|
||||
public class OkHttpChannelBuilderTest {
|
||||
|
||||
@SuppressWarnings("deprecation") // https://github.com/grpc/grpc-java/issues/7467
|
||||
@Rule public final ExpectedException thrown = ExpectedException.none();
|
||||
@Rule public final GrpcCleanupRule grpcCleanupRule = new GrpcCleanupRule();
|
||||
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ import org.mockito.ArgumentMatchers;
|
|||
*/
|
||||
@RunWith(JUnit4.class)
|
||||
public class OkHttpProtocolNegotiatorTest {
|
||||
@SuppressWarnings("deprecation") // https://github.com/grpc/grpc-java/issues/7467
|
||||
@Rule public final ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
private final SSLSocket sock = mock(SSLSocket.class);
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ import org.junit.runners.JUnit4;
|
|||
@RunWith(JUnit4.class)
|
||||
public class UtilsTest {
|
||||
|
||||
@SuppressWarnings("deprecation") // https://github.com/grpc/grpc-java/issues/7467
|
||||
@Rule
|
||||
public final ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ import org.junit.runners.JUnit4;
|
|||
@RunWith(JUnit4.class)
|
||||
public class ProtoLiteUtilsTest {
|
||||
|
||||
@SuppressWarnings("deprecation") // https://github.com/grpc/grpc-java/issues/7467
|
||||
@Rule public final ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
private Marshaller<Type> marshaller = ProtoLiteUtils.marshaller(Type.getDefaultInstance());
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ import org.mockito.InOrder;
|
|||
public class GrpcCleanupRuleTest {
|
||||
public static final FakeClock fakeClock = new FakeClock();
|
||||
|
||||
@SuppressWarnings("deprecation") // https://github.com/grpc/grpc-java/issues/7467
|
||||
@Rule
|
||||
public ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ import org.junit.runners.JUnit4;
|
|||
@RunWith(JUnit4.class)
|
||||
public class BootstrapperTest {
|
||||
|
||||
@SuppressWarnings("deprecation") // https://github.com/grpc/grpc-java/issues/7467
|
||||
@Rule public ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ import org.junit.runners.JUnit4;
|
|||
/** Tests for {@link PriorityLoadBalancerProvider}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class PriorityLoadBalancerProviderTest {
|
||||
@SuppressWarnings("deprecation") // https://github.com/grpc/grpc-java/issues/7467
|
||||
@Rule public final ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
@SuppressWarnings("ExpectedExceptionChecker")
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ import org.mockito.junit.MockitoRule;
|
|||
*/
|
||||
@RunWith(JUnit4.class)
|
||||
public class WeightedRandomPickerTest {
|
||||
@SuppressWarnings("deprecation") // https://github.com/grpc/grpc-java/issues/7467
|
||||
@Rule
|
||||
public final ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
|
|
|
|||
|
|
@ -176,6 +176,7 @@ public class XdsClientImplTest {
|
|||
|
||||
@Rule
|
||||
public final GrpcCleanupRule cleanupRule = new GrpcCleanupRule();
|
||||
@SuppressWarnings("deprecation") // https://github.com/grpc/grpc-java/issues/7467
|
||||
@Rule
|
||||
public ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ import org.junit.runners.JUnit4;
|
|||
*/
|
||||
@RunWith(JUnit4.class)
|
||||
public class XdsClientTest {
|
||||
@SuppressWarnings("deprecation") // https://github.com/grpc/grpc-java/issues/7467
|
||||
@Rule
|
||||
public final ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ import org.mockito.junit.MockitoRule;
|
|||
/** Unit tests for constructor of CEL-based Authorization Engine. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class AuthzEngineTest {
|
||||
@SuppressWarnings("deprecation") // https://github.com/grpc/grpc-java/issues/7467
|
||||
@Rule
|
||||
public final ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue