예제 #1
0
 /**
  * AwsBucket can correctly check the existence of the non-existing bucket.
  *
  * @throws IOException If fails
  */
 @Test
 public void existsNonExistingBucket() throws IOException {
   final Region region = Mockito.mock(Region.class);
   final AmazonS3 aws = Mockito.mock(AmazonS3.class);
   Mockito.when(region.aws()).thenReturn(aws);
   final String name = "non.existing.bucket.com";
   Mockito.when(aws.doesBucketExist(name)).thenReturn(false);
   final Bucket bucket = new AwsBucket(region, name);
   Assert.assertFalse(bucket.exists());
 }
예제 #2
0
 /**
  * AwsBucket can throw a proper exception.
  *
  * @throws IOException If succeeds
  */
 @Test(expected = IOException.class)
 public void existsThrowsIOException() throws IOException {
   final Region region = Mockito.mock(Region.class);
   final AmazonS3 aws = Mockito.mock(AmazonS3.class);
   Mockito.when(region.aws()).thenReturn(aws);
   final String name = "throwing.bucket.com";
   Mockito.when(aws.doesBucketExist(name)).thenThrow(new AmazonServiceException("Test exception"));
   final Bucket bucket = new AwsBucket(region, name);
   bucket.exists();
 }
예제 #3
0
 /**
  * Make AWS.
  *
  * @param region Region
  * @return AWS
  */
 private static AmazonS3 mockAws(final Region region) {
   final AmazonS3 aws = Mockito.mock(AmazonS3.class);
   Mockito.when(region.aws()).thenReturn(aws);
   return aws;
 }