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:51 UTC
[2/6] camel git commit: CAMEL-8910 Camel-JClouds: Add new operations
to JClouds Compute Service Producer, add rebootNode test
CAMEL-8910 Camel-JClouds: Add new operations to JClouds Compute Service Producer, add rebootNode test
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/422536bc
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/422536bc
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/422536bc
Branch: refs/heads/master
Commit: 422536bc9a3ea2c0a9a4cb983c881f7a19220596
Parents: 727d8b8
Author: Andrea Cosentino <an...@gmail.com>
Authored: Sun Jun 28 14:36:44 2015 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Sun Jun 28 15:09:46 2015 +0200
----------------------------------------------------------------------
.../jclouds/JcloudsComputeProducer.java | 2 +-
.../jclouds/JcloudsSpringComputeTest.java | 59 ++++++++++++++++++++
.../src/test/resources/compute-test.xml | 6 ++
3 files changed, 66 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/422536bc/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 4d96c37..e25cbbd 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
@@ -68,7 +68,7 @@ public class JcloudsComputeProducer extends JcloudsProducer {
} else if (JcloudsConstants.DESTROY_NODE.equals(operation)) {
destroyNode(exchange);
} else if (JcloudsConstants.REBOOT_NODE.equals(operation)) {
- destroyNode(exchange);
+ rebootNode(exchange);
}
}
http://git-wip-us.apache.org/repos/asf/camel/blob/422536bc/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 cbd1910..18fa1cc 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
@@ -37,6 +37,9 @@ public class JcloudsSpringComputeTest extends CamelSpringTestSupport {
@EndpointInject(uri = "mock:result")
protected MockEndpoint result;
+
+ @EndpointInject(uri = "mock:resultlist")
+ protected MockEndpoint resultlist;
@After
public void tearDown() throws Exception {
@@ -153,6 +156,44 @@ public class JcloudsSpringComputeTest extends CamelSpringTestSupport {
}
}
}
+
+ @Test
+ public void testCreateAndRebootNode() 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 running", 1, nodeMetadatas.size());
+
+ for (Object obj : nodeMetadatas) {
+ NodeMetadata nodeMetadata = (NodeMetadata) obj;
+ template.sendBodyAndHeaders("direct:start", null, rebootHeaders(nodeMetadata.getId(), null));
+ }
+ }
+ }
+
+ 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");
+ }
+ }
+ }
+ }
+
@SuppressWarnings("unchecked")
@Ignore("For now not possible to combine stub provider with ssh module, required for runScript")
@@ -227,4 +268,22 @@ public class JcloudsSpringComputeTest extends CamelSpringTestSupport {
return listHeaders;
}
+
+ /**
+ * Returns a {@Map} with the reboot headers.
+ *
+ * @param nodeId The id of the node to reboot.
+ * @param group The group of the node to reboot.
+ */
+ protected Map<String, Object> rebootHeaders(String nodeId, String group) {
+ Map<String, Object> rebootHeaders = new HashMap<String, Object>();
+ rebootHeaders.put(JcloudsConstants.OPERATION, JcloudsConstants.REBOOT_NODE);
+ if (nodeId != null) {
+ rebootHeaders.put(JcloudsConstants.NODE_ID, nodeId);
+ }
+ if (group != null) {
+ rebootHeaders.put(JcloudsConstants.GROUP, group);
+ }
+ return rebootHeaders;
+ }
}
http://git-wip-us.apache.org/repos/asf/camel/blob/422536bc/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 e8c1997..a71ffad 100644
--- a/components/camel-jclouds/src/test/resources/compute-test.xml
+++ b/components/camel-jclouds/src/test/resources/compute-test.xml
@@ -28,6 +28,12 @@
<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"/>