[FELIX-4914] Move test utility classes to a separate package

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1685088 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/.DS_Store b/.DS_Store
new file mode 100644
index 0000000..65b3cb2
--- /dev/null
+++ b/.DS_Store
Binary files differ
diff --git a/resolver/src/test/java/org/apache/felix/resolver/test/BigResolutionTest.java b/resolver/src/test/java/org/apache/felix/resolver/test/BigResolutionTest.java
index 05a7648..da48e43 100644
--- a/resolver/src/test/java/org/apache/felix/resolver/test/BigResolutionTest.java
+++ b/resolver/src/test/java/org/apache/felix/resolver/test/BigResolutionTest.java
@@ -31,6 +31,15 @@
 
 import org.apache.felix.resolver.Logger;
 import org.apache.felix.resolver.ResolverImpl;
+import org.apache.felix.resolver.test.util.CandidateComparator;
+import org.apache.felix.resolver.test.util.CapabilitySet;
+import org.apache.felix.resolver.test.util.ClauseParser;
+import org.apache.felix.resolver.test.util.GenericCapability;
+import org.apache.felix.resolver.test.util.GenericRequirement;
+import org.apache.felix.resolver.test.util.IterativeResolver;
+import org.apache.felix.resolver.test.util.JsonReader;
+import org.apache.felix.resolver.test.util.ResourceImpl;
+import org.apache.felix.resolver.test.util.SimpleFilter;
 import org.apache.felix.utils.version.VersionRange;
 import org.junit.Ignore;
 import org.junit.Test;
@@ -193,18 +202,24 @@
     }
 
     @SuppressWarnings("unchecked")
-    private Resource parseResource(Object resource) throws BundleException {
+    public static Resource parseResource(Object resource) throws BundleException {
         ResourceImpl res = new ResourceImpl();
-        for (String s : (Collection<String>) ((Map) resource).get("capabilities")) {
-            parseCapability(res, s);
+        Collection<String> caps = (Collection<String>) ((Map) resource).get("capabilities");
+        if (caps != null) {
+            for (String s : caps) {
+                parseCapability(res, s);
+            }
         }
-        for (String s : (Collection<String>) ((Map) resource).get("requirements")) {
-            parseRequirement(res, s);
+        Collection<String> reqs = (Collection<String>) ((Map) resource).get("requirements");
+        if (reqs != null) {
+            for (String s : reqs) {
+                parseRequirement(res, s);
+            }
         }
         return res;
     }
 
-    private void parseRequirement(ResourceImpl res, String s) throws BundleException {
+    private static void parseRequirement(ResourceImpl res, String s) throws BundleException {
         List<ClauseParser.ParsedHeaderClause> clauses = ClauseParser.parseStandardHeader(s);
         normalizeRequirementClauses(clauses);
         for (ClauseParser.ParsedHeaderClause clause : clauses) {
@@ -221,7 +236,7 @@
         }
     }
 
-    private void parseCapability(ResourceImpl res, String s) throws BundleException {
+    private static void parseCapability(ResourceImpl res, String s) throws BundleException {
         List<ClauseParser.ParsedHeaderClause> clauses = ClauseParser.parseStandardHeader(s);
         normalizeCapabilityClauses(clauses);
         for (ClauseParser.ParsedHeaderClause clause : clauses) {
diff --git a/resolver/src/test/java/org/apache/felix/resolver/test/Main.java b/resolver/src/test/java/org/apache/felix/resolver/test/Main.java
index 524d077..558c7c9 100644
--- a/resolver/src/test/java/org/apache/felix/resolver/test/Main.java
+++ b/resolver/src/test/java/org/apache/felix/resolver/test/Main.java
@@ -27,6 +27,14 @@
 
 import org.apache.felix.resolver.Logger;
 import org.apache.felix.resolver.ResolverImpl;
+import org.apache.felix.resolver.test.util.BundleCapability;
+import org.apache.felix.resolver.test.util.BundleRequirement;
+import org.apache.felix.resolver.test.util.GenericCapability;
+import org.apache.felix.resolver.test.util.GenericRequirement;
+import org.apache.felix.resolver.test.util.PackageCapability;
+import org.apache.felix.resolver.test.util.PackageRequirement;
+import org.apache.felix.resolver.test.util.ResolveContextImpl;
+import org.apache.felix.resolver.test.util.ResourceImpl;
 import org.osgi.framework.namespace.BundleNamespace;
 import org.osgi.framework.namespace.HostNamespace;
 import org.osgi.framework.namespace.IdentityNamespace;
diff --git a/resolver/src/test/java/org/apache/felix/resolver/test/ResolverTest.java b/resolver/src/test/java/org/apache/felix/resolver/test/ResolverTest.java
index 926b42c..bbd5ffe 100644
--- a/resolver/src/test/java/org/apache/felix/resolver/test/ResolverTest.java
+++ b/resolver/src/test/java/org/apache/felix/resolver/test/ResolverTest.java
@@ -33,7 +33,14 @@
 
 import org.apache.felix.resolver.Logger;
 import org.apache.felix.resolver.ResolverImpl;
-import org.junit.Ignore;
+import org.apache.felix.resolver.test.util.BundleCapability;
+import org.apache.felix.resolver.test.util.BundleRequirement;
+import org.apache.felix.resolver.test.util.GenericCapability;
+import org.apache.felix.resolver.test.util.GenericRequirement;
+import org.apache.felix.resolver.test.util.PackageCapability;
+import org.apache.felix.resolver.test.util.PackageRequirement;
+import org.apache.felix.resolver.test.util.ResolveContextImpl;
+import org.apache.felix.resolver.test.util.ResourceImpl;
 import org.junit.Test;
 import org.osgi.framework.Constants;
 import org.osgi.framework.namespace.BundleNamespace;
diff --git a/resolver/src/test/java/org/apache/felix/resolver/test/BundleCapability.java b/resolver/src/test/java/org/apache/felix/resolver/test/util/BundleCapability.java
similarity index 95%
rename from resolver/src/test/java/org/apache/felix/resolver/test/BundleCapability.java
rename to resolver/src/test/java/org/apache/felix/resolver/test/util/BundleCapability.java
index abc694f..a79e541 100644
--- a/resolver/src/test/java/org/apache/felix/resolver/test/BundleCapability.java
+++ b/resolver/src/test/java/org/apache/felix/resolver/test/util/BundleCapability.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.felix.resolver.test;
+package org.apache.felix.resolver.test.util;
 
 import java.util.HashMap;
 import java.util.Map;
@@ -26,7 +26,7 @@
 import org.osgi.resource.Capability;
 import org.osgi.resource.Resource;
 
-class BundleCapability implements Capability
+public class BundleCapability implements Capability
 {
     private final Resource m_resource;
     private final Map<String, String> m_dirs;
diff --git a/resolver/src/test/java/org/apache/felix/resolver/test/BundleRequirement.java b/resolver/src/test/java/org/apache/felix/resolver/test/util/BundleRequirement.java
similarity index 95%
rename from resolver/src/test/java/org/apache/felix/resolver/test/BundleRequirement.java
rename to resolver/src/test/java/org/apache/felix/resolver/test/util/BundleRequirement.java
index 4bcac26..c1e9e88 100644
--- a/resolver/src/test/java/org/apache/felix/resolver/test/BundleRequirement.java
+++ b/resolver/src/test/java/org/apache/felix/resolver/test/util/BundleRequirement.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.felix.resolver.test;
+package org.apache.felix.resolver.test.util;
 
 import java.util.HashMap;
 import java.util.Map;
@@ -26,7 +26,7 @@
 import org.osgi.resource.Requirement;
 import org.osgi.resource.Resource;
 
-class BundleRequirement implements Requirement
+public class BundleRequirement implements Requirement
 {
     private final Resource m_resource;
     private final Map<String, String> m_dirs;
diff --git a/resolver/src/test/java/org/apache/felix/resolver/test/CandidateComparator.java b/resolver/src/test/java/org/apache/felix/resolver/test/util/CandidateComparator.java
similarity index 99%
rename from resolver/src/test/java/org/apache/felix/resolver/test/CandidateComparator.java
rename to resolver/src/test/java/org/apache/felix/resolver/test/util/CandidateComparator.java
index 4ca9ef6..75021f0 100644
--- a/resolver/src/test/java/org/apache/felix/resolver/test/CandidateComparator.java
+++ b/resolver/src/test/java/org/apache/felix/resolver/test/util/CandidateComparator.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.felix.resolver.test;
+package org.apache.felix.resolver.test.util;
 
 import java.util.Comparator;
 
diff --git a/resolver/src/test/java/org/apache/felix/resolver/test/CapabilitySet.java b/resolver/src/test/java/org/apache/felix/resolver/test/util/CapabilitySet.java
similarity index 99%
rename from resolver/src/test/java/org/apache/felix/resolver/test/CapabilitySet.java
rename to resolver/src/test/java/org/apache/felix/resolver/test/util/CapabilitySet.java
index c5bd0e1..f9048ae 100644
--- a/resolver/src/test/java/org/apache/felix/resolver/test/CapabilitySet.java
+++ b/resolver/src/test/java/org/apache/felix/resolver/test/util/CapabilitySet.java
@@ -16,13 +16,12 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.felix.resolver.test;
+package org.apache.felix.resolver.test.util;
 
 import java.lang.reflect.Array;
 import java.lang.reflect.Constructor;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
diff --git a/resolver/src/test/java/org/apache/felix/resolver/test/ClauseParser.java b/resolver/src/test/java/org/apache/felix/resolver/test/util/ClauseParser.java
similarity index 98%
rename from resolver/src/test/java/org/apache/felix/resolver/test/ClauseParser.java
rename to resolver/src/test/java/org/apache/felix/resolver/test/util/ClauseParser.java
index e3357e0..cd0f421 100644
--- a/resolver/src/test/java/org/apache/felix/resolver/test/ClauseParser.java
+++ b/resolver/src/test/java/org/apache/felix/resolver/test/util/ClauseParser.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.felix.resolver.test;
+package org.apache.felix.resolver.test.util;
 
 import java.util.ArrayList;
 import java.util.LinkedHashMap;
@@ -286,7 +286,7 @@
     }
 
 
-    static class ParsedHeaderClause {
+    public static class ParsedHeaderClause {
         public final List<String> paths = new ArrayList<String>();
         public final Map<String, String> dirs = new LinkedHashMap<String, String>();
         public final Map<String, Object> attrs = new LinkedHashMap<String, Object>();
diff --git a/resolver/src/test/java/org/apache/felix/resolver/test/GenericCapability.java b/resolver/src/test/java/org/apache/felix/resolver/test/util/GenericCapability.java
similarity index 73%
rename from resolver/src/test/java/org/apache/felix/resolver/test/GenericCapability.java
rename to resolver/src/test/java/org/apache/felix/resolver/test/util/GenericCapability.java
index d805d5d..e384d1e 100644
--- a/resolver/src/test/java/org/apache/felix/resolver/test/GenericCapability.java
+++ b/resolver/src/test/java/org/apache/felix/resolver/test/util/GenericCapability.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.felix.resolver.test;
+package org.apache.felix.resolver.test.util;
 
 import java.util.HashMap;
 import java.util.Map;
@@ -24,7 +24,7 @@
 import org.osgi.resource.Capability;
 import org.osgi.resource.Resource;
 
-class GenericCapability implements Capability
+public class GenericCapability implements Capability
 {
     private final Resource m_resource;
     private final String m_namespace;
@@ -75,4 +75,26 @@
         return getNamespace() + "; "
             + getAttributes();
     }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        GenericCapability that = (GenericCapability) o;
+
+        if (!m_attrs.equals(that.m_attrs)) return false;
+        if (!m_dirs.equals(that.m_dirs)) return false;
+        if (!m_namespace.equals(that.m_namespace)) return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = m_namespace.hashCode();
+        result = 31 * result + m_dirs.hashCode();
+        result = 31 * result + m_attrs.hashCode();
+        return result;
+    }
 }
\ No newline at end of file
diff --git a/resolver/src/test/java/org/apache/felix/resolver/test/GenericRequirement.java b/resolver/src/test/java/org/apache/felix/resolver/test/util/GenericRequirement.java
similarity index 75%
rename from resolver/src/test/java/org/apache/felix/resolver/test/GenericRequirement.java
rename to resolver/src/test/java/org/apache/felix/resolver/test/util/GenericRequirement.java
index fa020fe..2973e35 100644
--- a/resolver/src/test/java/org/apache/felix/resolver/test/GenericRequirement.java
+++ b/resolver/src/test/java/org/apache/felix/resolver/test/util/GenericRequirement.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.felix.resolver.test;
+package org.apache.felix.resolver.test.util;
 
 import java.util.HashMap;
 import java.util.Map;
@@ -24,7 +24,7 @@
 import org.osgi.resource.Requirement;
 import org.osgi.resource.Resource;
 
-class GenericRequirement implements Requirement
+public class GenericRequirement implements Requirement
 {
     private final Resource m_resource;
     private final String m_namespace;
@@ -39,6 +39,20 @@
         m_attrs = new HashMap<String, Object>();
     }
 
+    public GenericRequirement(Resource resource, String namespace, Map<String, String> directives, Map<String, Object> attributes) {
+        this(resource, namespace);
+        if (directives != null) {
+            for (Map.Entry<String, String> entry : directives.entrySet()) {
+                addDirective(entry.getKey(), entry.getValue());
+            }
+        }
+        if (attributes != null) {
+            for (Map.Entry<String, Object> entry : attributes.entrySet()) {
+                addAttribute(entry.getKey(), entry.getValue());
+            }
+        }
+    }
+
     public String getNamespace()
     {
         return m_namespace;
diff --git a/resolver/src/test/java/org/apache/felix/resolver/test/IdentityCapability.java b/resolver/src/test/java/org/apache/felix/resolver/test/util/IdentityCapability.java
similarity index 89%
rename from resolver/src/test/java/org/apache/felix/resolver/test/IdentityCapability.java
rename to resolver/src/test/java/org/apache/felix/resolver/test/util/IdentityCapability.java
index adcd858..a79eb81 100644
--- a/resolver/src/test/java/org/apache/felix/resolver/test/IdentityCapability.java
+++ b/resolver/src/test/java/org/apache/felix/resolver/test/util/IdentityCapability.java
@@ -16,16 +16,17 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.felix.resolver.test;
+package org.apache.felix.resolver.test.util;
 
 import java.util.HashMap;
 import java.util.Map;
 
+import org.osgi.framework.Version;
 import org.osgi.framework.namespace.IdentityNamespace;
 import org.osgi.resource.Capability;
 import org.osgi.resource.Resource;
 
-class IdentityCapability implements Capability
+public class IdentityCapability implements Capability
 {
     private final Resource m_resource;
     private final Map<String, String> m_dirs;
@@ -38,6 +39,7 @@
         m_attrs = new HashMap<String, Object>();
         m_attrs.put(IdentityNamespace.IDENTITY_NAMESPACE, name);
         m_attrs.put(IdentityNamespace.CAPABILITY_TYPE_ATTRIBUTE, type);
+        m_attrs.put(IdentityNamespace.CAPABILITY_VERSION_ATTRIBUTE, Version.emptyVersion);
     }
 
     public String getNamespace()
diff --git a/resolver/src/test/java/org/apache/felix/resolver/test/IterativeResolver.java b/resolver/src/test/java/org/apache/felix/resolver/test/util/IterativeResolver.java
similarity index 99%
rename from resolver/src/test/java/org/apache/felix/resolver/test/IterativeResolver.java
rename to resolver/src/test/java/org/apache/felix/resolver/test/util/IterativeResolver.java
index 2055c3c..717e325 100644
--- a/resolver/src/test/java/org/apache/felix/resolver/test/IterativeResolver.java
+++ b/resolver/src/test/java/org/apache/felix/resolver/test/util/IterativeResolver.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.felix.resolver.test;
+package org.apache.felix.resolver.test.util;
 
 import java.util.ArrayList;
 import java.util.Collection;
diff --git a/resolver/src/test/java/org/apache/felix/resolver/test/JsonReader.java b/resolver/src/test/java/org/apache/felix/resolver/test/util/JsonReader.java
similarity index 99%
rename from resolver/src/test/java/org/apache/felix/resolver/test/JsonReader.java
rename to resolver/src/test/java/org/apache/felix/resolver/test/util/JsonReader.java
index df48e42..3eb7075 100644
--- a/resolver/src/test/java/org/apache/felix/resolver/test/JsonReader.java
+++ b/resolver/src/test/java/org/apache/felix/resolver/test/util/JsonReader.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.felix.resolver.test;
+package org.apache.felix.resolver.test.util;
 
 import java.io.IOException;
 import java.io.InputStream;
@@ -24,7 +24,6 @@
 import java.io.Reader;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.Map;
 
diff --git a/resolver/src/test/java/org/apache/felix/resolver/test/PackageCapability.java b/resolver/src/test/java/org/apache/felix/resolver/test/util/PackageCapability.java
similarity index 95%
rename from resolver/src/test/java/org/apache/felix/resolver/test/PackageCapability.java
rename to resolver/src/test/java/org/apache/felix/resolver/test/util/PackageCapability.java
index c672ada..452d85d 100644
--- a/resolver/src/test/java/org/apache/felix/resolver/test/PackageCapability.java
+++ b/resolver/src/test/java/org/apache/felix/resolver/test/util/PackageCapability.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.felix.resolver.test;
+package org.apache.felix.resolver.test.util;
 
 import java.util.HashMap;
 import java.util.Map;
@@ -25,7 +25,7 @@
 import org.osgi.resource.Capability;
 import org.osgi.resource.Resource;
 
-class PackageCapability implements Capability
+public class PackageCapability implements Capability
 {
     private final Resource m_resource;
     private final Map<String, String> m_dirs;
diff --git a/resolver/src/test/java/org/apache/felix/resolver/test/PackageRequirement.java b/resolver/src/test/java/org/apache/felix/resolver/test/util/PackageRequirement.java
similarity index 95%
rename from resolver/src/test/java/org/apache/felix/resolver/test/PackageRequirement.java
rename to resolver/src/test/java/org/apache/felix/resolver/test/util/PackageRequirement.java
index eaf6a9b..5d4422a 100644
--- a/resolver/src/test/java/org/apache/felix/resolver/test/PackageRequirement.java
+++ b/resolver/src/test/java/org/apache/felix/resolver/test/util/PackageRequirement.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.felix.resolver.test;
+package org.apache.felix.resolver.test.util;
 
 import java.util.HashMap;
 import java.util.Map;
@@ -25,7 +25,7 @@
 import org.osgi.resource.Requirement;
 import org.osgi.resource.Resource;
 
-class PackageRequirement implements Requirement
+public class PackageRequirement implements Requirement
 {
     private final Resource m_resource;
     private final Map<String, String> m_dirs;
diff --git a/resolver/src/test/java/org/apache/felix/resolver/test/ResolveContextImpl.java b/resolver/src/test/java/org/apache/felix/resolver/test/util/ResolveContextImpl.java
similarity index 95%
rename from resolver/src/test/java/org/apache/felix/resolver/test/ResolveContextImpl.java
rename to resolver/src/test/java/org/apache/felix/resolver/test/util/ResolveContextImpl.java
index 2a5f112..0870349 100644
--- a/resolver/src/test/java/org/apache/felix/resolver/test/ResolveContextImpl.java
+++ b/resolver/src/test/java/org/apache/felix/resolver/test/util/ResolveContextImpl.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.felix.resolver.test;
+package org.apache.felix.resolver.test.util;
 
 import java.util.ArrayList;
 import java.util.Collection;
@@ -29,7 +29,7 @@
 import org.osgi.service.resolver.HostedCapability;
 import org.osgi.service.resolver.ResolveContext;
 
-class ResolveContextImpl extends ResolveContext
+public class ResolveContextImpl extends ResolveContext
 {
     private final Map<Resource, Wiring> m_wirings;
     private final Map<Requirement, List<Capability>> m_candMap;
diff --git a/resolver/src/test/java/org/apache/felix/resolver/test/ResourceImpl.java b/resolver/src/test/java/org/apache/felix/resolver/test/util/ResourceImpl.java
similarity index 86%
rename from resolver/src/test/java/org/apache/felix/resolver/test/ResourceImpl.java
rename to resolver/src/test/java/org/apache/felix/resolver/test/util/ResourceImpl.java
index 2e4febe..226c43b 100644
--- a/resolver/src/test/java/org/apache/felix/resolver/test/ResourceImpl.java
+++ b/resolver/src/test/java/org/apache/felix/resolver/test/util/ResourceImpl.java
@@ -16,10 +16,13 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.felix.resolver.test;
+package org.apache.felix.resolver.test.util;
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.List;
+
+import org.apache.felix.resolver.test.util.IdentityCapability;
 import org.osgi.framework.namespace.IdentityNamespace;
 import org.osgi.resource.Capability;
 import org.osgi.resource.Requirement;
@@ -93,4 +96,16 @@
     {
         return getCapabilities(IdentityNamespace.IDENTITY_NAMESPACE).get(0).toString();
     }
+
+    public void addCapabilities(Collection<Capability> caps) {
+        for (Capability cap : caps) {
+            addCapability(cap);
+        }
+    }
+
+    public void addRequirements(Collection<Requirement> reqs) {
+        for (Requirement req : reqs) {
+            addRequirement(req);
+        }
+    }
 }
\ No newline at end of file
diff --git a/resolver/src/test/java/org/apache/felix/resolver/test/SimpleFilter.java b/resolver/src/test/java/org/apache/felix/resolver/test/util/SimpleFilter.java
similarity index 99%
rename from resolver/src/test/java/org/apache/felix/resolver/test/SimpleFilter.java
rename to resolver/src/test/java/org/apache/felix/resolver/test/util/SimpleFilter.java
index cf7b820..5e71c04 100644
--- a/resolver/src/test/java/org/apache/felix/resolver/test/SimpleFilter.java
+++ b/resolver/src/test/java/org/apache/felix/resolver/test/util/SimpleFilter.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.felix.resolver.test;
+package org.apache.felix.resolver.test.util;
 
 import java.util.ArrayList;
 import java.util.List;