Search in sources :

Example 1 with S3Region

use of org.talend.components.simplefileio.s3.S3Region in project components by Talend.

the class S3DatasetRuntimeTestIT method listBuckets.

@Test
@Ignore("It's slow (10 or more mins), our account doesn't allow to create this amount of buckets")
public void listBuckets() {
    String uuid = UUID.randomUUID().toString().substring(0, 8);
    String bucketFormat = "tcomp-s3-dataset-test-%s-" + uuid;
    S3DatasetProperties s3DatasetProperties = s3.createS3DatasetProperties();
    runtime.initialize(null, s3DatasetProperties);
    AmazonS3 client = S3Connection.createClient(s3.createS3DatastoreProperties());
    for (S3Region s3Region : getTestableS3Regions()) {
        client.setEndpoint(s3Region.toEndpoint());
        if (s3Region.equals(S3Region.US_EAST_1)) {
            client.createBucket(String.format(bucketFormat, s3Region.getValue()));
        } else {
            client.createBucket(String.format(bucketFormat, s3Region.getValue()), s3Region.getValue());
        }
        s3DatasetProperties.region.setValue(s3Region);
        Set<String> bucketNames = runtime.listBuckets();
        assertTrue(bucketNames.size() > 0);
        assertThat(bucketNames, hasItems(String.format(bucketFormat, s3Region.getValue())));
        client.setEndpoint(s3Region.toEndpoint());
        client.deleteBucket(String.format(bucketFormat, s3Region.getValue()));
    }
}
Also used : AmazonS3(com.talend.shaded.com.amazonaws.services.s3.AmazonS3) S3DatasetProperties(org.talend.components.simplefileio.s3.S3DatasetProperties) S3Region(org.talend.components.simplefileio.s3.S3Region) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

AmazonS3 (com.talend.shaded.com.amazonaws.services.s3.AmazonS3)1 Ignore (org.junit.Ignore)1 Test (org.junit.Test)1 S3DatasetProperties (org.talend.components.simplefileio.s3.S3DatasetProperties)1 S3Region (org.talend.components.simplefileio.s3.S3Region)1