Repository: docker-java/docker-java
Pull request #268 (2015-07-11 19:02:57)

#266 Concurrent DockerCmdExecFactory.getDefaultDockerCmdExecFactory fails on reload
Wrote test and added fix for issue


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 808cae3c..ab3c373e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,12 +5,11 @@ Latest SNAPSHOT
 ---
 
 * [#263](https://github.com/docker-java/docker-java/pull/263) Refactoring of streaming commands APIs (event, stats, log, attach)
-* [#262](https://github.com/docker-java/docker-java/pull/262) Accept filters in list containers 
 * [#260](https://github.com/docker-java/docker-java/pull/260) Add labels to create and inspect container
 
 v.1.4.0
 ---
-* [#248](https://github.com/docker-java/docker-java/pull/248) Removed deprecated start options
+* [#248](https://github.com/docker-java/docker-java/pull/233) Removed deprecated start options
 * [#247](https://github.com/docker-java/docker-java/pull/247) Add Domainname attribute on create command
 * [#245](https://github.com/docker-java/docker-java/pull/245) Added ReadonlyRootfs option
 * [#233](https://github.com/docker-java/docker-java/pull/233) Labels are array of Strings (fixes #232) 
diff --git a/README.md b/README.md
index 5c6c55d3..52d79192 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@
 
 Java API client for [Docker](http://docs.docker.io/ "Docker")
 
-Supports a subset of the Docker Remote API [v1.19](https://github.com/docker/docker/blob/master/docs/reference/api/docker_remote_api_v1.19.md), Docker Server version 1.7.x
+Supports a subset of the Docker Remote API [v1.18](https://github.com/docker/docker/blob/master/docs/reference/api/docker_remote_api_v1.18.md), Docker Server version 1.6.x
 
 <b>The current implementation is based on Jersey 2.x and therefore classpath incompatible with older Jersey 1.x dependent libraries!</b>
 
diff --git a/src/main/java/com/github/dockerjava/api/command/CreateContainerCmd.java b/src/main/java/com/github/dockerjava/api/command/CreateContainerCmd.java
index 9ad44b2c..3e31321e 100644
--- a/src/main/java/com/github/dockerjava/api/command/CreateContainerCmd.java
+++ b/src/main/java/com/github/dockerjava/api/command/CreateContainerCmd.java
@@ -43,26 +43,6 @@ public interface CreateContainerCmd extends DockerCmd<CreateContainerResponse> {
 
     public int getCpuShares();
 
-    /**
-     * @since 1.19
-     */
-    public Integer getCpuPeriod();
-
-    /**
-     * @since 1.19
-     */
-    public String getCpusetMems();
-
-    /**
-     * @since 1.19
-     */
-    public Integer getBlkioWeight();
-
-    /**
-     * @since 1.19
-     */
-    public Boolean isOomKillDisable();
-
     public Device[] getDevices();
 
     public String[] getDns();
@@ -159,26 +139,6 @@ public interface CreateContainerCmd extends DockerCmd<CreateContainerResponse> {
 
     public CreateContainerCmd withCpuShares(int cpuShares);
 
-    /**
-     * @since 1.19
-     */
-    public CreateContainerCmd withCpuPeriod(Integer cpuPeriod);
-
-    /**
-     * @since 1.19
-     */
-    public CreateContainerCmd withCpusetMems(String cpusetMems);
-
-    /**
-     * @since 1.19
-     */
-    public CreateContainerCmd withBlkioWeight(Integer blkioWeight);
-
-    /**
-     * @since 1.19
-     */
-    public CreateContainerCmd withOomKillDisable(Boolean oomKillDisable);
-
     /**
      * Add host devices to the container
      */
diff --git a/src/main/java/com/github/dockerjava/api/command/ListContainersCmd.java b/src/main/java/com/github/dockerjava/api/command/ListContainersCmd.java
index c2a116be..6d641f2e 100644
--- a/src/main/java/com/github/dockerjava/api/command/ListContainersCmd.java
+++ b/src/main/java/com/github/dockerjava/api/command/ListContainersCmd.java
@@ -3,7 +3,6 @@ package com.github.dockerjava.api.command;
 import java.util.List;
 
 import com.github.dockerjava.api.model.Container;
-import com.github.dockerjava.api.model.Filters;
 
 /**
  * List containers
@@ -32,8 +31,6 @@ public interface ListContainersCmd extends DockerCmd<List<Container>> {
 
     public String getBeforeId();
 
-    public Filters getFilters();
-
     public ListContainersCmd withShowAll(boolean showAll);
 
     public ListContainersCmd withShowSize(boolean showSize);
@@ -44,8 +41,6 @@ public interface ListContainersCmd extends DockerCmd<List<Container>> {
 
     public ListContainersCmd withBefore(String before);
 
-    public ListContainersCmd withFilters(Filters filters);
-
     public static interface Exec extends DockerCmdExec<ListContainersCmd, List<Container>> {
     }
 
diff --git a/src/main/java/com/github/dockerjava/api/model/Container.java b/src/main/java/com/github/dockerjava/api/model/Container.java
index 8152974e..6a97e20b 100644
--- a/src/main/java/com/github/dockerjava/api/model/Container.java
+++ b/src/main/java/com/github/dockerjava/api/model/Container.java
@@ -1,7 +1,5 @@
 package com.github.dockerjava.api.model;
 
-import java.util.Map;
-
 import org.apache.commons.lang.builder.ToStringBuilder;
 
 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
@@ -33,9 +31,6 @@ public class Container {
     @JsonProperty("Ports")
     public Port[] ports;
 
-    @JsonProperty("Labels")
-    public Map<String, String> labels;
-
     @JsonProperty("Status")
     private String status;
 
@@ -63,10 +58,6 @@ public class Container {
         return ports;
     }
 
-    public Map<String, String> getLabels() {
-        return labels;
-    }
-
     public String[] getNames() {
         return names;
     }
diff --git a/src/main/java/com/github/dockerjava/api/model/Filters.java b/src/main/java/com/github/dockerjava/api/model/Filters.java
deleted file mode 100644
index b912b541..00000000
--- a/src/main/java/com/github/dockerjava/api/model/Filters.java
+++ /dev/null
@@ -1,103 +0,0 @@
-package com.github.dockerjava.api.model;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import javax.ws.rs.core.MediaType;
-
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
-
-/**
- * Representation of Docker filters.
- *
- * @author Carlos Sanchez <carlos@apache.org>
- *
- */
-public class Filters {
-
-    private static ObjectMapper OBJECT_MAPPER = new JacksonJaxbJsonProvider().locateMapper(Map.class,
-            MediaType.APPLICATION_JSON_TYPE);
-
-    private Map<String, List<String>> filters = new HashMap<String, List<String>>();
-
-    public Filters() {
-    }
-
-    public Filters withFilter(String key, String... value) {
-        filters.put(key, Arrays.asList(value));
-        return this;
-    }
-
-    public List<String> getFilter(String key) {
-        return filters.get(key);
-    }
-
-    public Filters withImages(String... image) {
-        withFilter("image", image);
-        return this;
-    }
-
-    public List<String> getImage() {
-        return getFilter("image");
-    }
-
-    public Filters withContainers(String... container) {
-        withFilter("container", container);
-        return this;
-    }
-
-    public List<String> getContainer() {
-        return getFilter("container");
-    }
-
-    /**
-     * Filter by labels
-     *
-     * @param labels
-     *            string array in the form ["key"] or ["key=value"] or a mix of both
-     * @return
-     */
-    public Filters withLabels(String... labels) {
-        withFilter("label", labels);
-        return this;
-    }
-
-    /**
-     * Filter by labels
-     *
-     * @param labels
-     *            {@link Map} of labels that contains label keys and values
-     * @return
-     */
-    public Filters withLabels(Map<String, String> labels) {
-        withFilter("label", labelsMapToList(labels).toArray(new String[labels.size()]));
-        return this;
-    }
-
-    private static List<String> labelsMapToList(Map<String, String> labels) {
-        List<String> result = new ArrayList<String>();
-        for (Entry<String, String> entry : labels.entrySet()) {
-            String rest = (entry.getValue() != null & !entry.getValue().isEmpty()) ? "=" + entry.getValue() : "";
-
-            String label = entry.getKey() + rest;
-
-            result.add(label);
-        }
-        return result;
-    }
-
-    @Override
-    public String toString() {
-        try {
-            return OBJECT_MAPPER.writeValueAsString(filters);
-        } catch (JsonProcessingException e) {
-            throw new RuntimeException(e);
-        }
-    }
-}
diff --git a/src/main/java/com/github/dockerjava/api/model/Node.java b/src/main/java/com/github/dockerjava/api/model/Node.java
index 4bbeeec3..4fcf04e6 100644
--- a/src/main/java/com/github/dockerjava/api/model/Node.java
+++ b/src/main/java/com/github/dockerjava/api/model/Node.java
@@ -7,31 +7,31 @@ import com.fasterxml.jackson.annotation.JsonProperty;
  */
 public class Node {
 
-    @JsonProperty("Name")
-    private String name;
+  @JsonProperty("Name")
+  private String name;
 
-    @JsonProperty("Id")
-    private String id;
+  @JsonProperty("Id")
+  private String id;
 
-    @JsonProperty("Addr")
-    private String addr;
+  @JsonProperty("Addr")
+  private String addr;
 
-    @JsonProperty("Ip")
-    private String ip;
+  @JsonProperty("Ip")
+  private String ip;
 
-    public String getName() {
-        return name;
-    }
+  public String getName() {
+    return name;
+  }
 
-    public String getId() {
-        return id;
-    }
+  public String getId() {
+    return id;
+  }
 
-    public String getAddr() {
-        return addr;
-    }
+  public String getAddr() {
+    return addr;
+  }
 
-    public String getIp() {
-        return ip;
-    }
+  public String getIp() {
+    return ip;
+  }
 }
diff --git a/src/main/java/com/github/dockerjava/core/DockerClientBuilder.java b/src/main/java/com/github/dockerjava/core/DockerClientBuilder.java
index f906f43d..7524679b 100644
--- a/src/main/java/com/github/dockerjava/core/DockerClientBuilder.java
+++ b/src/main/java/com/github/dockerjava/core/DockerClientBuilder.java
@@ -1,15 +1,28 @@
 package com.github.dockerjava.core;
 
-import java.util.ServiceLoader;
-
 import com.github.dockerjava.api.DockerClient;
 import com.github.dockerjava.api.command.DockerCmdExecFactory;
 import com.github.dockerjava.core.DockerClientConfig.DockerClientConfigBuilder;
 
+import java.util.Iterator;
+import java.util.ServiceLoader;
+
 public class DockerClientBuilder {
 
+    private static Class<? extends DockerCmdExecFactory> factoryClass;
     private static ServiceLoader<DockerCmdExecFactory> serviceLoader = ServiceLoader.load(DockerCmdExecFactory.class);
 
+    static {
+        serviceLoader.reload();
+        Iterator<DockerCmdExecFactory> iterator = serviceLoader.iterator();
+        if (!iterator.hasNext()) {
+           throw new RuntimeException("Fatal: Can't find any implementation of '"
+                 + DockerCmdExecFactory.class.getName() + "' in the current classpath.");
+        }
+
+        factoryClass = iterator.next().getClass();
+    }
+
     private DockerClientImpl dockerClient = null;
 
     private DockerCmdExecFactory dockerCmdExecFactory = null;
@@ -35,15 +48,14 @@ public class DockerClientBuilder {
     }
 
     public static DockerCmdExecFactory getDefaultDockerCmdExecFactory() {
-        // clearing the cache is needed because otherwise we will get
-        // the same DockerCmdExecFactory instance each time
-        serviceLoader.reload();
-        if (!serviceLoader.iterator().hasNext()) {
-            throw new RuntimeException("Fatal: Can't find any implementation of '"
-                    + DockerCmdExecFactory.class.getName() + "' in the current classpath.");
-        }
-
-        return serviceLoader.iterator().next();
+       try
+       {
+          return factoryClass.newInstance();
+       }
+       catch (InstantiationException | IllegalAccessException e)
+       {
+          throw new RuntimeException("Fatal: Can't create new instance of '" + factoryClass.getName() + "'");
+       }
     }
 
     public DockerClientBuilder withDockerCmdExecFactory(DockerCmdExecFactory dockerCmdExecFactory) {
diff --git a/src/main/java/com/github/dockerjava/core/command/CreateContainerCmdImpl.java b/src/main/java/com/github/dockerjava/core/command/CreateContainerCmdImpl.java
index 32835b30..3caf3c1b 100644
--- a/src/main/java/com/github/dockerjava/core/command/CreateContainerCmdImpl.java
+++ b/src/main/java/com/github/dockerjava/core/command/CreateContainerCmdImpl.java
@@ -55,9 +55,6 @@ public class CreateContainerCmdImpl extends AbstrDockerCmd<CreateContainerCmd, C
     @JsonProperty("CpuShares")
     private int cpuShares = 0;
 
-    @JsonProperty("CpuPeriod")
-    private Integer cpuPeriod;
-
     @JsonProperty("Cpuset")
     private String cpuset;
 
@@ -115,15 +112,6 @@ public class CreateContainerCmdImpl extends AbstrDockerCmd<CreateContainerCmd, C
     @JsonProperty("Labels")
     private Map<String, String> labels;
 
-    @JsonProperty("CpusetMems")
-    private String cpusetMems;
-
-    @JsonProperty("BlkioWeight")
-    private Integer blkioWeight;
-
-    @JsonProperty("OomKillDisable")
-    private Boolean oomKillDisable;
-
     public CreateContainerCmdImpl(CreateContainerCmd.Exec exec, String image) {
         super(exec);
         checkNotNull(image, "image was not specified");
@@ -172,26 +160,6 @@ public class CreateContainerCmdImpl extends AbstrDockerCmd<CreateContainerCmd, C
         return cpuShares;
     }
 
-    @Override
-    public Integer getCpuPeriod() {
-        return cpuPeriod;
-    }
-
-    @Override
-    public String getCpusetMems() {
-        return cpusetMems;
-    }
-
-    @Override
-    public Integer getBlkioWeight() {
-        return blkioWeight;
-    }
-
-    @Override
-    public Boolean isOomKillDisable() {
-        return oomKillDisable;
-    }
-
     @Override
     @JsonIgnore
     public Device[] getDevices() {
@@ -441,30 +409,6 @@ public class CreateContainerCmdImpl extends AbstrDockerCmd<CreateContainerCmd, C
         return this;
     }
 
-    @Override
-    public CreateContainerCmd withCpuPeriod(Integer cpuPeriod) {
-        this.cpuPeriod = cpuPeriod;
-        return this;
-    }
-
-    @Override
-    public CreateContainerCmd withCpusetMems(String cpusetMems) {
-        this.cpusetMems = cpusetMems;
-        return null;
-    }
-
-    @Override
-    public CreateContainerCmd withBlkioWeight(Integer blkioWeight) {
-        this.blkioWeight = blkioWeight;
-        return null;
-    }
-
-    @Override
-    public CreateContainerCmd withOomKillDisable(Boolean oomKillDisable) {
-        this.oomKillDisable = oomKillDisable;
-        return null;
-    }
-
     @Override
     public CreateContainerCmd withDevices(Device... devices) {
         this.hostConfig.setDevices(devices);
diff --git a/src/main/java/com/github/dockerjava/core/command/FrameReader.java b/src/main/java/com/github/dockerjava/core/command/FrameReader.java
index bb5a5d17..a6db922d 100644
--- a/src/main/java/com/github/dockerjava/core/command/FrameReader.java
+++ b/src/main/java/com/github/dockerjava/core/command/FrameReader.java
@@ -46,6 +46,7 @@ public class FrameReader implements AutoCloseable {
 
         if (rawStreamDetected) {
 
+
             int read = inputStream.read(rawBuffer);
 
             return new Frame(StreamType.RAW, Arrays.copyOf(rawBuffer, read));
@@ -67,7 +68,7 @@ public class FrameReader implements AutoCloseable {
 
             StreamType streamType = streamType(header[0]);
 
-            if (streamType.equals(StreamType.RAW)) {
+            if(streamType.equals(StreamType.RAW)) {
                 rawStreamDetected = true;
                 return new Frame(StreamType.RAW, Arrays.copyOf(header, HEADER_SIZE));
             }
diff --git a/src/main/java/com/github/dockerjava/core/command/ListContainersCmdImpl.java b/src/main/java/com/github/dockerjava/core/command/ListContainersCmdImpl.java
index b957a3bd..13bb02cf 100644
--- a/src/main/java/com/github/dockerjava/core/command/ListContainersCmdImpl.java
+++ b/src/main/java/com/github/dockerjava/core/command/ListContainersCmdImpl.java
@@ -1,12 +1,12 @@
 package com.github.dockerjava.core.command;
 
-import static com.google.common.base.Preconditions.*;
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
 
 import java.util.List;
 
 import com.github.dockerjava.api.command.ListContainersCmd;
 import com.github.dockerjava.api.model.Container;
-import com.github.dockerjava.api.model.Filters;
 
 /**
  * List containers
@@ -32,8 +32,6 @@ public class ListContainersCmdImpl extends AbstrDockerCmd<ListContainersCmd, Lis
 
     private String sinceId, beforeId;
 
-    private Filters filters;
-
     public ListContainersCmdImpl(ListContainersCmd.Exec exec) {
         super(exec);
     }
@@ -63,11 +61,6 @@ public class ListContainersCmdImpl extends AbstrDockerCmd<ListContainersCmd, Lis
         return beforeId;
     }
 
-    @Override
-    public Filters getFilters() {
-        return filters;
-    }
-
     @Override
     public ListContainersCmd withShowAll(boolean showAll) {
         this.showAll = showAll;
@@ -101,18 +94,11 @@ public class ListContainersCmdImpl extends AbstrDockerCmd<ListContainersCmd, Lis
         return this;
     }
 
-    @Override
-    public ListContainersCmd withFilters(Filters filters) {
-        checkNotNull(filters, "filters was not specified");
-        this.filters = filters;
-        return this;
-    }
-
     @Override
     public String toString() {
         return new StringBuilder("ps ").append(showAll ? "--all=true" : "").append(showSize ? "--size=true" : "")
-                .append(sinceId != null ? " --since " + sinceId : "")
-                .append(beforeId != null ? " --before " + beforeId : "").append(limit != -1 ? "-n " + limit : "")
-                .append(filters != null ? " --filters " + filters : "").toString();
+                .append(sinceId != null ? "--since " + sinceId : "")
+                .append(beforeId != null ? "--before " + beforeId : "").append(limit != -1 ? "-n " + limit : "")
+                .toString();
     }
 }
diff --git a/src/main/java/com/github/dockerjava/jaxrs/ListContainersCmdExec.java b/src/main/java/com/github/dockerjava/jaxrs/ListContainersCmdExec.java
index 5feb5bda..5bb905b5 100644
--- a/src/main/java/com/github/dockerjava/jaxrs/ListContainersCmdExec.java
+++ b/src/main/java/com/github/dockerjava/jaxrs/ListContainersCmdExec.java
@@ -1,7 +1,5 @@
 package com.github.dockerjava.jaxrs;
 
-import static com.google.common.net.UrlEscapers.*;
-
 import java.util.List;
 
 import javax.ws.rs.client.WebTarget;
@@ -34,11 +32,6 @@ public class ListContainersCmdExec extends AbstrDockerCmdExec<ListContainersCmd,
             webResource = webResource.queryParam("limit", String.valueOf(command.getLimit()));
         }
 
-        if (command.getFilters() != null) {
-            webResource = webResource.queryParam("filters",
-                    urlPathSegmentEscaper().escape(command.getFilters().toString()));
-        }
-
         LOGGER.trace("GET: {}", webResource);
         List<Container> containers = webResource.request().accept(MediaType.APPLICATION_JSON)
                 .get(new GenericType<List<Container>>() {


Test patch:
diff --git a/src/test/java/com/github/dockerjava/client/AbstractDockerClientTest.java b/src/test/java/com/github/dockerjava/client/AbstractDockerClientTest.java
index 7faca037..e96e5bcc 100644
--- a/src/test/java/com/github/dockerjava/client/AbstractDockerClientTest.java
+++ b/src/test/java/com/github/dockerjava/client/AbstractDockerClientTest.java
@@ -181,6 +181,7 @@ public abstract class AbstractDockerClientTest extends Assert {
         assertThat(volumes, contains(expectedVolumes));
     }
 
+
     public static class CollectFramesCallback extends ResultCallbackTemplate<Frame> {
         public final List<Frame> frames = new ArrayList<Frame>();
 
diff --git a/src/test/java/com/github/dockerjava/core/DockerClientBuilderTest.java b/src/test/java/com/github/dockerjava/core/DockerClientBuilderTest.java
new file mode 100644
index 00000000..9b23e3b6
--- /dev/null
+++ b/src/test/java/com/github/dockerjava/core/DockerClientBuilderTest.java
@@ -0,0 +1,93 @@
+package com.github.dockerjava.core;
+
+import com.github.dockerjava.api.command.DockerCmdExecFactory;
+import org.testng.annotations.Test;
+
+import java.util.*;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotNull;
+
+public class DockerClientBuilderTest
+{
+   // Amount of instances created in test
+   private static final int AMOUNT = 100;
+
+   @Test
+   public void testConcurrentClientBuilding() throws Exception
+   {
+      // we use it to check instance uniqueness
+      final Set<DockerCmdExecFactory> instances = Collections.synchronizedSet(new HashSet<DockerCmdExecFactory>());
+
+      Runnable runnable = new Runnable()
+      {
+         @Override
+         public void run()
+         {
+            DockerCmdExecFactory factory = DockerClientBuilder.getDefaultDockerCmdExecFactory();
+            // factory created
+            assertNotNull(factory);
+            // and is unique
+            assertFalse(instances.contains(factory));
+            instances.add(factory);
+         }
+      };
+
+      parallel(AMOUNT, runnable);
+      // set contains all required unique instances
+      assertEquals(instances.size(), AMOUNT);
+   }
+
+   public static void parallel(int threads, final Runnable task) throws Exception
+   {
+      final ExceptionListener exceptionListener = new ExceptionListener();
+      Runnable runnable = new Runnable()
+      {
+         @Override
+         public void run()
+         {
+            try
+            {
+               task.run();
+            }
+            catch (Throwable e)
+            {
+               exceptionListener.onException(e);
+            }
+         }
+      };
+
+      List<Thread> threadList = new ArrayList<>(threads);
+      for (int i = 0; i < threads; i++)
+      {
+         Thread thread = new Thread(runnable);
+         thread.start();
+         threadList.add(thread);
+      }
+      for (Thread thread : threadList)
+      {
+         thread.join();
+      }
+      Throwable exception = exceptionListener.getException();
+      if (exception != null)
+      {
+         throw new RuntimeException(exception);
+      }
+   }
+
+   private static class ExceptionListener
+   {
+      private Throwable exception;
+
+      private synchronized void onException(Throwable e)
+      {
+         exception = e;
+      }
+
+      private synchronized Throwable getException()
+      {
+         return exception;
+      }
+   }
+}
diff --git a/src/test/java/com/github/dockerjava/core/command/AuthCmdImplTest.java b/src/test/java/com/github/dockerjava/core/command/AuthCmdImplTest.java
index 180d835b..ba8c1dac 100644
--- a/src/test/java/com/github/dockerjava/core/command/AuthCmdImplTest.java
+++ b/src/test/java/com/github/dockerjava/core/command/AuthCmdImplTest.java
@@ -41,7 +41,7 @@ public class AuthCmdImplTest extends AbstractDockerClientTest {
     }
 
     // Disabled because of 500/InternalServerException
-    @Test(enabled = false)
+    @Test(enabled=false)
     public void testAuthInvalid() throws Exception {
 
         try {
diff --git a/src/test/java/com/github/dockerjava/core/command/ListContainersCmdImplTest.java b/src/test/java/com/github/dockerjava/core/command/ListContainersCmdImplTest.java
index 2f052f84..b074409b 100644
--- a/src/test/java/com/github/dockerjava/core/command/ListContainersCmdImplTest.java
+++ b/src/test/java/com/github/dockerjava/core/command/ListContainersCmdImplTest.java
@@ -13,7 +13,6 @@ import static org.testinfected.hamcrest.jpa.HasFieldWithValue.hasField;
 
 import java.lang.reflect.Method;
 import java.util.List;
-import java.util.Map;
 
 import org.hamcrest.Matcher;
 import org.testng.ITestResult;
@@ -27,9 +26,7 @@ import com.github.dockerjava.api.DockerException;
 import com.github.dockerjava.api.command.CreateContainerResponse;
 import com.github.dockerjava.api.command.InspectContainerResponse;
 import com.github.dockerjava.api.model.Container;
-import com.github.dockerjava.api.model.Filters;
 import com.github.dockerjava.client.AbstractDockerClientTest;
-import com.google.common.collect.ImmutableMap;
 
 @Test(groups = "integration")
 public class ListContainersCmdImplTest extends AbstractDockerClientTest {
@@ -54,55 +51,8 @@ public class ListContainersCmdImplTest extends AbstractDockerClientTest {
         super.afterMethod(result);
     }
 
-    public void testListContainers() throws DockerException {
-
-        String testImage = "busybox";
-
-        // need to block until image is pulled completely
-        asString(dockerClient.pullImageCmd(testImage).exec());
-
-        List<Container> containers = dockerClient.listContainersCmd().withShowAll(true).exec();
-        assertThat(containers, notNullValue());
-        LOG.info("Container List: {}", containers);
-
-        int size = containers.size();
-
-        CreateContainerResponse container1 = dockerClient.createContainerCmd(testImage).withCmd("echo").exec();
-
-        assertThat(container1.getId(), not(isEmptyString()));
-
-        InspectContainerResponse inspectContainerResponse = dockerClient.inspectContainerCmd(container1.getId()).exec();
-
-        assertThat(inspectContainerResponse.getConfig().getImage(), is(equalTo(testImage)));
-
-        dockerClient.startContainerCmd(container1.getId()).exec();
-
-        LOG.info("container id: " + container1.getId());
-
-        List<Container> containers2 = dockerClient.listContainersCmd().withShowAll(true).exec();
-
-        for (Container container : containers2) {
-            LOG.info("listContainer: id=" + container.getId() + " image=" + container.getImage());
-        }
-
-        assertThat(size + 1, is(equalTo(containers2.size())));
-        Matcher matcher = hasItem(hasField("id", startsWith(container1.getId())));
-        assertThat(containers2, matcher);
-
-        List<Container> filteredContainers = filter(hasField("id", startsWith(container1.getId())), containers2);
-        assertThat(filteredContainers.size(), is(equalTo(1)));
-
-        for (Container container : filteredContainers) {
-            LOG.info("filteredContainer: " + container);
-        }
-
-        Container container2 = filteredContainers.get(0);
-        assertThat(container2.getCommand(), not(isEmptyString()));
-        assertThat(container2.getImage(), startsWith(testImage));
-    }
-
     @Test
-    public void testListContainersWithLabelsFilter() throws DockerException {
+    public void testListContainers() throws DockerException {
 
         String testImage = "busybox";
 
@@ -146,26 +96,7 @@ public class ListContainersCmdImplTest extends AbstractDockerClientTest {
 
         Container container2 = filteredContainers.get(0);
         assertThat(container2.getCommand(), not(isEmptyString()));
-        assertThat(container2.getImage(), startsWith(testImage));
-
-        Map<String, String> labels = ImmutableMap.of("test", "docker-java");
-
-        // list with filter by label
-        dockerClient.createContainerCmd(testImage).withCmd("echo").withLabels(labels).exec();
-        filteredContainers = dockerClient.listContainersCmd().withShowAll(true)
-                .withFilters(new Filters().withLabels(labels)).exec();
-        assertThat(filteredContainers.size(), is(equalTo(1)));
-        Container container3 = filteredContainers.get(0);
-        assertThat(container3.getCommand(), not(isEmptyString()));
-        assertThat(container3.getImage(), startsWith(testImage));
-
-        filteredContainers = dockerClient.listContainersCmd().withShowAll(true)
-                .withFilters(new Filters().withLabels("test")).exec();
-        assertThat(filteredContainers.size(), is(equalTo(1)));
-        container3 = filteredContainers.get(0);
-        assertThat(container3.getCommand(), not(isEmptyString()));
-        assertThat(container3.getImage(), startsWith(testImage));
-        assertEquals(container3.getLabels(), labels);
+        assertThat(container2.getImage(), startsWith(testImage + ":"));
     }
 
 }