Search in sources :

Example 61 with Builder

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

the class DefaultDockerClientUnitTest method testUpdateConfig_NotFound.

@Test(expected = NotFoundException.class)
public void testUpdateConfig_NotFound() throws Exception {
    final DefaultDockerClient dockerClient = new DefaultDockerClient(builder);
    enqueueServerApiVersion("1.30");
    server.enqueue(new MockResponse().setResponseCode(404).addHeader("Content-Type", "application/json"));
    final ConfigSpec configSpec = ConfigSpec.builder().data(Base64.encodeAsString("foobar")).name("foo.yaml").build();
    dockerClient.updateConfig("ktnbjxoalbkvbvedmg1urrz8h", 11L, configSpec);
}
Also used : MockResponse(okhttp3.mockwebserver.MockResponse) ConfigSpec(com.spotify.docker.client.messages.swarm.ConfigSpec) Test(org.junit.Test)

Example 62 with Builder

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

the class DefaultDockerClientUnitTest method testCustomHeaders.

@Test
public void testCustomHeaders() throws Exception {
    builder.header("int", 1);
    builder.header("string", "2");
    builder.header("list", Lists.newArrayList("a", "b", "c"));
    server.enqueue(new MockResponse());
    final DefaultDockerClient dockerClient = new DefaultDockerClient(builder);
    dockerClient.info();
    final RecordedRequest recordedRequest = takeRequestImmediately();
    assertThat(recordedRequest.getMethod(), is("GET"));
    assertThat(recordedRequest.getPath(), is("/info"));
    assertThat(recordedRequest.getHeader("int"), is("1"));
    assertThat(recordedRequest.getHeader("string"), is("2"));
    // TODO (mbrown): this seems like incorrect behavior - the client should send 3 headers with
    // name "list", not one header with a value of "[a, b, c]"
    assertThat(recordedRequest.getHeaders().values("list"), contains("[a, b, c]"));
}
Also used : RecordedRequest(okhttp3.mockwebserver.RecordedRequest) MockResponse(okhttp3.mockwebserver.MockResponse) Test(org.junit.Test)

Example 63 with Builder

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

the class DefaultDockerClientUnitTest method testCreateConfig_ConflictingName.

@Test(expected = ConflictException.class)
public void testCreateConfig_ConflictingName() throws Exception {
    final DefaultDockerClient dockerClient = new DefaultDockerClient(builder);
    enqueueServerApiVersion("1.30");
    server.enqueue(new MockResponse().setResponseCode(409).addHeader("Content-Type", "application/json"));
    final ConfigSpec configSpec = ConfigSpec.builder().data(Base64.encodeAsString("foobar")).name("foo.yaml").build();
    dockerClient.createConfig(configSpec);
}
Also used : MockResponse(okhttp3.mockwebserver.MockResponse) ConfigSpec(com.spotify.docker.client.messages.swarm.ConfigSpec) Test(org.junit.Test)

Example 64 with Builder

use of okhttp3.Request.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 65 with Builder

use of okhttp3.Request.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)

Aggregations

Request (okhttp3.Request)170 Response (okhttp3.Response)120 OkHttpClient (okhttp3.OkHttpClient)103 IOException (java.io.IOException)89 RequestBody (okhttp3.RequestBody)68 Test (org.junit.Test)68 File (java.io.File)36 MultipartBody (okhttp3.MultipartBody)36 HttpUrl (okhttp3.HttpUrl)34 Map (java.util.Map)31 MockResponse (okhttp3.mockwebserver.MockResponse)31 Call (okhttp3.Call)26 Interceptor (okhttp3.Interceptor)26 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)26 HttpLoggingInterceptor (okhttp3.logging.HttpLoggingInterceptor)24 Builder (okhttp3.OkHttpClient.Builder)21 Retrofit (retrofit2.Retrofit)21 Builder (okhttp3.Request.Builder)19 FormBody (okhttp3.FormBody)18 ResponseBody (okhttp3.ResponseBody)18