[FELIX-2278] refactor features-maven-plugin to use Parser/Clause/VersionRange from utils
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@933859 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/karaf/tooling/features-maven-plugin/src/main/java/org/apache/felix/karaf/tooling/features/GenerateFeaturesFileMojo.java b/karaf/tooling/features-maven-plugin/src/main/java/org/apache/felix/karaf/tooling/features/GenerateFeaturesFileMojo.java
index 5df9947..4562b8b 100644
--- a/karaf/tooling/features-maven-plugin/src/main/java/org/apache/felix/karaf/tooling/features/GenerateFeaturesFileMojo.java
+++ b/karaf/tooling/features-maven-plugin/src/main/java/org/apache/felix/karaf/tooling/features/GenerateFeaturesFileMojo.java
@@ -36,6 +36,7 @@
import java.util.Properties;
import java.util.Set;
import java.util.TreeSet;
+import java.util.jar.Manifest;
import java.util.zip.ZipEntry;
import java.util.zip.ZipException;
import java.util.zip.ZipFile;
@@ -53,7 +54,6 @@
import org.apache.maven.model.Dependency;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
-import org.osgi.impl.bundle.obr.resource.Manifest;
/**
* Generates the features XML file
@@ -409,9 +409,9 @@
ZipFile file = new ZipFile(artifact.getFile());
ZipEntry entry = file.getEntry("META-INF/MANIFEST.MF");
Manifest manifest = new Manifest(file.getInputStream(entry));
- if (manifest.getBsn() != null) {
+ if (ManifestUtils.isBundle(manifest)) {
getLog().debug(String.format("MANIFEST.MF for '%s' contains Bundle-Name '%s'",
- artifact, manifest.getBsn().getName()));
+ artifact, ManifestUtils.getBsn(manifest)));
return true;
}
} catch (ZipException e) {
diff --git a/karaf/tooling/features-maven-plugin/src/main/java/org/apache/felix/karaf/tooling/features/GenerateFeaturesXmlMojo.java b/karaf/tooling/features-maven-plugin/src/main/java/org/apache/felix/karaf/tooling/features/GenerateFeaturesXmlMojo.java
index d8ce42d..6e6092c 100644
--- a/karaf/tooling/features-maven-plugin/src/main/java/org/apache/felix/karaf/tooling/features/GenerateFeaturesXmlMojo.java
+++ b/karaf/tooling/features-maven-plugin/src/main/java/org/apache/felix/karaf/tooling/features/GenerateFeaturesXmlMojo.java
@@ -33,9 +33,12 @@
import java.util.Properties;
import java.util.Set;
import java.util.Stack;
+import java.util.jar.Manifest;
import java.util.zip.ZipException;
import java.util.zip.ZipFile;
+import org.apache.felix.utils.manifest.Clause;
+import org.apache.felix.utils.version.VersionRange;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.InvalidArtifactRTException;
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
@@ -50,9 +53,7 @@
import org.apache.maven.shared.dependency.tree.DependencyTreeBuilder;
import org.apache.maven.shared.dependency.tree.DependencyTreeBuilderException;
import org.apache.maven.shared.dependency.tree.traversal.DependencyNodeVisitor;
-import org.osgi.impl.bundle.obr.resource.Manifest;
-import org.osgi.impl.bundle.obr.resource.ManifestEntry;
-import org.osgi.impl.bundle.obr.resource.VersionRange;
+
/**
* Generates the features XML file
@@ -225,11 +226,9 @@
private void registerKernelBundle(Artifact artifact) throws ArtifactResolutionException, ArtifactNotFoundException, ZipException,
IOException {
Manifest manifest = getManifest(artifact);
- if (manifest.getExports() != null) {
- for (ManifestEntry entry : (List<ManifestEntry>)manifest.getExports()) {
- kernelExports.put(entry.getName(), entry.getVersion());
- getLog().debug(" adding kernel export " + entry.getName() + " (" + entry.getVersion() + ")");
- }
+ for (Clause clause : ManifestUtils.getExports(manifest)) {
+ kernelExports.put(clause.getName(), ManifestUtils.getVersionRange(clause));
+ getLog().debug(" adding kernel export " + clause.getName() + " (" + ManifestUtils.getVersionRange(clause) + ")");
}
registerBundle(artifact);
}
@@ -346,9 +345,9 @@
} else {
try {
Manifest manifest = getManifest(artifact);
- if (manifest.getBsn() != null) {
+ if (ManifestUtils.getBsn(manifest) != null) {
getLog().debug(String.format("MANIFEST.MF for '%s' contains Bundle-Name '%s'",
- artifact, manifest.getBsn().getName()));
+ artifact, ManifestUtils.getBsn(manifest)));
return true;
}
} catch (ZipException e) {
@@ -367,29 +366,29 @@
*/
private void addRequirements(Artifact artifact, Feature feature) throws ArtifactResolutionException, ArtifactNotFoundException, ZipException, IOException {
Manifest manifest = getManifest(artifact);
- Collection<ManifestEntry> remaining = getRemainingImports(manifest);
+ Collection<Clause> remaining = getRemainingImports(manifest);
Artifact previous = null;
- for (ManifestEntry entry : remaining) {
+ for (Clause clause : remaining) {
Artifact add = null;
- Map<VersionRange, Artifact> versions = bundleExports.get(entry.getName());
+ Map<VersionRange, Artifact> versions = bundleExports.get(clause.getName());
if (versions != null) {
for (VersionRange range : versions.keySet()) {
add = versions.get(range);
- if (range.compareTo(entry.getVersion()) == 0) {
+ if (range.intersect(ManifestUtils.getVersionRange(clause)) != null) {
add = versions.get(range);
}
}
}
if (add == null) {
- if (isOptional(entry)) {
+ if (ManifestUtils.isOptional(clause)) {
// debug logging for optional dependency...
getLog().debug(String.format(" Unable to find suitable bundle for optional dependency %s (%s)",
- entry.getName(), entry.getVersion()));
+ clause.getName(), ManifestUtils.getVersionRange(clause)));
} else {
// ...but a warning for a mandatory dependency
getLog().warn(
String.format(" Unable to find suitable bundle for dependency %s (%s) (required by %s)",
- entry.getName(), entry.getVersion(), artifact.getArtifactId()));
+ clause.getName(), ManifestUtils.getVersionRange(clause), artifact.getArtifactId()));
}
} else {
if (!add.equals(previous) && feature.push(add) && !isFeature(add)) {
@@ -409,14 +408,7 @@
return features.containsKey(artifact);
}
- /*
- * Check a manifest entry and check if the resolution for the import has been marked as optional
- */
- private boolean isOptional(ManifestEntry entry) {
- return entry.getAttributes() != null && entry.getAttributes().get("resolution:") != null
- && entry.getAttributes().get("resolution:").equals("optional");
- }
-
+
/*
* Register a bundle, enlisting all packages it provides
*/
@@ -425,14 +417,14 @@
getLog().debug("Registering bundle " + artifact);
knownBundles.add(toString(artifact));
Manifest manifest = getManifest(artifact);
- for (ManifestEntry entry : getManifestEntries(manifest.getExports())) {
- Map<VersionRange, Artifact> versions = bundleExports.get(entry.getName());
+ for (Clause clause : getManifestEntries(ManifestUtils.getExports(manifest))) {
+ Map<VersionRange, Artifact> versions = bundleExports.get(clause.getName());
if (versions == null) {
versions = new HashMap<VersionRange, Artifact>();
}
- versions.put(entry.getVersion(), artifact);
- getLog().debug(String.format(" %s exported by bundle %s", entry.getName(), artifact));
- bundleExports.put(entry.getName(), versions);
+ versions.put(ManifestUtils.getVersionRange(clause), artifact);
+ getLog().debug(String.format(" %s exported by bundle %s", clause.getName(), artifact));
+ bundleExports.put(clause.getName(), versions);
}
}
@@ -448,40 +440,40 @@
/*
* Determine the list of imports to be resolved
*/
- private Collection<ManifestEntry> getRemainingImports(Manifest manifest) {
+ private Collection<Clause> getRemainingImports(Manifest manifest) {
// take all imports
- Collection<ManifestEntry> input = getManifestEntries(manifest.getImports());
- Collection<ManifestEntry> output = new LinkedList<ManifestEntry>(input);
+ Collection<Clause> input = getManifestEntries(ManifestUtils.getImports(manifest));
+ Collection<Clause> output = new LinkedList<Clause>(input);
// remove imports satisfied by exports in the same bundle
- for (ManifestEntry entry : input) {
- for (ManifestEntry export : getManifestEntries(manifest.getExports())) {
- if (entry.getName().equals(export.getName())) {
- output.remove(entry);
+ for (Clause clause : input) {
+ for (Clause export : getManifestEntries(ManifestUtils.getExports(manifest))) {
+ if (clause.getName().equals(export.getName())) {
+ output.remove(clause);
}
}
}
// remove imports for packages exported by the kernel
- for (ManifestEntry entry : input) {
+ for (Clause clause : input) {
for (String export : kernelExports.keySet()) {
- if (entry.getName().equals(export)) {
- output.remove(entry);
+ if (clause.getName().equals(export)) {
+ output.remove(clause);
}
}
}
// remove imports for packages exported by the system bundle
- for (ManifestEntry entry : input) {
- if (systemExports.contains(entry.getName())) {
- output.remove(entry);
+ for (Clause clause : input) {
+ if (systemExports.contains(clause.getName())) {
+ output.remove(clause);
}
}
return output;
}
- private Collection<ManifestEntry> getManifestEntries(List imports) {
+ private Collection<Clause> getManifestEntries(List imports) {
if (imports == null) {
- return new LinkedList<ManifestEntry>();
+ return new LinkedList<Clause>();
} else {
- return (Collection<ManifestEntry>)imports;
+ return (Collection<Clause>)imports;
}
}
diff --git a/karaf/tooling/features-maven-plugin/src/main/java/org/apache/felix/karaf/tooling/features/ManifestUtils.java b/karaf/tooling/features-maven-plugin/src/main/java/org/apache/felix/karaf/tooling/features/ManifestUtils.java
index f5f1739..d21a3d9 100644
--- a/karaf/tooling/features-maven-plugin/src/main/java/org/apache/felix/karaf/tooling/features/ManifestUtils.java
+++ b/karaf/tooling/features-maven-plugin/src/main/java/org/apache/felix/karaf/tooling/features/ManifestUtils.java
@@ -19,14 +19,19 @@
import java.util.LinkedList;
import java.util.List;
+import java.util.jar.Manifest;
-import org.osgi.impl.bundle.obr.resource.Manifest;
-import org.osgi.impl.bundle.obr.resource.ManifestEntry;
+import org.apache.felix.utils.manifest.Clause;
+import org.apache.felix.utils.manifest.Parser;
+import org.apache.felix.utils.version.VersionRange;
+import org.osgi.framework.Constants;
+
/**
- * A set of utility methods to ease working with {@link org.osgi.impl.bundle.obr.resource.Manifest} and
- * {@link org.osgi.impl.bundle.obr.resource.ManifestEntry}
+ * A set of utility methods to ease working with {@link org.apache.felix.utils.manifest.Parser} and
+ * {@link org.apache.felix.utils.manifest.Clause}
*/
+
public class ManifestUtils {
private ManifestUtils() {
@@ -39,12 +44,13 @@
* @param manifest the manifest
* @return the list of imports
*/
- public static List<ManifestEntry> getImports(Manifest manifest) {
- if (manifest.getImports() == null) {
- return new LinkedList<ManifestEntry>();
- } else {
- return manifest.getImports();
- }
+ public static List<Clause> getImports(Manifest manifest) {
+ List<Clause> result = new LinkedList<Clause>();
+ Clause[] clauses = Parser.parseHeader(getHeader(Constants.IMPORT_PACKAGE, manifest));
+ for (Clause clause : clauses) {
+ result.add(clause);
+ }
+ return result;
}
/**
@@ -53,11 +59,11 @@
* @param manifest the manifest
* @return the list of non-optional imports
*/
- public static List<ManifestEntry> getMandatoryImports(Manifest manifest) {
- List<ManifestEntry> result = new LinkedList<ManifestEntry>();
- for (ManifestEntry entry : getImports(manifest)) {
- if (!isOptional(entry)) {
- result.add(entry);
+ public static List<Clause> getMandatoryImports(Manifest manifest) {
+ List<Clause> result = new LinkedList<Clause>();
+ for (Clause clause : getImports(manifest)) {
+ if (!isOptional(clause)) {
+ result.add(clause);
}
}
return result;
@@ -69,22 +75,23 @@
* @param manifest the manifest
* @return the list of exports
*/
- public static List<ManifestEntry> getExports(Manifest manifest) {
- if (manifest.getExports() == null) {
- return new LinkedList<ManifestEntry>();
- } else {
- return manifest.getExports();
- }
+ public static List<Clause> getExports(Manifest manifest) {
+ List<Clause> result = new LinkedList<Clause>();
+ Clause[] clauses = Parser.parseHeader(getHeader(Constants.EXPORT_PACKAGE, manifest));
+ for (Clause clause : clauses) {
+ result.add(clause);
+ }
+ return result;
}
/**
- * Check if a given manifest entry represents an optional import
+ * Check if a given manifest clause represents an optional import
*
- * @param entry the manifest entry
+ * @param clause the manifest clause
* @return <code>true</code> for an optional import, <code>false</code> for mandatory imports
*/
- public static boolean isOptional(ManifestEntry entry) {
- return "optional".equals(entry.getDirective("resolution"));
+ public static boolean isOptional(Clause clause) {
+ return "optional".equals(clause.getDirective("resolution"));
}
/**
@@ -94,17 +101,40 @@
* @return <code>true</code> if the manifest specifies a Bundle-Symbolic-Name
*/
public static boolean isBundle(Manifest manifest) {
- return manifest.getBsn() != null;
+ return getBsn(manifest) != null;
}
- public static boolean matches(ManifestEntry requirement, ManifestEntry export) {
+ public static boolean matches(Clause requirement, Clause export) {
if (requirement.getName().equals(export.getName())) {
- if (requirement.getVersion().isRange()) {
- return requirement.getVersion().compareTo(export.getVersion()) == 0;
- } else {
- return requirement.getVersion().compareTo(export.getVersion()) <= 0;
- }
+ VersionRange importVersionRange = getVersionRange(requirement);
+ VersionRange exportVersionRange = getVersionRange(export);
+ VersionRange intersection = importVersionRange.intersect(exportVersionRange);
+ return intersection != null;
}
return false;
}
+
+ public static String getHeader(String name, Manifest manifest) {
+ String value = manifest.getMainAttributes().getValue(name);
+ return value;
+ }
+
+ public static String getBsn(Manifest manifest) {
+ String bsn = getHeader(Constants.BUNDLE_SYMBOLICNAME, manifest);
+ return bsn;
+ }
+
+ public static VersionRange getVersionRange(Clause clause)
+ {
+ String v = clause.getAttribute(Constants.VERSION_ATTRIBUTE);
+ if (v == null)
+ {
+ v = clause.getAttribute(Constants.PACKAGE_SPECIFICATION_VERSION);
+ }
+ if (v == null)
+ {
+ v = clause.getAttribute(Constants.BUNDLE_VERSION_ATTRIBUTE);
+ }
+ return VersionRange.parseVersionRange(v);
+ }
}
diff --git a/karaf/tooling/features-maven-plugin/src/main/java/org/apache/felix/karaf/tooling/features/ValidateFeaturesMojo.java b/karaf/tooling/features-maven-plugin/src/main/java/org/apache/felix/karaf/tooling/features/ValidateFeaturesMojo.java
index bdea817..fc3fe0a 100644
--- a/karaf/tooling/features-maven-plugin/src/main/java/org/apache/felix/karaf/tooling/features/ValidateFeaturesMojo.java
+++ b/karaf/tooling/features-maven-plugin/src/main/java/org/apache/felix/karaf/tooling/features/ValidateFeaturesMojo.java
@@ -24,12 +24,14 @@
import java.io.*;
import java.net.URI;
import java.util.*;
+import java.util.jar.Manifest;
import java.util.zip.ZipException;
import java.util.zip.ZipFile;
import org.apache.felix.karaf.features.Feature;
import org.apache.felix.karaf.features.Repository;
import org.apache.felix.karaf.features.internal.RepositoryImpl;
+import org.apache.felix.utils.manifest.Clause;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.DefaultArtifactRepository;
@@ -43,8 +45,6 @@
import org.apache.maven.shared.dependency.tree.DependencyNode;
import org.apache.maven.shared.dependency.tree.DependencyTreeBuilder;
import org.apache.maven.shared.dependency.tree.traversal.DependencyNodeVisitor;
-import org.osgi.impl.bundle.obr.resource.Manifest;
-import org.osgi.impl.bundle.obr.resource.ManifestEntry;
/**
* Validates a features XML file
@@ -96,7 +96,7 @@
/*
* The packages exported by the features themselves -- useful when features depend on other features
*/
- private Map<String, Set<ManifestEntry>> featureExports = new HashMap<String, Set<ManifestEntry>>();
+ private Map<String, Set<Clause>> featureExports = new HashMap<String, Set<Clause>>();
/*
* The set of packages exported by the system bundle and by Karaf itself
@@ -190,9 +190,9 @@
info(" scanning %s for exports", artifact);
if (Artifact.SCOPE_PROVIDED.equals(artifact.getScope()) && !artifact.getType().equals("pom")) {
try {
- for (ManifestEntry entry : ManifestUtils.getExports(getManifest(artifact))) {
- getLog().debug(" adding " + entry.getName() + " to list of available packages");
- systemExports.add(entry.getName());
+ for (Clause clause : ManifestUtils.getExports(getManifest(artifact))) {
+ getLog().debug(" adding " + clause.getName() + " to list of available packages");
+ systemExports.add(clause.getName());
}
} catch (ArtifactResolutionException e) {
error("Unable to find bundle exports for %s: %s", e, artifact, e.getMessage());
@@ -228,7 +228,7 @@
*/
private void analyzeExports(Repository repository) throws Exception {
for (Feature feature : repository.getFeatures()) {
- Set<ManifestEntry> exports = new HashSet<ManifestEntry>();
+ Set<Clause> exports = new HashSet<Clause>();
for (String bundle : feature.getBundles()) {
exports.addAll(getExports(getManifest(bundles.get(bundle))));
}
@@ -271,8 +271,8 @@
* Validate if all imports for a feature are being matched with exports
*/
private void validateImportsExports(Feature feature) throws Exception {
- Map<ManifestEntry, String> imports = new HashMap<ManifestEntry, String>();
- Set<ManifestEntry> exports = new HashSet<ManifestEntry>();
+ Map<Clause, String> imports = new HashMap<Clause, String>();
+ Set<Clause> exports = new HashSet<Clause>();
for (Feature dependency : feature.getDependencies()) {
if (featureExports.containsKey(dependency.getName())) {
exports.addAll(featureExports.get(dependency.getName()));
@@ -283,23 +283,23 @@
for (String bundle : feature.getBundles()) {
Manifest meta = manifests.get(bundles.get(bundle));
exports.addAll(getExports(meta));
- for (ManifestEntry entry : getMandatoryImports(meta)) {
- imports.put(entry, bundle);
+ for (Clause clause : getMandatoryImports(meta)) {
+ imports.put(clause, bundle);
}
}
// setting up the set of required imports
- Set<ManifestEntry> requirements = new HashSet<ManifestEntry>();
+ Set<Clause> requirements = new HashSet<Clause>();
requirements.addAll(imports.keySet());
// now, let's remove requirements whenever we find a matching export for them
- for (ManifestEntry element : imports.keySet()) {
+ for (Clause element : imports.keySet()) {
if (systemExports.contains(element.getName())) {
debug("%s is resolved by a system bundle export or provided bundle", element);
requirements.remove(element);
continue;
}
- for (ManifestEntry export : exports) {
+ for (Clause export : exports) {
if (matches(element, export)) {
debug("%s is resolved by export %s", element, export);
requirements.remove(element);
@@ -312,7 +312,7 @@
// if there are any more requirements left here, there's a problem with the feature
if (!requirements.isEmpty()) {
warn("Failed to validate feature %s", feature.getName());
- for (ManifestEntry entry : requirements) {
+ for (Clause entry : requirements) {
warn("No export found to match %s (imported by %s)",
entry, imports.get(entry));
}
diff --git a/karaf/tooling/features-maven-plugin/src/test/java/org/apache/felix/karaf/tooling/features/ManifestUtilsTest.java b/karaf/tooling/features-maven-plugin/src/test/java/org/apache/felix/karaf/tooling/features/ManifestUtilsTest.java
index 07b869c..efa1136 100644
--- a/karaf/tooling/features-maven-plugin/src/test/java/org/apache/felix/karaf/tooling/features/ManifestUtilsTest.java
+++ b/karaf/tooling/features-maven-plugin/src/test/java/org/apache/felix/karaf/tooling/features/ManifestUtilsTest.java
@@ -20,51 +20,62 @@
import static org.apache.felix.karaf.tooling.features.ManifestUtils.matches;
import junit.framework.TestCase;
-import org.osgi.impl.bundle.obr.resource.ManifestEntry;
-import org.osgi.impl.bundle.obr.resource.VersionRange;
import java.util.HashMap;
+import org.apache.felix.utils.manifest.Attribute;
+import org.apache.felix.utils.manifest.Clause;
+import org.apache.felix.utils.manifest.Directive;
+import org.osgi.framework.Constants;
+
/**
* Test cased for {@link org.apache.felix.karaf.tooling.features.ManifestUtils}
*/
public class ManifestUtilsTest extends TestCase {
public void testIsOptional() {
- ManifestEntry entry = new ManifestEntry("org.apache.karaf.test");
- assertFalse(ManifestUtils.isOptional(entry));
+ Directive[] directive = new Directive[0];
+ Attribute[] attribute = new Attribute[0];
+ Clause clause = new Clause("org.apache.karaf.test", directive, attribute);
+ assertFalse(ManifestUtils.isOptional(clause));
- entry.directives = new HashMap();
- assertFalse(ManifestUtils.isOptional(entry));
+ directive = new Directive[1];
+ directive[0] = new Directive("resolution", "mandatory");
+ clause = new Clause("org.apache.karaf.test", directive, attribute);
+
+ assertFalse(ManifestUtils.isOptional(clause));
- entry.directives.put("resolution", "mandatory");
- assertFalse(ManifestUtils.isOptional(entry));
-
- entry.directives.put("resolution", "optional");
- assertTrue(ManifestUtils.isOptional(entry));
+ directive[0] = new Directive("resolution", "optional");
+ clause = new Clause("org.apache.karaf.test", directive, attribute);
+ assertTrue(ManifestUtils.isOptional(clause));
}
public void testMatches() {
- assertFalse(matches(entry("org.apache.karaf.dev"), entry("org.apache.karaf.test")));
- assertTrue(matches(entry("org.apache.karaf.test"), entry("org.apache.karaf.test")));
+ assertFalse(matches(clause("org.apache.karaf.dev"), clause("org.apache.karaf.test")));
+ assertTrue(matches(clause("org.apache.karaf.test"), clause("org.apache.karaf.test")));
- assertFalse(matches(entry("org.apache.karaf.test", "1.2.0"), entry("org.apache.karaf.test", "1.1.0")));
- assertTrue(matches(entry("org.apache.karaf.test", "1.1.0"), entry("org.apache.karaf.test", "1.1.0")));
+ assertFalse(matches(clause("org.apache.karaf.test", "1.2.0"), clause("org.apache.karaf.test", "[1.1.0, 1.1.0]")));
+ assertTrue(matches(clause("org.apache.karaf.test", "1.1.0"), clause("org.apache.karaf.test", "[1.1.0, 1.1.0]")));
// a single version means >= 1.0.0, so 1.1.O should be a match
- assertTrue(matches(entry("org.apache.karaf.test", "1.0.0"), entry("org.apache.karaf.test", "1.1.0")));
+ assertTrue(matches(clause("org.apache.karaf.test", "1.0.0"), clause("org.apache.karaf.test", "1.1.0")));
+ assertTrue(matches(clause("org.apache.karaf.test", "1.0.0"), clause("org.apache.karaf.test")));
- assertFalse(matches(entry("org.apache.karaf.test", "[1.1.0, 1.2.0)"), entry("org.apache.karaf.test", "1.0.0")));
- assertFalse(matches(entry("org.apache.karaf.test", "[1.1.0, 1.2.0)"), entry("org.apache.karaf.test", "1.2.0")));
- assertTrue(matches(entry("org.apache.karaf.test", "[1.1.0, 1.2.0)"), entry("org.apache.karaf.test", "1.1.0")));
- assertTrue(matches(entry("org.apache.karaf.test", "[1.1.0, 1.2.0)"), entry("org.apache.karaf.test", "1.1.1")));
+ assertFalse(matches(clause("org.apache.karaf.test", "[1.1.0, 1.2.0)"), clause("org.apache.karaf.test", "[1.0.0, 1.0.0]")));
+ assertFalse(matches(clause("org.apache.karaf.test", "[1.1.0, 1.2.0)"), clause("org.apache.karaf.test", "[1.2.0, 1.2.0]")));
+ assertTrue(matches(clause("org.apache.karaf.test", "[1.1.0, 1.2.0)"), clause("org.apache.karaf.test", "[1.1.0, 1.1.0]")));
+ assertTrue(matches(clause("org.apache.karaf.test", "[1.1.0, 1.2.0)"), clause("org.apache.karaf.test", "[1.1.1, 1.1.1]")));
+ assertTrue(matches(clause("org.apache.karaf.test", "[1.1.0, 1.1.0]"), clause("org.apache.karaf.test", "[1.1.0, 1.1.0]")));
+ assertFalse(matches(clause("org.apache.karaf.test", "[1.1.0, 1.1.0]"), clause("org.apache.karaf.test", "1.1.1")));
+ assertTrue(matches(clause("org.apache.karaf.test", "[1.1.0, 1.1.0]"), clause("org.apache.karaf.test", "1.0.0")));
}
- private ManifestEntry entry(String name) {
- return new ManifestEntry(name);
+ private Clause clause(String name) {
+ return new Clause(name, new Directive[0], new Attribute[0]);
}
- private ManifestEntry entry(String name, String version) {
- return new ManifestEntry(name, new VersionRange(version));
+ private Clause clause(String name, String version) {
+ Attribute[] attribute = {new Attribute(Constants.VERSION_ATTRIBUTE, version)};
+ return new Clause(name, new Directive[0], attribute);
}
}