lopushen opened a new pull request, #325:
URL: https://github.com/apache/camel-karaf/pull/325

   Fixes https://github.com/apache/camel-karaf/issues/324
   
   Motivation
   
   - During testing using an OSGI blueprint, it turned out that the 
camel-aws2-sns no missing bundles to successfully execute the route, but 
requires an integration test
   
   Modifications:
   
   - Add an integration test for camel-aws2-sns
   
   To run localstack (AWS emulator):
   `docker run --rm -it -p 4566:4566 -p 4510-4559:4510-4559 
localstack/localstack`
   In the emulator run
   `aws configure --profile localstack`
   and enter in the prompt:
   
   ```
   test
   test
   us-east-1
   json
   to get
   
   ```
   ```
   AWS Access Key ID [None]: test
   AWS Secret Access Key [None]: test
   Default region name [None]: us-east-1
   Default output format [None]: json
   ```
   Create an sns topic in the localstack
   `aws --endpoint-url=http://localhost:4566 sns create-topic --name my-topic 
--region us-east-1 --profile localstack`
   
   Add the repo and install the features:
   
   ```
   repo-add mvn:org.apache.camel.karaf/apache-camel/4.6.0-SNAPSHOT/xml/features
   feature:install camel-blueprint camel-aws2-sns
   ```
   Deploy the following blueprint (the endpoint is producer-only)
   
   ```
   <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0";
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
              
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0";
              xsi:schemaLocation="
                http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0 
http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.1.0.xsd
                http://www.osgi.org/xmlns/blueprint/v1.0.0 
https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
                http://camel.apache.org/schema/blueprint 
http://camel.apache.org/schema/blueprint/camel-blueprint.xsd";>
   
       <bean id="sns2Configuration" 
class="org.apache.camel.component.aws2.sns.Sns2Configuration">
           <property name="accessKey" value="test"/>
           <property name="secretKey" value="test"/>
           <property name="region" value="us-east-1"/>
           <property name="overrideEndpoint" value="true"/>
           <property name="uriEndpointOverride" value="http://localhost:4566"/>
       </bean>
   
       <bean id="aws2-sns" 
class="org.apache.camel.component.aws2.sns.Sns2Component">
           <property name="configuration" ref="sns2Configuration"/>
       </bean>
       <camelContext id="camel" 
xmlns="http://camel.apache.org/schema/blueprint";>
           <route id="sendSnsMessageRoute">
               <from uri="timer:sendEmailTimer?period=5000"/> 
               <setBody>
                   <constant>Hello, this is a test message from AWS 
sns!</constant>
               </setBody>
               <to uri="aws2-sns://MyTopic"/>
               <log message="Sent message: ${body}"/>
           </route>
       </camelContext>
   </blueprint>
   ```
   
   Observe the following output in Karaf:
   
   ```
   12:50:07.577 INFO [Camel (camel-5) thread #7 - timer://sendEmailTimer] Sent 
message: Hello, this is a test message from AWS sns!
   12:50:12.537 INFO [Camel (camel-5) thread #7 - timer://sendEmailTimer] Sent 
message: Hello, this is a test message from AWS sns!
   12:50:17.570 INFO [Camel (camel-5) thread #7 - timer://sendEmailTimer] Sent 
message: Hello, this is a test message from AWS sns!
   ```
   Observe the following output in localstack:
   ```
   2024-06-06 12:53:12 2024-06-06T09:53:12.676  INFO --- [et.reactor-1] 
localstack.request.aws     : AWS sns.Publish => 200
   2024-06-06 12:53:17 2024-06-06T09:53:17.702  INFO --- [et.reactor-2] 
localstack.request.aws     : AWS sns.Publish => 200
   2024-06-06 12:53:22 2024-06-06T09:53:22.681  INFO --- [et.reactor-4] 
localstack.request.aws     : AWS sns.Publish => 200
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to