Search in sources :

Example 66 with DummyContainerAdaptor

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

the class TestModuleContainer method testCompatReprovide.

@Test
public void testCompatReprovide() throws BundleException, IOException {
    DummyContainerAdaptor adaptor = createDummyAdaptor();
    ModuleContainer container = adaptor.getContainer();
    Module b1 = installDummyModule("compatReprovide1.MF", "b1", container);
    Module b2 = installDummyModule("compatReprovide2.MF", "b2", container);
    Module b3 = installDummyModule("compatReprovide3.MF", "b3", container);
    String b1Visibility = b1.getCurrentRevision().getRequirements(BundleNamespace.BUNDLE_NAMESPACE).iterator().next().getDirectives().get(BundleNamespace.REQUIREMENT_VISIBILITY_DIRECTIVE);
    String b2Visibility = b2.getCurrentRevision().getRequirements(BundleNamespace.BUNDLE_NAMESPACE).iterator().next().getDirectives().get(BundleNamespace.REQUIREMENT_VISIBILITY_DIRECTIVE);
    String b3Visibility = b3.getCurrentRevision().getRequirements(BundleNamespace.BUNDLE_NAMESPACE).iterator().next().getDirectives().get(BundleNamespace.REQUIREMENT_VISIBILITY_DIRECTIVE);
    Assert.assertEquals("Wrong visibility directive: " + b1, BundleNamespace.VISIBILITY_REEXPORT, b1Visibility);
    Assert.assertNull("Wrong visibility directive: ", b2Visibility);
    Assert.assertEquals("Wrong visibility directive: " + b2, BundleNamespace.VISIBILITY_REEXPORT, b3Visibility);
}
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 67 with DummyContainerAdaptor

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

the class TestModuleContainer method testUses4.

/*
	 * Test that fragments and uses constraints
	 */
@Test
public void testUses4() 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_h = installDummyModule("uses.h.MF", "h", container);
    Module uses_h_frag = installDummyModule("uses.h.frag.MF", "h.frag", container);
    container.resolve(null, false);
    Assert.assertEquals("h should resolve.", State.RESOLVED, uses_h.getState());
    Assert.assertEquals("h.frag should resolve.", State.RESOLVED, uses_h_frag.getState());
    Module uses_i = installDummyModule("uses.i.MF", "i", container);
    Module uses_j = installDummyModule("uses.j.MF", "j", container);
    container.resolve(null, false);
    Assert.assertEquals("i should resolve.", State.RESOLVED, uses_i.getState());
    Assert.assertEquals("j should resolve.", State.RESOLVED, uses_j.getState());
    List<BundleWire> requiredWires = uses_j.getCurrentRevision().getWiring().getRequiredWires(null);
    Assert.assertEquals("Wrong number of wires for j", 2, requiredWires.size());
    for (BundleWire wire : requiredWires) {
        Assert.assertEquals("Wrong provider", uses_i.getCurrentRevision(), wire.getProvider());
    }
    Module uses_j_dynamic = installDummyModule("uses.j.dynamic.MF", "j.dynamic", container);
    container.resolve(null, false);
    ModuleWire dynamicWire = container.resolveDynamic("uses2", uses_j_dynamic.getCurrentRevision());
    Assert.assertNotNull("Null dynamic wire.", dynamicWire);
    Assert.assertEquals("Wrong provider", uses_i.getCurrentRevision(), dynamicWire.getProvider());
}
Also used : DummyContainerAdaptor(org.eclipse.osgi.tests.container.dummys.DummyContainerAdaptor) ModuleWire(org.eclipse.osgi.container.ModuleWire) ModuleContainer(org.eclipse.osgi.container.ModuleContainer) Module(org.eclipse.osgi.container.Module) BundleWire(org.osgi.framework.wiring.BundleWire) Test(org.junit.Test)

Example 68 with DummyContainerAdaptor

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

the class TestModuleContainer method testCompatSingleton.

@Test
public void testCompatSingleton() throws BundleException, IOException {
    DummyContainerAdaptor adaptor = createDummyAdaptor();
    ModuleContainer container = adaptor.getContainer();
    Module s1 = installDummyModule("compatSingleton1.MF", "s1", container);
    Module s2 = installDummyModule("compatSingleton2.MF", "s2", container);
    Module s3 = installDummyModule("compatSingleton3.MF", "s3", container);
    String s1Singleton = s1.getCurrentRevision().getCapabilities(IdentityNamespace.IDENTITY_NAMESPACE).iterator().next().getDirectives().get(IdentityNamespace.CAPABILITY_SINGLETON_DIRECTIVE);
    String s2Singleton = s2.getCurrentRevision().getCapabilities(IdentityNamespace.IDENTITY_NAMESPACE).iterator().next().getDirectives().get(IdentityNamespace.CAPABILITY_SINGLETON_DIRECTIVE);
    String s3Singleton = s3.getCurrentRevision().getCapabilities(IdentityNamespace.IDENTITY_NAMESPACE).iterator().next().getDirectives().get(IdentityNamespace.CAPABILITY_SINGLETON_DIRECTIVE);
    Assert.assertEquals("Wrong singleton directive: " + s1, "true", s1Singleton);
    Assert.assertNull("Wrong singleton directive: " + s2, s2Singleton);
    Assert.assertEquals("Wrong singleton directive: " + s3, "true", s3Singleton);
}
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 69 with DummyContainerAdaptor

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

the class TestModuleContainer method testLoadPerformance.

// disabled @Test
public void testLoadPerformance() throws BundleException, IOException {
    setupModuleDatabase();
    ByteArrayOutputStream bytes = new ByteArrayOutputStream();
    resolvedModuleDatabase.store(new DataOutputStream(bytes), true);
    bytes.close();
    System.out.println("SIZE: " + bytes.size());
    long start = System.currentTimeMillis();
    for (int i = 0; i < 1000; i++) {
        DummyContainerAdaptor adaptor = createDummyAdaptor();
        adaptor.getDatabase().load(new DataInputStream(new ByteArrayInputStream(bytes.toByteArray())));
    }
    System.out.println("END: " + (System.currentTimeMillis() - start));
}
Also used : DummyContainerAdaptor(org.eclipse.osgi.tests.container.dummys.DummyContainerAdaptor) ByteArrayInputStream(java.io.ByteArrayInputStream) DataOutputStream(java.io.DataOutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) DataInputStream(java.io.DataInputStream)

Example 70 with DummyContainerAdaptor

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

the class TestModuleContainer method testInvalidAttributes.

@Test
public void testInvalidAttributes() throws IOException, BundleException {
    DummyContainerAdaptor adaptor = createDummyAdaptor();
    ModuleContainer container = adaptor.getContainer();
    // install the system.bundle
    installDummyModule("system.bundle.MF", Constants.SYSTEM_BUNDLE_LOCATION, Constants.SYSTEM_BUNDLE_SYMBOLICNAME, null, null, container);
    // provider with all supported types
    Map<String, String> invalidAttrManifest = new HashMap<String, String>();
    invalidAttrManifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
    invalidAttrManifest.put(Constants.BUNDLE_SYMBOLICNAME, "invalid");
    invalidAttrManifest.put(Constants.PROVIDE_CAPABILITY, "provider.cap; invalid:Boolean=true");
    checkInvalidManifest(invalidAttrManifest, container);
    invalidAttrManifest.put(Constants.PROVIDE_CAPABILITY, "provider.cap; invalid:Integer=1");
    checkInvalidManifest(invalidAttrManifest, container);
    invalidAttrManifest.put(Constants.PROVIDE_CAPABILITY, "provider.cap; invalid:List<Boolean>=true");
    checkInvalidManifest(invalidAttrManifest, container);
    invalidAttrManifest.put(Constants.PROVIDE_CAPABILITY, "provider.cap; invalid:List<Integer>=1");
    checkInvalidManifest(invalidAttrManifest, container);
}
Also used : DummyContainerAdaptor(org.eclipse.osgi.tests.container.dummys.DummyContainerAdaptor) ModuleContainer(org.eclipse.osgi.container.ModuleContainer) HashMap(java.util.HashMap) 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