Search in sources :

Example 6 with DeployedBundles

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"));
}
Also used : ApplicationMetadata(org.apache.aries.application.ApplicationMetadata) Content(org.apache.aries.application.Content) ArrayList(java.util.ArrayList) AriesApplication(org.apache.aries.application.management.AriesApplication) DeployedBundles(org.apache.aries.application.modelling.DeployedBundles) Manifest(java.util.jar.Manifest) MethodCall(org.apache.aries.unittest.mocks.MethodCall) ModelledResource(org.apache.aries.application.modelling.ModelledResource) Test(org.junit.Test)

Example 7 with DeployedBundles

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"));
}
Also used : ApplicationMetadata(org.apache.aries.application.ApplicationMetadata) Content(org.apache.aries.application.Content) ArrayList(java.util.ArrayList) AriesApplication(org.apache.aries.application.management.AriesApplication) DeployedBundles(org.apache.aries.application.modelling.DeployedBundles) Manifest(java.util.jar.Manifest) MethodCall(org.apache.aries.unittest.mocks.MethodCall) ModelledResource(org.apache.aries.application.modelling.ModelledResource) Test(org.junit.Test)

Example 8 with DeployedBundles

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));
}
Also used : ResolverException(org.apache.aries.application.management.ResolverException) DeployedBundles(org.apache.aries.application.modelling.DeployedBundles) Test(org.junit.Test)

Example 9 with DeployedBundles

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));
}
Also used : DeployedBundles(org.apache.aries.application.modelling.DeployedBundles) Test(org.junit.Test)

Example 10 with DeployedBundles

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);
}
Also used : ResolverException(org.apache.aries.application.management.ResolverException) DeployedBundles(org.apache.aries.application.modelling.DeployedBundles) ModelledResource(org.apache.aries.application.modelling.ModelledResource) Test(org.junit.Test)

Aggregations

DeployedBundles (org.apache.aries.application.modelling.DeployedBundles)26 Test (org.junit.Test)23 ArrayList (java.util.ArrayList)17 ResolverException (org.apache.aries.application.management.ResolverException)17 ModelledResource (org.apache.aries.application.modelling.ModelledResource)10 ApplicationMetadata (org.apache.aries.application.ApplicationMetadata)8 Content (org.apache.aries.application.Content)7 MethodCall (org.apache.aries.unittest.mocks.MethodCall)6 Manifest (java.util.jar.Manifest)4 AriesApplication (org.apache.aries.application.management.AriesApplication)4 List (java.util.List)3 ExportedPackage (org.apache.aries.application.modelling.ExportedPackage)3 InvalidAttributeException (org.apache.aries.application.InvalidAttributeException)2 ServiceUnavailableException (org.osgi.service.blueprint.container.ServiceUnavailableException)2 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Attributes (java.util.jar.Attributes)1 ResolveConstraint (org.apache.aries.application.management.ResolveConstraint)1