use of org.osgi.framework.Version in project aries by apache.
the class VersionRangeTest method testExactVersion.
@Test
public void testExactVersion() throws Exception {
VersionRange vr;
try {
vr = new VersionRange("[1.0.0, 2.0.0]", true);
fail("from 1 to 2 not excludsive is not an exact range");
} catch (IllegalArgumentException e) {
// expected
}
vr = new VersionRange("[1.0.0, 1.0.0]", true);
assertTrue(vr.isExactVersion());
try {
vr = new VersionRange("(1.0.0, 1.0.0]", true);
fail("from 1 (not including 1) to 1, is not valid");
} catch (IllegalArgumentException e) {
// expected
}
try {
vr = new VersionRange("[1.0.0, 1.0.0)", true);
fail("sfrom 1 to 1 (not including 1), is not valid");
} catch (IllegalArgumentException e) {
// expected
}
vr = new VersionRange("1.0.0", true);
assertTrue(vr.isExactVersion());
vr = new VersionRange("1.0.0", false);
assertFalse(vr.isExactVersion());
vr = new VersionRange("[1.0.0, 2.0.0]");
assertFalse(vr.isExactVersion());
vr = new VersionRange("[1.0.0, 1.0.0]");
assertTrue(vr.isExactVersion());
vr = new VersionRange("1.0.0", true);
assertEquals(new Version("1.0.0"), vr.getMinimumVersion());
assertTrue(vr.isExactVersion());
vr = new VersionRange("1.0.0", false);
assertEquals(new Version("1.0.0"), vr.getMinimumVersion());
assertNull(vr.getMaximumVersion());
assertFalse(vr.isExactVersion());
// don't throw any silly exceptions
vr = new VersionRange("[1.0.0,2.0.0)", false);
assertFalse(vr.isExactVersion());
vr = new VersionRange("[1.0.0, 2.0.0]");
assertFalse(vr.isExactVersion());
vr = new VersionRange("[1.0.0, 1.0.0]");
assertTrue(vr.isExactVersion());
}
use of org.osgi.framework.Version in project dbeaver by serge-rider.
the class FireBirdUtils method getViewSourceWithHeader.
public static String getViewSourceWithHeader(DBRProgressMonitor monitor, GenericTable view, String source) throws DBException {
Version version = getFireBirdServerVersion(view.getDataSource());
StringBuilder sql = new StringBuilder();
sql.append("CREATE ");
if (version.getMajor() > 2 || (version.getMajor() == 2 && version.getMinor() >= 5)) {
sql.append("OR ALTER ");
}
sql.append("VIEW ").append(view.getName()).append(" ");
Collection<GenericTableColumn> columns = view.getAttributes(monitor);
if (columns != null) {
sql.append("(");
boolean first = true;
for (GenericTableColumn column : columns) {
if (!first) {
sql.append(", ");
}
first = false;
sql.append(DBUtils.getQuotedIdentifier(column));
}
sql.append(")\n");
}
sql.append("AS\n").append(source);
return sql.toString();
}
use of org.osgi.framework.Version in project dbeaver by serge-rider.
the class FireBirdUtils method getFireBirdServerVersion.
public static Version getFireBirdServerVersion(DBPDataSource dataSource) {
String versionInfo = dataSource.getInfo().getDatabaseProductVersion();
Matcher matcher = VERSION_PATTERN.matcher(versionInfo);
if (matcher.matches()) {
return new Version(matcher.group(1));
}
return new Version(0, 0, 0);
}
use of org.osgi.framework.Version in project sling by apache.
the class UninstallBundleCommandTest method setUp.
@Before
public void setUp() throws Exception {
final Bundle[] b = new Bundle[3];
for (int i = 0; i < b.length; i++) {
b[i] = mockery.mock(Bundle.class, "bundle" + i);
}
// b0 is in version range, will be uninstalled
mockery.checking(new Expectations() {
{
allowing(b[0]).getSymbolicName();
will(returnValue("testbundle"));
allowing(b[0]).getHeaders();
will(returnValue(new Hashtable<String, String>()));
allowing(b[0]).getVersion();
will(returnValue(new Version("1.0.0")));
exactly(1).of(b[0]).uninstall();
}
});
// b1 is not in version range, not uninstalled
mockery.checking(new Expectations() {
{
allowing(b[1]).getSymbolicName();
will(returnValue("testbundle"));
allowing(b[1]).getHeaders();
will(returnValue(new Hashtable<String, String>()));
allowing(b[1]).getVersion();
will(returnValue(new Version("2.0.0")));
}
});
// b2 has different symbolic name, not uninstalled
mockery.checking(new Expectations() {
{
allowing(b[2]).getSymbolicName();
will(returnValue("otherbundle"));
allowing(b[2]).getHeaders();
will(returnValue(new Hashtable<String, String>()));
allowing(b[2]).getVersion();
will(returnValue(new Version("1.0.0")));
}
});
bundleContext = mockery.mock(BundleContext.class);
mockery.checking(new Expectations() {
{
allowing(bundleContext).getBundles();
will(returnValue(b));
}
});
}
use of org.osgi.framework.Version in project bnd by bndtools.
the class CapReqBuilder method toAttrs.
public Attrs toAttrs() {
Attrs attrs = new Attrs();
if (attributes != null) {
for (Entry<String, Object> e : attributes.entrySet()) {
Object value = e.getValue();
if (e.getKey().equals("version") || value instanceof Version)
value = toBndVersions(value);
attrs.putTyped(e.getKey(), value);
}
}
if (directives != null)
for (Entry<String, String> e : directives.entrySet()) {
attrs.put(e.getKey() + ":", e.getValue());
}
return attrs;
}
Aggregations