Search in sources :

Example 1 with Capability

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"));
}
Also used : Requirement(org.osgi.service.indexer.Requirement) Capability(org.osgi.service.indexer.Capability) Version(org.osgi.framework.Version) File(java.io.File)

Example 2 with Capability

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"));
}
Also used : Requirement(org.osgi.service.indexer.Requirement) Capability(org.osgi.service.indexer.Capability) Version(org.osgi.framework.Version) File(java.io.File) LinkedList(java.util.LinkedList)

Example 3 with Capability

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"));
}
Also used : Requirement(org.osgi.service.indexer.Requirement) Capability(org.osgi.service.indexer.Capability) Version(org.osgi.framework.Version) File(java.io.File) LinkedList(java.util.LinkedList)

Example 4 with Capability

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"));
}
Also used : Requirement(org.osgi.service.indexer.Requirement) Capability(org.osgi.service.indexer.Capability) Version(org.osgi.framework.Version) File(java.io.File) LinkedList(java.util.LinkedList)

Example 5 with Capability

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"));
}
Also used : Requirement(org.osgi.service.indexer.Requirement) Capability(org.osgi.service.indexer.Capability) Version(org.osgi.framework.Version) File(java.io.File) LinkedList(java.util.LinkedList)

Aggregations

Capability (org.osgi.service.indexer.Capability)12 File (java.io.File)11 Requirement (org.osgi.service.indexer.Requirement)11 LinkedList (java.util.LinkedList)7 Version (org.osgi.framework.Version)6 Resource (org.osgi.service.indexer.Resource)3 ResourceAnalyzer (org.osgi.service.indexer.ResourceAnalyzer)3 StringWriter (java.io.StringWriter)2 HashMap (java.util.HashMap)2 Builder (org.osgi.service.indexer.Builder)2 Project (aQute.bnd.build.Project)1 WorkspaceR5Repository (bndtools.central.WorkspaceR5Repository)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 PrintWriter (java.io.PrintWriter)1 URI (java.net.URI)1 URL (java.net.URL)1 Formatter (java.util.Formatter)1 HashSet (java.util.HashSet)1