ResultSetrs=stat.executeQuery("select idarea, COUNT(idroad) roadscount from area,roads where area.the_geom && roads.the_geom GROUP BY idarea ORDER BY idarea");
ResultSetrs=stat.executeQuery(
"select idarea, COUNT(idroad) roadscount "+
"from area, roads "+
"where area.the_geom && roads.the_geom "+
"GROUP BY idarea ORDER BY idarea");
assertTrue(rs.next());
assertEquals(1,rs.getInt("idarea"));
assertEquals(3,rs.getInt("roadscount"));
assertEquals(1,rs.getInt("idarea"));
assertEquals(3,rs.getInt("roadscount"));
assertTrue(rs.next());
assertEquals(2,rs.getInt("idarea"));
assertEquals(4,rs.getInt("roadscount"));
assertEquals(2,rs.getInt("idarea"));
assertEquals(4,rs.getInt("roadscount"));
assertTrue(rs.next());
assertEquals(3,rs.getInt("idarea"));
assertEquals(1,rs.getInt("roadscount"));
assertEquals(3,rs.getInt("idarea"));
assertEquals(1,rs.getInt("roadscount"));
assertTrue(rs.next());
assertEquals(4,rs.getInt("idarea"));
assertEquals(2,rs.getInt("roadscount"));
assertEquals(4,rs.getInt("idarea"));
assertEquals(2,rs.getInt("roadscount"));
assertTrue(rs.next());
assertEquals(5,rs.getInt("idarea"));
assertEquals(3,rs.getInt("roadscount"));
assertEquals(5,rs.getInt("idarea"));
assertEquals(3,rs.getInt("roadscount"));
assertTrue(rs.next());
assertEquals(6,rs.getInt("idarea"));
assertEquals(1,rs.getInt("roadscount"));
assertEquals(6,rs.getInt("idarea"));
assertEquals(1,rs.getInt("roadscount"));
assertFalse(rs.next());
rs.close();
}
...
...
@@ -331,25 +360,29 @@ public class TestSpatial extends TestBase {
// Remove a row but do not commit
stat.execute("delete from roads where idroad=7");
// Check if index is updated
ResultSetrs=stat.executeQuery("select idarea, COUNT(idroad) roadscount from area,roads where area.the_geom && roads.the_geom GROUP BY idarea ORDER BY idarea");
ResultSetrs=stat.executeQuery(
"select idarea, COUNT(idroad) roadscount "+
"from area, roads "+
"where area.the_geom && roads.the_geom "+
"GROUP BY idarea ORDER BY idarea");
assertTrue(rs.next());
assertEquals(1,rs.getInt("idarea"));
assertEquals(3,rs.getInt("roadscount"));
assertEquals(1,rs.getInt("idarea"));
assertEquals(3,rs.getInt("roadscount"));
assertTrue(rs.next());
assertEquals(2,rs.getInt("idarea"));
assertEquals(4,rs.getInt("roadscount"));
assertEquals(2,rs.getInt("idarea"));
assertEquals(4,rs.getInt("roadscount"));
assertTrue(rs.next());
assertEquals(3,rs.getInt("idarea"));
assertEquals(1,rs.getInt("roadscount"));
assertEquals(3,rs.getInt("idarea"));
assertEquals(1,rs.getInt("roadscount"));
assertTrue(rs.next());
assertEquals(4,rs.getInt("idarea"));
assertEquals(1,rs.getInt("roadscount"));
assertEquals(4,rs.getInt("idarea"));
assertEquals(1,rs.getInt("roadscount"));
assertTrue(rs.next());
assertEquals(5,rs.getInt("idarea"));
assertEquals(2,rs.getInt("roadscount"));
assertEquals(5,rs.getInt("idarea"));
assertEquals(2,rs.getInt("roadscount"));
assertTrue(rs.next());
assertEquals(6,rs.getInt("idarea"));
assertEquals(1,rs.getInt("roadscount"));
assertEquals(6,rs.getInt("idarea"));
assertEquals(1,rs.getInt("roadscount"));
assertFalse(rs.next());
rs.close();
conn.rollback(sp);
...
...
@@ -380,7 +413,9 @@ public class TestSpatial extends TestBase {