use of org.finra.herd.model.dto.AwsParamsDto in project herd by FINRAOS.
the class EmrDaoTest method getEmrClientAssertClientConfigurationNotSetWhenProxyPortIsNull.
@Test
public void getEmrClientAssertClientConfigurationNotSetWhenProxyPortIsNull() throws Exception {
String httpProxyHost = "httpProxyHost";
Integer httpProxyPort = null;
AwsParamsDto awsParamsDto = new AwsParamsDto();
awsParamsDto.setHttpProxyHost(httpProxyHost);
awsParamsDto.setHttpProxyPort(httpProxyPort);
AmazonElasticMapReduceClient amazonElasticMapReduceClient = emrDao.getEmrClient(awsParamsDto);
ClientConfiguration clientConfiguration = (ClientConfiguration) ReflectionTestUtils.getField(amazonElasticMapReduceClient, "clientConfiguration");
assertNotNull(clientConfiguration);
assertNull(clientConfiguration.getProxyHost());
}
use of org.finra.herd.model.dto.AwsParamsDto in project herd by FINRAOS.
the class EmrDaoTest method getEmrClientAssertClientConfigurationSet.
@Test
public void getEmrClientAssertClientConfigurationSet() throws Exception {
String httpProxyHost = "httpProxyHost";
Integer httpProxyPort = 1234;
AwsParamsDto awsParamsDto = new AwsParamsDto();
awsParamsDto.setHttpProxyHost(httpProxyHost);
awsParamsDto.setHttpProxyPort(httpProxyPort);
AmazonElasticMapReduceClient amazonElasticMapReduceClient = emrDao.getEmrClient(awsParamsDto);
ClientConfiguration clientConfiguration = (ClientConfiguration) ReflectionTestUtils.getField(amazonElasticMapReduceClient, "clientConfiguration");
assertNotNull(clientConfiguration);
assertEquals(httpProxyHost, clientConfiguration.getProxyHost());
assertEquals(httpProxyPort.intValue(), clientConfiguration.getProxyPort());
}
use of org.finra.herd.model.dto.AwsParamsDto in project herd by FINRAOS.
the class AwsClientFactoryTest method testGetAmazonSQSClientCacheHitMiss.
@Test
public void testGetAmazonSQSClientCacheHitMiss() {
// Create an AWS parameters DTO that contains proxy information.
AwsParamsDto awsParamsDto = new AwsParamsDto(NO_AWS_ACCESS_KEY, NO_AWS_SECRET_KEY, NO_SESSION_TOKEN, HTTP_PROXY_HOST, HTTP_PROXY_PORT);
// Get an Amazon SQS client.
AmazonSQS amazonSQS = awsClientFactory.getAmazonSQSClient(awsParamsDto);
// Confirm a cache hit.
assertEquals(amazonSQS, awsClientFactory.getAmazonSQSClient(new AwsParamsDto(NO_AWS_ACCESS_KEY, NO_AWS_SECRET_KEY, NO_SESSION_TOKEN, HTTP_PROXY_HOST, HTTP_PROXY_PORT)));
// Confirm a cache miss due to http proxy information.
assertNotEquals(amazonSQS, awsClientFactory.getAmazonSQSClient(new AwsParamsDto(NO_AWS_ACCESS_KEY, NO_AWS_SECRET_KEY, NO_SESSION_TOKEN, HTTP_PROXY_HOST_2, HTTP_PROXY_PORT_2)));
// Clear the cache.
cacheManager.getCache(DaoSpringModuleConfig.HERD_CACHE_NAME).clear();
// Confirm a cache miss due to cleared cache.
assertNotEquals(amazonSQS, awsClientFactory.getAmazonSQSClient(awsParamsDto));
}
use of org.finra.herd.model.dto.AwsParamsDto in project herd by FINRAOS.
the class AwsClientFactoryTest method testGetAmazonSNSClientCacheHitMiss.
@Test
public void testGetAmazonSNSClientCacheHitMiss() {
// Create an AWS parameters DTO that contains proxy information.
AwsParamsDto awsParamsDto = new AwsParamsDto(NO_AWS_ACCESS_KEY, NO_AWS_SECRET_KEY, NO_SESSION_TOKEN, HTTP_PROXY_HOST, HTTP_PROXY_PORT);
// Get an Amazon SNS client.
AmazonSNS amazonSNS = awsClientFactory.getAmazonSNSClient(awsParamsDto);
// Confirm a cache hit.
assertEquals(amazonSNS, awsClientFactory.getAmazonSNSClient(new AwsParamsDto(NO_AWS_ACCESS_KEY, NO_AWS_SECRET_KEY, NO_SESSION_TOKEN, HTTP_PROXY_HOST, HTTP_PROXY_PORT)));
// Confirm a cache miss due to http proxy information.
assertNotEquals(amazonSNS, awsClientFactory.getAmazonSNSClient(new AwsParamsDto(NO_AWS_ACCESS_KEY, NO_AWS_SECRET_KEY, NO_SESSION_TOKEN, HTTP_PROXY_HOST_2, HTTP_PROXY_PORT_2)));
// Clear the cache.
cacheManager.getCache(DaoSpringModuleConfig.HERD_CACHE_NAME).clear();
// Confirm a cache miss due to cleared cache.
assertNotEquals(amazonSNS, awsClientFactory.getAmazonSNSClient(awsParamsDto));
}
use of org.finra.herd.model.dto.AwsParamsDto in project herd by FINRAOS.
the class AwsClientFactoryTest method testGetEmrClientCacheHitMiss.
@Test
public void testGetEmrClientCacheHitMiss() {
// Create an AWS parameters DTO that contains both AWS credentials and proxy information.
AwsParamsDto awsParamsDto = new AwsParamsDto(AWS_ASSUMED_ROLE_ACCESS_KEY, AWS_ASSUMED_ROLE_SECRET_KEY, AWS_ASSUMED_ROLE_SESSION_TOKEN, HTTP_PROXY_HOST, HTTP_PROXY_PORT);
// Get an Amazon EMR client.
AmazonElasticMapReduceClient amazonElasticMapReduceClient = awsClientFactory.getEmrClient(awsParamsDto);
// Confirm a cache hit.
assertEquals(amazonElasticMapReduceClient, awsClientFactory.getEmrClient(new AwsParamsDto(AWS_ASSUMED_ROLE_ACCESS_KEY, AWS_ASSUMED_ROLE_SECRET_KEY, AWS_ASSUMED_ROLE_SESSION_TOKEN, HTTP_PROXY_HOST, HTTP_PROXY_PORT)));
// Confirm a cache miss due to AWS credentials.
assertNotEquals(amazonElasticMapReduceClient, awsClientFactory.getEmrClient(new AwsParamsDto(AWS_ASSUMED_ROLE_ACCESS_KEY_2, AWS_ASSUMED_ROLE_SECRET_KEY_2, AWS_ASSUMED_ROLE_SESSION_TOKEN_2, HTTP_PROXY_HOST, HTTP_PROXY_PORT)));
// Confirm a cache miss due to http proxy information.
assertNotEquals(amazonElasticMapReduceClient, awsClientFactory.getEmrClient(new AwsParamsDto(AWS_ASSUMED_ROLE_ACCESS_KEY, AWS_ASSUMED_ROLE_SECRET_KEY, AWS_ASSUMED_ROLE_SESSION_TOKEN, HTTP_PROXY_HOST_2, HTTP_PROXY_PORT_2)));
// Clear the cache.
cacheManager.getCache(DaoSpringModuleConfig.HERD_CACHE_NAME).clear();
// Confirm a cache miss due to cleared cache.
assertNotEquals(amazonElasticMapReduceClient, awsClientFactory.getEmrClient(awsParamsDto));
}
Aggregations