Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ jdk:
- openjdk8
script:
- set -e
- docker pull hello-world #for some IT cases
- mvn clean install -Pcheckstyle,itcases jacoco:report coveralls:report
5 changes: 5 additions & 0 deletions src/main/java/com/amihaiemil/docker/Inspection.java
Original file line number Diff line number Diff line change
Expand Up @@ -198,4 +198,9 @@ public Collection<JsonValue> values() {
public Set<Entry<String, JsonValue>> entrySet() {
return this.json.entrySet();
}

@Override
public String toString() {
return this.json.toString();
}
}
6 changes: 3 additions & 3 deletions src/main/java/com/amihaiemil/docker/RtContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@
* @todo #97:30min Continue implementing the rest of the Container operations
* (pause, unpause, logs etc) See the Docker API Docs for reference:
* https://docs.docker.com/engine/api/v1.35/#tag/Container
* @todo #46:30min Once we have the CI environment properly setup with a Docker
* instance, write integration tests for this class as well
* (RtContainerITCase).
* @todo #58:30min Now that we have the CI environment properly setup with
* a Docker instance, continue integration tests for RtContainer(s) and other
* parts of the API.
*/
final class RtContainer implements Container {

Expand Down
60 changes: 60 additions & 0 deletions src/test/java/com/amihaiemil/docker/RtContainerITCase.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/**
* Copyright (c) 2018, Mihai Emil Andronache
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1)Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2)Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3)Neither the name of docker-java-api nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package com.amihaiemil.docker;

import java.io.File;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.Test;

/**
* Integration tests for {@link RtContainer}.
* @author Mihai Andronache (amihaiemil@gmail.com)
* @version $Id$
* @since 0.0.1
*/
public final class RtContainerITCase {

/**
* {@link RtContainer} can rename the Docker container it represents.
* @throws Exception If something goes wrong.
*/
@Test
public void renamesContainer() throws Exception {
final Container container = new LocalDocker(
new File("/var/run/docker.sock")
).containers().create("Toomes", "hello-world");
MatcherAssert.assertThat(
container.inspect().getString("Name"),
Matchers.equalTo("/Toomes")
);
container.rename("Fury");
MatcherAssert.assertThat(
container.inspect().getString("Name"),
Matchers.equalTo("/Fury")
);
}
}