Search in sources :

Example 1 with S3MockClientFactory

use of com.nextdoor.bender.aws.S3MockClientFactory in project bender by Nextdoor.

the class SNSS3HandlerTest method setup.

@Override
public void setup() {
    /*
     * Patch the handler to use this test's factory which produces a mock client.
     */
    S3MockClientFactory f;
    try {
        f = new S3MockClientFactory(tmpFolder);
    } catch (Exception e) {
        throw new RuntimeException("unable to start s3proxy", e);
    }
    this.clientFactory = f;
    this.client = f.newInstance();
}
Also used : S3MockClientFactory(com.nextdoor.bender.aws.S3MockClientFactory)

Example 2 with S3MockClientFactory

use of com.nextdoor.bender.aws.S3MockClientFactory in project bender by Nextdoor.

the class GeoIpOperationFactoryTest method setup.

@Before
public void setup() {
    /*
     * Patch the handler to use this test's factory which produces a mock client.
     */
    S3MockClientFactory f;
    try {
        f = new S3MockClientFactory(tmpFolder);
    } catch (Exception e) {
        throw new RuntimeException("unable to start s3proxy", e);
    }
    this.clientFactory = f;
    this.client = f.newInstance();
    /*
     * Populate S3
     */
    this.client.createBucket(BUCKET);
    InputStream is = this.getClass().getResourceAsStream("my-ip-data.mmdb");
    this.client.putObject(BUCKET, "my-ip-data.mmdb", is, new ObjectMetadata());
    this.opFactory = new GeoIpOperationFactory();
    this.opFactory.s3Factory = this.clientFactory;
}
Also used : InputStream(java.io.InputStream) S3MockClientFactory(com.nextdoor.bender.aws.S3MockClientFactory) ObjectMetadata(com.amazonaws.services.s3.model.ObjectMetadata) Before(org.junit.Before)

Example 3 with S3MockClientFactory

use of com.nextdoor.bender.aws.S3MockClientFactory in project bender by Nextdoor.

the class BaseHandlerS3Test method setup.

@Before
public void setup() throws UnsupportedEncodingException, IOException {
    /*
     * Patch the handler to use this test's factory which produces a mock client.
     */
    S3MockClientFactory f;
    try {
        f = new S3MockClientFactory(tmpFolder);
    } catch (Exception e) {
        throw new RuntimeException("unable to start s3proxy", e);
    }
    AmazonS3Client client = f.newInstance();
    client.createBucket(S3_BUCKET);
    this.clientFactory = f;
    /*
     * Upload config file
     */
    String payload = IOUtils.toString(new InputStreamReader(this.getClass().getResourceAsStream("/config/handler_config.json"), "UTF-8"));
    client.putObject(S3_BUCKET, "bender/config.json", payload);
    /*
     * Export config file as env var
     */
    envVars.set("BENDER_CONFIG", "s3://" + S3_BUCKET + "/bender/config.json");
}
Also used : AmazonS3Client(com.amazonaws.services.s3.AmazonS3Client) InputStreamReader(java.io.InputStreamReader) S3MockClientFactory(com.nextdoor.bender.aws.S3MockClientFactory) IOException(java.io.IOException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) Before(org.junit.Before)

Example 4 with S3MockClientFactory

use of com.nextdoor.bender.aws.S3MockClientFactory in project bender by Nextdoor.

the class S3HandlerTest method setup.

@Override
public void setup() {
    /*
     * Patch the handler to use this test's factory which produces a mock client.
     */
    S3MockClientFactory f;
    try {
        f = new S3MockClientFactory(tmpFolder);
    } catch (Exception e) {
        throw new RuntimeException("unable to start s3proxy", e);
    }
    this.clientFactory = f;
    this.client = f.newInstance();
}
Also used : S3MockClientFactory(com.nextdoor.bender.aws.S3MockClientFactory)

Aggregations

S3MockClientFactory (com.nextdoor.bender.aws.S3MockClientFactory)4 Before (org.junit.Before)2 AmazonS3Client (com.amazonaws.services.s3.AmazonS3Client)1 ObjectMetadata (com.amazonaws.services.s3.model.ObjectMetadata)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1