Repository: camel Updated Branches: refs/heads/camel-2.19.x f54374616 -> 92a71ae75 refs/heads/master f2e425e6a -> 819f8f4eb
CAMEL-11489: Remove mandatory nature of amazonS3Client when accessKey and secretKey are provided Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/819f8f4e Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/819f8f4e Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/819f8f4e Branch: refs/heads/master Commit: 819f8f4eb61d6b548dbf93a434fc69a7506c24ff Parents: f2e425e Author: Thomas Demande <[email protected]> Authored: Sat Jul 1 15:19:14 2017 +0200 Committer: Thomas Demande <[email protected]> Committed: Sat Jul 1 15:19:14 2017 +0200 ---------------------------------------------------------------------- .../camel/component/aws/s3/S3Component.java | 4 ++-- .../aws/s3/S3ComponentConfigurationTest.java | 20 +++++++++++++++++++- 2 files changed, 21 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/819f8f4e/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Component.java ---------------------------------------------------------------------- diff --git a/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Component.java b/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Component.java index 8bdd994..a481267 100644 --- a/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Component.java +++ b/components/camel-aws/src/main/java/org/apache/camel/component/aws/s3/S3Component.java @@ -44,8 +44,8 @@ public class S3Component extends UriEndpointComponent { } configuration.setBucketName(remaining); - if (configuration.getAmazonS3Client() == null) { - throw new IllegalArgumentException("AmazonS3Client must be specified"); + if (configuration.getAmazonS3Client() == null && (configuration.getAccessKey() == null || configuration.getSecretKey() == null)) { + throw new IllegalArgumentException("AmazonS3Client or accessKey and secretKey must be specified"); } S3Endpoint endpoint = new S3Endpoint(uri, this, configuration); http://git-wip-us.apache.org/repos/asf/camel/blob/819f8f4e/components/camel-aws/src/test/java/org/apache/camel/component/aws/s3/S3ComponentConfigurationTest.java ---------------------------------------------------------------------- diff --git a/components/camel-aws/src/test/java/org/apache/camel/component/aws/s3/S3ComponentConfigurationTest.java b/components/camel-aws/src/test/java/org/apache/camel/component/aws/s3/S3ComponentConfigurationTest.java index 40185b5..39ec751 100644 --- a/components/camel-aws/src/test/java/org/apache/camel/component/aws/s3/S3ComponentConfigurationTest.java +++ b/components/camel-aws/src/test/java/org/apache/camel/component/aws/s3/S3ComponentConfigurationTest.java @@ -24,7 +24,7 @@ import org.junit.Test; public class S3ComponentConfigurationTest extends CamelTestSupport { @Test - public void createEndpointWithMinimalConfiguration() throws Exception { + public void createEndpointWithMinimalS3ClientConfiguration() throws Exception { AmazonS3ClientMock mock = new AmazonS3ClientMock(); ((JndiRegistry) ((PropertyPlaceholderDelegateRegistry) context.getRegistry()).getRegistry()).bind("amazonS3Client", mock); @@ -46,6 +46,24 @@ public class S3ComponentConfigurationTest extends CamelTestSupport { } @Test + public void createEndpointWithMinimalCredentialsConfiguration() throws Exception { + S3Component component = new S3Component(context); + S3Endpoint endpoint = (S3Endpoint) component.createEndpoint("aws-s3://MyBucket?accessKey=xxx&secretKey=yyy"); + + assertEquals("MyBucket", endpoint.getConfiguration().getBucketName()); + assertEquals("xxx", endpoint.getConfiguration().getAccessKey()); + assertEquals("yyy", endpoint.getConfiguration().getSecretKey()); + assertNull(endpoint.getConfiguration().getAmazonS3Client()); + assertNull(endpoint.getConfiguration().getRegion()); + assertTrue(endpoint.getConfiguration().isDeleteAfterRead()); + assertEquals(10, endpoint.getMaxMessagesPerPoll()); + assertNull(endpoint.getConfiguration().getAmazonS3Endpoint()); + assertNull(endpoint.getConfiguration().getPolicy()); + assertNull(endpoint.getConfiguration().getPrefix()); + assertTrue(endpoint.getConfiguration().isIncludeBody()); + } + + @Test public void createEndpointWithMinimalArnConfiguration() throws Exception { AmazonS3ClientMock mock = new AmazonS3ClientMock();
