use of org.apache.aries.application.management.AriesApplication in project aries by apache.
the class IsolatedRuntimeTest method testAppWithoutApplicationManifest.
@Test
@Ignore
public void testAppWithoutApplicationManifest() throws Exception {
AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("test.eba")));
AriesApplicationContext ctx = manager.install(app);
ctx.start();
assertHelloWorldService("test.eba");
manager.uninstall(ctx);
}
use of org.apache.aries.application.management.AriesApplication in project aries by apache.
the class AriesApplicationManagerImplTest method testUpdate.
@Test
public void testUpdate() throws Exception {
AriesApplication app = createApplication(TEST_EBA);
DeploymentMetadata depMf = createUpdateDepMf();
AriesApplicationContextManager ctxMgr = Skeleton.newMock(AriesApplicationContextManager.class);
_appMgr.setApplicationContextManager(ctxMgr);
_appMgr.update(app, depMf);
assertTrue("Deployment.mf should have been updated", app.getDeploymentMetadata() == depMf);
}
use of org.apache.aries.application.management.AriesApplication in project aries by apache.
the class AriesApplicationManagerImpl method createApplication.
/**
* Create an application from a URL.
* The first version of this method isn't smart enough to check whether
* the input URL is file://
*/
public AriesApplication createApplication(URL url) throws ManagementException {
OutputStream os = null;
AriesApplication app = null;
try {
File tempFile = _localPlatform.getTemporaryFile();
InputStream is = url.openStream();
os = new FileOutputStream(tempFile);
IOUtils.copy(is, os);
IDirectory downloadedSource = FileSystem.getFSRoot(tempFile);
app = createApplication(downloadedSource);
} catch (IOException iox) {
throw new ManagementException(iox);
} finally {
IOUtils.close(os);
}
return app;
}
use of org.apache.aries.application.management.AriesApplication in project aries by apache.
the class AriesApplicationManagerImplTest method testRolledbackUpdate.
@Test
public void testRolledbackUpdate() throws Exception {
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"), Collections.singleton(ctx));
Skeleton.getSkeleton(ctxMgr).setThrows(new MethodCall(AriesApplicationContextManager.class, "update", AriesApplication.class, DeploymentMetadata.class), new UpdateException("", null, true, null));
_appMgr.setApplicationContextManager(ctxMgr);
try {
_appMgr.update(app, depMf);
fail("Update should have failed.");
} catch (UpdateException e) {
assertTrue("Deployment.mf should have been rolled back to the old", app.getDeploymentMetadata() == oldMf);
}
}
use of org.apache.aries.application.management.AriesApplication in project aries by apache.
the class AriesApplicationManagerImplTest method testUpdateWithIncorrectDepMf.
@Test(expected = IllegalArgumentException.class)
public void testUpdateWithIncorrectDepMf() throws Exception {
AriesApplication app = createApplication(TEST_EBA);
DeploymentMetadata depMf = Skeleton.newMock(DeploymentMetadata.class);
Skeleton.getSkeleton(depMf).setReturnValue(new MethodCall(DeploymentMetadata.class, "getApplicationSymbolicName"), "random.app");
Skeleton.getSkeleton(depMf).setReturnValue(new MethodCall(DeploymentMetadata.class, "getApplicationVersion"), new Version("1.0.0"));
AriesApplicationContextManager ctxMgr = Skeleton.newMock(AriesApplicationContextManager.class);
_appMgr.setApplicationContextManager(ctxMgr);
_appMgr.update(app, depMf);
}
Aggregations