@Test() public void testSingleBundleDeploymentPackage() throws Exception { File tempFile = File.createTempFile("output-", ".jar"); FileOutputStream output = new FileOutputStream(tempFile); String name = "test"; String version = "1.0.0"; String bundleSymbolicName = "bundle"; String bundleVersion = "1.0.0"; File tempBundleFile = File.createTempFile(bundleSymbolicName + "-" + bundleVersion + "-", ".jar"); DeploymentPackageBuilder.createDeploymentPackage(name, version) .addBundle(createBundle(bundleSymbolicName, bundleVersion, tempBundleFile)) .generate(output); // the deployment package should have a name and a version, and a single entry (our bundle) Manifest m = getManifest(tempFile); Assert.assertEquals(name, m.getMainAttributes().getValue("DeploymentPackage-SymbolicName")); Assert.assertEquals(version, m.getMainAttributes().getValue("DeploymentPackage-Version")); Assert.assertEquals(1, m.getEntries().size()); contains(m.getEntries().values(), "Bundle-SymbolicName", bundleSymbolicName, "Bundle-Version", bundleVersion); }
@Test() public void testTwoBundleDeploymentPackage() throws Exception { File tempFile = File.createTempFile("output-", ".jar"); FileOutputStream output = new FileOutputStream(tempFile); String name = "test"; String version = "1.0.0"; String bundleSymbolicName = "bundle"; String bundleVersion = "1.0.0"; File tempBundleFile = File.createTempFile(bundleSymbolicName + "-" + bundleVersion + "-", ".jar"); String bundleSymbolicName2 = "bundle-two"; String bundleVersion2 = "1.2.0"; File tempBundleFile2 = File.createTempFile(bundleSymbolicName2 + "-" + bundleVersion2 + "-", ".jar"); DeploymentPackageBuilder.createDeploymentPackage(name, version) .addBundle(createBundle(bundleSymbolicName, bundleVersion, tempBundleFile)) .addBundle(createBundle(bundleSymbolicName2, bundleVersion2, tempBundleFile2)) .generate(output); // the deployment package should have a name and a version, and a single entry (our bundle) Manifest m = getManifest(tempFile); Assert.assertEquals(name, m.getMainAttributes().getValue("DeploymentPackage-SymbolicName")); Assert.assertEquals(version, m.getMainAttributes().getValue("DeploymentPackage-Version")); Assert.assertEquals(2, m.getEntries().size()); contains(m.getEntries().values(), "Bundle-SymbolicName", bundleSymbolicName, "Bundle-Version", bundleVersion); contains(m.getEntries().values(), "Bundle-SymbolicName", bundleSymbolicName2, "Bundle-Version", bundleVersion2); }