.add(dpBuilder.createBundleResource()
.setVersion("1.1.0")
.setFilter(new JarManifestManipulatingFilter("Bundle-Version", "1.1.0", "Foo", "bar"))
.setUrl(getTestBundle("bundle1")));
JarInputStream jis = new JarInputStream(dpBuilder.generate());
assertNotNull(jis);
Manifest manifest = jis.getManifest();
assertManifestHeader(manifest, "DeploymentPackage-SymbolicName", "dp-test");
assertManifestHeader(manifest, "DeploymentPackage-Version", "1.0.0");
String filename = getBundleName("bundle1");
assertManifestEntry(manifest, filename, "Name", filename);
assertManifestEntry(manifest, filename, "Bundle-SymbolicName", "testbundles.bundle1");
assertManifestEntry(manifest, filename, "Bundle-Version", "1.1.0");
filename = getBundleName("bundle2");
assertManifestEntry(manifest, filename, "Name", filename);
assertManifestEntry(manifest, filename, "Bundle-SymbolicName", "testbundles.bundle2");
assertManifestEntry(manifest, filename, "Bundle-Version", "1.0.0");
try {
byte[] buf = new byte[32 * 1024];
JarEntry entry;
while ((entry = jis.getNextJarEntry()) != null) {
if (entry.getName().endsWith("valid-bundle1.jar")) {
int read = jis.read(buf);
JarInputStream jis2 = new JarInputStream(new ByteArrayInputStream(Arrays.copyOf(buf, read)));
Manifest manifest2 = jis2.getManifest();
Attributes mainAttributes = manifest2.getMainAttributes();
assertEquals("1.1.0", mainAttributes.getValue("Bundle-Version"));
assertEquals("bar", mainAttributes.getValue("Foo"));
jis2.close();
}
jis.closeEntry();
}
}
finally {