use of org.apache.felix.deploymentadmin.itest.util.DeploymentPackageBuilder in project felix by apache.
the class InstallFixPackageTest method testUpdateWithDuplicateBundleFail.
/**
* Tests that if we try to update with a DP containing a duplicate bundle (of which one is already installed in
* an earlier DP) that this will fail the installation. See FELIX-4463.
*/
@Test
public void testUpdateWithDuplicateBundleFail() throws Exception {
DeploymentPackageBuilder dpBuilder = createDeploymentPackageBuilder("c", "1.0.0");
dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundleimpl1", "bundleimpl1", "1.0.0")));
dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundleapi1", "bundleapi1", "1.0.0")));
// Should succeed, as the DP is correct...
DeploymentPackage dp1 = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp1);
// then, install a fix package with implementation and api bundles in version 2.0.0, but *also* containing the original implementation
// bundle, which is incorrect (no bundles with the same BSN may exist in a DP)...
dpBuilder = createDeploymentPackageBuilder("c", "2.0.0").setFixPackage("[1.0.0,2.0.0]");
dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundleapi1", "bundleapi1", "1.0.0")));
dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundleimpl2", "bundleimpl2", "2.0.0")));
dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundleimpl1", "bundleimpl1", "1.0.0")));
try {
installDeploymentPackage(dpBuilder);
fail("DeploymentException expected!");
} catch (DeploymentException e) {
// Ok; expected...
assertEquals(DeploymentException.CODE_OTHER_ERROR, e.getCode());
}
awaitRefreshPackagesEvent();
// Nothing should be updated...
assertBundleExists(getSymbolicName("bundleimpl"), "1.0.0");
assertBundleExists(getSymbolicName("bundleapi"), "1.0.0");
}
use of org.apache.felix.deploymentadmin.itest.util.DeploymentPackageBuilder in project felix by apache.
the class InstallFixPackageTest method testInstallAndUpdateImplementationBundleWithSeparateAPIBundle_FELIX4184.
@Test
public void testInstallAndUpdateImplementationBundleWithSeparateAPIBundle_FELIX4184() throws Exception {
String value = System.getProperty("org.apache.felix.deploymentadmin.stopunaffectedbundle");
System.setProperty("org.apache.felix.deploymentadmin.stopunaffectedbundle", "false");
// first, install a deployment package with implementation and api bundles in version 1.0.0
DeploymentPackageBuilder dpBuilder = createDeploymentPackageBuilder("a", "1.0.0");
dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundleimpl1", "bundleimpl1", "1.0.0")));
dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundleapi1", "bundleapi1", "1.0.0")));
DeploymentPackage dp1 = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp1);
assertEquals("Expected a single deployment package?!", 1, countDeploymentPackages());
// then, install a fix package with implementation and api bundles in version 2.0.0
dpBuilder = createDeploymentPackageBuilder("a", "2.0.0").setFixPackage("[1.0.0,2.0.0]");
dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundleimpl2", "bundleimpl2", "2.0.0")));
dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundleapi2", "bundleapi2", "2.0.0")));
DeploymentPackage dp2 = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp2);
awaitRefreshPackagesEvent();
assertBundleExists(getSymbolicName("bundleimpl"), "2.0.0");
assertBundleExists(getSymbolicName("bundleapi"), "2.0.0");
assertBundleNotExists(getSymbolicName("bundleimpl"), "1.0.0");
assertBundleNotExists(getSymbolicName("bundleapi"), "1.0.0");
if (value != null) {
System.setProperty("org.apache.felix.deploymentadmin.stopunaffectedbundle", value);
}
}
use of org.apache.felix.deploymentadmin.itest.util.DeploymentPackageBuilder in project felix by apache.
the class InstallFixPackageTest method testInstallFixPackageReplacesOriginalTargetPackageOk.
/**
* Tests that installing a fix-package causes the original target package to be replaced.
*/
@Test
public void testInstallFixPackageReplacesOriginalTargetPackageOk() throws Exception {
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle2")));
DeploymentPackage dp1 = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp1);
assertEquals("Expected only a single deployment package?!", 1, countDeploymentPackages());
awaitRefreshPackagesEvent();
dpBuilder = createDeploymentPackageBuilder(dpBuilder.getSymbolicName(), "1.0.1");
dpBuilder.setFixPackage("[1.0,2.0)").add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle1"))).add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle2")).setMissing());
DeploymentPackage dp2 = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp2);
awaitRefreshPackagesEvent();
assertEquals("Expected only a single deployment package?!", 1, countDeploymentPackages());
}
use of org.apache.felix.deploymentadmin.itest.util.DeploymentPackageBuilder in project felix by apache.
the class InstallFixPackageTest method testInstallBundleWithDependencyInFixPackageUpdateOk.
/**
* Tests that we can install a new bundle through a fix-package.
*/
@Test
public void testInstallBundleWithDependencyInFixPackageUpdateOk() throws Exception {
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle2")));
DeploymentPackage dp1 = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp1);
awaitRefreshPackagesEvent();
Bundle bundle = dp1.getBundle(getSymbolicName("bundle2"));
assertNotNull("Failed to obtain bundle from deployment package?!", bundle);
assertEquals(Bundle.INSTALLED, bundle.getState());
dpBuilder = createDeploymentPackageBuilder(dpBuilder.getSymbolicName(), "1.0.1");
dpBuilder.setFixPackage("[1.0,2.0)").add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle1"))).add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle2")).setMissing());
DeploymentPackage dp2 = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp2);
awaitRefreshPackagesEvent();
bundle = dp2.getBundle(getSymbolicName("bundle2"));
assertNotNull("Failed to obtain bundle from bundle context?!", bundle);
assertBundleExists(getSymbolicName("bundle1"), "1.0.0");
assertBundleExists(getSymbolicName("bundle2"), "1.0.0");
assertTrue(isBundleActive(bundle));
}
use of org.apache.felix.deploymentadmin.itest.util.DeploymentPackageBuilder 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"))));
}
Aggregations