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 2015/06/21 15:43:08 UTC
[2/2] camel git commit: Camel-AWS EC2 improve producer tests
Camel-AWS EC2 improve producer tests
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/d769cba8
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/d769cba8
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/d769cba8
Branch: refs/heads/master
Commit: d769cba8da18d4841b31231687a7d997897f53fa
Parents: f1c608a
Author: Andrea Cosentino <an...@gmail.com>
Authored: Sun Jun 21 15:40:00 2015 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Sun Jun 21 15:41:20 2015 +0200
----------------------------------------------------------------------
.../component/aws/ec2/EC2ProducerTest.java | 84 ++++++++++++++++++++
1 file changed, 84 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/d769cba8/components/camel-aws/src/test/java/org/apache/camel/component/aws/ec2/EC2ProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-aws/src/test/java/org/apache/camel/component/aws/ec2/EC2ProducerTest.java b/components/camel-aws/src/test/java/org/apache/camel/component/aws/ec2/EC2ProducerTest.java
index 2e53781..c04b400 100644
--- a/components/camel-aws/src/test/java/org/apache/camel/component/aws/ec2/EC2ProducerTest.java
+++ b/components/camel-aws/src/test/java/org/apache/camel/component/aws/ec2/EC2ProducerTest.java
@@ -99,6 +99,90 @@ public class EC2ProducerTest extends CamelTestSupport {
}
@Test
+ public void ec2CreateAndRunImageIdNotSpecifiedTest() throws Exception {
+
+ mock.expectedMessageCount(0);
+ Exchange exchange = template.request("direct:createAndRun", new Processor() {
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ exchange.getIn().setHeader(EC2Constants.OPERATION, EC2Operations.createAndRunInstances);
+ exchange.getIn().setHeader(EC2Constants.INSTANCE_TYPE, InstanceType.T2Micro);
+ exchange.getIn().setHeader(EC2Constants.INSTANCE_MIN_COUNT, 1);
+ exchange.getIn().setHeader(EC2Constants.INSTANCE_MAX_COUNT, 1);
+ }
+ });
+
+ assertMockEndpointsSatisfied();
+
+ assertTrue("Should be failed", exchange.isFailed());
+ assertTrue("Should be IllegalArgumentException", exchange.getException() instanceof IllegalArgumentException);
+ assertEquals("AMI must be specified", exchange.getException().getMessage());
+ }
+
+ @Test
+ public void ec2CreateAndRunInstanceTypeNotSpecifiedTest() throws Exception {
+
+ mock.expectedMessageCount(0);
+ Exchange exchange = template.request("direct:createAndRun", new Processor() {
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ exchange.getIn().setHeader(EC2Constants.OPERATION, EC2Operations.createAndRunInstances);
+ exchange.getIn().setHeader(EC2Constants.IMAGE_ID, "test-1");
+ exchange.getIn().setHeader(EC2Constants.INSTANCE_MIN_COUNT, 1);
+ exchange.getIn().setHeader(EC2Constants.INSTANCE_MAX_COUNT, 1);
+ }
+ });
+
+ assertMockEndpointsSatisfied();
+
+ assertTrue("Should be failed", exchange.isFailed());
+ assertTrue("Should be IllegalArgumentException", exchange.getException() instanceof IllegalArgumentException);
+ assertEquals("Instance Type must be specified", exchange.getException().getMessage());
+ }
+
+ @Test
+ public void ec2CreateAndRunMinCountNotSpecifiedTest() throws Exception {
+
+ mock.expectedMessageCount(0);
+ Exchange exchange = template.request("direct:createAndRun", new Processor() {
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ exchange.getIn().setHeader(EC2Constants.OPERATION, EC2Operations.createAndRunInstances);
+ exchange.getIn().setHeader(EC2Constants.IMAGE_ID, "test-1");
+ exchange.getIn().setHeader(EC2Constants.INSTANCE_TYPE, InstanceType.T2Micro);
+ exchange.getIn().setHeader(EC2Constants.INSTANCE_MAX_COUNT, 1);
+ }
+ });
+
+ assertMockEndpointsSatisfied();
+
+ assertTrue("Should be failed", exchange.isFailed());
+ assertTrue("Should be IllegalArgumentException", exchange.getException() instanceof IllegalArgumentException);
+ assertEquals("Min instances count must be specified", exchange.getException().getMessage());
+ }
+
+ @Test
+ public void ec2CreateAndRunMaxCountNotSpecifiedTest() throws Exception {
+
+ mock.expectedMessageCount(0);
+ Exchange exchange = template.request("direct:createAndRun", new Processor() {
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ exchange.getIn().setHeader(EC2Constants.OPERATION, EC2Operations.createAndRunInstances);
+ exchange.getIn().setHeader(EC2Constants.IMAGE_ID, "test-1");
+ exchange.getIn().setHeader(EC2Constants.INSTANCE_TYPE, InstanceType.T2Micro);
+ exchange.getIn().setHeader(EC2Constants.INSTANCE_MIN_COUNT, 1);
+ }
+ });
+
+ assertMockEndpointsSatisfied();
+
+ assertTrue("Should be failed", exchange.isFailed());
+ assertTrue("Should be IllegalArgumentException", exchange.getException() instanceof IllegalArgumentException);
+ assertEquals("Max instances count must be specified", exchange.getException().getMessage());
+ }
+
+ @Test
public void ec2CreateAndRunTestWithKeyPair() throws Exception {
mock.expectedMessageCount(1);