Search in sources :

Example 31 with DummyContainerAdaptor

use of org.eclipse.osgi.tests.container.dummys.DummyContainerAdaptor in project rt.equinox.framework by eclipse.

the class TestModuleContainer method testUses3.

/*
	 * Test that split packages are handled ok with uses constraints
	 */
@Test
public void testUses3() throws BundleException, IOException {
    DummyContainerAdaptor adaptor = createDummyAdaptor();
    ModuleContainer container = adaptor.getContainer();
    Module systemBundle = installDummyModule("system.bundle.MF", Constants.SYSTEM_BUNDLE_LOCATION, container);
    container.resolve(Arrays.asList(systemBundle), true);
    Module uses_a = installDummyModule("uses.a.MF", "a", container);
    Module uses_b = installDummyModule("uses.b.MF", "b", container);
    Module uses_e = installDummyModule("uses.e.MF", "e", container);
    Module uses_f = installDummyModule("uses.f.MF", "f", container);
    Module uses_g = installDummyModule("uses.g.MF", "g", container);
    container.resolve(null, false);
    Assert.assertEquals("a should resolve.", State.RESOLVED, uses_a.getState());
    Assert.assertEquals("b should resolve.", State.RESOLVED, uses_b.getState());
    Assert.assertEquals("e should resolve.", State.RESOLVED, uses_e.getState());
    Assert.assertEquals("f should resolve.", State.RESOLVED, uses_f.getState());
    Assert.assertEquals("g should not resolve.", State.INSTALLED, uses_g.getState());
}
Also used : DummyContainerAdaptor(org.eclipse.osgi.tests.container.dummys.DummyContainerAdaptor) ModuleContainer(org.eclipse.osgi.container.ModuleContainer) Module(org.eclipse.osgi.container.Module) Test(org.junit.Test)

Example 32 with DummyContainerAdaptor

use of org.eclipse.osgi.tests.container.dummys.DummyContainerAdaptor in project rt.equinox.framework by eclipse.

the class TestModuleContainer method testUTF8LineContinuation.

@Test
public void testUTF8LineContinuation() throws BundleException, IOException {
    DummyContainerAdaptor adaptor = createDummyAdaptor();
    ModuleContainer container = adaptor.getContainer();
    String utfString = "a.with.�.multibyte";
    while (utfString.getBytes("UTF8").length < 500) {
        Map<String, String> manifest = getUTFManifest(utfString);
        Module testModule = installDummyModule(manifest, manifest.get(Constants.BUNDLE_SYMBOLICNAME), container);
        Assert.assertEquals("Wrong bns for the bundle.", utfString, testModule.getCurrentRevision().getSymbolicName());
        ModuleCapability exportPackage = testModule.getCurrentRevision().getModuleCapabilities(PackageNamespace.PACKAGE_NAMESPACE).get(0);
        ModuleRequirement importPackage = testModule.getCurrentRevision().getModuleRequirements(PackageNamespace.PACKAGE_NAMESPACE).get(0);
        String actualPackageName = (String) exportPackage.getAttributes().get(PackageNamespace.PACKAGE_NAMESPACE);
        Assert.assertEquals("Wrong exported package name.", utfString, actualPackageName);
        Assert.assertTrue("import does not match export: " + importPackage, importPackage.matches(exportPackage));
        utfString = "a" + utfString;
    }
}
Also used : DummyContainerAdaptor(org.eclipse.osgi.tests.container.dummys.DummyContainerAdaptor) ModuleContainer(org.eclipse.osgi.container.ModuleContainer) ModuleCapability(org.eclipse.osgi.container.ModuleCapability) Module(org.eclipse.osgi.container.Module) ModuleRequirement(org.eclipse.osgi.container.ModuleRequirement) Test(org.junit.Test)

Example 33 with DummyContainerAdaptor

use of org.eclipse.osgi.tests.container.dummys.DummyContainerAdaptor in project rt.equinox.framework by eclipse.

the class TestModuleContainer method testUnresolvedHostWithFragmentCycle.

@Test
public void testUnresolvedHostWithFragmentCycle() throws BundleException {
    DummyContainerAdaptor adaptor = createDummyAdaptor();
    ModuleContainer container = adaptor.getContainer();
    // install a host
    Map<String, String> hostManifest = new HashMap<String, String>();
    hostManifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
    hostManifest.put(Constants.BUNDLE_SYMBOLICNAME, "host");
    hostManifest.put(Constants.BUNDLE_VERSION, "1.0");
    hostManifest.put(Constants.EXPORT_PACKAGE, "host");
    hostManifest.put(Constants.IMPORT_PACKAGE, "host.impl");
    installDummyModule(hostManifest, "host10", container);
    hostManifest.put(Constants.BUNDLE_VERSION, "1.1");
    installDummyModule(hostManifest, "host11", container);
    hostManifest.put(Constants.BUNDLE_VERSION, "1.2");
    installDummyModule(hostManifest, "host12", container);
    // hostManifest.put(Constants.BUNDLE_VERSION, "1.3");
    // installDummyModule(hostManifest, "host13", container);
    // install a host.impl fragment
    Map<String, String> hostImplManifest = new HashMap<String, String>();
    hostImplManifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
    hostImplManifest.put(Constants.BUNDLE_SYMBOLICNAME, "host.impl");
    hostImplManifest.put(Constants.EXPORT_PACKAGE, "host.impl");
    hostImplManifest.put(Constants.IMPORT_PACKAGE, "host");
    hostImplManifest.put(Constants.FRAGMENT_HOST, "host");
    installDummyModule(hostImplManifest, "hostImpl", container);
    // install an importer of host package
    Map<String, String> hostImporterManifest = new HashMap<String, String>();
    hostImporterManifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
    hostImporterManifest.put(Constants.BUNDLE_SYMBOLICNAME, "host.importer");
    hostImporterManifest.put(Constants.IMPORT_PACKAGE, "host");
    Module hostImporter = installDummyModule(hostImporterManifest, "hostImporter", container);
    ResolutionReport report = container.resolve(Arrays.asList(hostImporter), true);
    Assert.assertNull("Failed to resolve test.", report.getResolutionException());
}
Also used : DummyContainerAdaptor(org.eclipse.osgi.tests.container.dummys.DummyContainerAdaptor) ModuleContainer(org.eclipse.osgi.container.ModuleContainer) HashMap(java.util.HashMap) Module(org.eclipse.osgi.container.Module) ResolutionReport(org.eclipse.osgi.report.resolution.ResolutionReport) Test(org.junit.Test)

Example 34 with DummyContainerAdaptor

use of org.eclipse.osgi.tests.container.dummys.DummyContainerAdaptor in project rt.equinox.framework by eclipse.

the class TestModuleContainer method testStaticSubstituted.

@Test
public void testStaticSubstituted() throws BundleException, IOException {
    DummyContainerAdaptor adaptor = createDummyAdaptor();
    ModuleContainer container = adaptor.getContainer();
    Module systemBundle = installDummyModule("system.bundle.MF", Constants.SYSTEM_BUNDLE_LOCATION, container);
    container.resolve(Arrays.asList(systemBundle), true);
    Module sub_n = installDummyModule("sub.n.static.MF", "n", container);
    Module sub_l = installDummyModule("sub.l.MF", "l", container);
    Module sub_m = installDummyModule("sub.m.MF", "m", container);
    container.resolve(null, false);
    Assert.assertEquals("l should resolve.", State.RESOLVED, sub_l.getState());
    Assert.assertEquals("m should resolve.", State.RESOLVED, sub_m.getState());
    Assert.assertEquals("n should resolve.", State.RESOLVED, sub_n.getState());
}
Also used : DummyContainerAdaptor(org.eclipse.osgi.tests.container.dummys.DummyContainerAdaptor) ModuleContainer(org.eclipse.osgi.container.ModuleContainer) Module(org.eclipse.osgi.container.Module) Test(org.junit.Test)

Example 35 with DummyContainerAdaptor

use of org.eclipse.osgi.tests.container.dummys.DummyContainerAdaptor in project rt.equinox.framework by eclipse.

the class TestModuleContainer method testSimpleUnResolveable.

@Test
public void testSimpleUnResolveable() throws BundleException, IOException {
    DummyContainerAdaptor adaptor = createDummyAdaptor();
    ModuleContainer container = adaptor.getContainer();
    Module systemBundle = installDummyModule("system.bundle.MF", Constants.SYSTEM_BUNDLE_LOCATION, container);
    container.resolve(Arrays.asList(systemBundle), true);
    Module c7 = installDummyModule("c7_v1.MF", "c7", container);
    installDummyModule("c6_v1.MF", "c6", container);
    ResolutionReport report = container.resolve(Arrays.asList(c7), true);
    Assert.assertNotNull("Expected a resolution exception", report.getResolutionException());
    // Should resolve now
    installDummyModule("c4_v1.MF", "c4", container);
    report = container.resolve(Arrays.asList(c7), true);
    Assert.assertNull("Unexpected resoltuion exception", report.getResolutionException());
}
Also used : DummyContainerAdaptor(org.eclipse.osgi.tests.container.dummys.DummyContainerAdaptor) ModuleContainer(org.eclipse.osgi.container.ModuleContainer) Module(org.eclipse.osgi.container.Module) ResolutionReport(org.eclipse.osgi.report.resolution.ResolutionReport) Test(org.junit.Test)

Aggregations

DummyContainerAdaptor (org.eclipse.osgi.tests.container.dummys.DummyContainerAdaptor)85 ModuleContainer (org.eclipse.osgi.container.ModuleContainer)80 Module (org.eclipse.osgi.container.Module)79 Test (org.junit.Test)73 ModuleWire (org.eclipse.osgi.container.ModuleWire)25 ResolutionReport (org.eclipse.osgi.report.resolution.ResolutionReport)23 ModuleWiring (org.eclipse.osgi.container.ModuleWiring)20 HashMap (java.util.HashMap)18 ArrayList (java.util.ArrayList)15 DummyModuleDatabase (org.eclipse.osgi.tests.container.dummys.DummyModuleDatabase)12 ByteArrayOutputStream (java.io.ByteArrayOutputStream)9 DummyModuleEvent (org.eclipse.osgi.tests.container.dummys.DummyModuleDatabase.DummyModuleEvent)9 ByteArrayInputStream (java.io.ByteArrayInputStream)8 DataInputStream (java.io.DataInputStream)8 DataOutputStream (java.io.DataOutputStream)8 ModuleRevision (org.eclipse.osgi.container.ModuleRevision)8 DummyCollisionHook (org.eclipse.osgi.tests.container.dummys.DummyCollisionHook)7 BundleException (org.osgi.framework.BundleException)7 BundleRequirement (org.osgi.framework.wiring.BundleRequirement)6 DummyContainerEvent (org.eclipse.osgi.tests.container.dummys.DummyModuleDatabase.DummyContainerEvent)5