Make sure we wrap capabilities pulled from BundleWiring when calculating
package sources. (FELIX-3178)


git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1199131 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/src/main/java/org/apache/felix/framework/resolver/ResolverImpl.java b/framework/src/main/java/org/apache/felix/framework/resolver/ResolverImpl.java
index a62a09e..56203b3 100644
--- a/framework/src/main/java/org/apache/felix/framework/resolver/ResolverImpl.java
+++ b/framework/src/main/java/org/apache/felix/framework/resolver/ResolverImpl.java
@@ -1391,12 +1391,22 @@
             List<BundleCapability> caps = (cap.getRevision().getWiring() != null)
                 ? cap.getRevision().getWiring().getCapabilities(null)
                 : cap.getRevision().getDeclaredCapabilities(null);
-            for (int capIdx = 0; capIdx < caps.size(); capIdx++)
+            for (BundleCapability sourceCap : caps)
             {
-                if (caps.get(capIdx).getNamespace().equals(BundleRevision.PACKAGE_NAMESPACE)
-                    && caps.get(capIdx).getAttributes().get(BundleRevision.PACKAGE_NAMESPACE).equals(pkgName))
+                if (sourceCap.getNamespace().equals(BundleRevision.PACKAGE_NAMESPACE)
+                    && sourceCap.getAttributes().get(BundleRevision.PACKAGE_NAMESPACE).equals(pkgName))
                 {
-                    sources.add(caps.get(capIdx));
+                    // Since capabilities may come from fragments, we need to check
+                    // for that case and wrap them.
+                    if (!cap.getRevision().equals(sourceCap.getRevision()))
+                    {
+                        sources.add(
+                            new HostedCapability(cap.getRevision(), (BundleCapabilityImpl) sourceCap));
+                    }
+                    else
+                    {
+                        sources.add(sourceCap);
+                    }
                 }
             }