Search in sources :

Example 6 with AriesApplicationManager

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

the class OBRResolverTest method testBlogAppResolveFail.

@Test(expected = ResolverException.class)
public void testBlogAppResolveFail() throws ResolverException, Exception {
    //  provision against the local runtime
    System.setProperty(AppConstants.PROVISON_EXCLUDE_LOCAL_REPO_SYSPROP, "false");
    generateOBRRepoXML(TRANSITIVE_BUNDLE_BY_REFERENCE + ".jar", CORE_BUNDLE_BY_REFERENCE + "_0.0.0.jar");
    RepositoryAdmin repositoryAdmin = context().getService(RepositoryAdmin.class);
    Repository[] repos = repositoryAdmin.listRepositories();
    for (Repository repo : repos) {
        repositoryAdmin.removeRepository(repo.getURI());
    }
    repositoryAdmin.addRepository(new File("repository.xml").toURI().toURL());
    AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
    AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("blog.eba")));
    //installing requires a valid url for the bundle in repository.xml.
    app = manager.resolve(app);
}
Also used : Repository(org.apache.felix.bundlerepository.Repository) RepositoryAdmin(org.apache.felix.bundlerepository.RepositoryAdmin) AriesApplicationManager(org.apache.aries.application.management.AriesApplicationManager) AriesApplication(org.apache.aries.application.management.AriesApplication) File(java.io.File) Test(org.junit.Test) AbstractIntegrationTest(org.apache.aries.itest.AbstractIntegrationTest)

Example 7 with AriesApplicationManager

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

the class UpdateAppTest method testFullUpdate.

@Test
@Ignore
public void testFullUpdate() throws Exception {
    AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
    AriesApplication app = setupApp();
    updateApp(manager, app);
    assertAppMessage("hello brave new world");
}
Also used : AriesApplicationManager(org.apache.aries.application.management.AriesApplicationManager) AriesApplication(org.apache.aries.application.management.AriesApplication) Ignore(org.junit.Ignore) Test(org.junit.Test) AbstractIntegrationTest(org.apache.aries.itest.AbstractIntegrationTest)

Example 8 with AriesApplicationManager

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

the class IsolatedCfgAdminRuntimeTest method uninstallApplication.

private void uninstallApplication(Context ctx) throws Exception {
    AriesApplicationManager appManager = context().getService(AriesApplicationManager.class);
    appManager.uninstall(ctx.getApplicationContext());
}
Also used : AriesApplicationManager(org.apache.aries.application.management.AriesApplicationManager)

Example 9 with AriesApplicationManager

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

the class IsolatedRuntimeTest method testFrameworkResolvedBeforeInnerBundlesStart.

@Test
@Ignore
public void testFrameworkResolvedBeforeInnerBundlesStart() throws Exception {
    /*
       * Lazy bundles have in the past triggered recursive bundle trackers to handle them before
       * the composite bundle framework was even resolved. In such a case the below loadClass
       * operation on a class that depends on a class imported from the outside of the composite 
       * will fail with an NPE.
       */
    final AtomicBoolean loadedClass = new AtomicBoolean(false);
    context().addBundleListener(new SynchronousBundleListener() {

        public void bundleChanged(BundleEvent event) {
            Bundle b = event.getBundle();
            if (event.getType() == BundleEvent.STARTING || event.getType() == BundleEvent.LAZY_ACTIVATION) {
                if (b.getEntry("org/apache/aries/isolated/sample/SharedImpl.class") != null) {
                    try {
                        Class<?> cl = b.loadClass("org.apache.aries.isolated.sample.SharedImpl");
                        cl.newInstance();
                        loadedClass.set(true);
                    } catch (Exception e) {
                        e.printStackTrace();
                        throw new RuntimeException(e);
                    }
                }
            } else if (event.getType() == BundleEvent.INSTALLED && b instanceof CompositeBundle) {
                ((CompositeBundle) b).getCompositeFramework().getBundleContext().addBundleListener(this);
            }
        }
    });
    AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
    AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("test2.eba")));
    AriesApplicationContext ctx = manager.install(app);
    try {
        ctx.start();
        app = ctx.getApplication();
        assertEquals(1, app.getDeploymentMetadata().getApplicationDeploymentContents().size());
        assertEquals(1, app.getDeploymentMetadata().getApplicationProvisionBundles().size());
        assertTrue(loadedClass.get());
    } finally {
        manager.uninstall(ctx);
    }
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) CompositeBundle(org.osgi.service.framework.CompositeBundle) Bundle(org.osgi.framework.Bundle) AriesApplicationContext(org.apache.aries.application.management.AriesApplicationContext) AriesApplicationManager(org.apache.aries.application.management.AriesApplicationManager) AriesApplication(org.apache.aries.application.management.AriesApplication) BundleEvent(org.osgi.framework.BundleEvent) PerClass(org.ops4j.pax.exam.spi.reactors.PerClass) CompositeBundle(org.osgi.service.framework.CompositeBundle) File(java.io.File) SynchronousBundleListener(org.osgi.framework.SynchronousBundleListener) Ignore(org.junit.Ignore) Test(org.junit.Test) AbstractIntegrationTest(org.apache.aries.itest.AbstractIntegrationTest)

Example 10 with AriesApplicationManager

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

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

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