Package org.apache.aries.application.management

Examples of org.apache.aries.application.management.AriesApplicationContext


  public void testFailedUpdate() throws Exception {
    AriesApplication app = createApplication(TEST_EBA);

    DeploymentMetadata depMf = createUpdateDepMf();
   
    AriesApplicationContext ctx = Skeleton.newMock(AriesApplicationContext.class);
    Skeleton.getSkeleton(ctx).setReturnValue(new MethodCall(AriesApplicationContext.class, "getApplication"), app);
   
    AriesApplicationContextManager ctxMgr = Skeleton.newMock(AriesApplicationContextManager.class);
    Skeleton.getSkeleton(ctxMgr).setReturnValue(
        new MethodCall(AriesApplicationContextManager.class, "getApplicationContexts"),
View Full Code Here


    AriesApplication app = createApplication(TEST_EBA);

    DeploymentMetadata depMf = createUpdateDepMf();
    DeploymentMetadata oldMf = app.getDeploymentMetadata();
   
    AriesApplicationContext ctx = Skeleton.newMock(AriesApplicationContext.class);
    Skeleton.getSkeleton(ctx).setReturnValue(new MethodCall(AriesApplicationContext.class, "getApplication"), app);
   
    AriesApplicationContextManager ctxMgr = Skeleton.newMock(AriesApplicationContextManager.class);
    Skeleton.getSkeleton(ctxMgr).setReturnValue(
        new MethodCall(AriesApplicationContextManager.class, "getApplicationContexts"),
View Full Code Here

            new ApplicationRepository(app),
            dict);
        serviceRegistrations.put(app, serviceReg);
    }
 
    AriesApplicationContext result = _applicationContextManager.getApplicationContext(app);
   
    // When installing bundles in the .eba file we use the jar url scheme. This results in a
    // JarFile being held open, which is bad as on windows we cannot delete the .eba file
    // so as a work around we open a url connection to one of the bundles in the eba and
    // if it is a jar url we close the associated JarFile.
View Full Code Here

      throw new IllegalArgumentException("The deployment metadata does not match the application.");
    }
   
    DeploymentMetadata oldMetadata = app.getDeploymentMetadata();
   
    AriesApplicationContext foundCtx = null;
    for (AriesApplicationContext ctx : _applicationContextManager.getApplicationContexts()) {
      if (ctx.getApplication().equals(app)) {
        foundCtx = ctx;
        break;
      }
View Full Code Here

 
  /* Install and start the blog eba */
  URL urlToEba = getUrlToEba("org.apache.aries.samples.blog", "org.apache.aries.samples.blog.jpa.eba");
  AriesApplicationManager manager = getOsgiService(AriesApplicationManager.class);
  AriesApplication app = manager.createApplication(urlToEba);
  AriesApplicationContext ctx = manager.install(app);
  ctx.start();

    /* Find and check all the blog sample bundles */

  Bundle bapi = getInstalledBundle("org.apache.aries.samples.blog.api");
    assertNotNull(bapi);
  assertEquals(bapi.ACTIVE, bapi.getState());

  Bundle bweb = getInstalledBundle("org.apache.aries.samples.blog.web");
    assertNotNull(bweb);
  assertEquals(bweb.ACTIVE, bweb.getState());

  Bundle bbiz = getInstalledBundle("org.apache.aries.samples.blog.biz");
    assertNotNull(bbiz);
  assertEquals(bbiz.ACTIVE, bbiz.getState());

  Bundle bper = getInstalledBundle("org.apache.aries.samples.blog.persistence.jpa");
    assertNotNull(bper);
  assertEquals(bper.ACTIVE, bper.getState());
    /* Datasource and transaction manager services are used by the blog sample */
  Bundle bds = getInstalledBundle("org.apache.aries.samples.blog.datasource");
  Bundle txs = getInstalledBundle("org.apache.aries.transaction.manager");

    /*Wait for all the required services to be registered */
    waitForServices(bbiz, "org.apache.aries.samples.blog.api.BloggingService");
    waitForServices(bper, "org.apache.aries.samples.blog.api.persistence.BlogPersistenceService");
    waitForServices(bds, "javax.sql.XADataSource");
    waitForServices(txs, "javax.transaction.TransactionManager");


    /*Check that they haven't timed out trying to register*/
  assertTrue("No services reistered for " + bbiz.getSymbolicName(), isServiceRegistered(bbiz));
  assertTrue("No services reistered for " + bper.getSymbolicName(), isServiceRegistered(bper));
  assertTrue("No services reistered for " + bds.getSymbolicName(), isServiceRegistered(bds));
  assertTrue("No services reistered for " + txs.getSymbolicName(), isServiceRegistered(txs));

  /*Check what services are registered - uncomment for additional debug */
  /*
  listBundleServices(bbiz);
  listBundleServices(bper);
  listBundleServices(bds);
  listBundleServices(txs);
   
  System.out.println("In test and trying to get connection....");
  */

  HttpURLConnection conn = makeConnection("http://localhost:8080/org.apache.aries.samples.blog.web/ViewBlog");
    String response = getHTTPResponse(conn);

  /* Uncomment for additional debug */
  /*
  System.out.println("ZZZZZ " + response);
    System.out.println("ZZZZZ " + conn.getResponseCode());
    System.out.println("ZZZZZ " + HttpURLConnection.HTTP_OK);
  */


    assertEquals(HttpURLConnection.HTTP_OK,
        conn.getResponseCode());

    assertTrue("The response did not contain the expected content", response.contains("Blog home"));
  ctx.stop();
    manager.uninstall(ctx);

    }
View Full Code Here

        URL urlToEba = getUrlToEba("org.apache.aries.samples.blog", "org.apache.aries.samples.blog.jdbc.eba");

        AriesApplicationManager manager = getOsgiService(AriesApplicationManager.class);
        AriesApplication app = manager.createApplication(urlToEba);
        AriesApplicationContext ctx = manager.install(app);
        ctx.start();

    /* Check that the Blog Sample bundles are present an started */
        Bundle bapi = getInstalledBundle("org.apache.aries.samples.blog.api");
        assertNotNull(bapi);
    assertEquals(bapi.ACTIVE, bapi.getState());

        Bundle bweb = getInstalledBundle("org.apache.aries.samples.blog.web");
        assertNotNull(bweb);

        Bundle bbiz = getInstalledBundle("org.apache.aries.samples.blog.biz");
        assertNotNull(bbiz);
    assertEquals(bbiz.ACTIVE, bbiz.getState());

        Bundle bper = getInstalledBundle("org.apache.aries.samples.blog.persistence.jdbc");
        assertNotNull(bper);
    assertEquals(bper.ACTIVE, bper.getState());

        /* Require services from biz and persistence - wait for them to register */
        waitForServices(bbiz, "org.apache.aries.samples.blog.api.BloggingService");
        waitForServices(bper, "org.apache.aries.samples.blog.api.persistence.BlogPersistenceService");

       /*Check that they haven't timed out trying to register*/
      assertTrue("No services reistered for " + bbiz.getSymbolicName(), isServiceRegistered(bbiz));
      assertTrue("No services reistered for " + bper.getSymbolicName(), isServiceRegistered(bper));

    /*Check what services are registered - uncomment for additional debug */
    /*
      listBundleServices(bbiz);
      listBundleServices(bper);

      System.out.println("In test and trying to get connection....");
    */
        HttpURLConnection conn = makeConnection("http://localhost:8080/org.apache.aries.samples.blog.web/ViewBlog");
        String response = getHTTPResponse(conn);
    /* Uncomment for additional debug */
    /*
        System.out.println("ZZZZZ " + response);
        System.out.println("ZZZZZ " + conn.getResponseCode());
        System.out.println("ZZZZZ " + HttpURLConnection.HTTP_OK);
    */

        assertEquals(HttpURLConnection.HTTP_OK, conn.getResponseCode());

        assertTrue("The response did not contain the expected content",
                response.contains("Blog home"));

        ctx.stop();
        manager.uninstall(ctx);
    }
View Full Code Here

   
    assertTrue("Bundle " + TRANSITIVE_BUNDLE_BY_REFERENCE + " not found.", bundleSymbolicNames.contains(TRANSITIVE_BUNDLE_BY_REFERENCE));
    assertTrue("Bundle " + TRANSITIVE_BUNDLE_BY_VALUE + " not found.", bundleSymbolicNames.contains(TRANSITIVE_BUNDLE_BY_VALUE));
    assertTrue("Bundle " + BUNDLE_IN_FRAMEWORK + " not found.", bundleSymbolicNames.contains(BUNDLE_IN_FRAMEWORK));
   
    AriesApplicationContext ctx = manager.install(app);
    ctx.start();

    Set<Bundle> bundles = ctx.getApplicationContent();
   
    assertEquals("Number of bundles provisioned in the app", 4, bundles.size());
   
    ctx.stop();
    manager.uninstall(ctx);
  }
View Full Code Here

  @Test
  public void testUpdateThenStart() throws Exception
  {
    AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
    AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("test.eba")));
    AriesApplicationContext ctx = manager.install(app);
    app = ctx.getApplication();

    BundleContext oldCtx = IsolationTestUtils.findIsolatedAppBundleContext(bundleContext, SAMPLE_APP_NAME);
   
    installMockUpdateStrategy();
    ctx = updateApp(manager, app);
   
    BundleContext newCtx = IsolationTestUtils.findIsolatedAppBundleContext(bundleContext, SAMPLE_APP_NAME);   
   
    assertNull("App is not started yet but HelloWorld service is already there",
        IsolationTestUtils.findHelloWorldService(bundleContext, SAMPLE_APP_NAME));
   
    ctx.start();
   
    assertAppMessage("hello brave new world");
   
    assertTrue("We bounced the app where the update was supposed to do an update in place", oldCtx == newCtx);
  }
View Full Code Here

  }
 
  private AriesApplication setupApp() throws Exception {
    AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
    AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("test.eba")));
    AriesApplicationContext ctx = manager.install(app);
    app = ctx.getApplication();

    ctx.start();
    assertAppMessage("hello world");   
   
    return app;
  }
View Full Code Here

     
      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);
    }
View Full Code Here

TOP

Related Classes of org.apache.aries.application.management.AriesApplicationContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.