Search in sources :

Example 51 with Subsystem

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

the class Aries1425Test method testProvisionResourceHeader.

@Test
public void testProvisionResourceHeader() throws Exception {
    Subsystem applicationA = installSubsystemFromFile(APPLICATION_A);
    try {
        Map<String, String> headers = applicationA.getDeploymentHeaders();
        String header = headers.get(SubsystemConstants.PROVISION_RESOURCE);
        assertFalse("Fragment content treated as dependency", header != null && header.contains(BUNDLE_A));
    } finally {
        uninstallSubsystemSilently(applicationA);
    }
}
Also used : Subsystem(org.osgi.service.subsystem.Subsystem) Test(org.junit.Test) SubsystemTest(org.apache.aries.subsystem.itests.SubsystemTest)

Example 52 with Subsystem

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

the class Aries1425Test method testBundleSelectedFromLocalRepository.

@Test
public void testBundleSelectedFromLocalRepository() throws Exception {
    Subsystem applicationB = installSubsystemFromFile(APPLICATION_B);
    try {
        assertNotConstituent(applicationB, BUNDLE_A, null, IdentityNamespace.TYPE_FRAGMENT);
        assertConstituent(applicationB, BUNDLE_A, null, IdentityNamespace.TYPE_BUNDLE);
    } finally {
        uninstallSubsystemSilently(applicationB);
    }
}
Also used : Subsystem(org.osgi.service.subsystem.Subsystem) Test(org.junit.Test) SubsystemTest(org.apache.aries.subsystem.itests.SubsystemTest)

Example 53 with Subsystem

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

the class Aries1425Test method testBundleSelectedFromRemoteRepository.

@Test
public void testBundleSelectedFromRemoteRepository() throws Exception {
    // Make sure the repository containing the fragment comes first.
    registerRepositoryService(BUNDLE_A_FRAGMENT);
    registerRepositoryService(BUNDLE_A_BUNDLE);
    Subsystem applicationC = installSubsystemFromFile(APPLICATION_C);
    try {
        assertNotConstituent(applicationC, BUNDLE_A, null, IdentityNamespace.TYPE_FRAGMENT);
        assertConstituent(applicationC, BUNDLE_A, null, IdentityNamespace.TYPE_BUNDLE);
    } finally {
        uninstallSubsystemSilently(applicationC);
    }
}
Also used : Subsystem(org.osgi.service.subsystem.Subsystem) Test(org.junit.Test) SubsystemTest(org.apache.aries.subsystem.itests.SubsystemTest)

Example 54 with Subsystem

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

the class Aries1425Test method testDeployedContentHeader.

@Test
public void testDeployedContentHeader() throws Exception {
    Subsystem applicationA = installSubsystemFromFile(APPLICATION_A);
    try {
        Map<String, String> headers = applicationA.getDeploymentHeaders();
        String header = headers.get(SubsystemConstants.DEPLOYED_CONTENT);
        DeployedContentHeader dch = new DeployedContentHeader(header);
        boolean foundClause = false;
        for (DeployedContentHeader.Clause clause : dch.getClauses()) {
            if (BUNDLE_A.equals(clause.getSymbolicName())) {
                assertEquals("Wrong type", IdentityNamespace.TYPE_FRAGMENT, clause.getType());
                foundClause = true;
                break;
            }
        }
        assertTrue("Missing clause", foundClause);
    } finally {
        uninstallSubsystemSilently(applicationA);
    }
}
Also used : Subsystem(org.osgi.service.subsystem.Subsystem) DeployedContentHeader(org.apache.aries.subsystem.core.archive.DeployedContentHeader) Test(org.junit.Test) SubsystemTest(org.apache.aries.subsystem.itests.SubsystemTest)

Example 55 with Subsystem

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

the class Aries1435Test method testWildcardEverything.

@Test
public void testWildcardEverything() throws Exception {
    registerWeavingHook("b", "*");
    Subsystem compositeB = installSubsystemFromFile(COMPOSITE_B);
    try {
        Bundle bundleB = compositeB.getBundleContext().installBundle(BUNDLE_B, new ByteArrayInputStream(createBundleBContent()));
        try {
            Subsystem applicationB = installSubsystemFromFile(compositeB, APPLICATION_B);
            Subsystem featureB = installSubsystemFromFile(applicationB, FEATURE_B);
            Subsystem applicationE = installSubsystemFromFile(featureB, APPLICATION_E);
            testSharingPolicy(applicationE, "b", false);
            testSharingPolicy(applicationE, "org.osgi.framework.Constants", false);
            testSharingPolicy(applicationB, "b", false);
            testSharingPolicy(applicationB, "org.osgi.framework.Constants", false);
            testSharingPolicy(compositeB, "b", false);
            testSharingPolicy(compositeB, "org.osgi.framework.Constants", false);
            testSharingPolicy(getRootSubsystem(), "b", false);
            testSharingPolicy(getRootSubsystem(), "org.osgi.framework.Constants", false);
            testDynamicImport(applicationE, "b.B");
            testDynamicImport(applicationE, "org.osgi.framework.Constants");
            testDynamicImport(featureB, "b.B");
            testDynamicImport(featureB, "org.osgi.framework.Constants");
            testDynamicImport(applicationB, "b.B");
            testDynamicImport(applicationB, "org.osgi.framework.Constants");
            testDynamicImport(compositeB, "b.B");
            testDynamicImport(compositeB, "org.osgi.framework.Constants");
            testSharingPolicy(applicationE, "b", true);
            testSharingPolicy(applicationE, "org.osgi.framework.Constants", true);
            testSharingPolicy(applicationB, "b", true);
            testSharingPolicy(applicationB, "org.osgi.framework.Constants", true);
            testSharingPolicy(compositeB, "b", true);
            testSharingPolicy(compositeB, "org.osgi.framework.Constants", true);
            testSharingPolicy(getRootSubsystem(), "b", false);
            testSharingPolicy(getRootSubsystem(), "org.osgi.framework.Constants", false);
            uninstallSubsystemSilently(applicationE);
            uninstallSubsystemSilently(featureB);
            uninstallSubsystemSilently(applicationB);
        } finally {
            uninstallSilently(bundleB);
        }
    } finally {
        uninstallSubsystemSilently(compositeB);
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) Bundle(org.osgi.framework.Bundle) Subsystem(org.osgi.service.subsystem.Subsystem) SubsystemTest(org.apache.aries.subsystem.itests.SubsystemTest) Test(org.junit.Test)

Aggregations

Subsystem (org.osgi.service.subsystem.Subsystem)202 Test (org.junit.Test)151 SubsystemTest (org.apache.aries.subsystem.itests.SubsystemTest)78 AriesSubsystem (org.apache.aries.subsystem.AriesSubsystem)52 SubsystemException (org.osgi.service.subsystem.SubsystemException)50 Bundle (org.osgi.framework.Bundle)48 SubsystemArchiveBuilder (org.apache.aries.subsystem.itests.util.SubsystemArchiveBuilder)31 BundleArchiveBuilder (org.apache.aries.subsystem.itests.util.BundleArchiveBuilder)22 BasicSubsystem (org.apache.aries.subsystem.core.internal.BasicSubsystem)19 IOException (java.io.IOException)13 Hashtable (java.util.Hashtable)9 ServiceReference (org.osgi.framework.ServiceReference)8 File (java.io.File)7 BundleContext (org.osgi.framework.BundleContext)7 ArrayList (java.util.ArrayList)6 TestCapability (org.apache.aries.subsystem.itests.util.TestCapability)6 ByteArrayInputStream (java.io.ByteArrayInputStream)5 FileInputStream (java.io.FileInputStream)5 Callable (java.util.concurrent.Callable)5 BundleException (org.osgi.framework.BundleException)5