Search in sources :

Example 66 with S3ObjectSummary

use of com.amazonaws.services.s3.model.S3ObjectSummary in project athenz by yahoo.

the class S3ChangeLogStoreTest method testGetServerDomains.

@Test
public void testGetServerDomains() {
    MockS3ChangeLogStore store = new MockS3ChangeLogStore(null);
    ArrayList<S3ObjectSummary> objectList = new ArrayList<>();
    S3ObjectSummary objectSummary = new S3ObjectSummary();
    objectSummary.setKey("iaas");
    objectList.add(objectSummary);
    objectSummary = new S3ObjectSummary();
    objectSummary.setKey("iaas.athenz");
    objectList.add(objectSummary);
    ObjectListing objectListing = mock(ObjectListing.class);
    when(objectListing.getObjectSummaries()).thenReturn(objectList);
    when(objectListing.isTruncated()).thenReturn(false);
    when(store.awsS3Client.listObjects(any(ListObjectsRequest.class))).thenReturn(objectListing);
    // verify that our last mod time is 0 before the call
    assertEquals(store.lastModTime, 0);
    // retrieve the list of domains
    Set<String> domains = store.getServerDomainList();
    assertEquals(domains.size(), 2);
    assertTrue(domains.contains("iaas"));
    assertTrue(domains.contains("iaas.athenz"));
    // also verify that last mod time is not updated
    assertEquals(store.lastModTime, 0);
}
Also used : ListObjectsRequest(com.amazonaws.services.s3.model.ListObjectsRequest) ArrayList(java.util.ArrayList) ObjectListing(com.amazonaws.services.s3.model.ObjectListing) S3ObjectSummary(com.amazonaws.services.s3.model.S3ObjectSummary) Test(org.testng.annotations.Test)

Aggregations

S3ObjectSummary (com.amazonaws.services.s3.model.S3ObjectSummary)60 ObjectListing (com.amazonaws.services.s3.model.ObjectListing)51 ArrayList (java.util.ArrayList)28 ListObjectsRequest (com.amazonaws.services.s3.model.ListObjectsRequest)24 DeleteObjectsRequest (com.amazonaws.services.s3.model.DeleteObjectsRequest)13 AmazonS3 (com.amazonaws.services.s3.AmazonS3)11 Test (org.testng.annotations.Test)9 AmazonS3Client (com.amazonaws.services.s3.AmazonS3Client)8 AmazonClientException (com.amazonaws.AmazonClientException)7 Path (org.apache.hadoop.fs.Path)7 AmazonServiceException (com.amazonaws.AmazonServiceException)6 DeleteObjectsResult (com.amazonaws.services.s3.model.DeleteObjectsResult)6 Properties (java.util.Properties)6 S3Object (com.amazonaws.services.s3.model.S3Object)4 IOException (java.io.IOException)4 HashMap (java.util.HashMap)4 Test (org.junit.Test)4 TransferManager (com.amazonaws.services.s3.transfer.TransferManager)3 Date (java.util.Date)3 HashSet (java.util.HashSet)3