Skip to content

Commit 0446591

Browse files
committed
Fix unit test failures on Windows
1 parent 9f5b913 commit 0446591

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

docker-java/src/test/java/com/github/dockerjava/core/DefaultDockerClientConfigTest.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.github.dockerjava.api.model.AuthConfigurations;
66
import com.google.common.io.Resources;
77
import org.apache.commons.lang3.SerializationUtils;
8+
import org.apache.commons.lang3.SystemUtils;
89
import org.junit.Test;
910

1011
import java.io.File;
@@ -97,8 +98,11 @@ public void emptyHost() {
9798

9899
DefaultDockerClientConfig config = buildConfig(env, new Properties());
99100

101+
String expectedDefaultHost = SystemUtils.IS_OS_WINDOWS ? DefaultDockerClientConfig.WINDOWS_DEFAULT_DOCKER_HOST
102+
: DefaultDockerClientConfig.DEFAULT_DOCKER_HOST;
103+
100104
assertEquals(
101-
DefaultDockerClientConfig.DEFAULT_DOCKER_HOST,
105+
expectedDefaultHost,
102106
config.getDockerHost().toString()
103107
);
104108
}
@@ -119,7 +123,9 @@ public void defaults() throws Exception {
119123
DefaultDockerClientConfig config = buildConfig(Collections.<String, String> emptyMap(), systemProperties);
120124

121125
// then the cert path is as expected
122-
assertEquals(config.getDockerHost(), URI.create("unix:///var/run/docker.sock"));
126+
URI expectedDefaultURI = SystemUtils.IS_OS_WINDOWS ? URI.create(DefaultDockerClientConfig.WINDOWS_DEFAULT_DOCKER_HOST)
127+
: URI.create(DefaultDockerClientConfig.DEFAULT_DOCKER_HOST);
128+
assertEquals(config.getDockerHost(), expectedDefaultURI);
123129
assertEquals(config.getRegistryUsername(), "someUserName");
124130
assertEquals(config.getRegistryUrl(), AuthConfig.DEFAULT_SERVER_ADDRESS);
125131
assertEquals(config.getApiVersion(), RemoteApiVersion.unknown());

docker-java/src/test/java/com/github/dockerjava/core/util/CompressArchiveUtilTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
44
import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
5+
import org.apache.commons.lang3.SystemUtils;
56
import org.junit.Rule;
67
import org.junit.Test;
78
import org.junit.rules.TemporaryFolder;
@@ -22,6 +23,7 @@
2223
import static org.junit.Assert.assertEquals;
2324
import static org.junit.Assert.assertNotNull;
2425
import static org.junit.Assert.assertTrue;
26+
import static org.junit.Assume.assumeFalse;
2527

2628
public class CompressArchiveUtilTest {
2729

@@ -69,6 +71,7 @@ public void tarWithExecutableFileAsInput() throws Exception {
6971

7072
@Test
7173
public void tarWithSymbolicLinkFileAsInput() throws IOException {
74+
assumeSymbolicLinksAreUnrestrictedByDefault();
7275
Path archiveSourceFile = tempFolder.getRoot().toPath().resolve("symlinkFile");
7376
Path linkTargetFile = tempFolder.newFile("link-target").toPath();
7477
Files.createSymbolicLink(archiveSourceFile, linkTargetFile);
@@ -139,6 +142,7 @@ public void tarWithfolderAsInputAndNestedExecutableFile() throws Exception {
139142

140143
@Test
141144
public void tarWithfolderAsInputAndNestedSymbolicLinkFile() throws Exception {
145+
assumeSymbolicLinksAreUnrestrictedByDefault();
142146
Path archiveSourceDir = tempFolder.newFolder("archive-source").toPath();
143147
Path linkTargetFile = tempFolder.newFile("link-target").toPath();
144148
Path symlinkFile = archiveSourceDir.resolve("symlinkFile");
@@ -160,6 +164,7 @@ public void tarWithfolderAsInputAndNestedSymbolicLinkFile() throws Exception {
160164

161165
@Test
162166
public void tarWithfolderAsInputAndNestedSymbolicLinkDir() throws Exception {
167+
assumeSymbolicLinksAreUnrestrictedByDefault();
163168
Path archiveSourceDir = tempFolder.newFolder("archive-source").toPath();
164169
Path linkTargetDir = tempFolder.newFolder("link-target").toPath();
165170
Path symlinkFile = archiveSourceDir.resolve("symlinkFile");
@@ -204,6 +209,7 @@ public void archiveTARFilesWithExecutableFile() throws Exception {
204209

205210
@Test
206211
public void archiveTARFilesWithSymbolicLinkFile() throws Exception {
212+
assumeSymbolicLinksAreUnrestrictedByDefault();
207213
Path linkTargetFile = tempFolder.newFile("link-target").toPath();
208214
Path symlinkFile = tempFolder.getRoot().toPath().resolve("symlinkFile");
209215
Files.createSymbolicLink(symlinkFile, linkTargetFile);
@@ -215,6 +221,7 @@ public void archiveTARFilesWithSymbolicLinkFile() throws Exception {
215221

216222
@Test
217223
public void archiveTARFilesWithSymbolicLinkDir() throws Exception {
224+
assumeSymbolicLinksAreUnrestrictedByDefault();
218225
Path linkTargetDir = tempFolder.newFolder("link-target").toPath();
219226
Path symlinkFile = tempFolder.getRoot().toPath().resolve("symlinkFile");
220227
Files.createSymbolicLink(symlinkFile, linkTargetDir);
@@ -317,4 +324,8 @@ private static int getNumberOfEntryInArchive(File tarArchive) throws IOException
317324
}
318325
return numberOfEntries;
319326
}
327+
328+
private static void assumeSymbolicLinksAreUnrestrictedByDefault(){
329+
assumeFalse(SystemUtils.IS_OS_WINDOWS);
330+
}
320331
}

0 commit comments

Comments
 (0)