use of com.ingenico.connect.gateway.sdk.java.Communicator in project connect-sdk-java by Ingenico-ePayments.
the class SDKProxyTest method assertProxySet.
@SuppressWarnings("resource")
private void assertProxySet(ApiResource resource, ProxyConfiguration proxyConfiguration) {
Communicator communicator = getField(resource, "communicator", Communicator.class);
Session session = getField(communicator, "session", Session.class);
DefaultConnection connection = getField(session, "connection", DefaultConnection.class);
CloseableHttpClient httpClient = getField(connection, "httpClient", CloseableHttpClient.class);
DefaultProxyRoutePlanner routePlanner = getField(httpClient, "routePlanner", DefaultProxyRoutePlanner.class);
HttpHost proxy = getField(routePlanner, "proxy", HttpHost.class);
Assert.assertEquals(proxyConfiguration.getScheme(), proxy.getSchemeName());
Assert.assertEquals(proxyConfiguration.getPort(), proxy.getPort());
BasicCredentialsProvider credentialsProvider = getField(httpClient, "credentialsProvider", BasicCredentialsProvider.class);
AuthScope authScope = new AuthScope(proxy);
Credentials credentials = credentialsProvider.getCredentials(authScope);
Assert.assertTrue(credentials instanceof UsernamePasswordCredentials);
UsernamePasswordCredentials usernamePasswordCredentials = (UsernamePasswordCredentials) credentials;
Assert.assertEquals(proxyConfiguration.getUsername(), usernamePasswordCredentials.getUserName());
Assert.assertEquals(proxyConfiguration.getPassword(), usernamePasswordCredentials.getPassword());
}
use of com.ingenico.connect.gateway.sdk.java.Communicator in project connect-sdk-java by Ingenico-ePayments.
the class ConnectionPoolingTest method testConnectionPooling.
private void testConnectionPooling(int requestCount, int maxConnections) throws Exception {
ExecutorService executorService = Executors.newFixedThreadPool(requestCount);
try {
CommunicatorConfiguration configuration = getCommunicatorConfiguration().withMaxConnections(maxConnections);
Communicator communicator = Factory.createCommunicator(configuration);
try {
testConnectionPooling(executorService, communicator, requestCount);
} finally {
communicator.close();
}
} finally {
executorService.shutdown();
}
}
use of com.ingenico.connect.gateway.sdk.java.Communicator in project connect-sdk-java by Ingenico-ePayments.
the class DefaultConnectionLoggerTest method createClient.
@SuppressWarnings("resource")
private Client createClient(HttpHost host, int connectTimeout, int socketTimeout) throws URISyntaxException {
URI uri = new URI(host.getSchemeName(), null, host.getHostName(), host.getPort(), null, null, null);
Connection connection = new DefaultConnection(connectTimeout, socketTimeout);
Authenticator authenticator = new DefaultAuthenticator(AuthorizationType.V1HMAC, "apiKey", "secret");
MetaDataProvider metaDataProvider = new MetaDataProvider("Ingenico");
Session session = new Session(uri, connection, authenticator, metaDataProvider);
Communicator communicator = Factory.createCommunicator(session);
Client client = Factory.createClient(communicator);
return client;
}
use of com.ingenico.connect.gateway.sdk.java.Communicator in project connect-sdk-java by Ingenico-ePayments.
the class DefaultConnectionIdempotenceTest method createClient.
@SuppressWarnings("resource")
private Client createClient(HttpHost host) {
Connection connection = new DefaultConnection(500, 500);
Authenticator authenticator = new DefaultAuthenticator(AuthorizationType.V1HMAC, "apiKey", "secret");
MetaDataProvider metaDataProvider = new MetaDataProvider("Ingenico");
Session session = new Session(URI.create(host.toURI()), connection, authenticator, metaDataProvider);
Communicator communicator = Factory.createCommunicator(session);
Client client = Factory.createClient(communicator);
return client;
}
Aggregations