提交 4ca5c7bd authored 作者: Thomas Mueller's avatar Thomas Mueller

More tests

上级 a3086043
...@@ -33,6 +33,8 @@ import org.h2.value.ValueGeometry; ...@@ -33,6 +33,8 @@ import org.h2.value.ValueGeometry;
* @author Nicolas Fortin, Atelier SIG, IRSTV FR CNRS 24888 * @author Nicolas Fortin, Atelier SIG, IRSTV FR CNRS 24888
*/ */
public class TestSpatial extends TestBase { public class TestSpatial extends TestBase {
String url = "spatial";
/** /**
* Run just this test. * Run just this test.
...@@ -50,24 +52,31 @@ public class TestSpatial extends TestBase { ...@@ -50,24 +52,31 @@ public class TestSpatial extends TestBase {
} }
if (DataType.GEOMETRY_CLASS != null) { if (DataType.GEOMETRY_CLASS != null) {
deleteDb("spatial"); deleteDb("spatial");
testSpatialValues(); url = "spatial";
testOverlap(); testSpatial();
testNotOverlap(); url = "spatial;MV_STORE=false";
testPersistentSpatialIndex(); testSpatial();
testSpatialIndexQueryMultipleTable();
testIndexTransaction();
testJavaAlias();
testJavaAliasTableFunction();
testMemorySpatialIndex();
testGeometryDataType();
testWKB();
testValueConversion();
testEquals();
testTableFunctionGeometry();
testHashCode();
deleteDb("spatial"); deleteDb("spatial");
} }
} }
private void testSpatial() throws SQLException {
testSpatialValues();
testOverlap();
testNotOverlap();
testPersistentSpatialIndex();
testSpatialIndexQueryMultipleTable();
testIndexTransaction();
testJavaAlias();
testJavaAliasTableFunction();
testMemorySpatialIndex();
testGeometryDataType();
testWKB();
testValueConversion();
testEquals();
testTableFunctionGeometry();
testHashCode();
}
private void testHashCode() { private void testHashCode() {
ValueGeometry geomA = ValueGeometry ValueGeometry geomA = ValueGeometry
...@@ -82,7 +91,7 @@ public class TestSpatial extends TestBase { ...@@ -82,7 +91,7 @@ public class TestSpatial extends TestBase {
private void testSpatialValues() throws SQLException { private void testSpatialValues() throws SQLException {
deleteDb("spatial"); deleteDb("spatial");
Connection conn = getConnection("spatial"); Connection conn = getConnection(url);
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.execute("create memory table test(id int primary key, polygon geometry)"); stat.execute("create memory table test(id int primary key, polygon geometry)");
...@@ -142,7 +151,7 @@ public class TestSpatial extends TestBase { ...@@ -142,7 +151,7 @@ public class TestSpatial extends TestBase {
private void testOverlap() throws SQLException { private void testOverlap() throws SQLException {
deleteDb("spatial"); deleteDb("spatial");
Connection conn = getConnection("spatial"); Connection conn = getConnection(url);
try { try {
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.execute("create memory table test(id int primary key, poly geometry)"); stat.execute("create memory table test(id int primary key, poly geometry)");
...@@ -162,8 +171,8 @@ public class TestSpatial extends TestBase { ...@@ -162,8 +171,8 @@ public class TestSpatial extends TestBase {
} }
} }
private void testPersistentSpatialIndex() throws SQLException { private void testPersistentSpatialIndex() throws SQLException {
deleteDb("spatialPersistent"); deleteDb("spatial");
Connection conn = getConnection("spatialPersistent"); Connection conn = getConnection(url);
try { try {
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.execute("create table test(id int primary key, poly geometry)"); stat.execute("create table test(id int primary key, poly geometry)");
...@@ -198,7 +207,7 @@ public class TestSpatial extends TestBase { ...@@ -198,7 +207,7 @@ public class TestSpatial extends TestBase {
return; return;
} }
conn = getConnection("spatialPersistent"); conn = getConnection(url);
try { try {
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
ResultSet rs = stat.executeQuery( ResultSet rs = stat.executeQuery(
...@@ -215,7 +224,7 @@ public class TestSpatial extends TestBase { ...@@ -215,7 +224,7 @@ public class TestSpatial extends TestBase {
} }
private void testNotOverlap() throws SQLException { private void testNotOverlap() throws SQLException {
deleteDb("spatial"); deleteDb("spatial");
Connection conn = getConnection("spatial"); Connection conn = getConnection(url);
try { try {
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.execute("create memory table test(id int primary key, poly geometry)"); stat.execute("create memory table test(id int primary key, poly geometry)");
...@@ -272,7 +281,7 @@ public class TestSpatial extends TestBase { ...@@ -272,7 +281,7 @@ public class TestSpatial extends TestBase {
private void testSpatialIndexQueryMultipleTable() throws SQLException { private void testSpatialIndexQueryMultipleTable() throws SQLException {
deleteDb("spatial"); deleteDb("spatial");
Connection conn = getConnection("spatial"); Connection conn = getConnection(url);
try { try {
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
createTestTable(stat); createTestTable(stat);
...@@ -312,8 +321,8 @@ public class TestSpatial extends TestBase { ...@@ -312,8 +321,8 @@ public class TestSpatial extends TestBase {
} }
private void testIndexTransaction() throws SQLException { private void testIndexTransaction() throws SQLException {
// Check session management in index // Check session management in index
deleteDb("spatialIndex"); deleteDb("spatial");
Connection conn = getConnection("spatialIndex"); Connection conn = getConnection(url);
conn.setAutoCommit(false); conn.setAutoCommit(false);
try { try {
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
...@@ -360,8 +369,8 @@ public class TestSpatial extends TestBase { ...@@ -360,8 +369,8 @@ public class TestSpatial extends TestBase {
* Test the in the in-memory spatial index * Test the in the in-memory spatial index
*/ */
private void testMemorySpatialIndex() throws SQLException { private void testMemorySpatialIndex() throws SQLException {
deleteDb("spatialIndex"); deleteDb("spatial");
Connection conn = getConnection("spatialIndex"); Connection conn = getConnection(url);
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.execute("create memory table test(id int primary key, polygon geometry)"); stat.execute("create memory table test(id int primary key, polygon geometry)");
...@@ -409,15 +418,15 @@ public class TestSpatial extends TestBase { ...@@ -409,15 +418,15 @@ public class TestSpatial extends TestBase {
stat.execute("drop table test"); stat.execute("drop table test");
conn.close(); conn.close();
deleteDb("spatialIndex"); deleteDb("spatial");
} }
/** /**
* Test java alias with Geometry type. * Test java alias with Geometry type.
*/ */
private void testJavaAlias() throws SQLException { private void testJavaAlias() throws SQLException {
deleteDb("spatialIndex"); deleteDb("spatial");
Connection conn = getConnection("spatialIndex"); Connection conn = getConnection(url);
try { try {
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.execute("CREATE ALIAS T_GEOM_FROM_TEXT FOR \"" + TestSpatial.class.getName() + ".geomFromText\""); stat.execute("CREATE ALIAS T_GEOM_FROM_TEXT FOR \"" + TestSpatial.class.getName() + ".geomFromText\"");
...@@ -431,15 +440,15 @@ public class TestSpatial extends TestBase { ...@@ -431,15 +440,15 @@ public class TestSpatial extends TestBase {
} finally { } finally {
conn.close(); conn.close();
} }
deleteDb("spatialIndex"); deleteDb("spatial");
} }
/** /**
* Test java alias with Geometry type. * Test java alias with Geometry type.
*/ */
private void testJavaAliasTableFunction() throws SQLException { private void testJavaAliasTableFunction() throws SQLException {
deleteDb("spatialIndex"); deleteDb("spatial");
Connection conn = getConnection("spatialIndex"); Connection conn = getConnection(url);
try { try {
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.execute("CREATE ALIAS T_RANDOM_GEOM_TABLE FOR \"" + stat.execute("CREATE ALIAS T_RANDOM_GEOM_TABLE FOR \"" +
...@@ -454,7 +463,7 @@ public class TestSpatial extends TestBase { ...@@ -454,7 +463,7 @@ public class TestSpatial extends TestBase {
} finally { } finally {
conn.close(); conn.close();
} }
deleteDb("spatialIndex"); deleteDb("spatial");
} }
/** /**
...@@ -547,8 +556,8 @@ public class TestSpatial extends TestBase { ...@@ -547,8 +556,8 @@ public class TestSpatial extends TestBase {
* Test conversion of Geometry object into Object * Test conversion of Geometry object into Object
*/ */
private void testValueConversion() throws SQLException { private void testValueConversion() throws SQLException {
deleteDb("spatialIndex"); deleteDb("spatial");
Connection conn = getConnection("spatialIndex"); Connection conn = getConnection(url);
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.execute("CREATE ALIAS OBJ_STRING FOR \"" + stat.execute("CREATE ALIAS OBJ_STRING FOR \"" +
TestSpatial.class.getName() + ".getObjectString\""); TestSpatial.class.getName() + ".getObjectString\"");
...@@ -556,7 +565,7 @@ public class TestSpatial extends TestBase { ...@@ -556,7 +565,7 @@ public class TestSpatial extends TestBase {
assertTrue(rs.next()); assertTrue(rs.next());
assertEquals("POINT (15 25)", rs.getString(1)); assertEquals("POINT (15 25)", rs.getString(1));
conn.close(); conn.close();
deleteDb("spatialIndex"); deleteDb("spatial");
} }
/** /**
...@@ -599,8 +608,8 @@ public class TestSpatial extends TestBase { ...@@ -599,8 +608,8 @@ public class TestSpatial extends TestBase {
* Check that geometry column type is kept with a table function * Check that geometry column type is kept with a table function
*/ */
private void testTableFunctionGeometry() throws SQLException { private void testTableFunctionGeometry() throws SQLException {
deleteDb("spatialIndex"); deleteDb("spatial");
Connection conn = getConnection("spatialIndex"); Connection conn = getConnection(url);
try { try {
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.execute("CREATE ALIAS POINT_TABLE FOR \"" + stat.execute("CREATE ALIAS POINT_TABLE FOR \"" +
...@@ -614,7 +623,7 @@ public class TestSpatial extends TestBase { ...@@ -614,7 +623,7 @@ public class TestSpatial extends TestBase {
} finally { } finally {
conn.close(); conn.close();
} }
deleteDb("spatialIndex"); deleteDb("spatial");
} }
public static ResultSet pointTable(double x, double y) { public static ResultSet pointTable(double x, double y) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论