use of okhttp3.Request.Builder in project docker-client by spotify.
the class DefaultDockerClientUnitTest method testInspectVolume.
@Test
public void testInspectVolume() throws Exception {
final DefaultDockerClient dockerClient = new DefaultDockerClient(builder);
server.enqueue(new MockResponse().setResponseCode(200).addHeader("Content-Type", "application/json").setBody(fixture("fixtures/1.33/inspectVolume.json")));
final Volume volume = dockerClient.inspectVolume("my-volume");
assertThat(volume.name(), is("tardis"));
assertThat(volume.driver(), is("custom"));
assertThat(volume.mountpoint(), is("/var/lib/docker/volumes/tardis"));
assertThat(volume.status(), is(ImmutableMap.of("hello", "world")));
assertThat(volume.labels(), is(ImmutableMap.of("com.example.some-label", "some-value", "com.example.some-other-label", "some-other-value")));
assertThat(volume.scope(), is("local"));
assertThat(volume.options(), is(ImmutableMap.of("foo", "bar", "baz", "qux")));
}
use of okhttp3.Request.Builder in project docker-client by spotify.
the class DefaultDockerClientUnitTest method testCapAddAndDrop.
@Test
@SuppressWarnings("unchecked")
public void testCapAddAndDrop() throws Exception {
final DefaultDockerClient dockerClient = new DefaultDockerClient(builder);
final HostConfig hostConfig = HostConfig.builder().capAdd(ImmutableList.of("foo", "bar")).capAdd(ImmutableList.of("baz", "qux")).build();
final ContainerConfig containerConfig = ContainerConfig.builder().hostConfig(hostConfig).build();
server.enqueue(new MockResponse());
dockerClient.createContainer(containerConfig);
final RecordedRequest recordedRequest = takeRequestImmediately();
assertThat(recordedRequest.getMethod(), is("POST"));
assertThat(recordedRequest.getPath(), is("/containers/create"));
assertThat(recordedRequest.getHeader("Content-Type"), is("application/json"));
// TODO (mbrown): use hamcrest-jackson for this, once we upgrade to Java 8
final JsonNode requestJson = toJson(recordedRequest.getBody());
final JsonNode capAddNode = requestJson.get("HostConfig").get("CapAdd");
assertThat(capAddNode.isArray(), is(true));
assertThat(childrenTextNodes((ArrayNode) capAddNode), containsInAnyOrder("baz", "qux"));
}
use of okhttp3.Request.Builder in project docker-client by spotify.
the class DefaultDockerClientUnitTest method testInspectNodeNonManager.
@Test
public void testInspectNodeNonManager() throws Exception {
final DefaultDockerClient dockerClient = new DefaultDockerClient(builder);
enqueueServerApiVersion("1.27");
server.enqueue(new MockResponse().setResponseCode(200).addHeader("Content-Type", "application/json").setBody(fixture("fixtures/1.27/nodeInfoNonManager.json")));
NodeInfo nodeInfo = dockerClient.inspectNode("24ifsmvkjbyhk");
assertThat(nodeInfo, notNullValue());
assertThat(nodeInfo.id(), is("24ifsmvkjbyhk"));
assertThat(nodeInfo.status(), notNullValue());
assertThat(nodeInfo.status().addr(), is("172.17.0.2"));
assertThat(nodeInfo.managerStatus(), nullValue());
}
use of okhttp3.Request.Builder in project docker-client by spotify.
the class DefaultDockerClientUnitTest method testInspectNonLeaderNode.
@Test
public void testInspectNonLeaderNode() throws Exception {
final DefaultDockerClient dockerClient = new DefaultDockerClient(builder);
enqueueServerApiVersion("1.27");
server.enqueue(new MockResponse().setResponseCode(200).addHeader("Content-Type", "application/json").setBody(fixture("fixtures/1.27/nodeInfoNonLeader.json")));
NodeInfo nodeInfo = dockerClient.inspectNode("24ifsmvkjbyhk");
assertThat(nodeInfo, notNullValue());
assertThat(nodeInfo.id(), is("24ifsmvkjbyhk"));
assertThat(nodeInfo.status(), notNullValue());
assertThat(nodeInfo.status().addr(), is("172.17.0.2"));
assertThat(nodeInfo.managerStatus(), notNullValue());
assertThat(nodeInfo.managerStatus().addr(), is("172.17.0.2:2377"));
assertThat(nodeInfo.managerStatus().leader(), nullValue());
assertThat(nodeInfo.managerStatus().reachability(), is("reachable"));
}
use of okhttp3.Request.Builder in project docker-client by spotify.
the class DefaultDockerClientUnitTest method testInspectConfig_NotFound.
@Test(expected = NotFoundException.class)
public void testInspectConfig_NotFound() throws Exception {
final DefaultDockerClient dockerClient = new DefaultDockerClient(builder);
enqueueServerApiVersion("1.30");
server.enqueue(new MockResponse().setResponseCode(404).addHeader("Content-Type", "application/json"));
dockerClient.inspectConfig("ktnbjxoalbkvbvedmg1urrz8h");
}
Aggregations