aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Ross2012-09-12 16:06:39 (EDT)
committerThomas Watson2012-09-12 16:50:31 (EDT)
commiteefbfdedca01f266235f9c20ad414f5b90f9f88c (patch)
tree65b739d8a0fd5bc60299dda33751741c57a834fc
parent34a8baadaa0a7deef5f4142fc3d0af0b831fe905 (diff)
downloadrt.equinox.framework-eefbfdedca01f266235f9c20ad414f5b90f9f88c.zip
rt.equinox.framework-eefbfdedca01f266235f9c20ad414f5b90f9f88c.tar.gz
rt.equinox.framework-eefbfdedca01f266235f9c20ad414f5b90f9f88c.tar.bz2
Added new test for UNRESOLVED_PROVIDER resolution report entry type. It demonstrates how the chain of entries can be followed in order to determine the root cause.
-rw-r--r--bundles/org.eclipse.osgi.container.tests/manifests/resolution.report.c.MF3
-rw-r--r--bundles/org.eclipse.osgi.container.tests/manifests/resolution.report.d.MF4
-rw-r--r--bundles/org.eclipse.osgi.container.tests/src/org/eclipse/osgi/container/tests/ResolutionReportTest.java47
3 files changed, 51 insertions, 3 deletions
diff --git a/bundles/org.eclipse.osgi.container.tests/manifests/resolution.report.c.MF b/bundles/org.eclipse.osgi.container.tests/manifests/resolution.report.c.MF
new file mode 100644
index 0000000..3cac9b7
--- /dev/null
+++ b/bundles/org.eclipse.osgi.container.tests/manifests/resolution.report.c.MF
@@ -0,0 +1,3 @@
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: resolution.report.c
+Require-Capability: resolution.report.d
diff --git a/bundles/org.eclipse.osgi.container.tests/manifests/resolution.report.d.MF b/bundles/org.eclipse.osgi.container.tests/manifests/resolution.report.d.MF
new file mode 100644
index 0000000..f44ee7a
--- /dev/null
+++ b/bundles/org.eclipse.osgi.container.tests/manifests/resolution.report.d.MF
@@ -0,0 +1,4 @@
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: resolution.report.d
+Provide-Capability: resolution.report.d
+Require-Capability: does.not.exist
diff --git a/bundles/org.eclipse.osgi.container.tests/src/org/eclipse/osgi/container/tests/ResolutionReportTest.java b/bundles/org.eclipse.osgi.container.tests/src/org/eclipse/osgi/container/tests/ResolutionReportTest.java
index 2c30a9c..1d9128c 100644
--- a/bundles/org.eclipse.osgi.container.tests/src/org/eclipse/osgi/container/tests/ResolutionReportTest.java
+++ b/bundles/org.eclipse.osgi.container.tests/src/org/eclipse/osgi/container/tests/ResolutionReportTest.java
@@ -22,6 +22,7 @@ import org.eclipse.osgi.container.tests.dummys.*;
import org.eclipse.osgi.report.resolution.ResolutionReport;
import org.junit.Test;
import org.osgi.framework.Constants;
+import org.osgi.framework.namespace.IdentityNamespace;
import org.osgi.framework.wiring.BundleRevision;
import org.osgi.framework.wiring.FrameworkWiring;
import org.osgi.resource.*;
@@ -149,7 +150,32 @@ public class ResolutionReportTest extends AbstractTest {
assertResolutionReportEntriesSize(entries, 1);
ResolutionReport.Entry entry = entries.get(0);
assertResolutionReportEntryTypeMissingCapability(entry.getType());
- assertResolutionReportEntryDataMissingCapability(entry.getData(), "resolution.report.a");
+ assertResolutionReportEntryDataMissingCapability(entry.getData(), "osgi.wiring.package", "resolution.report.a");
+ }
+
+ @Test
+ public void testResolutionReportEntryUnresolvedProvider() throws Exception {
+ DummyResolverHook hook = new DummyResolverHook();
+ DummyContainerAdaptor adaptor = createDummyAdaptor(hook);
+ ModuleContainer container = adaptor.getContainer();
+ Module resolutionReportC = installDummyModule("resolution.report.c.MF", "resolution.report.c", container);
+ Module resolutionReportD = installDummyModule("resolution.report.d.MF", "resolution.report.d", container);
+ assertResolutionDoesNotSucceed(container, Arrays.asList(resolutionReportC, resolutionReportD));
+ ResolutionReport report = hook.getResolutionReports().get(0);
+ Map<Resource, List<ResolutionReport.Entry>> resourceToEntries = report.getEntries();
+ assertResolutionReportEntriesSize(resourceToEntries, 2);
+
+ List<ResolutionReport.Entry> entries = resourceToEntries.get(resolutionReportC.getCurrentRevision());
+ assertResolutionReportEntriesSize(entries, 1);
+ ResolutionReport.Entry entry = entries.get(0);
+ assertResolutionReportEntryTypeUnresolvedProvider(entry.getType());
+ assertResolutionReportEntryDataUnresolvedProvider(entry.getData(), "resolution.report.d");
+
+ entries = resourceToEntries.get(resolutionReportD.getCurrentRevision());
+ assertResolutionReportEntriesSize(entries, 1);
+ entry = entries.get(0);
+ assertResolutionReportEntryTypeMissingCapability(entry.getType());
+ assertResolutionReportEntryDataMissingCapability(entry.getData(), "does.not.exist", null);
}
private void clearResolutionReports(DummyResolverHook hook) {
@@ -199,11 +225,26 @@ public class ResolutionReportTest extends AbstractTest {
assertResolutionReportEntryType(ResolutionReport.Entry.Type.SINGLETON_SELECTION, type);
}
- private void assertResolutionReportEntryDataMissingCapability(Object data, String osgiWiringPackage) {
+ private void assertResolutionReportEntryTypeUnresolvedProvider(ResolutionReport.Entry.Type type) {
+ assertResolutionReportEntryType(ResolutionReport.Entry.Type.UNRESOLVED_PROVIDER, type);
+ }
+
+ private void assertResolutionReportEntryDataMissingCapability(Object data, String namespace, String namespaceValue) {
assertResolutionReportEntryDataNotNull(data);
assertTrue("Wrong resolution report entry data type", data instanceof Requirement);
Requirement requirement = (Requirement) data;
- assertTrue("Wrong missing capability", requirement.getDirectives().get(Namespace.REQUIREMENT_FILTER_DIRECTIVE).contains("osgi.wiring.package=" + osgiWiringPackage));
+ assertEquals("Wrong requirement namespace", namespace, requirement.getNamespace());
+ if (namespaceValue == null)
+ return;
+ assertTrue("Wrong requirement namespace value", requirement.getDirectives().get(Namespace.REQUIREMENT_FILTER_DIRECTIVE).contains(namespace + "=" + namespaceValue));
+ }
+
+ private void assertResolutionReportEntryDataUnresolvedProvider(Object data, String osgiIdentity) {
+ assertResolutionReportEntryDataNotNull(data);
+ assertTrue("Wrong resolution report entry data type", data instanceof Resource);
+ Resource resource = (Resource) data;
+ Capability capability = resource.getCapabilities(IdentityNamespace.IDENTITY_NAMESPACE).get(0);
+ assertEquals("Wrong unresolved provider", osgiIdentity, capability.getAttributes().get(IdentityNamespace.IDENTITY_NAMESPACE));
}
private void assertResolutionReportEntryTypeMissingCapability(ResolutionReport.Entry.Type type) {