Search in sources :

Example 36 with Builder

use of okhttp3.HttpUrl.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 37 with Builder

use of okhttp3.HttpUrl.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 38 with Builder

use of okhttp3.HttpUrl.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 39 with Builder

use of okhttp3.HttpUrl.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 40 with Builder

use of okhttp3.HttpUrl.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)204 Response (okhttp3.Response)146 OkHttpClient (okhttp3.OkHttpClient)141 IOException (java.io.IOException)111 RequestBody (okhttp3.RequestBody)81 Test (org.junit.Test)75 HttpUrl (okhttp3.HttpUrl)47 File (java.io.File)42 MultipartBody (okhttp3.MultipartBody)40 MockResponse (okhttp3.mockwebserver.MockResponse)40 Map (java.util.Map)39 HttpLoggingInterceptor (okhttp3.logging.HttpLoggingInterceptor)31 Call (okhttp3.Call)29 Interceptor (okhttp3.Interceptor)29 Retrofit (retrofit2.Retrofit)29 Builder (okhttp3.OkHttpClient.Builder)26 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)25 ResponseBody (okhttp3.ResponseBody)24 HashMap (java.util.HashMap)22 FormBody (okhttp3.FormBody)21