Search in sources :

Example 41 with Builder

use of okhttp3.FormBody.Builder in project docker-client by spotify.

the class DefaultDockerClientUnitTest method testInspectConfig.

@Test
public void testInspectConfig() throws Exception {
    final DefaultDockerClient dockerClient = new DefaultDockerClient(builder);
    enqueueServerApiVersion("1.30");
    server.enqueue(new MockResponse().setResponseCode(200).addHeader("Content-Type", "application/json").setBody(fixture("fixtures/1.30/inspectConfig.json")));
    final Config config = dockerClient.inspectConfig("ktnbjxoalbkvbvedmg1urrz8h");
    assertThat(config, notNullValue());
    assertThat(config.id(), equalTo("ktnbjxoalbkvbvedmg1urrz8h"));
    assertThat(config.version().index(), equalTo(11L));
    final ConfigSpec configSpec = config.configSpec();
    assertThat(configSpec.name(), equalTo("app-dev.crt"));
}
Also used : MockResponse(okhttp3.mockwebserver.MockResponse) HostConfig(com.spotify.docker.client.messages.HostConfig) ContainerConfig(com.spotify.docker.client.messages.ContainerConfig) EngineConfig(com.spotify.docker.client.messages.swarm.EngineConfig) Config(com.spotify.docker.client.messages.swarm.Config) ConfigSpec(com.spotify.docker.client.messages.swarm.ConfigSpec) Test(org.junit.Test)

Example 42 with Builder

use of okhttp3.FormBody.Builder in project docker-client by spotify.

the class DefaultDockerClientUnitTest method testDeleteConfig.

@Test
public void testDeleteConfig() throws Exception {
    final DefaultDockerClient dockerClient = new DefaultDockerClient(builder);
    enqueueServerApiVersion("1.30");
    server.enqueue(new MockResponse().setResponseCode(204).addHeader("Content-Type", "application/json"));
    dockerClient.deleteConfig("ktnbjxoalbkvbvedmg1urrz8h");
}
Also used : MockResponse(okhttp3.mockwebserver.MockResponse) Test(org.junit.Test)

Example 43 with Builder

use of okhttp3.FormBody.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")));
}
Also used : MockResponse(okhttp3.mockwebserver.MockResponse) Volume(com.spotify.docker.client.messages.Volume) Test(org.junit.Test)

Example 44 with Builder

use of okhttp3.FormBody.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"));
}
Also used : ContainerConfig(com.spotify.docker.client.messages.ContainerConfig) RecordedRequest(okhttp3.mockwebserver.RecordedRequest) MockResponse(okhttp3.mockwebserver.MockResponse) HostConfig(com.spotify.docker.client.messages.HostConfig) JsonNode(com.fasterxml.jackson.databind.JsonNode) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) Test(org.junit.Test)

Example 45 with Builder

use of okhttp3.FormBody.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());
}
Also used : MockResponse(okhttp3.mockwebserver.MockResponse) NodeInfo(com.spotify.docker.client.messages.swarm.NodeInfo) Test(org.junit.Test)

Aggregations

Request (okhttp3.Request)190 Response (okhttp3.Response)133 OkHttpClient (okhttp3.OkHttpClient)128 IOException (java.io.IOException)100 RequestBody (okhttp3.RequestBody)77 Test (org.junit.Test)68 File (java.io.File)42 HttpUrl (okhttp3.HttpUrl)40 MultipartBody (okhttp3.MultipartBody)40 Map (java.util.Map)34 MockResponse (okhttp3.mockwebserver.MockResponse)32 Call (okhttp3.Call)29 Retrofit (retrofit2.Retrofit)29 Interceptor (okhttp3.Interceptor)28 HttpLoggingInterceptor (okhttp3.logging.HttpLoggingInterceptor)26 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)25 Builder (okhttp3.OkHttpClient.Builder)24 ResponseBody (okhttp3.ResponseBody)21 Provides (dagger.Provides)20 FormBody (okhttp3.FormBody)20