mirror of https://github.com/grpc/grpc-java.git
all: upgrade to JUnit 4.12
This commit is contained in:
parent
765a40c7e6
commit
5e36a8deb5
|
|
@ -210,7 +210,7 @@ subprojects {
|
||||||
netty_tcnative: 'io.netty:netty-tcnative-boringssl-static:2.0.6.Final',
|
netty_tcnative: 'io.netty:netty-tcnative-boringssl-static:2.0.6.Final',
|
||||||
|
|
||||||
// Test dependencies.
|
// Test dependencies.
|
||||||
junit: 'junit:junit:4.11',
|
junit: 'junit:junit:4.12',
|
||||||
mockito: 'org.mockito:mockito-core:1.9.5',
|
mockito: 'org.mockito:mockito-core:1.9.5',
|
||||||
truth: 'com.google.truth:truth:0.28',
|
truth: 'com.google.truth:truth:0.28',
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,9 @@ import java.util.concurrent.TimeUnit;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Assume;
|
import org.junit.Assume;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.rules.Timeout;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.JUnit4;
|
import org.junit.runners.JUnit4;
|
||||||
import org.mockito.ArgumentCaptor;
|
import org.mockito.ArgumentCaptor;
|
||||||
|
|
@ -62,6 +64,9 @@ import org.mockito.MockitoAnnotations;
|
||||||
/** Unit tests for {@link DnsNameResolver}. */
|
/** Unit tests for {@link DnsNameResolver}. */
|
||||||
@RunWith(JUnit4.class)
|
@RunWith(JUnit4.class)
|
||||||
public class DnsNameResolverTest {
|
public class DnsNameResolverTest {
|
||||||
|
|
||||||
|
@Rule public final Timeout globalTimeout = Timeout.seconds(10);
|
||||||
|
|
||||||
private static final int DEFAULT_PORT = 887;
|
private static final int DEFAULT_PORT = 887;
|
||||||
private static final Attributes NAME_RESOLVER_PARAMS =
|
private static final Attributes NAME_RESOLVER_PARAMS =
|
||||||
Attributes.newBuilder().set(NameResolver.Factory.PARAMS_DEFAULT_PORT, DEFAULT_PORT).build();
|
Attributes.newBuilder().set(NameResolver.Factory.PARAMS_DEFAULT_PORT, DEFAULT_PORT).build();
|
||||||
|
|
@ -270,7 +275,7 @@ public class DnsNameResolverTest {
|
||||||
verifyNoMoreInteractions(mockListener);
|
verifyNoMoreInteractions(mockListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(timeout = 10000)
|
@Test
|
||||||
public void jdkResolverWorks() throws Exception {
|
public void jdkResolverWorks() throws Exception {
|
||||||
DnsNameResolver.DelegateResolver resolver = new DnsNameResolver.JdkResolver();
|
DnsNameResolver.DelegateResolver resolver = new DnsNameResolver.JdkResolver();
|
||||||
|
|
||||||
|
|
@ -280,7 +285,7 @@ public class DnsNameResolverTest {
|
||||||
assertThat(results.txtRecords).isNotNull();
|
assertThat(results.txtRecords).isNotNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(timeout = 10000)
|
@Test
|
||||||
public void jndiResolverWorks() throws Exception {
|
public void jndiResolverWorks() throws Exception {
|
||||||
Assume.assumeTrue(DnsNameResolver.jndiAvailable());
|
Assume.assumeTrue(DnsNameResolver.jndiAvailable());
|
||||||
DnsNameResolver.DelegateResolver resolver = new DnsNameResolver.JndiResolver();
|
DnsNameResolver.DelegateResolver resolver = new DnsNameResolver.JndiResolver();
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ monitoring service, we need to make the following changes:
|
||||||
+ compile "io.grpc:grpc-services:${grpcVersion}"
|
+ compile "io.grpc:grpc-services:${grpcVersion}"
|
||||||
compile "io.grpc:grpc-stub:${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
|
--- a/examples/src/main/java/io/grpc/examples/helloworld/HelloWorldServer.java
|
||||||
+++ b/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;
|
@@ -33,6 +33,8 @@ package io.grpc.examples.helloworld;
|
||||||
|
|
@ -113,7 +113,7 @@ Unix domain socket (`/tmp/grpc_monitoring.sock`) alongside the
|
||||||
+ // This must match the version of netty used by grpcVersion
|
+ // This must match the version of netty used by grpcVersion
|
||||||
+ compile "io.netty:netty-transport-native-epoll:4.1.8.Final:linux-x86_64"
|
+ 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"
|
testCompile "org.mockito:mockito-core:1.9.5"
|
||||||
--- a/examples/src/main/java/io/grpc/examples/helloworld/HelloWorldClient.java
|
--- a/examples/src/main/java/io/grpc/examples/helloworld/HelloWorldClient.java
|
||||||
+++ b/examples/src/main/java/io/grpc/examples/helloworld/HelloWorldClient.java
|
+++ b/examples/src/main/java/io/grpc/examples/helloworld/HelloWorldClient.java
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ need to make the following changes:
|
||||||
+ compile "io.grpc:grpc-services:${grpcVersion}"
|
+ compile "io.grpc:grpc-services:${grpcVersion}"
|
||||||
compile "io.grpc:grpc-stub:${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
|
--- a/examples/src/main/java/io/grpc/examples/helloworld/HelloWorldServer.java
|
||||||
+++ b/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;
|
@@ -33,6 +33,7 @@ package io.grpc.examples.helloworld;
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ dependencies {
|
||||||
compile "io.grpc:grpc-stub:${grpcVersion}"
|
compile "io.grpc:grpc-stub:${grpcVersion}"
|
||||||
|
|
||||||
testCompile "io.grpc:grpc-testing:${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"
|
testCompile "org.mockito:mockito-core:1.9.5"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
<version>4.11</version>
|
<version>4.12</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
||||||
|
|
@ -110,7 +110,9 @@ import org.junit.After;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Assume;
|
import org.junit.Assume;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.rules.Timeout;
|
||||||
import org.mockito.ArgumentCaptor;
|
import org.mockito.ArgumentCaptor;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
import org.mockito.verification.VerificationMode;
|
import org.mockito.verification.VerificationMode;
|
||||||
|
|
@ -121,6 +123,9 @@ import org.mockito.verification.VerificationMode;
|
||||||
* <p> New tests should avoid using Mockito to support running on AppEngine.</p>
|
* <p> New tests should avoid using Mockito to support running on AppEngine.</p>
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractInteropTest {
|
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. */
|
/** 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 int MAX_MESSAGE_SIZE = 16 * 1024 * 1024;
|
||||||
public static final Metadata.Key<Messages.SimpleContext> METADATA_KEY =
|
public static final Metadata.Key<Messages.SimpleContext> METADATA_KEY =
|
||||||
|
|
@ -266,7 +271,7 @@ public abstract class AbstractInteropTest {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(timeout = 10000)
|
@Test
|
||||||
public void emptyUnary() throws Exception {
|
public void emptyUnary() throws Exception {
|
||||||
assertEquals(EMPTY, blockingStub.emptyCall(EMPTY));
|
assertEquals(EMPTY, blockingStub.emptyCall(EMPTY));
|
||||||
}
|
}
|
||||||
|
|
@ -309,7 +314,7 @@ public abstract class AbstractInteropTest {
|
||||||
assertNotEquals(response1, response3);
|
assertNotEquals(response1, response3);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(timeout = 10000)
|
@Test
|
||||||
public void largeUnary() throws Exception {
|
public void largeUnary() throws Exception {
|
||||||
assumeEnoughMemory();
|
assumeEnoughMemory();
|
||||||
final SimpleRequest request = SimpleRequest.newBuilder()
|
final SimpleRequest request = SimpleRequest.newBuilder()
|
||||||
|
|
@ -393,7 +398,7 @@ public abstract class AbstractInteropTest {
|
||||||
* compliant server, this test will exercise the code path for receiving a compressed response but
|
* compliant server, this test will exercise the code path for receiving a compressed response but
|
||||||
* cannot itself verify that the response was compressed.
|
* cannot itself verify that the response was compressed.
|
||||||
*/
|
*/
|
||||||
@Test(timeout = 10000)
|
@Test
|
||||||
public void serverCompressedUnary() throws Exception {
|
public void serverCompressedUnary() throws Exception {
|
||||||
assumeEnoughMemory();
|
assumeEnoughMemory();
|
||||||
final SimpleRequest responseShouldBeCompressed =
|
final SimpleRequest responseShouldBeCompressed =
|
||||||
|
|
@ -432,7 +437,7 @@ public abstract class AbstractInteropTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(timeout = 10000)
|
@Test
|
||||||
public void serverStreaming() throws Exception {
|
public void serverStreaming() throws Exception {
|
||||||
final StreamingOutputCallRequest request = StreamingOutputCallRequest.newBuilder()
|
final StreamingOutputCallRequest request = StreamingOutputCallRequest.newBuilder()
|
||||||
.setResponseType(PayloadType.COMPRESSABLE)
|
.setResponseType(PayloadType.COMPRESSABLE)
|
||||||
|
|
@ -474,7 +479,7 @@ public abstract class AbstractInteropTest {
|
||||||
assertEquals(goldenResponses, recorder.getValues());
|
assertEquals(goldenResponses, recorder.getValues());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(timeout = 10000)
|
@Test
|
||||||
public void clientStreaming() throws Exception {
|
public void clientStreaming() throws Exception {
|
||||||
final List<StreamingInputCallRequest> requests = Arrays.asList(
|
final List<StreamingInputCallRequest> requests = Arrays.asList(
|
||||||
StreamingInputCallRequest.newBuilder()
|
StreamingInputCallRequest.newBuilder()
|
||||||
|
|
@ -589,7 +594,7 @@ public abstract class AbstractInteropTest {
|
||||||
assertEquals(goldenResponses, recorder.getValues());
|
assertEquals(goldenResponses, recorder.getValues());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(timeout = 10000)
|
@Test
|
||||||
public void pingPong() throws Exception {
|
public void pingPong() throws Exception {
|
||||||
final List<StreamingOutputCallRequest> requests = Arrays.asList(
|
final List<StreamingOutputCallRequest> requests = Arrays.asList(
|
||||||
StreamingOutputCallRequest.newBuilder()
|
StreamingOutputCallRequest.newBuilder()
|
||||||
|
|
@ -666,7 +671,7 @@ public abstract class AbstractInteropTest {
|
||||||
assertEquals("Completed", queue.poll(operationTimeoutMillis(), TimeUnit.MILLISECONDS));
|
assertEquals("Completed", queue.poll(operationTimeoutMillis(), TimeUnit.MILLISECONDS));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(timeout = 10000)
|
@Test
|
||||||
public void emptyStream() throws Exception {
|
public void emptyStream() throws Exception {
|
||||||
StreamRecorder<StreamingOutputCallResponse> responseObserver = StreamRecorder.create();
|
StreamRecorder<StreamingOutputCallResponse> responseObserver = StreamRecorder.create();
|
||||||
StreamObserver<StreamingOutputCallRequest> requestObserver
|
StreamObserver<StreamingOutputCallRequest> requestObserver
|
||||||
|
|
@ -675,7 +680,7 @@ public abstract class AbstractInteropTest {
|
||||||
responseObserver.awaitCompletion(operationTimeoutMillis(), TimeUnit.MILLISECONDS);
|
responseObserver.awaitCompletion(operationTimeoutMillis(), TimeUnit.MILLISECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(timeout = 10000)
|
@Test
|
||||||
public void cancelAfterBegin() throws Exception {
|
public void cancelAfterBegin() throws Exception {
|
||||||
StreamRecorder<StreamingInputCallResponse> responseObserver = StreamRecorder.create();
|
StreamRecorder<StreamingInputCallResponse> responseObserver = StreamRecorder.create();
|
||||||
StreamObserver<StreamingInputCallRequest> requestObserver =
|
StreamObserver<StreamingInputCallRequest> requestObserver =
|
||||||
|
|
@ -698,7 +703,7 @@ public abstract class AbstractInteropTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(timeout = 10000)
|
@Test
|
||||||
public void cancelAfterFirstResponse() throws Exception {
|
public void cancelAfterFirstResponse() throws Exception {
|
||||||
final StreamingOutputCallRequest request = StreamingOutputCallRequest.newBuilder()
|
final StreamingOutputCallRequest request = StreamingOutputCallRequest.newBuilder()
|
||||||
.addResponseParameters(ResponseParameters.newBuilder()
|
.addResponseParameters(ResponseParameters.newBuilder()
|
||||||
|
|
@ -728,7 +733,7 @@ public abstract class AbstractInteropTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(timeout = 10000)
|
@Test
|
||||||
public void fullDuplexCallShouldSucceed() throws Exception {
|
public void fullDuplexCallShouldSucceed() throws Exception {
|
||||||
// Build the request.
|
// Build the request.
|
||||||
List<Integer> responseSizes = Arrays.asList(50, 100, 150, 200);
|
List<Integer> responseSizes = Arrays.asList(50, 100, 150, 200);
|
||||||
|
|
@ -769,7 +774,7 @@ public abstract class AbstractInteropTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(timeout = 10000)
|
@Test
|
||||||
public void halfDuplexCallShouldSucceed() throws Exception {
|
public void halfDuplexCallShouldSucceed() throws Exception {
|
||||||
// Build the request.
|
// Build the request.
|
||||||
List<Integer> responseSizes = Arrays.asList(50, 100, 150, 200);
|
List<Integer> responseSizes = Arrays.asList(50, 100, 150, 200);
|
||||||
|
|
@ -804,7 +809,7 @@ public abstract class AbstractInteropTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(timeout = 10000)
|
@Test
|
||||||
public void serverStreamingShouldBeFlowControlled() throws Exception {
|
public void serverStreamingShouldBeFlowControlled() throws Exception {
|
||||||
final StreamingOutputCallRequest request = StreamingOutputCallRequest.newBuilder()
|
final StreamingOutputCallRequest request = StreamingOutputCallRequest.newBuilder()
|
||||||
.setResponseType(COMPRESSABLE)
|
.setResponseType(COMPRESSABLE)
|
||||||
|
|
@ -863,7 +868,7 @@ public abstract class AbstractInteropTest {
|
||||||
assertEquals(Status.OK, queue.poll(operationTimeoutMillis(), TimeUnit.MILLISECONDS));
|
assertEquals(Status.OK, queue.poll(operationTimeoutMillis(), TimeUnit.MILLISECONDS));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(timeout = 30000)
|
@Test
|
||||||
public void veryLargeRequest() throws Exception {
|
public void veryLargeRequest() throws Exception {
|
||||||
assumeEnoughMemory();
|
assumeEnoughMemory();
|
||||||
final SimpleRequest request = SimpleRequest.newBuilder()
|
final SimpleRequest request = SimpleRequest.newBuilder()
|
||||||
|
|
@ -882,7 +887,7 @@ public abstract class AbstractInteropTest {
|
||||||
assertEquals(goldenResponse, blockingStub.unaryCall(request));
|
assertEquals(goldenResponse, blockingStub.unaryCall(request));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(timeout = 30000)
|
@Test
|
||||||
public void veryLargeResponse() throws Exception {
|
public void veryLargeResponse() throws Exception {
|
||||||
assumeEnoughMemory();
|
assumeEnoughMemory();
|
||||||
final SimpleRequest request = SimpleRequest.newBuilder()
|
final SimpleRequest request = SimpleRequest.newBuilder()
|
||||||
|
|
@ -898,7 +903,7 @@ public abstract class AbstractInteropTest {
|
||||||
assertEquals(goldenResponse, blockingStub.unaryCall(request));
|
assertEquals(goldenResponse, blockingStub.unaryCall(request));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(timeout = 10000)
|
@Test
|
||||||
public void exchangeMetadataUnaryCall() throws Exception {
|
public void exchangeMetadataUnaryCall() throws Exception {
|
||||||
TestServiceGrpc.TestServiceBlockingStub stub = blockingStub;
|
TestServiceGrpc.TestServiceBlockingStub stub = blockingStub;
|
||||||
|
|
||||||
|
|
@ -921,7 +926,7 @@ public abstract class AbstractInteropTest {
|
||||||
Assert.assertEquals(contextValue, trailersCapture.get().get(METADATA_KEY));
|
Assert.assertEquals(contextValue, trailersCapture.get().get(METADATA_KEY));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(timeout = 10000)
|
@Test
|
||||||
public void exchangeMetadataStreamingCall() throws Exception {
|
public void exchangeMetadataStreamingCall() throws Exception {
|
||||||
TestServiceGrpc.TestServiceStub stub = asyncStub;
|
TestServiceGrpc.TestServiceStub stub = asyncStub;
|
||||||
|
|
||||||
|
|
@ -968,7 +973,7 @@ public abstract class AbstractInteropTest {
|
||||||
Assert.assertEquals(contextValue, trailersCapture.get().get(METADATA_KEY));
|
Assert.assertEquals(contextValue, trailersCapture.get().get(METADATA_KEY));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(timeout = 10000)
|
@Test
|
||||||
public void sendsTimeoutHeader() {
|
public void sendsTimeoutHeader() {
|
||||||
Assume.assumeTrue("can not capture server side request headers", server != null);
|
Assume.assumeTrue("can not capture server side request headers", server != null);
|
||||||
long configuredTimeoutMinutes = 100;
|
long configuredTimeoutMinutes = 100;
|
||||||
|
|
@ -996,7 +1001,7 @@ public abstract class AbstractInteropTest {
|
||||||
.build()).next();
|
.build()).next();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(timeout = 25000)
|
@Test
|
||||||
public void deadlineExceeded() throws Exception {
|
public void deadlineExceeded() throws Exception {
|
||||||
// warm up the channel and JVM
|
// warm up the channel and JVM
|
||||||
blockingStub.emptyCall(Empty.getDefaultInstance());
|
blockingStub.emptyCall(Empty.getDefaultInstance());
|
||||||
|
|
@ -1024,7 +1029,7 @@ public abstract class AbstractInteropTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(timeout = 10000)
|
@Test
|
||||||
public void deadlineExceededServerStreaming() throws Exception {
|
public void deadlineExceededServerStreaming() throws Exception {
|
||||||
// warm up the channel and JVM
|
// warm up the channel and JVM
|
||||||
blockingStub.emptyCall(Empty.getDefaultInstance());
|
blockingStub.emptyCall(Empty.getDefaultInstance());
|
||||||
|
|
@ -1057,7 +1062,7 @@ public abstract class AbstractInteropTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(timeout = 10000)
|
@Test
|
||||||
public void deadlineInPast() throws Exception {
|
public void deadlineInPast() throws Exception {
|
||||||
// Test once with idle channel and once with active channel
|
// Test once with idle channel and once with active channel
|
||||||
try {
|
try {
|
||||||
|
|
@ -1099,7 +1104,7 @@ public abstract class AbstractInteropTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(timeout = 10000)
|
@Test
|
||||||
public void maxInboundSize_exact() {
|
public void maxInboundSize_exact() {
|
||||||
StreamingOutputCallRequest request = StreamingOutputCallRequest.newBuilder()
|
StreamingOutputCallRequest request = StreamingOutputCallRequest.newBuilder()
|
||||||
.addResponseParameters(ResponseParameters.newBuilder().setSize(1))
|
.addResponseParameters(ResponseParameters.newBuilder().setSize(1))
|
||||||
|
|
@ -1112,7 +1117,7 @@ public abstract class AbstractInteropTest {
|
||||||
stub.streamingOutputCall(request).next();
|
stub.streamingOutputCall(request).next();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(timeout = 10000)
|
@Test
|
||||||
public void maxInboundSize_tooBig() {
|
public void maxInboundSize_tooBig() {
|
||||||
StreamingOutputCallRequest request = StreamingOutputCallRequest.newBuilder()
|
StreamingOutputCallRequest request = StreamingOutputCallRequest.newBuilder()
|
||||||
.addResponseParameters(ResponseParameters.newBuilder().setSize(1))
|
.addResponseParameters(ResponseParameters.newBuilder().setSize(1))
|
||||||
|
|
@ -1132,7 +1137,7 @@ public abstract class AbstractInteropTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(timeout = 10000)
|
@Test
|
||||||
public void maxOutboundSize_exact() {
|
public void maxOutboundSize_exact() {
|
||||||
// warm up the channel and JVM
|
// warm up the channel and JVM
|
||||||
blockingStub.emptyCall(Empty.getDefaultInstance());
|
blockingStub.emptyCall(Empty.getDefaultInstance());
|
||||||
|
|
@ -1147,7 +1152,7 @@ public abstract class AbstractInteropTest {
|
||||||
stub.streamingOutputCall(request).next();
|
stub.streamingOutputCall(request).next();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(timeout = 10000)
|
@Test
|
||||||
public void maxOutboundSize_tooBig() {
|
public void maxOutboundSize_tooBig() {
|
||||||
// warm up the channel and JVM
|
// warm up the channel and JVM
|
||||||
blockingStub.emptyCall(Empty.getDefaultInstance());
|
blockingStub.emptyCall(Empty.getDefaultInstance());
|
||||||
|
|
@ -1172,7 +1177,7 @@ public abstract class AbstractInteropTest {
|
||||||
return 10485760;
|
return 10485760;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(timeout = 10000)
|
@Test
|
||||||
public void gracefulShutdown() throws Exception {
|
public void gracefulShutdown() throws Exception {
|
||||||
final List<StreamingOutputCallRequest> requests = Arrays.asList(
|
final List<StreamingOutputCallRequest> requests = Arrays.asList(
|
||||||
StreamingOutputCallRequest.newBuilder()
|
StreamingOutputCallRequest.newBuilder()
|
||||||
|
|
@ -1252,7 +1257,7 @@ public abstract class AbstractInteropTest {
|
||||||
assertFalse(errorSeen.isDone());
|
assertFalse(errorSeen.isDone());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(timeout = 10000)
|
@Test
|
||||||
public void customMetadata() throws Exception {
|
public void customMetadata() throws Exception {
|
||||||
final int responseSize = 314159;
|
final int responseSize = 314159;
|
||||||
final int requestSize = 271828;
|
final int requestSize = 271828;
|
||||||
|
|
@ -1331,7 +1336,7 @@ public abstract class AbstractInteropTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(timeout = 10000)
|
@Test
|
||||||
public void statusCodeAndMessage() throws Exception {
|
public void statusCodeAndMessage() throws Exception {
|
||||||
int errorCode = 2;
|
int errorCode = 2;
|
||||||
String errorMessage = "test status message";
|
String errorMessage = "test status message";
|
||||||
|
|
@ -1378,7 +1383,7 @@ public abstract class AbstractInteropTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Sends an rpc to an unimplemented method within TestService. */
|
/** Sends an rpc to an unimplemented method within TestService. */
|
||||||
@Test(timeout = 10000)
|
@Test
|
||||||
public void unimplementedMethod() {
|
public void unimplementedMethod() {
|
||||||
try {
|
try {
|
||||||
blockingStub.unimplementedCall(Empty.getDefaultInstance());
|
blockingStub.unimplementedCall(Empty.getDefaultInstance());
|
||||||
|
|
@ -1394,7 +1399,7 @@ public abstract class AbstractInteropTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Sends an rpc to an unimplemented service on the server. */
|
/** Sends an rpc to an unimplemented service on the server. */
|
||||||
@Test(timeout = 10000)
|
@Test
|
||||||
public void unimplementedService() {
|
public void unimplementedService() {
|
||||||
UnimplementedServiceGrpc.UnimplementedServiceBlockingStub stub =
|
UnimplementedServiceGrpc.UnimplementedServiceBlockingStub stub =
|
||||||
UnimplementedServiceGrpc.newBlockingStub(channel).withInterceptors(tracerSetupInterceptor);
|
UnimplementedServiceGrpc.newBlockingStub(channel).withInterceptors(tracerSetupInterceptor);
|
||||||
|
|
@ -1413,7 +1418,7 @@ public abstract class AbstractInteropTest {
|
||||||
|
|
||||||
/** Start a fullDuplexCall which the server will not respond, and verify the deadline expires. */
|
/** Start a fullDuplexCall which the server will not respond, and verify the deadline expires. */
|
||||||
@SuppressWarnings("MissingFail")
|
@SuppressWarnings("MissingFail")
|
||||||
@Test(timeout = 10000)
|
@Test
|
||||||
public void timeoutOnSleepingServer() throws Exception {
|
public void timeoutOnSleepingServer() throws Exception {
|
||||||
TestServiceGrpc.TestServiceStub stub =
|
TestServiceGrpc.TestServiceStub stub =
|
||||||
asyncStub.withDeadlineAfter(1, TimeUnit.MILLISECONDS);
|
asyncStub.withDeadlineAfter(1, TimeUnit.MILLISECONDS);
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,9 @@ import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.rules.Timeout;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.JUnit4;
|
import org.junit.runners.JUnit4;
|
||||||
|
|
||||||
|
|
@ -59,6 +61,9 @@ import org.junit.runners.JUnit4;
|
||||||
// bidirectional streaming requests also.
|
// bidirectional streaming requests also.
|
||||||
@RunWith(JUnit4.class)
|
@RunWith(JUnit4.class)
|
||||||
public class ConcurrencyTest {
|
public class ConcurrencyTest {
|
||||||
|
|
||||||
|
@Rule public final Timeout globalTimeout = Timeout.seconds(10);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A response observer that signals a {@code CountDownLatch} when the proper number of responses
|
* A response observer that signals a {@code CountDownLatch} when the proper number of responses
|
||||||
* arrives and the server signals that the RPC is complete.
|
* arrives and the server signals that the RPC is complete.
|
||||||
|
|
@ -165,7 +170,7 @@ public class ConcurrencyTest {
|
||||||
/**
|
/**
|
||||||
* Tests that gRPC can handle concurrent server-streaming RPCs.
|
* Tests that gRPC can handle concurrent server-streaming RPCs.
|
||||||
*/
|
*/
|
||||||
@Test(timeout = 10000)
|
@Test
|
||||||
public void serverStreamingTest() throws Exception {
|
public void serverStreamingTest() throws Exception {
|
||||||
CyclicBarrier startBarrier = new CyclicBarrier(NUM_CONCURRENT_REQUESTS);
|
CyclicBarrier startBarrier = new CyclicBarrier(NUM_CONCURRENT_REQUESTS);
|
||||||
CountDownLatch responsesDoneSignal = new CountDownLatch(NUM_CONCURRENT_REQUESTS);
|
CountDownLatch responsesDoneSignal = new CountDownLatch(NUM_CONCURRENT_REQUESTS);
|
||||||
|
|
|
||||||
|
|
@ -82,12 +82,12 @@ public class Http2NettyTest extends AbstractInteropTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(timeout = 10000)
|
@Test
|
||||||
public void remoteAddr() {
|
public void remoteAddr() {
|
||||||
assertRemoteAddr("/0:0:0:0:0:0:0:1");
|
assertRemoteAddr("/0:0:0:0:0:0:0:1");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(timeout = 10000)
|
@Test
|
||||||
public void tlsInfo() {
|
public void tlsInfo() {
|
||||||
assertX500SubjectDn("CN=testclient, O=Internet Widgits Pty Ltd, ST=Some-State, C=AU");
|
assertX500SubjectDn("CN=testclient, O=Internet Widgits Pty Ltd, ST=Some-State, C=AU");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,7 @@ public class Http2OkHttpTest extends AbstractInteropTest {
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(timeout = 10000)
|
@Test
|
||||||
public void receivedDataForFinishedStream() throws Exception {
|
public void receivedDataForFinishedStream() throws Exception {
|
||||||
Messages.ResponseParameters.Builder responseParameters =
|
Messages.ResponseParameters.Builder responseParameters =
|
||||||
Messages.ResponseParameters.newBuilder()
|
Messages.ResponseParameters.newBuilder()
|
||||||
|
|
@ -141,7 +141,7 @@ public class Http2OkHttpTest extends AbstractInteropTest {
|
||||||
assertEquals(EMPTY, blockingStub.emptyCall(EMPTY));
|
assertEquals(EMPTY, blockingStub.emptyCall(EMPTY));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(timeout = 10000)
|
@Test
|
||||||
public void wrongHostNameFailHostnameVerification() throws Exception {
|
public void wrongHostNameFailHostnameVerification() throws Exception {
|
||||||
ManagedChannel channel = createChannelBuilder()
|
ManagedChannel channel = createChannelBuilder()
|
||||||
.overrideAuthority(GrpcUtil.authorityFromHostAndPort(
|
.overrideAuthority(GrpcUtil.authorityFromHostAndPort(
|
||||||
|
|
@ -161,7 +161,7 @@ public class Http2OkHttpTest extends AbstractInteropTest {
|
||||||
channel.shutdown();
|
channel.shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(timeout = 10000)
|
@Test
|
||||||
public void hostnameVerifierWithBadHostname() throws Exception {
|
public void hostnameVerifierWithBadHostname() throws Exception {
|
||||||
ManagedChannel channel = createChannelBuilder()
|
ManagedChannel channel = createChannelBuilder()
|
||||||
.overrideAuthority(GrpcUtil.authorityFromHostAndPort(
|
.overrideAuthority(GrpcUtil.authorityFromHostAndPort(
|
||||||
|
|
@ -181,7 +181,7 @@ public class Http2OkHttpTest extends AbstractInteropTest {
|
||||||
channel.shutdown();
|
channel.shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(timeout = 10000)
|
@Test
|
||||||
public void hostnameVerifierWithCorrectHostname() throws Exception {
|
public void hostnameVerifierWithCorrectHostname() throws Exception {
|
||||||
ManagedChannel channel = createChannelBuilder()
|
ManagedChannel channel = createChannelBuilder()
|
||||||
.overrideAuthority(GrpcUtil.authorityFromHostAndPort(
|
.overrideAuthority(GrpcUtil.authorityFromHostAndPort(
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ public class MoreInProcessTest {
|
||||||
private static final String UNIQUE_SERVER_NAME =
|
private static final String UNIQUE_SERVER_NAME =
|
||||||
"in-process server for " + MoreInProcessTest.class;
|
"in-process server for " + MoreInProcessTest.class;
|
||||||
@Rule
|
@Rule
|
||||||
public final Timeout globalTimeout = new Timeout(1000);
|
public final Timeout globalTimeout = new Timeout(1, TimeUnit.SECONDS);
|
||||||
// use a mutable service registry for later registering the service impl for each test case.
|
// use a mutable service registry for later registering the service impl for each test case.
|
||||||
private final MutableHandlerRegistry serviceRegistry = new MutableHandlerRegistry();
|
private final MutableHandlerRegistry serviceRegistry = new MutableHandlerRegistry();
|
||||||
private final Server inProcessServer = InProcessServerBuilder.forName(UNIQUE_SERVER_NAME)
|
private final Server inProcessServer = InProcessServerBuilder.forName(UNIQUE_SERVER_NAME)
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,9 @@ import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.locks.LockSupport;
|
import java.util.concurrent.locks.LockSupport;
|
||||||
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.rules.Timeout;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.JUnit4;
|
import org.junit.runners.JUnit4;
|
||||||
|
|
||||||
|
|
@ -41,6 +43,9 @@ import org.junit.runners.JUnit4;
|
||||||
@RunWith(JUnit4.class)
|
@RunWith(JUnit4.class)
|
||||||
public class StressTestClientTest {
|
public class StressTestClientTest {
|
||||||
|
|
||||||
|
@Rule
|
||||||
|
public final Timeout globalTimeout = Timeout.seconds(5);
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void ipv6AddressesShouldBeSupported() {
|
public void ipv6AddressesShouldBeSupported() {
|
||||||
StressTestClient client = new StressTestClient();
|
StressTestClient client = new StressTestClient();
|
||||||
|
|
@ -108,7 +113,7 @@ public class StressTestClientTest {
|
||||||
assertEquals("foo.test.google.fr", client.addresses().get(0).getHostName());
|
assertEquals("foo.test.google.fr", client.addresses().get(0).getHostName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(timeout = 5000)
|
@Test
|
||||||
public void gaugesShouldBeExported() throws Exception {
|
public void gaugesShouldBeExported() throws Exception {
|
||||||
|
|
||||||
TestServiceServer server = new TestServiceServer();
|
TestServiceServer server = new TestServiceServer();
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,9 @@ import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.rules.Timeout;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.JUnit4;
|
import org.junit.runners.JUnit4;
|
||||||
import org.mockito.ArgumentCaptor;
|
import org.mockito.ArgumentCaptor;
|
||||||
|
|
@ -103,6 +105,9 @@ import org.mockito.stubbing.Answer;
|
||||||
@RunWith(JUnit4.class)
|
@RunWith(JUnit4.class)
|
||||||
public class NettyServerHandlerTest extends NettyHandlerTestBase<NettyServerHandler> {
|
public class NettyServerHandlerTest extends NettyHandlerTestBase<NettyServerHandler> {
|
||||||
|
|
||||||
|
@Rule
|
||||||
|
public final Timeout globalTimeout = Timeout.seconds(1);
|
||||||
|
|
||||||
private static final int STREAM_ID = 3;
|
private static final int STREAM_ID = 3;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
|
|
@ -529,7 +534,7 @@ public class NettyServerHandlerTest extends NettyHandlerTestBase<NettyServerHand
|
||||||
assertFalse(channel().isActive());
|
assertFalse(channel().isActive());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(timeout = 1000)
|
@Test
|
||||||
public void keepAliveEnforcer_sendingDataResetsCounters() throws Exception {
|
public void keepAliveEnforcer_sendingDataResetsCounters() throws Exception {
|
||||||
permitKeepAliveWithoutCalls = false;
|
permitKeepAliveWithoutCalls = false;
|
||||||
permitKeepAliveTimeInNanos = TimeUnit.HOURS.toNanos(1);
|
permitKeepAliveTimeInNanos = TimeUnit.HOURS.toNanos(1);
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,7 @@ import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.rules.ExpectedException;
|
import org.junit.rules.ExpectedException;
|
||||||
|
import org.junit.rules.Timeout;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.JUnit4;
|
import org.junit.runners.JUnit4;
|
||||||
import org.mockito.ArgumentCaptor;
|
import org.mockito.ArgumentCaptor;
|
||||||
|
|
@ -74,6 +75,8 @@ public class ProtocolNegotiatorsTest {
|
||||||
@Override public void run() {}
|
@Override public void run() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@Rule public final Timeout globalTimeout = Timeout.seconds(5);
|
||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
public final ExpectedException thrown = ExpectedException.none();
|
public final ExpectedException thrown = ExpectedException.none();
|
||||||
|
|
||||||
|
|
@ -303,7 +306,7 @@ public class ProtocolNegotiatorsTest {
|
||||||
ProtocolNegotiators.plaintext()));
|
ProtocolNegotiators.plaintext()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(timeout = 5000)
|
@Test
|
||||||
public void httpProxy_completes() throws Exception {
|
public void httpProxy_completes() throws Exception {
|
||||||
DefaultEventLoopGroup elg = new DefaultEventLoopGroup(1);
|
DefaultEventLoopGroup elg = new DefaultEventLoopGroup(1);
|
||||||
// ProxyHandler is incompatible with EmbeddedChannel because when channelRegistered() is called
|
// ProxyHandler is incompatible with EmbeddedChannel because when channelRegistered() is called
|
||||||
|
|
@ -367,7 +370,7 @@ public class ProtocolNegotiatorsTest {
|
||||||
channel.close();
|
channel.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(timeout = 5000)
|
@Test
|
||||||
public void httpProxy_500() throws Exception {
|
public void httpProxy_500() throws Exception {
|
||||||
DefaultEventLoopGroup elg = new DefaultEventLoopGroup(1);
|
DefaultEventLoopGroup elg = new DefaultEventLoopGroup(1);
|
||||||
// ProxyHandler is incompatible with EmbeddedChannel because when channelRegistered() is called
|
// ProxyHandler is incompatible with EmbeddedChannel because when channelRegistered() is called
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,9 @@ import io.netty.channel.EventLoop;
|
||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.rules.Timeout;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.JUnit4;
|
import org.junit.runners.JUnit4;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
|
|
@ -45,6 +47,9 @@ import org.mockito.stubbing.Answer;
|
||||||
@RunWith(JUnit4.class)
|
@RunWith(JUnit4.class)
|
||||||
public class WriteQueueTest {
|
public class WriteQueueTest {
|
||||||
|
|
||||||
|
@Rule
|
||||||
|
public final Timeout globalTimeout = Timeout.seconds(10);
|
||||||
|
|
||||||
private final Object lock = new Object();
|
private final Object lock = new Object();
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
|
|
@ -138,7 +143,7 @@ public class WriteQueueTest {
|
||||||
verify(channel, times(2)).flush();
|
verify(channel, times(2)).flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(timeout = 10000)
|
@Test
|
||||||
public void concurrentWriteAndFlush() throws Throwable {
|
public void concurrentWriteAndFlush() throws Throwable {
|
||||||
final WriteQueue queue = new WriteQueue(channel);
|
final WriteQueue queue = new WriteQueue(channel);
|
||||||
final CountDownLatch flusherStarted = new CountDownLatch(1);
|
final CountDownLatch flusherStarted = new CountDownLatch(1);
|
||||||
|
|
|
||||||
|
|
@ -118,8 +118,7 @@ public class OkHttpClientTransportTest {
|
||||||
private static final int HEADER_LENGTH = 5;
|
private static final int HEADER_LENGTH = 5;
|
||||||
private static final Status SHUTDOWN_REASON = Status.UNAVAILABLE.withDescription("for test");
|
private static final Status SHUTDOWN_REASON = Status.UNAVAILABLE.withDescription("for test");
|
||||||
|
|
||||||
@Rule
|
@Rule public final Timeout globalTimeout = Timeout.seconds(10);
|
||||||
public Timeout globalTimeout = new Timeout(10 * 1000);
|
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private FrameWriter frameWriter;
|
private FrameWriter frameWriter;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue