Search in sources :

Example 71 with OkHttpClient

use of com.github.mjeanroy.junit.servers.client.impl.okhttp3.OkHttpClient in project cumulocity-lora by SoftwareAG.

the class ActilityConnector method init.

@Override
protected void init() {
    HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
    interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
    OkHttpClient dxClient = new OkHttpClient.Builder().addInterceptor(new DXAdminJWTInterceptor(properties.getProperty("username"), properties.getProperty("password"))).addInterceptor(interceptor).build();
    String url = properties.getProperty("url");
    OkHttpClient client = new OkHttpClient.Builder().addInterceptor(interceptor).build();
    Retrofit core = new Retrofit.Builder().client(dxClient).baseUrl(url + "/thingpark/dx/core/latest/api/").addConverterFactory(JacksonConverterFactory.create()).build();
    Retrofit admin = new Retrofit.Builder().baseUrl(url + "/iot-flow/v1/").client(client).addConverterFactory(JacksonConverterFactory.create()).build();
    actilityCoreService = core.create(ActilityCoreService.class);
    actilityAdminService = admin.create(ActilityAdminService.class);
}
Also used : Retrofit(retrofit2.Retrofit) OkHttpClient(okhttp3.OkHttpClient) ActilityAdminService(lora.ns.actility.rest.ActilityAdminService) ActilityCoreService(lora.ns.actility.rest.ActilityCoreService) HttpLoggingInterceptor(okhttp3.logging.HttpLoggingInterceptor)

Example 72 with OkHttpClient

use of com.github.mjeanroy.junit.servers.client.impl.okhttp3.OkHttpClient in project cumulocity-lora by SoftwareAG.

the class LoriotConnector method init.

@Override
protected void init() {
    OkHttpClient okHttpClient = new OkHttpClient.Builder().addInterceptor(new APIKeyInterceptor()).build();
    Retrofit retrofit = new Retrofit.Builder().client(okHttpClient).baseUrl(getProperties().getProperty("url")).addConverterFactory(JacksonConverterFactory.create()).build();
    loriotService = retrofit.create(LoriotService.class);
}
Also used : Retrofit(retrofit2.Retrofit) LoriotService(lora.ns.loriot.rest.LoriotService) OkHttpClient(okhttp3.OkHttpClient)

Example 73 with OkHttpClient

use of com.github.mjeanroy.junit.servers.client.impl.okhttp3.OkHttpClient in project java-sdk by dapr.

the class DaprHttpClientTest method setUp.

@Before
public void setUp() {
    mockInterceptor = new MockInterceptor(Behavior.UNORDERED);
    okHttpClient = new OkHttpClient.Builder().addInterceptor(mockInterceptor).build();
}
Also used : OkHttpClient(okhttp3.OkHttpClient) MockInterceptor(okhttp3.mock.MockInterceptor) Before(org.junit.Before)

Example 74 with OkHttpClient

use of com.github.mjeanroy.junit.servers.client.impl.okhttp3.OkHttpClient in project java-sdk by dapr.

the class DaprHttpBuilderTest method getOkHttpClient.

private static OkHttpClient getOkHttpClient(DaprHttp daprHttp) throws Exception {
    Field httpClientField = DaprHttp.class.getDeclaredField("httpClient");
    httpClientField.setAccessible(true);
    OkHttpClient okHttpClient = (OkHttpClient) httpClientField.get(daprHttp);
    assertNotNull(okHttpClient);
    return okHttpClient;
}
Also used : Field(java.lang.reflect.Field) OkHttpClient(okhttp3.OkHttpClient)

Example 75 with OkHttpClient

use of com.github.mjeanroy.junit.servers.client.impl.okhttp3.OkHttpClient in project java-sdk by dapr.

the class DaprPreviewClientHttpTest method setUp.

@Before
public void setUp() {
    mockInterceptor = new MockInterceptor(Behavior.UNORDERED);
    okHttpClient = new OkHttpClient.Builder().addInterceptor(mockInterceptor).build();
    daprHttp = new DaprHttp(Properties.SIDECAR_IP.get(), 3000, okHttpClient);
    daprPreviewClientHttp = new DaprClientHttp(daprHttp);
}
Also used : OkHttpClient(okhttp3.OkHttpClient) MockInterceptor(okhttp3.mock.MockInterceptor) Before(org.junit.Before)

Aggregations

OkHttpClient (okhttp3.OkHttpClient)1944 Request (okhttp3.Request)1024 Response (okhttp3.Response)880 IOException (java.io.IOException)567 Test (org.junit.Test)365 Call (okhttp3.Call)290 RequestBody (okhttp3.RequestBody)222 Test (org.junit.jupiter.api.Test)145 Retrofit (retrofit2.Retrofit)138 File (java.io.File)132 HttpUrl (okhttp3.HttpUrl)131 HttpLoggingInterceptor (okhttp3.logging.HttpLoggingInterceptor)128 Callback (okhttp3.Callback)117 JSONObject (org.json.JSONObject)110 ArrayList (java.util.ArrayList)106 ResponseBody (okhttp3.ResponseBody)105 Gson (com.google.gson.Gson)98 MediaType (okhttp3.MediaType)98 List (java.util.List)92 Map (java.util.Map)85