forked from docker-java/docker-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUnpauseCmdIT.java
More file actions
90 lines (62 loc) · 3.56 KB
/
Copy pathUnpauseCmdIT.java
File metadata and controls
90 lines (62 loc) · 3.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package com.github.dockerjava.cmd;
import com.github.dockerjava.api.command.CreateContainerResponse;
import com.github.dockerjava.api.exception.InternalServerErrorException;
import com.github.dockerjava.api.exception.NotFoundException;
import com.github.dockerjava.utils.ContainerUtils;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.emptyString;
import static org.hamcrest.Matchers.not;
public class UnpauseCmdIT extends CmdIT {
public static final Logger LOG = LoggerFactory.getLogger(UnpauseCmdIT.class);
@Test
public void unpausePausedContainer() {
CreateContainerResponse container = dockerRule.getClient().createContainerCmd("busybox").withCmd("sleep", "9999").exec();
LOG.info("Created container: {}", container.toString());
assertThat(container.getId(), not(is(emptyString())));
ContainerUtils.startContainer(dockerRule.getClient(), container);
ContainerUtils.pauseContainer(dockerRule.getClient(), container);
ContainerUtils.unpauseContainer(dockerRule.getClient(), container);
}
@Test(expected = InternalServerErrorException.class)
public void unpauseRunningContainer() {
CreateContainerResponse container = dockerRule.getClient().createContainerCmd("busybox").withCmd("sleep", "9999").exec();
LOG.info("Created container: {}", container.toString());
assertThat(container.getId(), not(is(emptyString())));
ContainerUtils.startContainer(dockerRule.getClient(), container);
dockerRule.getClient().unpauseContainerCmd(container.getId()).exec();
}
@Test(expected = InternalServerErrorException.class)
public void unpauseStoppedContainer() {
CreateContainerResponse container = dockerRule.getClient().createContainerCmd("busybox").withCmd("sleep", "9999").exec();
LOG.info("Created container: {}", container.toString());
assertThat(container.getId(), not(is(emptyString())));
ContainerUtils.startContainer(dockerRule.getClient(), container);
ContainerUtils.stopContainer(dockerRule.getClient(), container);
dockerRule.getClient().unpauseContainerCmd(container.getId()).exec();
}
@Test(expected = NotFoundException.class)
public void unpauseNonExistingContainer() {
dockerRule.getClient().unpauseContainerCmd("non-existing").exec();
}
@Test(expected = InternalServerErrorException.class)
public void unpauseCreatedContainer() {
CreateContainerResponse container = dockerRule.getClient().createContainerCmd("busybox").withCmd("sleep", "9999").exec();
LOG.info("Created container: {}", container.toString());
assertThat(container.getId(), not(is(emptyString())));
dockerRule.getClient().unpauseContainerCmd(container.getId()).exec();
}
@Test(expected = InternalServerErrorException.class)
public void unpauseUnpausedContainer() {
CreateContainerResponse container = dockerRule.getClient().createContainerCmd("busybox").withCmd("sleep", "9999").exec();
LOG.info("Created container: {}", container.toString());
assertThat(container.getId(), not(is(emptyString())));
ContainerUtils.startContainer(dockerRule.getClient(), container);
ContainerUtils.pauseContainer(dockerRule.getClient(), container);
dockerRule.getClient().unpauseContainerCmd(container.getId()).exec();
dockerRule.getClient().unpauseContainerCmd(container.getId()).exec();
}
}