Search in sources :

Example 91 with Version

use of org.osgi.framework.Version 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 92 with Version

use of org.osgi.framework.Version 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 93 with Version

use of org.osgi.framework.Version 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 94 with Version

use of org.osgi.framework.Version 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 95 with Version

use of org.osgi.framework.Version 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

Version (org.osgi.framework.Version)222 Test (org.junit.Test)35 ArrayList (java.util.ArrayList)28 Bundle (org.osgi.framework.Bundle)27 File (java.io.File)23 HashMap (java.util.HashMap)21 Capability (org.osgi.resource.Capability)20 IOException (java.io.IOException)19 BundleException (org.osgi.framework.BundleException)15 Resource (org.osgi.resource.Resource)14 InputStream (java.io.InputStream)12 Map (java.util.Map)11 Manifest (java.util.jar.Manifest)11 List (java.util.List)10 URL (java.net.URL)8 HashSet (java.util.HashSet)8 Content (org.apache.aries.application.Content)8 AriesApplication (org.apache.aries.application.management.AriesApplication)8 VersionRange (org.apache.felix.utils.version.VersionRange)8 BundleRevision (org.osgi.framework.wiring.BundleRevision)8