use of org.apache.felix.deploymentadmin.itest.util.DeploymentPackageBuilder in project felix by apache.
the class UninstallDeploymentPackageTest method testUninstallBundleWithOtherArtifactsOk.
/**
* Tests that uninstalling a DP with a bundle along with other (non-bundle) artifacts succeeds.
*/
@Test
public void testUninstallBundleWithOtherArtifactsOk() throws Exception {
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
dpBuilder.add(dpBuilder.createResourceProcessorResource().setUrl(getTestBundleURL("rp1"))).add(dpBuilder.createResource().setResourceProcessorPID(TEST_FAILING_BUNDLE_RP1).setUrl(getTestResource("test-config1.xml"))).add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle3")));
DeploymentPackage dp = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp);
awaitRefreshPackagesEvent();
// Though the commit failed; the package should be installed...
assertBundleExists(getSymbolicName("rp1"), "1.0.0");
assertBundleExists(getSymbolicName("bundle3"), "1.0.0");
assertEquals("Expected a single deployment package?!", 1, countDeploymentPackages());
// Should succeed...
dp.uninstall();
assertEquals("Expected no deployment package?!", 0, countDeploymentPackages());
assertBundleNotExists(getSymbolicName("rp1"), "1.0.0");
assertBundleNotExists(getSymbolicName("bundle3"), "1.0.0");
}
use of org.apache.felix.deploymentadmin.itest.util.DeploymentPackageBuilder in project felix by apache.
the class UninstallDeploymentPackageTest method testUninstallDeploymentPackageWithExceptionThrownInStopCauseNoRollbackOk.
/**
* Tests that if an exception is thrown during the uninstall of a bundle, the installation/update continues and succeeds.
*/
@Test
public void testUninstallDeploymentPackageWithExceptionThrownInStopCauseNoRollbackOk() throws Exception {
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle1"))).add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle3")));
DeploymentPackage dp = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp);
awaitRefreshPackagesEvent();
assertBundleExists(getSymbolicName("bundle3"), "1.0.0");
System.setProperty("bundle3", "stop");
// should succeed.
dp.uninstall();
// FELIX-4484: only after a successful uninstall, the DP should be marked as stale...
assertTrue(dp.isStale());
awaitRefreshPackagesEvent();
assertEquals("Expected no deployment package?!", 0, countDeploymentPackages());
assertTrue("Expected no bundles to remain?!", getCurrentBundles().isEmpty());
}
use of org.apache.felix.deploymentadmin.itest.util.DeploymentPackageBuilder in project felix by apache.
the class UninstallDeploymentPackageTest method testUninstallDeploymentPackageWithExceptionThrowingInDropAllResourcesCausesRollbackOk.
/**
* Tests that if an exception is thrown during the dropping of a resource, the installation is rolled back.
*/
@Test
public void testUninstallDeploymentPackageWithExceptionThrowingInDropAllResourcesCausesRollbackOk() 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);
assertEquals("Expected no deployment package?!", 1, countDeploymentPackages());
System.setProperty("rp1", "dropAllResources");
try {
dp.uninstall();
fail("Expected uninstall to fail and rollback!");
} catch (DeploymentException exception) {
// Ok; expected
assertDeploymentException(CODE_OTHER_ERROR, exception);
}
// FELIX-4484: only after a successful uninstall, the DP should be marked as stale...
assertFalse(dp.isStale());
assertTrue("Two bundles should be started!", getCurrentBundles().size() == 2);
assertEquals("Expected no deployment package?!", 1, countDeploymentPackages());
}
use of org.apache.felix.deploymentadmin.itest.util.DeploymentPackageBuilder in project felix by apache.
the class UninstallDeploymentPackageTest method testUninstallDeploymentPackageWithMissingResourceProcessorCausesRollback.
/**
* Tests that if a resource processor is missing (uninstalled) during the uninstallation of a deployment package, this is regarded an error and a rollback is performed.
*/
@Test
public void testUninstallDeploymentPackageWithMissingResourceProcessorCausesRollback() 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());
try {
dp.uninstall();
fail("Expected uninstall to fail and rollback!");
} catch (DeploymentException exception) {
// Ok; expected
assertDeploymentException(CODE_PROCESSOR_NOT_FOUND, exception);
}
assertTrue("One bundle should be started!", getCurrentBundles().size() == 1);
assertEquals("Expected one deployment package?!", 1, countDeploymentPackages());
}
use of org.apache.felix.deploymentadmin.itest.util.DeploymentPackageBuilder in project felix by apache.
the class UninstallDeploymentPackageTest method testUninstallDeploymentPackageWithExceptionThrowingInCommitCausesNoRollbackOk.
/**
* Tests that if an exception is thrown during the commit-phase, the installation is continued normally.
*/
@Test
public void testUninstallDeploymentPackageWithExceptionThrowingInCommitCausesNoRollbackOk() 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);
assertEquals("Expected no deployment package?!", 1, countDeploymentPackages());
System.setProperty("rp1", "commit");
dp.uninstall();
assertTrue("No bundles should be started! " + getCurrentBundles(), getCurrentBundles().isEmpty());
assertEquals("Expected no deployment package?!", 0, countDeploymentPackages());
}
Aggregations