Search in sources :

Example 11 with AriesApplicationManager

use of org.apache.aries.application.management.AriesApplicationManager in project aries by apache.

the class IsolatedRuntimeTest method testAppWithGlobalRepositoryBundle.

@Test
@Ignore
public void testAppWithGlobalRepositoryBundle() throws Exception {
    AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
    AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("test2.eba")));
    IsolationTestUtils.prepareSampleBundleV2(bundleContext, context().getService(RepositoryGenerator.class), context().getService(RepositoryAdmin.class), context().getService(ModellingManager.class));
    AriesApplication newApp = manager.resolve(app, new ResolveConstraint() {

        @Override
        public String getBundleName() {
            return "org.apache.aries.isolated.sample";
        }

        @Override
        public VersionRange getVersionRange() {
            return ManifestHeaderProcessor.parseVersionRange("[2.0.0,2.0.0]", true);
        }
    });
    AriesApplicationContext ctx = manager.install(newApp);
    ctx.start();
    assertHelloWorldService("org.apache.aries.sample2", "hello brave new world");
    manager.uninstall(ctx);
}
Also used : RepositoryGenerator(org.apache.aries.application.management.spi.repository.RepositoryGenerator) RepositoryAdmin(org.apache.felix.bundlerepository.RepositoryAdmin) ResolveConstraint(org.apache.aries.application.management.ResolveConstraint) AriesApplicationContext(org.apache.aries.application.management.AriesApplicationContext) AriesApplicationManager(org.apache.aries.application.management.AriesApplicationManager) AriesApplication(org.apache.aries.application.management.AriesApplication) ModellingManager(org.apache.aries.application.modelling.ModellingManager) VersionRange(org.apache.aries.util.VersionRange) File(java.io.File) Ignore(org.junit.Ignore) Test(org.junit.Test) AbstractIntegrationTest(org.apache.aries.itest.AbstractIntegrationTest)

Example 12 with AriesApplicationManager

use of org.apache.aries.application.management.AriesApplicationManager in project aries by apache.

the class IsolatedRuntimeTest method testAppWithApplicationManifest.

@Test
@Ignore
public void testAppWithApplicationManifest() throws Exception {
    AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
    AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("test2.eba")));
    AriesApplicationContext ctx = manager.install(app);
    ctx.start();
    assertHelloWorldService("org.apache.aries.sample2");
    manager.uninstall(ctx);
}
Also used : AriesApplicationContext(org.apache.aries.application.management.AriesApplicationContext) AriesApplicationManager(org.apache.aries.application.management.AriesApplicationManager) AriesApplication(org.apache.aries.application.management.AriesApplication) File(java.io.File) Ignore(org.junit.Ignore) Test(org.junit.Test) AbstractIntegrationTest(org.apache.aries.itest.AbstractIntegrationTest)

Example 13 with AriesApplicationManager

use of org.apache.aries.application.management.AriesApplicationManager in project aries by apache.

the class IsolatedRuntimeTest method testAppWithFragment.

@Test
@Ignore
public void testAppWithFragment() throws Exception {
    AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
    AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("withFragment.eba")));
    AriesApplicationContext ctx = manager.install(app);
    ctx.start();
    assertHelloWorldService("withFragment.eba");
    manager.uninstall(ctx);
}
Also used : AriesApplicationContext(org.apache.aries.application.management.AriesApplicationContext) AriesApplicationManager(org.apache.aries.application.management.AriesApplicationManager) AriesApplication(org.apache.aries.application.management.AriesApplication) File(java.io.File) Ignore(org.junit.Ignore) Test(org.junit.Test) AbstractIntegrationTest(org.apache.aries.itest.AbstractIntegrationTest)

Example 14 with AriesApplicationManager

use of org.apache.aries.application.management.AriesApplicationManager in project aries by apache.

the class BasicAppManagerTest method testAppStore.

@Test
public void testAppStore() throws Exception {
    AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
    AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("test2.eba")));
    app = manager.resolve(app);
    app.store(new FileOutputStream("test2-resolved.eba"));
    app = manager.createApplication(FileSystem.getFSRoot(new File("test2-resolved.eba")));
    // application name should equal to whatever Application name provided in the application.mf
    assertEquals("test application 2", app.getApplicationMetadata().getApplicationName());
    AriesApplicationContext ctx = manager.install(app);
    ctx.start();
    HelloWorld hw = context().getService(HelloWorld.class);
    String result = hw.getMessage();
    assertEquals(result, "hello world");
    ctx.stop();
    manager.uninstall(ctx);
}
Also used : AriesApplicationContext(org.apache.aries.application.management.AriesApplicationContext) AriesApplicationManager(org.apache.aries.application.management.AriesApplicationManager) FileOutputStream(java.io.FileOutputStream) AriesApplication(org.apache.aries.application.management.AriesApplication) File(java.io.File) HelloWorld(org.apache.aries.sample.HelloWorld) Test(org.junit.Test) AbstractIntegrationTest(org.apache.aries.itest.AbstractIntegrationTest)

Example 15 with AriesApplicationManager

use of org.apache.aries.application.management.AriesApplicationManager in project aries by apache.

the class BasicAppManagerTest method testAppWithoutApplicationManifest.

@Test
public void testAppWithoutApplicationManifest() throws Exception {
    AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
    AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("test.eba")));
    // application name should be equal to eba name since application.mf is not provided
    assertEquals("test.eba", app.getApplicationMetadata().getApplicationName());
    AriesApplicationContext ctx = manager.install(app);
    ctx.start();
    HelloWorld hw = context().getService(HelloWorld.class);
    String result = hw.getMessage();
    assertEquals(result, "hello world");
    ctx.stop();
    manager.uninstall(ctx);
}
Also used : AriesApplicationContext(org.apache.aries.application.management.AriesApplicationContext) AriesApplicationManager(org.apache.aries.application.management.AriesApplicationManager) AriesApplication(org.apache.aries.application.management.AriesApplication) File(java.io.File) HelloWorld(org.apache.aries.sample.HelloWorld) Test(org.junit.Test) AbstractIntegrationTest(org.apache.aries.itest.AbstractIntegrationTest)

Aggregations

AriesApplicationManager (org.apache.aries.application.management.AriesApplicationManager)25 AriesApplication (org.apache.aries.application.management.AriesApplication)24 AbstractIntegrationTest (org.apache.aries.itest.AbstractIntegrationTest)22 Test (org.junit.Test)22 File (java.io.File)21 AriesApplicationContext (org.apache.aries.application.management.AriesApplicationContext)19 RepositoryAdmin (org.apache.felix.bundlerepository.RepositoryAdmin)9 Ignore (org.junit.Ignore)9 Repository (org.apache.felix.bundlerepository.Repository)8 HelloWorld (org.apache.aries.sample.HelloWorld)7 Bundle (org.osgi.framework.Bundle)3 BundleContext (org.osgi.framework.BundleContext)3 ArrayList (java.util.ArrayList)2 DeploymentContent (org.apache.aries.application.DeploymentContent)2 DeploymentMetadata (org.apache.aries.application.DeploymentMetadata)2 FileOutputStream (java.io.FileOutputStream)1 HashMap (java.util.HashMap)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 Content (org.apache.aries.application.Content)1 ResolveConstraint (org.apache.aries.application.management.ResolveConstraint)1