use of org.apache.aries.application.management.ResolverException in project aries by apache.
the class DeployedBundlesTest method testGetImportPackage_InvalidBundleVersion.
//Inside cannot bundle-symbolic-name an outside bundle until the new RFC 138!
@Test
public void testGetImportPackage_InvalidBundleVersion() throws Exception {
DeployedBundles deployedBundles = getSimpleDeployedBundles(ternary.CONTENT, ternary.USES, ternary.NONE);
deployedBundles.addBundle(createModelledResource("bundle.a", "1.0.0", Arrays.asList("package.b;version=\"[1.0.0,1.0.0]\";bundle-symbolic-name=bundle.b;bundle-version=\"[0.0.0,1.0.0)\""), new ArrayList<String>()));
deployedBundles.addBundle(createModelledResource("bundle.b", "1.0.0", new ArrayList<String>(), Arrays.asList("package.b;version=1.0.0")));
// Check that the bundle version requirement generates an error because it doesn't match the a bundle in use-bundle.
String importPackageEntry = null;
try {
importPackageEntry = deployedBundles.getImportPackage();
Assert.fail("Expected exception. ImportPackage=" + importPackageEntry);
} catch (ResolverException e) {
// We expect to reach this point if the test passes.
}
}
use of org.apache.aries.application.management.ResolverException in project aries by apache.
the class DeployedBundlesTest method testGetImportPackage_rfc138PreventsBundleVersionWorking.
@Test
public void testGetImportPackage_rfc138PreventsBundleVersionWorking() throws Exception {
DeployedBundles deployedBundles = getSimpleDeployedBundles(ternary.CONTENT, ternary.NONE, ternary.NONE);
deployedBundles.addBundle(createModelledResource("bundle.a", "1.0.0", Arrays.asList("package.b;version=1.0.0;bundle-version=1.0.0"), new ArrayList<String>()));
deployedBundles.addBundle(createModelledResource("bundle.b", "1.0.0", new ArrayList<String>(), Arrays.asList("package.b;version=2.0.0")));
// Check that the bundle-symbolic-name attribute for a bundle outside use-bundle causes an exception.
String importPackageEntry = null;
try {
importPackageEntry = deployedBundles.getImportPackage();
Assert.fail("Expected exception. ImportPackage=" + importPackageEntry);
} catch (ResolverException e) {
// We expect to reach this point if the test passes.
}
}
use of org.apache.aries.application.management.ResolverException in project aries by apache.
the class DeployedBundlesTest method testGetImportPackage_ValidDuplicates.
@Test
public void testGetImportPackage_ValidDuplicates() throws Exception {
DeployedBundles deployedBundles = getSimpleDeployedBundles(ternary.CONTENT, ternary.CONTENT, ternary.CONTENT);
deployedBundles.addBundle(createModelledResource("bundle.a", "1.0.0", Arrays.asList("package.d;version=\"[1.0.0,3.0.0)\""), new ArrayList<String>()));
deployedBundles.addBundle(createModelledResource("bundle.b", "1.0.0", Arrays.asList("package.d;version=\"2.0.0\""), new ArrayList<String>()));
deployedBundles.addBundle(createModelledResource("bundle.c", "1.0.0", Arrays.asList("package.d;version=\"1.0.0\""), new ArrayList<String>()));
deployedBundles.addBundle(createModelledResource("bundle.d", "1.0.0", new ArrayList<String>(), Arrays.asList("package.d;version=2.0.1")));
// Check that package D is not duplicated in Import-Package, and that the version range
// has been narrowed to the intersection of the original requirements.
String importPackageEntry = null;
try {
importPackageEntry = deployedBundles.getImportPackage();
} catch (ResolverException e) {
e.printStackTrace();
Assert.fail(e.toString());
}
String expectedResult = "package.d;version=\"[2.0.0,3.0.0)\"";
Assert.assertTrue("ImportPackage=" + importPackageEntry, isEqual(importPackageEntry, expectedResult));
}
use of org.apache.aries.application.management.ResolverException in project aries by apache.
the class AriesApplicationManagerImpl method resolve.
public AriesApplication resolve(AriesApplication originalApp, ResolveConstraint... constraints) throws ResolverException {
AriesApplicationImpl application = new AriesApplicationImpl(originalApp.getApplicationMetadata(), originalApp.getBundleInfo(), _localPlatform);
Manifest deploymentManifest = deploymentManifestManager.generateDeploymentManifest(originalApp, constraints);
try {
application.setDeploymentMetadata(_deploymentMetadataFactory.createDeploymentMetadata(deploymentManifest));
} catch (IOException ioe) {
throw new ResolverException(ioe);
}
// Store a reference to any modified bundles
if (originalApp instanceof AriesApplicationImpl) {
// TODO: are we really passing streams around ?
application.setModifiedBundles(((AriesApplicationImpl) originalApp).getModifiedBundles());
}
return application;
}
use of org.apache.aries.application.management.ResolverException in project aries by apache.
the class OBRAriesResolver method toImportedBundle.
private Collection<ImportedBundle> toImportedBundle(Collection<Content> content) throws ResolverException {
log.debug(LOG_ENTRY, "toImportedBundle", content);
List<ImportedBundle> result = new ArrayList<ImportedBundle>();
for (Content c : content) {
try {
result.add(modellingManager.getImportedBundle(c.getContentName(), c.getVersion().toString()));
} catch (InvalidAttributeException iae) {
throw new ResolverException(iae);
}
}
log.debug(LOG_EXIT, "toImportedBundle", result);
return result;
}
Aggregations