use of com.opengamma.sdk.common.auth.Credentials in project JavaSDK by OpenGamma.
the class BasicTest method testAuthGoodHttpFactory.
public void testAuthGoodHttpFactory() {
AuthClient mockAuth = new TestingAuthClient();
try (ServiceInvoker invoker = ServiceInvoker.builder(CREDENTIALS).httpClientFactory(builder -> builder.addInterceptor(chain -> chain.proceed(chain.request())).followRedirects(false).build()).authClientFactory(inv -> mockAuth).build()) {
assertEquals(invoker.getServiceUrl(), SERVICE_URL);
// logging, user-agent & auth plus one from test
assertEquals(invoker.getHttpClient().interceptors().size(), 4);
assertEquals(invoker.getHttpClient().followRedirects(), false);
}
}
use of com.opengamma.sdk.common.auth.Credentials in project JavaSDK by OpenGamma.
the class BasicTest method testAuthGoodHttpClient.
public void testAuthGoodHttpClient() {
AuthClient mockAuth = new TestingAuthClient();
try (ServiceInvoker invoker = ServiceInvoker.builder(CREDENTIALS).httpClient(new OkHttpClient()).authClientFactory(inv -> mockAuth).build()) {
assertEquals(invoker.getServiceUrl(), SERVICE_URL);
// user-agent & auth
assertEquals(invoker.getHttpClient().interceptors().size(), 2);
}
}
use of com.opengamma.sdk.common.auth.Credentials in project JavaSDK by OpenGamma.
the class BasicTest method testAuthGood.
public void testAuthGood() {
AuthClient mockAuth = new TestingAuthClient();
@SuppressWarnings("resource") ServiceInvoker invoker = ServiceInvoker.builder(CREDENTIALS).authClientFactory(inv -> mockAuth).build();
assertEquals(invoker.getServiceUrl(), SERVICE_URL);
assertEquals(invoker.getHttpClient().interceptors().size(), 3);
assertEquals(invoker.getHttpClient().followRedirects(), true);
assertEquals(invoker.getExecutor().isShutdown(), false);
invoker.close();
assertEquals(invoker.getExecutor().isShutdown(), true);
}
Aggregations