use of com.amazonaws.services.s3.model.PutObjectRequest in project camel by apache.
the class S3ComponentExistingBucketTest method sendCustomHeaderValues.
@Test
public void sendCustomHeaderValues() throws Exception {
result.expectedMessageCount(1);
final Date now = new Date();
final Map<String, String> userMetadata = new HashMap<String, String>();
userMetadata.put("CamelName", "Camel");
final Map<String, String> s3Headers = new HashMap<String, String>();
s3Headers.put("x-aws-s3-header", "extra");
Exchange exchange = template.send("direct:start", ExchangePattern.InOnly, new Processor() {
public void process(Exchange exchange) throws Exception {
exchange.getIn().setHeader(S3Constants.STORAGE_CLASS, "STANDARD");
exchange.getIn().setHeader(S3Constants.KEY, "CamelUnitTest");
exchange.getIn().setHeader(S3Constants.CONTENT_LENGTH, 2L);
exchange.getIn().setHeader(S3Constants.CONTENT_TYPE, "text/html");
exchange.getIn().setHeader(S3Constants.CACHE_CONTROL, "no-cache");
exchange.getIn().setHeader(S3Constants.CONTENT_DISPOSITION, "attachment;");
exchange.getIn().setHeader(S3Constants.CONTENT_ENCODING, "gzip");
exchange.getIn().setHeader(S3Constants.CONTENT_MD5, "TWF");
exchange.getIn().setHeader(S3Constants.LAST_MODIFIED, now);
exchange.getIn().setHeader(S3Constants.USER_METADATA, userMetadata);
exchange.getIn().setHeader(S3Constants.S3_HEADERS, s3Headers);
exchange.getIn().setBody("This is my bucket content.");
}
});
assertMockEndpointsSatisfied();
assertResultExchange(result.getExchanges().get(0));
PutObjectRequest putObjectRequest = client.putObjectRequests.get(0);
assertEquals("STANDARD", putObjectRequest.getStorageClass());
assertEquals("mycamelbucket", putObjectRequest.getBucketName());
assertEquals(2L, putObjectRequest.getMetadata().getContentLength());
assertEquals("text/html", putObjectRequest.getMetadata().getContentType());
assertEquals("no-cache", putObjectRequest.getMetadata().getCacheControl());
assertEquals("attachment;", putObjectRequest.getMetadata().getContentDisposition());
assertEquals("gzip", putObjectRequest.getMetadata().getContentEncoding());
assertEquals("TWF", putObjectRequest.getMetadata().getContentMD5());
assertEquals(now, putObjectRequest.getMetadata().getLastModified());
assertEquals(userMetadata, putObjectRequest.getMetadata().getUserMetadata());
assertEquals("extra", putObjectRequest.getMetadata().getRawMetadataValue("x-aws-s3-header"));
assertResponseMessage(exchange.getIn());
}
use of com.amazonaws.services.s3.model.PutObjectRequest in project camel by apache.
the class S3ComponentExistingBucketTest method sendInOut.
@Test
public void sendInOut() throws Exception {
result.expectedMessageCount(1);
Exchange exchange = template.send("direct:start", ExchangePattern.InOut, new Processor() {
public void process(Exchange exchange) throws Exception {
exchange.getIn().setHeader(S3Constants.KEY, "CamelUnitTest");
exchange.getIn().setBody("This is my bucket content.");
}
});
assertMockEndpointsSatisfied();
assertResultExchange(result.getExchanges().get(0));
PutObjectRequest putObjectRequest = client.putObjectRequests.get(0);
assertEquals("REDUCED_REDUNDANCY", putObjectRequest.getStorageClass());
assertEquals("mycamelbucket", putObjectRequest.getBucketName());
assertResponseMessage(exchange.getOut());
}
use of com.amazonaws.services.s3.model.PutObjectRequest in project camel by apache.
the class S3ComponentFileTest method sendFile.
@Test
public void sendFile() throws Exception {
result.expectedMessageCount(1);
Exchange exchange = templateKeep.send("direct:startKeep", ExchangePattern.InOnly, new Processor() {
public void process(Exchange exchange) throws Exception {
exchange.getIn().setHeader(S3Constants.KEY, "CamelUnitTest");
exchange.getIn().setBody(testFile);
}
});
assertMockEndpointsSatisfied();
assertResultExchange(result.getExchanges().get(0), true);
PutObjectRequest putObjectRequest = client.putObjectRequests.get(0);
assertEquals(getCamelBucket(), putObjectRequest.getBucketName());
assertResponseMessage(exchange.getIn());
assertFileExists(testFile.getAbsolutePath());
}
use of com.amazonaws.services.s3.model.PutObjectRequest in project camel by apache.
the class S3ComponentNonExistingBucketTest method sendInOnly.
@Test
public void sendInOnly() throws Exception {
result.expectedMessageCount(1);
Exchange exchange = template.send("direct:start", ExchangePattern.InOnly, new Processor() {
public void process(Exchange exchange) throws Exception {
exchange.getIn().setHeader(S3Constants.KEY, "CamelUnitTest");
exchange.getIn().setBody("This is my bucket content.");
}
});
assertMockEndpointsSatisfied();
assertResultExchange(result.getExchanges().get(0));
PutObjectRequest putObjectRequest = client.putObjectRequests.get(0);
assertEquals("REDUCED_REDUNDANCY", putObjectRequest.getStorageClass());
assertEquals("nonExistingBucket", putObjectRequest.getBucketName());
assertResponseMessage(exchange.getIn());
}
use of com.amazonaws.services.s3.model.PutObjectRequest in project camel by apache.
the class S3ComponentNonExistingBucketTest method sendInOut.
@Test
public void sendInOut() throws Exception {
result.expectedMessageCount(1);
Exchange exchange = template.send("direct:start", ExchangePattern.InOut, new Processor() {
public void process(Exchange exchange) throws Exception {
exchange.getIn().setHeader(S3Constants.KEY, "CamelUnitTest");
exchange.getIn().setBody("This is my bucket content.");
}
});
assertMockEndpointsSatisfied();
assertResultExchange(result.getExchanges().get(0));
PutObjectRequest putObjectRequest = client.putObjectRequests.get(0);
assertEquals("REDUCED_REDUNDANCY", putObjectRequest.getStorageClass());
assertEquals("nonExistingBucket", putObjectRequest.getBucketName());
assertResponseMessage(exchange.getOut());
}
Aggregations