You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2020/04/09 11:01:59 UTC

[camel] 10/10: CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-ec2 added a little test

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 504fef7ddf04c944190b7aaedc50dc677229b5a6
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu Apr 9 12:28:52 2020 +0200

    CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-ec2 added a little test
---
 .../camel/component/aws2/ec2/EC2ProducerTest.java      | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/components/camel-aws2-ec2/src/test/java/org/apache/camel/component/aws2/ec2/EC2ProducerTest.java b/components/camel-aws2-ec2/src/test/java/org/apache/camel/component/aws2/ec2/EC2ProducerTest.java
index 795a0f9..0dc321e 100644
--- a/components/camel-aws2-ec2/src/test/java/org/apache/camel/component/aws2/ec2/EC2ProducerTest.java
+++ b/components/camel-aws2-ec2/src/test/java/org/apache/camel/component/aws2/ec2/EC2ProducerTest.java
@@ -33,6 +33,7 @@ import software.amazon.awssdk.services.ec2.model.InstanceStateName;
 import software.amazon.awssdk.services.ec2.model.InstanceType;
 import software.amazon.awssdk.services.ec2.model.MonitorInstancesResponse;
 import software.amazon.awssdk.services.ec2.model.MonitoringState;
+import software.amazon.awssdk.services.ec2.model.RunInstancesRequest;
 import software.amazon.awssdk.services.ec2.model.RunInstancesResponse;
 import software.amazon.awssdk.services.ec2.model.StartInstancesResponse;
 import software.amazon.awssdk.services.ec2.model.StopInstancesResponse;
@@ -67,6 +68,22 @@ public class EC2ProducerTest extends CamelTestSupport {
         assertEquals(resultGet.instances().get(0).instanceType(), InstanceType.T2_MICRO);
         assertEquals(resultGet.instances().get(0).instanceId(), "instance-1");
     }
+    
+    @Test
+    public void createAndRunInstancesPojo() {
+
+        Exchange exchange = template.request("direct:createAndRunPojo", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(AWS2EC2Constants.OPERATION, AWS2EC2Operations.createAndRunInstances);
+                exchange.getIn().setBody(RunInstancesRequest.builder().imageId("test-1").instanceType(InstanceType.T2_MICRO).build());
+            }
+        });
+
+        RunInstancesResponse resultGet = (RunInstancesResponse)exchange.getMessage().getBody();
+        assertEquals(resultGet.instances().get(0).imageId(), "test-1");
+        assertEquals(resultGet.instances().get(0).instanceType(), InstanceType.T2_MICRO);
+        assertEquals(resultGet.instances().get(0).instanceId(), "instance-1");
+    }
 
     @Test
     public void ec2CreateAndRunTestWithKeyPair() throws Exception {
@@ -244,6 +261,7 @@ public class EC2ProducerTest extends CamelTestSupport {
             @Override
             public void configure() throws Exception {
                 from("direct:createAndRun").to("aws2-ec2://test?amazonEc2Client=#amazonEc2Client&operation=createAndRunInstances").to("mock:result");
+                from("direct:createAndRunPojo").to("aws2-ec2://test?amazonEc2Client=#amazonEc2Client&operation=createAndRunInstances&pojoRequest=true").to("mock:result");
                 from("direct:start").to("aws2-ec2://test?amazonEc2Client=#amazonEc2Client&operation=startInstances").to("mock:result");
                 from("direct:stop").to("aws2-ec2://test?amazonEc2Client=#amazonEc2Client&operation=stopInstances").to("mock:result");
                 from("direct:terminate").to("aws2-ec2://test?amazonEc2Client=#amazonEc2Client&operation=terminateInstances").to("mock:result");