Skip to content

Commit 5a6c46d

Browse files
author
Andrey Klimachev
committed
Fixing tests for Exec-start and Exec-create.
1 parent e8d9896 commit 5a6c46d

2 files changed

Lines changed: 6 additions & 10 deletions

File tree

src/test/java/com/github/dockerjava/core/command/ExecCreateCmdImplTest.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public void execCreateTest() {
4141
String containerName = "generated_" + new SecureRandom().nextInt();
4242

4343
CreateContainerResponse container = dockerClient
44-
.createContainerCmd("busybox").withCmd("env")
44+
.createContainerCmd("busybox").withCmd("top")
4545
.withName(containerName).exec();
4646

4747
LOG.info("Created container {}", container.toString());
@@ -50,9 +50,7 @@ public void execCreateTest() {
5050

5151
dockerClient.startContainerCmd(container.getId()).exec();
5252

53-
dockerClient.waitContainerCmd(container.getId()).exec();
54-
55-
ExecCreateCmdResponse execCreateCmdResponse = dockerClient.execCreateCmd(container.getId()).withCmd("touch file.log").exec();
53+
ExecCreateCmdResponse execCreateCmdResponse = dockerClient.execCreateCmd(container.getId()).withCmd("touch","file.log").exec();
5654

5755
assertThat(execCreateCmdResponse.getId(), not(isEmptyString()));
5856
}

src/test/java/com/github/dockerjava/core/command/ExecStartCmdImplTest.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import static org.hamcrest.Matchers.isEmptyString;
1616
import static org.hamcrest.Matchers.not;
1717

18+
@Test(groups = "integration")
1819
public class ExecStartCmdImplTest extends AbstractDockerClientTest {
1920
@BeforeTest
2021
public void beforeTest() throws DockerException {
@@ -41,7 +42,7 @@ public void execStartTest() throws Exception {
4142
String containerName = "generated_" + new SecureRandom().nextInt();
4243

4344
CreateContainerResponse container = dockerClient
44-
.createContainerCmd("busybox").withCmd("env")
45+
.createContainerCmd("busybox").withCmd("top")
4546
.withName(containerName).exec();
4647

4748
LOG.info("Created container {}", container.toString());
@@ -50,13 +51,10 @@ public void execStartTest() throws Exception {
5051

5152
dockerClient.startContainerCmd(container.getId()).exec();
5253

53-
dockerClient.waitContainerCmd(container.getId()).exec();
54-
55-
ExecCreateCmdResponse execCreateCmdResponse = dockerClient.execCreateCmd(container.getId()).withCmd("touch","file.log").exec();
56-
54+
ExecCreateCmdResponse execCreateCmdResponse = dockerClient.execCreateCmd(container.getId()).attachStdout(true).withCmd("touch","file.log").exec();
5755
dockerClient.execStartCmd(execCreateCmdResponse.getId()).exec();
5856

59-
InputStream response = dockerClient.copyFileFromContainerCmd(container.getId(), "file.log").exec();
57+
InputStream response = dockerClient.copyFileFromContainerCmd(container.getId(), "/file.log").exec();
6058
assertTrue(response.available() > 0, "The file was not copied from the container.");
6159
}
6260
}

0 commit comments

Comments
 (0)