camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acosent...@apache.org
Subject [2/5] camel git commit: CAMEL-10307, docker test (async) fixed!
Date Tue, 20 Sep 2016 09:11:09 GMT
CAMEL-10307, docker test (async) fixed!


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/0e9af90a
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/0e9af90a
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/0e9af90a

Branch: refs/heads/master
Commit: 0e9af90ad2f6999c49443569f184713909ed2a51
Parents: a9304c5
Author: Fabryprog <fabryprog@gmail.com>
Authored: Tue Sep 20 00:29:47 2016 +0200
Committer: Andrea Cosentino <ancosen@gmail.com>
Committed: Tue Sep 20 11:07:34 2016 +0200

----------------------------------------------------------------------
 .../src/main/docs/docker-component.adoc         |  6 +-
 .../component/docker/DockerClientFactory.java   | 15 ++---
 .../component/docker/DockerClientProfile.java   | 26 ++------
 .../camel/component/docker/DockerHelper.java    | 56 ++++++++--------
 .../docker/producer/AsyncDockerProducer.java    | 69 +++++++++++++++++---
 .../headers/AttachContainerCmdHeaderTest.java   | 18 +++--
 .../docker/headers/BuildImageCmdHeaderTest.java |  7 +-
 .../headers/CreateContainerCmdHeaderTest.java   |  2 +-
 .../docker/headers/ExecStartCmdHeaderTest.java  | 11 +++-
 .../headers/LogContainerCmdHeaderTest.java      | 11 +++-
 .../docker/headers/PullImageCmdHeaderTest.java  | 11 +++-
 .../docker/headers/PushImageCmdHeaderTest.java  | 11 +++-
 .../headers/WaitContainerCmdHeaderTest.java     |  7 +-
 13 files changed, 166 insertions(+), 84 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/0e9af90a/components/camel-docker/src/main/docs/docker-component.adoc
----------------------------------------------------------------------
diff --git a/components/camel-docker/src/main/docs/docker-component.adoc b/components/camel-docker/src/main/docs/docker-component.adoc
index 2472600..91608b8 100644
--- a/components/camel-docker/src/main/docs/docker-component.adoc
+++ b/components/camel-docker/src/main/docs/docker-component.adoc
@@ -67,9 +67,9 @@ The Docker component supports 18 endpoint options which are listed below:
 | operation | common |  | DockerOperation | *Required* Which operation to use
 | certPath | common |  | String | Location containing the SSL certificate chain
 | email | common |  | String | Email address associated with the user
-| followRedirectFilter | common | false | boolean | Whether to follow redirect filter
+| followRedirectFilter | common | false | boolean | *Deprecated since 2.18* Whether to follow
redirect filter
 | host | common | localhost | String | *Required* Docker host
-| loggingFilter | common | false | boolean | Whether to use logging filter
+| loggingFilter | common | false | boolean | *Deprecated since 2.18* Whether to use logging
filter
 | maxPerRouteConnections | common | 100 | Integer | Maximum route connections
 | maxTotalConnections | common | 100 | Integer | Maximum total connections
 | password | common |  | String | Password to authenticate with
@@ -82,6 +82,8 @@ The Docker component supports 18 endpoint options which are listed below:
 | exceptionHandler | consumer (advanced) |  | ExceptionHandler | To let the consumer use
a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this options
is not in use. By default the consumer will deal with exceptions that will be logged at WARN/ERROR
level and ignored.
 | exchangePattern | consumer (advanced) |  | ExchangePattern | Sets the exchange pattern
when the consumer creates an exchange.
 | synchronous | advanced | false | boolean | Sets whether synchronous processing should be
strictly used or Camel is allowed to use asynchronous processing (if supported).
+| tlsVerify | boolean | *from 2.18* TLS Verify flag
+| socket | boolean | *from 2.18* Connection mode, true docker client use socket otherwise
tcp
 |=======================================================================
 {% endraw %}
 // endpoint options: END

http://git-wip-us.apache.org/repos/asf/camel/blob/0e9af90a/components/camel-docker/src/main/java/org/apache/camel/component/docker/DockerClientFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-docker/src/main/java/org/apache/camel/component/docker/DockerClientFactory.java
b/components/camel-docker/src/main/java/org/apache/camel/component/docker/DockerClientFactory.java
index f6664b4..d614e12 100644
--- a/components/camel-docker/src/main/java/org/apache/camel/component/docker/DockerClientFactory.java
+++ b/components/camel-docker/src/main/java/org/apache/camel/component/docker/DockerClientFactory.java
@@ -16,11 +16,6 @@
  */
 package org.apache.camel.component.docker;
 
-import org.apache.camel.Message;
-import org.apache.camel.component.docker.exception.DockerException;
-import org.apache.camel.component.docker.ssl.NoImplSslConfig;
-import org.apache.camel.util.ObjectHelper;
-
 import com.github.dockerjava.api.DockerClient;
 import com.github.dockerjava.api.command.DockerCmdExecFactory;
 import com.github.dockerjava.core.DefaultDockerClientConfig;
@@ -28,6 +23,10 @@ import com.github.dockerjava.core.DockerClientBuilder;
 import com.github.dockerjava.core.LocalDirectorySSLConfig;
 import com.github.dockerjava.core.SSLConfig;
 import com.github.dockerjava.jaxrs.JerseyDockerCmdExecFactory;
+import org.apache.camel.Message;
+import org.apache.camel.component.docker.exception.DockerException;
+import org.apache.camel.component.docker.ssl.NoImplSslConfig;
+import org.apache.camel.util.ObjectHelper;
 
 /**
  * Methods for communicating with Docker
@@ -64,10 +63,6 @@ public final class DockerClientFactory {
         String serverAddress = DockerHelper.getProperty(DockerConstants.DOCKER_SERVER_ADDRESS,
dockerConfiguration, message, String.class, dockerConfiguration.getServerAddress());
         String certPath = DockerHelper.getProperty(DockerConstants.DOCKER_CERT_PATH, dockerConfiguration,
message, String.class, dockerConfiguration.getCertPath());
         Boolean secure = DockerHelper.getProperty(DockerConstants.DOCKER_SECURE, dockerConfiguration,
message, Boolean.class, dockerConfiguration.isSecure());
-        Boolean loggingFilter = DockerHelper.getProperty(DockerConstants.DOCKER_LOGGING_FILTER,
dockerConfiguration, message, Boolean.class,
-                                                         dockerConfiguration.isLoggingFilterEnabled());
-        Boolean followRedirectFilter = DockerHelper.getProperty(DockerConstants.DOCKER_FOLLOW_REDIRECT_FILTER,
dockerConfiguration, message, Boolean.class,
-                                                                dockerConfiguration.isFollowRedirectFilterEnabled());
         Boolean tlsVerify = DockerHelper.getProperty(DockerConstants.DOCKER_TLSVERIFY, dockerConfiguration,
message, Boolean.class, dockerConfiguration.isTlsVerify());
 
         clientProfile.setHost(host);
@@ -81,8 +76,6 @@ public final class DockerClientFactory {
         clientProfile.setMaxTotalConnections(maxTotalConnections);
         clientProfile.setMaxPerRouteConnections(maxPerRouteConnections);
         clientProfile.setSecure(secure);
-        clientProfile.setFollowRedirectFilter(followRedirectFilter);
-        clientProfile.setLoggingFilter(loggingFilter);
         clientProfile.setTlsVerify(tlsVerify);
 
         DockerClient dockerClient = dockerComponent.getClient(clientProfile);

http://git-wip-us.apache.org/repos/asf/camel/blob/0e9af90a/components/camel-docker/src/main/java/org/apache/camel/component/docker/DockerClientProfile.java
----------------------------------------------------------------------
diff --git a/components/camel-docker/src/main/java/org/apache/camel/component/docker/DockerClientProfile.java
b/components/camel-docker/src/main/java/org/apache/camel/component/docker/DockerClientProfile.java
index 9d5b7df..cb45be2 100644
--- a/components/camel-docker/src/main/java/org/apache/camel/component/docker/DockerClientProfile.java
+++ b/components/camel-docker/src/main/java/org/apache/camel/component/docker/DockerClientProfile.java
@@ -45,9 +45,9 @@ public class DockerClientProfile {
     private Integer maxTotalConnections;
 
     private Integer maxPerRouteConnections;
-    
+
     private Boolean loggingFilterEnabled;
-    
+
     private Boolean followRedirectFilterEnabled;
 
     private Boolean tlsVerify;
@@ -149,22 +149,6 @@ public class DockerClientProfile {
         return ((this.socket) ? "unix" : "tcp") + "://" + host + ":" + port;
     }
 
-    public Boolean isLoggingFilterEnabled() {
-        return loggingFilterEnabled;
-    }
-
-    public void setLoggingFilter(Boolean loggingFilterEnabled) {
-        this.loggingFilterEnabled = loggingFilterEnabled;
-    }
-
-    public Boolean isFollowRedirectFilterEnabled() {
-        return followRedirectFilterEnabled;
-    }
-
-    public void setFollowRedirectFilter(Boolean followRedirectFilterEnabled) {
-        this.followRedirectFilterEnabled = followRedirectFilterEnabled;
-    }
-
     public Boolean isTlsVerify() {
         return tlsVerify;
     }
@@ -179,9 +163,9 @@ public class DockerClientProfile {
 
     public void setSocket(Boolean socket) {
         this.socket = socket;
-    }    
+    }
 
-   @Override
+    @Override
     public int hashCode() {
         final int prime = 31;
         int result = 1;
@@ -212,7 +196,7 @@ public class DockerClientProfile {
         if (getClass() != obj.getClass()) {
             return false;
         }
-        DockerClientProfile other = (DockerClientProfile) obj;
+        DockerClientProfile other = (DockerClientProfile)obj;
         if (certPath == null) {
             if (other.certPath != null) {
                 return false;

http://git-wip-us.apache.org/repos/asf/camel/blob/0e9af90a/components/camel-docker/src/main/java/org/apache/camel/component/docker/DockerHelper.java
----------------------------------------------------------------------
diff --git a/components/camel-docker/src/main/java/org/apache/camel/component/docker/DockerHelper.java
b/components/camel-docker/src/main/java/org/apache/camel/component/docker/DockerHelper.java
index 37edee7..a0adc62 100644
--- a/components/camel-docker/src/main/java/org/apache/camel/component/docker/DockerHelper.java
+++ b/components/camel-docker/src/main/java/org/apache/camel/component/docker/DockerHelper.java
@@ -20,13 +20,11 @@ import java.lang.reflect.Array;
 import java.util.HashMap;
 import java.util.Map;
 
+import com.github.dockerjava.api.exception.DockerClientException;
 import org.apache.camel.Message;
 import org.apache.camel.util.ObjectHelper;
 import org.apache.commons.lang.BooleanUtils;
 
-import com.github.dockerjava.api.exception.DockerClientException;
-
-
 /**
  * Utility methods for Docker Component
  */
@@ -35,7 +33,7 @@ public final class DockerHelper {
     private static final String STRING_DELIMITER = ";";
 
     private DockerHelper() {
-        //Helpser class
+        // Helpser class
     }
 
     /**
@@ -58,7 +56,6 @@ public final class DockerHelper {
                 throw new DockerClientException(key + " is not a valid URI parameter");
             }
 
-
             try {
                 Class<?> parameterClass = validParamMap.get(transformedKey);
                 Object parameterValue = parameters.get(key);
@@ -68,9 +65,9 @@ public final class DockerHelper {
                 }
 
                 if (Integer.class == parameterClass) {
-                    Integer.parseInt((String) parameterValue);
+                    Integer.parseInt((String)parameterValue);
                 } else if (Boolean.class == parameterClass) {
-                    BooleanUtils.toBooleanObject((String) parameterValue, "true", "false",
"null");
+                    BooleanUtils.toBooleanObject((String)parameterValue, "true", "false",
"null");
                 }
             } catch (Exception e) {
                 throw new DockerClientException("Failed to validate parameter type for property
" + key);
@@ -80,7 +77,8 @@ public final class DockerHelper {
     }
 
     /**
-     * Transforms a Docker Component header value to its' analogous URI parameter
+     * Transforms a Docker Component header value to its' analogous URI
+     * parameter
      *
      * @param name
      * @return
@@ -101,7 +99,8 @@ public final class DockerHelper {
     }
 
     /**
-     * Transforms a Docker Component URI parameter to its' analogous header value
+     * Transforms a Docker Component URI parameter to its' analogous header
+     * value
      *
      * @param name
      * @return
@@ -111,7 +110,6 @@ public final class DockerHelper {
 
         StringBuilder formattedName = new StringBuilder(DockerConstants.DOCKER_PREFIX);
 
-
         if (name.length() > 0) {
             formattedName.append(name.substring(0, 1).toUpperCase());
             formattedName.append(name.substring(1));
@@ -121,8 +119,9 @@ public final class DockerHelper {
     }
 
     /**
-     * Attempts to locate a given property name within a URI parameter or the message header.
-     * A found value in a message header takes precedence over a URI parameter.
+     * Attempts to locate a given property name within a URI parameter or the
+     * message header. A found value in a message header takes precedence over a
+     * URI parameter.
      *
      * @param name
      * @param configuration
@@ -135,9 +134,9 @@ public final class DockerHelper {
     }
 
     /**
-     * Attempts to locate a given property name within a URI parameter or the message header.
-     * A found value in a message header takes precedence over a URI parameter. Returns a
-     * default value if given
+     * Attempts to locate a given property name within a URI parameter or the
+     * message header. A found value in a message header takes precedence over a
+     * URI parameter. Returns a default value if given
      *
      * @param name
      * @param configuration
@@ -148,7 +147,8 @@ public final class DockerHelper {
      */
     @SuppressWarnings("unchecked")
     public static <T> T getProperty(String name, DockerConfiguration configuration,
Message message, Class<T> clazz, T defaultValue) {
-        // First attempt to locate property from Message Header, then fallback to Endpoint
property
+        // First attempt to locate property from Message Header, then fallback
+        // to Endpoint property
 
         if (message != null) {
             T headerProperty = message.getHeader(name, clazz);
@@ -163,11 +163,11 @@ public final class DockerHelper {
         if (prop != null) {
 
             if (prop.getClass().isAssignableFrom(clazz)) {
-                return (T) prop;
+                return (T)prop;
             } else if (Integer.class == clazz) {
-                return (T) Integer.valueOf((String) prop);
+                return (T)Integer.valueOf((String)prop);
             } else if (Boolean.class == clazz) {
-                return (T) BooleanUtils.toBooleanObject((String) prop, "true", "false", "null");
+                return (T)BooleanUtils.toBooleanObject((String)prop, "true", "false", "null");
             }
         } else if (defaultValue != null) {
             return defaultValue;
@@ -175,12 +175,12 @@ public final class DockerHelper {
 
         return null;
 
-
     }
 
     /**
-     * Attempts to locate a given property which is an array by name within a URI parameter
or the message header.
-     * A found value in a message header takes precedence over a URI parameter.
+     * Attempts to locate a given property which is an array by name within a
+     * URI parameter or the message header. A found value in a message header
+     * takes precedence over a URI parameter.
      *
      * @param name
      * @param message
@@ -196,15 +196,15 @@ public final class DockerHelper {
             if (header != null) {
                 if (header.getClass().isAssignableFrom(clazz)) {
 
-                    T[] headerArray = (T[]) Array.newInstance(clazz, 1);
-                    headerArray[0] = (T) header;
+                    T[] headerArray = (T[])Array.newInstance(clazz, 1);
+                    headerArray[0] = (T)header;
                     return headerArray;
 
                 }
 
                 if (header.getClass().isArray()) {
                     if (header.getClass().getComponentType().isAssignableFrom(clazz) || header.getClass().getDeclaringClass().isAssignableFrom(clazz))
{
-                        return (T[]) header;
+                        return (T[])header;
                     }
                 }
             }
@@ -217,7 +217,7 @@ public final class DockerHelper {
 
     /**
      * @param headerName name of the header
-     * @param message    the Camel message
+     * @param message the Camel message
      * @return
      */
     public static String[] parseDelimitedStringHeader(String headerName, Message message)
{
@@ -227,11 +227,11 @@ public final class DockerHelper {
         if (header != null) {
 
             if (header instanceof String) {
-                return ((String) header).split(STRING_DELIMITER);
+                return ((String)header).split(STRING_DELIMITER);
             }
 
             if (header instanceof String[]) {
-                return (String[]) header;
+                return (String[])header;
             }
         }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/0e9af90a/components/camel-docker/src/main/java/org/apache/camel/component/docker/producer/AsyncDockerProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-docker/src/main/java/org/apache/camel/component/docker/producer/AsyncDockerProducer.java
b/components/camel-docker/src/main/java/org/apache/camel/component/docker/producer/AsyncDockerProducer.java
index aacce33..999a953 100644
--- a/components/camel-docker/src/main/java/org/apache/camel/component/docker/producer/AsyncDockerProducer.java
+++ b/components/camel-docker/src/main/java/org/apache/camel/component/docker/producer/AsyncDockerProducer.java
@@ -17,9 +17,11 @@
 package org.apache.camel.component.docker.producer;
 
 import java.io.File;
+import java.io.IOException;
 import java.io.InputStream;
 
 import com.github.dockerjava.api.DockerClient;
+import com.github.dockerjava.api.async.ResultCallback;
 import com.github.dockerjava.api.command.AttachContainerCmd;
 import com.github.dockerjava.api.command.BuildImageCmd;
 import com.github.dockerjava.api.command.ExecStartCmd;
@@ -92,7 +94,16 @@ public class AsyncDockerProducer extends DefaultAsyncProducer {
                         log.trace("build image callback {}", item);
                         super.onNext(item);
                     }
-                }).awaitImageId();
+                });
+
+                if (result != null) {
+                    String imageId = ((BuildImageResultCallback)result).awaitImageId();
+
+                    ((BuildImageResultCallback)result).close();
+                    
+                    result = imageId;
+                }
+
                 break;
             case PULL_IMAGE:
                 result = executePullImageRequest(client, message).exec(new PullImageResultCallback()
{
@@ -102,6 +113,13 @@ public class AsyncDockerProducer extends DefaultAsyncProducer {
                         super.onNext(item);
                     }
                 });
+
+                if (result != null) {
+                    result = ((PullImageResultCallback)result).awaitCompletion();
+
+                    ((PullImageResultCallback)result).close();
+                }
+
                 break;
             case PUSH_IMAGE:
                 result = executePushImageRequest(client, message).exec(new PushImageResultCallback()
{
@@ -110,7 +128,14 @@ public class AsyncDockerProducer extends DefaultAsyncProducer {
                         log.trace("push image callback {}", item);
                         super.onNext(item);
                     }
-                }).awaitCompletion();
+                });
+
+                if (result != null) {
+                    result = ((PushImageResultCallback)result).awaitCompletion();
+                    
+                    ((PushImageResultCallback)result).close();
+                }
+
                 break;
             /** Containers **/
             case ATTACH_CONTAINER:
@@ -121,7 +146,13 @@ public class AsyncDockerProducer extends DefaultAsyncProducer {
                         super.onNext(item);
                     }
 
-                }).awaitCompletion();
+                });
+
+                if (result != null) {
+                    result = ((AttachContainerResultCallback)result).awaitCompletion();
+                    
+                    ((AttachContainerResultCallback)result).close();
+                }
 
                 break;
             case LOG_CONTAINER:
@@ -132,8 +163,14 @@ public class AsyncDockerProducer extends DefaultAsyncProducer {
                         super.onNext(item);
                     }
 
-                }).awaitCompletion();
+                });
 
+                if (result != null) {
+                    result = ((LogContainerResultCallback)result).awaitCompletion();
+                    
+                    ((LogContainerResultCallback)result).close();
+                }
+                
                 break;
             case WAIT_CONTAINER:
                 // result contain a status code value
@@ -144,7 +181,16 @@ public class AsyncDockerProducer extends DefaultAsyncProducer {
                         super.onNext(item);
                     }
 
-                }).awaitStatusCode();
+                });
+                
+                if (result != null) {
+                    Integer statusCode = ((WaitContainerResultCallback)result).awaitStatusCode();
+                    
+                    ((WaitContainerResultCallback)result).close();
+                    
+                    result = statusCode;
+                }
+                
                 break;
             case EXEC_START:
                 result = executeExecStartRequest(client, message).exec(new ExecStartResultCallback()
{
@@ -154,7 +200,14 @@ public class AsyncDockerProducer extends DefaultAsyncProducer {
                         super.onNext(item);
                     }
 
-                }).awaitCompletion();
+                });
+                
+                if (result != null) {
+                    result = ((ExecStartResultCallback)result).awaitCompletion();
+                    
+                    ((ExecStartResultCallback)result).close();
+                }
+                
                 break;
             default:
                 throw new DockerException("Invalid operation: " + operation);
@@ -166,7 +219,7 @@ public class AsyncDockerProducer extends DefaultAsyncProducer {
 
                 return true;
             }
-        } catch (DockerException | InterruptedException e) {
+        } catch (DockerException | InterruptedException | IOException e) {
             log.error(e.getMessage(), e);
 
             return false;
@@ -313,7 +366,7 @@ public class AsyncDockerProducer extends DefaultAsyncProducer {
         ObjectHelper.notNull(containerId, "Container ID must be specified");
 
         AttachContainerCmd attachContainerCmd = client.attachContainerCmd(containerId);
-        
+
         Boolean followStream = DockerHelper.getProperty(DockerConstants.DOCKER_FOLLOW_STREAM,
configuration, message, Boolean.class);
 
         if (followStream != null) {

http://git-wip-us.apache.org/repos/asf/camel/blob/0e9af90a/components/camel-docker/src/test/java/org/apache/camel/component/docker/headers/AttachContainerCmdHeaderTest.java
----------------------------------------------------------------------
diff --git a/components/camel-docker/src/test/java/org/apache/camel/component/docker/headers/AttachContainerCmdHeaderTest.java
b/components/camel-docker/src/test/java/org/apache/camel/component/docker/headers/AttachContainerCmdHeaderTest.java
index f641168..95629a2 100644
--- a/components/camel-docker/src/test/java/org/apache/camel/component/docker/headers/AttachContainerCmdHeaderTest.java
+++ b/components/camel-docker/src/test/java/org/apache/camel/component/docker/headers/AttachContainerCmdHeaderTest.java
@@ -18,6 +18,8 @@ package org.apache.camel.component.docker.headers;
 
 import java.util.Map;
 
+import com.github.dockerjava.api.command.AttachContainerCmd;
+import com.github.dockerjava.core.command.AttachContainerResultCallback;
 import org.apache.camel.component.docker.DockerConstants;
 import org.apache.camel.component.docker.DockerOperation;
 import org.junit.Test;
@@ -25,9 +27,6 @@ import org.mockito.Matchers;
 import org.mockito.Mock;
 import org.mockito.Mockito;
 
-import com.github.dockerjava.api.command.AttachContainerCmd;
-import com.github.dockerjava.core.command.AttachContainerResultCallback;
-
 /**
  * Validates Attach Container Request headers are applied properly
  */
@@ -38,9 +37,9 @@ public class AttachContainerCmdHeaderTest extends BaseDockerHeaderTest<AttachCon
 
     @Mock
     private AttachContainerResultCallback callback;
-    
+
     @Test
-    public void attachContainerHeaderTest(){
+    public void attachContainerHeaderTest() {
 
         String containerId = "9c09acd48a25";
         boolean stdOut = true;
@@ -57,9 +56,8 @@ public class AttachContainerCmdHeaderTest extends BaseDockerHeaderTest<AttachCon
         headers.put(DockerConstants.DOCKER_TIMESTAMPS, timestamps);
         headers.put(DockerConstants.DOCKER_LOGS, logs);
 
-
         template.sendBodyAndHeaders("direct:in", "", headers);
-        
+
         Mockito.verify(dockerClient, Mockito.times(1)).attachContainerCmd(containerId);
         Mockito.verify(mockObject, Mockito.times(1)).withFollowStream(Matchers.eq(followStream));
         Mockito.verify(mockObject, Mockito.times(1)).withLogs(Matchers.eq(logs));
@@ -72,6 +70,12 @@ public class AttachContainerCmdHeaderTest extends BaseDockerHeaderTest<AttachCon
     @Override
     protected void setupMocks() {
         Mockito.when(dockerClient.attachContainerCmd(Matchers.anyString())).thenReturn(mockObject);
+        Mockito.when(mockObject.exec(Mockito.anyObject())).thenReturn(callback);
+        try {
+            Mockito.when(callback.awaitCompletion()).thenReturn(callback);
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+        }
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/camel/blob/0e9af90a/components/camel-docker/src/test/java/org/apache/camel/component/docker/headers/BuildImageCmdHeaderTest.java
----------------------------------------------------------------------
diff --git a/components/camel-docker/src/test/java/org/apache/camel/component/docker/headers/BuildImageCmdHeaderTest.java
b/components/camel-docker/src/test/java/org/apache/camel/component/docker/headers/BuildImageCmdHeaderTest.java
index 235ef98..dff491b 100644
--- a/components/camel-docker/src/test/java/org/apache/camel/component/docker/headers/BuildImageCmdHeaderTest.java
+++ b/components/camel-docker/src/test/java/org/apache/camel/component/docker/headers/BuildImageCmdHeaderTest.java
@@ -22,7 +22,7 @@ import java.io.InputStream;
 import java.util.Map;
 
 import com.github.dockerjava.api.command.BuildImageCmd;
-
+import com.github.dockerjava.core.command.BuildImageResultCallback;
 import org.apache.camel.component.docker.DockerConstants;
 import org.apache.camel.component.docker.DockerOperation;
 import org.junit.Test;
@@ -42,6 +42,9 @@ public class BuildImageCmdHeaderTest extends BaseDockerHeaderTest<BuildImageCmd>
     private InputStream inputStream;
 
     @Mock
+    private BuildImageResultCallback callback;
+    
+    @Mock
     private File file;
 
     private String repository = "docker/empty";
@@ -81,6 +84,8 @@ public class BuildImageCmdHeaderTest extends BaseDockerHeaderTest<BuildImageCmd>
         Mockito.when(dockerClient.buildImageCmd(Matchers.any(InputStream.class))).thenReturn(mockObject);
         Mockito.when(dockerClient.buildImageCmd(Matchers.any(File.class))).thenReturn(mockObject);
 
+        Mockito.when(mockObject.exec(Mockito.anyObject())).thenReturn(callback);
+        Mockito.when(callback.awaitImageId()).thenReturn(Mockito.anyString());
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/camel/blob/0e9af90a/components/camel-docker/src/test/java/org/apache/camel/component/docker/headers/CreateContainerCmdHeaderTest.java
----------------------------------------------------------------------
diff --git a/components/camel-docker/src/test/java/org/apache/camel/component/docker/headers/CreateContainerCmdHeaderTest.java
b/components/camel-docker/src/test/java/org/apache/camel/component/docker/headers/CreateContainerCmdHeaderTest.java
index f140cde..8a5317c 100644
--- a/components/camel-docker/src/test/java/org/apache/camel/component/docker/headers/CreateContainerCmdHeaderTest.java
+++ b/components/camel-docker/src/test/java/org/apache/camel/component/docker/headers/CreateContainerCmdHeaderTest.java
@@ -118,7 +118,7 @@ public class CreateContainerCmdHeaderTest extends BaseDockerHeaderTest<CreateCon
         Mockito.verify(mockObject, Mockito.times(1)).withAttachStderr(attachStdErr);
         Mockito.verify(mockObject, Mockito.times(1)).withAttachStdin(attachStdIn);
         Mockito.verify(mockObject, Mockito.times(1)).withAttachStdout(attachStdOut);
-//        Mockito.verify(mockObject, Mockito.times(1)).withMemoryLimit(memoryLimit);
+        Mockito.verify(mockObject, Mockito.times(1)).withMemory(memoryLimit);
         Mockito.verify(mockObject, Mockito.times(1)).withMemorySwap(swapMemory);
         Mockito.verify(mockObject, Mockito.times(1)).withCpuShares(cpuShares);
         Mockito.verify(mockObject, Mockito.times(1)).withVolumes(volumes);

http://git-wip-us.apache.org/repos/asf/camel/blob/0e9af90a/components/camel-docker/src/test/java/org/apache/camel/component/docker/headers/ExecStartCmdHeaderTest.java
----------------------------------------------------------------------
diff --git a/components/camel-docker/src/test/java/org/apache/camel/component/docker/headers/ExecStartCmdHeaderTest.java
b/components/camel-docker/src/test/java/org/apache/camel/component/docker/headers/ExecStartCmdHeaderTest.java
index d7b85ab..faed4b0 100644
--- a/components/camel-docker/src/test/java/org/apache/camel/component/docker/headers/ExecStartCmdHeaderTest.java
+++ b/components/camel-docker/src/test/java/org/apache/camel/component/docker/headers/ExecStartCmdHeaderTest.java
@@ -19,7 +19,7 @@ package org.apache.camel.component.docker.headers;
 import java.util.Map;
 
 import com.github.dockerjava.api.command.ExecStartCmd;
-
+import com.github.dockerjava.core.command.ExecStartResultCallback;
 import org.apache.camel.component.docker.DockerConstants;
 import org.apache.camel.component.docker.DockerOperation;
 import org.junit.Test;
@@ -35,6 +35,9 @@ public class ExecStartCmdHeaderTest extends BaseDockerHeaderTest<ExecStartCmd>
{
     @Mock
     private ExecStartCmd mockObject;
 
+    @Mock
+    private ExecStartResultCallback callback;
+    
     @Test
     public void execCreateHeaderTest() {
 
@@ -55,6 +58,12 @@ public class ExecStartCmdHeaderTest extends BaseDockerHeaderTest<ExecStartCmd>
{
     @Override
     protected void setupMocks() {
         Mockito.when(dockerClient.execStartCmd(Matchers.anyString())).thenReturn(mockObject);
+        Mockito.when(mockObject.exec(Mockito.anyObject())).thenReturn(callback);
+        try {
+            Mockito.when(callback.awaitCompletion()).thenReturn(callback);
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+        }
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/camel/blob/0e9af90a/components/camel-docker/src/test/java/org/apache/camel/component/docker/headers/LogContainerCmdHeaderTest.java
----------------------------------------------------------------------
diff --git a/components/camel-docker/src/test/java/org/apache/camel/component/docker/headers/LogContainerCmdHeaderTest.java
b/components/camel-docker/src/test/java/org/apache/camel/component/docker/headers/LogContainerCmdHeaderTest.java
index cc20d8e..9c15638 100644
--- a/components/camel-docker/src/test/java/org/apache/camel/component/docker/headers/LogContainerCmdHeaderTest.java
+++ b/components/camel-docker/src/test/java/org/apache/camel/component/docker/headers/LogContainerCmdHeaderTest.java
@@ -19,7 +19,7 @@ package org.apache.camel.component.docker.headers;
 import java.util.Map;
 
 import com.github.dockerjava.api.command.LogContainerCmd;
-
+import com.github.dockerjava.core.command.LogContainerResultCallback;
 import org.apache.camel.component.docker.DockerConstants;
 import org.apache.camel.component.docker.DockerOperation;
 import org.junit.Test;
@@ -35,6 +35,9 @@ public class LogContainerCmdHeaderTest extends BaseDockerHeaderTest<LogContainer
     @Mock
     private LogContainerCmd mockObject;
 
+    @Mock
+    private LogContainerResultCallback callback;
+    
     @Test
     public void logContainerHeaderTest() {
 
@@ -70,6 +73,12 @@ public class LogContainerCmdHeaderTest extends BaseDockerHeaderTest<LogContainer
     @Override
     protected void setupMocks() {
         Mockito.when(dockerClient.logContainerCmd(Matchers.anyString())).thenReturn(mockObject);
+        Mockito.when(mockObject.exec(Mockito.anyObject())).thenReturn(callback);
+        try {
+            Mockito.when(callback.awaitCompletion()).thenReturn(callback);
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+        }
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/camel/blob/0e9af90a/components/camel-docker/src/test/java/org/apache/camel/component/docker/headers/PullImageCmdHeaderTest.java
----------------------------------------------------------------------
diff --git a/components/camel-docker/src/test/java/org/apache/camel/component/docker/headers/PullImageCmdHeaderTest.java
b/components/camel-docker/src/test/java/org/apache/camel/component/docker/headers/PullImageCmdHeaderTest.java
index b2c75fe..1a01b03 100644
--- a/components/camel-docker/src/test/java/org/apache/camel/component/docker/headers/PullImageCmdHeaderTest.java
+++ b/components/camel-docker/src/test/java/org/apache/camel/component/docker/headers/PullImageCmdHeaderTest.java
@@ -19,7 +19,7 @@ package org.apache.camel.component.docker.headers;
 import java.util.Map;
 
 import com.github.dockerjava.api.command.PullImageCmd;
-
+import com.github.dockerjava.core.command.PullImageResultCallback;
 import org.apache.camel.component.docker.DockerConstants;
 import org.apache.camel.component.docker.DockerOperation;
 import org.junit.Test;
@@ -35,6 +35,9 @@ public class PullImageCmdHeaderTest extends BaseDockerHeaderTest<PullImageCmd>
{
     @Mock
     private PullImageCmd mockObject;
 
+    @Mock
+    private PullImageResultCallback callback;
+    
     @Test
     public void pullImageHeaderTest() {
 
@@ -59,6 +62,12 @@ public class PullImageCmdHeaderTest extends BaseDockerHeaderTest<PullImageCmd>
{
     @Override
     protected void setupMocks() {
         Mockito.when(dockerClient.pullImageCmd(Matchers.anyString())).thenReturn(mockObject);
+        Mockito.when(mockObject.exec(Mockito.anyObject())).thenReturn(callback);
+        try {
+            Mockito.when(callback.awaitCompletion()).thenReturn(callback);
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+        }
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/camel/blob/0e9af90a/components/camel-docker/src/test/java/org/apache/camel/component/docker/headers/PushImageCmdHeaderTest.java
----------------------------------------------------------------------
diff --git a/components/camel-docker/src/test/java/org/apache/camel/component/docker/headers/PushImageCmdHeaderTest.java
b/components/camel-docker/src/test/java/org/apache/camel/component/docker/headers/PushImageCmdHeaderTest.java
index 7ae6279..85e4e7c 100644
--- a/components/camel-docker/src/test/java/org/apache/camel/component/docker/headers/PushImageCmdHeaderTest.java
+++ b/components/camel-docker/src/test/java/org/apache/camel/component/docker/headers/PushImageCmdHeaderTest.java
@@ -19,7 +19,7 @@ package org.apache.camel.component.docker.headers;
 import java.util.Map;
 
 import com.github.dockerjava.api.command.PushImageCmd;
-
+import com.github.dockerjava.core.command.PushImageResultCallback;
 import org.apache.camel.component.docker.DockerClientProfile;
 import org.apache.camel.component.docker.DockerConstants;
 import org.apache.camel.component.docker.DockerOperation;
@@ -36,6 +36,9 @@ public class PushImageCmdHeaderTest extends BaseDockerHeaderTest<PushImageCmd>
{
     @Mock
     private PushImageCmd mockObject;
 
+    @Mock
+    private PushImageResultCallback callback;
+    
     private String userName = "jdoe";
     private String password = "password";
     private String email = "jdoe@example.com";
@@ -67,6 +70,12 @@ public class PushImageCmdHeaderTest extends BaseDockerHeaderTest<PushImageCmd>
{
     @Override
     protected void setupMocks() {
         Mockito.when(dockerClient.pushImageCmd(Matchers.anyString())).thenReturn(mockObject);
+        Mockito.when(mockObject.exec(Mockito.anyObject())).thenReturn(callback);
+        try {
+            Mockito.when(callback.awaitCompletion()).thenReturn(callback);
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+        }
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/camel/blob/0e9af90a/components/camel-docker/src/test/java/org/apache/camel/component/docker/headers/WaitContainerCmdHeaderTest.java
----------------------------------------------------------------------
diff --git a/components/camel-docker/src/test/java/org/apache/camel/component/docker/headers/WaitContainerCmdHeaderTest.java
b/components/camel-docker/src/test/java/org/apache/camel/component/docker/headers/WaitContainerCmdHeaderTest.java
index 03fc687..a3b0873 100644
--- a/components/camel-docker/src/test/java/org/apache/camel/component/docker/headers/WaitContainerCmdHeaderTest.java
+++ b/components/camel-docker/src/test/java/org/apache/camel/component/docker/headers/WaitContainerCmdHeaderTest.java
@@ -19,7 +19,7 @@ package org.apache.camel.component.docker.headers;
 import java.util.Map;
 
 import com.github.dockerjava.api.command.WaitContainerCmd;
-
+import com.github.dockerjava.core.command.WaitContainerResultCallback;
 import org.apache.camel.component.docker.DockerConstants;
 import org.apache.camel.component.docker.DockerOperation;
 import org.junit.Test;
@@ -35,6 +35,9 @@ public class WaitContainerCmdHeaderTest extends BaseDockerHeaderTest<WaitContain
     @Mock
     private WaitContainerCmd mockObject;
 
+    @Mock
+    private WaitContainerResultCallback callback;
+    
     @Test
     public void waitContainerHeaderTest() {
 
@@ -53,6 +56,8 @@ public class WaitContainerCmdHeaderTest extends BaseDockerHeaderTest<WaitContain
     @Override
     protected void setupMocks() {
         Mockito.when(dockerClient.waitContainerCmd(Matchers.anyString())).thenReturn(mockObject);
+        Mockito.when(mockObject.exec(Mockito.anyObject())).thenReturn(callback);
+        Mockito.when(callback.awaitStatusCode()).thenReturn(Mockito.anyInt());
     }
 
     @Override


Mime
View raw message