Search in sources :

Example 11 with OkHttpAdapter

use of io.crnk.client.http.okhttp.OkHttpAdapter in project crnk-framework by crnk-project.

the class HttpAdapterProviderTest method testOkHttpProvider.

@Test
public void testOkHttpProvider() {
    OkHttpAdapterProvider provider = new OkHttpAdapterProvider();
    Assert.assertTrue(provider.isAvailable());
    Assert.assertTrue(provider.newInstance() instanceof OkHttpAdapter);
}
Also used : OkHttpAdapter(io.crnk.client.http.okhttp.OkHttpAdapter) OkHttpAdapterProvider(io.crnk.client.http.okhttp.OkHttpAdapterProvider) AbstractClientTest(io.crnk.client.AbstractClientTest) Test(org.junit.Test)

Example 12 with OkHttpAdapter

use of io.crnk.client.http.okhttp.OkHttpAdapter in project crnk-framework by crnk-project.

the class OkHttpAdapterTest method testCannotAddListenersAfterInitialization.

@Test
public void testCannotAddListenersAfterInitialization() {
    OkHttpAdapter adapter = new OkHttpAdapter();
    adapter.getImplementation();
    try {
        adapter.addListener(Mockito.mock(OkHttpAdapterListener.class));
        Assert.fail();
    } catch (IllegalStateException e) {
    // ok
    }
}
Also used : OkHttpAdapterListener(io.crnk.client.http.okhttp.OkHttpAdapterListener) OkHttpAdapter(io.crnk.client.http.okhttp.OkHttpAdapter) Test(org.junit.Test)

Example 13 with OkHttpAdapter

use of io.crnk.client.http.okhttp.OkHttpAdapter in project crnk-framework by crnk-project.

the class OkHttpAdapterTest method testCannotSetTimeoutAfterInitialization.

@Test
public void testCannotSetTimeoutAfterInitialization() {
    OkHttpAdapter adapter = new OkHttpAdapter();
    adapter.getImplementation();
    try {
        adapter.setReceiveTimeout(0, TimeUnit.DAYS);
        Assert.fail();
    } catch (IllegalStateException e) {
    // ok
    }
}
Also used : OkHttpAdapter(io.crnk.client.http.okhttp.OkHttpAdapter) Test(org.junit.Test)

Example 14 with OkHttpAdapter

use of io.crnk.client.http.okhttp.OkHttpAdapter in project crnk-framework by crnk-project.

the class AbstractOperationsTest method setNetworkTimeout.

public static void setNetworkTimeout(CrnkClient client, final int timeout, final TimeUnit timeUnit) {
    OkHttpAdapter httpAdapter = (OkHttpAdapter) client.getHttpAdapter();
    httpAdapter.addListener(new OkHttpAdapterListenerBase() {

        @Override
        public void onBuild(Builder builder) {
            builder.readTimeout(timeout, timeUnit);
        }
    });
}
Also used : Builder(okhttp3.OkHttpClient.Builder) OkHttpAdapter(io.crnk.client.http.okhttp.OkHttpAdapter) OkHttpAdapterListenerBase(io.crnk.client.http.okhttp.OkHttpAdapterListenerBase)

Aggregations

OkHttpAdapter (io.crnk.client.http.okhttp.OkHttpAdapter)14 OkHttpAdapterListener (io.crnk.client.http.okhttp.OkHttpAdapterListener)5 OkHttpAdapterListenerBase (io.crnk.client.http.okhttp.OkHttpAdapterListenerBase)5 Builder (okhttp3.OkHttpClient.Builder)4 Test (org.junit.Test)4 HttpClientAdapter (io.crnk.client.http.apache.HttpClientAdapter)3 AbstractClientTest (io.crnk.client.AbstractClientTest)2 HttpClientAdapterListener (io.crnk.client.http.apache.HttpClientAdapterListener)2 QuerySpec (io.crnk.core.queryspec.QuerySpec)2 Task (io.crnk.test.mock.models.Task)2 Interceptor (okhttp3.Interceptor)2 OkHttpClient (okhttp3.OkHttpClient)2 HttpTracing (brave.http.HttpTracing)1 HttpAdapter (io.crnk.client.http.HttpAdapter)1 OkHttpAdapterProvider (io.crnk.client.http.okhttp.OkHttpAdapterProvider)1 QueryParamsBuilder (io.crnk.legacy.queryParams.QueryParamsBuilder)1 HttpClientBraveIntegration (io.crnk.monitor.brave.internal.HttpClientBraveIntegration)1 OkHttpBraveIntegration (io.crnk.monitor.brave.internal.OkHttpBraveIntegration)1 Constructor (java.lang.reflect.Constructor)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1