提交 3effef99 authored 作者: Thomas Mueller's avatar Thomas Mueller

Use a weak dependency to the JTS jar file (allow to use H2 without the JTS jar…

Use a weak dependency to the JTS jar file (allow to use H2 without the JTS jar file in the classpath)
上级 279516bb
......@@ -114,6 +114,10 @@ public class TestClearReferences extends TestBase {
Class<?> clazz = null;
try {
clazz = Class.forName(className);
} catch (NoClassDefFoundError e) {
if (e.toString().indexOf("lucene") >= 0) {
// Lucene is not in the classpath, OK
}
} catch (ClassNotFoundException e) {
fail("Could not load " + className + ": " + e.toString());
}
......@@ -129,7 +133,23 @@ public class TestClearReferences extends TestBase {
* @param clazz the class to clear
*/
private void clearClass(Class<?> clazz) throws Exception {
for (Field field : clazz.getDeclaredFields()) {
Field[] fields;
try {
fields = clazz.getDeclaredFields();
} catch (NoClassDefFoundError e) {
if (e.toString().indexOf("lucene") >= 0) {
// Lucene is not in the classpath, OK
return;
} else if (e.toString().indexOf("jts") >= 0) {
// JTS is not in the classpath, OK
return;
} else if (e.toString().indexOf("slf4j") >= 0) {
// slf4j is not in the classpath, OK
return;
}
throw e;
}
for (Field field : fields) {
if (field.getType().isPrimitive() || field.getName().indexOf("$") != -1) {
continue;
}
......
......@@ -24,6 +24,7 @@ import org.h2.tools.SimpleResultSet;
import org.h2.util.SmallLRUCache;
import org.h2.util.TempFileDeleter;
import org.h2.util.Utils;
import org.h2.value.DataType;
import org.h2.value.Value;
import org.h2.value.ValueArray;
import org.h2.value.ValueBoolean;
......@@ -81,7 +82,12 @@ public class TestValueMemory extends TestBase implements DataHandler {
trace(s);
}
for (int i = 0; i < Value.TYPE_COUNT; i++) {
assertEquals(i, create(i).getType());
Value v = create(i);
if (v == ValueNull.INSTANCE && i == Value.GEOMETRY) {
// jts not in the classpath, OK
continue;
}
assertEquals(i, v.getType());
testType(i);
}
}
......@@ -188,6 +194,9 @@ public class TestValueMemory extends TestBase implements DataHandler {
case Value.STRING_FIXED:
return ValueStringFixed.get(randomString(random.nextInt(100)));
case Value.GEOMETRY:
if (DataType.GEOMETRY_CLASS == null) {
return ValueNull.INSTANCE;
}
return ValueGeometry.get("POINT (" + random.nextInt(100) + " "+random.nextInt(100)+")");
default:
throw new AssertionError("type=" + type);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论