|
3 | 3 | import com.github.dockerjava.api.command.CreateContainerResponse; |
4 | 4 | import com.github.dockerjava.api.exception.DockerClientException; |
5 | 5 | import com.github.dockerjava.api.exception.NotFoundException; |
| 6 | +import com.github.dockerjava.core.RemoteApiVersion; |
6 | 7 | import com.github.dockerjava.core.command.PullImageResultCallback; |
7 | 8 | import com.github.dockerjava.core.command.PushImageResultCallback; |
8 | 9 | import com.github.dockerjava.junit.category.AuthIntegration; |
|
16 | 17 |
|
17 | 18 | import java.util.concurrent.TimeUnit; |
18 | 19 |
|
| 20 | +import static com.github.dockerjava.utils.TestUtils.getVersion; |
| 21 | +import static com.github.dockerjava.utils.TestUtils.isNotSwarm; |
19 | 22 | import static org.hamcrest.MatcherAssert.assertThat; |
20 | | -import static org.hamcrest.Matchers.anyOf; |
21 | | -import static org.hamcrest.Matchers.instanceOf; |
22 | 23 | import static org.hamcrest.Matchers.isEmptyString; |
23 | 24 | import static org.hamcrest.Matchers.not; |
24 | 25 |
|
@@ -62,11 +63,17 @@ public void pushLatest() throws Exception { |
62 | 63 |
|
63 | 64 | @Test |
64 | 65 | public void pushNonExistentImage() throws Exception { |
65 | | - //swarms throws a different error here |
66 | | - exception.expect(anyOf(instanceOf(DockerClientException.class), instanceOf(NotFoundException.class))); |
| 66 | + |
| 67 | + if (isNotSwarm(dockerRule.getClient()) && getVersion(dockerRule.getClient()) |
| 68 | + .isGreaterOrEqual(RemoteApiVersion.VERSION_1_24)) { |
| 69 | + exception.expect(DockerClientException.class); |
| 70 | + } else { |
| 71 | + exception.expect(NotFoundException.class); |
| 72 | + } |
67 | 73 |
|
68 | 74 | dockerRule.getClient().pushImageCmd(username + "/xxx") |
69 | 75 | .exec(new PushImageResultCallback()) |
70 | | - .awaitCompletion(30, TimeUnit.SECONDS); |
| 76 | + .awaitCompletion(30, TimeUnit.SECONDS); // exclude infinite await sleep |
| 77 | + |
71 | 78 | } |
72 | 79 | } |
0 commit comments