public class TestUtils extends Object
Modifier and Type | Field and Description |
---|---|
static String |
TEST_SERVER_HOST |
Modifier and Type | Method and Description |
---|---|
static ServerInterceptor |
echoRequestHeadersInterceptor(Metadata.Key<?>... keys)
Echo the request headers from a client into response headers and trailers.
|
static SSLSocketFactory |
getSslSocketFactoryForCertainCert(File certChainFile)
Returns a SSLSocketFactory which uses the certificate specified in certChainFile.
|
static File |
loadCert(String name)
Load a file from the resources folder.
|
static int |
pickUnusedPort()
Picks an unused port.
|
static InetSocketAddress |
testServerAddress(int port)
Creates a new
InetSocketAddress on localhost that overrides the host with
TEST_SERVER_HOST . |
static InetSocketAddress |
testServerAddress(String host,
int port)
Creates a new
InetSocketAddress that overrides the host with TEST_SERVER_HOST . |
public static final String TEST_SERVER_HOST
public static ServerInterceptor echoRequestHeadersInterceptor(Metadata.Key<?>... keys)
public static int pickUnusedPort()
public static InetSocketAddress testServerAddress(String host, int port)
InetSocketAddress
that overrides the host with TEST_SERVER_HOST
.public static InetSocketAddress testServerAddress(int port)
InetSocketAddress
on localhost that overrides the host with
TEST_SERVER_HOST
.public static File loadCert(String name) throws IOException
name
- name of a file in src/main/resources/certs.IOException
public static SSLSocketFactory getSslSocketFactoryForCertainCert(File certChainFile) throws Exception
Exception