use of org.osgi.service.indexer.Capability in project bnd by bndtools.
the class TestOSGiFrameworkAnalyzer method testOsgiFrameworkSpecificationVersions.
public void testOsgiFrameworkSpecificationVersions() throws Exception {
LinkedList<Capability> caps;
LinkedList<Requirement> reqs;
caps = new LinkedList<Capability>();
reqs = new LinkedList<Requirement>();
JarResource inputResource = new JarResource(new File("testdata/org.apache.felix.framework-4.0.2.jar"));
new BundleAnalyzer(new XNullLogSvc()).analyzeResource(inputResource, caps, reqs);
new OSGiFrameworkAnalyzer(new XNullLogSvc()).analyzeResource(inputResource, caps, reqs);
assertEquals(new Version("4.3.0"), findCaps("osgi.contract", caps).get(0).getAttributes().get("version"));
caps = new LinkedList<Capability>();
reqs = new LinkedList<Requirement>();
inputResource = new JarResource(new File("testdata/org.eclipse.osgi_3.7.2.v20120110-1415.jar"));
new BundleAnalyzer(new XNullLogSvc()).analyzeResource(inputResource, caps, reqs);
new OSGiFrameworkAnalyzer(new XNullLogSvc()).analyzeResource(inputResource, caps, reqs);
assertEquals(new Version("4.3.0"), findCaps("osgi.contract", caps).get(0).getAttributes().get("version"));
caps = new LinkedList<Capability>();
reqs = new LinkedList<Requirement>();
inputResource = new JarResource(new File("testdata/org.apache.felix.framework-3.2.2.jar"));
new BundleAnalyzer(new XNullLogSvc()).analyzeResource(inputResource, caps, reqs);
new OSGiFrameworkAnalyzer(new XNullLogSvc()).analyzeResource(inputResource, caps, reqs);
assertEquals(new Version("4.2.0"), findCaps("osgi.contract", caps).get(0).getAttributes().get("version"));
caps = new LinkedList<Capability>();
reqs = new LinkedList<Requirement>();
inputResource = new JarResource(new File("testdata/org.eclipse.osgi_3.6.2.R36x_v20110210.jar"));
new BundleAnalyzer(new XNullLogSvc()).analyzeResource(inputResource, caps, reqs);
new OSGiFrameworkAnalyzer(new XNullLogSvc()).analyzeResource(inputResource, caps, reqs);
assertEquals(new Version("4.2.0"), findCaps("osgi.contract", caps).get(0).getAttributes().get("version"));
}
use of org.osgi.service.indexer.Capability in project bnd by bndtools.
the class TestOSGiFrameworkAnalyzer method testOsgiFramework.
public void testOsgiFramework() throws Exception {
LinkedList<Capability> caps = new LinkedList<Capability>();
LinkedList<Requirement> reqs = new LinkedList<Requirement>();
JarResource input = new JarResource(new File("testdata/org.apache.felix.framework-4.0.2.jar"));
new BundleAnalyzer(new XNullLogSvc()).analyzeResource(input, caps, reqs);
new OSGiFrameworkAnalyzer(new XNullLogSvc()).analyzeResource(input, caps, reqs);
List<Capability> fwkCaps = findCaps("osgi.contract", caps);
assertNotNull(fwkCaps);
assertEquals(1, fwkCaps.size());
Capability fwkCap = fwkCaps.get(0);
assertEquals("OSGiFramework", fwkCap.getAttributes().get("osgi.contract"));
assertEquals(new Version("4.3.0"), fwkCap.getAttributes().get("version"));
assertEquals("org.osgi.framework.startlevel,org.osgi.framework.wiring,org.osgi.framework.hooks.bundle,org.osgi.framework.hooks.service,org.osgi.framework.hooks.resolver,org.osgi.framework.launch,org.osgi.framework,org.osgi.framework.hooks.weaving,org.osgi.service.packageadmin,org.osgi.service.url,org.osgi.service.startlevel,org.osgi.util.tracker", fwkCap.getDirectives().get("uses"));
}
use of org.osgi.service.indexer.Capability in project bnd by bndtools.
the class TestBundleAnalyzer method testContentAndIdentity.
public void testContentAndIdentity() throws Exception {
BundleAnalyzer a = new BundleAnalyzer(new XNullLogSvc());
LinkedList<Capability> caps = new LinkedList<Capability>();
LinkedList<Requirement> reqs = new LinkedList<Requirement>();
a.analyzeResource(new JarResource(new File("testdata/01-bsn+version.jar")), caps, reqs);
assertEquals(4, caps.size());
Capability idcap = caps.get(0);
assertEquals("osgi.identity", idcap.getNamespace());
assertEquals("org.example.a", idcap.getAttributes().get("osgi.identity"));
assertEquals("osgi.bundle", idcap.getAttributes().get("type"));
assertEquals(new Version("0.0.0"), idcap.getAttributes().get("version"));
Capability content = caps.get(1);
assertEquals("osgi.content", content.getNamespace());
assertEquals("64f661eea43334dc5d38d7f16dbcacd02c799e68332b40e72da8021828e3329c", content.getAttributes().get("osgi.content"));
assertEquals("testdata/01-bsn+version.jar", content.getAttributes().get("url"));
assertEquals("application/vnd.osgi.bundle", content.getAttributes().get("mime"));
assertEquals(1104L, content.getAttributes().get("size"));
}
use of org.osgi.service.indexer.Capability in project bnd by bndtools.
the class TestBundleAnalyzer method testPackageExportBundleSymbolicNameAndVersion.
// bundle-symbolic-name and bundle-version must be on package capabilities,
// for the idiots
// who add this to their imports...
public void testPackageExportBundleSymbolicNameAndVersion() throws Exception {
BundleAnalyzer a = new BundleAnalyzer(new XNullLogSvc());
LinkedList<Capability> caps = new LinkedList<Capability>();
LinkedList<Requirement> reqs = new LinkedList<Requirement>();
a.analyzeResource(new JarResource(new File("testdata/04-export+uses.jar")), caps, reqs);
List<Capability> exports = findCaps("osgi.wiring.package", caps);
assertEquals(2, exports.size());
assertEquals("org.example.b", exports.get(0).getAttributes().get("osgi.wiring.package"));
assertEquals("org.example.d", exports.get(0).getAttributes().get("bundle-symbolic-name"));
assertEquals(new Version(0, 0, 0), exports.get(0).getAttributes().get("bundle-version"));
assertEquals("org.example.a", exports.get(1).getAttributes().get("osgi.wiring.package"));
assertEquals("org.example.d", exports.get(0).getAttributes().get("bundle-symbolic-name"));
assertEquals(new Version(0, 0, 0), exports.get(0).getAttributes().get("bundle-version"));
}
use of org.osgi.service.indexer.Capability in project bnd by bndtools.
the class TestBundleAnalyzer method testPackageExports.
public void testPackageExports() throws Exception {
BundleAnalyzer a = new BundleAnalyzer(new XNullLogSvc());
LinkedList<Capability> caps = new LinkedList<Capability>();
LinkedList<Requirement> reqs = new LinkedList<Requirement>();
a.analyzeResource(new JarResource(new File("testdata/03-export.jar")), caps, reqs);
Capability export = findCaps("osgi.wiring.package", caps).get(0);
assertEquals("org.example.a", export.getAttributes().get("osgi.wiring.package"));
assertEquals(new Version(1, 0, 0), export.getAttributes().get("version"));
}
Aggregations