Search in sources :

Example 6 with JarManifestManipulatingFilter

use of org.apache.felix.deploymentadmin.itest.util.DeploymentPackageBuilder.JarManifestManipulatingFilter in project felix by apache.

the class ResourceSharingTest method testForeignBundleCanCoexistWithPackagedBundleIfVersionsDiffer.

@Test
public void testForeignBundleCanCoexistWithPackagedBundleIfVersionsDiffer() throws Exception {
    // Manually install a bundle...
    Bundle result = m_context.installBundle(getTestBundleURL("bundle1").toExternalForm());
    assertNotNull(result);
    long bundleId = result.getBundleId();
    assertBundleExists(getSymbolicName("bundle1"), "1.0.0");
    assertTrue(isBundleInstalled(result));
    DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
    dpBuilder.add(dpBuilder.createBundleResource().setVersion("1.1.0").setUrl(getTestBundleURL("bundle1")).setFilter(new JarManifestManipulatingFilter("Bundle-Version", "1.1.0"))).add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle2")));
    // should succeed: valid-bundle1 is installed, but has a different version than the one in our DP...
    DeploymentPackage dp = installDeploymentPackage(dpBuilder);
    awaitRefreshPackagesEvent();
    assertBundleExists(getSymbolicName("bundle1"), "1.0.0");
    assertBundleExists(getSymbolicName("bundle1"), "1.1.0");
    // The manually installed bundle should still be in the installed or resolved state...
    assertTrue(isBundleInstalled(m_context.getBundle(bundleId)) || isBundleResolved(m_context.getBundle(bundleId)));
    assertTrue(isBundleActive(dp.getBundle(getSymbolicName("bundle1"))));
}
Also used : Bundle(org.osgi.framework.Bundle) DeploymentPackageBuilder(org.apache.felix.deploymentadmin.itest.util.DeploymentPackageBuilder) DeploymentPackage(org.osgi.service.deploymentadmin.DeploymentPackage) JarManifestManipulatingFilter(org.apache.felix.deploymentadmin.itest.util.DeploymentPackageBuilder.JarManifestManipulatingFilter) Test(org.junit.Test)

Aggregations

DeploymentPackageBuilder (org.apache.felix.deploymentadmin.itest.util.DeploymentPackageBuilder)6 JarManifestManipulatingFilter (org.apache.felix.deploymentadmin.itest.util.DeploymentPackageBuilder.JarManifestManipulatingFilter)6 Test (org.junit.Test)6 Bundle (org.osgi.framework.Bundle)3 DeploymentException (org.osgi.service.deploymentadmin.DeploymentException)3 DeploymentPackage (org.osgi.service.deploymentadmin.DeploymentPackage)3 File (java.io.File)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 Attributes (java.util.jar.Attributes)1 JarEntry (java.util.jar.JarEntry)1 JarInputStream (java.util.jar.JarInputStream)1 Manifest (java.util.jar.Manifest)1