Search in sources :

Example 11 with AriesApplicationContext

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);
}
Also used : AriesApplicationContext(org.apache.aries.application.management.AriesApplicationContext) Bundle(org.osgi.framework.Bundle) MavenArtifactUrlReference(org.ops4j.pax.exam.options.MavenArtifactUrlReference) Test(org.junit.Test)

Example 12 with AriesApplicationContext

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;
}
Also used : AriesApplicationContext(org.apache.aries.application.management.AriesApplicationContext) AriesApplication(org.apache.aries.application.management.AriesApplication) URL(java.net.URL)

Example 13 with AriesApplicationContext

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);
}
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 14 with AriesApplicationContext

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);
}
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 15 with AriesApplicationContext

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

AriesApplicationContext (org.apache.aries.application.management.AriesApplicationContext)34 AriesApplication (org.apache.aries.application.management.AriesApplication)24 Test (org.junit.Test)23 AriesApplicationManager (org.apache.aries.application.management.AriesApplicationManager)19 File (java.io.File)18 AbstractIntegrationTest (org.apache.aries.itest.AbstractIntegrationTest)18 HelloWorld (org.apache.aries.sample.HelloWorld)7 Ignore (org.junit.Ignore)7 DeploymentMetadata (org.apache.aries.application.DeploymentMetadata)6 RepositoryAdmin (org.apache.felix.bundlerepository.RepositoryAdmin)6 ArrayList (java.util.ArrayList)5 Repository (org.apache.felix.bundlerepository.Repository)5 UpdateException (org.apache.aries.application.management.UpdateException)4 MavenArtifactUrlReference (org.ops4j.pax.exam.options.MavenArtifactUrlReference)4 Bundle (org.osgi.framework.Bundle)4 URL (java.net.URL)3 DeploymentContent (org.apache.aries.application.DeploymentContent)3 BundleException (org.osgi.framework.BundleException)3 AriesApplicationContextManager (org.apache.aries.application.management.spi.runtime.AriesApplicationContextManager)2 MethodCall (org.apache.aries.unittest.mocks.MethodCall)2