Package org.apache.aries.application.management

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


    @Test
    public void test() throws Exception {
 
  /* 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/blog/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"));
   
   
    //So Blog is working properly, let's quiesce it, we would expect to get a JPA and a Blueprint
    //participant
   
    QuiesceManager quiesceMgr = getOsgiService(QuiesceManager.class);
    List<Bundle> bundleList = new ArrayList<Bundle>();
    bundleList.add(bapi);
    quiesceMgr.quiesce(500,bundleList);
    Thread.sleep(1000);
   
    //blog api bundle should now be stopped, but others should still be running
    assertTrue("Blog api bundle should have been quiesced, but it's state is "+bapi.getState(), bapi.getState() != bapi.ACTIVE);
  assertEquals(bweb.ACTIVE, bweb.getState());
  assertEquals(bbiz.ACTIVE, bbiz.getState());
  assertEquals(bper.ACTIVE, bper.getState());
 
  bundleList.add(bweb);
  bundleList.add(bbiz);
  bundleList.add(bper);
 
  quiesceMgr.quiesce(500,bundleList);
    Thread.sleep(1000);
   
    //all blog bundles should now be stopped
    assertTrue("Blog api bundle should have been quiesced, but it's state is "+bapi.getState(), bapi.getState() != bapi.ACTIVE);
    assertTrue("Blog web bundle should have been quiesced, but it's state is "+bweb.getState(), bweb.getState() != bweb.ACTIVE);
    assertTrue("Blog biz bundle should have been quiesced, but it's state is "+bbiz.getState(), bbiz.getState() != bbiz.ACTIVE);
    assertTrue("Blog persistence bundle should have been quiesced, but it's state is "+bper.getState(), bper.getState() != bper.ACTIVE);
   
    //check we can start them again after quiesce and everything works as before
    bapi.start();
    bweb.start();
    bbiz.start();
    bper.start();

    /*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));
   
  conn = makeConnection("http://localhost:8080/blog/ViewBlog");
    response = getHTTPResponse(conn);

    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


    @Test
    public void test() throws Exception {
 
  /* 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(Bundle.ACTIVE, bapi.getState());

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

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

  Bundle bper = getInstalledBundle("org.apache.aries.samples.blog.persistence.jpa");
    assertNotNull(bper);
  assertEquals(Bundle.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 registered for " + bbiz.getSymbolicName(), isServiceRegistered(bbiz));
  assertTrue("No services registered for " + bper.getSymbolicName(), isServiceRegistered(bper));
  assertTrue("No services registered for " + bds.getSymbolicName(), isServiceRegistered(bds));
  assertTrue("No services registered 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/blog/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

    @Test
    public void test() throws Exception {

        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(Bundle.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(Bundle.ACTIVE, bbiz.getState());

        Bundle bper = getInstalledBundle("org.apache.aries.samples.blog.persistence.jdbc");
        assertNotNull(bper);
    assertEquals(Bundle.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 registered for " + bbiz.getSymbolicName(), isServiceRegistered(bbiz));
      assertTrue("No services registered 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/blog/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

  }
 
  @Test
  public void testAppWithoutApplicationManifest() throws Exception {
   
    AriesApplicationManager manager = getOsgiService(AriesApplicationManager.class);
    AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("test.eba")));
    AriesApplicationContext ctx = manager.install(app);
    ctx.start();
   
    HelloWorld hw = getOsgiService(HelloWorld.class);
    String result = hw.getMessage();
    assertEquals (result, "hello world");
   
    ctx.stop();
    manager.uninstall(ctx);
  }
View Full Code Here

    manager.uninstall(ctx);
  }

  @Test
  public void testAppWithApplicationManifest() throws Exception {
    AriesApplicationManager manager = getOsgiService(AriesApplicationManager.class);
    AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("test2.eba")));
    AriesApplicationContext ctx = manager.install(app);
    ctx.start();
   
    HelloWorld hw = getOsgiService(HelloWorld.class);
    String result = hw.getMessage();
    assertEquals (result, "hello world");
   
    ctx.stop();
    manager.uninstall(ctx);
  }
View Full Code Here

      repositoryAdmin.removeRepository(repo.getURL());
    }
   
    repositoryAdmin.addRepository(new File("repository.xml").toURI().toURL());

    AriesApplicationManager manager = getOsgiService(AriesApplicationManager.class);
    AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("blog.eba")));
    //installing requires a valid url for the bundle in repository.xml.
   
    app = manager.resolve(app);
  }
View Full Code Here

      repositoryAdmin.removeRepository(repo.getURL());
    }
   
    repositoryAdmin.addRepository(new File("repository.xml").toURI().toURL());

    AriesApplicationManager manager = getOsgiService(AriesApplicationManager.class);
    AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("blog.eba")));
    //installing requires a valid url for the bundle in repository.xml.
   
    app = manager.resolve(app);
   
    DeploymentMetadata depMeta = app.getDeploymentMetadata();
   
    List<DeploymentContent> provision = depMeta.getApplicationProvisionBundles();
   
    assertEquals(provision.toString(), 2, provision.size());
   
    List<String> bundleSymbolicNames = new ArrayList<String>();
   
    for (DeploymentContent dep : provision) {
      bundleSymbolicNames.add(dep.getContentName());
    }
   
    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));
   
    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

          System.out.println(c.getName() + " : " + c.getProperties());
        }
      }
    }
   
    AriesApplicationManager manager = getOsgiService(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.
//    ApplicationContext ctx = manager.install(app);
//    ctx.start();

//    HelloWorld hw = getOsgiService(HelloWorld.class);
View Full Code Here

                                                Collection<ConfigurationStore> configurationStores,
                                                ArtifactResolver artifactResolver,
                                                ConfigurationStore targetConfigurationStore)
        throws IOException, DeploymentException {
               
        AriesApplicationManager appManager = getAriesApplicationManager();
       
        AriesApplication app = null;
        try {
            app = appManager.createApplication(FileSystem.getFSRoot(new File(jarFile.getName())));
        } catch (Exception e) {
            throw new DeploymentException("Error creating Aries Application", e);
        }
       
        try {
            app = appManager.resolve(app);
        } catch (Exception e) {
            throw new DeploymentException("Error resolving Aries Application", e);
        }
               
        DeploymentContext context = installer.startInstall(app, targetConfigurationStore);
View Full Code Here

   
    FileWriter writer = new FileWriter("twitterRepo.xml");
    writer.write(repo);
    writer.close();
    repositoryAdmin.addRepository(new File("twitterRepo.xml").toURI().toURL());
    AriesApplicationManager manager = getOsgiService(AriesApplicationManager.class);
    AriesApplication app = manager.createApplication(twitterEbaUrl);
    app = manager.resolve(app);
    DeploymentMetadata depMeta = app.getDeploymentMetadata();
    List<DeploymentContent> provision = depMeta.getApplicationProvisionBundles();
    Collection<DeploymentContent> useBundles = depMeta.getDeployedUseBundle();
    Collection<DeploymentContent> appContent = depMeta.getApplicationDeploymentContents();
    // We cannot be sure whether there are two or three provision bundles pulled in by Felix OBR as there is an outstanding defect
    // https://issues.apache.org/jira/browse/FELIX-2672
    // The workaround is to check we get the two bundles we are looking for, instead of insisting on just having two bundles.
   
    List<String> provisionBundleSymbolicNames = new ArrayList<String>();
    for (DeploymentContent dep : provision) {
       provisionBundleSymbolicNames.add(dep.getContentName());
    }
    String provision_bundle1 = "org.apache.commons.lang";
    String provision_bundle2 = "twitter4j";
    assertTrue("Bundle " + provision_bundle1 + " not found.", provisionBundleSymbolicNames.contains(provision_bundle1));
    assertTrue("Bundle " + provision_bundle2 + " not found.", provisionBundleSymbolicNames.contains(provision_bundle2));
    assertEquals(useBundles.toString(), 0, useBundles.size());
    assertEquals(appContent.toString(), 1, appContent.size());
    AriesApplicationContext ctx = manager.install(app);
    ctx.start();
  }
View Full Code Here

TOP

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

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.