use of org.apache.felix.deploymentadmin.itest.util.DeploymentPackageBuilder in project felix by apache.
the class InstallDeploymentPackageTest method testInstallBundleWithFragmentOk.
/**
* Tests that installing a bundle along with a fragment bundle succeeds (DA should not try to start the fragment,
* see FELIX-4167).
*/
@Test
public void testInstallBundleWithFragmentOk() 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"))));
assertEquals("Expected a single deployment package?!", 1, countDeploymentPackages());
}
use of org.apache.felix.deploymentadmin.itest.util.DeploymentPackageBuilder in project felix by apache.
the class InstallDeploymentPackageTest method testInstallTwoValidBundlesOk.
/**
* Tests that installing two bundles works as expected.
*/
@Test
public void testInstallTwoValidBundlesOk() throws Exception {
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle1"))).add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle2")));
DeploymentPackage dp = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp);
awaitRefreshPackagesEvent();
assertNotNull("Failed to obtain test service?!", awaitService(TEST_SERVICE_NAME));
assertBundleExists(getSymbolicName("bundle1"), "1.0.0");
assertBundleExists(getSymbolicName("bundle2"), "1.0.0");
assertTrue(isBundleActive(dp.getBundle(getSymbolicName("bundle1"))));
assertTrue(isBundleActive(dp.getBundle(getSymbolicName("bundle2"))));
}
use of org.apache.felix.deploymentadmin.itest.util.DeploymentPackageBuilder in project felix by apache.
the class InstallDeploymentPackageTest method testUninstallBundleWithExceptionThrownInStopCauseNoRollbackOk.
/**
* Tests that if an exception is thrown during the uninstall of a bundle, the installation/update continues and
* succeeds.
*/
@Test
public void testUninstallBundleWithExceptionThrownInStopCauseNoRollbackOk() 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");
dpBuilder = dpBuilder.create("1.0.1");
dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle1"))).add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle2")));
dp = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp);
assertBundleExists(getSymbolicName("bundle1"), "1.0.0");
assertBundleExists(getSymbolicName("bundle2"), "1.0.0");
assertBundleNotExists(getSymbolicName("bundle3"), "1.0.0");
assertTrue(isBundleActive(dp.getBundle(getSymbolicName("bundle1"))));
assertTrue(isBundleActive(dp.getBundle(getSymbolicName("bundle2"))));
assertEquals("Expected a single deployment package?!", 1, countDeploymentPackages());
}
use of org.apache.felix.deploymentadmin.itest.util.DeploymentPackageBuilder in project felix by apache.
the class InstallDeploymentPackageTest method testInstallBundleWithMissingDependencyOk.
/**
* Tests that installing a bundle whose dependencies cannot be met, is installed, but not started.
*/
@Test
public void testInstallBundleWithMissingDependencyOk() throws Exception {
DeploymentPackageBuilder dpBuilder = createNewDeploymentPackageBuilder("1.0.0");
dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle2")));
DeploymentPackage dp = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp);
awaitRefreshPackagesEvent();
Bundle bundle = dp.getBundle(getSymbolicName("bundle2"));
assertNotNull("Failed to obtain bundle from deployment package?!", bundle);
assertBundleExists(getSymbolicName("bundle2"), "1.0.0");
assertTrue(isBundleInstalled(dp.getBundle(getSymbolicName("bundle2"))));
}
use of org.apache.felix.deploymentadmin.itest.util.DeploymentPackageBuilder in project felix by apache.
the class InstallDeploymentPackageTest method testUpdateBundleWithExceptionThrownInStopCauseNoRollbackOk.
/**
* Tests that if an exception is thrown during the stop of a bundle, the installation/update continues and succeeds.
*/
@Test
public void testUpdateBundleWithExceptionThrownInStopCauseNoRollbackOk() 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");
dpBuilder = createDeploymentPackageBuilder(dpBuilder.getSymbolicName(), "1.0.1");
dpBuilder.add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle1"))).add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle2"))).add(dpBuilder.createBundleResource().setUrl(getTestBundleURL("bundle3")));
dp = installDeploymentPackage(dpBuilder);
assertNotNull("No deployment package returned?!", dp);
assertBundleExists(getSymbolicName("bundle1"), "1.0.0");
assertBundleExists(getSymbolicName("bundle2"), "1.0.0");
assertBundleExists(getSymbolicName("bundle3"), "1.0.0");
assertTrue(isBundleActive(dp.getBundle(getSymbolicName("bundle1"))));
assertTrue(isBundleActive(dp.getBundle(getSymbolicName("bundle2"))));
assertTrue(isBundleActive(dp.getBundle(getSymbolicName("bundle3"))));
assertEquals("Expected a single deployment package?!", 1, countDeploymentPackages());
}
Aggregations