use of org.apache.aries.application.management.AriesApplication in project aries by apache.
the class BasicNoOpResolverTest 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.application.management.AriesApplication in project aries by apache.
the class TwitterTest method testTwitter.
/**
* Test for ARIES-461
* Application that bring in dependency bundles from a bundle repository doesn't deploy
*
* @throws Exception
*/
@Test
public void testTwitter() throws Exception {
// provision against the local runtime
System.setProperty(AppConstants.PROVISON_EXCLUDE_LOCAL_REPO_SYSPROP, "false");
deleteRepos();
MavenArtifactUrlReference twitterEbaUrl = maven("org.apache.aries.samples.twitter", "org.apache.aries.samples.twitter.eba").versionAsInProject().type("eba");
MavenArtifactUrlReference twitterCommonLangJar = maven("commons-lang", "commons-lang").versionAsInProject();
MavenArtifactUrlReference twitterJar = maven("org.apache.aries.samples.twitter", "org.apache.aries.samples.twitter.twitter4j").versionAsInProject();
// add the repository xml to the repository admin
String repositoryXML = getRepoContent("/obr/twitter/TwitterRepository.xml");
// replace the jar file url with the real url related to the environment
String repo = repositoryXML.replaceAll("commons.lang.location", twitterCommonLangJar.getURL()).replaceAll("twitter4j.location", twitterJar.getURL());
URL url = getRepoUrl(repo);
repositoryAdmin.addRepository(url);
AriesApplication app = manager.createApplication(new URL(twitterEbaUrl.getURL()));
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();
}
Aggregations