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