Search in sources :

Example 36 with Version

use of org.osgi.framework.Version in project aries by apache.

the class FragmentHostHeaderTest method testSymbolicName.

@Test
public void testSymbolicName() {
    String headerStr = "org.foo";
    FragmentHostHeader header = new FragmentHostHeader(headerStr);
    assertClauses(header, 1);
    assertSymbolicName(header.getClauses().iterator().next(), headerStr);
    assertBundleVersionAttribute(header.getClauses().iterator().next(), new VersionRange(VersionRange.LEFT_CLOSED, new Version("0"), null, VersionRange.RIGHT_OPEN));
}
Also used : Version(org.osgi.framework.Version) VersionRange(org.osgi.framework.VersionRange) Test(org.junit.Test)

Example 37 with Version

use of org.osgi.framework.Version in project aries by apache.

the class ManifestHeaderProcessorTest method testIP2LocationCapability.

private void testIP2LocationCapability(GenericMetadata cap) {
    assertEquals(0, cap.getDirectives().size());
    assertEquals(4, cap.getAttributes().size());
    assertEquals(new Version(1, 3, 0), cap.getAttributes().get("version"));
    assertEquals(Arrays.asList("nl", "be", "fr", "uk"), cap.getAttributes().get("country"));
    assertEquals(Long.MAX_VALUE, cap.getAttributes().get("long"));
    assertEquals(0, new Double("3.141592653589793").compareTo((Double) cap.getAttributes().get("d")));
}
Also used : Version(org.osgi.framework.Version)

Example 38 with Version

use of org.osgi.framework.Version in project aries by apache.

the class ManifestHeaderProcessorTest method testDictionaryCapability1.

private void testDictionaryCapability1(GenericMetadata cap) {
    assertEquals(2, cap.getDirectives().size());
    assertEquals("resolve", cap.getDirectives().get("effective"));
    assertEquals("test", cap.getDirectives().get("somedir"));
    assertEquals(3, cap.getAttributes().size());
    assertEquals("nl", cap.getAttributes().get("from"));
    assertEquals("de", cap.getAttributes().get("to"));
    assertEquals(new Version(3, 4, 0, "test"), cap.getAttributes().get("version"));
}
Also used : Version(org.osgi.framework.Version)

Example 39 with Version

use of org.osgi.framework.Version in project aries by apache.

the class BundleCompatibility method isVersionCorrect.

static boolean isVersionCorrect(VERSION_CHANGE_TYPE status, String oldVersionStr, String newVersionStr) {
    boolean versionCorrect = false;
    Version oldVersion = Version.parseVersion(oldVersionStr);
    Version newVersion = Version.parseVersion(newVersionStr);
    if (status == VERSION_CHANGE_TYPE.MAJOR_CHANGE) {
        if (newVersion.getMajor() > oldVersion.getMajor()) {
            versionCorrect = true;
        }
    } else if (status == VERSION_CHANGE_TYPE.MINOR_CHANGE) {
        if ((newVersion.getMajor() > oldVersion.getMajor()) || (newVersion.getMinor() > oldVersion.getMinor())) {
            versionCorrect = true;
        }
    } else {
        if ((newVersion.getMajor() >= oldVersion.getMajor()) && (newVersion.getMinor() >= oldVersion.getMinor())) {
            versionCorrect = true;
        }
    }
    return versionCorrect;
}
Also used : Version(org.osgi.framework.Version)

Example 40 with Version

use of org.osgi.framework.Version in project aries by apache.

the class BundleManifest method getVersion.

public Version getVersion() {
    String specifiedVersion = manifest.getMainAttributes().getValue(Constants.BUNDLE_VERSION);
    Version result = (specifiedVersion == null) ? Version.emptyVersion : new Version(specifiedVersion);
    return result;
}
Also used : Version(org.osgi.framework.Version)

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