use of org.apache.felix.deploymentadmin.itest.util.DeploymentPackageBuilder in project felix by apache.
the class UninstallDeploymentPackageTest method testUninstallBundleWithFragmentOk.
/**
* Tests that uninstalling a DP containing a bundle along with a fragment bundle succeeds (DA should not try to stop the fragment, see FELIX-4167).
*/
@Test
public void testUninstallBundleWithFragmentOk() throws Exception {
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle1"))).add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("fragment1")));
DeploymentPackage dp = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp);
awaitRefreshPackagesEvent();
assertBundleExists(getSymbolicName("bundle1"), "1.0.0");
assertBundleExists(getSymbolicName("fragment1"), "1.0.0");
assertTrue(isBundleActive(dp.getBundle(getSymbolicName("bundle1"))));
assertFalse(isBundleActive(dp.getBundle(getSymbolicName("fragment1"))));
// Should succeed...
dp.uninstall();
assertEquals("Expected no deployment package?!", 0, countDeploymentPackages());
// Both bundles should be uninstalled...
assertBundleNotExists(getSymbolicName("bundle1"), "1.0.0");
assertBundleNotExists(getSymbolicName("fragment1"), "1.0.0");
}
use of org.apache.felix.deploymentadmin.itest.util.DeploymentPackageBuilder in project felix by apache.
the class UninstallDeploymentPackageTest method testForcedUninstallDeploymentPackageWithMissingResourceProcessorSucceeds.
/**
* Tests that if a resource processor is missing (uninstalled) during the forced uninstallation of a deployment package this will ignored and the uninstall completes.
*/
@Test
public void testForcedUninstallDeploymentPackageWithMissingResourceProcessorSucceeds() throws Exception {
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle1"))).add(dpBuilder.createResourceProcessorResource().setUrl(getTestBundleURL("rp1"))).add(dpBuilder.createResource().setResourceProcessorPID(TEST_FAILING_BUNDLE_RP1).setUrl(getTestResource("test-config1.xml")));
DeploymentPackage dp = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp);
awaitRefreshPackagesEvent();
assertTrue("Two bundles should be started!", getCurrentBundles().size() == 2);
Bundle rpBundle = dp.getBundle(getSymbolicName("rp1"));
rpBundle.uninstall();
assertTrue("One bundle should be started!", getCurrentBundles().size() == 1);
assertEquals("Expected no deployment package?!", 1, countDeploymentPackages());
assertTrue(dp.uninstallForced());
// FELIX-4484: after a forced uninstall, the DP should be marked as stale...
assertTrue(dp.isStale());
assertTrue("No bundle should be started!", getCurrentBundles().isEmpty());
assertEquals("Expected no deployment package?!", 0, countDeploymentPackages());
}
Aggregations