use of org.apache.aries.application.management.AriesApplication in project aries by apache.
the class IsolatedRuntimeTest method testAppWithGlobalRepositoryBundle.
@Test
@Ignore
public void testAppWithGlobalRepositoryBundle() throws Exception {
AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("test2.eba")));
IsolationTestUtils.prepareSampleBundleV2(bundleContext, context().getService(RepositoryGenerator.class), context().getService(RepositoryAdmin.class), context().getService(ModellingManager.class));
AriesApplication newApp = manager.resolve(app, new ResolveConstraint() {
@Override
public String getBundleName() {
return "org.apache.aries.isolated.sample";
}
@Override
public VersionRange getVersionRange() {
return ManifestHeaderProcessor.parseVersionRange("[2.0.0,2.0.0]", true);
}
});
AriesApplicationContext ctx = manager.install(newApp);
ctx.start();
assertHelloWorldService("org.apache.aries.sample2", "hello brave new world");
manager.uninstall(ctx);
}
use of org.apache.aries.application.management.AriesApplication in project aries by apache.
the class IsolatedRuntimeTest method testAppWithFragment.
@Test
@Ignore
public void testAppWithFragment() throws Exception {
AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("withFragment.eba")));
AriesApplicationContext ctx = manager.install(app);
ctx.start();
assertHelloWorldService("withFragment.eba");
manager.uninstall(ctx);
}
use of org.apache.aries.application.management.AriesApplication in project aries by apache.
the class IsolatedRuntimeTest method testFrameworkResolvedBeforeInnerBundlesStart.
@Test
@Ignore
public void testFrameworkResolvedBeforeInnerBundlesStart() throws Exception {
/*
* Lazy bundles have in the past triggered recursive bundle trackers to handle them before
* the composite bundle framework was even resolved. In such a case the below loadClass
* operation on a class that depends on a class imported from the outside of the composite
* will fail with an NPE.
*/
final AtomicBoolean loadedClass = new AtomicBoolean(false);
context().addBundleListener(new SynchronousBundleListener() {
public void bundleChanged(BundleEvent event) {
Bundle b = event.getBundle();
if (event.getType() == BundleEvent.STARTING || event.getType() == BundleEvent.LAZY_ACTIVATION) {
if (b.getEntry("org/apache/aries/isolated/sample/SharedImpl.class") != null) {
try {
Class<?> cl = b.loadClass("org.apache.aries.isolated.sample.SharedImpl");
cl.newInstance();
loadedClass.set(true);
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
} else if (event.getType() == BundleEvent.INSTALLED && b instanceof CompositeBundle) {
((CompositeBundle) b).getCompositeFramework().getBundleContext().addBundleListener(this);
}
}
});
AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("test2.eba")));
AriesApplicationContext ctx = manager.install(app);
try {
ctx.start();
app = ctx.getApplication();
assertEquals(1, app.getDeploymentMetadata().getApplicationDeploymentContents().size());
assertEquals(1, app.getDeploymentMetadata().getApplicationProvisionBundles().size());
assertTrue(loadedClass.get());
} finally {
manager.uninstall(ctx);
}
}
use of org.apache.aries.application.management.AriesApplication in project aries by apache.
the class OBRResolverAdvancedTest method testDemoApp.
@Test
public void testDemoApp() throws Exception {
// do not provision against the local runtime
System.setProperty(AppConstants.PROVISON_EXCLUDE_LOCAL_REPO_SYSPROP, "true");
generateOBRRepoXML(false, TRANSITIVE_BUNDLE_BY_REFERENCE + ".jar", CORE_BUNDLE_BY_REFERENCE + ".jar", USE_BUNDLE_BY_REFERENCE + ".jar");
RepositoryAdmin repositoryAdmin = context().getService(RepositoryAdmin.class);
Repository[] repos = repositoryAdmin.listRepositories();
for (Repository repo : repos) {
repositoryAdmin.removeRepository(repo.getURI());
}
repositoryAdmin.addRepository(new File("repository.xml").toURI().toURL());
AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("demo.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();
Collection<DeploymentContent> useBundles = depMeta.getDeployedUseBundle();
Collection<Content> importPackages = depMeta.getImportPackage();
assertEquals(provision.toString(), 2, provision.size());
assertEquals(useBundles.toString(), 1, useBundles.size());
assertEquals(importPackages.toString(), 4, importPackages.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));
bundleSymbolicNames.clear();
for (DeploymentContent dep : useBundles) {
bundleSymbolicNames.add(dep.getContentName());
}
assertTrue("Bundle " + USE_BUNDLE_BY_REFERENCE + " not found.", bundleSymbolicNames.contains(USE_BUNDLE_BY_REFERENCE));
Collection<String> packages = new ArrayList<String>();
Map<String, String> maps = new HashMap<String, String>();
maps.put("version", "0.0.0");
maps.put("bundle-symbolic-name", "use.bundle.by.reference");
maps.put("bundle-version", "[1.0.0,1.0.0]");
Content useContent = ContentFactory.parseContent("a.b.c", maps);
assertTrue("Use Bundle not found in import packags", importPackages.contains(useContent));
for (Content c : importPackages) {
packages.add(c.getContentName());
}
assertTrue("package javax.naming not found", packages.contains("javax.naming"));
assertTrue("package p.q.r not found", packages.contains("p.q.r"));
assertTrue("package x.y.z not found", packages.contains("x.y.z"));
assertTrue("package a.b.c not found", packages.contains("a.b.c"));
AriesApplicationContext ctx = manager.install(app);
ctx.start();
Set<Bundle> bundles = ctx.getApplicationContent();
assertEquals("Number of bundles provisioned in the app", 5, bundles.size());
ctx.stop();
manager.uninstall(ctx);
}
use of org.apache.aries.application.management.AriesApplication in project aries by apache.
the class OBRResolverAdvancedTest method testDemoAppResolveFail.
@Test(expected = ResolverException.class)
public void testDemoAppResolveFail() throws ResolverException, Exception {
// do not provision against the local runtime
System.setProperty(AppConstants.PROVISON_EXCLUDE_LOCAL_REPO_SYSPROP, "true");
generateOBRRepoXML(false, TRANSITIVE_BUNDLE_BY_REFERENCE + ".jar", CORE_BUNDLE_BY_REFERENCE + "_0.0.0.jar", USE_BUNDLE_BY_REFERENCE + ".jar");
RepositoryAdmin repositoryAdmin = context().getService(RepositoryAdmin.class);
Repository[] repos = repositoryAdmin.listRepositories();
for (Repository repo : repos) {
repositoryAdmin.removeRepository(repo.getURI());
}
repositoryAdmin.addRepository(new File("repository.xml").toURI().toURL());
AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("demo.eba")));
app = manager.resolve(app);
}
Aggregations