use of org.apache.aries.application.management.AriesApplicationContext in project aries by apache.
the class QuiesceBlogSampleWithEbaTest method test.
@Test
public void test() throws Exception {
resolveBundles();
MavenArtifactUrlReference eba = CoreOptions.maven().groupId("org.apache.aries.samples.blog").artifactId("org.apache.aries.samples.blog.jpa.eba").versionAsInProject().type("eba");
AriesApplicationContext ctx = installEba(eba);
/* Find and check all the blog sample bundles */
Bundle bapi = assertBundleStarted("org.apache.aries.samples.blog.api");
Bundle bweb = assertBundleStarted("org.apache.aries.samples.blog.web");
Bundle bbiz = assertBundleStarted("org.apache.aries.samples.blog.biz");
Bundle bper = assertBundleStarted("org.apache.aries.samples.blog.persistence.jpa");
Bundle bds = assertBundleStarted("org.apache.aries.samples.blog.datasource");
Bundle txs = assertBundleStarted("org.apache.aries.transaction.manager");
assertBlogServicesStarted();
checkBlogWebAccess();
//So Blog is working properly, let's quiesce it, we would expect to get a JPA and a Blueprint
//participant
quiesceMgr.quiesce(500, Collections.singletonList(bapi));
Thread.sleep(1000);
// Blog api bundle should now be stopped, but others should still be running
assertResolved(bapi);
assertActive(bweb);
assertActive(bbiz);
assertActive(bper);
quiesceMgr.quiesce(500, Arrays.asList(bapi, bweb, bbiz, bper));
Thread.sleep(1000);
// All blog bundles should now be stopped
assertResolved(bapi);
assertResolved(bweb);
assertResolved(bbiz);
assertResolved(bper);
// Check we can start them again after quiesce and everything works as before
bapi.start();
bweb.start();
bbiz.start();
bper.start();
assertBlogServicesStarted();
assertBlogServicesStarted();
System.out.println("Checking if blog works again after restart");
checkBlogWebAccess();
ctx.stop();
manager.uninstall(ctx);
}
use of org.apache.aries.application.management.AriesApplicationContext in project aries by apache.
the class AbstractBlogIntegrationTest method installEba.
protected AriesApplicationContext installEba(MavenArtifactUrlReference eba) throws Exception {
AriesApplication app = manager.createApplication(new URL(eba.getURL()));
AriesApplicationContext ctx = manager.install(app);
ctx.start();
return ctx;
}
use of org.apache.aries.application.management.AriesApplicationContext 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.application.management.AriesApplicationContext 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);
}
use of org.apache.aries.application.management.AriesApplicationContext 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);
}
Aggregations