Search in sources :

Example 51 with SubsystemException

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

the class Aries1383Test method test8.

/*
	 * (8) Subsystem with apache-aries-provision-dependencies:=resolve is not 
	 * available as a service after an unsuccessful installation.
	 */
@Test
public void test8() throws Exception {
    Subsystem root = getRootSubsystem();
    try {
        Subsystem subsystem = installSubsystem(root, APPLICATION_INSTALL_FAILED, applicationInstallFailed(), false);
        uninstallSubsystemSilently(subsystem);
        fail("Subsystem should not have installed");
    } catch (SubsystemException e) {
        e.printStackTrace();
        assertEquals("Subsystem service should not exist", 0, bundleContext.getServiceReferences(Subsystem.class, "(" + SubsystemConstants.SUBSYSTEM_ID_PROPERTY + "=" + lastSubsystemId() + ")").size());
    }
}
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 52 with SubsystemException

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

the class Aries1383Test method testImplicitlyInstalledChildOverridesProvisionDependencies.

@Test
public void testImplicitlyInstalledChildOverridesProvisionDependencies() throws Exception {
    Subsystem root = getRootSubsystem();
    subsystemEvents.clear();
    try {
        Subsystem subsystem = root.install("parent", new SubsystemArchiveBuilder().symbolicName("parent").type(SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION + ';' + AriesProvisionDependenciesDirective.INSTALL.toString()).subsystem("child", new SubsystemArchiveBuilder().symbolicName("child").type(SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION + ';' + AriesProvisionDependenciesDirective.RESOLVE.toString()).build()).build());
        uninstallSubsystemSilently(subsystem);
        fail("Subsystem should not have installed");
    } catch (SubsystemException e) {
        e.printStackTrace();
    }
}
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)

Example 53 with SubsystemException

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

the class Aries1383Test method test7.

/*
	 * (7) Subsystem with apache-aries-provision-dependencies:=resolve is in the 
	 * INSTALL_FAILED state after an unsuccessful installation.
	 */
@Test
public void test7() throws Exception {
    Subsystem root = getRootSubsystem();
    subsystemEvents.clear();
    try {
        Subsystem subsystem = root.install(APPLICATION_INSTALL_FAILED, applicationInstallFailed());
        uninstallSubsystemSilently(subsystem);
        fail("Subsystem should not have installed");
    } catch (SubsystemException e) {
        e.printStackTrace();
        long id = lastSubsystemId();
        assertEvent(id, APPLICATION_INSTALL_FAILED, Version.emptyVersion, SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION, State.INSTALLING, subsystemEvents.poll(id, 5000), ServiceEvent.REGISTERED);
        assertEvent(id, APPLICATION_INSTALL_FAILED, Version.emptyVersion, SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION, State.INSTALL_FAILED, subsystemEvents.poll(id, 5000), ServiceEvent.MODIFIED);
        assertEvent(id, APPLICATION_INSTALL_FAILED, Version.emptyVersion, SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION, State.UNINSTALLING, subsystemEvents.poll(id, 5000), ServiceEvent.MODIFIED);
        assertEvent(id, APPLICATION_INSTALL_FAILED, Version.emptyVersion, SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION, State.UNINSTALLED, subsystemEvents.poll(id, 5000), ServiceEvent.MODIFIED);
    }
}
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 54 with SubsystemException

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

the class Aries1383Test method test15a.

/*
	 * (15) Unscoped subsystem with a value of apache-aries-provision-dependencies 
	 * that is different than the scoped parent fails installation.
	 */
@Test
public void test15a() throws Exception {
    Subsystem root = getRootSubsystem();
    try {
        Subsystem subsystem = installSubsystem(root, FEATURE_PROVISION_DEPENDENCIES_RESOLVE, featureProvisionDependenciesResolve(), false);
        uninstallSubsystemSilently(subsystem);
        fail("Subsystem should not have installed");
    } catch (SubsystemException e) {
        e.printStackTrace();
    }
}
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 55 with SubsystemException

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

the class Aries1383Test method test4e3bCompliance.

@Test
public void test4e3bCompliance() throws Exception {
    serviceRegistrations.add(bundleContext.registerService(Repository.class, new TestRepository.Builder().resource(new TestRepositoryContent.Builder().capability(new TestCapability.Builder().namespace(IdentityNamespace.IDENTITY_NAMESPACE).attribute(IdentityNamespace.IDENTITY_NAMESPACE, "a").attribute(IdentityNamespace.CAPABILITY_VERSION_ATTRIBUTE, Version.emptyVersion).attribute(IdentityNamespace.CAPABILITY_TYPE_ATTRIBUTE, IdentityNamespace.TYPE_BUNDLE)).capability(new TestCapability.Builder().namespace(PackageNamespace.PACKAGE_NAMESPACE).attribute(PackageNamespace.PACKAGE_NAMESPACE, "x").attribute(IdentityNamespace.CAPABILITY_VERSION_ATTRIBUTE, Version.emptyVersion)).capability(new TestCapability.Builder().namespace(BundleNamespace.BUNDLE_NAMESPACE).attribute(BundleNamespace.BUNDLE_NAMESPACE, "a").attribute(BundleNamespace.CAPABILITY_BUNDLE_VERSION_ATTRIBUTE, Version.emptyVersion)).content(new BundleArchiveBuilder().symbolicName("a").exportPackage("x").buildAsBytes()).build()).resource(new TestRepositoryContent.Builder().capability(new TestCapability.Builder().namespace(IdentityNamespace.IDENTITY_NAMESPACE).attribute(IdentityNamespace.IDENTITY_NAMESPACE, "b").attribute(IdentityNamespace.CAPABILITY_VERSION_ATTRIBUTE, Version.emptyVersion).attribute(IdentityNamespace.CAPABILITY_TYPE_ATTRIBUTE, IdentityNamespace.TYPE_BUNDLE)).capability(new TestCapability.Builder().namespace("y")).content(new BundleArchiveBuilder().symbolicName("b").header("Provide-Capability", "y").buildAsBytes()).build()).build(), null));
    Subsystem root = getRootSubsystem();
    try {
        Subsystem s1 = installSubsystem(root, "s1", new SubsystemArchiveBuilder().symbolicName("s1").type(SubsystemConstants.SUBSYSTEM_TYPE_COMPOSITE).subsystem("s3", new SubsystemArchiveBuilder().symbolicName("s3").type(SubsystemConstants.SUBSYSTEM_TYPE_COMPOSITE).subsystem("s2", new SubsystemArchiveBuilder().symbolicName("s2").type(SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION).bundle("c", new BundleArchiveBuilder().symbolicName("c").importPackage("x").build()).bundle("d", new BundleArchiveBuilder().symbolicName("d").header("Require-Bundle", "a").build()).bundle("e", new BundleArchiveBuilder().symbolicName("e").header("Require-Capability", "y").build()).build()).build()).build(), true);
        uninstallableSubsystems.add(s1);
        fail("Subsystem should not have installed");
    } catch (SubsystemException e) {
        e.printStackTrace();
    }
}
Also used : SubsystemArchiveBuilder(org.apache.aries.subsystem.itests.util.SubsystemArchiveBuilder) TestRepository(org.apache.aries.subsystem.itests.util.TestRepository) Repository(org.osgi.service.repository.Repository) TestRepository(org.apache.aries.subsystem.itests.util.TestRepository) BundleArchiveBuilder(org.apache.aries.subsystem.itests.util.BundleArchiveBuilder) BundleArchiveBuilder(org.apache.aries.subsystem.itests.util.BundleArchiveBuilder) 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) TestCapability(org.apache.aries.subsystem.itests.util.TestCapability) 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