Search in sources :

Example 1 with HelloWorld

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

the class OBRResolverAdvancedTest method testMutlipleServices.

@Test
public void testMutlipleServices() throws Exception {
    // provision against the local runtime
    System.setProperty(AppConstants.PROVISON_EXCLUDE_LOCAL_REPO_SYSPROP, "false");
    generateOBRRepoXML(false, HELLO_WORLD_SERVICE_BUNDLE1 + ".jar", HELLO_WORLD_SERVICE_BUNDLE2 + ".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("hello.eba")));
    AriesApplicationContext ctx = manager.install(app);
    ctx.start();
    // Wait 5 seconds just to give the blueprint-managed beans a chance to come up
    try {
        Thread.sleep(5000);
    } catch (InterruptedException ix) {
    }
    HelloWorld hw = context().getService(HelloWorld.class);
    String result = hw.getMessage();
    assertEquals(result, "hello world");
    // Uncomment the block below after https://issues.apache.org/jira/browse/FELIX-2546,
    // "Only one service is provisioned even when specifying for mulitple services"
    // is fixed. This tracks the problem of provisioning only one service even when we
    // specify multiple services.
    /** HelloWorldManager hwm = context().getService(HelloWorldManager.class);
         * int numberOfServices = hwm.getNumOfHelloServices();
         * assertEquals(2, numberOfServices);
         */
    ctx.stop();
    manager.uninstall(ctx);
}
Also used : Repository(org.apache.felix.bundlerepository.Repository) RepositoryAdmin(org.apache.felix.bundlerepository.RepositoryAdmin) 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) AbstractIntegrationTest(org.apache.aries.itest.AbstractIntegrationTest) Test(org.junit.Test)

Example 2 with HelloWorld

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

Example 3 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)

Example 4 with HelloWorld

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

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

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