camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1410709 - in /camel/trunk/components/camel-jclouds/src: main/java/org/apache/camel/component/jclouds/ test/java/org/apache/camel/component/jclouds/ test/resources/
Date Sat, 17 Nov 2012 08:32:58 GMT
Author: davsclaus
Date: Sat Nov 17 08:32:56 2012
New Revision: 1410709

URL: http://svn.apache.org/viewvc?rev=1410709&view=rev
Log:
Fixed test and polished code.

Modified:
    camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsBlobStoreEndpoint.java
    camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsBlobStoreHelper.java
    camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsBlobStoreProducer.java
    camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsComponent.java
    camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsComputeEndpoint.java
    camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsComputeProducer.java
    camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsProducer.java
    camel/trunk/components/camel-jclouds/src/test/java/org/apache/camel/component/jclouds/JcloudsBlobStoreConsumerTest.java
    camel/trunk/components/camel-jclouds/src/test/java/org/apache/camel/component/jclouds/JcloudsBlobStoreProducerTest.java
    camel/trunk/components/camel-jclouds/src/test/java/org/apache/camel/component/jclouds/JcloudsMultipleBlobStoreTest.java
    camel/trunk/components/camel-jclouds/src/test/java/org/apache/camel/component/jclouds/JcloudsSpringBlobstoreTest.java
    camel/trunk/components/camel-jclouds/src/test/java/org/apache/camel/component/jclouds/JcloudsSpringComputeTest.java
    camel/trunk/components/camel-jclouds/src/test/resources/blobstore-test.xml

Modified: camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsBlobStoreEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsBlobStoreEndpoint.java?rev=1410709&r1=1410708&r2=1410709&view=diff
==============================================================================
--- camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsBlobStoreEndpoint.java
(original)
+++ camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsBlobStoreEndpoint.java
Sat Nov 17 08:32:56 2012
@@ -21,7 +21,6 @@ import org.apache.camel.Processor;
 import org.apache.camel.Producer;
 import org.jclouds.blobstore.BlobStore;
 
-
 public class JcloudsBlobStoreEndpoint extends JcloudsEndpoint {
 
     private String locationId;
@@ -32,13 +31,6 @@ public class JcloudsBlobStoreEndpoint ex
 
     private BlobStore blobStore;
 
-    /**
-     * Constructor
-     *
-     * @param uri
-     * @param component
-     * @param blobStore
-     */
     public JcloudsBlobStoreEndpoint(String uri, JcloudsComponent component, BlobStore blobStore)
{
         super(uri, component);
         this.blobStore = blobStore;

Modified: camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsBlobStoreHelper.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsBlobStoreHelper.java?rev=1410709&r1=1410708&r2=1410709&view=diff
==============================================================================
--- camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsBlobStoreHelper.java
(original)
+++ camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsBlobStoreHelper.java
Sat Nov 17 08:32:56 2012
@@ -14,7 +14,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.camel.component.jclouds;
 
 import java.io.InputStream;
@@ -35,10 +34,6 @@ public final class JcloudsBlobStoreHelpe
 
     /**
      * Creates all directories that are part of the blobName.
-     *
-     * @param blobStore
-     * @param container
-     * @param blobName
      */
     public static void mkDirs(BlobStore blobStore, String container, String blobName) {
         if (blobStore != null && !Strings.isNullOrEmpty(blobName) && blobName.contains("/"))
{
@@ -62,10 +57,6 @@ public final class JcloudsBlobStoreHelpe
 
     /**
      * Returns the {@link Location} that matches the locationId.
-     *
-     * @param blobStore
-     * @param locationId
-     * @return
      */
     public static Location getLocationById(BlobStore blobStore, String locationId) {
         if (blobStore != null && !Strings.isNullOrEmpty(locationId)) {
@@ -80,11 +71,6 @@ public final class JcloudsBlobStoreHelpe
 
     /**
      * Writes {@link Payload} to the the {@link BlobStore}.
-     *
-     * @param blobStore
-     * @param container
-     * @param blobName
-     * @param payload
      */
     public static void writeBlob(BlobStore blobStore, String container, String blobName,
Payload payload) {
         if (blobName != null && payload != null) {
@@ -96,10 +82,6 @@ public final class JcloudsBlobStoreHelpe
 
     /**
      * Reads from a {@link BlobStore}. It returns an Object.
-     *
-     * @param container
-     * @param blobName
-     * @return
      */
     public static InputStream readBlob(BlobStore blobStore, String container, String blobName)
{
         InputStream is = null;

Modified: camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsBlobStoreProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsBlobStoreProducer.java?rev=1410709&r1=1410708&r2=1410709&view=diff
==============================================================================
--- camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsBlobStoreProducer.java
(original)
+++ camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsBlobStoreProducer.java
Sat Nov 17 08:32:56 2012
@@ -50,7 +50,9 @@ public class JcloudsBlobStoreProducer ex
         String blobName = getBlobName(exchange);
         String operation = getOperation(exchange);
 
-        LOG.trace("Processing {} operation on '{}'", operation, container + "/" + blobName);
+        if (LOG.isTraceEnabled()) {
+            LOG.trace("Processing {} operation on '{}'", operation, container + "/" + blobName);
+        }
         if (JcloudsConstants.GET.equals(operation)) {
             exchange.getOut().setBody(JcloudsBlobStoreHelper.readBlob(blobStore, container,
blobName));
         } else {
@@ -61,9 +63,6 @@ public class JcloudsBlobStoreProducer ex
 
     /**
      * Retrieves the blobName from the URI or from the exchange headers. The header will
take precedence over the URI.
-     *
-     * @param exchange
-     * @return
      */
     protected String getBlobName(Exchange exchange) {
         String blobName = ((JcloudsBlobStoreEndpoint) getEndpoint()).getBlobName();
@@ -75,9 +74,6 @@ public class JcloudsBlobStoreProducer ex
 
     /**
      * Retrieves the containerName from the URI or from the exchange headers. The header
will take precedence over the URI.
-     *
-     * @param exchange
-     * @return
      */
     protected String getContainerName(Exchange exchange) {
         String containerName = ((JcloudsBlobStoreEndpoint) getEndpoint()).getContainer();
@@ -89,9 +85,6 @@ public class JcloudsBlobStoreProducer ex
 
     /**
      * Retrieves the operation from the URI or from the exchange headers. The header will
take precedence over the URI.
-     *
-     * @param exchange
-     * @return
      */
     public String getOperation(Exchange exchange) {
         String operation = ((JcloudsBlobStoreEndpoint) getEndpoint()).getOperation();
@@ -104,9 +97,6 @@ public class JcloudsBlobStoreProducer ex
 
     /**
      * Retrieves the locationId from the URI or from the exchange headers. The header will
take precedence over the URI.
-     *
-     * @param exchange
-     * @return
      */
     public String getLocationId(Exchange exchange) {
         String operation = ((JcloudsBlobStoreEndpoint) getEndpoint()).getLocationId();

Modified: camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsComponent.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsComponent.java?rev=1410709&r1=1410708&r2=1410709&view=diff
==============================================================================
--- camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsComponent.java
(original)
+++ camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsComponent.java
Sat Nov 17 08:32:56 2012
@@ -46,20 +46,20 @@ public class JcloudsComponent extends De
         }
 
         if (JcloudsConstants.BLOBSTORE.endsWith(endpointType)) {
-            if (uriParts.length >= 2) {
+            if (uriParts != null && uriParts.length >= 2) {
                 String provider = uriParts[1];
                 BlobStore blobStore = getBlobStore(provider);
                 endpoint = new JcloudsBlobStoreEndpoint(uri, this, blobStore);
             } else {
-                throw new Exception("Invalid Endpoint URI. It should contains a valid provider
name");
+                throw new IllegalArgumentException("Invalid Endpoint URI: " + uri + ". It
should contains a valid provider name");
             }
         } else if (JcloudsConstants.COMPUTE.endsWith(endpointType)) {
-            if (uriParts.length >= 2) {
+            if (uriParts != null && uriParts.length >= 2) {
                 String provider = uriParts[1];
                 ComputeService computeService = getComputeService(provider);
                 endpoint = new JcloudsComputeEndpoint(uri, this, computeService);
             } else {
-                throw new Exception("Invalid Endpoint URI. It should contains a valid provider
name");
+                throw new IllegalArgumentException("Invalid Endpoint URI: \" + uri + \".
It should contains a valid provider name");
             }
         }
 
@@ -72,7 +72,7 @@ public class JcloudsComponent extends De
      * @param predicate The blobstore context name, provider or api.
      * @return The matching {@link BlobStore}
      */
-    protected BlobStore getBlobStore(String predicate) throws Exception {
+    protected BlobStore getBlobStore(String predicate) throws IllegalArgumentException {
         if (blobStores != null && !blobStores.isEmpty()) {
 
             //First try using name and then fallback to the provider or api.
@@ -89,9 +89,9 @@ public class JcloudsComponent extends De
                     return blobStore;
                 }
             }
-            throw new Exception(String.format("No blobstore found for:%s", predicate));
+            throw new IllegalArgumentException(String.format("No blobstore found for:%s",
predicate));
         } else {
-            throw new Exception("No blobstore available.");
+            throw new IllegalArgumentException("No blobstore available.");
         }
     }
 
@@ -100,7 +100,7 @@ public class JcloudsComponent extends De
      * @param predicate The compute context name, provider or api.
      * @return The matching {@link ComputeService}
      */
-    protected ComputeService getComputeService(String predicate) throws Exception {
+    protected ComputeService getComputeService(String predicate) throws IllegalArgumentException
{
 
         if (computeServices != null && !computeServices.isEmpty()) {
             //First try using name and then fallback to the provider or api.
@@ -117,9 +117,9 @@ public class JcloudsComponent extends De
                     return computeService;
                 }
             }
-            throw new Exception(String.format("No compute service found for :%s", predicate));
+            throw new IllegalArgumentException(String.format("No compute service found for
:%s", predicate));
         } else {
-            throw new Exception("No compute service available.");
+            throw new IllegalArgumentException("No compute service available.");
         }
     }
 
@@ -127,8 +127,6 @@ public class JcloudsComponent extends De
      * Checks if jclouds {@link Context} supports the name.
      * We need this method as getName is not supported in earlier micro version of 1.5.x.
      * So we use this check to fallback to traditional means of looking up contexts and services,
if name is not present.
-     *
-     * @return
      */
     private boolean isNameSupportedByContext() {
         try {

Modified: camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsComputeEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsComputeEndpoint.java?rev=1410709&r1=1410708&r2=1410709&view=diff
==============================================================================
--- camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsComputeEndpoint.java
(original)
+++ camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsComputeEndpoint.java
Sat Nov 17 08:32:56 2012
@@ -16,7 +16,6 @@
  */
 package org.apache.camel.component.jclouds;
 
-
 import org.apache.camel.Consumer;
 import org.apache.camel.Processor;
 import org.apache.camel.Producer;
@@ -41,7 +40,6 @@ public class JcloudsComputeEndpoint exte
         this.computeService = computeService;
     }
 
-
     @Override
     public Producer createProducer() throws Exception {
         return new JcloudsComputeProducer(this, computeService);

Modified: camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsComputeProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsComputeProducer.java?rev=1410709&r1=1410708&r2=1410709&view=diff
==============================================================================
--- camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsComputeProducer.java
(original)
+++ camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsComputeProducer.java
Sat Nov 17 08:32:56 2012
@@ -19,6 +19,7 @@ package org.apache.camel.component.jclou
 import java.util.Set;
 import com.google.common.base.Predicate;
 import org.apache.camel.CamelException;
+import org.apache.camel.CamelExchangeException;
 import org.apache.camel.Exchange;
 import org.jclouds.compute.ComputeService;
 import org.jclouds.compute.RunNodesException;
@@ -33,7 +34,6 @@ import org.jclouds.compute.domain.intern
 import org.jclouds.compute.options.RunScriptOptions;
 import org.jclouds.domain.LoginCredentials;
 
-
 public class JcloudsComputeProducer extends JcloudsProducer {
 
     private final ComputeService computeService;
@@ -53,7 +53,7 @@ public class JcloudsComputeProducer exte
         String operation = getOperation(exchange);
 
         if (operation == null) {
-            throw new CamelException("Operation must be specified in the endpoitn URI or
as a property on the exchange.");
+            throw new CamelExchangeException("Operation must be specified in the endpoint
URI or as a property on the exchange.", exchange);
         }
 
         if (JcloudsConstants.LIST_NODES.equals(operation)) {
@@ -73,9 +73,6 @@ public class JcloudsComputeProducer exte
 
     /**
      * Create a node with the specified group.
-     *
-     * @param exchange
-     * @throws CamelException
      */
     protected void createNode(Exchange exchange) throws CamelException {
         String group = getGroup(exchange);
@@ -84,7 +81,7 @@ public class JcloudsComputeProducer exte
         String hardwareId = getHardwareId(exchange);
 
         if (group == null) {
-            throw new CamelException("Group must be specific in the URI or as exchange property
for the destroy node operation.");
+            throw new CamelExchangeException("Group must be specific in the URI or as exchange
property for the destroy node operation.", exchange);
         }
         TemplateBuilder builder = computeService.templateBuilder();
         builder.any();
@@ -104,15 +101,12 @@ public class JcloudsComputeProducer exte
             exchange.getOut().setBody(nodeMetadatas);
             exchange.getOut().setHeaders(exchange.getIn().getHeaders());
         } catch (RunNodesException e) {
-            throw new CamelException("Error creating jclouds node.", e);
+            throw new CamelExchangeException("Error creating jclouds node.", exchange, e);
         }
     }
 
     /**
      * Runs a script on the target node.
-     *
-     * @param exchange
-     * @throws CamelException
      */
     @SuppressWarnings("deprecation")
     protected void runScriptOnNode(Exchange exchange) throws CamelException {
@@ -134,7 +128,7 @@ public class JcloudsComputeProducer exte
         }
 
         if (execResponse == null) {
-            throw new CamelException("Failed to receive response for run script operation.");
+            throw new CamelExchangeException("Failed to receive response for run script operation
on node: " + nodeId + " using script: " + script, exchange);
         }
 
         exchange.setProperty(JcloudsConstants.RUN_SCRIPT_ERROR, execResponse.getError());
@@ -144,22 +138,16 @@ public class JcloudsComputeProducer exte
 
     /**
      * Destroys the node with the specified nodeId.
-     *
-     * @param exchange
-     * @throws CamelException
      */
-    protected void destroyNode(Exchange exchange) throws CamelException {
+    protected void destroyNode(Exchange exchange) {
         Predicate<NodeMetadata> predicate = getNodePredicate(exchange);
         computeService.destroyNodesMatching(predicate);
     }
 
     /**
      * Sets the metadata of the available nodes to the out message.
-     *
-     * @param exchange
-     * @throws CamelException
      */
-    protected void listNodes(Exchange exchange) throws CamelException {
+    protected void listNodes(Exchange exchange) {
         Predicate<ComputeMetadata> predicate = getComputePredicate(exchange);
         Set<? extends ComputeMetadata> computeMetadatas = computeService.listNodesDetailsMatching(predicate);
         exchange.getOut().setBody(computeMetadatas);
@@ -167,22 +155,16 @@ public class JcloudsComputeProducer exte
 
     /**
      * Sets the available images to the out message.
-     *
-     * @param exchange
-     * @throws CamelException
      */
-    protected void listImages(Exchange exchange) throws CamelException {
+    protected void listImages(Exchange exchange) {
         Set<? extends Image> images = computeService.listImages();
         exchange.getOut().setBody(images);
     }
 
     /**
      * Sets the available hardware profiles to the out message.
-     *
-     * @param exchange
-     * @throws CamelException
      */
-    protected void listHardware(Exchange exchange) throws CamelException {
+    protected void listHardware(Exchange exchange) {
         Set<? extends Hardware> hardwareProfiles = computeService.listHardwareProfiles();
         exchange.getOut().setBody(hardwareProfiles);
     }
@@ -191,9 +173,6 @@ public class JcloudsComputeProducer exte
     /**
      * Returns the required {@ComputeMetadata} {@link Predicate} for the Exhcnage.
      * The predicate can be used for filtering.
-     *
-     * @param exchange
-     * @return
      */
     public Predicate<ComputeMetadata> getComputePredicate(final Exchange exchange)
{
         final String nodeId = getNodeId(exchange);
@@ -221,9 +200,6 @@ public class JcloudsComputeProducer exte
     /**
      * Returns the required {@ComputeMetadata} {@link Predicate} for the Exhcnage.
      * The predicate can be used for filtering.
-     *
-     * @param exchange
-     * @return
      */
     public Predicate<NodeMetadata> getNodePredicate(Exchange exchange) {
         final String nodeId = getNodeId(exchange);
@@ -253,9 +229,6 @@ public class JcloudsComputeProducer exte
 
     /**
      * Retrieves the operation from the URI or from the exchange headers. The header will
take precedence over the URI.
-     *
-     * @param exchange
-     * @return
      */
     public String getOperation(Exchange exchange) {
         String operation = getEndpoint().getOperation();
@@ -268,9 +241,6 @@ public class JcloudsComputeProducer exte
 
     /**
      * Retrieves the node state from the URI or from the exchange headers. The header will
take precedence over the URI.
-     *
-     * @param exchange
-     * @return
      */
     public NodeState getNodeState(Exchange exchange) {
         NodeState nodeState = null;
@@ -295,9 +265,6 @@ public class JcloudsComputeProducer exte
 
     /**
      * Retrieves the image id from the URI or from the exchange properties. The property
will take precedence over the URI.
-     *
-     * @param exchange
-     * @return
      */
     protected String getImageId(Exchange exchange) {
         String imageId = getEndpoint().getImageId();
@@ -310,9 +277,6 @@ public class JcloudsComputeProducer exte
 
     /**
      * Retrieves the hardware id from the URI or from the exchange headers. The header will
take precedence over the URI.
-     *
-     * @param exchange
-     * @return
      */
     protected String getHardwareId(Exchange exchange) {
         String hardwareId = getEndpoint().getHardwareId();
@@ -325,9 +289,6 @@ public class JcloudsComputeProducer exte
 
     /**
      * Retrieves the location id from the URI or from the exchange headers. The header will
take precedence over the URI.
-     *
-     * @param exchange
-     * @return
      */
     protected String getLocationId(Exchange exchange) {
         String locationId = getEndpoint().getLocationId();
@@ -340,9 +301,6 @@ public class JcloudsComputeProducer exte
 
     /**
      * Retrieves the node id from the URI or from the exchange headers. The header will take
precedence over the URI.
-     *
-     * @param exchange
-     * @return
      */
     protected String getNodeId(Exchange exchange) {
         String nodeId = getEndpoint().getNodeId();
@@ -355,9 +313,6 @@ public class JcloudsComputeProducer exte
 
     /**
      * Retrieves the group from the URI or from the exchange headers. The header will take
precedence over the URI.
-     *
-     * @param exchange
-     * @return
      */
     protected String getGroup(Exchange exchange) {
         String group = getEndpoint().getGroup();
@@ -370,9 +325,6 @@ public class JcloudsComputeProducer exte
 
     /**
      * Retrieves the user from the URI or from the exchange headers. The header will take
precedence over the URI.
-     *
-     * @param exchange
-     * @return
      */
     protected String getUser(Exchange exchange) {
         String user = getEndpoint().getUser();
@@ -382,4 +334,5 @@ public class JcloudsComputeProducer exte
         }
         return user;
     }
+
 }

Modified: camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsProducer.java?rev=1410709&r1=1410708&r2=1410709&view=diff
==============================================================================
--- camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsProducer.java
(original)
+++ camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsProducer.java
Sat Nov 17 08:32:56 2012
@@ -16,20 +16,12 @@
  */
 package org.apache.camel.component.jclouds;
 
-import org.apache.camel.Exchange;
 import org.apache.camel.impl.DefaultProducer;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
-public class JcloudsProducer extends DefaultProducer {
-    private static final transient Logger LOG = LoggerFactory.getLogger(JcloudsProducer.class);
+public abstract class JcloudsProducer extends DefaultProducer {
 
     public JcloudsProducer(JcloudsEndpoint endpoint) {
         super(endpoint);
     }
 
-    public void process(Exchange exchange) throws Exception {
-        LOG.debug("JcloudsProducer received: {}", exchange.getIn().getBody());    
-    }
-
 }

Modified: camel/trunk/components/camel-jclouds/src/test/java/org/apache/camel/component/jclouds/JcloudsBlobStoreConsumerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jclouds/src/test/java/org/apache/camel/component/jclouds/JcloudsBlobStoreConsumerTest.java?rev=1410709&r1=1410708&r2=1410709&view=diff
==============================================================================
--- camel/trunk/components/camel-jclouds/src/test/java/org/apache/camel/component/jclouds/JcloudsBlobStoreConsumerTest.java
(original)
+++ camel/trunk/components/camel-jclouds/src/test/java/org/apache/camel/component/jclouds/JcloudsBlobStoreConsumerTest.java
Sat Nov 17 08:32:56 2012
@@ -14,7 +14,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.camel.component.jclouds;
 
 import com.google.common.collect.Lists;
@@ -44,41 +43,38 @@ public class JcloudsBlobStoreConsumerTes
     @Test
     public void testBlobStoreGetOneBlob() throws InterruptedException {
         String message = "Some message";
-        JcloudsBlobStoreHelper.writeBlob(blobStore, TEST_CONTAINER, TEST_BLOB1, new StringPayload(message));
 
         MockEndpoint mockEndpoint = resolveMandatoryEndpoint("mock:results", MockEndpoint.class);
-        mockEndpoint.expectedMessageCount(1);
-
         mockEndpoint.expectedBodiesReceived(message);
 
-        mockEndpoint.assertIsSatisfied();
+        JcloudsBlobStoreHelper.writeBlob(blobStore, TEST_CONTAINER, TEST_BLOB1, new StringPayload(message));
 
+        mockEndpoint.assertIsSatisfied();
     }
 
     @Test
     public void testBlobStoreGetTwoBlobs() throws InterruptedException {
         String message1 = "Blob 1";
-        JcloudsBlobStoreHelper.writeBlob(blobStore, TEST_CONTAINER, TEST_BLOB1, new StringPayload(message1));
-
         String message2 = "Blob 2";
-        JcloudsBlobStoreHelper.writeBlob(blobStore, TEST_CONTAINER, TEST_BLOB2, new StringPayload(message2));
 
         MockEndpoint mockEndpoint = resolveMandatoryEndpoint("mock:results", MockEndpoint.class);
-        mockEndpoint.expectedMessageCount(2);
         mockEndpoint.expectedBodiesReceived(message1, message2);
 
+        JcloudsBlobStoreHelper.writeBlob(blobStore, TEST_CONTAINER, TEST_BLOB1, new StringPayload(message1));
+        JcloudsBlobStoreHelper.writeBlob(blobStore, TEST_CONTAINER, TEST_BLOB2, new StringPayload(message2));
+
         mockEndpoint.assertIsSatisfied();
     }
 
     @Test
     public void testBlobStoreWithDirectory() throws InterruptedException {
         String message1 = "Blob in directory";
-        JcloudsBlobStoreHelper.writeBlob(blobStore, TEST_CONTAINER_WITH_DIR, TEST_BLOB_IN_DIR,
new StringPayload(message1));
 
         MockEndpoint mockEndpoint = resolveMandatoryEndpoint("mock:results-in-dir", MockEndpoint.class);
-        mockEndpoint.expectedMessageCount(1);
         mockEndpoint.expectedBodiesReceived(message1);
 
+        JcloudsBlobStoreHelper.writeBlob(blobStore, TEST_CONTAINER_WITH_DIR, TEST_BLOB_IN_DIR,
new StringPayload(message1));
+
         mockEndpoint.assertIsSatisfied();
     }
 
@@ -86,26 +82,24 @@ public class JcloudsBlobStoreConsumerTes
     public void testBlobStoreWithMultipleDirectories() throws InterruptedException {
         String message1 = "Blob in directory";
         String message2 = "Blob in other directory";
-        JcloudsBlobStoreHelper.writeBlob(blobStore, TEST_CONTAINER_WITH_DIR, TEST_BLOB_IN_DIR,
new StringPayload(message1));
-        JcloudsBlobStoreHelper.writeBlob(blobStore, TEST_CONTAINER_WITH_DIR, TEST_BLOB_IN_OTHER,
new StringPayload(message2));
 
         MockEndpoint mockEndpoint = resolveMandatoryEndpoint("mock:results-in-dir", MockEndpoint.class);
-        mockEndpoint.expectedMessageCount(1);
         mockEndpoint.expectedBodiesReceived(message1);
 
+        JcloudsBlobStoreHelper.writeBlob(blobStore, TEST_CONTAINER_WITH_DIR, TEST_BLOB_IN_DIR,
new StringPayload(message1));
+        JcloudsBlobStoreHelper.writeBlob(blobStore, TEST_CONTAINER_WITH_DIR, TEST_BLOB_IN_OTHER,
new StringPayload(message2));
+
         mockEndpoint.assertIsSatisfied();
     }
 
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
-
         blobStore.createContainerInLocation(null, TEST_CONTAINER);
         blobStore.createContainerInLocation(null, TEST_CONTAINER_WITH_DIR);
         ((JcloudsComponent) context.getComponent("jclouds")).setBlobStores(Lists.newArrayList(blobStore));
 
         return new RouteBuilder() {
             public void configure() {
-
                 from("jclouds:blobstore:transient?container=" + TEST_CONTAINER)
                         .convertBodyTo(String.class)
                         .to("mock:results");

Modified: camel/trunk/components/camel-jclouds/src/test/java/org/apache/camel/component/jclouds/JcloudsBlobStoreProducerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jclouds/src/test/java/org/apache/camel/component/jclouds/JcloudsBlobStoreProducerTest.java?rev=1410709&r1=1410708&r2=1410709&view=diff
==============================================================================
--- camel/trunk/components/camel-jclouds/src/test/java/org/apache/camel/component/jclouds/JcloudsBlobStoreProducerTest.java
(original)
+++ camel/trunk/components/camel-jclouds/src/test/java/org/apache/camel/component/jclouds/JcloudsBlobStoreProducerTest.java
Sat Nov 17 08:32:56 2012
@@ -14,7 +14,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.camel.component.jclouds;
 
 import java.io.ByteArrayInputStream;
@@ -34,8 +33,6 @@ import org.jclouds.blobstore.BlobStore;
 import org.jclouds.blobstore.BlobStoreContext;
 import org.junit.Test;
 
-
-
 public class JcloudsBlobStoreProducerTest extends CamelTestSupport {
 
     private static final String TEST_CONTAINER = "testContainer";
@@ -71,10 +68,8 @@ public class JcloudsBlobStoreProducerTes
         assertEquals(MESSAGE, result);
     }
 
-
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
-
         blobStore.createContainerInLocation(null, TEST_CONTAINER);
         ((JcloudsComponent) context.getComponent("jclouds")).setBlobStores(Lists.newArrayList(blobStore));
 

Modified: camel/trunk/components/camel-jclouds/src/test/java/org/apache/camel/component/jclouds/JcloudsMultipleBlobStoreTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jclouds/src/test/java/org/apache/camel/component/jclouds/JcloudsMultipleBlobStoreTest.java?rev=1410709&r1=1410708&r2=1410709&view=diff
==============================================================================
--- camel/trunk/components/camel-jclouds/src/test/java/org/apache/camel/component/jclouds/JcloudsMultipleBlobStoreTest.java
(original)
+++ camel/trunk/components/camel-jclouds/src/test/java/org/apache/camel/component/jclouds/JcloudsMultipleBlobStoreTest.java
Sat Nov 17 08:32:56 2012
@@ -39,14 +39,10 @@ public class JcloudsMultipleBlobStoreTes
     BlobStoreContext blobStoreContext2 = ContextBuilder.newBuilder("transient").name("b2").credentials("identity",
"credential").build(BlobStoreContext.class);
     BlobStore blobStore2 = blobStoreContext2.getBlobStore();
 
-
     @Test
     public void testWithMultipleServices() throws InterruptedException {
         String message1 = "Blob 1";
-        JcloudsBlobStoreHelper.writeBlob(blobStore1, TEST_CONTAINER, TEST_BLOB1, new StringPayload(message1));
-
         String message2 = "Blob 2";
-        JcloudsBlobStoreHelper.writeBlob(blobStore2, TEST_CONTAINER, TEST_BLOB2, new StringPayload(message2));
 
         MockEndpoint mockEndpoint1 = resolveMandatoryEndpoint("mock:results1", MockEndpoint.class);
         mockEndpoint1.expectedBodiesReceived(message1);
@@ -54,23 +50,21 @@ public class JcloudsMultipleBlobStoreTes
         MockEndpoint mockEndpoint2 = resolveMandatoryEndpoint("mock:results2", MockEndpoint.class);
         mockEndpoint2.expectedBodiesReceived(message2);
 
+        JcloudsBlobStoreHelper.writeBlob(blobStore1, TEST_CONTAINER, TEST_BLOB1, new StringPayload(message1));
+        JcloudsBlobStoreHelper.writeBlob(blobStore2, TEST_CONTAINER, TEST_BLOB2, new StringPayload(message2));
 
         mockEndpoint1.assertIsSatisfied();
         mockEndpoint2.assertIsSatisfied();
     }
 
-
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
-
         blobStore1.createContainerInLocation(null, TEST_CONTAINER);
         blobStore2.createContainerInLocation(null, TEST_CONTAINER);
-
         ((JcloudsComponent) context.getComponent("jclouds")).setBlobStores(Lists.newArrayList(blobStore1,
blobStore2));
 
         return new RouteBuilder() {
             public void configure() {
-
                 from("jclouds:blobstore:b1?container=" + TEST_CONTAINER)
                         .convertBodyTo(String.class)
                         .to("mock:results1");

Modified: camel/trunk/components/camel-jclouds/src/test/java/org/apache/camel/component/jclouds/JcloudsSpringBlobstoreTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jclouds/src/test/java/org/apache/camel/component/jclouds/JcloudsSpringBlobstoreTest.java?rev=1410709&r1=1410708&r2=1410709&view=diff
==============================================================================
--- camel/trunk/components/camel-jclouds/src/test/java/org/apache/camel/component/jclouds/JcloudsSpringBlobstoreTest.java
(original)
+++ camel/trunk/components/camel-jclouds/src/test/java/org/apache/camel/component/jclouds/JcloudsSpringBlobstoreTest.java
Sat Nov 17 08:32:56 2012
@@ -50,22 +50,22 @@ public class JcloudsSpringBlobstoreTest 
 
     @Test
     public void testBlobStorePut() throws InterruptedException {
-        template.sendBody("direct:start", "Some message");
         resultFoo.expectedMessageCount(1);
+        template.sendBody("direct:start", "Some message");
         resultFoo.assertIsSatisfied();
     }
 
     @Test
     public void testBlobStoreGet() throws InterruptedException {
-        template.sendBody("direct:start", "Some message");
         resultFoo.expectedMessageCount(1);
+        template.sendBody("direct:start", "Some message");
         resultFoo.assertIsSatisfied();
     }
 
     @Test
     public void testProduceWithUrlParametes() throws InterruptedException {
-        template.sendBody("direct:start-with-url-parameters", "Some message");
         resultBar.expectedMessageCount(1);
+        template.sendBody("direct:start-with-url-parameters", "Some message");
         resultBar.assertIsSatisfied();
     }
 }

Modified: camel/trunk/components/camel-jclouds/src/test/java/org/apache/camel/component/jclouds/JcloudsSpringComputeTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jclouds/src/test/java/org/apache/camel/component/jclouds/JcloudsSpringComputeTest.java?rev=1410709&r1=1410708&r2=1410709&view=diff
==============================================================================
--- camel/trunk/components/camel-jclouds/src/test/java/org/apache/camel/component/jclouds/JcloudsSpringComputeTest.java
(original)
+++ camel/trunk/components/camel-jclouds/src/test/java/org/apache/camel/component/jclouds/JcloudsSpringComputeTest.java
Sat Nov 17 08:32:56 2012
@@ -50,9 +50,10 @@ public class JcloudsSpringComputeTest ex
 
     @Test
     public void testListImages() throws InterruptedException {
-        template.sendBodyAndHeader("direct:start", null, JcloudsConstants.OPERATION, JcloudsConstants.LIST_IMAGES);
         result.expectedMessageCount(1);
+        template.sendBodyAndHeader("direct:start", null, JcloudsConstants.OPERATION, JcloudsConstants.LIST_IMAGES);
         result.assertIsSatisfied();
+
         List<Exchange> exchanges = result.getExchanges();
         if (exchanges != null && !exchanges.isEmpty()) {
             for (Exchange exchange : exchanges) {
@@ -67,9 +68,10 @@ public class JcloudsSpringComputeTest ex
 
     @Test
     public void testListHardware() throws InterruptedException {
-        template.sendBodyAndHeader("direct:start", null, JcloudsConstants.OPERATION, JcloudsConstants.LIST_HARDWARE);
         result.expectedMessageCount(1);
+        template.sendBodyAndHeader("direct:start", null, JcloudsConstants.OPERATION, JcloudsConstants.LIST_HARDWARE);
         result.assertIsSatisfied();
+
         List<Exchange> exchanges = result.getExchanges();
         if (exchanges != null && !exchanges.isEmpty()) {
             for (Exchange exchange : exchanges) {
@@ -84,9 +86,10 @@ public class JcloudsSpringComputeTest ex
 
     @Test
     public void testListNodes() throws InterruptedException {
-        template.sendBodyAndHeader("direct:start", null, JcloudsConstants.OPERATION, JcloudsConstants.LIST_NODES);
         result.expectedMessageCount(1);
+        template.sendBodyAndHeader("direct:start", null, JcloudsConstants.OPERATION, JcloudsConstants.LIST_NODES);
         result.assertIsSatisfied();
+
         List<Exchange> exchanges = result.getExchanges();
         if (exchanges != null && !exchanges.isEmpty()) {
             for (Exchange exchange : exchanges) {
@@ -98,11 +101,11 @@ public class JcloudsSpringComputeTest ex
 
     @Test
     public void testCreateAndListNodes() throws InterruptedException {
+        result.expectedMessageCount(2);
         template.sendBodyAndHeaders("direct:start", null, createHeaders("1", "default"));
-
         template.sendBodyAndHeader("direct:start", null, JcloudsConstants.OPERATION, JcloudsConstants.LIST_NODES);
-        result.expectedMessageCount(2);
         result.assertIsSatisfied();
+
         List<Exchange> exchanges = result.getExchanges();
         if (exchanges != null && !exchanges.isEmpty()) {
             for (Exchange exchange : exchanges) {
@@ -115,6 +118,8 @@ public class JcloudsSpringComputeTest ex
 
     @Test
     public void testCreateAndListWithPredicates() throws InterruptedException {
+        result.expectedMessageCount(6);
+
         //Create a node for the default group
         template.sendBodyAndHeaders("direct:start", null, createHeaders("1", "default"));
 
@@ -126,10 +131,9 @@ public class JcloudsSpringComputeTest ex
         template.sendBodyAndHeaders("direct:start", null, listNodeHeaders("3", "other", null));
         template.sendBodyAndHeaders("direct:start", null, listNodeHeaders("3", "other", "RUNNING"));
 
-        result.expectedMessageCount(6);
         result.assertIsSatisfied();
-        List<Exchange> exchanges = result.getExchanges();
 
+        List<Exchange> exchanges = result.getExchanges();
         Exchange exchange = exchanges.get(3);
         Set<?> nodeMetadatas = exchange.getIn().getBody(Set.class);
         assertEquals("Nodes should be 2", 2, nodeMetadatas.size());
@@ -153,9 +157,10 @@ public class JcloudsSpringComputeTest ex
 
     @Test
     public void testCreateAndDestroyNode() throws InterruptedException {
-        template.sendBodyAndHeaders("direct:start", null, createHeaders("1", "default"));
         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) {
@@ -171,7 +176,7 @@ public class JcloudsSpringComputeTest ex
     }
 
     @SuppressWarnings("unchecked")
-    @Ignore("For now not possible to combine stub provider with ssh module, requird for runScript")
+    @Ignore("For now not possible to combine stub provider with ssh module, required for
runScript")
     @Test
     public void testRunScript() throws InterruptedException {
         Map<String, Object> runScriptHeaders = new HashMap<String, Object>();
@@ -192,7 +197,6 @@ public class JcloudsSpringComputeTest ex
      *
      * @param imageId The imageId to use for creating the node.
      * @param group   The group to be assigned to the node.
-     * @return
      */
     protected Map<String, Object> createHeaders(String imageId, String group) {
         Map<String, Object> createHeaders = new HashMap<String, Object>();
@@ -208,7 +212,6 @@ public class JcloudsSpringComputeTest ex
      *
      * @param nodeId The id of the node to destroy.
      * @param group  The group of the node to destroy.
-     * @return
      */
     protected Map<String, Object> destroyHeaders(String nodeId, String group) {
         Map<String, Object> destroyHeaders = new HashMap<String, Object>();
@@ -227,7 +230,6 @@ public class JcloudsSpringComputeTest ex
      *
      * @param nodeId The id of the node to destroy.
      * @param group  The group of the node to destroy.
-     * @return
      */
     protected Map<String, Object> listNodeHeaders(String nodeId, String group, Object
state) {
         Map<String, Object> listHeaders = new HashMap<String, Object>();

Modified: camel/trunk/components/camel-jclouds/src/test/resources/blobstore-test.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jclouds/src/test/resources/blobstore-test.xml?rev=1410709&r1=1410708&r2=1410709&view=diff
==============================================================================
--- camel/trunk/components/camel-jclouds/src/test/resources/blobstore-test.xml (original)
+++ camel/trunk/components/camel-jclouds/src/test/resources/blobstore-test.xml Sat Nov 17
08:32:56 2012
@@ -17,7 +17,6 @@
   -->
 <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-       xmlns:camel="http://activemq.apache.org/camel/schema/spring"
        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
 



Mime
View raw message