Search in sources :

Example 6 with HelloWorld

use of org.apache.aries.sample.HelloWorld 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 7 with HelloWorld

use of org.apache.aries.sample.HelloWorld in project aries by apache.

the class OBRAppManagerTest method testAppWithApplicationManifest.

@Test
public void testAppWithApplicationManifest() throws Exception {
    RepositoryAdmin repositoryAdmin = context().getService(RepositoryAdmin.class);
    repositoryAdmin.addRepository(new File("repository.xml").toURI().toURL());
    Repository[] repos = repositoryAdmin.listRepositories();
    for (Repository repo : repos) {
        Resource[] resources = repo.getResources();
        for (Resource r : resources) {
            Capability[] cs = r.getCapabilities();
            for (Capability c : cs) {
                System.out.println(c.getName() + " : " + c.getProperties());
            }
        }
    }
    AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
    AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("test.eba")));
    app = manager.resolve(app);
    //installing requires a valid url for the bundle in repository.xml.
    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 : RepositoryAdmin(org.apache.felix.bundlerepository.RepositoryAdmin) Capability(org.apache.felix.bundlerepository.Capability) AriesApplicationManager(org.apache.aries.application.management.AriesApplicationManager) Resource(org.apache.felix.bundlerepository.Resource) AriesApplication(org.apache.aries.application.management.AriesApplication) HelloWorld(org.apache.aries.sample.HelloWorld) Repository(org.apache.felix.bundlerepository.Repository) AriesApplicationContext(org.apache.aries.application.management.AriesApplicationContext) File(java.io.File) Test(org.junit.Test) AbstractIntegrationTest(org.apache.aries.itest.AbstractIntegrationTest)

Aggregations

File (java.io.File)7 AriesApplication (org.apache.aries.application.management.AriesApplication)7 AriesApplicationContext (org.apache.aries.application.management.AriesApplicationContext)7 AriesApplicationManager (org.apache.aries.application.management.AriesApplicationManager)7 AbstractIntegrationTest (org.apache.aries.itest.AbstractIntegrationTest)7 HelloWorld (org.apache.aries.sample.HelloWorld)7 Test (org.junit.Test)7 Repository (org.apache.felix.bundlerepository.Repository)2 RepositoryAdmin (org.apache.felix.bundlerepository.RepositoryAdmin)2 FileOutputStream (java.io.FileOutputStream)1 Capability (org.apache.felix.bundlerepository.Capability)1 Resource (org.apache.felix.bundlerepository.Resource)1