Search in sources :

Example 56 with SubsystemException

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

the class Aries1383Test method testMatchingCapabilityInDisconnectedRegion.

@Test
public void testMatchingCapabilityInDisconnectedRegion() throws Exception {
    Subsystem root = getRootSubsystem();
    BundleArchiveBuilder b1Builder = new BundleArchiveBuilder().symbolicName("b1").exportPackage("b1");
    Bundle b1 = root.getBundleContext().installBundle("b1", b1Builder.build());
    try {
        Subsystem a1 = installSubsystem(root, "a1", new SubsystemArchiveBuilder().symbolicName("a1").type(SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION + ';' + AriesProvisionDependenciesDirective.RESOLVE.toString() + ';' + SubsystemConstants.PROVISION_POLICY_DIRECTIVE + ":=" + SubsystemConstants.PROVISION_POLICY_ACCEPT_DEPENDENCIES).build(), false);
        uninstallableSubsystems.add(a1);
        startSubsystem(a1, false);
        stoppableSubsystems.add(a1);
        removeConnectionWithParent(a1);
        Subsystem a2 = installSubsystem(a1, "a2", new SubsystemArchiveBuilder().symbolicName("a2").type(SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION).content("b2").bundle("b2", new BundleArchiveBuilder().symbolicName("b2").importPackage("b1").build()).bundle("b1", b1Builder.build()).build(), false);
        uninstallableSubsystems.add(a2);
        assertState(State.INSTALLING, a2);
        assertNotConstituent(a1, "b1");
        try {
            startSubsystem(a2, false);
            stoppableSubsystems.add(a2);
            assertConstituent(a1, "b1");
        } catch (SubsystemException e) {
            e.printStackTrace();
            fail("Subsystem should have started");
        }
    } finally {
        uninstallSilently(b1);
    }
}
Also used : SubsystemArchiveBuilder(org.apache.aries.subsystem.itests.util.SubsystemArchiveBuilder) BundleArchiveBuilder(org.apache.aries.subsystem.itests.util.BundleArchiveBuilder) Bundle(org.osgi.framework.Bundle) AriesSubsystem(org.apache.aries.subsystem.AriesSubsystem) Subsystem(org.osgi.service.subsystem.Subsystem) SubsystemException(org.osgi.service.subsystem.SubsystemException) SubsystemTest(org.apache.aries.subsystem.itests.SubsystemTest) Test(org.junit.Test)

Example 57 with SubsystemException

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

the class Aries1383Test method test12.

/*
	 * (12) Subsystem with apache-aries-provision-dependencies:=resolve undergoes 
	 * the following state transitions when starting fails due to a start 
	 * failure: INSTALLING -> INSTALLED -> RESOLVING -> RESOLVED -> STARTING -> 
	 * RESOLVED.
	 */
@Test
public void test12() throws Exception {
    Subsystem root = getRootSubsystem();
    subsystemEvents.clear();
    Subsystem subsystem = root.install(APPLICATION_START_FAILURE, applicationStartFailure());
    try {
        subsystem.start();
        stopSubsystemSilently(subsystem);
        fail("Subsystem should not have started");
    } catch (SubsystemException e) {
        e.printStackTrace();
        long id = lastSubsystemId();
        assertEvent(id, APPLICATION_START_FAILURE, Version.emptyVersion, SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION, State.INSTALLING, subsystemEvents.poll(id, 5000), ServiceEvent.REGISTERED);
        assertEvent(id, APPLICATION_START_FAILURE, Version.emptyVersion, SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION, State.INSTALLED, subsystemEvents.poll(id, 5000), ServiceEvent.MODIFIED);
        assertEvent(id, APPLICATION_START_FAILURE, Version.emptyVersion, SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION, State.RESOLVING, subsystemEvents.poll(id, 5000), ServiceEvent.MODIFIED);
        assertEvent(id, APPLICATION_START_FAILURE, Version.emptyVersion, SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION, State.RESOLVED, subsystemEvents.poll(id, 5000), ServiceEvent.MODIFIED);
        assertEvent(id, APPLICATION_START_FAILURE, Version.emptyVersion, SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION, State.STARTING, subsystemEvents.poll(id, 5000), ServiceEvent.MODIFIED);
        assertEvent(id, APPLICATION_START_FAILURE, Version.emptyVersion, SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION, State.RESOLVED, subsystemEvents.poll(id, 5000), ServiceEvent.MODIFIED);
    } finally {
        uninstallSubsystemSilently(subsystem);
    }
}
Also used : AriesSubsystem(org.apache.aries.subsystem.AriesSubsystem) Subsystem(org.osgi.service.subsystem.Subsystem) SubsystemException(org.osgi.service.subsystem.SubsystemException) SubsystemTest(org.apache.aries.subsystem.itests.SubsystemTest) Test(org.junit.Test)

Example 58 with SubsystemException

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

the class Aries1383Test method test9.

/*
	 * (9) Subsystem with apache-aries-provision-dependencies:=resolve is in the 
	 * INSTALLING state when dependencies cannot be provisioned after invoking 
	 * the start method.
	 */
@Test
public void test9() throws Exception {
    Subsystem root = getRootSubsystem();
    Subsystem subsystem = installSubsystem(root, APPLICATION_MISSING_DEPENDENCY, applicationMissingDependency(), false);
    try {
        startSubsystem(subsystem, false);
        stopSubsystemSilently(subsystem);
        fail("Subsystem should not have started");
    } catch (SubsystemException e) {
        e.printStackTrace();
        assertState(State.INSTALLING, subsystem);
    } finally {
        uninstallSubsystemSilently(subsystem);
    }
}
Also used : AriesSubsystem(org.apache.aries.subsystem.AriesSubsystem) Subsystem(org.osgi.service.subsystem.Subsystem) SubsystemException(org.osgi.service.subsystem.SubsystemException) SubsystemTest(org.apache.aries.subsystem.itests.SubsystemTest) Test(org.junit.Test)

Example 59 with SubsystemException

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

the class Aries1338Test method test.

private void test(String importPackage, String exportPackage, boolean shouldFail) throws Exception {
    Subsystem root = getRootSubsystem();
    try {
        Subsystem subsystem = installSubsystem(root, "subsystem", new SubsystemArchiveBuilder().symbolicName("subsystem").bundle("a", new BundleArchiveBuilder().symbolicName("a").importPackage(importPackage).build()).bundle("b", new BundleArchiveBuilder().symbolicName("b").exportPackage(exportPackage).build()).build());
        uninstallableSubsystems.add(subsystem);
        if (shouldFail) {
            fail("Subsystem should not have installed");
        }
    } catch (SubsystemException e) {
        e.printStackTrace();
        if (!shouldFail) {
            fail("Subsystem should have installed");
        }
    }
}
Also used : SubsystemArchiveBuilder(org.apache.aries.subsystem.itests.util.SubsystemArchiveBuilder) BundleArchiveBuilder(org.apache.aries.subsystem.itests.util.BundleArchiveBuilder) Subsystem(org.osgi.service.subsystem.Subsystem) SubsystemException(org.osgi.service.subsystem.SubsystemException)

Example 60 with SubsystemException

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

the class Aries1383Test method testProvideCapabilityNamespaceOnly.

@Test
public void testProvideCapabilityNamespaceOnly() throws Exception {
    Subsystem root = getRootSubsystem();
    Subsystem c1 = installSubsystem(root, "c1", new SubsystemArchiveBuilder().symbolicName("c1").type(SubsystemConstants.SUBSYSTEM_TYPE_COMPOSITE).provideCapability("y").build());
    uninstallableSubsystems.add(c1);
    try {
        startSubsystem(c1);
        stoppableSubsystems.add(c1);
    } catch (SubsystemException e) {
        e.printStackTrace();
        fail("Subsystem should have started");
    }
}
Also used : SubsystemArchiveBuilder(org.apache.aries.subsystem.itests.util.SubsystemArchiveBuilder) AriesSubsystem(org.apache.aries.subsystem.AriesSubsystem) Subsystem(org.osgi.service.subsystem.Subsystem) SubsystemException(org.osgi.service.subsystem.SubsystemException) SubsystemTest(org.apache.aries.subsystem.itests.SubsystemTest) Test(org.junit.Test)

Aggregations

SubsystemException (org.osgi.service.subsystem.SubsystemException)61 Subsystem (org.osgi.service.subsystem.Subsystem)39 Test (org.junit.Test)32 SubsystemTest (org.apache.aries.subsystem.itests.SubsystemTest)23 AriesSubsystem (org.apache.aries.subsystem.AriesSubsystem)19 SubsystemArchiveBuilder (org.apache.aries.subsystem.itests.util.SubsystemArchiveBuilder)15 Bundle (org.osgi.framework.Bundle)11 BundleArchiveBuilder (org.apache.aries.subsystem.itests.util.BundleArchiveBuilder)7 Resource (org.osgi.resource.Resource)6 IOException (java.io.IOException)5 ArrayList (java.util.ArrayList)5 SubsystemContentHeader (org.apache.aries.subsystem.core.archive.SubsystemContentHeader)5 BundleException (org.osgi.framework.BundleException)5 Requirement (org.osgi.resource.Requirement)5 InvalidSyntaxException (org.osgi.framework.InvalidSyntaxException)3 BundleRevision (org.osgi.framework.wiring.BundleRevision)3 Repository (org.osgi.service.repository.Repository)3 File (java.io.File)2 URISyntaxException (java.net.URISyntaxException)2 DeploymentManifest (org.apache.aries.subsystem.core.archive.DeploymentManifest)2