Search in sources :

Example 1 with ApplicationMetadataFactoryImpl

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

the class ApplicationMetadataImplTest method testMetadataCreation.

@Test
public void testMetadataCreation() throws Exception {
    ApplicationMetadataFactory manager = new ApplicationMetadataFactoryImpl();
    ApplicationMetadata app = manager.parseApplicationMetadata(getClass().getResourceAsStream("/META-INF/APPLICATION4.MF"));
    assertEquals("Travel Reservation", app.getApplicationName());
    assertEquals("com.travel.reservation", app.getApplicationSymbolicName());
    assertEquals(Version.parseVersion("1.2.0"), app.getApplicationVersion());
    List<Content> appContents = app.getApplicationContents();
    assertEquals(2, appContents.size());
    Content appContent1 = new ContentImpl("com.travel.reservation.business");
    Map<String, String> attrs = new HashMap<String, String>();
    attrs.put("version", "\"[1.1.0,1.2.0)\"");
    Content appContent2 = new ContentImpl("com.travel.reservation.web", attrs);
    assertTrue(appContents.contains(appContent2));
    assertTrue(appContents.contains(appContent1));
    List<ServiceDeclaration> importedService = app.getApplicationImportServices();
    assertEquals(2, importedService.size());
    assertTrue(importedService.contains(new ServiceDeclarationImpl("com.travel.flight.api")));
    assertTrue(importedService.contains(new ServiceDeclarationImpl("com.travel.rail.api")));
    List<ServiceDeclaration> exportedService = app.getApplicationExportServices();
    assertTrue(exportedService.contains(new ServiceDeclarationImpl("com.travel.reservation")));
}
Also used : ApplicationMetadata(org.apache.aries.application.ApplicationMetadata) HashMap(java.util.HashMap) Content(org.apache.aries.application.Content) ServiceDeclaration(org.apache.aries.application.ServiceDeclaration) ApplicationMetadataFactory(org.apache.aries.application.ApplicationMetadataFactory) ApplicationMetadataFactoryImpl(org.apache.aries.application.impl.ApplicationMetadataFactoryImpl) Test(org.junit.Test)

Example 2 with ApplicationMetadataFactoryImpl

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

the class ManifestProcessorTest method testManifestWithoutEndingInNewLine.

@Test
public void testManifestWithoutEndingInNewLine() throws Exception {
    ApplicationMetadataFactoryImpl manager = new ApplicationMetadataFactoryImpl();
    InputStream in = getClass().getClassLoader().getResourceAsStream("META-INF/APPLICATION3.MF");
    ApplicationMetadata am = manager.parseApplicationMetadata(in);
    assertNotNull(am);
    assertEquals("Wrong number of bundles are in the application", 1, am.getApplicationContents().size());
    assertEquals("Wrong bundle name", "org.apache.aries.applications.test.bundle", am.getApplicationContents().get(0).getContentName());
}
Also used : ApplicationMetadata(org.apache.aries.application.ApplicationMetadata) InputStream(java.io.InputStream) ApplicationMetadataFactoryImpl(org.apache.aries.application.impl.ApplicationMetadataFactoryImpl) Test(org.junit.Test)

Example 3 with ApplicationMetadataFactoryImpl

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

the class AriesApplicationManagerImplTest method setup.

@Before
public void setup() {
    _appMgr = new AriesApplicationManagerImpl();
    _appMetaFactory = new ApplicationMetadataFactoryImpl();
    DeploymentMetadataFactory dmf = new DeploymentMetadataFactoryImpl();
    _converter = new DummyConverter();
    List<BundleConverter> bundleConverters = new ArrayList<BundleConverter>();
    bundleConverters.add(_converter);
    _resolver = new DummyResolver();
    _dmMgr = new DummyDMManager();
    _dmMgr.setResolver(_resolver);
    _appMgr.setApplicationMetadataFactory(_appMetaFactory);
    _appMgr.setDeploymentMetadataFactory(dmf);
    _appMgr.setBundleConverters(bundleConverters);
    _appMgr.setDeploymentManifestManager(_dmMgr);
    _appMgr.setLocalPlatform(new DummyLocalPlatform());
}
Also used : BundleConverter(org.apache.aries.application.management.spi.convert.BundleConverter) DeploymentMetadataFactory(org.apache.aries.application.DeploymentMetadataFactory) DeploymentMetadataFactoryImpl(org.apache.aries.application.impl.DeploymentMetadataFactoryImpl) ArrayList(java.util.ArrayList) ApplicationMetadataFactoryImpl(org.apache.aries.application.impl.ApplicationMetadataFactoryImpl) Before(org.junit.Before)

Example 4 with ApplicationMetadataFactoryImpl

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

the class ManifestProcessorTest method testManifestMetadataWithMultiLineEntries.

/**
   * Check metadata can be extracted from a manifest that uses multiple lines
   * for a single manifest attribute.
   */
@Test
public void testManifestMetadataWithMultiLineEntries() throws Exception {
    ApplicationMetadataFactoryImpl manager = new ApplicationMetadataFactoryImpl();
    InputStream in = getClass().getClassLoader().getResourceAsStream("META-INF/APPLICATION2.MF");
    ApplicationMetadata am = manager.parseApplicationMetadata(in);
    assertNotNull(am);
    assertEquals(am.getApplicationName(), appName);
    //"com.travel.reservation.web;version=\"[1.1.0,1.2.0)\",com.travel.reservation.business",
    List<Content> contents = am.getApplicationContents();
    for (Content content : contents) {
        if ("com.travel.reservation.web".equals(content.getContentName())) {
            VersionRange vr = content.getVersion();
            assertEquals(vr.getMinimumVersion(), new Version("1.1.0"));
            assertEquals(vr.getMaximumVersion(), new Version("1.2.0"));
        } else if ("com.travel.reservation.business".equals(content.getContentName())) {
            VersionRange vr = content.getVersion();
            assertEquals(new Version(0, 0, 0), vr.getMinimumVersion());
        } else
            fail("Unexepcted content name " + content.getContentName());
    }
}
Also used : ApplicationMetadata(org.apache.aries.application.ApplicationMetadata) Version(org.osgi.framework.Version) InputStream(java.io.InputStream) Content(org.apache.aries.application.Content) VersionRange(org.apache.aries.util.VersionRange) ApplicationMetadataFactoryImpl(org.apache.aries.application.impl.ApplicationMetadataFactoryImpl) Test(org.junit.Test)

Example 5 with ApplicationMetadataFactoryImpl

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

the class ManifestProcessorTest method testManifestMetadata.

/**
   * Check metadata can be extracted from a simple manifest.
   */
@Test
public void testManifestMetadata() throws Exception {
    ApplicationMetadataFactoryImpl manager = new ApplicationMetadataFactoryImpl();
    InputStream in = getClass().getClassLoader().getResourceAsStream("META-INF/APPLICATION.MF");
    ApplicationMetadata am = manager.parseApplicationMetadata(in);
    assertNotNull(am);
    assertEquals(am.getApplicationName(), appName);
    //"com.travel.reservation.web;version=\"[1.1.0,1.2.0)\",com.travel.reservation.business",
    List<Content> contents = am.getApplicationContents();
    for (Content content : contents) {
        if ("com.travel.reservation.web".equals(content.getContentName())) {
            VersionRange vr = content.getVersion();
            assertEquals(vr.getMinimumVersion(), new Version("1.1.0"));
            assertEquals(vr.getMaximumVersion(), new Version("1.2.0"));
        } else if ("com.travel.reservation.business".equals(content.getContentName())) {
            VersionRange vr = content.getVersion();
            assertEquals(new Version(0, 0, 0), vr.getMinimumVersion());
        } else
            fail("Unexepcted content name " + content.getContentName());
    }
}
Also used : ApplicationMetadata(org.apache.aries.application.ApplicationMetadata) Version(org.osgi.framework.Version) InputStream(java.io.InputStream) Content(org.apache.aries.application.Content) VersionRange(org.apache.aries.util.VersionRange) ApplicationMetadataFactoryImpl(org.apache.aries.application.impl.ApplicationMetadataFactoryImpl) Test(org.junit.Test)

Aggregations

ApplicationMetadataFactoryImpl (org.apache.aries.application.impl.ApplicationMetadataFactoryImpl)6 ApplicationMetadata (org.apache.aries.application.ApplicationMetadata)5 Test (org.junit.Test)5 InputStream (java.io.InputStream)3 Content (org.apache.aries.application.Content)3 ApplicationMetadataFactory (org.apache.aries.application.ApplicationMetadataFactory)2 VersionRange (org.apache.aries.util.VersionRange)2 Version (org.osgi.framework.Version)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 DeploymentMetadataFactory (org.apache.aries.application.DeploymentMetadataFactory)1 ServiceDeclaration (org.apache.aries.application.ServiceDeclaration)1 DeploymentMetadataFactoryImpl (org.apache.aries.application.impl.DeploymentMetadataFactoryImpl)1 BundleConverter (org.apache.aries.application.management.spi.convert.BundleConverter)1 Before (org.junit.Before)1