Search in sources :

Example 66 with Subsystem

use of org.osgi.service.subsystem.Subsystem in project aries by apache.

the class NoBSNTest method testApplication1.

/*
	 * Subsystem application1 has content bundle tb1.jar.
	 * Bundle tb1.jar has an import package dependency on org.apache.aries.subsystem.itests.tb3.
	 */
@Test
public void testApplication1() throws Exception {
    Subsystem nobsn = installSubsystemFromFile("nobsn.esa");
    try {
        assertSymbolicName("org.apache.aries.subsystem.nobsn", nobsn);
        assertVersion("0.0.0", nobsn);
        assertType(SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION, nobsn);
        assertChildren(0, nobsn);
        assertConstituents(1, nobsn);
        startSubsystem(nobsn);
    } finally {
        stopSubsystemSilently(nobsn);
        uninstallSubsystemSilently(nobsn);
    }
}
Also used : Subsystem(org.osgi.service.subsystem.Subsystem) Test(org.junit.Test)

Example 67 with Subsystem

use of org.osgi.service.subsystem.Subsystem in project aries by apache.

the class RegionNameTest method testApplicationRegionName.

@Test
public void testApplicationRegionName() throws Exception {
    Subsystem applicationA = installSubsystemFromFile(APPLICATION_A);
    try {
        testRegionName(applicationA);
        Subsystem featureA = getChild(applicationA, FEATURE_A, null, SubsystemConstants.SUBSYSTEM_TYPE_FEATURE);
        testRegionName(featureA);
    } finally {
        uninstallSubsystemSilently(applicationA);
    }
}
Also used : Subsystem(org.osgi.service.subsystem.Subsystem) Test(org.junit.Test)

Example 68 with Subsystem

use of org.osgi.service.subsystem.Subsystem in project aries by apache.

the class RootSubsystemTest method testServiceEvents.

@Test
public void testServiceEvents() throws Exception {
    Subsystem root = getRootSubsystem();
    Bundle core = getSubsystemCoreBundle();
    // TODO Temporary(?) workaround to allow time for any tardy service
    // events to arrive so they can be cleared. So far, this sleep has only
    // been necessary on the IBM 6.0 64-bit JDK.
    Thread.sleep(1000);
    subsystemEvents.clear();
    core.stop();
    assertServiceEventsStop(root);
    core.uninstall();
    core = bundleContext.installBundle(normalizeBundleLocation(core));
    core.start();
    // There should be install events since the persisted root subsystem was
    // deleted when the subsystems implementation bundle was uninstalled.
    assertServiceEventsInstall(root);
    assertServiceEventsResolve(root);
    assertServiceEventsStart(root);
    core.stop();
    assertServiceEventsStop(root);
    core.start();
    // There should be no install events or RESOLVING event since there
    // should be a persisted root subsystem already in the RESOLVED state.
    assertServiceEventResolved(root, ServiceEvent.REGISTERED);
    assertServiceEventsStart(root);
}
Also used : Bundle(org.osgi.framework.Bundle) Subsystem(org.osgi.service.subsystem.Subsystem) Test(org.junit.Test)

Example 69 with Subsystem

use of org.osgi.service.subsystem.Subsystem in project aries by apache.

the class SharedResourceTest method testSharedBundleNotUninstalledWhileStillReferenced.

@Test
public void testSharedBundleNotUninstalledWhileStillReferenced() throws Exception {
    Subsystem applicationA = installSubsystemFromFile(APPLICATION_A);
    try {
        startSubsystem(applicationA);
        Subsystem applicationB = installSubsystemFromFile(APPLICATION_B);
        try {
            startSubsystem(applicationB);
            stopSubsystem(applicationA);
            uninstallSubsystem(applicationA);
            assertBundleState(Bundle.ACTIVE, BUNDLE_C, getRootSubsystem());
        } finally {
            stopAndUninstallSubsystemSilently(applicationB);
        }
    } finally {
        stopAndUninstallSubsystemSilently(applicationA);
    }
}
Also used : Subsystem(org.osgi.service.subsystem.Subsystem) Test(org.junit.Test)

Example 70 with Subsystem

use of org.osgi.service.subsystem.Subsystem in project aries by apache.

the class Aries1084Test method testBundleStartsWhenSubsystemLeftInInvalidState.

@Test
public void testBundleStartsWhenSubsystemLeftInInvalidState() throws Exception {
    Subsystem featureA = installSubsystemFromFile(FEATURE_A);
    try {
        startSubsystem(featureA);
        assertBundleState(Bundle.ACTIVE, BUNDLE_A, featureA);
        Bundle core = getSubsystemCoreBundle();
        File file = core.getBundleContext().getDataFile(featureA.getSubsystemId() + "/OSGI-INF/DEPLOYMENT.MF");
        core.stop();
        DeploymentManifest manifest = new DeploymentManifest(file);
        FileOutputStream fos = new FileOutputStream(file);
        try {
            new DeploymentManifest.Builder().manifest(manifest).state(Subsystem.State.ACTIVE).build().write(fos);
        } finally {
            fos.close();
        }
        core.start();
        featureA = getChild(getRootSubsystem(), FEATURE_A);
        assertBundleState(Bundle.ACTIVE, BUNDLE_A, featureA);
    } finally {
        stopAndUninstallSubsystemSilently(featureA);
    }
}
Also used : DeploymentManifest(org.apache.aries.subsystem.core.archive.DeploymentManifest) Bundle(org.osgi.framework.Bundle) Subsystem(org.osgi.service.subsystem.Subsystem) FileOutputStream(java.io.FileOutputStream) File(java.io.File) Test(org.junit.Test) SubsystemTest(org.apache.aries.subsystem.itests.SubsystemTest)

Aggregations

Subsystem (org.osgi.service.subsystem.Subsystem)202 Test (org.junit.Test)151 SubsystemTest (org.apache.aries.subsystem.itests.SubsystemTest)78 AriesSubsystem (org.apache.aries.subsystem.AriesSubsystem)52 SubsystemException (org.osgi.service.subsystem.SubsystemException)50 Bundle (org.osgi.framework.Bundle)48 SubsystemArchiveBuilder (org.apache.aries.subsystem.itests.util.SubsystemArchiveBuilder)31 BundleArchiveBuilder (org.apache.aries.subsystem.itests.util.BundleArchiveBuilder)22 BasicSubsystem (org.apache.aries.subsystem.core.internal.BasicSubsystem)19 IOException (java.io.IOException)13 Hashtable (java.util.Hashtable)9 ServiceReference (org.osgi.framework.ServiceReference)8 File (java.io.File)7 BundleContext (org.osgi.framework.BundleContext)7 ArrayList (java.util.ArrayList)6 TestCapability (org.apache.aries.subsystem.itests.util.TestCapability)6 ByteArrayInputStream (java.io.ByteArrayInputStream)5 FileInputStream (java.io.FileInputStream)5 Callable (java.util.concurrent.Callable)5 BundleException (org.osgi.framework.BundleException)5