TClass testRoundTrip(TClass item, JavaType type)
+ throws IOException, AssertionError {
+ ObjectMapper mapper = new ObjectMapper();
+
+ String serialized1 = mapper.writeValueAsString(item);
+ JsonNode json1 = mapper.readTree(serialized1);
+
+ TClass deserialized1 = mapper.readValue(serialized1, type);
+ String serialized2 = mapper.writeValueAsString(deserialized1);
+
+ JsonNode json2 = mapper.readTree(serialized2);
+ TClass deserialized2 = mapper.readValue(serialized2, type);
+
+ assertEquals(json2, json1, "JSONs must be equal after the second roundtrip");
+ assertEquals(deserialized2, deserialized2, "Objects must be equal after the second roundtrip");
+ assertNotSame(deserialized2, deserialized1, "Objects must be not the same");
+
+ return deserialized2;
+ }
+}
diff --git a/src/test/java/com/github/dockerjava/test/serdes/JSONTestHelper.java b/src/test/java/com/github/dockerjava/test/serdes/JSONTestHelper.java
index 8cacb6c5e..99a90f0af 100644
--- a/src/test/java/com/github/dockerjava/test/serdes/JSONTestHelper.java
+++ b/src/test/java/com/github/dockerjava/test/serdes/JSONTestHelper.java
@@ -29,10 +29,6 @@
/**
* Provides helper methods for serialization-deserialization tests.
*
- *
- * TODO: Create helper that loads json files from simple folder structure using a type, version number, and name.
- *
- *
* @author Oleg Nenashev
*/
public class JSONTestHelper {
diff --git a/src/test/java/com/github/dockerjava/utils/TestUtils.java b/src/test/java/com/github/dockerjava/utils/TestUtils.java
new file mode 100644
index 000000000..b40273ecb
--- /dev/null
+++ b/src/test/java/com/github/dockerjava/utils/TestUtils.java
@@ -0,0 +1,17 @@
+package com.github.dockerjava.utils;
+
+import com.github.dockerjava.api.DockerClient;
+import com.github.dockerjava.core.RemoteApiVersion;
+
+/**
+ * @author Kanstantsin Shautsou
+ */
+public class TestUtils {
+ private TestUtils() {
+ }
+
+ public static RemoteApiVersion getVersion(DockerClient client) {
+ final String serverVersion = client.versionCmd().exec().getApiVersion();
+ return RemoteApiVersion.parseConfig(serverVersion);
+ }
+}
diff --git a/src/test/resources/samples/1.22/containers/container/json/1.json b/src/test/resources/samples/1.22/containers/container/json/1.json
new file mode 100644
index 000000000..6cb71cc82
--- /dev/null
+++ b/src/test/resources/samples/1.22/containers/container/json/1.json
@@ -0,0 +1,151 @@
+{
+ "Id": "095351afe7b4995dfb3e965f9cfd3a07b1fe69198c50085a2cb7c2b5a5c9b62f",
+ "Created": "2016-02-16T22:40:51.465045919Z",
+ "Path": "echo",
+ "Args": [],
+ "State": {
+ "Status": "created",
+ "Running": false,
+ "Paused": false,
+ "Restarting": false,
+ "OOMKilled": false,
+ "Dead": false,
+ "Pid": 0,
+ "ExitCode": 0,
+ "Error": "",
+ "StartedAt": "0001-01-01T00:00:00Z",
+ "FinishedAt": "0001-01-01T00:00:00Z"
+ },
+ "Image": "sha256:0cb40641836c461bc97c793971d84d758371ed682042457523e4ae701efe7ec9",
+ "ResolvConfPath": "",
+ "HostnamePath": "",
+ "HostsPath": "",
+ "LogPath": "",
+ "Name": "/drunk_golick",
+ "RestartCount": 0,
+ "Driver": "aufs",
+ "MountLabel": "",
+ "ProcessLabel": "",
+ "AppArmorProfile": "",
+ "ExecIDs": null,
+ "HostConfig": {
+ "Binds": null,
+ "ContainerIDFile": "",
+ "LogConfig": {
+ "Type": "json-file",
+ "Config": {}
+ },
+ "NetworkMode": "default",
+ "PortBindings": null,
+ "RestartPolicy": {
+ "Name": "",
+ "MaximumRetryCount": 0
+ },
+ "VolumeDriver": "",
+ "VolumesFrom": null,
+ "CapAdd": null,
+ "CapDrop": null,
+ "Dns": null,
+ "DnsOptions": null,
+ "DnsSearch": null,
+ "ExtraHosts": null,
+ "GroupAdd": null,
+ "IpcMode": "",
+ "Links": null,
+ "OomScoreAdj": 0,
+ "PidMode": "",
+ "Privileged": false,
+ "PublishAllPorts": false,
+ "ReadonlyRootfs": false,
+ "SecurityOpt": null,
+ "UTSMode": "",
+ "ShmSize": 67108864,
+ "ConsoleSize": [
+ 0,
+ 0
+ ],
+ "Isolation": "",
+ "CpuShares": 0,
+ "CgroupParent": "",
+ "BlkioWeight": 0,
+ "BlkioWeightDevice": null,
+ "BlkioDeviceReadBps": null,
+ "BlkioDeviceWriteBps": null,
+ "BlkioDeviceReadIOps": null,
+ "BlkioDeviceWriteIOps": null,
+ "CpuPeriod": 0,
+ "CpuQuota": 0,
+ "CpusetCpus": "",
+ "CpusetMems": "",
+ "Devices": null,
+ "KernelMemory": 0,
+ "Memory": 0,
+ "MemoryReservation": 0,
+ "MemorySwap": 0,
+ "MemorySwappiness": -1,
+ "OomKillDisable": false,
+ "PidsLimit": 0,
+ "Ulimits": null
+ },
+ "GraphDriver": {
+ "Name": "aufs",
+ "Data": null
+ },
+ "Mounts": [],
+ "Config": {
+ "Hostname": "095351afe7b4",
+ "Domainname": "",
+ "User": "",
+ "AttachStdin": false,
+ "AttachStdout": false,
+ "AttachStderr": false,
+ "Tty": false,
+ "OpenStdin": false,
+ "StdinOnce": false,
+ "Env": null,
+ "Cmd": [
+ "echo"
+ ],
+ "Image": "busybox",
+ "Volumes": null,
+ "WorkingDir": "",
+ "Entrypoint": null,
+ "OnBuild": null,
+ "Labels": {}
+ },
+ "NetworkSettings": {
+ "Bridge": "",
+ "SandboxID": "",
+ "HairpinMode": false,
+ "LinkLocalIPv6Address": "",
+ "LinkLocalIPv6PrefixLen": 0,
+ "Ports": null,
+ "SandboxKey": "",
+ "SecondaryIPAddresses": null,
+ "SecondaryIPv6Addresses": null,
+ "EndpointID": "",
+ "Gateway": "",
+ "GlobalIPv6Address": "",
+ "GlobalIPv6PrefixLen": 0,
+ "IPAddress": "",
+ "IPPrefixLen": 0,
+ "IPv6Gateway": "",
+ "MacAddress": "",
+ "Networks": {
+ "bridge": {
+ "IPAMConfig": null,
+ "Links": null,
+ "Aliases": null,
+ "NetworkID": "",
+ "EndpointID": "",
+ "Gateway": "",
+ "IPAddress": "",
+ "IPPrefixLen": 0,
+ "IPv6Gateway": "",
+ "GlobalIPv6Address": "",
+ "GlobalIPv6PrefixLen": 0,
+ "MacAddress": ""
+ }
+ }
+ }
+}
diff --git a/src/test/resources/samples/1.22/containers/container/update/docs.json b/src/test/resources/samples/1.22/containers/container/update/docs.json
new file mode 100644
index 000000000..9d26fcb2f
--- /dev/null
+++ b/src/test/resources/samples/1.22/containers/container/update/docs.json
@@ -0,0 +1,12 @@
+{
+ "BlkioWeight": 300,
+ "CpuShares": 512,
+ "CpuPeriod": 100000,
+ "CpuQuota": 50000,
+ "CpusetCpus": "0,1",
+ "CpusetMems": "0",
+ "Memory": 314572800,
+ "MemorySwap": 514288000,
+ "MemoryReservation": 209715200,
+ "KernelMemory": 52428800
+}
diff --git a/src/test/resources/samples/1.22/containers/create/docs.json b/src/test/resources/samples/1.22/containers/create/docs.json
new file mode 100644
index 000000000..4bafc3cb5
--- /dev/null
+++ b/src/test/resources/samples/1.22/containers/create/docs.json
@@ -0,0 +1,131 @@
+{
+ "Hostname": "",
+ "Domainname": "",
+ "User": "",
+ "AttachStdin": false,
+ "AttachStdout": true,
+ "AttachStderr": true,
+ "Tty": false,
+ "OpenStdin": false,
+ "StdinOnce": false,
+ "Env": [
+ "FOO=bar",
+ "BAZ=quux"
+ ],
+ "Cmd": [
+ "date"
+ ],
+ "Entrypoint": "",
+ "Image": "ubuntu",
+ "Labels": {
+ "com.example.vendor": "Acme",
+ "com.example.license": "GPL",
+ "com.example.version": "1.0"
+ },
+ "Mounts": [
+ {
+ "Name": "fac362...80535",
+ "Source": "/data",
+ "Destination": "/data",
+ "Driver": "local",
+ "Mode": "ro,Z",
+ "RW": false,
+ "Propagation": ""
+ }
+ ],
+ "WorkingDir": "",
+ "NetworkDisabled": false,
+ "MacAddress": "12:34:56:78:9a:bc",
+ "ExposedPorts": {
+ "22/tcp": {}
+ },
+ "StopSignal": "SIGTERM",
+ "HostConfig": {
+ "Binds": [
+ "/tmp:/tmp"
+ ],
+ "Links": [
+ "redis3:redis"
+ ],
+ "Memory": 0,
+ "MemorySwap": 0,
+ "MemoryReservation": 0,
+ "KernelMemory": 0,
+ "CpuShares": 512,
+ "CpuPeriod": 100000,
+ "CpuQuota": 50000,
+ "CpusetCpus": "0,1",
+ "CpusetMems": "0,1",
+ "BlkioWeight": 300,
+ "BlkioWeightDevice": [
+ {}
+ ],
+ "BlkioDeviceReadBps": [
+ {}
+ ],
+ "BlkioDeviceReadIOps": [
+ {}
+ ],
+ "BlkioDeviceWriteBps": [
+ {}
+ ],
+ "BlkioDeviceWriteIOps": [
+ {}
+ ],
+ "MemorySwappiness": 60,
+ "OomKillDisable": false,
+ "OomScoreAdj": 500,
+ "PortBindings": {
+ "22/tcp": [
+ {
+ "HostPort": "11022"
+ }
+ ]
+ },
+ "PublishAllPorts": false,
+ "Privileged": false,
+ "ReadonlyRootfs": false,
+ "Dns": [
+ "8.8.8.8"
+ ],
+ "DnsOptions": [
+ ""
+ ],
+ "DnsSearch": [
+ ""
+ ],
+ "ExtraHosts": null,
+ "VolumesFrom": [
+ "parent",
+ "other:ro"
+ ],
+ "CapAdd": [
+ "NET_ADMIN"
+ ],
+ "CapDrop": [
+ "MKNOD"
+ ],
+ "GroupAdd": [
+ "newgroup"
+ ],
+ "RestartPolicy": {
+ "Name": "",
+ "MaximumRetryCount": 0
+ },
+ "NetworkMode": "bridge",
+ "Devices": [],
+ "Ulimits": [
+ {}
+ ],
+ "LogConfig": {
+ "Type": "json-file",
+ "Config": {}
+ },
+ "SecurityOpt": [
+ ""
+ ],
+ "CgroupParent": "",
+ "VolumeDriver": "",
+ "ShmSize": 67108864
+ }
+}
diff --git a/src/test/resources/samples/1.22/containers/json/filter1.json b/src/test/resources/samples/1.22/containers/json/filter1.json
new file mode 100644
index 000000000..159e62da6
--- /dev/null
+++ b/src/test/resources/samples/1.22/containers/json/filter1.json
@@ -0,0 +1,37 @@
+[
+ {
+ "Id": "095351afe7b4995dfb3e965f9cfd3a07b1fe69198c50085a2cb7c2b5a5c9b62f",
+ "Names": [
+ "/drunk_golick"
+ ],
+ "Image": "busybox",
+ "ImageID": "sha256:0cb40641836c461bc97c793971d84d758371ed682042457523e4ae701efe7ec9",
+ "Command": "echo",
+ "Created": 1455662451,
+ "Ports": [],
+ "SizeRootFs": 1113554,
+ "Labels": {},
+ "Status": "Up Less than a second",
+ "HostConfig": {
+ "NetworkMode": "default"
+ },
+ "NetworkSettings": {
+ "Networks": {
+ "bridge": {
+ "IPAMConfig": null,
+ "Links": null,
+ "Aliases": null,
+ "NetworkID": "",
+ "EndpointID": "f69f5cff77b527c829bc45d71ba8c5eabca005ef3a8da8c7ee88c13ffc1ab602",
+ "Gateway": "172.17.0.1",
+ "IPAddress": "172.17.0.2",
+ "IPPrefixLen": 16,
+ "IPv6Gateway": "",
+ "GlobalIPv6Address": "",
+ "GlobalIPv6PrefixLen": 0,
+ "MacAddress": "02:42:ac:11:00:02"
+ }
+ }
+ }
+ }
+]
diff --git a/src/test/resources/samples/1.22/exec/ID/1.json b/src/test/resources/samples/1.22/exec/ID/1.json
new file mode 100644
index 000000000..f06c807af
--- /dev/null
+++ b/src/test/resources/samples/1.22/exec/ID/1.json
@@ -0,0 +1,18 @@
+{
+ "ID": "1ca2ca598fab202f86dd9281196c405456069013958a475396b707e85c56473b",
+ "Running": false,
+ "ExitCode": null,
+ "ProcessConfig": {
+ "tty": false,
+ "entrypoint": "/bin/bash",
+ "arguments": [],
+ "privileged": false,
+ "user": ""
+ },
+ "OpenStdin": false,
+ "OpenStderr": true,
+ "OpenStdout": true,
+ "CanRemove": false,
+ "ContainerID": "ffa39805f089af3099e36452a985481f96170a9dff40be69d34d1722c7660d38",
+ "DetachKeys": ""
+}
diff --git a/src/test/resources/samples/1.22/info/1.json b/src/test/resources/samples/1.22/info/1.json
new file mode 100644
index 000000000..42ceb1b6e
--- /dev/null
+++ b/src/test/resources/samples/1.22/info/1.json
@@ -0,0 +1,91 @@
+{
+ "ID": "HLN2:5SBU:SRQR:CQI6:AB52:LZZ2:DED5:REDM:BU73:JFHE:R37A:5HMX",
+ "Containers": 2,
+ "ContainersRunning": 2,
+ "ContainersPaused": 10,
+ "ContainersStopped": 3,
+ "Images": 13,
+ "Driver": "aufs",
+ "DriverStatus": [
+ [
+ "Root Dir",
+ "/mnt/sda1/var/lib/docker/aufs"
+ ],
+ [
+ "Backing Filesystem",
+ "extfs"
+ ],
+ [
+ "Dirs",
+ "31"
+ ],
+ [
+ "Dirperm1 Supported",
+ "true"
+ ]
+ ],
+ "SystemStatus": null,
+ "Plugins": {
+ "Volume": [
+ "local"
+ ],
+ "Network": [
+ "bridge",
+ "null",
+ "host"
+ ],
+ "Authorization": null
+ },
+ "MemoryLimit": true,
+ "SwapLimit": true,
+ "CpuCfsPeriod": true,
+ "CpuCfsQuota": true,
+ "CPUShares": true,
+ "CPUSet": true,
+ "IPv4Forwarding": true,
+ "BridgeNfIptables": true,
+ "BridgeNfIp6tables": true,
+ "Debug": true,
+ "NFd": 24,
+ "OomKillDisable": true,
+ "NGoroutines": 40,
+ "SystemTime": "2016-02-17T14:56:35.212841831Z",
+ "ExecutionDriver": "native-0.2",
+ "LoggingDriver": "json-file",
+ "NEventsListener": 0,
+ "KernelVersion": "4.1.17-boot2docker",
+ "OperatingSystem": "Boot2Docker 1.10.1 (TCL 6.4.1); master : b03e158 - Thu Feb 11 22:34:01 UTC 2016",
+ "OSType": "linux",
+ "Architecture": "x86_64",
+ "IndexServerAddress": "https://index.docker.io/v1/",
+ "RegistryConfig": {
+ "InsecureRegistryCIDRs": [
+ "127.0.0.0/8"
+ ],
+ "IndexConfigs": {
+ "docker.io": {
+ "Name": "docker.io",
+ "Mirrors": null,
+ "Secure": true,
+ "Official": true
+ }
+ },
+ "Mirrors": null
+ },
+ "InitSha1": "",
+ "InitPath": "/usr/local/bin/docker",
+ "NCPU": 1,
+ "MemTotal": 1044574208,
+ "DockerRootDir": "/mnt/sda1/var/lib/docker",
+ "HttpProxy": "",
+ "HttpsProxy": "",
+ "NoProxy": "",
+ "Name": "docker-java",
+ "Labels": [
+ "provider=virtualbox"
+ ],
+ "ExperimentalBuild": false,
+ "ServerVersion": "1.10.1",
+ "ClusterStore": "",
+ "ClusterAdvertise": ""
+}
diff --git a/src/test/resources/samples/1.22/info/docs.json b/src/test/resources/samples/1.22/info/docs.json
new file mode 100644
index 000000000..537a0a1d2
--- /dev/null
+++ b/src/test/resources/samples/1.22/info/docs.json
@@ -0,0 +1,76 @@
+{
+ "Architecture": "x86_64",
+ "Containers": 11,
+ "ContainersRunning": 7,
+ "ContainersStopped": 3,
+ "ContainersPaused": 1,
+ "CpuCfsPeriod": true,
+ "CpuCfsQuota": true,
+ "Debug": false,
+ "DiscoveryBackend": "etcd://localhost:2379",
+ "DockerRootDir": "/var/lib/docker",
+ "Driver": "btrfs",
+ "DriverStatus": [
+ [
+ ""
+ ]
+ ],
+ "SystemStatus": [
+ [
+ "State",
+ "Healthy"
+ ]
+ ],
+ "Plugins": {
+ "Volume": [
+ "local"
+ ],
+ "Network": [
+ "null",
+ "host",
+ "bridge"
+ ]
+ },
+ "ExecutionDriver": "native-0.1",
+ "ExperimentalBuild": false,
+ "HttpProxy": "http://test:test@localhost:8080",
+ "HttpsProxy": "https://test:test@localhost:8080",
+ "ID": "7TRN:IPZB:QYBB:VPBQ:UMPP:KARE:6ZNR:XE6T:7EWV:PKF4:ZOJD:TPYS",
+ "IPv4Forwarding": true,
+ "Images": 16,
+ "IndexServerAddress": "https://index.docker.io/v1/",
+ "InitPath": "/usr/bin/docker",
+ "InitSha1": "",
+ "KernelVersion": "3.12.0-1-amd64",
+ "Labels": [
+ "storage=ssd"
+ ],
+ "MemTotal": 2099236864,
+ "MemoryLimit": true,
+ "NCPU": 1,
+ "NEventsListener": 0,
+ "NFd": 11,
+ "NGoroutines": 21,
+ "Name": "prod-server-42",
+ "NoProxy": "9.81.1.160",
+ "OomKillDisable": true,
+ "OSType": "linux",
+ "OomScoreAdj": 500,
+ "OperatingSystem": "Boot2Docker",
+ "RegistryConfig": {
+ "IndexConfigs": {
+ "docker.io": {
+ "Mirrors": null,
+ "Name": "docker.io",
+ "Official": true,
+ "Secure": true
+ }
+ },
+ "InsecureRegistryCIDRs": [
+ "127.0.0.0/8"
+ ]
+ },
+ "SwapLimit": false,
+ "SystemTime": "2015-03-10T11:11:23.730591467-07:00",
+ "ServerVersion": "1.9.0"
+}
diff --git a/src/test/resources/samples/1.22/other/AuthConfig/docs1.json b/src/test/resources/samples/1.22/other/AuthConfig/docs1.json
new file mode 100644
index 000000000..5f712fb62
--- /dev/null
+++ b/src/test/resources/samples/1.22/other/AuthConfig/docs1.json
@@ -0,0 +1,5 @@
+{
+ "username": "jdoe",
+ "password": "secret",
+ "email": "jdoe@acme.com"
+}
diff --git a/src/test/resources/samples/1.22/other/AuthConfig/docs2.json b/src/test/resources/samples/1.22/other/AuthConfig/docs2.json
new file mode 100644
index 000000000..8ac70c20a
--- /dev/null
+++ b/src/test/resources/samples/1.22/other/AuthConfig/docs2.json
@@ -0,0 +1,3 @@
+{
+ "registrytoken": "9cbaf023786cd7..."
+}
diff --git a/src/test/resources/samples/1.22/version/1.json b/src/test/resources/samples/1.22/version/1.json
new file mode 100644
index 000000000..454c767ba
--- /dev/null
+++ b/src/test/resources/samples/1.22/version/1.json
@@ -0,0 +1,10 @@
+{
+ "Version": "1.10.1",
+ "ApiVersion": "1.22",
+ "GitCommit": "9e83765",
+ "GoVersion": "go1.5.3",
+ "Os": "linux",
+ "Arch": "amd64",
+ "KernelVersion": "4.1.17-boot2docker",
+ "BuildTime": "2016-02-11T20:39:58.688092588+00:00"
+}