Search in sources :

Example 6 with OkHttpAdapter

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

the class AbstractJpaJerseyTest 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 : QueryParamsBuilder(io.crnk.legacy.queryParams.QueryParamsBuilder) Builder(okhttp3.OkHttpClient.Builder) OkHttpAdapter(io.crnk.client.http.okhttp.OkHttpAdapter) OkHttpAdapterListenerBase(io.crnk.client.http.okhttp.OkHttpAdapterListenerBase)

Example 7 with OkHttpAdapter

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

the class SecurityModuleIntTest method setBasicAuthentication.

private static void setBasicAuthentication(CrnkClient client, final String userName, final String password) {
    OkHttpAdapter httpAdapter = (OkHttpAdapter) client.getHttpAdapter();
    httpAdapter.addListener(new OkHttpAdapterListenerBase() {

        @Override
        public void onBuild(OkHttpClient.Builder builder) {
            builder.authenticator(new TestAuthenticator(userName, password));
        }
    });
}
Also used : OkHttpClient(okhttp3.OkHttpClient) OkHttpAdapter(io.crnk.client.http.okhttp.OkHttpAdapter) OkHttpAdapterListenerBase(io.crnk.client.http.okhttp.OkHttpAdapterListenerBase)

Example 8 with OkHttpAdapter

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

the class OkHttpClientTest method setupClient.

@Override
protected void setupClient(CrnkClient client) {
    super.setupClient(client);
    listener = Mockito.mock(OkHttpAdapterListener.class);
    OkHttpAdapter httpAdapter = OkHttpAdapter.newInstance();
    httpAdapter.addListener(new OkHttpAdapterListenerBase());
    httpAdapter.addListener(listener);
    client.setHttpAdapter(httpAdapter);
}
Also used : OkHttpAdapterListener(io.crnk.client.http.okhttp.OkHttpAdapterListener) OkHttpAdapter(io.crnk.client.http.okhttp.OkHttpAdapter) OkHttpAdapterListenerBase(io.crnk.client.http.okhttp.OkHttpAdapterListenerBase)

Example 9 with OkHttpAdapter

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

the class ModuleClientTest method testReconfigureHttpAdapter.

@Test
public void testReconfigureHttpAdapter() {
    OkHttpAdapter newAdapter = new OkHttpAdapter();
    client.setHttpAdapter(newAdapter);
    Mockito.verify(testModule, Mockito.times(1)).setHttpAdapter(newAdapter);
}
Also used : OkHttpAdapter(io.crnk.client.http.okhttp.OkHttpAdapter) Test(org.junit.Test) AbstractClientTest(io.crnk.client.AbstractClientTest)

Example 10 with OkHttpAdapter

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

the class ModuleClientTest method setup.

@Before
public void setup() {
    super.setup();
    client.setHttpAdapter(new OkHttpAdapter());
    client.addModule(testModule);
}
Also used : OkHttpAdapter(io.crnk.client.http.okhttp.OkHttpAdapter) Before(org.junit.Before)

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