public final class TestUtil
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.net.InetSocketAddress |
UNREACHABLE_ADDRESS |
Modifier and Type | Method and Description |
---|---|
static void |
awaitGarbageCollection()
See FinalizationTester for discussion on how to best trigger GC in tests.
|
static OkHttpClient |
defaultClient()
Returns an OkHttpClient for all tests to use as a starting point.
|
static void |
ensureAllConnectionsReleased(OkHttpClient client) |
static java.util.List<okhttp3.internal.http2.Header> |
headerEntries(java.lang.String... elements) |
static java.lang.String |
repeat(char c,
int count) |
public static OkHttpClient defaultClient()
The shared instance allows all tests to share a single connection pool, which prevents idle connections from consuming unnecessary resources while connections wait to be evicted.
This client is also configured to be slightly more deterministic, returning a single IP address for all hosts, regardless of the actual number of IP addresses reported by DNS.
public static java.util.List<okhttp3.internal.http2.Header> headerEntries(java.lang.String... elements)
public static java.lang.String repeat(char c, int count)
public static void awaitGarbageCollection() throws java.lang.Exception
java.lang.Exception
public static void ensureAllConnectionsReleased(OkHttpClient client)
Copyright © 2019. All Rights Reserved.