use of org.apache.aries.application.modelling.DeployedBundles in project aries by apache.
the class DeploymentGeneratorTest method checkBundleInAppContentAndProvisionContentButNothingSharedToIsolatedContent.
/**
* Similar to the checkBundleInAppContentAndProvisionContent scenario. However, this time the provisioned bundle does not provide
* a package or service to the isolated content, so there is no problem.
* @throws Exception
*/
@Test
public void checkBundleInAppContentAndProvisionContentButNothingSharedToIsolatedContent() throws Exception {
List<ModelledResource> cmr = new ArrayList<ModelledResource>();
cmr.add(createModelledResource("test.util", "1.1.0", Collections.<String>emptyList(), Arrays.asList("test.api.pack;version=1.1.0")));
cmr.add(createModelledResource("test.bundle", "1.0.0", Arrays.asList("test.api.pack;version=\"[1.1.0,2.0.0)\""), Collections.<String>emptyList()));
cmr.add(createModelledResource("test.provisioned", "1.0.0", Arrays.asList("test.api.pack;version=\"[1.0.0,1.1.0)\""), Collections.<String>emptyList()));
cmr.add(createModelledResource("test.util", "1.0.0", Collections.<String>emptyList(), Arrays.asList("test.api.pack;version=1.0.0")));
// The second time DeploymentGenerator calls the Resolver, it will provide just
// test.shared. The resolver will return test.shared _plus_ test.isolated.
_resolver.addResult(cmr);
Skeleton.getSkeleton(appMetadata).setReturnValue(new MethodCall(ApplicationMetadata.class, "getApplicationContents"), Arrays.asList(mockContent("test.util", "1.1.0"), mockContent("test.bundle", "1.0.0")));
app = Skeleton.newMock(AriesApplication.class);
Skeleton.getSkeleton(app).setReturnValue(new MethodCall(AriesApplication.class, "getApplicationMetadata"), appMetadata);
DeployedBundles deployedBundles = deplMFMgr.generateDeployedBundles(appMetadata, Arrays.asList(new ModelledResource[] { cmr.get(0), cmr.get(1) }), new ArrayList<Content>());
Manifest mf = deplMFMgr.generateDeploymentManifest(appMetadata.getApplicationSymbolicName(), appMetadata.getApplicationVersion().toString(), deployedBundles);
assertTrue(mf.getMainAttributes().getValue("Deployed-Content").contains("test.util;deployed-version=1.1.0"));
assertTrue(mf.getMainAttributes().getValue("Provision-Bundle").contains("test.util;deployed-version=1.0.0"));
}
use of org.apache.aries.application.modelling.DeployedBundles in project aries by apache.
the class DeploymentGeneratorTest method checkBundleInAppContentAndUseContent.
@Test
public void checkBundleInAppContentAndUseContent() throws Exception {
List<ModelledResource> cmr = new ArrayList<ModelledResource>();
cmr.add(createModelledResource("test.api", "1.1.0", Collections.<String>emptyList(), Arrays.asList("test.api.pack;version=1.1.0")));
cmr.add(createModelledResource("test.api", "1.0.0", Collections.<String>emptyList(), Arrays.asList("test.api.pack;version=1.0.0")));
cmr.add(createModelledResource("test.consumer", "1.0.0", Arrays.asList("test.api.pack;version=\"[1.0.0,2.0.0)\""), Collections.<String>emptyList()));
cmr.add(createModelledResource("test.provider", "1.0.0", Arrays.asList("test.api.pack;version=\"[1.0.0,1.1.0)\""), Collections.<String>emptyList()));
// The second time DeploymentGenerator calls the Resolver, it will provide just
// test.shared. The resolver will return test.shared _plus_ test.isolated.
_resolver.addResult(cmr);
Skeleton.getSkeleton(appMetadata).setReturnValue(new MethodCall(ApplicationMetadata.class, "getApplicationContents"), Arrays.asList(mockContent("test.api", "1.1.0"), mockContent("test.consumer", "1.0.0"), mockContent("test.provider", "1.0.0")));
Skeleton.getSkeleton(appMetadata).setReturnValue(new MethodCall(ApplicationMetadata.class, "getUseBundles"), Arrays.asList(mockContent("test.api", "1.0.0")));
app = Skeleton.newMock(AriesApplication.class);
Skeleton.getSkeleton(app).setReturnValue(new MethodCall(AriesApplication.class, "getApplicationMetadata"), appMetadata);
DeployedBundles deployedBundles = deplMFMgr.generateDeployedBundles(appMetadata, Arrays.asList(new ModelledResource[] { cmr.get(0), cmr.get(2), cmr.get(3) }), new ArrayList<Content>());
Manifest mf = deplMFMgr.generateDeploymentManifest(appMetadata.getApplicationSymbolicName(), appMetadata.getApplicationVersion().toString(), deployedBundles);
mf.write(System.out);
assertTrue(mf.getMainAttributes().getValue("Deployed-Content").contains("test.api;deployed-version=1.1.0"));
assertTrue(mf.getMainAttributes().getValue("Deployed-Use-Bundle").contains("test.api;deployed-version=1.0.0"));
}
use of org.apache.aries.application.modelling.DeployedBundles in project aries by apache.
the class DeployedBundlesTest method testGetImportPackage_Valid.
@Test
public void testGetImportPackage_Valid() throws Exception {
// Check the import package entry is correct.
String importPackageEntry = null;
try {
DeployedBundles deployedBundles = validDeployedBundles();
packagesResolve(deployedBundles);
importPackageEntry = deployedBundles.getImportPackage();
} catch (ResolverException e) {
e.printStackTrace();
Assert.fail(e.toString());
}
String expectedResult = "package.c;version=\"1.0.0\";bundle-symbolic-name=\"bundle.c\";bundle-version=\"[1.0.0,1.0.0]\"," + "package.d;version=\"1.0.0\";bundle-symbolic-name=\"bundle.d\";bundle-version=\"[1.0.0,1.0.0]\"," + "package.e;version=\"[1.0.0,2.0.0)\"," + "package.g;version=\"0.0.0\"";
/*
* String expectedResult = "package.c;bundle-symbolic-name=bundle.c;bundle-version=\"[1.0.0,1.0.0]\""
+ ",package.d;version=\"1.0.0\";bundle-symbolic-name=bundle.d;bundle-version=\"[1.0.0,1.0.0]\""
+ ",package.e;version=\"[1.0.0,2.0.0)\""
+ ",package.g";
*/
Assert.assertTrue("ImportPackage=" + importPackageEntry, isEqual(importPackageEntry, expectedResult));
}
use of org.apache.aries.application.modelling.DeployedBundles in project aries by apache.
the class DeployedBundlesTest method testGetContent_Valid.
@Test
public void testGetContent_Valid() throws Exception {
// Get a valid set of deployment information.
DeployedBundles deployedBundles = validDeployedBundles();
packagesResolve(deployedBundles);
// Check the deployed content entry is correct.
String contentEntry = deployedBundles.getContent();
String expectedResult = "bundle.a;deployed-version=1.0.0,bundle.b;deployed-version=1.0.0";
Assert.assertTrue("Content=" + contentEntry, isEqual(contentEntry, expectedResult));
}
use of org.apache.aries.application.modelling.DeployedBundles in project aries by apache.
the class DeployedBundlesTest method testGetRequiredUseBundle_Valid.
@Test
public void testGetRequiredUseBundle_Valid() throws Exception {
// Get a valid set of deployment information.
DeployedBundles deployedBundles = validDeployedBundles();
packagesResolve(deployedBundles);
// Check all the use-bundle entries are required.
Collection<ModelledResource> requiredUseBundle = null;
try {
requiredUseBundle = deployedBundles.getRequiredUseBundle();
} catch (ResolverException e) {
e.printStackTrace();
Assert.fail(e.toString());
}
Assert.assertTrue("RequiredUseBundle=" + requiredUseBundle, requiredUseBundle.size() == 2);
}
Aggregations