Skip to content

Commit

Permalink
interop-testing: limit the amount of noise from failing tests
Browse files Browse the repository at this point in the history
Also mark Netty class as internal
  • Loading branch information
carl-mastrangelo committed Sep 29, 2016
1 parent 3fb3af4 commit 3481283
Showing 2 changed files with 35 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -40,8 +40,6 @@
import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.timeout;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;

import com.google.auth.oauth2.AccessToken;
import com.google.auth.oauth2.ComputeEngineCredentials;
@@ -90,6 +88,8 @@
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Mockito;
import org.mockito.verification.VerificationMode;

import java.io.IOException;
import java.io.InputStream;
@@ -989,4 +989,35 @@ private static void assumeEnoughMemory() {
actuallyFreeMemory + " is not sufficient to run this test",
actuallyFreeMemory >= 64 * 1024 * 1024);
}

/**
* Wrapper around {@link Mockito#verify}, to keep log spam down on failure.
*/
private static <T> T verify(T mock, VerificationMode mode) {
try {
return Mockito.verify(mock, mode);
} catch (AssertionError e) {
String msg = e.getMessage();
if (msg.length() >= 256) {
throw new AssertionError(msg.substring(0, 256), e);
}
throw e;
}

}

/**
* Wrapper around {@link Mockito#verify}, to keep log spam down on failure.
*/
private static void verifyNoMoreInteractions(Object... mocks) {
try {
Mockito.verifyNoMoreInteractions(mocks);
} catch (AssertionError e) {
String msg = e.getMessage();
if (msg.length() >= 256) {
throw new AssertionError(msg.substring(0, 256), e);
}
throw e;
}
}
}
Original file line number Diff line number Diff line change
@@ -32,6 +32,7 @@
package io.grpc.netty;

import io.grpc.Attributes;
import io.grpc.Internal;
import io.netty.handler.codec.http2.Http2ConnectionDecoder;
import io.netty.handler.codec.http2.Http2ConnectionEncoder;
import io.netty.handler.codec.http2.Http2ConnectionHandler;
@@ -40,6 +41,7 @@
/**
* gRPC wrapper for {@link Http2ConnectionHandler}.
*/
@Internal
public abstract class GrpcHttp2ConnectionHandler extends Http2ConnectionHandler {
public GrpcHttp2ConnectionHandler(Http2ConnectionDecoder decoder,
Http2ConnectionEncoder encoder,

0 comments on commit 3481283

Please sign in to comment.