use of org.apache.felix.deploymentadmin.itest.util.DeploymentPackageBuilder in project felix by apache.
the class InstallDeploymentPackageTest method testInstallInvalidDeploymentPackageFail.
/**
* FELIX-4409/4410/4463 - test the installation of an invalid deployment package.
*/
@Test
public void testInstallInvalidDeploymentPackageFail() throws Exception {
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
// incluse two different versions of the same bundle (with the same BSN), this is *not* allowed per the DA
// spec...
dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundleapi1", "bundleapi1", "1.0.0"))).add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundleapi2", "bundleapi2", "2.0.0")));
try {
installDeploymentPackage(dpBuilder);
fail("DeploymentException expected!");
} catch (DeploymentException e) {
// Ok; expected...
}
// Verify that none of the bundles are installed...
assertBundleNotExists("testbundles.bundleapi", "1.0.0");
assertBundleNotExists("testbundles.bundleapi", "2.0.0");
}
use of org.apache.felix.deploymentadmin.itest.util.DeploymentPackageBuilder in project felix by apache.
the class InstallDeploymentPackageTest method testInstallBundlesWithPathsOk.
/**
* FELIX-1835 - test whether we can install bundles with a non-root path inside the DP.
*/
@Test
public void testInstallBundlesWithPathsOk() throws Exception {
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
// incluse two different versions of the same bundle (with the same BSN), this is *not* allowed per the DA
// spec...
dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundleapi1", "bundleapi1", "1.0.0")).setFilename("bundles/bundleapi1.jar")).add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundleimpl1", "bundleimpl1", "1.0.0")).setFilename("bundles/bundleimpl1.jar"));
DeploymentPackage dp = installDeploymentPackage(dpBuilder);
assertNotNull(dp);
BundleInfo[] bundleInfos = dp.getBundleInfos();
assertEquals(2, bundleInfos.length);
// Verify that none of the bundles are installed...
assertBundleExists("testbundles.bundleapi", "1.0.0");
assertBundleExists("testbundles.bundleimpl", "1.0.0");
}
use of org.apache.felix.deploymentadmin.itest.util.DeploymentPackageBuilder in project felix by apache.
the class InstallDeploymentPackageTest method testInstallDeploymentPackageWithLocalizationAndSignatureFilesOk.
/**
* FELIX-518 - Test that DP with localization and signature files are properly deployed.
*/
@Test
public void testInstallDeploymentPackageWithLocalizationAndSignatureFilesOk() throws Exception {
URL dpProps = getClass().getResource("/dp.properties");
assertNotNull(dpProps);
SignerInfo signer = createSelfSignedCert("CN=dpTest", KeyType.EC);
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
dpBuilder.signOutput(signer.getPrivate(), signer.getCert()).add(dpBuilder.createLocalizationResource().setUrl(dpProps).setResourceProcessorPID(TEST_FAILING_BUNDLE_RP1).setFilename("dp.properties")).add(dpBuilder.createResourceProcessorResource().setUrl(getTestBundleURL("rp1"))).add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle1"))).add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle2")));
// should succeed.
installDeploymentPackage(dpBuilder);
assertBundleExists("testbundles.bundle1", "1.0.0");
assertBundleExists("testbundles.bundle2", "1.0.0");
assertBundleExists("testbundles.rp1", "1.0.0");
}
use of org.apache.felix.deploymentadmin.itest.util.DeploymentPackageBuilder in project felix by apache.
the class InstallDeploymentPackageTest method testInstallBundleWithExceptionThrownInStartCausesNoRollbackOk.
/**
* Tests that if an exception is thrown in the start method of a bundle, the installation is not rolled back.
*/
@Test
public void testInstallBundleWithExceptionThrownInStartCausesNoRollbackOk() throws Exception {
System.setProperty("bundle3", "start");
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("bundle1"), "1.0.0");
assertBundleExists(getSymbolicName("bundle3"), "1.0.0");
assertTrue(isBundleActive(dp.getBundle(getSymbolicName("bundle1"))));
// the bundle threw an exception during start, so it is not active...
assertFalse(isBundleActive(dp.getBundle(getSymbolicName("bundle3"))));
assertEquals("Expected a single deployment package?!", 1, countDeploymentPackages());
}
use of org.apache.felix.deploymentadmin.itest.util.DeploymentPackageBuilder in project felix by apache.
the class InstallFixPackageTest method testInstallFixPackageOutsideLowerTargetRangeFail.
/**
* 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 testInstallFixPackageOutsideLowerTargetRangeFail() 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("(1.0,2.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);
}
}
Aggregations