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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations