Source:
public void testLoad() throws Exception { sut.pull(BUSYBOX_LATEST); final String image1 = BUSYBOX + "test1" + System.nanoTime() + ":latest"; final String image2 = BUSYBOX + "test2" + System.nanoTime() + ":latest"; try (InputStream imagePayload = new BufferedInputStream(new FileInputStream(save(BUSYBOX_LATEST)))) { sut.create(image1, imagePayload); } try (InputStream imagePayload = new BufferedInputStream(new FileInputStream(save(BUSYBOX_LATEST)))) { sut.create(image2, imagePayload); } final File imagesFile = save(image1, image2); sut.removeImage(image1); sut.removeImage(image2); try { sut.inspectImage(image1); fail("inspectImage should have thrown ImageNotFoundException"); } catch (ImageNotFoundException e) { } try { sut.inspectImage(image2); fail("inspectImage should have thrown ImageNotFoundException"); } catch (ImageNotFoundException e) { } final List<ProgressMessage> messages = new ArrayList<>(); final Set<String> loadedImages; try (InputStream imageFileInputStream = new FileInputStream(imagesFile)) { loadedImages = sut.load(imageFileInputStream, new ProgressHandler() { @Override public void progress(ProgressMessage message) throws DockerException { messages.add(message); } }); } assertEquals(loadedImages.size(), 2); assertTrue(loadedImages.contains(image1)); assertTrue(loadedImages.contains(image2)); assertThat(messages, not(empty())); for (final ProgressMessage message : messages) { assertTrue(message.error() != null || message.id() != null || message.progress() != null || message.progressDetail() != null || message.status() != null || message.stream() != null); } try { sut.inspectImage(image1); sut.inspectImage(image2); } catch (ImageNotFoundException e) { fail("image not properly loaded in the local Docker instance"); } sut.removeImage(image1); sut.removeImage(image2); }

Target:
public void testLoad() throws Exception { sut.pull(BUSYBOX_LATEST); final String image1 = BUSYBOX + "test1" + System.nanoTime() + ":latest"; final String image2 = BUSYBOX + "test2" + System.nanoTime() + ":latest"; try (InputStream imagePayload = new BufferedInputStream(new FileInputStream(save(BUSYBOX_LATEST)))) { sut.create(image1, imagePayload); } try (InputStream imagePayload = new BufferedInputStream(new FileInputStream(save(BUSYBOX_LATEST)))) { sut.create(image2, imagePayload); } final File imagesFile = save(image1, image2); sut.removeImage(image1); sut.removeImage(image2); try { sut.inspectImage(image1); fail("inspectImage should have thrown ImageNotFoundException"); } catch (ImageNotFoundException e) { } try { sut.inspectImage(image2); fail("inspectImage should have thrown ImageNotFoundException"); } catch (ImageNotFoundException e) { } final List<ProgressMessage> messages = new ArrayList<>(); final Set<String> loadedImages; try (InputStream imageFileInputStream = new FileInputStream(imagesFile)) { loadedImages = sut.load(imageFileInputStream, new ProgressHandler() { @Override public void progress(ProgressMessage message) throws DockerException { messages.add(message); } }); } if (dockerApiVersionAtLeast("1.24")) { assertEquals(loadedImages.size(), 2); assertTrue(loadedImages.contains(image1)); assertTrue(loadedImages.contains(image2)); } if (dockerApiVersionAtLeast("1.23")) { assertThat(messages, not(empty())); for (final ProgressMessage message : messages) { assertTrue(message.error() != null || message.id() != null || message.progress() != null || message.progressDetail() != null || message.status() != null || message.stream() != null); } } try { sut.inspectImage(image1); sut.inspectImage(image2); } catch (ImageNotFoundException e) { fail("image not properly loaded in the local Docker instance"); } sut.removeImage(image1); sut.removeImage(image2); }