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
2 changes: 1 addition & 1 deletion docker-java-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.10</version>
<version>1.18.12</version>
<scope>provided</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,8 @@ public ContainerNetwork withNetworkID(String networkID) {
/**
* Docker named it EndpointIPAMConfig
*/
public static class Ipam {
public static class Ipam implements Serializable {
private static final long serialVersionUID = 1L;

@JsonProperty("IPv4Address")
private String ipv4Address;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ public InfoRegistryConfig withMirrors(Object mirrors) {
*/
@EqualsAndHashCode
@ToString
public static final class IndexConfig {
public static final class IndexConfig implements Serializable {
private static final long serialVersionUID = 1L;

@JsonProperty("Mirrors")
private List<String> mirrors;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ public Map<String, String> getLabels() {

@EqualsAndHashCode
@ToString
public static class ContainerNetworkConfig {
public static class ContainerNetworkConfig implements Serializable {
private static final long serialVersionUID = 1L;

@JsonProperty("EndpointID")
private String endpointId;
Expand Down Expand Up @@ -127,7 +128,8 @@ public String getIpv6Address() {

@EqualsAndHashCode
@ToString
public static class Ipam {
public static class Ipam implements Serializable {
private static final long serialVersionUID = 1L;

@JsonProperty("Driver")
private String driver;
Expand Down Expand Up @@ -165,7 +167,8 @@ public Ipam withDriver(String driver) {
return this;
}

public static class Config {
public static class Config implements Serializable {
private static final long serialVersionUID = 1L;

@JsonProperty("Subnet")
private String subnet;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ public Map<ExposedPort, Binding[]> getBindings() {
* @see ExposedPort
*/
@EqualsAndHashCode
public static class Binding {
public static class Binding implements Serializable {
private static final long serialVersionUID = 1L;

/**
* Creates a {@link Binding} for the given {@link #getHostPortSpec() port spec}, leaving the {@link #getHostIp() IP address}
Expand Down
2 changes: 1 addition & 1 deletion docker-java-transport-jersey/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.4.10</version>
<version>4.4.13</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
Expand Down
2 changes: 1 addition & 1 deletion docker-java-transport-okhttp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna-platform</artifactId>
<version>5.4.0</version>
<version>5.5.0</version>
</dependency>
</dependencies>

Expand Down
3 changes: 1 addition & 2 deletions docker-java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<version>4.13</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand All @@ -113,7 +113,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<trimStackTrace>false</trimStackTrace>
<rerunFailingTestsCount>3</rerunFailingTestsCount>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.github.dockerjava.api.model.ResponseItem;
import com.google.common.reflect.ClassPath.ClassInfo;
import org.apache.commons.lang.reflect.FieldUtils;
import org.hamcrest.MatcherAssert;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -17,10 +18,10 @@
import java.util.List;

import static com.google.common.reflect.ClassPath.from;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.object.IsCompatibleType.typeCompatibleWith;
import static org.junit.Assert.assertThat;

/**
* @author Kanstantsin Shautsou
Expand All @@ -33,13 +34,19 @@ public class ModelsSerializableTest {
BuildResponseItem.class.getName(),
PullResponseItem.class.getName(),
PushResponseItem.class.getName(),
ResponseItem.class.getName()
ResponseItem.class.getName(),
ResponseItem.ErrorDetail.class.getName(),
ResponseItem.ProgressDetail.class.getName()
);

@Test
public void allModelsSerializable() throws IOException, NoSuchFieldException, IllegalAccessException {
final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
for (ClassInfo classInfo : from(contextClassLoader).getTopLevelClasses("com.github.dockerjava.api.model")) {
for (ClassInfo classInfo : from(contextClassLoader).getAllClasses()) {
if (!classInfo.getPackageName().equals("com.github.dockerjava.api.model")) {
continue;
}

if (classInfo.getName().endsWith("Test")) {
continue;
}
Expand All @@ -50,13 +57,13 @@ public void allModelsSerializable() throws IOException, NoSuchFieldException, Il
continue;
}

LOG.debug("aClass: {}", aClass);
LOG.debug("Checking: {}", aClass);
assertThat(aClass, typeCompatibleWith(Serializable.class));

final Object serialVersionUID = FieldUtils.readDeclaredStaticField(aClass, "serialVersionUID", true);
if (!excludeClasses.contains(aClass.getName())) {
assertThat(serialVersionUID, instanceOf(Long.class));
assertThat("Follow devel docs", (Long) serialVersionUID, is(1L));
assertThat("Follow devel docs for " + aClass, (Long) serialVersionUID, is(1L));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
import static com.github.dockerjava.test.serdes.JSONTestHelper.testRoundTrip;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.emptyString;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.isEmptyString;
import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.nullValue;
import static org.hamcrest.core.IsNot.not;
Expand All @@ -51,7 +51,7 @@ public class InspectContainerResponseTest {
@Test
public void roundTrip_full() throws IOException {
InspectContainerResponse[] responses = testRoundTrip(CommandJSONSamples.inspectContainerResponse_full,
InspectContainerResponse[].class);
InspectContainerResponse[].class);
assertEquals(1, responses.length);
final InspectContainerResponse response = responses[0];

Expand All @@ -72,10 +72,10 @@ public void roundTrip_full_healthcheck() throws IOException {
final JavaType type = JSONTestHelper.getMapper().getTypeFactory().constructType(InspectContainerResponse.class);

final InspectContainerResponse response = testRoundTrip(RemoteApiVersion.VERSION_1_24,
"/containers/inspect/1.json",
type
"/containers/inspect/1.json",
type
);

assertEquals(response.getState().getHealth().getStatus(), "healthy");
assertEquals(response.getState().getHealth().getFailingStreak(), new Integer(0));
assertEquals(response.getState().getHealth().getLog().size(), 2);
Expand All @@ -86,7 +86,7 @@ public void roundTrip_full_healthcheck() throws IOException {
@Test
public void roundTrip_1_21_full() throws IOException {
InspectContainerResponse[] responses = testRoundTrip(CommandJSONSamples.inspectContainerResponse_full_1_21,
InspectContainerResponse[].class);
InspectContainerResponse[].class);
assertEquals(1, responses.length);
final InspectContainerResponse response = responses[0];
final InspectContainerResponse.ContainerState state = response.getState();
Expand All @@ -96,13 +96,13 @@ public void roundTrip_1_21_full() throws IOException {
assertThat(state.getStatus(), containsString("running"));
assertFalse(state.getRestarting());
assertFalse(state.getOOMKilled());
assertThat(state.getError(), isEmptyString());
assertThat(state.getError(), is(emptyString()));
}

@Test
public void roundTrip_1_26a_full() throws IOException {
InspectContainerResponse[] responses = testRoundTrip(CommandJSONSamples.inspectContainerResponse_full_1_26a,
InspectContainerResponse[].class);
InspectContainerResponse[].class);

assertEquals(1, responses.length);
final InspectContainerResponse response = responses[0];
Expand All @@ -118,7 +118,7 @@ public void roundTrip_1_26a_full() throws IOException {
@Test
public void roundTrip_1_26b_full() throws IOException {
InspectContainerResponse[] responses = testRoundTrip(CommandJSONSamples.inspectContainerResponse_full_1_26b,
InspectContainerResponse[].class);
InspectContainerResponse[].class);

assertEquals(1, responses.length);
final InspectContainerResponse response = responses[0];
Expand All @@ -142,8 +142,8 @@ public void inspect_windows_container() throws IOException {
final JavaType type = JSONTestHelper.getMapper().getTypeFactory().constructType(InspectContainerResponse.class);

final InspectContainerResponse response = testRoundTrip(RemoteApiVersion.VERSION_1_38,
"/containers/inspect/lcow.json",
type
"/containers/inspect/lcow.json",
type
);

assertThat(response, notNullValue());
Expand All @@ -157,31 +157,31 @@ public void inspect_windows_container() throws IOException {
assertThat(response.getGraphDriver(), notNullValue());
assertThat(response.getGraphDriver().getName(), is("windowsfilter"));
assertThat(response.getGraphDriver().getData(), is(new GraphData().withDir(
"C:\\ProgramData\\Docker\\windowsfilter\\35da02ca897bd378ee52be3066c847fee396ba1a28a00b4be36f42c6686bf556"
"C:\\ProgramData\\Docker\\windowsfilter\\35da02ca897bd378ee52be3066c847fee396ba1a28a00b4be36f42c6686bf556"
)));

assertThat(response.getHostConfig(), notNullValue());
assertThat(response.getHostConfig().getIsolation(), is(Isolation.HYPERV));

assertThat(response.getImageId(), is("sha256:1381511ec0122f197b6abff5bc0692bef19943ddafd6680eff41197afa3a6dda"));
assertThat(response.getLogPath(), is(
"C:\\ProgramData\\Docker\\containers\\35da02ca897bd378ee52be3066c847fee396ba1a28a00b4be36f42c6686bf556" +
"\\35da02ca897bd378ee52be3066c847fee396ba1a28a00b4be36f42c6686bf556-json.log"
"C:\\ProgramData\\Docker\\containers\\35da02ca897bd378ee52be3066c847fee396ba1a28a00b4be36f42c6686bf556" +
"\\35da02ca897bd378ee52be3066c847fee396ba1a28a00b4be36f42c6686bf556-json.log"
));
assertThat(response.getName(), is("/cranky_clarke"));

assertThat(response.getNetworkSettings(), notNullValue());
assertThat(response.getNetworkSettings().getNetworks(), is(Collections.singletonMap("nat",
new ContainerNetwork()
.withEndpointId("493b77d6fe7e3b92435b1eb01461fde669781330deb84a9cbada360db8997ebc")
.withGateway("172.17.18.1")
.withGlobalIPv6Address("")
.withGlobalIPv6PrefixLen(0)
.withIpv4Address("172.17.18.123")
.withIpPrefixLen(16)
.withIpV6Gateway("")
.withMacAddress("00:aa:ff:cf:dd:09")
.withNetworkID("398c0e206dd677ed4a6566f9de458311f5767d8c7a8b963275490ab64c5d10a7")
new ContainerNetwork()
.withEndpointId("493b77d6fe7e3b92435b1eb01461fde669781330deb84a9cbada360db8997ebc")
.withGateway("172.17.18.1")
.withGlobalIPv6Address("")
.withGlobalIPv6PrefixLen(0)
.withIpv4Address("172.17.18.123")
.withIpPrefixLen(16)
.withIpV6Gateway("")
.withMacAddress("00:aa:ff:cf:dd:09")
.withNetworkID("398c0e206dd677ed4a6566f9de458311f5767d8c7a8b963275490ab64c5d10a7")
)));

assertThat(response.getPath(), is("cmd"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.isEmptyString;
import static org.hamcrest.Matchers.emptyString;
import static org.hamcrest.core.IsNull.notNullValue;
import static org.hamcrest.core.IsNull.nullValue;

Expand Down Expand Up @@ -40,7 +40,7 @@ public void test_1_22_SerDer1() throws Exception {
assertThat(processConfig.getEntryPoint(), is("/bin/bash"));
assertThat(processConfig.getArguments(), hasSize(0));
assertThat(processConfig.isPrivileged(), is(false));
assertThat(processConfig.getUser(), isEmptyString());
assertThat(processConfig.getUser(), is(emptyString()));


assertThat(execResponse.isOpenStdin(), is(false));
Expand All @@ -50,6 +50,6 @@ public void test_1_22_SerDer1() throws Exception {
assertThat(execResponse.getContainerID(),
is("ffa39805f089af3099e36452a985481f96170a9dff40be69d34d1722c7660d38"));

assertThat(execResponse.getDetachKeys(), isEmptyString());
assertThat(execResponse.getDetachKeys(), is(emptyString()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.isEmptyString;
import static org.hamcrest.Matchers.emptyString;
import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.nullValue;

Expand Down Expand Up @@ -84,7 +84,7 @@ public void serder1_22Json() throws IOException {
assertThat(inspectImage, notNullValue());
assertThat(inspectImage.getArch(), is("amd64"));
assertThat(inspectImage.getAuthor(), is("hack@worldticket.net"));
assertThat(inspectImage.getComment(), isEmptyString());
assertThat(inspectImage.getComment(), is(emptyString()));

assertThat(inspectImage.getConfig(), notNullValue());
assertThat(inspectImage.getConfig(), equalTo(config));
Expand All @@ -98,7 +98,7 @@ public void serder1_22Json() throws IOException {
assertThat(inspectImage.getDockerVersion(), is("0.8.1"));
assertThat(inspectImage.getId(), is("sha256:ee45fe0d1fcdf1a0f9c2d1e36c6f4b3202bbb2032f14d7c9312b27bfcf6aee24"));
assertThat(inspectImage.getOs(), is("linux"));
assertThat(inspectImage.getParent(), isEmptyString());
assertThat(inspectImage.getParent(), is(emptyString()));
assertThat(inspectImage.getSize(), is(0L));

assertThat(inspectImage.getRepoTags(), hasSize(1));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import org.junit.Test;

import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;

public class BindPropagationTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import static org.hamcrest.Matchers.arrayContaining;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;

public class BindsTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,21 @@
import org.apache.commons.compress.utils.Lists;
import org.junit.Test;

import java.io.IOException;
import java.util.List;
import java.util.Map.Entry;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.arrayContainingInAnyOrder;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertThat;

public class ExposedPortsTest {

@Test
public void usesToJson() throws Exception {
ExposedPorts ports = new ExposedPorts(
new ExposedPort(80),
new ExposedPort(123, InternetProtocol.UDP),
new ExposedPort(3868, InternetProtocol.SCTP)
new ExposedPort(80),
new ExposedPort(123, InternetProtocol.UDP),
new ExposedPort(3868, InternetProtocol.SCTP)
);
String json = JSONTestHelper.getMapper().writeValueAsString(ports);
List<Entry<String, JsonNode>> jsonEntries = getJsonEntries(json);
Expand All @@ -42,9 +41,9 @@ public void usesFromJson() throws Exception {

assertThat(ports, notNullValue());
assertThat(ports.getExposedPorts(), arrayContainingInAnyOrder(
new ExposedPort(80),
new ExposedPort(123, InternetProtocol.UDP),
new ExposedPort(3868, InternetProtocol.SCTP)
new ExposedPort(80),
new ExposedPort(123, InternetProtocol.UDP),
new ExposedPort(3868, InternetProtocol.SCTP)
));
}
}
Loading