Search in sources :

Example 11 with DeploymentPackageBuilder

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

Example 12 with DeploymentPackageBuilder

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

Example 13 with DeploymentPackageBuilder

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

Example 14 with DeploymentPackageBuilder

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"))));
}
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)

Example 15 with DeploymentPackageBuilder

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());
}
Also used : 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