提交 b8fc1320 authored 作者: Thomas Mueller's avatar Thomas Mueller

Cleanup.

上级 48690027
...@@ -214,7 +214,7 @@ public class TestCompatibility extends TestBase { ...@@ -214,7 +214,7 @@ public class TestCompatibility extends TestBase {
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
stat.execute("SET MODE PostgreSQL"); stat.execute("SET MODE PostgreSQL");
testLog(Math.log10(10), stat); testLog(Math.log10(10), stat);
assertResult("ABC", stat, "SELECT SUBSTRING('ABCDEF' FOR 3)"); assertResult("ABC", stat, "SELECT SUBSTRING('ABCDEF' FOR 3)");
assertResult("ABCD", stat, "SELECT SUBSTRING('0ABCDEF' FROM 2 FOR 4)"); assertResult("ABCD", stat, "SELECT SUBSTRING('0ABCDEF' FROM 2 FOR 4)");
} }
......
...@@ -143,7 +143,7 @@ public class TestIndex extends TestBase { ...@@ -143,7 +143,7 @@ public class TestIndex extends TestBase {
} }
stat.execute("drop table test"); stat.execute("drop table test");
} }
private void testNonUniqueHashIndex() throws SQLException { private void testNonUniqueHashIndex() throws SQLException {
reconnect(); reconnect();
stat.execute("create memory table test(id bigint, data bigint)"); stat.execute("create memory table test(id bigint, data bigint)");
......
...@@ -13,11 +13,11 @@ import java.sql.ResultSet; ...@@ -13,11 +13,11 @@ import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Statement; import java.sql.Statement;
/** /**
* Test of compatibility for the SHOW statement * Test of compatibility for the SHOW statement.
*/ */
public class TestShow extends TestBase { public class TestShow extends TestBase {
/** /**
* Run just this test. * Run just this test.
* *
......
...@@ -21,7 +21,7 @@ public class TestSpatial extends TestBase { ...@@ -21,7 +21,7 @@ public class TestSpatial extends TestBase {
/** /**
* Run just this test. * Run just this test.
* *
* @param a ignored * @param a ignored
*/ */
public static void main(String... a) throws Exception { public static void main(String... a) throws Exception {
...@@ -40,23 +40,27 @@ public class TestSpatial extends TestBase { ...@@ -40,23 +40,27 @@ public class TestSpatial extends TestBase {
deleteDb("spatial"); deleteDb("spatial");
Connection conn = getConnection("spatial"); Connection conn = getConnection("spatial");
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, polygon geometry)");
stat.execute("insert into test values(1, 'POLYGON ((1 1, 1 2, 2 2, 1 1))')"); stat.execute("insert into test values(1, 'POLYGON ((1 1, 1 2, 2 2, 1 1))')");
ResultSet rs = stat.executeQuery("select * from test"); ResultSet rs = stat.executeQuery("select * from test");
assertTrue(rs.next()); assertTrue(rs.next());
assertEquals(1, rs.getInt(1)); assertEquals(1, rs.getInt(1));
assertEquals("POLYGON ((1 1, 1 2, 2 2, 1 1))", rs.getString(2)); assertEquals("POLYGON ((1 1, 1 2, 2 2, 1 1))", rs.getString(2));
GeometryFactory f = new GeometryFactory(); GeometryFactory f = new GeometryFactory();
Polygon poly = f.createPolygon(new Coordinate[] { new Coordinate(1,1), new Coordinate(1,2), new Coordinate(2,2), new Coordinate(1, 1) }); Polygon polygon = f.createPolygon(new Coordinate[] {
assertTrue(poly.equals(rs.getObject(2))); new Coordinate(1, 1),
new Coordinate(1, 2),
rs = stat.executeQuery("select * from test where poly = 'POLYGON ((1 1, 1 2, 2 2, 1 1))'"); new Coordinate(2, 2),
new Coordinate(1, 1) });
assertTrue(polygon.equals(rs.getObject(2)));
rs = stat.executeQuery("select * from test where polygon = 'POLYGON ((1 1, 1 2, 2 2, 1 1))'");
assertTrue(rs.next()); assertTrue(rs.next());
assertEquals(1, rs.getInt(1)); assertEquals(1, rs.getInt(1));
stat.executeQuery("select * from test where poly > 'POLYGON ((1 1, 1 2, 2 2, 1 1))'"); stat.executeQuery("select * from test where polygon > 'POLYGON ((1 1, 1 2, 2 2, 1 1))'");
stat.executeQuery("select * from test where poly < 'POLYGON ((1 1, 1 2, 2 2, 1 1))'"); stat.executeQuery("select * from test where polygon < 'POLYGON ((1 1, 1 2, 2 2, 1 1))'");
stat.execute("drop table test"); stat.execute("drop table test");
conn.close(); conn.close();
deleteDb("spatial"); deleteDb("spatial");
...@@ -67,30 +71,30 @@ public class TestSpatial extends TestBase { ...@@ -67,30 +71,30 @@ public class TestSpatial extends TestBase {
deleteDb("spatialIndex"); deleteDb("spatialIndex");
Connection conn = getConnection("spatialIndex"); Connection conn = getConnection("spatialIndex");
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, polygon geometry)");
stat.execute("create spatial index idx_test_poly on test(poly)"); stat.execute("create spatial index idx_test_polygon on test(polygon)");
stat.execute("insert into test values(1, 'POLYGON ((1 1, 1 2, 2 2, 1 1))')"); stat.execute("insert into test values(1, 'POLYGON ((1 1, 1 2, 2 2, 1 1))')");
ResultSet rs = stat.executeQuery("explain select * from test where poly = 'POLYGON ((1 1, 1 2, 2 2, 1 1))'"); ResultSet rs = stat.executeQuery("explain select * from test where polygon = 'POLYGON ((1 1, 1 2, 2 2, 1 1))'");
rs.next(); rs.next();
assertContains(rs.getString(1), "/* PUBLIC.IDX_TEST_POLY: POLY ="); assertContains(rs.getString(1), "/* PUBLIC.IDX_TEST_POLYGON: POLYGON =");
// these queries actually have no meaning in the context of a spatial index, but // these queries actually have no meaning in the context of a spatial index,
// check them anyhow // just check that the query works
stat.executeQuery("select * from test where poly = 'POLYGON ((1 1, 1 2, 2 2, 1 1))'"); stat.executeQuery("select * from test where polygon = 'POLYGON ((1 1, 1 2, 2 2, 1 1))'");
stat.executeQuery("select * from test where poly > 'POLYGON ((1 1, 1 2, 2 2, 1 1))'"); stat.executeQuery("select * from test where polygon > 'POLYGON ((1 1, 1 2, 2 2, 1 1))'");
stat.executeQuery("select * from test where poly < 'POLYGON ((1 1, 1 2, 2 2, 1 1))'"); stat.executeQuery("select * from test where polygon < 'POLYGON ((1 1, 1 2, 2 2, 1 1))'");
rs = stat.executeQuery("select * from test where intersects(poly, 'POLYGON ((1 1, 1 2, 2 2, 1 1))')"); rs = stat.executeQuery("select * from test where intersects(polygon, 'POLYGON ((1 1, 1 2, 2 2, 1 1))')");
assertTrue(rs.next()); assertTrue(rs.next());
rs = stat.executeQuery("select * from test where intersects(poly, 'POINT (1 1)')"); rs = stat.executeQuery("select * from test where intersects(polygon, 'POINT (1 1)')");
assertTrue(rs.next()); assertTrue(rs.next());
rs = stat.executeQuery("select * from test where intersects(poly, 'POINT (0 0)')"); rs = stat.executeQuery("select * from test where intersects(polygon, 'POINT (0 0)')");
assertFalse(rs.next()); assertFalse(rs.next());
stat.execute("drop table test"); stat.execute("drop table test");
conn.close(); conn.close();
deleteDb("spatialIndex"); deleteDb("spatialIndex");
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论