use of okhttp3.Dispatcher in project dropbox-sdk-java by dropbox.
the class OkHttp3RequestorTest method testSameThreadDispatcher.
@Test(expectedExceptions = { IllegalArgumentException.class })
public void testSameThreadDispatcher() {
OkHttpClient.Builder client = new OkHttpClient.Builder();
// should fail for same-thread executors
client.dispatcher(new Dispatcher(MoreExecutors.newDirectExecutorService()));
new OkHttp3Requestor(client.build());
}
use of okhttp3.Dispatcher in project dropbox-sdk-java by dropbox.
the class OkHttp3RequestorTest method testCustomDispatcher.
@Test
public void testCustomDispatcher() {
OkHttpClient.Builder client = new OkHttpClient.Builder();
// should be fine with default Dispatcher
new OkHttp3Requestor(client.build());
// should also be fine with other common executors that run on separate threads
client.dispatcher(new Dispatcher(Executors.newSingleThreadExecutor()));
new OkHttp3Requestor(client.build());
client.dispatcher(new Dispatcher(Executors.newCachedThreadPool()));
new OkHttp3Requestor(client.build());
client.dispatcher(new Dispatcher(Executors.newFixedThreadPool(3)));
new OkHttp3Requestor(client.build());
}
Aggregations