Search in sources :

Example 16 with BundleArchiveBuilder

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

the class Aries1383Test method testAutoInstallDependenciesComposite.

@Test
public void testAutoInstallDependenciesComposite() throws Exception {
    Subsystem root = getRootSubsystem();
    Subsystem b = installSubsystem(root, "b", new SubsystemArchiveBuilder().symbolicName("b").type(SubsystemConstants.SUBSYSTEM_TYPE_COMPOSITE + ';' + AriesProvisionDependenciesDirective.RESOLVE.toString()).content("a;version=\"[0,0]\"").exportPackage("a").importPackage("b").bundle("a", new BundleArchiveBuilder().symbolicName("a").importPackage("b").exportPackage("a").build()).bundle("b", new BundleArchiveBuilder().symbolicName("b").exportPackage("b").build()).build(), false);
    uninstallableSubsystems.add(b);
    try {
        Subsystem a = installSubsystem(root, "a", new SubsystemArchiveBuilder().symbolicName("a").type(SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION).bundle("a", new BundleArchiveBuilder().symbolicName("a").importPackage("a").build()).build(), true);
        uninstallableSubsystems.add(a);
        assertState(EnumSet.of(State.INSTALLED, State.RESOLVED), b);
    } catch (Exception e) {
        e.printStackTrace();
        fail("Subsystem should have installed");
    }
}
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) SubsystemException(org.osgi.service.subsystem.SubsystemException) SubsystemTest(org.apache.aries.subsystem.itests.SubsystemTest) Test(org.junit.Test)

Example 17 with BundleArchiveBuilder

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

Example 18 with BundleArchiveBuilder

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

the class Aries1383Test method test20.

/*
	 * (20) 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 as content. F2 has 
	 * bundle B2 as content. B2 has B1 as a dependency. B1 should be a 
	 * constituent of F1 but not of the root subsystem.
	 */
@Test
public void test20() 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)).content(new BundleArchiveBuilder().symbolicName("b1").exportPackage("a").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)).content(new BundleArchiveBuilder().symbolicName("b2").importPackage("a").buildAsBytes()).build()).build(), null));
    Subsystem root = getRootSubsystem();
    Subsystem s1 = installSubsystem(root, "s1", new SubsystemArchiveBuilder().symbolicName("s1").type(SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION + ';' + AriesProvisionDependenciesDirective.RESOLVE.toString()).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").build(), false);
    uninstallableSubsystems.add(f2);
    assertChild(s1, "f2", null, SubsystemConstants.SUBSYSTEM_TYPE_FEATURE);
    assertConstituent(f2, "b2");
    Subsystem f1 = installSubsystem(s1, "f1", new SubsystemArchiveBuilder().symbolicName("f1").type(SubsystemConstants.SUBSYSTEM_TYPE_FEATURE).content("b1").build(), false);
    uninstallableSubsystems.add(f1);
    assertChild(s1, "f1", null, SubsystemConstants.SUBSYSTEM_TYPE_FEATURE);
    assertConstituent(f1, "b1");
    assertNotConstituent(root, "b1");
}
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) TestCapability(org.apache.aries.subsystem.itests.util.TestCapability) TestRepositoryContent(org.apache.aries.subsystem.itests.util.TestRepositoryContent) SubsystemTest(org.apache.aries.subsystem.itests.SubsystemTest) Test(org.junit.Test)

Example 19 with BundleArchiveBuilder

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

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

the class Aries1538Test method testHostFragmentCircularDependency.

private void testHostFragmentCircularDependency(AriesProvisionDependenciesDirective provisionDependencies) throws Exception {
    boolean flag = AriesProvisionDependenciesDirective.INSTALL.equals(provisionDependencies);
    BundleArchiveBuilder hostBuilder = new BundleArchiveBuilder();
    hostBuilder.symbolicName("host");
    hostBuilder.exportPackage("foo");
    hostBuilder.importPackage("bar");
    BundleArchiveBuilder fragmentBuilder = new BundleArchiveBuilder();
    fragmentBuilder.symbolicName("fragment");
    fragmentBuilder.exportPackage("bar");
    fragmentBuilder.importPackage("foo");
    fragmentBuilder.header("Fragment-Host", "host");
    Subsystem root = getRootSubsystem();
    Bundle host = root.getBundleContext().installBundle("host", hostBuilder.build());
    uninstallableBundles.add(host);
    Bundle fragment = root.getBundleContext().installBundle("fragment", fragmentBuilder.build());
    uninstallableBundles.add(fragment);
    startBundle(host);
    try {
        Subsystem subsystem = installSubsystem(root, "subsystem", new SubsystemArchiveBuilder().symbolicName("subsystem").type(SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION + ';' + provisionDependencies.toString()).bundle("a", new BundleArchiveBuilder().symbolicName("a").importPackage("foo").build()).build(), flag);
        uninstallableSubsystems.add(subsystem);
        startSubsystem(subsystem, flag);
        stoppableSubsystems.add(subsystem);
    } catch (SubsystemException e) {
        e.printStackTrace();
        fail("Subsystem should have installed and started");
    }
}
Also used : SubsystemArchiveBuilder(org.apache.aries.subsystem.itests.util.SubsystemArchiveBuilder) BundleArchiveBuilder(org.apache.aries.subsystem.itests.util.BundleArchiveBuilder) Bundle(org.osgi.framework.Bundle) Subsystem(org.osgi.service.subsystem.Subsystem) SubsystemException(org.osgi.service.subsystem.SubsystemException)

Aggregations

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