|
1 | 1 | package com.github.dockerjava.netty.exec; |
2 | 2 |
|
| 3 | +import static com.github.dockerjava.core.RemoteApiVersion.VERSION_1_22; |
| 4 | +import static com.github.dockerjava.core.RemoteApiVersion.VERSION_1_23; |
| 5 | +import static com.github.dockerjava.utils.TestUtils.getVersion; |
3 | 6 | import static org.hamcrest.MatcherAssert.assertThat; |
4 | 7 | import static org.hamcrest.Matchers.isEmptyString; |
5 | 8 | import static org.hamcrest.Matchers.not; |
|
12 | 15 | import java.security.SecureRandom; |
13 | 16 | import java.util.concurrent.TimeUnit; |
14 | 17 |
|
| 18 | +import com.github.dockerjava.core.RemoteApiVersion; |
15 | 19 | import org.testng.ITestResult; |
16 | 20 | import org.testng.annotations.AfterMethod; |
17 | 21 | import org.testng.annotations.AfterTest; |
@@ -193,16 +197,22 @@ public void execStartNotAttachedStdin() throws Exception { |
193 | 197 | ExecCreateCmdResponse execCreateCmdResponse = dockerClient.execCreateCmd(container.getId()) |
194 | 198 | .withAttachStdout(true) |
195 | 199 | .withAttachStdin(false) |
196 | | - .withCmd("/bin/sh").exec(); |
| 200 | + .withCmd("/bin/sh") |
| 201 | + .exec(); |
197 | 202 |
|
198 | 203 | boolean completed = dockerClient.execStartCmd(execCreateCmdResponse.getId()) |
199 | 204 | .withDetach(false) |
200 | 205 | .withStdIn(stdin) |
201 | 206 | .exec(new ExecStartResultCallback(stdout, System.err)) |
202 | 207 | .awaitCompletion(5, TimeUnit.SECONDS); |
203 | 208 |
|
204 | | - // with v1.22 of the remote api the server closed the connection when no stdin was attached while exec create, so completed was true |
205 | | - assertFalse(completed, "The process was not finished."); |
206 | 209 | assertEquals(stdout.toString(), ""); |
| 210 | + |
| 211 | + if (getVersion(dockerClient).isGreaterOrEqual(VERSION_1_23)) { |
| 212 | + assertFalse(completed, "The process was not finished."); |
| 213 | + } else { |
| 214 | + assertTrue(completed, "with v1.22 of the remote api the server closed the connection when no stdin " + |
| 215 | + "was attached while exec create, so completed was true"); |
| 216 | + } |
207 | 217 | } |
208 | 218 | } |
0 commit comments