BundleMaker { public File copyAdding(File f, Map<ZipEntry, ? extends InputStream> entries) { return copyAdding(f, entries, Predicates.<String>alwaysTrue(), false); } BundleMaker(@Nonnull ResourceUtils resources);  BundleMaker(@Nonnull Framework f, @Nonnull ResourceUtils resources);  BundleMaker(@Nonnull ManagementContext mgmt); void setDefaultClassForLoading(Class<?> optionalDefaultClassForLoading); File createJarFromClasspathDir(String path); boolean hasOsgiManifest(File f); Manifest getManifest(File f); File copyAddingManifest(File f, Map<String,String> attrs); File copyAddingManifest(File f, Manifest mf); File copyAdding(File f, Map<ZipEntry, ? extends InputStream> entries); File copyAddingAtEnd(File f, Map<ZipEntry, ? extends InputStream> entries); File copyRemoving(File f, final Set<String> itemsToRemove); File copyRemoving(File f, Predicate<? super String> filter); @Deprecated Bundle installBundle(File f, boolean start); File createTempBundle(String nameHint, Manifest mf, Map<ZipEntry, InputStream> files); File createTempBundle(String nameHint, Map<String, String> mf, Map<ZipEntry, InputStream> files); File createTempZip(String nameHint, Map<ZipEntry, InputStream> files);  }
@Test public void testCopyAdding() throws Exception { generatedJar = bundleMaker.copyAdding(emptyJar, ImmutableMap.of(new ZipEntry("myfile.txt"), new ByteArrayInputStream("mytext".getBytes()))); assertJarContents(generatedJar, ImmutableMap.of("myfile.txt", "mytext"), false); }
@Test public void testCopyAddingToNonEmpty() throws Exception { tempJar = bundleMaker.copyAdding(emptyJar, ImmutableMap.of(new ZipEntry("preExisting.txt"), new ByteArrayInputStream("myPreExisting".getBytes()))); generatedJar = bundleMaker.copyAdding(tempJar, ImmutableMap.of(new ZipEntry("myfile.txt"), new ByteArrayInputStream("mytext".getBytes()))); assertJarContents(generatedJar, ImmutableMap.of("preExisting.txt", "myPreExisting", "myfile.txt", "mytext"), false); }
@Test public void testCopyAddingOverwritesEntry() throws Exception { tempJar = bundleMaker.copyAdding(emptyJar, ImmutableMap.of(new ZipEntry("myfile.txt"), new ByteArrayInputStream("myPreExisting".getBytes()))); generatedJar = bundleMaker.copyAdding(tempJar, ImmutableMap.of(new ZipEntry("myfile.txt"), new ByteArrayInputStream("mytext".getBytes()))); assertJarContents(generatedJar, ImmutableMap.of("myfile.txt", "mytext"), false); }