pool.release(broker);
}
}
public void testGeometricProperties() {
BrokerPool pool = null;
DBBroker broker = null;
try {
pool = BrokerPool.getInstance();
assertNotNull(pool);
broker = pool.get(pool.getSecurityManager().getSystemSubject());
XQuery xquery = broker.getXQueryService();
assertNotNull(xquery);
String query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " +
"at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " +
"declare namespace gml = 'http://www.opengis.net/gml'; " +
"spatial:getWKT((//gml:Polygon)[1])";
Sequence seq = xquery.execute(query, null, AccessContext.TEST);
assertNotNull(seq);
assertTrue(seq.getItemCount() > 0);
query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " +
"at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " +
"declare namespace gml = 'http://www.opengis.net/gml'; " +
"spatial:getWKB((//gml:Polygon)[1])";
seq = xquery.execute(query, null, AccessContext.TEST);
assertNotNull(seq);
assertTrue(seq.getItemCount() > 0);
query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " +
"at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " +
"declare namespace gml = 'http://www.opengis.net/gml'; " +
"spatial:getMinX((//gml:Polygon)[1])";
seq = xquery.execute(query, null, AccessContext.TEST);
assertNotNull(seq);
assertTrue(seq.getItemCount() > 0);
query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " +
"at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " +
"declare namespace gml = 'http://www.opengis.net/gml'; " +
"spatial:getMaxX((//gml:Polygon)[1])";
seq = xquery.execute(query, null, AccessContext.TEST);
assertNotNull(seq);
assertTrue(seq.getItemCount() > 0);
query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " +
"at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " +
"declare namespace gml = 'http://www.opengis.net/gml'; " +
"spatial:getMinY((//gml:Polygon)[1])";
seq = xquery.execute(query, null, AccessContext.TEST);
assertNotNull(seq);
assertTrue(seq.getItemCount() > 0);
query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " +
"at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " +
"declare namespace gml = 'http://www.opengis.net/gml'; " +
"spatial:getMaxY((//gml:Polygon)[1])";
seq = xquery.execute(query, null, AccessContext.TEST);
assertNotNull(seq);
assertTrue(seq.getItemCount() > 0);
query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " +
"at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " +
"declare namespace gml = 'http://www.opengis.net/gml'; " +
"spatial:getCentroidX((//gml:Polygon)[1])";
seq = xquery.execute(query, null, AccessContext.TEST);
assertNotNull(seq);
assertTrue(seq.getItemCount() > 0);
query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " +
"at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " +
"declare namespace gml = 'http://www.opengis.net/gml'; " +
"spatial:getCentroidY((//gml:Polygon)[1])";
seq = xquery.execute(query, null, AccessContext.TEST);
assertNotNull(seq);
assertTrue(seq.getItemCount() > 0);
query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " +
"at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " +
"declare namespace gml = 'http://www.opengis.net/gml'; " +
"spatial:getArea((//gml:Polygon)[1])";
seq = xquery.execute(query, null, AccessContext.TEST);
assertNotNull(seq);
assertTrue(seq.getItemCount() > 0);
query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " +
"at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " +
"declare namespace gml = 'http://www.opengis.net/gml'; " +
"spatial:getEPSG4326WKT((//gml:Polygon)[1])";
seq = xquery.execute(query, null, AccessContext.TEST);
assertNotNull(seq);
assertTrue(seq.getItemCount() > 0);
query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " +
"at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " +
"declare namespace gml = 'http://www.opengis.net/gml'; " +
"spatial:getEPSG4326WKB((//gml:Polygon)[1])";
seq = xquery.execute(query, null, AccessContext.TEST);
assertNotNull(seq);
assertTrue(seq.getItemCount() > 0);
query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " +
"at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " +
"declare namespace gml = 'http://www.opengis.net/gml'; " +
"spatial:getEPSG4326MinX((//gml:Polygon)[1])";
seq = xquery.execute(query, null, AccessContext.TEST);
assertNotNull(seq);
assertTrue(seq.getItemCount() > 0);
query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " +
"at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " +
"declare namespace gml = 'http://www.opengis.net/gml'; " +
"spatial:getEPSG4326MaxX((//gml:Polygon)[1])";
seq = xquery.execute(query, null, AccessContext.TEST);
assertNotNull(seq);
assertTrue(seq.getItemCount() > 0);
query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " +
"at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " +
"declare namespace gml = 'http://www.opengis.net/gml'; " +
"spatial:getEPSG4326MinY((//gml:Polygon)[1])";
seq = xquery.execute(query, null, AccessContext.TEST);
assertNotNull(seq);
assertTrue(seq.getItemCount() > 0);
query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " +
"at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " +
"declare namespace gml = 'http://www.opengis.net/gml'; " +
"spatial:getEPSG4326MaxY((//gml:Polygon)[1])";
seq = xquery.execute(query, null, AccessContext.TEST);
assertNotNull(seq);
assertTrue(seq.getItemCount() > 0);
query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " +
"at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " +
"declare namespace gml = 'http://www.opengis.net/gml'; " +
"spatial:getEPSG4326CentroidX((//gml:Polygon)[1])";
seq = xquery.execute(query, null, AccessContext.TEST);
assertNotNull(seq);
assertTrue(seq.getItemCount() > 0);
query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " +
"at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " +
"declare namespace gml = 'http://www.opengis.net/gml'; " +
"spatial:getEPSG4326CentroidY((//gml:Polygon)[1])";
seq = xquery.execute(query, null, AccessContext.TEST);
assertNotNull(seq);
assertTrue(seq.getItemCount() > 0);
query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " +
"at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " +
"declare namespace gml = 'http://www.opengis.net/gml'; " +
"spatial:getEPSG4326Area((//gml:Polygon)[1])";
seq = xquery.execute(query, null, AccessContext.TEST);
assertNotNull(seq);
assertTrue(seq.getItemCount() > 0);
query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " +
"at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " +
"declare namespace gml = 'http://www.opengis.net/gml'; " +
"spatial:getSRS((//gml:Polygon)[1])";
seq = xquery.execute(query, null, AccessContext.TEST);
assertNotNull(seq);
assertTrue(seq.getItemCount() > 0);
query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " +
"at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " +
"declare namespace gml = 'http://www.opengis.net/gml'; " +
"spatial:getGeometryType((//gml:Polygon)[1])";
seq = xquery.execute(query, null, AccessContext.TEST);
assertNotNull(seq);
assertTrue(seq.getItemCount() > 0);
query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " +
"at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " +
"declare namespace gml = 'http://www.opengis.net/gml'; " +
"spatial:isClosed((//gml:Polygon)[1])";
seq = xquery.execute(query, null, AccessContext.TEST);
assertNotNull(seq);
assertTrue(seq.getItemCount() > 0);
query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " +
"at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " +
"declare namespace gml = 'http://www.opengis.net/gml'; " +
"spatial:isSimple((//gml:Polygon)[1])";
seq = xquery.execute(query, null, AccessContext.TEST);
assertNotNull(seq);
assertTrue(seq.getItemCount() > 0);
query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " +
"at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " +
"declare namespace gml = 'http://www.opengis.net/gml'; " +
"spatial:isValid((//gml:Polygon)[1])";
seq = xquery.execute(query, null, AccessContext.TEST);
assertNotNull(seq);
assertTrue(seq.getItemCount() > 0);
//Tests with empty sequences
query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " +
"at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " +
"declare namespace gml = 'http://www.opengis.net/gml'; " +
"spatial:getWKT(())";
seq = xquery.execute(query, null, AccessContext.TEST);
assertNotNull(seq);
assertTrue(seq.getItemCount() == 0);
query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " +
"at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " +
"declare namespace gml = 'http://www.opengis.net/gml'; " +
"spatial:getArea(())";
seq = xquery.execute(query, null, AccessContext.TEST);
assertNotNull(seq);
assertTrue(seq.getItemCount() == 0);
//In-memory tests
query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " +
"at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " +
"declare namespace gml = 'http://www.opengis.net/gml'; " +
"spatial:getWKT(" + IN_MEMORY_GML + ")";
seq = xquery.execute(query, null, AccessContext.TEST);
assertNotNull(seq);
assertTrue(seq.getItemCount() > 0);
query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " +
"at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " +
"declare namespace gml = 'http://www.opengis.net/gml'; " +
"spatial:getWKB(" + IN_MEMORY_GML + ")";
seq = xquery.execute(query, null, AccessContext.TEST);
assertNotNull(seq);
assertTrue(seq.getItemCount() > 0);
query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " +
"at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " +
"declare namespace gml = 'http://www.opengis.net/gml'; " +
"spatial:getMinX(" + IN_MEMORY_GML + ")";
seq = xquery.execute(query, null, AccessContext.TEST);
assertNotNull(seq);
assertTrue(seq.getItemCount() > 0);
query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " +
"at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " +
"declare namespace gml = 'http://www.opengis.net/gml'; " +
"spatial:getMaxX(" + IN_MEMORY_GML + ")";
seq = xquery.execute(query, null, AccessContext.TEST);
assertNotNull(seq);
assertTrue(seq.getItemCount() > 0);
query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " +
"at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " +
"declare namespace gml = 'http://www.opengis.net/gml'; " +
"spatial:getMinY(" + IN_MEMORY_GML + ")";
seq = xquery.execute(query, null, AccessContext.TEST);
assertNotNull(seq);
assertTrue(seq.getItemCount() > 0);
query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " +
"at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " +
"declare namespace gml = 'http://www.opengis.net/gml'; " +
"spatial:getMaxY(" + IN_MEMORY_GML + ")";
seq = xquery.execute(query, null, AccessContext.TEST);
assertNotNull(seq);
assertTrue(seq.getItemCount() > 0);
query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " +
"at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " +
"declare namespace gml = 'http://www.opengis.net/gml'; " +
"spatial:getCentroidX(" + IN_MEMORY_GML + ")";
seq = xquery.execute(query, null, AccessContext.TEST);
assertNotNull(seq);
assertTrue(seq.getItemCount() > 0);
query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " +
"at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " +
"declare namespace gml = 'http://www.opengis.net/gml'; " +
"spatial:getCentroidY(" + IN_MEMORY_GML + ")";
seq = xquery.execute(query, null, AccessContext.TEST);
assertNotNull(seq);
assertTrue(seq.getItemCount() > 0);
query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " +
"at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " +
"declare namespace gml = 'http://www.opengis.net/gml'; " +
"spatial:getArea(" + IN_MEMORY_GML + ")";
seq = xquery.execute(query, null, AccessContext.TEST);
assertNotNull(seq);
assertTrue(seq.getItemCount() > 0);
query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " +
"at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " +
"declare namespace gml = 'http://www.opengis.net/gml'; " +
"spatial:getEPSG4326WKT(" + IN_MEMORY_GML + ")";
seq = xquery.execute(query, null, AccessContext.TEST);
assertNotNull(seq);
assertTrue(seq.getItemCount() > 0);
query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " +
"at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " +
"declare namespace gml = 'http://www.opengis.net/gml'; " +
"spatial:getEPSG4326WKB(" + IN_MEMORY_GML + ")";
seq = xquery.execute(query, null, AccessContext.TEST);
assertNotNull(seq);
assertTrue(seq.getItemCount() > 0);
query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " +
"at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " +
"declare namespace gml = 'http://www.opengis.net/gml'; " +
"spatial:getEPSG4326MinX(" + IN_MEMORY_GML + ")";
seq = xquery.execute(query, null, AccessContext.TEST);
assertNotNull(seq);
assertTrue(seq.getItemCount() > 0);
query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " +
"at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " +
"declare namespace gml = 'http://www.opengis.net/gml'; " +
"spatial:getEPSG4326MaxX(" + IN_MEMORY_GML + ")";
seq = xquery.execute(query, null, AccessContext.TEST);
assertNotNull(seq);
assertTrue(seq.getItemCount() > 0);
query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " +
"at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " +
"declare namespace gml = 'http://www.opengis.net/gml'; " +
"spatial:getEPSG4326MinY(" + IN_MEMORY_GML + ")";
seq = xquery.execute(query, null, AccessContext.TEST);
assertNotNull(seq);
assertTrue(seq.getItemCount() > 0);
query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " +
"at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " +
"declare namespace gml = 'http://www.opengis.net/gml'; " +
"spatial:getEPSG4326MaxY(" + IN_MEMORY_GML + ")";
seq = xquery.execute(query, null, AccessContext.TEST);
assertNotNull(seq);
assertTrue(seq.getItemCount() > 0);
query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " +
"at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " +
"declare namespace gml = 'http://www.opengis.net/gml'; " +
"spatial:getEPSG4326CentroidX(" + IN_MEMORY_GML + ")";
seq = xquery.execute(query, null, AccessContext.TEST);
assertNotNull(seq);
assertTrue(seq.getItemCount() > 0);
query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " +
"at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " +
"declare namespace gml = 'http://www.opengis.net/gml'; " +
"spatial:getEPSG4326CentroidY(" + IN_MEMORY_GML + ")";
seq = xquery.execute(query, null, AccessContext.TEST);
assertNotNull(seq);
assertTrue(seq.getItemCount() > 0);
query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " +
"at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " +
"declare namespace gml = 'http://www.opengis.net/gml'; " +
"spatial:getEPSG4326Area(" + IN_MEMORY_GML + ")";
seq = xquery.execute(query, null, AccessContext.TEST);
assertNotNull(seq);
assertTrue(seq.getItemCount() > 0);
query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " +
"at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " +
"declare namespace gml = 'http://www.opengis.net/gml'; " +
"spatial:getSRS(" + IN_MEMORY_GML + ")";
seq = xquery.execute(query, null, AccessContext.TEST);
assertNotNull(seq);
assertTrue(seq.getItemCount() > 0);
query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " +
"at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " +
"declare namespace gml = 'http://www.opengis.net/gml'; " +
"spatial:getGeometryType(" + IN_MEMORY_GML + ")";
seq = xquery.execute(query, null, AccessContext.TEST);
assertNotNull(seq);
assertTrue(seq.getItemCount() > 0);
query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " +
"at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " +
"declare namespace gml = 'http://www.opengis.net/gml'; " +
"spatial:isClosed(" + IN_MEMORY_GML + ")";
seq = xquery.execute(query, null, AccessContext.TEST);
assertNotNull(seq);
assertTrue(seq.getItemCount() > 0);
query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " +
"at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " +
"declare namespace gml = 'http://www.opengis.net/gml'; " +
"spatial:isSimple(" + IN_MEMORY_GML + ")";
seq = xquery.execute(query, null, AccessContext.TEST);
assertNotNull(seq);
assertTrue(seq.getItemCount() > 0);
query = "import module namespace spatial='http://exist-db.org/xquery/spatial' " +
"at 'java:org.exist.examples.indexing.spatial.module.SpatialModule'; " +
"declare namespace gml = 'http://www.opengis.net/gml'; " +
"spatial:isValid(" + IN_MEMORY_GML + ")";
seq = xquery.execute(query, null, AccessContext.TEST);
assertNotNull(seq);
assertTrue(seq.getItemCount() > 0);
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
} finally {
if (pool !=null)
pool.release(broker);
}
}