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);
}
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());
}
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);
}
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));
}
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);
}
Aggregations