File tree Expand file tree Collapse file tree 2 files changed +21
-3
lines changed
main/java/org/testcontainers/images
test/java/org/testcontainers/containers Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ public class RemoteDockerImage extends LazyFuture<String> {
2828
2929 private static final Duration PULL_RETRY_TIME_LIMIT = Duration .ofMinutes (2 );
3030
31+ @ ToString .Exclude
3132 private Future <DockerImageName > imageNameFuture ;
3233
3334 @ Wither
@@ -54,9 +55,8 @@ protected DockerImageName resolve() {
5455 }
5556
5657 @ Override
57- @ SneakyThrows ({InterruptedException .class , ExecutionException .class })
5858 protected final String resolve () {
59- final DockerImageName imageName = imageNameFuture . get ();
59+ final DockerImageName imageName = getImageName ();
6060 Logger logger = DockerLoggerFactory .getLogger (imageName .toString ());
6161 try {
6262 if (!imagePullPolicy .shouldPull (imageName )) {
@@ -95,4 +95,10 @@ protected final String resolve() {
9595 throw new ContainerFetchException ("Failed to get Docker client for " + imageName , e );
9696 }
9797 }
98+
99+ @ ToString .Include (name = "imageName" , rank = 1 )
100+ @ SneakyThrows ({InterruptedException .class , ExecutionException .class })
101+ DockerImageName getImageName () {
102+ return imageNameFuture .get ();
103+ }
98104}
Original file line number Diff line number Diff line change 22
33import com .github .dockerjava .api .DockerClient ;
44import com .github .dockerjava .api .command .InspectContainerResponse .ContainerState ;
5- import com .github .dockerjava .api .model .HostConfig ;
65import lombok .RequiredArgsConstructor ;
76import lombok .SneakyThrows ;
87import lombok .experimental .FieldDefaults ;
@@ -54,6 +53,19 @@ public void shouldReportErrorAfterWait() {
5453 }
5554 }
5655
56+ @ Test
57+ public void shouldLogImageNameWhenGetDockerImageNameFails () {
58+ // A docker image that doesn't exist is enough. The NotFoundException
59+ // that the ContainerFetchException wraps may contain the image name.
60+ // This test verifies that the ContainerFetchException itself does.
61+ String imageName = "doesNotExist" ;
62+ try (GenericContainer container = new GenericContainer <>(imageName )) {
63+ assertThatThrownBy (container ::getDockerImageName )
64+ .isInstanceOf (ContainerFetchException .class )
65+ .hasMessageContaining (imageName );
66+ }
67+ }
68+
5769 static class NoopStartupCheckStrategy extends StartupCheckStrategy {
5870
5971 @ Override
You can’t perform that action at this time.
0 commit comments