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);
}
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));
}
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();
}
Aggregations