use of org.apache.aries.application.management.AriesApplication in project aries by apache.
the class UpdateAppTest method updateApp.
private AriesApplicationContext updateApp(AriesApplicationManager manager, AriesApplication app) throws Exception {
IsolationTestUtils.prepareSampleBundleV2(bundleContext, context().getService(RepositoryGenerator.class), context().getService(RepositoryAdmin.class), context().getService(ModellingManager.class));
AriesApplication newApp = manager.resolve(app, new ResolveConstraint() {
public String getBundleName() {
return "org.apache.aries.isolated.sample";
}
public VersionRange getVersionRange() {
return ManifestHeaderProcessor.parseVersionRange("[2.0.0,2.0.0]", true);
}
});
return manager.update(app, newApp.getDeploymentMetadata());
}
use of org.apache.aries.application.management.AriesApplication in project aries by apache.
the class UpdateAppTest method testFineUpdate.
@Test
@Ignore
public void testFineUpdate() throws Exception {
AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
AriesApplication app = setupApp();
BundleContext oldCtx = IsolationTestUtils.findIsolatedAppBundleContext(bundleContext, SAMPLE_APP_NAME);
installMockUpdateStrategy();
updateApp(manager, app);
BundleContext newCtx = IsolationTestUtils.findIsolatedAppBundleContext(bundleContext, SAMPLE_APP_NAME);
assertAppMessage("hello brave new world");
assertTrue("We bounced the app where the update was supposed to do an update in place", oldCtx == newCtx);
}
use of org.apache.aries.application.management.AriesApplication in project aries by apache.
the class UpdateAppTest method testUpdateThenStart.
@Test
@Ignore
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);
}
use of org.apache.aries.application.management.AriesApplication in project aries by apache.
the class UpdateAppTest method setupApp.
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;
}
use of org.apache.aries.application.management.AriesApplication in project aries by apache.
the class IsolationTestUtils method prepareSampleBundleV2.
/**
* Set up the necessary resources for installing version 2 of the org.apache.aries.isolated.sample sample bundle,
* which returns the message "hello brave new world" rather than "hello world"
*
* This means setting up a global bundle repository as well as a global OBR repository
*/
public static void prepareSampleBundleV2(BundleContext runtimeCtx, RepositoryGenerator repoGen, RepositoryAdmin repoAdmin, ModellingManager modellingManager) throws Exception {
BundleRepository repo = new BundleRepository() {
public int getCost() {
return 1;
}
public BundleSuggestion suggestBundleToUse(DeploymentContent content) {
if (content.getContentName().equals("org.apache.aries.isolated.sample")) {
return new BundleSuggestion() {
public Bundle install(BundleFramework framework, AriesApplication app) throws BundleException {
File f = new File("sample_2.0.0.jar");
try {
return framework.getIsolatedBundleContext().installBundle(f.toURL().toString());
} catch (MalformedURLException mue) {
throw new RuntimeException(mue);
}
}
public Version getVersion() {
return new Version("2.0.0");
}
public Set<Content> getImportPackage() {
return Collections.emptySet();
}
public Set<Content> getExportPackage() {
return Collections.emptySet();
}
public int getCost() {
return 1;
}
};
} else {
return null;
}
}
};
Hashtable<String, String> props = new Hashtable<String, String>();
props.put(BundleRepository.REPOSITORY_SCOPE, BundleRepository.GLOBAL_SCOPE);
runtimeCtx.registerService(BundleRepository.class.getName(), repo, props);
Attributes attrs = new Attributes();
attrs.putValue("Bundle-ManifestVersion", "2");
attrs.putValue("Bundle-Version", "2.0.0");
attrs.putValue("Bundle-SymbolicName", "org.apache.aries.isolated.sample");
attrs.putValue("Manifest-Version", "1");
ModelledResource res = modellingManager.getModelledResource(new File("sample_2.0.0.jar").toURI().toString(), attrs, Collections.EMPTY_LIST, Collections.EMPTY_LIST);
repoGen.generateRepository("repo.xml", Arrays.asList(res), new FileOutputStream("repo.xml"));
repoAdmin.addRepository(new File("repo.xml").toURI().toString());
}
Aggregations