|
34 | 34 | import java.util.Arrays; |
35 | 35 | import java.util.Collections; |
36 | 36 | import java.util.HashMap; |
| 37 | +import java.util.List; |
37 | 38 | import java.util.Map; |
38 | 39 | import java.util.UUID; |
39 | 40 | import java.util.concurrent.TimeUnit; |
|
45 | 46 | import static org.hamcrest.Matchers.containsInAnyOrder; |
46 | 47 | import static org.hamcrest.Matchers.containsString; |
47 | 48 | import static org.hamcrest.Matchers.equalTo; |
| 49 | +import static org.hamcrest.Matchers.hasItem; |
48 | 50 | import static org.hamcrest.Matchers.hasItemInArray; |
| 51 | +import static org.hamcrest.Matchers.hasSize; |
49 | 52 | import static org.hamcrest.Matchers.is; |
50 | 53 | import static org.hamcrest.Matchers.isEmptyString; |
51 | 54 | import static org.hamcrest.Matchers.not; |
@@ -191,21 +194,24 @@ public void createContainerWithVolumesFrom() throws DockerException { |
191 | 194 |
|
192 | 195 | @Test |
193 | 196 | public void createContainerWithEnv() throws Exception { |
| 197 | + final String testVariable = "VARIABLE=success"; |
194 | 198 |
|
195 | | - CreateContainerResponse container = dockerClient.createContainerCmd(BUSYBOX_IMAGE).withEnv("VARIABLE=success") |
196 | | - .withCmd("env").exec(); |
| 199 | + CreateContainerResponse container = dockerClient.createContainerCmd(BUSYBOX_IMAGE) |
| 200 | + .withEnv(testVariable) |
| 201 | + .withCmd("env") |
| 202 | + .exec(); |
197 | 203 |
|
198 | 204 | LOG.info("Created container {}", container.toString()); |
199 | 205 |
|
200 | 206 | assertThat(container.getId(), not(isEmptyString())); |
201 | 207 |
|
202 | 208 | InspectContainerResponse inspectContainerResponse = dockerClient.inspectContainerCmd(container.getId()).exec(); |
203 | 209 |
|
204 | | - assertThat(Arrays.asList(inspectContainerResponse.getConfig().getEnv()), containsInAnyOrder("VARIABLE=success")); |
| 210 | + assertThat(Arrays.asList(inspectContainerResponse.getConfig().getEnv()), hasItem("VARIABLE=success")); |
205 | 211 |
|
206 | 212 | dockerClient.startContainerCmd(container.getId()).exec(); |
207 | 213 |
|
208 | | - assertThat(containerLog(container.getId()), containsString("VARIABLE=success")); |
| 214 | + assertThat(containerLog(container.getId()), containsString(testVariable)); |
209 | 215 | } |
210 | 216 |
|
211 | 217 | @Test |
|
0 commit comments