Package org.apache.aries.application.management.spi.resolve

Examples of org.apache.aries.application.management.spi.resolve.PostResolveTransformer


     */
    @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());
    }
View Full Code Here

TOP

Related Classes of org.apache.aries.application.management.spi.resolve.PostResolveTransformer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.