This is an automated email from the ASF dual-hosted git repository. acosentino pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git
commit 6780428dba4aef6f80644c4e0318519f4ac279a3 Author: Andrea Cosentino <[email protected]> AuthorDate: Tue Nov 17 15:19:48 2020 +0100 CAMEL-15836 - Camel-AWS2-SES: enable autowire on the SES Client, fixed tests --- .../apache/camel/component/aws2/ses/Ses2Component.java | 18 ------------------ .../aws2/ses/SESComponentClientRegistryTest.java | 5 +++-- 2 files changed, 3 insertions(+), 20 deletions(-) diff --git a/components/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Component.java b/components/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Component.java index e7ce05b..a6fcc48 100644 --- a/components/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Component.java +++ b/components/camel-aws2-ses/src/main/java/org/apache/camel/component/aws2/ses/Ses2Component.java @@ -17,17 +17,14 @@ package org.apache.camel.component.aws2.ses; import java.util.Map; -import java.util.Set; import org.apache.camel.CamelContext; import org.apache.camel.Endpoint; import org.apache.camel.spi.Metadata; import org.apache.camel.spi.annotations.Component; import org.apache.camel.support.DefaultComponent; -import org.apache.camel.util.ObjectHelper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import software.amazon.awssdk.services.ses.SesClient; /** * For working with Amazon ECS SDK v2. @@ -78,19 +75,4 @@ public class Ses2Component extends DefaultComponent { public void setConfiguration(Ses2Configuration configuration) { this.configuration = configuration; } - - private void checkAndSetRegistryClient(Ses2Configuration configuration, Ses2Endpoint endpoint) { - if (ObjectHelper.isEmpty(endpoint.getConfiguration().getAmazonSESClient())) { - LOG.debug("Looking for an SesClient instance in the registry"); - Set<SesClient> clients = getCamelContext().getRegistry().findByType(SesClient.class); - if (clients.size() == 1) { - LOG.debug("Found exactly one SesClient instance in the registry"); - configuration.setAmazonSESClient(clients.stream().findFirst().get()); - } else { - LOG.debug("No SesClient instance in the registry"); - } - } else { - LOG.debug("SesClient instance is already set at endpoint level: skipping the check in the registry"); - } - } } diff --git a/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/SESComponentClientRegistryTest.java b/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/SESComponentClientRegistryTest.java index 0e64724..80e1141 100644 --- a/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/SESComponentClientRegistryTest.java +++ b/components/camel-aws2-ses/src/test/java/org/apache/camel/component/aws2/ses/SESComponentClientRegistryTest.java @@ -29,8 +29,9 @@ public class SESComponentClientRegistryTest extends CamelTestSupport { AmazonSESClientMock awsSESClient = new AmazonSESClientMock(); context.getRegistry().bind("awsSesClient", awsSESClient); - Ses2Component component = new Ses2Component(context); - Ses2Endpoint endpoint = (Ses2Endpoint) component.createEndpoint("aws2-ses://[email protected]?accessKey=xxx&secretKey=yyy"); + Ses2Component component = context.getComponent("aws2-ses", Ses2Component.class); + Ses2Endpoint endpoint + = (Ses2Endpoint) component.createEndpoint("aws2-ses://[email protected]"); assertNotNull(endpoint.getConfiguration().getAmazonSESClient()); }
