use of org.apache.aries.util.VersionRange in project aries by apache.
the class PackageRequirementMergerTest method isEqual.
private static boolean isEqual(Collection<ImportedPackage> reqs1, Collection<ImportedPackage> reqs2) {
boolean result = true;
if (reqs1.size() != reqs2.size()) {
result = false;
} else {
for (ImportedPackage r1 : reqs1) {
boolean foundMatch = false;
for (ImportedPackage r2 : reqs2) {
if (!r1.getPackageName().equals(r2.getPackageName())) {
continue;
}
if (r1.isOptional() != r2.isOptional()) {
continue;
}
Map<String, String> attribs1 = new HashMap<String, String>(r1.getAttributes());
Map<String, String> attribs2 = new HashMap<String, String>(r2.getAttributes());
VersionRange v1 = ManifestHeaderProcessor.parseVersionRange(attribs1.remove(Constants.VERSION_ATTRIBUTE));
VersionRange v2 = ManifestHeaderProcessor.parseVersionRange(attribs2.remove(Constants.VERSION_ATTRIBUTE));
if (!v1.equals(v2)) {
continue;
}
if (!attribs1.equals(attribs2)) {
continue;
}
foundMatch = true;
break;
}
if (!foundMatch) {
result = false;
break;
}
}
}
return result;
}
use of org.apache.aries.util.VersionRange in project aries by apache.
the class ManifestProcessorTest method testManifestMetadataWithMultiLineEntries.
/**
* Check metadata can be extracted from a manifest that uses multiple lines
* for a single manifest attribute.
*/
@Test
public void testManifestMetadataWithMultiLineEntries() throws Exception {
ApplicationMetadataFactoryImpl manager = new ApplicationMetadataFactoryImpl();
InputStream in = getClass().getClassLoader().getResourceAsStream("META-INF/APPLICATION2.MF");
ApplicationMetadata am = manager.parseApplicationMetadata(in);
assertNotNull(am);
assertEquals(am.getApplicationName(), appName);
//"com.travel.reservation.web;version=\"[1.1.0,1.2.0)\",com.travel.reservation.business",
List<Content> contents = am.getApplicationContents();
for (Content content : contents) {
if ("com.travel.reservation.web".equals(content.getContentName())) {
VersionRange vr = content.getVersion();
assertEquals(vr.getMinimumVersion(), new Version("1.1.0"));
assertEquals(vr.getMaximumVersion(), new Version("1.2.0"));
} else if ("com.travel.reservation.business".equals(content.getContentName())) {
VersionRange vr = content.getVersion();
assertEquals(new Version(0, 0, 0), vr.getMinimumVersion());
} else
fail("Unexepcted content name " + content.getContentName());
}
}
use of org.apache.aries.util.VersionRange in project aries by apache.
the class ManifestProcessorTest method testManifestMetadata.
/**
* Check metadata can be extracted from a simple manifest.
*/
@Test
public void testManifestMetadata() throws Exception {
ApplicationMetadataFactoryImpl manager = new ApplicationMetadataFactoryImpl();
InputStream in = getClass().getClassLoader().getResourceAsStream("META-INF/APPLICATION.MF");
ApplicationMetadata am = manager.parseApplicationMetadata(in);
assertNotNull(am);
assertEquals(am.getApplicationName(), appName);
//"com.travel.reservation.web;version=\"[1.1.0,1.2.0)\",com.travel.reservation.business",
List<Content> contents = am.getApplicationContents();
for (Content content : contents) {
if ("com.travel.reservation.web".equals(content.getContentName())) {
VersionRange vr = content.getVersion();
assertEquals(vr.getMinimumVersion(), new Version("1.1.0"));
assertEquals(vr.getMaximumVersion(), new Version("1.2.0"));
} else if ("com.travel.reservation.business".equals(content.getContentName())) {
VersionRange vr = content.getVersion();
assertEquals(new Version(0, 0, 0), vr.getMinimumVersion());
} else
fail("Unexepcted content name " + content.getContentName());
}
}
use of org.apache.aries.util.VersionRange in project aries by apache.
the class DeploymentContentImpl method getVersion.
public VersionRange getVersion() {
String deployedVersion = _content.getAttribute(AppConstants.DEPLOYMENT_BUNDLE_VERSION);
VersionRange vr = null;
if (deployedVersion != null && deployedVersion.length() > 0) {
vr = ManifestHeaderProcessor.parseVersionRange(deployedVersion, true);
}
return vr;
}
use of org.apache.aries.util.VersionRange in project aries by apache.
the class DeploymentContentImplTest method testDeploymentContent001.
@Test
public void testDeploymentContent001() throws Exception {
DeploymentContentImpl dc = new DeploymentContentImpl("com.travel.reservation.web;deployed-version=\"1.1.0\"");
assertEquals("1.1.0", dc.getAttribute("deployed-version"));
VersionRange vi = dc.getVersion();
assertTrue(vi.isExactVersion());
assertEquals(new Version("1.1.0"), dc.getExactVersion());
assertEquals("com.travel.reservation.web", dc.getContentName());
assertEquals("{deployed-version=1.1.0}", dc.getNameValueMap().toString());
}
Aggregations