DockerConnector { public InputStream getResource(String container, String sourcePath) throws IOException { try (DockerConnection connection = openConnection(dockerDaemonUri).method("GET") .path("/containers/" + container + "/archive") .query("path", sourcePath)) { final DockerResponse response = connection.request(); final int status = response.getStatus(); if (status != OK.getStatusCode()) { throw new DockerException(getDockerExceptionMessage(response), status); } return new CloseConnectionInputStream(response.getInputStream(), connection); } } DockerConnector(InitialAuthConfig initialAuthConfig);  DockerConnector(URI dockerDaemonUri,
                           DockerCertificates dockerCertificates,
                           InitialAuthConfig initialAuthConfig); @Inject private  DockerConnector(DockerConnectorConfiguration connectorConfiguration); org.eclipse.che.plugin.docker.client.json.SystemInfo getSystemInfo(); Version getVersion(); Image[] listImages(); String buildImage(String repository, ProgressMonitor progressMonitor, AuthConfigs authConfigs, File... files); ImageInfo inspectImage(String image); void removeImage(String image, boolean force); void tag(String image, String repository, String tag); void push(String repository,
                     String tag,
                     String registry,
                     final ProgressMonitor progressMonitor); void pull(String image,
                     String tag,
                     String registry,
                     ProgressMonitor progressMonitor); ContainerCreated createContainer(ContainerConfig containerConfig, String containerName); void startContainer(String container, HostConfig hostConfig); void stopContainer(String container, long timeout, TimeUnit timeunit); void killContainer(String container, int signal); void killContainer(String container); void removeContainer(String container, boolean force, boolean removeVolumes); int waitContainer(String container); ContainerInfo inspectContainer(String container); void attachContainer(String container, MessageProcessor<LogMessage> containerLogsProcessor, boolean stream); String commit(String container, String repository, String tag, String comment, String author); @Deprecated void copy(String container, String path, File hostPath); Exec createExec(String container, boolean detach, String... cmd); void startExec(String execId, MessageProcessor<LogMessage> execOutputProcessor); ExecInfo getExecInfo(String execId); ContainerProcesses top(String container, String... psArgs); InputStream getResource(String container, String sourcePath); void putResource(String container,
                            String targetPath,
                            InputStream sourceStream,
                            boolean noOverwriteDirNonDir); void getEvents(long sinceSecond,
                          long untilSecond,
                          Filters filters,
                          MessageProcessor<Event> messageProcessor); static final String UNIX_SOCKET_SCHEME; static final String UNIX_SOCKET_PATH; static final URI UNIX_SOCKET_URI; static final String DOCKER_CERT_PATH_PROPERTY; static final String DOCKER_TLS_VERIFY_PROPERTY; static final String DOCKER_HOST_PROPERTY; static final URI DEFAULT_DOCKER_MACHINE_URI; static final String DEFAULT_DOCKER_MACHINE_CERTS_DIR; }
@Test public void shouldGetResourcesFromContainer() throws IOException { String resource = "stream data"; when(dockerResponse.getStatus()).thenReturn(200); when(dockerResponse.getInputStream()) .thenReturn(new CloseConnectionInputStream(new ByteArrayInputStream(resource.getBytes()), dockerConnection)); String response = CharStreams.toString(new InputStreamReader(dockerConnector.getResource("id", "path"))); Assert.assertEquals(response, resource); }
@Test(expectedExceptions = IOException.class, expectedExceptionsMessageRegExp = "Error response from docker API, status: 500, message: Error") public void shouldProduceAnErrorWhenGetsResourcesFromContainer() throws IOException { String msg = "Error"; when(dockerResponse.getStatus()).thenReturn(500); when(dockerResponse.getInputStream()) .thenReturn(new CloseConnectionInputStream(new ByteArrayInputStream(msg.getBytes()), dockerConnection)); dockerConnector.getResource("id", "path"); }