summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Ross2012-09-11 10:26:51 (EDT)
committer Thomas Watson2012-09-11 11:01:02 (EDT)
commit9bc24c15248264c132639dd4c8dcea9567e4bc9c (patch)
treebe71a9e31f5d6354c8bb66799fd980f188dc428a
parenta328dd521967c164d5d319a73a0f7e2cbc569949 (diff)
downloadrt.equinox.framework-9bc24c15248264c132639dd4c8dcea9567e4bc9c.zip
rt.equinox.framework-9bc24c15248264c132639dd4c8dcea9567e4bc9c.tar.gz
rt.equinox.framework-9bc24c15248264c132639dd4c8dcea9567e4bc9c.tar.bz2
Added test for MISSING_CAPABILITY resolution report entry type.
-rw-r--r--bundles/org.eclipse.osgi.container.tests/manifests/resolution.report.b.MF3
-rw-r--r--bundles/org.eclipse.osgi.container.tests/src/org/eclipse/osgi/container/tests/ResolutionReportTest.java31
2 files changed, 33 insertions, 1 deletions
diff --git a/bundles/org.eclipse.osgi.container.tests/manifests/resolution.report.b.MF b/bundles/org.eclipse.osgi.container.tests/manifests/resolution.report.b.MF
new file mode 100644
index 0000000..181ddd2
--- /dev/null
+++ b/bundles/org.eclipse.osgi.container.tests/manifests/resolution.report.b.MF
@@ -0,0 +1,3 @@
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: resolution.report.b
+Import-Package: resolution.report.a
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 dc217d7..a592a2f 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
@@ -12,6 +12,7 @@ package org.eclipse.osgi.container.tests;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.util.*;
@@ -23,7 +24,7 @@ import org.junit.Test;
import org.osgi.framework.Constants;
import org.osgi.framework.wiring.BundleRevision;
import org.osgi.framework.wiring.FrameworkWiring;
-import org.osgi.resource.Resource;
+import org.osgi.resource.*;
import org.osgi.service.resolver.ResolutionException;
public class ResolutionReportTest extends AbstractTest {
@@ -134,6 +135,23 @@ public class ResolutionReportTest extends AbstractTest {
assertResolutionReportEntryDataNotNull(entry.getData());
}
+ @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(), "resolution.report.a");
+ }
+
private void clearResolutionReports(DummyResolverHook hook) {
hook.getResolutionReports().clear();
}
@@ -181,6 +199,17 @@ public class ResolutionReportTest extends AbstractTest {
assertResolutionReportEntryType(ResolutionReport.Entry.Type.SINGLETON_SELECTION, type);
}
+ private void assertResolutionReportEntryDataMissingCapability(Object data, String osgiWiringPackage) {
+ 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));
+ }
+
+ private void assertResolutionReportEntryTypeMissingCapability(ResolutionReport.Entry.Type type) {
+ assertResolutionReportEntryType(ResolutionReport.Entry.Type.MISSING_CAPABILITY, type);
+ }
+
private void assertResolutionReportEntryType(ResolutionReport.Entry.Type expected, ResolutionReport.Entry.Type actual) {
assertEquals("Wrong resolution report entry type", expected, actual);
}