summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Ross2012-09-18 16:35:49 (EDT)
committer Thomas Watson2012-09-20 09:57:37 (EDT)
commit077c07efda3e89f0038ee5027457a08930baa4b9 (patch)
tree7c2107b10f1b77367e5a2d6f0026744f356a726e
parent827ec89b082a7a2ed48ed56731c24ad31852a9d9 (diff)
downloadrt.equinox.framework-077c07efda3e89f0038ee5027457a08930baa4b9.zip
rt.equinox.framework-077c07efda3e89f0038ee5027457a08930baa4b9.tar.gz
rt.equinox.framework-077c07efda3e89f0038ee5027457a08930baa4b9.tar.bz2
Made the UNRESOLVED_PROVIDER tests more robust in terms of testing the entry data.
-rw-r--r--bundles/org.eclipse.osgi.container.tests/src/org/eclipse/osgi/container/tests/ResolutionReportTest.java33
-rw-r--r--bundles/org.eclipse.osgi.container.tests/src/org/eclipse/osgi/container/tests/dummys/UnresolvedProviderEntryBuilder.java26
2 files changed, 46 insertions, 13 deletions
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 3e76bca..03186d6 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.PackageNamespace;
import org.osgi.framework.wiring.BundleRevision;
import org.osgi.framework.wiring.FrameworkWiring;
import org.osgi.resource.*;
@@ -170,7 +171,12 @@ public class ResolutionReportTest extends AbstractTest {
assertResolutionReportEntriesSize(entries, 1);
ResolutionReport.Entry entry = entries.get(0);
assertResolutionReportEntryTypeUnresolvedProvider(entry.getType());
- assertResolutionReportEntryDataUnresolvedProvider(entry.getData(), Arrays.asList("resolution.report.d"));
+ assertResolutionReportEntryDataUnresolvedProvider(
+ entry.getData(),
+ new UnresolvedProviderEntryBuilder()
+ .requirement(resolutionReportC.getCurrentRevision().getRequirements("resolution.report.d").get(0))
+ .capability(resolutionReportD.getCurrentRevision().getCapabilities("resolution.report.d").get(0))
+ .build());
entries = resourceToEntries.get(resolutionReportD.getCurrentRevision());
assertResolutionReportEntriesSize(entries, 1);
@@ -196,7 +202,12 @@ public class ResolutionReportTest extends AbstractTest {
assertResolutionReportEntriesSize(entries, 1);
ResolutionReport.Entry entry = entries.get(0);
assertResolutionReportEntryTypeUnresolvedProvider(entry.getType());
- assertResolutionReportEntryDataUnresolvedProvider(entry.getData(), Arrays.asList("osgi.wiring.package"));
+ assertResolutionReportEntryDataUnresolvedProvider(
+ entry.getData(),
+ new UnresolvedProviderEntryBuilder()
+ .requirement(resolutionReportG.getCurrentRevision().getRequirements(PackageNamespace.PACKAGE_NAMESPACE).get(1))
+ .capability(resolutionReportF.getCurrentRevision().getCapabilities(PackageNamespace.PACKAGE_NAMESPACE).get(0))
+ .build());
entries = resourceToEntries.get(resolutionReportF.getCurrentRevision());
assertResolutionReportEntriesSize(entries, 1);
@@ -278,21 +289,17 @@ public class ResolutionReportTest extends AbstractTest {
}
@SuppressWarnings("unchecked")
- private void assertResolutionReportEntryDataUnresolvedProvider(Object data, Collection<String> namespaces) {
+ private void assertResolutionReportEntryDataUnresolvedProvider(Object data, Map<Requirement, List<Capability>> expected) {
assertResolutionReportEntryDataNotNull(data);
assertTrue("Wrong resolution report entry data type", data instanceof Map);
Map<Requirement, Set<Capability>> unresolvedProviders = (Map<Requirement, Set<Capability>>) data;
- assertEquals("Wrong number of unresolved providers", namespaces.size(), unresolvedProviders.size());
- for (String namespace : namespaces) {
- boolean found = false;
- for (Map.Entry<Requirement, Set<Capability>> entry : unresolvedProviders.entrySet()) {
- if (entry.getKey().getNamespace().equals(namespace)) {
- found = true;
- break;
- }
+ assertEquals("Wrong number of unresolved providers", expected.size(), unresolvedProviders.size());
+ for (Map.Entry<Requirement, List<Capability>> entry : expected.entrySet()) {
+ Set<Capability> actualCapabilities = unresolvedProviders.get(entry.getKey());
+ assertEquals("Wrong number of capabilities", entry.getValue().size(), actualCapabilities.size());
+ for (Capability c : entry.getValue()) {
+ assertTrue("Capability not found", actualCapabilities.contains(c));
}
- if (!found)
- fail("Unresolved provider not found: " + namespace);
}
}
diff --git a/bundles/org.eclipse.osgi.container.tests/src/org/eclipse/osgi/container/tests/dummys/UnresolvedProviderEntryBuilder.java b/bundles/org.eclipse.osgi.container.tests/src/org/eclipse/osgi/container/tests/dummys/UnresolvedProviderEntryBuilder.java
new file mode 100644
index 0000000..06cbf0e
--- /dev/null
+++ b/bundles/org.eclipse.osgi.container.tests/src/org/eclipse/osgi/container/tests/dummys/UnresolvedProviderEntryBuilder.java
@@ -0,0 +1,26 @@
+package org.eclipse.osgi.container.tests.dummys;
+
+import java.util.*;
+import org.osgi.resource.Capability;
+import org.osgi.resource.Requirement;
+
+public class UnresolvedProviderEntryBuilder {
+ private final Map<Requirement, List<Capability>> data = new HashMap<Requirement, List<Capability>>();
+
+ private Requirement lastRequirement;
+
+ public Map<Requirement, List<Capability>> build() {
+ return new HashMap<Requirement, List<Capability>>(data);
+ }
+
+ public UnresolvedProviderEntryBuilder capability(Capability value) {
+ data.get(lastRequirement).add(value);
+ return this;
+ }
+
+ public UnresolvedProviderEntryBuilder requirement(Requirement key) {
+ data.put(key, new ArrayList<Capability>());
+ lastRequirement = key;
+ return this;
+ }
+}