use of org.apache.aries.application.modelling.DeployedBundles 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.modelling.DeployedBundles 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.modelling.DeployedBundles in project aries by apache.
the class DeployedBundlesTest method testImportedService.
@Test
public void testImportedService() throws Exception {
DeployedBundles deployedBundles = getSimpleDeployedBundles(ternary.CONTENT, ternary.NONE, ternary.NONE);
deployedBundles.addBundle(createModelledServiceBundle("bundle.a", "1.0.0", Collections.singleton("java.util.List"), Collections.<String>emptyList()));
deployedBundles.addBundle(createModelledServiceBundle("bundle.b", "1.0.0", Collections.singleton("java.util.Set"), Collections.singleton("java.util.List")));
deployedBundles.addBundle(createModelledServiceBundle("bundle.c", "1.0.0", Collections.<String>emptyList(), Collections.singleton("java.util.Set")));
assertEquals("(objectClass=java.util.List)", deployedBundles.getDeployedImportService());
}
use of org.apache.aries.application.modelling.DeployedBundles in project aries by apache.
the class DeployedBundlesTest method testGetImportPackage_InvalidDuplicatesWithAttributes.
@Test
public void testGetImportPackage_InvalidDuplicatesWithAttributes() throws Exception {
DeployedBundles deployedBundles = getSimpleDeployedBundles(ternary.CONTENT, ternary.CONTENT, ternary.NONE);
deployedBundles.addBundle(createModelledResource("bundle.a", "1.0.0", Arrays.asList("package.c;version=1.0.0;was_internal=true"), new ArrayList<String>()));
deployedBundles.addBundle(createModelledResource("bundle.b", "1.0.0", Arrays.asList("package.c;version=2.0.0"), new ArrayList<String>()));
deployedBundles.addBundle(createModelledResource("bundle.c", "1.0.0", new ArrayList<String>(), Arrays.asList("package.c;version=2.0.0;was_internal=true")));
// Check that the incompatible package requirement attributes cause 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.modelling.DeployedBundles in project aries by apache.
the class DeploymentGeneratorTest method testResolve.
@Test
public void testResolve() throws Exception {
Skeleton.getSkeleton(appMetadata).setReturnValue(new MethodCall(ApplicationMetadata.class, "getApplicationContents"), Arrays.asList(mockContent("aries.test.a", "1.0.0"), mockContent("aries.test.b", "[1.0.0, 2.0.0)")));
Skeleton.getSkeleton(appMetadata).setReturnValue(new MethodCall(ApplicationMetadata.class, "getUseBundles"), Arrays.asList(BUNDLE_C, BUNDLE_D));
DeployedBundles deployedBundles = deplMFMgr.generateDeployedBundles(appMetadata, new ArrayList<ModelledResource>(), Collections.<Content>emptyList());
Manifest man = deplMFMgr.generateDeploymentManifest(appMetadata.getApplicationSymbolicName(), appMetadata.getApplicationVersion().toString(), deployedBundles);
Attributes attrs = man.getMainAttributes();
assertEquals("aries.test", attrs.getValue(AppConstants.APPLICATION_SYMBOLIC_NAME));
assertEquals("1.0.0", attrs.getValue(AppConstants.APPLICATION_VERSION));
String content = attrs.getValue(AppConstants.DEPLOYMENT_CONTENT);
String useBundle = attrs.getValue(AppConstants.DEPLOYMENT_USE_BUNDLE);
String provisioned = attrs.getValue(AppConstants.DEPLOYMENT_PROVISION_BUNDLE);
assertTrue(content.contains("aries.test.a;deployed-version=1.0.0"));
assertTrue(content.contains("aries.test.b;deployed-version=1.1.0"));
assertTrue(useBundle.contains("aries.test.c;deployed-version=1.0.5"));
assertFalse(useBundle.contains("aries.test.d"));
assertTrue(provisioned.contains("aries.test.e;deployed-version=1.0.0"));
}
Aggregations