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/28 16:06:55 UTC
[6/6] camel git commit: CAMEL-8910 Camel-JClouds: Add new operations
to JClouds Compute Service Producer, add resumeNode test
CAMEL-8910 Camel-JClouds: Add new operations to JClouds Compute Service Producer, add resumeNode test
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/b7794510
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/b7794510
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/b7794510
Branch: refs/heads/master
Commit: b7794510463f86452d4524b70135f36d343197d4
Parents: 8c640f5
Author: Andrea Cosentino <an...@gmail.com>
Authored: Sun Jun 28 15:36:21 2015 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Sun Jun 28 16:04:44 2015 +0200
----------------------------------------------------------------------
.../jclouds/JcloudsComputeProducer.java | 4 +-
.../jclouds/JcloudsSpringComputeTest.java | 67 ++++++++++----------
.../src/test/resources/compute-test.xml | 6 --
3 files changed, 37 insertions(+), 40 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/b7794510/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsComputeProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsComputeProducer.java b/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsComputeProducer.java
index 3714ce2..c6ce1c2 100644
--- a/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsComputeProducer.java
+++ b/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsComputeProducer.java
@@ -70,9 +70,9 @@ public class JcloudsComputeProducer extends JcloudsProducer {
} else if (JcloudsConstants.REBOOT_NODE.equals(operation)) {
rebootNode(exchange);
} else if (JcloudsConstants.SUSPEND_NODE.equals(operation)) {
- suspendNode(exchange);
+ suspendNode(exchange);
} else if (JcloudsConstants.RESUME_NODE.equals(operation)) {
- resumeNode(exchange);
+ resumeNode(exchange);
}
}
http://git-wip-us.apache.org/repos/asf/camel/blob/b7794510/components/camel-jclouds/src/test/java/org/apache/camel/component/jclouds/JcloudsSpringComputeTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jclouds/src/test/java/org/apache/camel/component/jclouds/JcloudsSpringComputeTest.java b/components/camel-jclouds/src/test/java/org/apache/camel/component/jclouds/JcloudsSpringComputeTest.java
index 7baef0a..3b5cbad 100644
--- a/components/camel-jclouds/src/test/java/org/apache/camel/component/jclouds/JcloudsSpringComputeTest.java
+++ b/components/camel-jclouds/src/test/java/org/apache/camel/component/jclouds/JcloudsSpringComputeTest.java
@@ -175,23 +175,6 @@ public class JcloudsSpringComputeTest extends CamelSpringTestSupport {
}
}
}
-
- resultlist.expectedMessageCount(1);
- template.sendBodyAndHeaders("direct:nodelist",null, listNodeHeaders("1", "default", "RUNNING"));
- resultlist.assertIsSatisfied();
-
- List<Exchange> exchangesNodeList = resultlist.getExchanges();
- if (exchangesNodeList != null && !exchangesNodeList.isEmpty()) {
- for (Exchange exchange : exchangesNodeList) {
- Set<?> nodeMetadatas = exchange.getIn().getBody(Set.class);
- assertEquals("There should be one node running", 1, nodeMetadatas.size());
-
- for (Object obj : nodeMetadatas) {
- NodeMetadata nodeMetadata = (NodeMetadata) obj;
- assertEquals(nodeMetadata.getId(), "1");
- }
- }
- }
}
@Test
@@ -212,26 +195,28 @@ public class JcloudsSpringComputeTest extends CamelSpringTestSupport {
}
}
}
-
- resultlist.expectedMessageCount(1);
- template.sendBodyAndHeaders("direct:nodelist",null, listNodeHeaders("1", "default", "SUSPENDED"));
- resultlist.assertIsSatisfied();
-
- List<Exchange> exchangesNodeList = resultlist.getExchanges();
- if (exchangesNodeList != null && !exchangesNodeList.isEmpty()) {
- for (Exchange exchange : exchangesNodeList) {
+ }
+
+ @Test
+ public void testCreateSuspendAndResumeNode() throws InterruptedException {
+ result.expectedMessageCount(1);
+ template.sendBodyAndHeaders("direct:start", null, createHeaders("1", "default"));
+ result.assertIsSatisfied();
+
+ List<Exchange> exchanges = result.getExchanges();
+ if (exchanges != null && !exchanges.isEmpty()) {
+ for (Exchange exchange : exchanges) {
Set<?> nodeMetadatas = exchange.getIn().getBody(Set.class);
- assertEquals("There should be one node suspended", 1, nodeMetadatas.size());
+ assertEquals("There should be one node running", 1, nodeMetadatas.size());
for (Object obj : nodeMetadatas) {
NodeMetadata nodeMetadata = (NodeMetadata) obj;
- assertEquals(nodeMetadata.getId(), "1");
+ template.sendBodyAndHeaders("direct:start", null, resumeHeaders(nodeMetadata.getId(), null));
}
}
}
}
-
@SuppressWarnings("unchecked")
@Ignore("For now not possible to combine stub provider with ssh module, required for runScript")
@Test
@@ -316,10 +301,10 @@ public class JcloudsSpringComputeTest extends CamelSpringTestSupport {
Map<String, Object> rebootHeaders = new HashMap<String, Object>();
rebootHeaders.put(JcloudsConstants.OPERATION, JcloudsConstants.REBOOT_NODE);
if (nodeId != null) {
- rebootHeaders.put(JcloudsConstants.NODE_ID, nodeId);
+ rebootHeaders.put(JcloudsConstants.NODE_ID, nodeId);
}
if (group != null) {
- rebootHeaders.put(JcloudsConstants.GROUP, group);
+ rebootHeaders.put(JcloudsConstants.GROUP, group);
}
return rebootHeaders;
}
@@ -334,10 +319,28 @@ public class JcloudsSpringComputeTest extends CamelSpringTestSupport {
Map<String, Object> rebootHeaders = new HashMap<String, Object>();
rebootHeaders.put(JcloudsConstants.OPERATION, JcloudsConstants.SUSPEND_NODE);
if (nodeId != null) {
- rebootHeaders.put(JcloudsConstants.NODE_ID, nodeId);
+ rebootHeaders.put(JcloudsConstants.NODE_ID, nodeId);
+ }
+ if (group != null) {
+ rebootHeaders.put(JcloudsConstants.GROUP, group);
+ }
+ return rebootHeaders;
+ }
+
+ /**
+ * Returns a {@Map} with the suspend headers.
+ *
+ * @param nodeId The id of the node to resume.
+ * @param group The group of the node to resume.
+ */
+ protected Map<String, Object> resumeHeaders(String nodeId, String group) {
+ Map<String, Object> rebootHeaders = new HashMap<String, Object>();
+ rebootHeaders.put(JcloudsConstants.OPERATION, JcloudsConstants.RESUME_NODE);
+ if (nodeId != null) {
+ rebootHeaders.put(JcloudsConstants.NODE_ID, nodeId);
}
if (group != null) {
- rebootHeaders.put(JcloudsConstants.GROUP, group);
+ rebootHeaders.put(JcloudsConstants.GROUP, group);
}
return rebootHeaders;
}
http://git-wip-us.apache.org/repos/asf/camel/blob/b7794510/components/camel-jclouds/src/test/resources/compute-test.xml
----------------------------------------------------------------------
diff --git a/components/camel-jclouds/src/test/resources/compute-test.xml b/components/camel-jclouds/src/test/resources/compute-test.xml
index a71ffad..e8c1997 100644
--- a/components/camel-jclouds/src/test/resources/compute-test.xml
+++ b/components/camel-jclouds/src/test/resources/compute-test.xml
@@ -28,12 +28,6 @@
<to uri="jclouds:compute:stub?operation=CamelJcloudsListImages&nodeState=RUNNING"/>
<to uri="mock:result"/>
</route>
-
- <route>
- <from uri="direct:nodelist"/>
- <to uri="jclouds:compute:stub?operation=CamelJcloudsListImage"/>
- <to uri="mock:resultlist"/>
- </route>
<route>
<from uri="direct:in-out"/>