AwsClientFactory { @Cacheable(DaoSpringModuleConfig.HERD_CACHE_NAME) public AmazonSQS getAmazonSQSClient(AwsParamsDto awsParamsDto) { return AmazonSQSClientBuilder.standard().withClientConfiguration(awsHelper.getClientConfiguration(awsParamsDto)) .withRegion(awsParamsDto.getAwsRegionName()).build(); }  @Cacheable(DaoSpringModuleConfig.HERD_CACHE_NAME) AmazonSNS getAmazonSNSClient(AwsParamsDto awsParamsDto); @Cacheable(DaoSpringModuleConfig.HERD_CACHE_NAME) AmazonSQS getAmazonSQSClient(AwsParamsDto awsParamsDto); @Cacheable(DaoSpringModuleConfig.HERD_CACHE_NAME) AmazonEC2 getEc2Client(AwsParamsDto awsParamsDto); @Cacheable(DaoSpringModuleConfig.HERD_CACHE_NAME) AmazonElasticMapReduce getEmrClient(AwsParamsDto awsParamsDto); @Cacheable(DaoSpringModuleConfig.HERD_CACHE_NAME) AmazonSimpleEmailService getSesClient(AwsParamsDto awsParamsDto);  }
@Test public void testGetAmazonSQSClient() { assertNotNull(awsClientFactory.getAmazonSQSClient( new AwsParamsDto(NO_AWS_ACCESS_KEY, NO_AWS_SECRET_KEY, NO_SESSION_TOKEN, HTTP_PROXY_HOST, HTTP_PROXY_PORT, AWS_REGION_NAME_US_EAST_1))); }
@Test public void testGetAmazonSQSClientCacheHitMiss() { AwsParamsDto awsParamsDto = new AwsParamsDto(NO_AWS_ACCESS_KEY, NO_AWS_SECRET_KEY, NO_SESSION_TOKEN, HTTP_PROXY_HOST, HTTP_PROXY_PORT, AWS_REGION_NAME_US_EAST_1); AmazonSQS amazonSQS = awsClientFactory.getAmazonSQSClient(awsParamsDto); assertEquals(amazonSQS, awsClientFactory.getAmazonSQSClient( new AwsParamsDto(NO_AWS_ACCESS_KEY, NO_AWS_SECRET_KEY, NO_SESSION_TOKEN, HTTP_PROXY_HOST, HTTP_PROXY_PORT, AWS_REGION_NAME_US_EAST_1))); 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, AWS_REGION_NAME_US_EAST_1))); cacheManager.getCache(DaoSpringModuleConfig.HERD_CACHE_NAME).clear(); assertNotEquals(amazonSQS, awsClientFactory.getAmazonSQSClient(awsParamsDto)); }