use of org.apache.felix.deploymentadmin.itest.util.DeploymentPackageBuilder in project felix by apache.
the class InstallFixPackageTest method testInstallFixPackageOutsideUpperTargetRangeFail.
/**
* Tests that it is not possible to install a fix package if it specifies a fix-version range that falls outside the installed target deployment package.
*/
@Test
public void testInstallFixPackageOutsideUpperTargetRangeFail() 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");
// should not include version 1.0.0!
dpBuilder.setFixPackage("[0.9,1.0)").add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle1"))).add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle2")).setMissing());
try {
installDeploymentPackage(dpBuilder);
fail("Succeeded into installing fix package for undefined target package?!");
} catch (DeploymentException exception) {
// Ok; expected
assertDeploymentException(CODE_MISSING_FIXPACK_TARGET, exception);
}
}
use of org.apache.felix.deploymentadmin.itest.util.DeploymentPackageBuilder in project felix by apache.
the class InstallFixPackageTest method testInstallFixPackageWithMissingTargetBundleFail.
/**
* Tests that installing a fix-package that mentions a bundle that is not in the target package fails.
*/
@Test
public void testInstallFixPackageWithMissingTargetBundleFail() throws Exception {
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
// missed valid-bundle1 as dependency...
dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle1")));
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("bundle3"))).add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle2")).setMissing());
try {
installDeploymentPackage(dpBuilder);
fail("Succeeded into installing a fix-package with a missing bundle on target?!");
} catch (DeploymentException exception) {
assertDeploymentException(CODE_MISSING_BUNDLE, exception);
}
}
use of org.apache.felix.deploymentadmin.itest.util.DeploymentPackageBuilder in project felix by apache.
the class InstallFixPackageTest method testInstallFixPackageWithMissingTargetResourceProcessorFail.
/**
* Tests that installing a fix-package that mentions a resource processor that is not in the target package fails.
*/
@Test
public void testInstallFixPackageWithMissingTargetResourceProcessorFail() throws Exception {
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle1")));
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.createResourceProcessorResource().setUrl(getTestBundleURL("rp1")).setMissing()).add(dpBuilder.createResource().setResourceProcessorPID(TEST_FAILING_BUNDLE_RP1).setUrl(getTestResource("test-config1.xml")));
try {
installDeploymentPackage(dpBuilder);
fail("Succeeded into installing a fix-package with a missing bundle on target?!");
} catch (DeploymentException exception) {
assertDeploymentException(CODE_MISSING_BUNDLE, exception);
}
}
use of org.apache.felix.deploymentadmin.itest.util.DeploymentPackageBuilder in project felix by apache.
the class InstallFixPackageTest method testUninstallBundleRemovedInFixPackageOk.
/**
* Tests that we can uninstall a fix-package.
*/
@Test
public void testUninstallBundleRemovedInFixPackageOk() throws Exception {
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle1"))).add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle2")));
DeploymentPackage dp1 = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp1);
awaitRefreshPackagesEvent();
// remove valid-bundle1 through fix package...
dpBuilder = createDeploymentPackageBuilder(dpBuilder.getSymbolicName(), "1.0.1");
dpBuilder.setFixPackage("[1.0,2.0)").add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle1")));
DeploymentPackage dp2 = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp2);
awaitRefreshPackagesEvent();
assertEquals("Expected a single deployment package?!", 1, countDeploymentPackages());
assertBundleExists(getSymbolicName("bundle1"), "1.0.0");
assertBundleNotExists(getSymbolicName("bundle2"), "1.0.0");
// Uninstall the deployment package; should yield the initial situation again...
dp2.uninstall();
awaitRefreshPackagesEvent();
assertEquals("Expected no deployment package?!", 0, countDeploymentPackages());
// None of our installed bundles should remain...
assertBundleNotExists(getSymbolicName("bundle1"), "1.0.0");
assertBundleNotExists(getSymbolicName("bundle2"), "1.0.0");
}
use of org.apache.felix.deploymentadmin.itest.util.DeploymentPackageBuilder in project felix by apache.
the class InstallFixPackageTest method testUninstallFixPackageOnlyRemovesOwnArtifactsOk.
/**
* Tests that we can uninstall a fix-package and that this will only uninstall the bundles installed by the fix-package.
*/
@Test
public void testUninstallFixPackageOnlyRemovesOwnArtifactsOk() throws Exception {
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle1")));
DeploymentPackage dp1 = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp1);
assertEquals("Expected a single deployment package?!", 1, countDeploymentPackages());
dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle2")));
DeploymentPackage dp2 = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp2);
awaitRefreshPackagesEvent();
assertEquals("Expected two deployment packages?!", 2, countDeploymentPackages());
// add bundle2 through fix package...
dpBuilder = createDeploymentPackageBuilder(dpBuilder.getSymbolicName(), "1.0.1");
dpBuilder.setFixPackage("[1.0,2.0)").add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle3"))).add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle2")).setMissing());
DeploymentPackage dp3 = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp3);
awaitRefreshPackagesEvent();
assertEquals("Expected two deployment packages?!", 2, countDeploymentPackages());
assertBundleExists(getSymbolicName("bundle1"), "1.0.0");
assertBundleExists(getSymbolicName("bundle2"), "1.0.0");
assertBundleExists(getSymbolicName("bundle3"), "1.0.0");
// Uninstall the deployment package; should yield the initial situation again...
dp3.uninstall();
awaitRefreshPackagesEvent();
assertEquals("Expected a single deployment package?!", 1, countDeploymentPackages());
// None of our installed bundles should remain...
assertBundleNotExists(getSymbolicName("bundle3"), "1.0.0");
assertBundleNotExists(getSymbolicName("bundle2"), "1.0.0");
// The bundle installed in another deployment package should still remain...
assertBundleExists(getSymbolicName("bundle1"), "1.0.0");
}
Aggregations