### Question:
ICOBundler implements ImageBundler { @Override public File bundle(SelfExtractingExecutableConfiguration definition, Path tempFile, Log log) { val excfg = definition.getExecutableFileConfiguration(); val iconDefinition = excfg.getIconDefinition(); val sourceFile = iconDefinition.getSource(); if (sourceFile == null) { log.warn("Error: image source file must not be null"); throw new IllegalArgumentException("image source file must not be null"); } log.info( "Attempting to generate ICO file from '%s' in sizes [\n%s\n]...", sourceFile, getSizes(iconDefinition)); IOUtilities.checkFile(sourceFile.toPath(), log); val image = readImage(sourceFile, log); val icons = ICO.resize(image, getSizeValues(iconDefinition), log); val actualTempFile = tempFile.resolve(UUID.randomUUID().toString() + ".ico").toFile(); try { if (!actualTempFile.exists()) { val parent = actualTempFile.getParentFile(); if (!(parent.exists() || parent.mkdirs())) { throw new IllegalArgumentException( format( "Error: failed to create '%s'--do you have appropriate permissions in its parent directory ('%s')?", parent, parent.getParent())); } if (!actualTempFile.createNewFile()) { throw new IllegalArgumentException( format( "Error: failed to create '%s'--do you have appropriate permissions in its parent directory ('%s')?", actualTempFile, actualTempFile.getParent())); } } } catch (IOException e) { log.warn("Failed to create file '%s', reason: '%s'", actualTempFile, e.getMessage()); throw new IllegalArgumentException(e); } try { log.info("Writing intermediate file to '%s'...", actualTempFile); ICOEncoder.write(icons, actualTempFile); } catch (IOException ex) { log.warn( "Failed to save intermediate file '%s', reason: %s", actualTempFile, ex.getMessage()); } return actualTempFile.getAbsoluteFile(); }  @Override boolean supports(CompositeIconDefinition.Format format); @Override File bundle(SelfExtractingExecutableConfiguration definition, Path tempFile, Log log);  }### Answer:
@Test void ensureIconBundlerWorks() throws IOException { val serviceLoader = ImageBundler.resolve( CompositeIconDefinition.Format.ICO, ClassLoader.getSystemClassLoader()); val cfg = mock(SelfExtractingExecutableConfiguration.class); val excfg = mock(ExecutableFileConfiguration.class); val iconDef = mock(CompositeIconDefinition.class); given(cfg.getExecutableFileConfiguration()).willReturn(excfg); given(iconDef.getSource()) .willReturn(new File(ClassLoader.getSystemResource("icons/installer256px.png").getFile())); given(excfg.getIconDefinition()).willReturn(iconDef); val testDefinition = mock(IconDefinition.class); given(testDefinition.getSize()).willReturn(IconDefinition.Size.Size48px); List<IconDefinition> iconDefinitions = List.of(testDefinition); doReturn(iconDefinitions).when(iconDef).getIconDefinitions(); val result = serviceLoader.bundle( cfg, new File(Tests.buildDirectory(), UUID.randomUUID().toString()).toPath(), sysout); assertTrue(result.exists()); val icoFile = ICODecoder.read(result); assertEquals(1, icoFile.size()); }