Search in sources :

Example 16 with VersionRange

use of org.osgi.framework.VersionRange in project aries by apache.

the class Aries1427Test method testRequirementConversionWithVersionPresence.

@Test
public void testRequirementConversionWithVersionPresence() {
    VersionRange range = VersionRange.valueOf("(1.0,2.0)");
    String filter = new StringBuilder().append("(&(").append(PackageNamespace.PACKAGE_NAMESPACE).append("=com.acme.tnt").append(')').append(range.toFilterString(PackageNamespace.CAPABILITY_VERSION_ATTRIBUTE)).append(')').toString();
    Requirement requirement = new BasicRequirement.Builder().namespace(PackageNamespace.PACKAGE_NAMESPACE).directive(PackageNamespace.REQUIREMENT_FILTER_DIRECTIVE, filter).resource(new Resource() {

        @Override
        public List<Capability> getCapabilities(String namespace) {
            return Collections.emptyList();
        }

        @Override
        public List<Requirement> getRequirements(String namespace) {
            return Collections.emptyList();
        }
    }).build();
    ImportPackageHeader.Clause expected = new ImportPackageHeader.Clause("com.acme.tnt;version=\"(1.0,2.0)\"");
    ImportPackageHeader.Clause actual = ImportPackageHeader.Clause.valueOf(requirement);
    assertEquals("Wrong clause", expected, actual);
}
Also used : Requirement(org.osgi.resource.Requirement) BasicRequirement(org.apache.aries.subsystem.core.internal.BasicRequirement) Capability(org.osgi.resource.Capability) Resource(org.osgi.resource.Resource) VersionRange(org.osgi.framework.VersionRange) Test(org.junit.Test)

Example 17 with VersionRange

use of org.osgi.framework.VersionRange in project aries by apache.

the class FragmentHostHeaderTest method testBundleVersionRange.

@Test
public void testBundleVersionRange() {
    String headerStr = "com.acme.support;bundle-version=\"[2.0,3.0)\"";
    FragmentHostHeader header = new FragmentHostHeader(headerStr);
    assertClauses(header, 1);
    assertSymbolicName(header.getClauses().iterator().next(), "com.acme.support");
    assertBundleVersionAttribute(header.getClauses().iterator().next(), new VersionRange(VersionRange.LEFT_CLOSED, new Version("2.0"), new Version("3.0"), VersionRange.RIGHT_OPEN));
}
Also used : Version(org.osgi.framework.Version) VersionRange(org.osgi.framework.VersionRange) Test(org.junit.Test)

Example 18 with VersionRange

use of org.osgi.framework.VersionRange in project tycho by eclipse.

the class DefaultVersionRangeUpdateStrategy method computeNewVersionRange.

@Override
public String computeNewVersionRange(String originalVersionRange, String originalReferencedVersion, String newReferencedVersion) {
    if (originalVersionRange == null) {
        return null;
    }
    VersionRange originalVersionRangeObject = VersionRange.valueOf(originalVersionRange);
    Version originalReferencedVersionObject = parseBaseVersion(originalReferencedVersion);
    Version newReferencedVersionObject = parseBaseVersion(newReferencedVersion);
    Version newArtifactVersion = Version.valueOf(newReferencedVersion);
    VersionRange newVersionRangeObject = computeNewVersionRange(originalVersionRangeObject, originalReferencedVersionObject, newReferencedVersionObject, newArtifactVersion);
    return newVersionRangeObject.toString();
}
Also used : Version(org.osgi.framework.Version) VersionRange(org.osgi.framework.VersionRange)

Aggregations

VersionRange (org.osgi.framework.VersionRange)18 Version (org.osgi.framework.Version)7 HashMap (java.util.HashMap)4 Test (org.junit.Test)4 Map (java.util.Map)3 ManifestElement (org.eclipse.osgi.util.ManifestElement)3 File (java.io.File)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 ZipFile (org.apache.commons.compress.archivers.zip.ZipFile)2 Requirement (org.osgi.resource.Requirement)2 Artifact (io.fabric8.patch.management.Artifact)1 Artifact.isSameButVersion (io.fabric8.patch.management.Artifact.isSameButVersion)1 LinkedHashMap (java.util.LinkedHashMap)1 LinkedList (java.util.LinkedList)1 Matcher (java.util.regex.Matcher)1 SimpleFilter (org.apache.aries.subsystem.core.capabilityset.SimpleFilter)1 BasicRequirement (org.apache.aries.subsystem.core.internal.BasicRequirement)1 LocationPattern (org.apache.karaf.features.LocationPattern)1 BundleReplacements (org.apache.karaf.features.internal.model.processing.BundleReplacements)1