Search in sources :

Example 6 with SubsystemArchiveBuilder

use of org.apache.aries.subsystem.itests.util.SubsystemArchiveBuilder in project aries by apache.

the class Aries1383Test method testRestart.

@Test
public void testRestart() throws Exception {
    Subsystem root = getRootSubsystem();
    Subsystem a1 = installSubsystem(root, "a1", new SubsystemArchiveBuilder().symbolicName("a1").type(SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION + ';' + AriesProvisionDependenciesDirective.RESOLVE.toString()).content("b1,c1;type=osgi.subsystem.composite").bundle("b1", new BundleArchiveBuilder().symbolicName("b1").importPackage("b2").build()).bundle("b2", new BundleArchiveBuilder().symbolicName("b2").exportPackage("b2").build()).subsystem("c1", new SubsystemArchiveBuilder().symbolicName("c1").type(SubsystemConstants.SUBSYSTEM_TYPE_COMPOSITE + ';' + AriesProvisionDependenciesDirective.RESOLVE.toString()).content("b1;version=\"[0,0]\"").importPackage("b2").bundle("b1", new BundleArchiveBuilder().symbolicName("b1").importPackage("b2").build()).build()).build(), false);
    uninstallableSubsystems.add(a1);
    assertChild(root, "a1");
    assertState(State.INSTALLING, a1);
    Subsystem c1 = getChild(a1, "c1", null, SubsystemConstants.SUBSYSTEM_TYPE_COMPOSITE);
    assertNotNull("Missing child", c1);
    assertState(State.INSTALLING, c1);
    restartSubsystemsImplBundle();
    root = getRootSubsystem();
    a1 = getChild(root, "a1");
    assertNotNull("Missing child", a1);
    uninstallableSubsystems.add(a1);
    assertState(State.INSTALLING, a1);
    assertConstituent(a1, "b1");
    assertNotConstituent(root, "b2");
    c1 = getChild(a1, "c1", null, SubsystemConstants.SUBSYSTEM_TYPE_COMPOSITE);
    assertNotNull("Missing child", c1);
    uninstallableSubsystems.add(c1);
    assertConstituent(c1, "b1");
    startSubsystem(c1, false);
    stoppableSubsystems.add(c1);
    assertState(State.INSTALLED, a1);
    stoppableSubsystems.add(a1);
    assertConstituent(root, "b2");
}
Also used : SubsystemArchiveBuilder(org.apache.aries.subsystem.itests.util.SubsystemArchiveBuilder) BundleArchiveBuilder(org.apache.aries.subsystem.itests.util.BundleArchiveBuilder) AriesSubsystem(org.apache.aries.subsystem.AriesSubsystem) Subsystem(org.osgi.service.subsystem.Subsystem) SubsystemTest(org.apache.aries.subsystem.itests.SubsystemTest) Test(org.junit.Test)

Example 7 with SubsystemArchiveBuilder

use of org.apache.aries.subsystem.itests.util.SubsystemArchiveBuilder in project aries by apache.

the class Aries1383Test method test16a.

/*
	 * (16) Unscoped subsystem with a value of apache-aries-provision-dependencies 
	 * that is the same as the scoped parent installs successfully.
	 */
@Test
public void test16a() throws Exception {
    Subsystem root = getRootSubsystem();
    try {
        Subsystem subsystem = installSubsystem(root, FEATURE_PROVISION_DEPENDENCIES_INSTALL, new SubsystemArchiveBuilder().symbolicName("application").type(SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION + ';' + AriesProvisionDependenciesDirective.INSTALL.toString()).build(), true);
        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)

Example 8 with SubsystemArchiveBuilder

use of org.apache.aries.subsystem.itests.util.SubsystemArchiveBuilder in project aries by apache.

the class Aries1383Test method testInterleavingContentDependencies.

@Test
public void testInterleavingContentDependencies() throws Exception {
    Subsystem root = getRootSubsystem();
    Subsystem c1 = installSubsystem(root, "c1", new SubsystemArchiveBuilder().symbolicName("c1").type(SubsystemConstants.SUBSYSTEM_TYPE_COMPOSITE + ';' + AriesProvisionDependenciesDirective.RESOLVE.toString()).content("c1b1;version=\"[0,0]\"").exportPackage("c1b1").importPackage("c2b1").bundle("c1b1", new BundleArchiveBuilder().symbolicName("c1b1").exportPackage("c1b1").importPackage("c2b1").build()).build(), false);
    uninstallableSubsystems.add(c1);
    Subsystem c2 = installSubsystem(root, "c2", new SubsystemArchiveBuilder().symbolicName("c2").type(SubsystemConstants.SUBSYSTEM_TYPE_COMPOSITE + ';' + AriesProvisionDependenciesDirective.RESOLVE.toString()).content("c2b1;version=\"[0,0]\"").exportPackage("c2b1").importPackage("c1b1").bundle("c2b1", new BundleArchiveBuilder().symbolicName("c2b1").exportPackage("c2b1").importPackage("c1b1").build()).build(), false);
    uninstallableSubsystems.add(c2);
    startSubsystem(c1, false);
    stoppableSubsystems.add(c1);
    assertState(EnumSet.of(State.RESOLVED, State.ACTIVE), c2);
    stoppableSubsystems.add(c2);
}
Also used : SubsystemArchiveBuilder(org.apache.aries.subsystem.itests.util.SubsystemArchiveBuilder) BundleArchiveBuilder(org.apache.aries.subsystem.itests.util.BundleArchiveBuilder) AriesSubsystem(org.apache.aries.subsystem.AriesSubsystem) Subsystem(org.osgi.service.subsystem.Subsystem) SubsystemTest(org.apache.aries.subsystem.itests.SubsystemTest) Test(org.junit.Test)

Example 9 with SubsystemArchiveBuilder

use of org.apache.aries.subsystem.itests.util.SubsystemArchiveBuilder in project aries by apache.

the class Aries1383Test method test21.

/*
	 * (21) Install a scoped subsystem, S1, with 
	 * apache-aries-provision-dependencies:=resolve. Install two features, F1 and 
	 * F2, independently as children of S1. F1 has bundle B1 and B2 as content. 
	 * F2 has bundle B2 and B3 as content. B2 is shared content. B1 has a 
	 * dependency on bundle B4, B2 has a dependency on bundle B5. B3 has a 
	 * dependency on bundle B6. Start F1. Dependency bundles B4 and B5 should be 
	 * provisioned but not B6.
	 */
@Test
public void test21() 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, "b1").attribute(IdentityNamespace.CAPABILITY_VERSION_ATTRIBUTE, Version.emptyVersion).attribute(IdentityNamespace.CAPABILITY_TYPE_ATTRIBUTE, IdentityNamespace.TYPE_BUNDLE)).requirement(new TestRequirement.Builder().namespace(PackageNamespace.PACKAGE_NAMESPACE).directive(PackageNamespace.REQUIREMENT_FILTER_DIRECTIVE, "(osgi.wiring.package=b4)")).content(new BundleArchiveBuilder().symbolicName("b1").importPackage("b4").buildAsBytes()).build()).resource(new TestRepositoryContent.Builder().capability(new TestCapability.Builder().namespace(IdentityNamespace.IDENTITY_NAMESPACE).attribute(IdentityNamespace.IDENTITY_NAMESPACE, "b2").attribute(IdentityNamespace.CAPABILITY_VERSION_ATTRIBUTE, Version.emptyVersion).attribute(IdentityNamespace.CAPABILITY_TYPE_ATTRIBUTE, IdentityNamespace.TYPE_BUNDLE)).requirement(new TestRequirement.Builder().namespace(PackageNamespace.PACKAGE_NAMESPACE).directive(PackageNamespace.REQUIREMENT_FILTER_DIRECTIVE, "(osgi.wiring.package=b5)")).content(new BundleArchiveBuilder().symbolicName("b2").importPackage("b5").buildAsBytes()).build()).resource(new TestRepositoryContent.Builder().capability(new TestCapability.Builder().namespace(IdentityNamespace.IDENTITY_NAMESPACE).attribute(IdentityNamespace.IDENTITY_NAMESPACE, "b3").attribute(IdentityNamespace.CAPABILITY_VERSION_ATTRIBUTE, Version.emptyVersion).attribute(IdentityNamespace.CAPABILITY_TYPE_ATTRIBUTE, IdentityNamespace.TYPE_BUNDLE)).requirement(new TestRequirement.Builder().namespace(PackageNamespace.PACKAGE_NAMESPACE).directive(PackageNamespace.REQUIREMENT_FILTER_DIRECTIVE, "(osgi.wiring.package=b6)")).content(new BundleArchiveBuilder().symbolicName("b3").importPackage("b6").buildAsBytes()).build()).resource(new TestRepositoryContent.Builder().capability(new TestCapability.Builder().namespace(IdentityNamespace.IDENTITY_NAMESPACE).attribute(IdentityNamespace.IDENTITY_NAMESPACE, "b4").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, "b4")).content(new BundleArchiveBuilder().symbolicName("b4").exportPackage("b4").buildAsBytes()).build()).resource(new TestRepositoryContent.Builder().capability(new TestCapability.Builder().namespace(IdentityNamespace.IDENTITY_NAMESPACE).attribute(IdentityNamespace.IDENTITY_NAMESPACE, "b5").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, "b5")).content(new BundleArchiveBuilder().symbolicName("b5").exportPackage("b5").buildAsBytes()).build()).resource(new TestRepositoryContent.Builder().capability(new TestCapability.Builder().namespace(IdentityNamespace.IDENTITY_NAMESPACE).attribute(IdentityNamespace.IDENTITY_NAMESPACE, "b6").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, "b6")).content(new BundleArchiveBuilder().symbolicName("b6").exportPackage("b6").buildAsBytes()).build()).build(), null));
    Subsystem root = getRootSubsystem();
    Subsystem s1 = installSubsystem(root, "s1", new SubsystemArchiveBuilder().symbolicName("s1").type(SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION + ';' + AriesProvisionDependenciesDirective.RESOLVE.toString() + ';' + SubsystemConstants.PROVISION_POLICY_DIRECTIVE + ":=" + SubsystemConstants.PROVISION_POLICY_ACCEPT_DEPENDENCIES).build(), false);
    uninstallableSubsystems.add(s1);
    startSubsystem(s1, false);
    stoppableSubsystems.add(s1);
    Subsystem f2 = installSubsystem(s1, "f2", new SubsystemArchiveBuilder().symbolicName("f2").type(SubsystemConstants.SUBSYSTEM_TYPE_FEATURE).content("b2,b3").build(), false);
    uninstallableSubsystems.add(f2);
    assertChild(s1, "f2", null, SubsystemConstants.SUBSYSTEM_TYPE_FEATURE);
    assertConstituent(s1, "f2", null, SubsystemConstants.SUBSYSTEM_TYPE_FEATURE);
    assertConstituent(f2, "b2");
    assertConstituent(f2, "b3");
    Subsystem f1 = installSubsystem(s1, "f1", new SubsystemArchiveBuilder().symbolicName("f1").type(SubsystemConstants.SUBSYSTEM_TYPE_FEATURE).content("b1,b2").build(), false);
    uninstallableSubsystems.add(f1);
    assertChild(s1, "f1", null, SubsystemConstants.SUBSYSTEM_TYPE_FEATURE);
    assertConstituent(s1, "f1", null, SubsystemConstants.SUBSYSTEM_TYPE_FEATURE);
    assertConstituent(f1, "b1");
    assertConstituent(f1, "b2");
    startSubsystem(f1, false);
    stoppableSubsystems.add(f1);
    assertState(EnumSet.of(State.RESOLVED, State.ACTIVE), f2);
    assertConstituent(s1, "b4");
    assertConstituent(s1, "b5");
    assertConstituent(s1, "b6");
}
Also used : 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) TestCapability(org.apache.aries.subsystem.itests.util.TestCapability) TestRepositoryContent(org.apache.aries.subsystem.itests.util.TestRepositoryContent) SubsystemArchiveBuilder(org.apache.aries.subsystem.itests.util.SubsystemArchiveBuilder) TestRepository(org.apache.aries.subsystem.itests.util.TestRepository) Repository(org.osgi.service.repository.Repository) AriesSubsystem(org.apache.aries.subsystem.AriesSubsystem) Subsystem(org.osgi.service.subsystem.Subsystem) TestRequirement(org.apache.aries.subsystem.itests.util.TestRequirement) SubsystemTest(org.apache.aries.subsystem.itests.SubsystemTest) Test(org.junit.Test)

Example 10 with SubsystemArchiveBuilder

use of org.apache.aries.subsystem.itests.util.SubsystemArchiveBuilder 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

SubsystemArchiveBuilder (org.apache.aries.subsystem.itests.util.SubsystemArchiveBuilder)31 Subsystem (org.osgi.service.subsystem.Subsystem)30 BundleArchiveBuilder (org.apache.aries.subsystem.itests.util.BundleArchiveBuilder)22 AriesSubsystem (org.apache.aries.subsystem.AriesSubsystem)21 SubsystemTest (org.apache.aries.subsystem.itests.SubsystemTest)21 Test (org.junit.Test)21 SubsystemException (org.osgi.service.subsystem.SubsystemException)16 Bundle (org.osgi.framework.Bundle)5 Callable (java.util.concurrent.Callable)3 ExecutorService (java.util.concurrent.ExecutorService)3 Future (java.util.concurrent.Future)3 TestCapability (org.apache.aries.subsystem.itests.util.TestCapability)3 TestRepository (org.apache.aries.subsystem.itests.util.TestRepository)3 Repository (org.osgi.service.repository.Repository)3 TestRepositoryContent (org.apache.aries.subsystem.itests.util.TestRepositoryContent)2 TestRequirement (org.apache.aries.subsystem.itests.util.TestRequirement)1