use of org.apache.aries.application.management.spi.resolve.PostResolveTransformer 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