use of org.apache.aries.application.Content in project aries by apache.
the class SimpleBundleInfo method getContentSetFromHeader.
private Set<Content> getContentSetFromHeader(Attributes attributes, String key) {
String header = _attributes.getValue(key);
List<String> splitHeader = ManifestHeaderProcessor.split(header, ",");
HashSet<Content> result = new HashSet<Content>();
for (String s : splitHeader) {
Content c = new ContentImpl(s);
result.add(c);
}
return result;
}
use of org.apache.aries.application.Content in project aries by apache.
the class ApplicationMetadataImplTest method testMetadataCreation.
@Test
public void testMetadataCreation() throws Exception {
ApplicationMetadataFactory manager = new ApplicationMetadataFactoryImpl();
ApplicationMetadata app = manager.parseApplicationMetadata(getClass().getResourceAsStream("/META-INF/APPLICATION4.MF"));
assertEquals("Travel Reservation", app.getApplicationName());
assertEquals("com.travel.reservation", app.getApplicationSymbolicName());
assertEquals(Version.parseVersion("1.2.0"), app.getApplicationVersion());
List<Content> appContents = app.getApplicationContents();
assertEquals(2, appContents.size());
Content appContent1 = new ContentImpl("com.travel.reservation.business");
Map<String, String> attrs = new HashMap<String, String>();
attrs.put("version", "\"[1.1.0,1.2.0)\"");
Content appContent2 = new ContentImpl("com.travel.reservation.web", attrs);
assertTrue(appContents.contains(appContent2));
assertTrue(appContents.contains(appContent1));
List<ServiceDeclaration> importedService = app.getApplicationImportServices();
assertEquals(2, importedService.size());
assertTrue(importedService.contains(new ServiceDeclarationImpl("com.travel.flight.api")));
assertTrue(importedService.contains(new ServiceDeclarationImpl("com.travel.rail.api")));
List<ServiceDeclaration> exportedService = app.getApplicationExportServices();
assertTrue(exportedService.contains(new ServiceDeclarationImpl("com.travel.reservation")));
}
use of org.apache.aries.application.Content 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.Content 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.Content in project aries by apache.
the class RepositoryDescriptorGenerator method generateRepositoryDescriptor.
public static Document generateRepositoryDescriptor(String name, Set<BundleInfo> bundles) throws ParserConfigurationException {
Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
Element root = doc.createElement("repository");
root.setAttribute("name", name);
doc.appendChild(root);
for (BundleInfo info : bundles) {
Element resource = doc.createElement("resource");
resource.setAttribute(Resource.VERSION, info.getVersion().toString());
resource.setAttribute("uri", info.getLocation());
resource.setAttribute(Resource.SYMBOLIC_NAME, info.getSymbolicName());
resource.setAttribute(Resource.PRESENTATION_NAME, info.getHeaders().get(Constants.BUNDLE_NAME));
resource.setAttribute(Resource.ID, info.getSymbolicName() + "/" + info.getVersion());
root.appendChild(resource);
addBundleCapability(doc, resource, info);
for (Content p : info.getExportPackage()) {
addPackageCapability(doc, resource, info, p);
}
for (Content p : info.getImportPackage()) {
addPackageRequirement(doc, resource, info, p);
}
for (Content p : info.getRequireBundle()) {
addBundleRequirement(doc, resource, info, p);
}
}
return doc;
}
Aggregations