Search in sources :

Example 36 with Builder

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

the class DefaultDockerClientUnitTest method testInspectConfig_NonSwarmNode.

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

Example 37 with Builder

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

the class DefaultDockerClientUnitTest method testListNodesWithServerError.

@Test(expected = DockerException.class)
public void testListNodesWithServerError() throws Exception {
    final DefaultDockerClient dockerClient = new DefaultDockerClient(builder);
    enqueueServerApiVersion("1.28");
    server.enqueue(new MockResponse().setResponseCode(500).addHeader("Content-Type", "application/json"));
    dockerClient.listNodes();
}
Also used : MockResponse(okhttp3.mockwebserver.MockResponse) Test(org.junit.Test)

Example 38 with Builder

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

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

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

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