forked from docker-java/docker-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomCommandIT.java
More file actions
36 lines (28 loc) · 1.23 KB
/
Copy pathCustomCommandIT.java
File metadata and controls
36 lines (28 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package com.github.dockerjava.cmd;
import com.github.dockerjava.core.DockerClientImpl;
import com.github.dockerjava.core.DockerRule;
import com.github.dockerjava.transport.DockerHttpClient;
import com.github.dockerjava.transport.DockerHttpClient.Request;
import com.github.dockerjava.transport.DockerHttpClient.Response;
import org.apache.commons.io.IOUtils;
import org.junit.Assume;
import org.junit.Test;
import java.nio.charset.StandardCharsets;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
public class CustomCommandIT extends CmdIT {
@Test
public void testCustomCommand() throws Exception {
DockerClientImpl dockerClient = getFactoryType().createDockerClient(DockerRule.config(null));
DockerHttpClient httpClient = dockerClient.getHttpClient();
Assume.assumeNotNull(httpClient);
Request request = Request.builder()
.method(Request.Method.GET)
.path("/_ping")
.build();
try (Response response = httpClient.execute(request)) {
assertThat(response.getStatusCode(), equalTo(200));
assertThat(IOUtils.toString(response.getBody(), StandardCharsets.UTF_8), equalTo("OK"));
}
}
}