Search in sources :

Example 16 with AriesApplicationManager

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

the class BasicNoOpResolverTest 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)

Example 17 with AriesApplicationManager

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

the class BasicNoOpResolverTest method testAppWithApplicationManifest.

@Test
public void testAppWithApplicationManifest() throws Exception {
    AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
    AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("test2.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) 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 18 with AriesApplicationManager

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

the class UpdateAppTest method testFineUpdate.

@Test
@Ignore
public void testFineUpdate() throws Exception {
    AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
    AriesApplication app = setupApp();
    BundleContext oldCtx = IsolationTestUtils.findIsolatedAppBundleContext(bundleContext, SAMPLE_APP_NAME);
    installMockUpdateStrategy();
    updateApp(manager, app);
    BundleContext newCtx = IsolationTestUtils.findIsolatedAppBundleContext(bundleContext, SAMPLE_APP_NAME);
    assertAppMessage("hello brave new world");
    assertTrue("We bounced the app where the update was supposed to do an update in place", oldCtx == newCtx);
}
Also used : AriesApplicationManager(org.apache.aries.application.management.AriesApplicationManager) AriesApplication(org.apache.aries.application.management.AriesApplication) BundleContext(org.osgi.framework.BundleContext) Ignore(org.junit.Ignore) Test(org.junit.Test) AbstractIntegrationTest(org.apache.aries.itest.AbstractIntegrationTest)

Example 19 with AriesApplicationManager

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

the class UpdateAppTest method testUpdateThenStart.

@Test
@Ignore
public void testUpdateThenStart() throws Exception {
    AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
    AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("test.eba")));
    AriesApplicationContext ctx = manager.install(app);
    app = ctx.getApplication();
    BundleContext oldCtx = IsolationTestUtils.findIsolatedAppBundleContext(bundleContext, SAMPLE_APP_NAME);
    installMockUpdateStrategy();
    ctx = updateApp(manager, app);
    BundleContext newCtx = IsolationTestUtils.findIsolatedAppBundleContext(bundleContext, SAMPLE_APP_NAME);
    assertNull("App is not started yet but HelloWorld service is already there", IsolationTestUtils.findHelloWorldService(bundleContext, SAMPLE_APP_NAME));
    ctx.start();
    assertAppMessage("hello brave new world");
    assertTrue("We bounced the app where the update was supposed to do an update in place", oldCtx == newCtx);
}
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) BundleContext(org.osgi.framework.BundleContext) Ignore(org.junit.Ignore) Test(org.junit.Test) AbstractIntegrationTest(org.apache.aries.itest.AbstractIntegrationTest)

Example 20 with AriesApplicationManager

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

the class UpdateAppTest method setupApp.

private AriesApplication setupApp() throws Exception {
    AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
    AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("test.eba")));
    AriesApplicationContext ctx = manager.install(app);
    app = ctx.getApplication();
    ctx.start();
    assertAppMessage("hello world");
    return app;
}
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)

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