use of org.eclipse.osgi.report.resolution.ResolutionReport in project rt.equinox.framework by eclipse.
the class ResolutionReportTest method testResolutionReportEntryMissingCapability.
@Test
public void testResolutionReportEntryMissingCapability() throws Exception {
DummyResolverHook hook = new DummyResolverHook();
DummyContainerAdaptor adaptor = createDummyAdaptor(hook);
ModuleContainer container = adaptor.getContainer();
Module resolutionReportB = installDummyModule("resolution.report.b.MF", "resolution.report.b", container);
assertResolutionDoesNotSucceed(container, Arrays.asList(resolutionReportB));
ResolutionReport report = hook.getResolutionReports().get(0);
Map<Resource, List<ResolutionReport.Entry>> resourceToEntries = report.getEntries();
assertResolutionReportEntriesSize(resourceToEntries, 1);
List<ResolutionReport.Entry> entries = resourceToEntries.get(resolutionReportB.getCurrentRevision());
assertResolutionReportEntriesSize(entries, 1);
ResolutionReport.Entry entry = entries.get(0);
assertResolutionReportEntryTypeMissingCapability(entry.getType());
assertResolutionReportEntryDataMissingCapability(entry.getData(), "osgi.wiring.package", "resolution.report.a");
}
use of org.eclipse.osgi.report.resolution.ResolutionReport in project rt.equinox.framework by eclipse.
the class TestModuleContainer method testMultiHostFragmentWithOverlapImport.
@Test
public void testMultiHostFragmentWithOverlapImport() throws BundleException {
DummyContainerAdaptor adaptor = createDummyAdaptor();
ModuleContainer container = adaptor.getContainer();
// install an exporter
Map<String, String> exporterManifest = new HashMap<String, String>();
exporterManifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
exporterManifest.put(Constants.BUNDLE_SYMBOLICNAME, "exporter");
exporterManifest.put(Constants.BUNDLE_VERSION, "1.0");
exporterManifest.put(Constants.EXPORT_PACKAGE, "exporter");
installDummyModule(exporterManifest, "exporter", container);
// install a fragment to the exporter
Map<String, String> exporterFragManifest = new HashMap<String, String>();
exporterFragManifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
exporterFragManifest.put(Constants.BUNDLE_SYMBOLICNAME, "exporter.frag");
exporterFragManifest.put(Constants.EXPORT_PACKAGE, "exporter.frag");
exporterFragManifest.put(Constants.FRAGMENT_HOST, "exporter");
installDummyModule(exporterFragManifest, "exporter.frag", container);
// install a host that imports the exporter
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.IMPORT_PACKAGE, "exporter");
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);
// install a fragment that also imports the exporter
Map<String, String> hostFragManifest = new HashMap<String, String>();
hostFragManifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
hostFragManifest.put(Constants.BUNDLE_SYMBOLICNAME, "host.frag");
hostFragManifest.put(Constants.FRAGMENT_HOST, "host");
hostFragManifest.put(Constants.IMPORT_PACKAGE, "exporter; version=0.0");
Module hostFrag = installDummyModule(hostFragManifest, "host.frag", container);
ResolutionReport report = container.resolve(Arrays.asList(hostFrag), true);
Assert.assertNull("Failed to resolve test.", report.getResolutionException());
}
use of org.eclipse.osgi.report.resolution.ResolutionReport in project rt.equinox.framework by eclipse.
the class TestModuleContainer method testUsesTimeout.
// DISABLE see bug 498064 @Test
public void testUsesTimeout() throws BundleException {
// Always want to go to zero threads when idle
int coreThreads = 0;
// use the number of processors - 1 because we use the current thread when rejected
int maxThreads = Math.max(Runtime.getRuntime().availableProcessors() - 1, 1);
// idle timeout; make it short to get rid of threads quickly after resolve
int idleTimeout = 5;
// use sync queue to force thread creation
BlockingQueue<Runnable> queue = new SynchronousQueue<Runnable>();
// try to name the threads with useful name
ThreadFactory threadFactory = new ThreadFactory() {
@Override
public Thread newThread(Runnable r) {
// $NON-NLS-1$
Thread t = new Thread(r, "Resolver thread - UNIT TEST");
t.setDaemon(true);
return t;
}
};
// use a rejection policy that simply runs the task in the current thread once the max threads is reached
RejectedExecutionHandler rejectHandler = new RejectedExecutionHandler() {
@Override
public void rejectedExecution(Runnable r, ThreadPoolExecutor exe) {
r.run();
}
};
ExecutorService executor = new ThreadPoolExecutor(coreThreads, maxThreads, idleTimeout, TimeUnit.SECONDS, queue, threadFactory, rejectHandler);
ScheduledExecutorService timeoutExecutor = new ScheduledThreadPoolExecutor(1);
Map<String, String> configuration = new HashMap<String, String>();
configuration.put(EquinoxConfiguration.PROP_RESOLVER_BATCH_TIMEOUT, "5000");
Map<String, String> debugOpts = Collections.emptyMap();
DummyContainerAdaptor adaptor = new DummyContainerAdaptor(new DummyCollisionHook(false), configuration, new DummyResolverHookFactory(), new DummyDebugOptions(debugOpts));
adaptor.setResolverExecutor(executor);
adaptor.setTimeoutExecutor(timeoutExecutor);
ModuleContainer container = adaptor.getContainer();
for (int i = 1; i <= 1000; i++) {
for (Map<String, String> manifest : getUsesTimeoutManifests("test" + i)) {
installDummyModule(manifest, manifest.get(Constants.BUNDLE_SYMBOLICNAME), container);
}
}
ResolutionReport report = container.resolve(container.getModules(), true);
Assert.assertNull("Found resolution errors.", report.getResolutionException());
for (Module module : container.getModules()) {
Assert.assertEquals("Wrong state of module: " + module, State.RESOLVED, module.getState());
}
executor.shutdown();
timeoutExecutor.shutdown();
System.gc();
System.gc();
System.gc();
}
use of org.eclipse.osgi.report.resolution.ResolutionReport in project rt.equinox.framework by eclipse.
the class TestModuleContainer method testR3.
@Test
public void testR3() throws BundleException, IOException {
DummyContainerAdaptor adaptor = createDummyAdaptor();
ModuleContainer container = adaptor.getContainer();
// install the system.bundle
Module systemBundle = installDummyModule("system.bundle.MF", Constants.SYSTEM_BUNDLE_LOCATION, Constants.SYSTEM_BUNDLE_SYMBOLICNAME, null, null, container);
ResolutionReport report = container.resolve(Arrays.asList(systemBundle), true);
Assert.assertNull("Failed to resolve system.bundle.", report.getResolutionException());
// R3 bundle
Map<String, String> exporterManifest = new HashMap<String, String>();
exporterManifest = new HashMap<String, String>();
exporterManifest.put(Constants.BUNDLE_SYMBOLICNAME, "exporter");
exporterManifest.put(Constants.EXPORT_PACKAGE, "exporter; version=\"1.1\"");
Module moduleExport = installDummyModule(exporterManifest, "exporter", container);
report = container.resolve(Arrays.asList(moduleExport, moduleExport), true);
Assert.assertNull("Failed to resolve", report.getResolutionException());
List<BundleRequirement> reqs = moduleExport.getCurrentRevision().getWiring().getRequirements(PackageNamespace.PACKAGE_NAMESPACE);
assertEquals("Wrong number of imports.", 0, reqs.size());
// R3 bundle
exporterManifest.clear();
exporterManifest.put(Constants.BUNDLE_SYMBOLICNAME, "dynamicExporter");
exporterManifest.put(Constants.EXPORT_PACKAGE, "exporter; version=\"1.0\"");
exporterManifest.put(Constants.DYNAMICIMPORT_PACKAGE, "exporter");
Module moduleWithDynExport = installDummyModule(exporterManifest, "dynamicExporter", container);
report = container.resolve(Arrays.asList(moduleWithDynExport), true);
Assert.assertNull("Failed to resolve", report.getResolutionException());
reqs = moduleWithDynExport.getCurrentRevision().getWiring().getRequirements(PackageNamespace.PACKAGE_NAMESPACE);
assertEquals("Wrong number of imports.", 2, reqs.size());
report = container.resolve(Arrays.asList(moduleWithDynExport), true);
Assert.assertNull("Failed to resolve", report.getResolutionException());
reqs = moduleWithDynExport.getCurrentRevision().getWiring().getRequirements(PackageNamespace.PACKAGE_NAMESPACE);
assertEquals("Wrong number of imports.", 2, reqs.size());
ModuleWiring wiring = moduleWithDynExport.getCurrentRevision().getWiring();
List<ModuleWire> packageWires = wiring.getRequiredModuleWires(PackageNamespace.PACKAGE_NAMESPACE);
Assert.assertEquals("Unexpected number of wires", 1, packageWires.size());
Assert.assertEquals("Wrong exporter", packageWires.get(0).getProviderWiring().getRevision(), moduleExport.getCurrentRevision());
}
use of org.eclipse.osgi.report.resolution.ResolutionReport in project rt.equinox.framework by eclipse.
the class TestModuleContainer method testResolveDeadlock.
@Test
public void testResolveDeadlock() throws BundleException, IOException, InterruptedException {
DummyContainerAdaptor adaptor = createDummyAdaptor();
ModuleContainer container = adaptor.getContainer();
// install the system.bundle
Module systemBundle = installDummyModule("system.bundle.MF", Constants.SYSTEM_BUNDLE_LOCATION, Constants.SYSTEM_BUNDLE_SYMBOLICNAME, null, null, container);
ResolutionReport report = container.resolve(Arrays.asList(systemBundle), true);
Assert.assertNull("Failed to resolve system.bundle.", report.getResolutionException());
systemBundle.start();
// install a bunch of modules
Map<String, String> manifest = new HashMap<String, String>();
List<Module> modules = new ArrayList<Module>();
for (int i = 0; i < 5; i++) {
manifest.clear();
manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
manifest.put(Constants.BUNDLE_SYMBOLICNAME, "module." + i);
modules.add(installDummyModule(manifest, manifest.get(Constants.BUNDLE_SYMBOLICNAME), container));
}
adaptor.setSlowdownEvents(true);
final ConcurrentLinkedQueue<BundleException> startErrors = new ConcurrentLinkedQueue<BundleException>();
final ExecutorService executor = Executors.newFixedThreadPool(10);
try {
for (final Module module : modules) {
executor.execute(new Runnable() {
@Override
public void run() {
try {
module.start();
} catch (BundleException e) {
startErrors.offer(e);
e.printStackTrace();
}
}
});
}
} finally {
executor.shutdown();
executor.awaitTermination(5, TimeUnit.MINUTES);
systemBundle.stop();
}
Assert.assertNull("Found a error.", startErrors.poll());
List<DummyContainerEvent> events = adaptor.getDatabase().getContainerEvents();
for (DummyContainerEvent event : events) {
Assert.assertNotEquals("Found an error.", ContainerEvent.ERROR, event.type);
}
}
Aggregations