Search in sources :

Example 66 with DeploymentPackageBuilder

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");
}
Also used : DeploymentPackageBuilder(org.apache.felix.deploymentadmin.itest.util.DeploymentPackageBuilder) DeploymentPackage(org.osgi.service.deploymentadmin.DeploymentPackage) Test(org.junit.Test)

Example 67 with DeploymentPackageBuilder

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());
}
Also used : Bundle(org.osgi.framework.Bundle) DeploymentPackageBuilder(org.apache.felix.deploymentadmin.itest.util.DeploymentPackageBuilder) DeploymentPackage(org.osgi.service.deploymentadmin.DeploymentPackage) Test(org.junit.Test)

Aggregations

DeploymentPackageBuilder (org.apache.felix.deploymentadmin.itest.util.DeploymentPackageBuilder)67 Test (org.junit.Test)67 DeploymentPackage (org.osgi.service.deploymentadmin.DeploymentPackage)46 DeploymentException (org.osgi.service.deploymentadmin.DeploymentException)28 Bundle (org.osgi.framework.Bundle)15 JarInputStream (java.util.jar.JarInputStream)6 JarManifestManipulatingFilter (org.apache.felix.deploymentadmin.itest.util.DeploymentPackageBuilder.JarManifestManipulatingFilter)6 Manifest (java.util.jar.Manifest)5 File (java.io.File)4 Dictionary (java.util.Dictionary)4 Properties (java.util.Properties)4 CountDownLatch (java.util.concurrent.CountDownLatch)4 AtomicReference (java.util.concurrent.atomic.AtomicReference)4 ServiceRegistration (org.osgi.framework.ServiceRegistration)4 Event (org.osgi.service.event.Event)4 EventHandler (org.osgi.service.event.EventHandler)4 ByteArrayInputStream (java.io.ByteArrayInputStream)2 URL (java.net.URL)2 JarEntry (java.util.jar.JarEntry)2 SignerInfo (org.apache.felix.deploymentadmin.itest.util.CertificateUtil.SignerInfo)2