Search in sources :

Example 16 with SubsystemException

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

the class Aries1429Test method testMissingParentChildEdgeNotTolerated.

@Test
public void testMissingParentChildEdgeNotTolerated() throws Exception {
    Subsystem applicationA = installSubsystemFromFile(APPLICATION_A);
    try {
        removeConnectionWithParent(applicationA);
        try {
            ((AriesSubsystem) applicationA).addRequirements(Collections.singletonList((Requirement) new TestRequirement.Builder().namespace(PackageNamespace.PACKAGE_NAMESPACE).attribute(PackageNamespace.PACKAGE_NAMESPACE, "org.osgi.framework").build()));
            fail("No exception received");
        } catch (SubsystemException e) {
            Throwable cause = e.getCause();
            assertNotNull("Wrong cause", cause);
            assertEquals("Wrong cause", IllegalStateException.class, cause.getClass());
        }
    } finally {
        uninstallSubsystemSilently(applicationA);
    }
}
Also used : Requirement(org.osgi.resource.Requirement) TestRequirement(org.apache.aries.subsystem.itests.util.TestRequirement) AriesSubsystem(org.apache.aries.subsystem.AriesSubsystem) Subsystem(org.osgi.service.subsystem.Subsystem) SubsystemException(org.osgi.service.subsystem.SubsystemException) AriesSubsystem(org.apache.aries.subsystem.AriesSubsystem) SubsystemTest(org.apache.aries.subsystem.itests.SubsystemTest) Test(org.junit.Test)

Example 17 with SubsystemException

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

the class Aries1408Test method testRequirementFromRemoteRepositoryConvertsToRequireCapability.

@Test
public void testRequirementFromRemoteRepositoryConvertsToRequireCapability() throws Exception {
    Bundle bundleB = installBundleFromFile(BUNDLE_B);
    try {
        Subsystem applicationA = installSubsystemFromFile(APPLICATION_A);
        uninstallSubsystemSilently(applicationA);
    } catch (SubsystemException e) {
        e.printStackTrace();
        fail("Subsystem should have installed");
    } finally {
        uninstallSilently(bundleB);
    }
}
Also used : Bundle(org.osgi.framework.Bundle) Subsystem(org.osgi.service.subsystem.Subsystem) SubsystemException(org.osgi.service.subsystem.SubsystemException) SubsystemTest(org.apache.aries.subsystem.itests.SubsystemTest) Test(org.junit.Test)

Example 18 with SubsystemException

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

the class Aries1416Test method testSharedContentBundlePreferredProvider.

@Test
public void testSharedContentBundlePreferredProvider() throws Exception {
    // Install feature A containing bundle B and application A both in the
    // archive and as content into the root subsystem region. Bundle B 
    // provides capability b. Application A contains bundle A requiring 
    // capability b both in the archive and as content. Preferred provider 
    // bundle B is also included in the archive but not as content.
    Subsystem featureA = installSubsystemFromFile(FEATURE_A);
    try {
        // Install feature B having the same characteristics as feature A
        // described above into the root subsystem region. Bundle B will 
        // become shared content of features A and B. Shared content bundle
        // B from the system repository should be used as the preferred
        // provider. Bundle B from the local repository should not be
        // provisioned.
        Subsystem featureB = installSubsystemFromFile(FEATURE_B);
        uninstallSubsystemSilently(featureB);
    } catch (SubsystemException e) {
        e.printStackTrace();
        fail("Subsystem should have installed");
    } finally {
        uninstallSubsystemSilently(featureA);
    }
}
Also used : Subsystem(org.osgi.service.subsystem.Subsystem) SubsystemException(org.osgi.service.subsystem.SubsystemException) Test(org.junit.Test) SubsystemTest(org.apache.aries.subsystem.itests.SubsystemTest)

Example 19 with SubsystemException

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

the class Aries1416Test method testSystemRepositoryBundlePreferredProvider.

@Test
public void testSystemRepositoryBundlePreferredProvider() throws Exception {
    Subsystem root = getRootSubsystem();
    // Install bundle B providing capability b into the root subsystem's
    // region.
    Bundle bundleB = installBundleFromFile(BUNDLE_B, root);
    try {
        // Install application A containing content bundle A requiring 
        // capability b and dependency bundle B providing capability b.
        // Bundle B is not content but will become part of the local 
        // repository. The preferred provider is bundle B. Bundle B from the
        // system repository should be used. Bundle B from the local
        // repository should not be provisioned.
        Subsystem applicationA = installSubsystemFromFile(APPLICATION_A);
        uninstallSubsystemSilently(applicationA);
    } catch (SubsystemException e) {
        e.printStackTrace();
        fail("Subsystem should have installed");
    } finally {
        uninstallSilently(bundleB);
    }
}
Also used : Bundle(org.osgi.framework.Bundle) Subsystem(org.osgi.service.subsystem.Subsystem) SubsystemException(org.osgi.service.subsystem.SubsystemException) Test(org.junit.Test) SubsystemTest(org.apache.aries.subsystem.itests.SubsystemTest)

Example 20 with SubsystemException

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

the class Aries1383Test method test16c.

/*
	 * (16) Unscoped subsystem with a value of apache-aries-provision-dependencies 
	 * that is the same as the scoped parent installs successfully.
	 */
@Test
public void test16c() throws Exception {
    Subsystem root = getRootSubsystem();
    try {
        Subsystem subsystem = installSubsystem(root, "application", new SubsystemArchiveBuilder().symbolicName("application").type(SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION + ';' + AriesProvisionDependenciesDirective.RESOLVE.toString()).subsystem("feature", new SubsystemArchiveBuilder().symbolicName("feature").type(SubsystemConstants.SUBSYSTEM_TYPE_FEATURE + ';' + AriesProvisionDependenciesDirective.RESOLVE.toString()).build()).build(), false);
        uninstallSubsystemSilently(subsystem);
    } catch (SubsystemException e) {
        e.printStackTrace();
        fail("Subsystem should have installed");
    }
}
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