use of org.apache.aries.application.management.AriesApplication in project aries by apache.
the class OBRResolverTest method testBlogAppResolveFail.
@Test(expected = ResolverException.class)
public void testBlogAppResolveFail() throws ResolverException, Exception {
// provision against the local runtime
System.setProperty(AppConstants.PROVISON_EXCLUDE_LOCAL_REPO_SYSPROP, "false");
generateOBRRepoXML(TRANSITIVE_BUNDLE_BY_REFERENCE + ".jar", CORE_BUNDLE_BY_REFERENCE + "_0.0.0.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("blog.eba")));
//installing requires a valid url for the bundle in repository.xml.
app = manager.resolve(app);
}
use of org.apache.aries.application.management.AriesApplication in project aries by apache.
the class AriesApplicationManagerImplTest method createApplication.
private AriesApplication createApplication(String fileName) throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException, ManagementException, ResolverException {
// This next block is a very long winded way of constructing a BundleInfoImpl
// against the existing (BundleManifest bm, String location) constructor. If we
// find we need a String-based BundleInfoImpl constructor for other reasons,
// we could change to using it here.
Set<BundleInfo> nextResolverResult = new HashSet<BundleInfo>();
String persistenceLibraryLocation = "../src/test/resources/bundles/repository/a.handy.persistence.library.jar";
File persistenceLibrary = new File(persistenceLibraryLocation);
BundleManifest mf = BundleManifest.fromBundle(persistenceLibrary);
BundleInfo resolvedPersistenceLibrary = new SimpleBundleInfo(mf, persistenceLibraryLocation);
Field v = SimpleBundleInfo.class.getDeclaredField("_version");
v.setAccessible(true);
v.set(resolvedPersistenceLibrary, new Version("1.1.0"));
nextResolverResult.add(resolvedPersistenceLibrary);
_resolver.setNextResult(nextResolverResult);
IDirectory testEba = FileSystem.getFSRoot(new File(fileName));
AriesApplication app = _appMgr.createApplication(testEba);
app = _appMgr.resolve(app);
return app;
}
use of org.apache.aries.application.management.AriesApplication in project aries by apache.
the class AriesApplicationManagerImplTest method testStoreAndReload.
@Test
public void testStoreAndReload() throws Exception {
AriesApplication app = createApplication(TEST_EBA);
File dest = new File("ariesApplicationManagerImplTest/stored.eba");
app.store(dest);
/* Dest should be a zip file with four entries:
* /foo.bar.widgets.jar
* /my.business.logic.jar
* /META-INF/APPLICATION.MF
* /META-INF/DEPLOYMENT.MF
*/
IDirectory storedEba = FileSystem.getFSRoot(dest);
assertNotNull(storedEba);
assertEquals(storedEba.listFiles().size(), 3);
IFile ifile = storedEba.getFile("META-INF/APPLICATION.MF");
assertNotNull(ifile);
ifile = storedEba.getFile("META-INF/DEPLOYMENT.MF");
assertNotNull(ifile);
ifile = storedEba.getFile("foo.bar.widgets.jar");
assertNotNull(ifile);
ifile = storedEba.getFile("my.business.logic.jar");
assertNotNull(ifile);
AriesApplication newApp = _appMgr.createApplication(storedEba);
DeploymentMetadata dm = newApp.getDeploymentMetadata();
assertEquals(2, dm.getApplicationDeploymentContents().size());
assertEquals(1, dm.getApplicationProvisionBundles().size());
assertEquals(dm.getApplicationSymbolicName(), app.getApplicationMetadata().getApplicationSymbolicName());
assertEquals(dm.getApplicationVersion(), app.getApplicationMetadata().getApplicationVersion());
}
use of org.apache.aries.application.management.AriesApplication in project aries by apache.
the class AriesApplicationManagerImplTest method testCreate.
@Test
public void testCreate() throws Exception {
AriesApplication app = createApplication(TEST_EBA);
ApplicationMetadata appMeta = app.getApplicationMetadata();
assertEquals(appMeta.getApplicationName(), "Test application");
assertEquals(appMeta.getApplicationSymbolicName(), "org.apache.aries.application.management.test");
assertEquals(appMeta.getApplicationVersion(), new Version("1.0"));
List<Content> appContent = appMeta.getApplicationContents();
assertEquals(appContent.size(), 2);
Content fbw = new ContentImpl("foo.bar.widgets;version=1.0.0");
Content mbl = new ContentImpl("my.business.logic;version=1.0.0");
assertTrue(appContent.contains(fbw));
assertTrue(appContent.contains(mbl));
DeploymentMetadata dm = app.getDeploymentMetadata();
List<DeploymentContent> dcList = dm.getApplicationDeploymentContents();
assertEquals(2, dcList.size());
DeploymentContent dc1 = new DeploymentContentImpl("foo.bar.widgets;deployed-version=1.1.0");
DeploymentContent dc2 = new DeploymentContentImpl("my.business.logic;deployed-version=1.1.0");
DeploymentContent dc3 = new DeploymentContentImpl("a.handy.persistence.library;deployed-version=1.1.0");
assertTrue(dcList.contains(dc1));
assertTrue(dcList.contains(dc2));
dcList = dm.getApplicationProvisionBundles();
assertEquals(1, dcList.size());
assertTrue(dcList.contains(dc3));
}
use of org.apache.aries.application.management.AriesApplication in project aries by apache.
the class ApplicationRepositoryTest method testBundleNotInApp.
@Test
public void testBundleNotInApp() {
AriesApplication app = Skeleton.newMock(AriesApplication.class);
BundleInfo bi = Skeleton.newMock(BundleInfo.class);
Skeleton.getSkeleton(bi).setReturnValue(new MethodCall(BundleInfo.class, "getSymbolicName"), "test.bundle");
Skeleton.getSkeleton(bi).setReturnValue(new MethodCall(BundleInfo.class, "getVersion"), new Version("1.0.0"));
Skeleton.getSkeleton(app).setReturnValue(new MethodCall(AriesApplication.class, "getBundleInfo"), new HashSet<BundleInfo>());
ApplicationRepository rep = new ApplicationRepository(app);
BundleSuggestion sug = rep.suggestBundleToUse(new DeploymentContentImpl("test.bundle", new Version("2.0.0")));
assertNull("We have apparently found a bundle that is not in the application in the ApplicationRepository", sug);
}
Aggregations