Skip to content

Commit 0bc6671

Browse files
committed
Add test case
1 parent 7e6173d commit 0bc6671

File tree

3 files changed

+171
-7
lines changed

3 files changed

+171
-7
lines changed

src/test/java/com/github/dockerjava/api/command/CommandJSONSamples.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
*/
2525
public enum CommandJSONSamples implements JSONResourceRef {
2626

27-
inspectContainerResponse_full, inspectContainerResponse_empty;
27+
inspectContainerResponse_full,
28+
inspectContainerResponse_full_1_21,
29+
inspectContainerResponse_empty;
2830

2931
@Override
3032
public String getFileName() {

src/test/java/com/github/dockerjava/api/command/InspectContainerResponseTest.java

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,21 @@
1515
*/
1616
package com.github.dockerjava.api.command;
1717

18-
import static com.github.dockerjava.test.serdes.JSONTestHelper.testRoundTrip;
19-
import static org.testng.Assert.assertEquals;
20-
import static org.testng.Assert.assertFalse;
21-
import static org.testng.Assert.assertTrue;
18+
import org.testng.annotations.Test;
2219

2320
import java.io.IOException;
2421

25-
import org.testng.annotations.Test;
22+
import static com.github.dockerjava.test.serdes.JSONTestHelper.testRoundTrip;
23+
import static org.hamcrest.MatcherAssert.assertThat;
24+
import static org.hamcrest.Matchers.containsString;
25+
import static org.hamcrest.Matchers.isEmptyString;
26+
import static org.hamcrest.Matchers.nullValue;
27+
import static org.hamcrest.core.IsNot.not;
28+
import static org.testng.Assert.*;
2629

2730
/**
2831
* Tests for {@link InspectContainerResponse}.
29-
*
32+
*
3033
* @author Oleg Nenashev
3134
*/
3235
public class InspectContainerResponseTest {
@@ -48,6 +51,22 @@ public void roundTrip_full() throws IOException {
4851
assertTrue(response.getVolumesRW()[0].getAccessMode().toBoolean());
4952
}
5053

54+
@Test
55+
public void roundTrip_1_21_full() throws IOException {
56+
InspectContainerResponse[] responses = testRoundTrip(CommandJSONSamples.inspectContainerResponse_full_1_21,
57+
InspectContainerResponse[].class);
58+
assertEquals(1, responses.length);
59+
final InspectContainerResponse response = responses[0];
60+
final InspectContainerResponse.ContainerState state = response.getState();
61+
assertThat(state, not(nullValue()));
62+
63+
assertFalse(state.getDead());
64+
assertThat(state.getStatus(), containsString("running"));
65+
assertFalse(state.getRestarting());
66+
assertFalse(state.getOOMKilled());
67+
assertThat(state.getError(), isEmptyString());
68+
}
69+
5170
@Test
5271
public void roundTrip_empty() throws IOException {
5372
testRoundTrip(CommandJSONSamples.inspectContainerResponse_empty, InspectContainerResponse[].class);
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
[
2+
{
3+
"Id": "fc1243c01bbb791d9eca64204d76f72fc47fbebbca892d7dd0a5cd0e4e346045",
4+
"Created": "2015-11-20T21:10:34.775649753Z",
5+
"Path": "cat",
6+
"Args": [],
7+
"State": {
8+
"Status": "running",
9+
"Running": true,
10+
"Paused": false,
11+
"Restarting": false,
12+
"OOMKilled": false,
13+
"Dead": false,
14+
"Pid": 10912,
15+
"ExitCode": 0,
16+
"Error": "",
17+
"StartedAt": "2015-11-20T21:10:34.845546358Z",
18+
"FinishedAt": "0001-01-01T00:00:00Z"
19+
},
20+
"Image": "c51f86c283408d1749d066333f7acd5d33b053b003a61ff6a7b36819ddcbc7b7",
21+
"ResolvConfPath": "/mnt/sda1/var/lib/docker/containers/fc1243c01bbb791d9eca64204d76f72fc47fbebbca892d7dd0a5cd0e4e346045/resolv.conf",
22+
"HostnamePath": "/mnt/sda1/var/lib/docker/containers/fc1243c01bbb791d9eca64204d76f72fc47fbebbca892d7dd0a5cd0e4e346045/hostname",
23+
"HostsPath": "/mnt/sda1/var/lib/docker/containers/fc1243c01bbb791d9eca64204d76f72fc47fbebbca892d7dd0a5cd0e4e346045/hosts",
24+
"LogPath": "/mnt/sda1/var/lib/docker/containers/fc1243c01bbb791d9eca64204d76f72fc47fbebbca892d7dd0a5cd0e4e346045/fc1243c01bbb791d9eca64204d76f72fc47fbebbca892d7dd0a5cd0e4e346045-json.log",
25+
"Name": "/small_hodgkin",
26+
"RestartCount": 0,
27+
"Driver": "aufs",
28+
"ExecDriver": "native-0.2",
29+
"MountLabel": "",
30+
"ProcessLabel": "",
31+
"AppArmorProfile": "",
32+
"ExecIDs": null,
33+
"HostConfig": {
34+
"Binds": null,
35+
"ContainerIDFile": "",
36+
"LxcConf": [],
37+
"Memory": 0,
38+
"MemoryReservation": 0,
39+
"MemorySwap": 0,
40+
"KernelMemory": 0,
41+
"CpuShares": 0,
42+
"CpuPeriod": 0,
43+
"CpusetCpus": "",
44+
"CpusetMems": "",
45+
"CpuQuota": 0,
46+
"BlkioWeight": 0,
47+
"OomKillDisable": false,
48+
"MemorySwappiness": -1,
49+
"Privileged": false,
50+
"PortBindings": {},
51+
"Links": null,
52+
"PublishAllPorts": false,
53+
"Dns": null,
54+
"DnsOptions": null,
55+
"DnsSearch": null,
56+
"ExtraHosts": null,
57+
"VolumesFrom": null,
58+
"Devices": [],
59+
"NetworkMode": "default",
60+
"IpcMode": "",
61+
"PidMode": "",
62+
"UTSMode": "",
63+
"CapAdd": null,
64+
"CapDrop": null,
65+
"GroupAdd": null,
66+
"RestartPolicy": {
67+
"Name": "no",
68+
"MaximumRetryCount": 0
69+
},
70+
"SecurityOpt": null,
71+
"ReadonlyRootfs": false,
72+
"Ulimits": null,
73+
"LogConfig": {
74+
"Type": "json-file",
75+
"Config": {}
76+
},
77+
"CgroupParent": "",
78+
"ConsoleSize": [
79+
0,
80+
0
81+
],
82+
"VolumeDriver": ""
83+
},
84+
"GraphDriver": {
85+
"Name": "aufs",
86+
"Data": null
87+
},
88+
"Mounts": [],
89+
"Config": {
90+
"Hostname": "fc1243c01bbb",
91+
"Domainname": "",
92+
"User": "",
93+
"AttachStdin": false,
94+
"AttachStdout": false,
95+
"AttachStderr": false,
96+
"Tty": false,
97+
"OpenStdin": true,
98+
"StdinOnce": false,
99+
"Env": null,
100+
"Cmd": [
101+
"cat"
102+
],
103+
"Image": "busybox",
104+
"Volumes": null,
105+
"WorkingDir": "",
106+
"Entrypoint": null,
107+
"OnBuild": null,
108+
"Labels": {},
109+
"StopSignal": "SIGTERM"
110+
},
111+
"NetworkSettings": {
112+
"Bridge": "",
113+
"SandboxID": "5a6ded01bf23cc180e8ba6a059449ac832f28fa1d8367127e316607f92d3228c",
114+
"HairpinMode": false,
115+
"LinkLocalIPv6Address": "",
116+
"LinkLocalIPv6PrefixLen": 0,
117+
"Ports": {},
118+
"SandboxKey": "/var/run/docker/netns/5a6ded01bf23",
119+
"SecondaryIPAddresses": null,
120+
"SecondaryIPv6Addresses": null,
121+
"EndpointID": "6b4bb2aff9981d6e132cf37ebbfd370069061fab848ae56247b154717a99aba7",
122+
"Gateway": "172.17.0.1",
123+
"GlobalIPv6Address": "",
124+
"GlobalIPv6PrefixLen": 0,
125+
"IPAddress": "172.17.0.2",
126+
"IPPrefixLen": 16,
127+
"IPv6Gateway": "",
128+
"MacAddress": "02:42:ac:11:00:02",
129+
"Networks": {
130+
"bridge": {
131+
"EndpointID": "6b4bb2aff9981d6e132cf37ebbfd370069061fab848ae56247b154717a99aba7",
132+
"Gateway": "172.17.0.1",
133+
"IPAddress": "172.17.0.2",
134+
"IPPrefixLen": 16,
135+
"IPv6Gateway": "",
136+
"GlobalIPv6Address": "",
137+
"GlobalIPv6PrefixLen": 0,
138+
"MacAddress": "02:42:ac:11:00:02"
139+
}
140+
}
141+
}
142+
}
143+
]

0 commit comments

Comments
 (0)