1515import java .lang .reflect .Method ;
1616import java .util .*;
1717
18+ import com .fasterxml .jackson .databind .ObjectMapper ;
1819import com .github .dockerjava .api .DockerException ;
1920import com .github .dockerjava .api .NotFoundException ;
2021import com .github .dockerjava .api .command .CreateContainerResponse ;
2122import com .github .dockerjava .api .command .InspectContainerResponse ;
23+ import com .github .dockerjava .api .command .StartContainerCmd ;
2224import com .github .dockerjava .api .model .*;
2325
2426import org .testng .ITestResult ;
@@ -416,6 +418,11 @@ public void existingHostConfigIsPreservedByBlankStartCmd() throws DockerExceptio
416418
417419 @ Test
418420 public void existingHostConfigIsResetByConfiguredStartCmd () throws DockerException {
421+ // As of version 1.3.2, Docker assumes that you either configure a container
422+ // when creating it or when starting it, but not mixing both.
423+ // See https://github.com/docker-java/docker-java/pull/111
424+ // If this test starts to fail, this behavior changed and a review of implementation
425+ // and documentation might be needed.
419426
420427 String dnsServer = "8.8.8.8" ;
421428
@@ -438,4 +445,11 @@ public void existingHostConfigIsResetByConfiguredStartCmd() throws DockerExcepti
438445 // although start did not modify DNS Settings, they were reset to their default.
439446 assertThat (inspectContainerResponse .getHostConfig ().getDns (), is (nullValue (String [].class )));
440447 }
448+
449+ @ Test
450+ public void anUnconfiguredCommandSerializesToEmptyJson () throws Exception {
451+ ObjectMapper objectMapper = new ObjectMapper ();
452+ StartContainerCmd command = dockerClient .startContainerCmd ("" );
453+ assertThat (objectMapper .writeValueAsString (command ), is ("{}" ));
454+ }
441455}
0 commit comments