Search in sources :

Example 1 with DeploymentContentImpl

use of org.apache.aries.application.impl.DeploymentContentImpl in project aries by apache.

the class ApplicationRepositoryTest method testBundleNotInApp.

@Test
public void testBundleNotInApp() {
    AriesApplication app = Skeleton.newMock(AriesApplication.class);
    BundleInfo bi = Skeleton.newMock(BundleInfo.class);
    Skeleton.getSkeleton(bi).setReturnValue(new MethodCall(BundleInfo.class, "getSymbolicName"), "test.bundle");
    Skeleton.getSkeleton(bi).setReturnValue(new MethodCall(BundleInfo.class, "getVersion"), new Version("1.0.0"));
    Skeleton.getSkeleton(app).setReturnValue(new MethodCall(AriesApplication.class, "getBundleInfo"), new HashSet<BundleInfo>());
    ApplicationRepository rep = new ApplicationRepository(app);
    BundleSuggestion sug = rep.suggestBundleToUse(new DeploymentContentImpl("test.bundle", new Version("2.0.0")));
    assertNull("We have apparently found a bundle that is not in the application in the ApplicationRepository", sug);
}
Also used : DeploymentContentImpl(org.apache.aries.application.impl.DeploymentContentImpl) BundleInfo(org.apache.aries.application.management.BundleInfo) Version(org.osgi.framework.Version) AriesApplication(org.apache.aries.application.management.AriesApplication) BundleSuggestion(org.apache.aries.application.management.spi.repository.BundleRepository.BundleSuggestion) MethodCall(org.apache.aries.unittest.mocks.MethodCall) Test(org.junit.Test)

Example 2 with DeploymentContentImpl

use of org.apache.aries.application.impl.DeploymentContentImpl in project aries by apache.

the class AriesApplicationManagerImplTest method testCreate.

@Test
public void testCreate() throws Exception {
    AriesApplication app = createApplication(TEST_EBA);
    ApplicationMetadata appMeta = app.getApplicationMetadata();
    assertEquals(appMeta.getApplicationName(), "Test application");
    assertEquals(appMeta.getApplicationSymbolicName(), "org.apache.aries.application.management.test");
    assertEquals(appMeta.getApplicationVersion(), new Version("1.0"));
    List<Content> appContent = appMeta.getApplicationContents();
    assertEquals(appContent.size(), 2);
    Content fbw = new ContentImpl("foo.bar.widgets;version=1.0.0");
    Content mbl = new ContentImpl("my.business.logic;version=1.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("foo.bar.widgets;deployed-version=1.1.0");
    DeploymentContent dc2 = new DeploymentContentImpl("my.business.logic;deployed-version=1.1.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));
}
Also used : DeploymentMetadata(org.apache.aries.application.DeploymentMetadata) DeploymentContentImpl(org.apache.aries.application.impl.DeploymentContentImpl) ApplicationMetadata(org.apache.aries.application.ApplicationMetadata) Version(org.osgi.framework.Version) Content(org.apache.aries.application.Content) DeploymentContent(org.apache.aries.application.DeploymentContent) AriesApplication(org.apache.aries.application.management.AriesApplication) ContentImpl(org.apache.aries.application.impl.ContentImpl) DeploymentContentImpl(org.apache.aries.application.impl.DeploymentContentImpl) DeploymentContent(org.apache.aries.application.DeploymentContent) Test(org.junit.Test)

Example 3 with DeploymentContentImpl

use of org.apache.aries.application.impl.DeploymentContentImpl 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"));
}
Also used : DeploymentMetadata(org.apache.aries.application.DeploymentMetadata) DeploymentContentImpl(org.apache.aries.application.impl.DeploymentContentImpl) ApplicationMetadata(org.apache.aries.application.ApplicationMetadata) BundleInfo(org.apache.aries.application.management.BundleInfo) SimpleBundleInfo(org.apache.aries.application.utils.management.SimpleBundleInfo) Version(org.osgi.framework.Version) Content(org.apache.aries.application.Content) DeploymentContent(org.apache.aries.application.DeploymentContent) AriesApplication(org.apache.aries.application.management.AriesApplication) ContentImpl(org.apache.aries.application.impl.ContentImpl) DeploymentContentImpl(org.apache.aries.application.impl.DeploymentContentImpl) DeploymentContent(org.apache.aries.application.DeploymentContent) Test(org.junit.Test)

Aggregations

DeploymentContentImpl (org.apache.aries.application.impl.DeploymentContentImpl)3 AriesApplication (org.apache.aries.application.management.AriesApplication)3 Test (org.junit.Test)3 Version (org.osgi.framework.Version)3 ApplicationMetadata (org.apache.aries.application.ApplicationMetadata)2 Content (org.apache.aries.application.Content)2 DeploymentContent (org.apache.aries.application.DeploymentContent)2 DeploymentMetadata (org.apache.aries.application.DeploymentMetadata)2 ContentImpl (org.apache.aries.application.impl.ContentImpl)2 BundleInfo (org.apache.aries.application.management.BundleInfo)2 BundleSuggestion (org.apache.aries.application.management.spi.repository.BundleRepository.BundleSuggestion)1 SimpleBundleInfo (org.apache.aries.application.utils.management.SimpleBundleInfo)1 MethodCall (org.apache.aries.unittest.mocks.MethodCall)1