use of org.apache.aries.application.ApplicationMetadata in project aries by apache.
the class AriesApplicationManagerImplTest method testCreateAndConversion.
@Test
public void testCreateAndConversion() throws Exception {
AriesApplication app = createApplication(CONVERSION_EBA);
ApplicationMetadata appMeta = app.getApplicationMetadata();
assertEquals(appMeta.getApplicationName(), "conversion.eba");
assertEquals(appMeta.getApplicationSymbolicName(), "conversion.eba");
assertEquals(appMeta.getApplicationVersion(), new Version("0.0"));
List<Content> appContent = appMeta.getApplicationContents();
assertEquals(2, appContent.size());
Content fbw = new ContentImpl("hello.world.jar;version=\"[1.1.0, 1.1.0]\"");
Content mbl = new ContentImpl("helloWorld.war;version=\"[0.0.0, 0.0.0]\"");
assertTrue(appContent.contains(fbw));
assertTrue(appContent.contains(mbl));
DeploymentMetadata dm = app.getDeploymentMetadata();
List<DeploymentContent> dcList = dm.getApplicationDeploymentContents();
assertEquals(2, dcList.size());
DeploymentContent dc1 = new DeploymentContentImpl("hello.world.jar;deployed-version=1.1.0");
DeploymentContent dc2 = new DeploymentContentImpl("helloWorld.war;deployed-version=0.0.0");
DeploymentContent dc3 = new DeploymentContentImpl("a.handy.persistence.library;deployed-version=1.1.0");
assertTrue(dcList.contains(dc1));
assertTrue(dcList.contains(dc2));
dcList = dm.getApplicationProvisionBundles();
assertEquals(1, dcList.size());
assertTrue(dcList.contains(dc3));
assertEquals(2, app.getBundleInfo().size());
BundleInfo info;
info = findBundleInfo(app.getBundleInfo(), "hello.world.jar");
assertNotNull(info);
assertEquals("HelloWorldJar", info.getHeaders().get(Constants.BUNDLE_NAME));
info = findBundleInfo(app.getBundleInfo(), "helloWorld.war");
assertNotNull(info);
assertEquals("helloWorld.war", info.getHeaders().get(Constants.BUNDLE_NAME));
assertEquals("/test", info.getHeaders().get("Bundle-ContextPath"));
}
use of org.apache.aries.application.ApplicationMetadata in project aries by apache.
the class ConfigurationPostResolverTest method validatePostResolveTransform.
/**
* This test validates that the transformer is correctly detecting the config admin package. Checks
* are performed to validate that an existing import package is still honored etc.
*
* @throws Exception
*/
@Test
public void validatePostResolveTransform() throws Exception {
RichBundleContext ctx = new RichBundleContext(bundleContext);
PostResolveTransformer transformer = ctx.getService(PostResolveTransformer.class);
Assert.assertNotNull("Unable to locate transformer", transformer);
/**
* Try processing deployed content that doesn't have any import for the
* org.osgi.service.cm package, the resultant imports should be unaffected.
*/
ApplicationMetadata mockApplicationMetadata = Skeleton.newMock(ApplicationMetadata.class);
MockDeployedBundles originalDeployedBundles = new MockDeployedBundles();
originalDeployedBundles.setDeployedContent(getNonConfigModelledResources());
DeployedBundles transformedDeployedBundles = transformer.postResolveProcess(mockApplicationMetadata, originalDeployedBundles);
Assert.assertNotNull("An instance should have been returned", transformedDeployedBundles);
Assert.assertEquals(originalDeployedBundles.getImportPackage(), transformedDeployedBundles.getImportPackage());
/**
* Now try processing a deployed bundles instances that has an import for the org.osgi.service.cm package in multiple
* modelled resources with an empty import package set in the mock deployed bundles instance.
*/
originalDeployedBundles = new MockDeployedBundles();
originalDeployedBundles.setDeployedContent(getConfigModelledResources());
transformedDeployedBundles = transformer.postResolveProcess(mockApplicationMetadata, originalDeployedBundles);
Assert.assertNotNull("An instance should have been returned", transformedDeployedBundles);
Assert.assertNotSame("Missing config package", originalDeployedBundles.getImportPackage(), transformedDeployedBundles.getImportPackage());
Assert.assertEquals("Missing config package", "org.osgi.service.cm;version=\"1.2.0\"", transformedDeployedBundles.getImportPackage());
/**
* Now try processing a deployed bundles instances that has an import for the org.osgi.service.cm package in multiple
* modelled resources with a populated import package set in the mock deployed bundles instance.
*/
originalDeployedBundles = new MockDeployedBundles();
originalDeployedBundles.setDeployedContent(getConfigModelledResources());
originalDeployedBundles.setImportPackage("org.foo.bar;version=\1.0.0\",org.bar.foo;version=\"1.0.0\"");
transformedDeployedBundles = transformer.postResolveProcess(mockApplicationMetadata, originalDeployedBundles);
Assert.assertNotNull("An instance should have been returned", transformedDeployedBundles);
Assert.assertNotSame("Missing config package", originalDeployedBundles.getImportPackage(), transformedDeployedBundles.getImportPackage());
Assert.assertEquals("Missing config package", "org.foo.bar;version=\1.0.0\",org.bar.foo;version=\"1.0.0\",org.osgi.service.cm;version=\"1.2.0\"", transformedDeployedBundles.getImportPackage());
}
Aggregations