Skip to content

Commit

Permalink
all: upgrade to JUnit 4.12
Browse files Browse the repository at this point in the history
  • Loading branch information
carl-mastrangelo authored Oct 5, 2017
1 parent 765a40c commit 5e36a8d
Show file tree
Hide file tree
Showing 16 changed files with 85 additions and 53 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ subprojects {
netty_tcnative: 'io.netty:netty-tcnative-boringssl-static:2.0.6.Final',

// Test dependencies.
junit: 'junit:junit:4.11',
junit: 'junit:junit:4.12',
mockito: 'org.mockito:mockito-core:1.9.5',
truth: 'com.google.truth:truth:0.28',

Expand Down
9 changes: 7 additions & 2 deletions core/src/test/java/io/grpc/internal/DnsNameResolverTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@
import org.junit.After;
import org.junit.Assume;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.Timeout;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.mockito.ArgumentCaptor;
Expand All @@ -62,6 +64,9 @@
/** Unit tests for {@link DnsNameResolver}. */
@RunWith(JUnit4.class)
public class DnsNameResolverTest {

@Rule public final Timeout globalTimeout = Timeout.seconds(10);

private static final int DEFAULT_PORT = 887;
private static final Attributes NAME_RESOLVER_PARAMS =
Attributes.newBuilder().set(NameResolver.Factory.PARAMS_DEFAULT_PORT, DEFAULT_PORT).build();
Expand Down Expand Up @@ -270,7 +275,7 @@ public void shutdownCancelsScheduledRetry() throws Exception {
verifyNoMoreInteractions(mockListener);
}

@Test(timeout = 10000)
@Test
public void jdkResolverWorks() throws Exception {
DnsNameResolver.DelegateResolver resolver = new DnsNameResolver.JdkResolver();

Expand All @@ -280,7 +285,7 @@ public void jdkResolverWorks() throws Exception {
assertThat(results.txtRecords).isNotNull();
}

@Test(timeout = 10000)
@Test
public void jndiResolverWorks() throws Exception {
Assume.assumeTrue(DnsNameResolver.jndiAvailable());
DnsNameResolver.DelegateResolver resolver = new DnsNameResolver.JndiResolver();
Expand Down
4 changes: 2 additions & 2 deletions documentation/monitoring-service-tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ monitoring service, we need to make the following changes:
+ compile "io.grpc:grpc-services:${grpcVersion}"
compile "io.grpc:grpc-stub:${grpcVersion}"

testCompile "junit:junit:4.11"
testCompile "junit:junit:4.12"
--- a/examples/src/main/java/io/grpc/examples/helloworld/HelloWorldServer.java
+++ b/examples/src/main/java/io/grpc/examples/helloworld/HelloWorldServer.java
@@ -33,6 +33,8 @@ package io.grpc.examples.helloworld;
Expand Down Expand Up @@ -113,7 +113,7 @@ Unix domain socket (`/tmp/grpc_monitoring.sock`) alongside the
+ // This must match the version of netty used by grpcVersion
+ compile "io.netty:netty-transport-native-epoll:4.1.8.Final:linux-x86_64"

testCompile "junit:junit:4.11"
testCompile "junit:junit:4.12"
testCompile "org.mockito:mockito-core:1.9.5"
--- a/examples/src/main/java/io/grpc/examples/helloworld/HelloWorldClient.java
+++ b/examples/src/main/java/io/grpc/examples/helloworld/HelloWorldClient.java
Expand Down
2 changes: 1 addition & 1 deletion documentation/server-reflection-tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ need to make the following changes:
+ compile "io.grpc:grpc-services:${grpcVersion}"
compile "io.grpc:grpc-stub:${grpcVersion}"

testCompile "junit:junit:4.11"
testCompile "junit:junit:4.12"
--- a/examples/src/main/java/io/grpc/examples/helloworld/HelloWorldServer.java
+++ b/examples/src/main/java/io/grpc/examples/helloworld/HelloWorldServer.java
@@ -33,6 +33,7 @@ package io.grpc.examples.helloworld;
Expand Down
2 changes: 1 addition & 1 deletion examples/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ dependencies {
compile "io.grpc:grpc-stub:${grpcVersion}"

testCompile "io.grpc:grpc-testing:${grpcVersion}"
testCompile "junit:junit:4.11"
testCompile "junit:junit:4.12"
testCompile "org.mockito:mockito-core:1.9.5"
}

Expand Down
2 changes: 1 addition & 1 deletion examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@
import org.junit.Assert;
import org.junit.Assume;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.Timeout;
import org.mockito.ArgumentCaptor;
import org.mockito.Mockito;
import org.mockito.verification.VerificationMode;
Expand All @@ -121,6 +123,9 @@
* <p> New tests should avoid using Mockito to support running on AppEngine.</p>
*/
public abstract class AbstractInteropTest {

@Rule public final Timeout globalTimeout = Timeout.seconds(30);

/** Must be at least {@link #unaryPayloadLength()}, plus some to account for encoding overhead. */
public static final int MAX_MESSAGE_SIZE = 16 * 1024 * 1024;
public static final Metadata.Key<Messages.SimpleContext> METADATA_KEY =
Expand Down Expand Up @@ -266,7 +271,7 @@ protected boolean metricsExpected() {
return true;
}

@Test(timeout = 10000)
@Test
public void emptyUnary() throws Exception {
assertEquals(EMPTY, blockingStub.emptyCall(EMPTY));
}
Expand Down Expand Up @@ -309,7 +314,7 @@ public void cacheableUnary() {
assertNotEquals(response1, response3);
}

@Test(timeout = 10000)
@Test
public void largeUnary() throws Exception {
assumeEnoughMemory();
final SimpleRequest request = SimpleRequest.newBuilder()
Expand Down Expand Up @@ -393,7 +398,7 @@ public void clientCompressedUnary() throws Exception {
* compliant server, this test will exercise the code path for receiving a compressed response but
* cannot itself verify that the response was compressed.
*/
@Test(timeout = 10000)
@Test
public void serverCompressedUnary() throws Exception {
assumeEnoughMemory();
final SimpleRequest responseShouldBeCompressed =
Expand Down Expand Up @@ -432,7 +437,7 @@ public void serverCompressedUnary() throws Exception {
}
}

@Test(timeout = 10000)
@Test
public void serverStreaming() throws Exception {
final StreamingOutputCallRequest request = StreamingOutputCallRequest.newBuilder()
.setResponseType(PayloadType.COMPRESSABLE)
Expand Down Expand Up @@ -474,7 +479,7 @@ public void serverStreaming() throws Exception {
assertEquals(goldenResponses, recorder.getValues());
}

@Test(timeout = 10000)
@Test
public void clientStreaming() throws Exception {
final List<StreamingInputCallRequest> requests = Arrays.asList(
StreamingInputCallRequest.newBuilder()
Expand Down Expand Up @@ -589,7 +594,7 @@ public void serverCompressedStreaming() throws Exception {
assertEquals(goldenResponses, recorder.getValues());
}

@Test(timeout = 10000)
@Test
public void pingPong() throws Exception {
final List<StreamingOutputCallRequest> requests = Arrays.asList(
StreamingOutputCallRequest.newBuilder()
Expand Down Expand Up @@ -666,7 +671,7 @@ public void onCompleted() {
assertEquals("Completed", queue.poll(operationTimeoutMillis(), TimeUnit.MILLISECONDS));
}

@Test(timeout = 10000)
@Test
public void emptyStream() throws Exception {
StreamRecorder<StreamingOutputCallResponse> responseObserver = StreamRecorder.create();
StreamObserver<StreamingOutputCallRequest> requestObserver
Expand All @@ -675,7 +680,7 @@ public void emptyStream() throws Exception {
responseObserver.awaitCompletion(operationTimeoutMillis(), TimeUnit.MILLISECONDS);
}

@Test(timeout = 10000)
@Test
public void cancelAfterBegin() throws Exception {
StreamRecorder<StreamingInputCallResponse> responseObserver = StreamRecorder.create();
StreamObserver<StreamingInputCallRequest> requestObserver =
Expand All @@ -698,7 +703,7 @@ public void cancelAfterBegin() throws Exception {
}
}

@Test(timeout = 10000)
@Test
public void cancelAfterFirstResponse() throws Exception {
final StreamingOutputCallRequest request = StreamingOutputCallRequest.newBuilder()
.addResponseParameters(ResponseParameters.newBuilder()
Expand Down Expand Up @@ -728,7 +733,7 @@ public void cancelAfterFirstResponse() throws Exception {
}
}

@Test(timeout = 10000)
@Test
public void fullDuplexCallShouldSucceed() throws Exception {
// Build the request.
List<Integer> responseSizes = Arrays.asList(50, 100, 150, 200);
Expand Down Expand Up @@ -769,7 +774,7 @@ public void fullDuplexCallShouldSucceed() throws Exception {
}
}

@Test(timeout = 10000)
@Test
public void halfDuplexCallShouldSucceed() throws Exception {
// Build the request.
List<Integer> responseSizes = Arrays.asList(50, 100, 150, 200);
Expand Down Expand Up @@ -804,7 +809,7 @@ public void halfDuplexCallShouldSucceed() throws Exception {
}
}

@Test(timeout = 10000)
@Test
public void serverStreamingShouldBeFlowControlled() throws Exception {
final StreamingOutputCallRequest request = StreamingOutputCallRequest.newBuilder()
.setResponseType(COMPRESSABLE)
Expand Down Expand Up @@ -863,7 +868,7 @@ public void onClose(Status status, Metadata trailers) {
assertEquals(Status.OK, queue.poll(operationTimeoutMillis(), TimeUnit.MILLISECONDS));
}

@Test(timeout = 30000)
@Test
public void veryLargeRequest() throws Exception {
assumeEnoughMemory();
final SimpleRequest request = SimpleRequest.newBuilder()
Expand All @@ -882,7 +887,7 @@ public void veryLargeRequest() throws Exception {
assertEquals(goldenResponse, blockingStub.unaryCall(request));
}

@Test(timeout = 30000)
@Test
public void veryLargeResponse() throws Exception {
assumeEnoughMemory();
final SimpleRequest request = SimpleRequest.newBuilder()
Expand All @@ -898,7 +903,7 @@ public void veryLargeResponse() throws Exception {
assertEquals(goldenResponse, blockingStub.unaryCall(request));
}

@Test(timeout = 10000)
@Test
public void exchangeMetadataUnaryCall() throws Exception {
TestServiceGrpc.TestServiceBlockingStub stub = blockingStub;

Expand All @@ -921,7 +926,7 @@ public void exchangeMetadataUnaryCall() throws Exception {
Assert.assertEquals(contextValue, trailersCapture.get().get(METADATA_KEY));
}

@Test(timeout = 10000)
@Test
public void exchangeMetadataStreamingCall() throws Exception {
TestServiceGrpc.TestServiceStub stub = asyncStub;

Expand Down Expand Up @@ -968,7 +973,7 @@ public void exchangeMetadataStreamingCall() throws Exception {
Assert.assertEquals(contextValue, trailersCapture.get().get(METADATA_KEY));
}

@Test(timeout = 10000)
@Test
public void sendsTimeoutHeader() {
Assume.assumeTrue("can not capture server side request headers", server != null);
long configuredTimeoutMinutes = 100;
Expand Down Expand Up @@ -996,7 +1001,7 @@ public void deadlineNotExceeded() {
.build()).next();
}

@Test(timeout = 25000)
@Test
public void deadlineExceeded() throws Exception {
// warm up the channel and JVM
blockingStub.emptyCall(Empty.getDefaultInstance());
Expand Down Expand Up @@ -1024,7 +1029,7 @@ public void deadlineExceeded() throws Exception {
}
}

@Test(timeout = 10000)
@Test
public void deadlineExceededServerStreaming() throws Exception {
// warm up the channel and JVM
blockingStub.emptyCall(Empty.getDefaultInstance());
Expand Down Expand Up @@ -1057,7 +1062,7 @@ public void deadlineExceededServerStreaming() throws Exception {
}
}

@Test(timeout = 10000)
@Test
public void deadlineInPast() throws Exception {
// Test once with idle channel and once with active channel
try {
Expand Down Expand Up @@ -1099,7 +1104,7 @@ public void deadlineInPast() throws Exception {
}
}

@Test(timeout = 10000)
@Test
public void maxInboundSize_exact() {
StreamingOutputCallRequest request = StreamingOutputCallRequest.newBuilder()
.addResponseParameters(ResponseParameters.newBuilder().setSize(1))
Expand All @@ -1112,7 +1117,7 @@ public void maxInboundSize_exact() {
stub.streamingOutputCall(request).next();
}

@Test(timeout = 10000)
@Test
public void maxInboundSize_tooBig() {
StreamingOutputCallRequest request = StreamingOutputCallRequest.newBuilder()
.addResponseParameters(ResponseParameters.newBuilder().setSize(1))
Expand All @@ -1132,7 +1137,7 @@ public void maxInboundSize_tooBig() {
}
}

@Test(timeout = 10000)
@Test
public void maxOutboundSize_exact() {
// warm up the channel and JVM
blockingStub.emptyCall(Empty.getDefaultInstance());
Expand All @@ -1147,7 +1152,7 @@ public void maxOutboundSize_exact() {
stub.streamingOutputCall(request).next();
}

@Test(timeout = 10000)
@Test
public void maxOutboundSize_tooBig() {
// warm up the channel and JVM
blockingStub.emptyCall(Empty.getDefaultInstance());
Expand All @@ -1172,7 +1177,7 @@ protected int unaryPayloadLength() {
return 10485760;
}

@Test(timeout = 10000)
@Test
public void gracefulShutdown() throws Exception {
final List<StreamingOutputCallRequest> requests = Arrays.asList(
StreamingOutputCallRequest.newBuilder()
Expand Down Expand Up @@ -1252,7 +1257,7 @@ public void onCompleted() {
assertFalse(errorSeen.isDone());
}

@Test(timeout = 10000)
@Test
public void customMetadata() throws Exception {
final int responseSize = 314159;
final int requestSize = 271828;
Expand Down Expand Up @@ -1331,7 +1336,7 @@ public void customMetadata() throws Exception {
}
}

@Test(timeout = 10000)
@Test
public void statusCodeAndMessage() throws Exception {
int errorCode = 2;
String errorMessage = "test status message";
Expand Down Expand Up @@ -1378,7 +1383,7 @@ public void statusCodeAndMessage() throws Exception {
}

/** Sends an rpc to an unimplemented method within TestService. */
@Test(timeout = 10000)
@Test
public void unimplementedMethod() {
try {
blockingStub.unimplementedCall(Empty.getDefaultInstance());
Expand All @@ -1394,7 +1399,7 @@ public void unimplementedMethod() {
}

/** Sends an rpc to an unimplemented service on the server. */
@Test(timeout = 10000)
@Test
public void unimplementedService() {
UnimplementedServiceGrpc.UnimplementedServiceBlockingStub stub =
UnimplementedServiceGrpc.newBlockingStub(channel).withInterceptors(tracerSetupInterceptor);
Expand All @@ -1413,7 +1418,7 @@ public void unimplementedService() {

/** Start a fullDuplexCall which the server will not respond, and verify the deadline expires. */
@SuppressWarnings("MissingFail")
@Test(timeout = 10000)
@Test
public void timeoutOnSleepingServer() throws Exception {
TestServiceGrpc.TestServiceStub stub =
asyncStub.withDeadlineAfter(1, TimeUnit.MILLISECONDS);
Expand Down
Loading

0 comments on commit 5e36a8d

Please sign in to comment.