# HG changeset patch # User Giannis Vlachopoulos # Date 1431591889 -10800 # Node ID 6521e8989dc9820bdb3145162fda1263c9d3e87a # Parent 38b0c0a12614f8dfa97393a4ec9f9b49aa3bfc6d# Parent 94599fbf9c01bd42b42472c27bfec694cfaee77d merge diff -r 38b0c0a12614 -r 6521e8989dc9 generaldb/src/test/java/org/openrdf/sesame/sail/generaldb/AppTest.java --- a/generaldb/src/test/java/org/openrdf/sesame/sail/generaldb/AppTest.java Thu May 14 11:24:32 2015 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,38 +0,0 @@ -package org.openrdf.sesame.sail.generaldb; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -/** - * Unit test for simple App. - */ -public class AppTest - extends TestCase -{ - /** - * Create the test case - * - * @param testName name of the test case - */ - public AppTest( String testName ) - { - super( testName ); - } - - /** - * @return the suite of tests being tested - */ - public static Test suite() - { - return new TestSuite( AppTest.class ); - } - - /** - * Rigourous Test :-) - */ - public void testApp() - { - assertTrue( true ); - } -} diff -r 38b0c0a12614 -r 6521e8989dc9 postgis/src/test/java/org/openrdf/sesame/sail/postgis/AppTest.java --- a/postgis/src/test/java/org/openrdf/sesame/sail/postgis/AppTest.java Thu May 14 11:24:32 2015 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,38 +0,0 @@ -package org.openrdf.sesame.sail.postgis; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -/** - * Unit test for simple App. - */ -public class AppTest - extends TestCase -{ - /** - * Create the test case - * - * @param testName name of the test case - */ - public AppTest( String testName ) - { - super( testName ); - } - - /** - * @return the suite of tests being tested - */ - public static Test suite() - { - return new TestSuite( AppTest.class ); - } - - /** - * Rigourous Test :-) - */ - public void testApp() - { - assertTrue( true ); - } -} diff -r 38b0c0a12614 -r 6521e8989dc9 runtime/src/main/java/eu/earthobservatory/utils/GeonamesParser.java --- a/runtime/src/main/java/eu/earthobservatory/utils/GeonamesParser.java Thu May 14 11:24:32 2015 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,392 +0,0 @@ -/** - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * Copyright (C) 2010, 2011, 2012, Pyravlos Team - * - * http://www.strabon.di.uoa.gr/ - */ -package eu.earthobservatory.utils; - -import info.aduna.iteration.CloseableIteration; - -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.OutputStreamWriter; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.ListIterator; -import java.util.Map; - -import org.geotools.data.DataUtilities; -import org.geotools.data.shapefile.ShapefileDataStore; -import org.geotools.data.shapefile.ShapefileDataStoreFactory; -import org.geotools.data.simple.SimpleFeatureCollection; -import org.geotools.data.simple.SimpleFeatureIterator; -import org.geotools.data.simple.SimpleFeatureSource; -import org.geotools.feature.FeatureCollections; -import org.geotools.feature.SchemaException; -import org.geotools.feature.simple.SimpleFeatureBuilder; -import org.geotools.geometry.jts.JTSFactoryFinder; -import org.opengis.feature.simple.SimpleFeature; -import org.opengis.feature.simple.SimpleFeatureType; -import org.opengis.geometry.MismatchedDimensionException; -import org.opengis.referencing.FactoryException; -import org.opengis.referencing.NoSuchAuthorityCodeException; -import org.opengis.referencing.operation.TransformException; -import org.openrdf.model.Namespace; -import org.openrdf.model.Resource; -import org.openrdf.model.Statement; -import org.openrdf.model.URI; -import org.openrdf.model.Value; -import org.openrdf.model.impl.LiteralImpl; -import org.openrdf.model.impl.StatementImpl; -import org.openrdf.model.impl.URIImpl; -import org.openrdf.repository.Repository; -import org.openrdf.repository.RepositoryConnection; -import org.openrdf.repository.RepositoryException; -import org.openrdf.repository.sail.SailRepository; -import org.openrdf.rio.RDFHandler; -import org.openrdf.rio.RDFHandlerException; -import org.openrdf.rio.RDFParseException; -import org.openrdf.rio.RDFWriter; -import org.openrdf.rio.turtle.TurtleWriter; - -import org.openrdf.sail.memory.MemoryStore; - -import com.vividsolutions.jts.geom.Coordinate; -import com.vividsolutions.jts.geom.Geometry; -import com.vividsolutions.jts.geom.GeometryFactory; -import com.vividsolutions.jts.geom.MultiLineString; -import com.vividsolutions.jts.geom.Point; -import com.vividsolutions.jts.io.ParseException; -import com.vividsolutions.jts.io.WKTReader; - -public class GeonamesParser { - - static int pointsOut = 0; - static int e = 0, a = 0; - - public static void main(String[] args) throws IOException, SchemaException, - NoSuchAuthorityCodeException, FactoryException, - MismatchedDimensionException, TransformException { - - if (args.length < 2) { - System.err.println("Usage: eu.earthobservatory.utils.GeonamesParser "); - System.exit(0); - } - final String inFile = args[0]; - final String outFile = args[1]; - final String baseURI = "http://www.geonames.org"; - - String greece = "POLYGON((" + - "19.2214041948412 39.915644583545,19.2214041948412 39.915644583545,19.181097387078 39.9237059450676," + - "19.5519200182563 40.0285036451009,19.6567177185669 39.9156445835922,20.1968289424263 39.9075832219288," + - "20.3741788961446 40.1655467910226,20.6805106346546 40.4073876369722,20.8497992263774 40.94749885984," + - "21.6962421887069 41.0845420054562,21.8897148655894 41.2538305976083,22.5910533201724 41.2780146817553," + - "22.5829919583984 41.4231191894311,23.1150418204718 41.4473032736882,23.5987235131646 41.5279168887397," + - "23.896993890336 41.5682236962285,24.3967983060956 41.6568986728098,24.7434368528031 41.5359782495121," + - "25.331916245936 41.3989351029729,25.9687638080256 41.4553646333056,26.0574387848902 41.5440396101636," + - "25.9284569997944 41.7536350102425,26.1944819306803 41.8423099869814,26.6297954543722 41.7375122866789," + - "26.7426545167742 41.2941374019925,26.4685682243736 41.1812783406592,26.5169363940019 40.9716829406332," + - "26.0896842326308 40.6008603101938,25.5415116482987 40.0688104490916,26.4927523118004 39.4642083330579," + - "26.7265317973552 39.0288948098343,26.4040773361785 38.5693972024431,27.1537839611879 37.8599973865071," + - "28.451663172698 36.4734432006192,28.0082882886197 35.6834297705082,29.5560697054562 36.3605841370316," + - "29.9671991450442 36.0864978436166,27.0570476273072 34.6596368562464,24.0904665776989 34.5870846050009," + - "21.9219603198949 35.538325268111,19.2214041948412 39.915644583545" + - "))"; - - Repository myRepository = new SailRepository(new MemoryStore()); - BufferedReader dis = null; - RepositoryConnection conn = null; - boolean isEven = false; - - Geometry greeceGeo = null; - try { - //mbbInWGS84 = new WKTReader().read("POLYGON((-10.6700 34.5000, 31.5500 34.5000, 31.5500 71.0500, -10.6700 71.0500, -10.6700 34.5000))"); - greeceGeo = new WKTReader().read(greece); - greeceGeo.setSRID(4326); - } catch (ParseException e1) { - e1.printStackTrace(); - } - - // System.out.println("|--MBB Created--|"); - - // // -- Display map of Greece and its mbb -- // - // SimpleFeatureCollection mbbCollection = createCollection(mbbInWGS84); - // MapContext map = new DefaultMapContext(); - // map.setTitle("Map"); - // map.addLayer(clcFeatureCollection, null); - // map.addLayer(mbbCollection, null); - // JMapFrame.showMap(map); - - try { - // Initialization of classes used for RDF handling - myRepository.initialize(); - conn = myRepository.getConnection(); - conn.setAutoCommit(true); - - dis = new BufferedReader(new InputStreamReader( - new FileInputStream(new File(inFile)))); - BufferedWriter osw = new BufferedWriter(new OutputStreamWriter( - new FileOutputStream(outFile), "UTF-8")); - // BufferedWriter osw = new BufferedWriter(new - // OutputStreamWriter(new FileOutputStream(outFile), "UTF-8")); - RDFWriter wr = new TurtleWriter(osw); - String line = null; - - // Adding data to repository - wr.startRDF(); - while (dis.ready()) { - line = dis.readLine(); - if (isEven) { - try { - conn.clear(); - //ByteArrayInputStream bis = new ByteArrayInputStream(line.getBytes()); - ByteArrayInputStream bis = new ByteArrayInputStream(line.getBytes("UTF-8")); - conn.add(bis, baseURI, org.openrdf.rio.RDFFormat.RDFXML); - exportGeoname(wr, conn, greeceGeo); - } catch (RDFParseException ex) { - System.err.println(line); - e++; - } - } else { - a++; - } - isEven = !isEven; - } - wr.endRDF(); - dis.close(); - - System.out.println("Rejected features: " + e); - System.out.println("Parsed features: " + a); - System.out.println("Points out of MBB of Greece: " + pointsOut); - } catch (RepositoryException e) { - e.printStackTrace(); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } catch (RDFHandlerException e) { - e.printStackTrace(); - } - - } - - /** - * Create a SimpleFeatureCollection with a Geometry - * - * @param all - * @return - * @throws SchemaException - */ - public static SimpleFeatureCollection createCollection(Geometry g) - throws SchemaException { - - SimpleFeatureCollection collection = FeatureCollections.newCollection(); - SimpleFeatureType TYPE = DataUtilities.createType("MBB", - "location:Polygon:srid=4326"); // 4326 = srid of wgs84 - SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(TYPE); - - featureBuilder.add(g); - SimpleFeature feature = featureBuilder.buildFeature(null); - collection.add(feature); - - return collection; - } - -// public static Geometry getMBB(String filename) throws IOException, -// SchemaException, NoSuchAuthorityCodeException, FactoryException { -// SimpleFeatureCollection featureCollection = getFeatureCollection( -// filename, "ISO8859-7"); -// -// SimpleFeatureIterator featureIterator = featureCollection.features(); -// -// MultiPolygon all = null; -// // Iterate features of shp file -// while (featureIterator.hasNext()) { -// SimpleFeature f = featureIterator.next(); -// List attributes = f.getAttributes(); -// -// MultiPolygon landItem = (MultiPolygon) attributes.get(0); -// -// if (all == null) -// all = landItem; -// else -// all = (MultiPolygon) all.union(landItem); -// } -// -// return all.getEnvelope(); -// } - - /** - * @param filename - * shp file to be opened - * @param encoding - * encoding of opened shp file - * @return a feature collection of opened shp file - * @throws IOException - * @throws FactoryException - * @throws NoSuchAuthorityCodeException - */ - public static SimpleFeatureCollection getFeatureCollection(String filename, - String encoding) throws IOException, NoSuchAuthorityCodeException, - FactoryException { - // Open file - File infile = new File(filename); - - // Parameters of ShapefileDatastore - Map params = new HashMap(); - params.put(ShapefileDataStoreFactory.URLP.key, infile.toURI().toURL()); - // params.put("create spatial index", Boolean.TRUE); - params.put(ShapefileDataStoreFactory.DBFCHARSET.key, encoding); - - // -- Create ShapefileDatastore -- // - ShapefileDataStoreFactory dataStoreFactory = new ShapefileDataStoreFactory(); - ShapefileDataStore shapefile = (ShapefileDataStore) dataStoreFactory - .createNewDataStore(params); - // shapefile.setStringCharset(Charset.forName("ISO8859-7")); - // DataStore shapefile = new ShapefileDataStore( infile.toURI().toURL(), false); - - // Get feature collection - String[] typeName = shapefile.getTypeNames(); - SimpleFeatureSource featureSource = shapefile - .getFeatureSource(typeName[0]); - //SimpleFeatureCollection collection; - SimpleFeatureCollection featureCollection = featureSource.getFeatures(); - - // SimpleFeatureIterator clcFeatureIterator = - // clcFeatureCollection.features(); - return featureCollection; - } - - // public static void showMap(String filename) throws IOException { - // - // File file = new File(filename); - // - // FileDataStore store = FileDataStoreFinder.getDataStore(file); - // SimpleFeatureSource featureSource = store.getFeatureSource(); - // - // // Create a map context and add our shapefile to it - // MapContext map = new DefaultMapContext(); - // map.setTitle("Quickstart"); - // map.addLayer(featureSource, null); - // - // // Now display the map - // JMapFrame.showMap(map); - // } - - /** - * @param featureIterator - * iterator of features to print - * @throws IOException - */ - public static void printFeatures(SimpleFeatureIterator featureIterator) - throws IOException { - - // Iterate features of shp file - while (featureIterator.hasNext()) { - SimpleFeature f = featureIterator.next(); - List attributes = f.getAttributes(); - - for (int i = 0; i < attributes.size(); i++) { - // MultiLineString geometry = - // (MultiLineString)attributes.get(0); - Object attribute = attributes.get(i); - if (!(attribute instanceof MultiLineString)) - System.out.println(attributes.get(i).toString()); - } - System.out.println("---------"); - } - } - - public static void exportGeoname(RDFHandler handler, - RepositoryConnection conn, Geometry greeceGeo) - throws RepositoryException, RDFHandlerException { - - final URI hasGeography = new URIImpl( - "http://teleios.di.uoa.gr/ontologies/noaOntology.owl#hasGeography"); - final URI geometry = new URIImpl("http://strdf.di.uoa.gr/ontology#WKT"); - URI latPredicate = new URIImpl( - "http://www.w3.org/2003/01/geo/wgs84_pos#lat"); - URI longPredicate = new URIImpl( - "http://www.w3.org/2003/01/geo/wgs84_pos#long"); - - handler.handleNamespace("geo", "http://www.example.org/geo#"); - handler.handleNamespace("strdf", "http://strdf.di.uoa.gr/ontology#"); - handler.handleNamespace("noa", - "http://teleios.di.uoa.gr/ontologies/noaOntology.owl#"); - - // Export namespace information - CloseableIteration nsIter = conn - .getNamespaces(); - try { - while (nsIter.hasNext()) { - Namespace ns = nsIter.next(); - handler.handleNamespace(ns.getPrefix(), ns.getName()); - } - } finally { - nsIter.close(); - } - - // Export statements - CloseableIteration stIter = conn - .getStatements(null, null, null, false); - - try { - Value latV = null, longV = null; - Statement st = null; - ArrayList stL = new ArrayList(); - Resource sub = null; - while (stIter.hasNext()) { - st = stIter.next(); - URI p = st.getPredicate(); - - if (p.equals(latPredicate)) { - sub = st.getSubject(); - latV = st.getObject(); - } else if (p.equals(longPredicate)) { - longV = st.getObject(); - } else { - stL.add(st); - } - } - st = new StatementImpl(sub, hasGeography, new LiteralImpl("POINT(" - + longV.stringValue() + " " + latV.stringValue() + ")", - geometry) // TODO einai swsth h seira, nomizw nai ?? - ); - stL.add(st); - - GeometryFactory geometryFactory = JTSFactoryFinder - .getGeometryFactory(null); - Point point = geometryFactory.createPoint(new Coordinate(Double.parseDouble( - //latV.stringValue()), Double.parseDouble(longV.stringValue())) - longV.stringValue()), Double.parseDouble(latV.stringValue())) - ); - // TODO To parapanw nomizw einai swsto edw giati ta pairnei - // anapoda?? - - if (greeceGeo.contains(point)) { - ListIterator stLI = stL.listIterator(); - while (stLI.hasNext()) { - handler.handleStatement(stLI.next()); - } - } else - pointsOut++; - - System.out.println(a + ": " + e + " - " + pointsOut); - } finally { - stIter.close(); - } - } -} \ No newline at end of file diff -r 38b0c0a12614 -r 6521e8989dc9 runtime/src/test/java/eu/earthobservatory/runtime/generaldb/AggregateTests.java --- a/runtime/src/test/java/eu/earthobservatory/runtime/generaldb/AggregateTests.java Thu May 14 11:24:32 2015 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,143 +0,0 @@ -/** - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * Copyright (C) 2010, 2011, 2012, Pyravlos Team - * - * http://www.strabon.di.uoa.gr/ - */ -package eu.earthobservatory.runtime.generaldb; - -import java.io.IOException; - -import org.junit.Test; -import org.openrdf.query.MalformedQueryException; -import org.openrdf.query.QueryEvaluationException; -import org.openrdf.query.TupleQueryResultHandlerException; - -public class AggregateTests { - public static Strabon strabon; - - - protected static String jdbcDriver= "org.postgresql.Driver"; - protected static String serverName = "localhost"; - protected static String username = "postgres"; - protected static String password = "postgres"; - protected static Integer port = 5432; - protected static java.sql.Connection conn = null; - protected static String databaseName = null; - - - - - - String prefixes = - "PREFIX lgdo: "+ - "PREFIX geo: "+ - "PREFIX rdfs: "+ - "PREFIX strdf: "; - - String queryGroupBy1 = - prefixes+ - "SELECT (?placegeo AS ?xxx) (AVG(?placegeo) AS ?av) (strdf:union(?placegeo) AS ?united) "+ - "WHERE { "+ - "?place "+ - "rdfs:label ?placename ; "+ - "geo:geometry ?placegeo ; "+ - "a ?type. "+ - "FILTER(strdf:mbbIntersects(?placegeo,?placegeo)) "+ - "} "+ - "GROUP BY ?placegeo (STR(?place) AS ?str) strdf:union(?placegeo,?placegeo) "+ - "HAVING (AVG(?str) < 1) "+ - "ORDER BY ?placegeo strdf:union(?placegeo,?placegeo) "+ - ""; - - String queryGroupBy2 = - prefixes+ - "SELECT (strdf:union(strdf:intersection(?placegeo,?placegeo2)) AS ?united) "+ - "WHERE { "+ - "?place "+ - "rdfs:label ?placename ; "+ - "geo:geometry ?placegeo ; "+ - "geo:geometry ?placegeo2 ; "+ - "a ?type. "+ - "FILTER(strdf:mbbIntersects(?placegeo,?placegeo)) "+ - "} "+ - "GROUP BY ?placegeo ?placegeo2"; - - String queryGroupBy3 = - prefixes+ - "SELECT (strdf:union(strdf:intersection(?placegeo,?placegeo2)) AS ?united) "+ - "WHERE { "+ - "?place "+ - "rdfs:label ?placename ; "+ - "geo:geometry ?placegeo ; "+ - "geo:geometry ?placegeo2 ; "+ - "a ?type. "+ - "FILTER(strdf:mbbIntersects(?placegeo,?placegeo)) "+ - "} "+ - "GROUP BY ?placegeo ?placegeo2"; - - - String queryOrder1 = - prefixes+ - "SELECT ?placegeo ?place (strdf:union(?placegeo) AS ?koko) (strdf:union(?placegeo,?placegeo) AS ?kiki) "+ - "WHERE { "+ - "?place "+ - "rdfs:label ?placename ; "+ - "geo:geometry ?placegeo ; "+ - "a ?type. "+ - "FILTER(strdf:mbbIntersects(?placegeo,?placegeo)) "+ - "} "+ - "ORDER BY strdf:union(?placegeo,?placegeo) ?placegeo ?place"; - - - String queryOrder2 = - prefixes+ - "SELECT (?place AS ?xx) (strdf:union(?placegeo,?placegeo) AS ?koko) ?place "+ - "WHERE { "+ - "?place "+ - "rdfs:label ?placename ; "+ - "geo:geometry ?placegeo ; "+ - "a ?type. "+ - "FILTER(strdf:mbbIntersects(?placegeo,?placegeo)) "+ - "} "+ - "ORDER BY ?placegeo "; - - - - @Test - public void testQueryGroupBy1() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - strabon.query(queryGroupBy1,strabon.getSailRepoConnection()); - } - - @Test - public void testQueryGroupBy2() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - strabon.query(queryGroupBy2,strabon.getSailRepoConnection()); - - } - - @Test - public void testQueryGroupBy3() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - strabon.query(queryGroupBy3,strabon.getSailRepoConnection()); - - } - - @Test - public void testQueryOrder1() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - strabon.query(queryOrder1,strabon.getSailRepoConnection()); - - } - - @Test - public void testQueryOrder2() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - strabon.query(queryOrder2,strabon.getSailRepoConnection()); - - } -} diff -r 38b0c0a12614 -r 6521e8989dc9 runtime/src/test/java/eu/earthobservatory/runtime/generaldb/GeneralTests.java --- a/runtime/src/test/java/eu/earthobservatory/runtime/generaldb/GeneralTests.java Thu May 14 11:24:32 2015 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,649 +0,0 @@ -/** - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * Copyright (C) 2010, 2011, 2012, Pyravlos Team - * - * http://www.strabon.di.uoa.gr/ - */ -package eu.earthobservatory.runtime.generaldb; - -import java.io.IOException; - -import org.junit.Test; -import org.openrdf.query.MalformedQueryException; -import org.openrdf.query.QueryEvaluationException; -import org.openrdf.query.TupleQueryResultHandlerException; - -abstract public class GeneralTests { - public static Strabon strabon; - - - protected static String jdbcDriver= "org.postgresql.Driver"; - protected static String serverName = "localhost"; - protected static String username = "postgres"; - protected static String password = "postgres"; - protected static Integer port = 5432; - protected static java.sql.Connection conn = null; - protected static String databaseName = null; - - // @BeforeClass - // public static void initialize() throws SQLException, ClassNotFoundException - // { - // strabon = new Strabon("cco2","postgres","p1r3as", 5432, "localhost", true); - // - // } - - - - - - - protected String prefixes = - "PREFIX lgdo: "+ - "PREFIX geo: "+ - "PREFIX rdfs: "+ - "PREFIX strdf: "+ - "PREFIX geonames:"; - - protected String query1 = - prefixes+ - "SELECT ?place ?placegeo "+ - "WHERE { "+ - "?place "+ - "rdfs:label ?placename ; "+ - "geo:geometry ?placegeo ; "+ - "a ?type. "+ - "FILTER(strdf:mbbIntersects(strdf:union(?placegeo,?placegeo),?placegeo)) "+ - "}"; - - protected String query2 = - prefixes+ - "SELECT ?place (?placegeo AS ?tt1) (strdf:union(?placegeo,?placegeo) AS ?constr) "+ - "WHERE { "+ - "?place "+ - " a ?type ; "+ - " geo:geometry ?placegeo ; "+ - " rdfs:label ?placename . "+ - "FILTER(strdf:mbbIntersects(strdf:union(?placegeo,?placegeo),?placegeo)) "+ - "}"; - - protected String query3 = - prefixes+ - "SELECT ?place (?placegeo AS ?constr) "+ - "WHERE { "+ - "?place "+ - " a ?type ; "+ - " geo:geometry ?placegeo ; "+ - " rdfs:label ?placename . "+ - "FILTER(strdf:mbbIntersects(strdf:union(?placegeo,?placegeo),?placegeo)) "+ - "}"; - - protected String query4 = - prefixes+ - "SELECT ?place ?placegeo "+ - "WHERE { "+ - "?place "+ - " a ?type ; "+ - " geo:geometry ?placegeo ; "+ - " rdfs:label ?placename . "+ - "FILTER(strdf:mbbIntersects(strdf:union(?placegeo,?placegeo),?placegeo) " + - "&& strdf:mbbIntersects(strdf:union(?placegeo,?placegeo),?placegeo)) "+ - "}"; - - protected String query5 = - prefixes+ - "SELECT ?place ?placegeo "+ - "WHERE { "+ - "?place "+ - " a ?type ; "+ - " geo:geometry ?placegeo ; "+ - " rdfs:label ?placename . "+ - "FILTER(strdf:mbbIntersects(strdf:union(?placegeo,?placegeo),?placegeo)). "+ - "FILTER(strdf:mbbIntersects(strdf:union(?placegeo,?placegeo),?placegeo)). "+ - "}"; - - protected String query6 = - prefixes+ - "SELECT (strdf:union(?placegeo,strdf:union(?placegeo,?placegeo)) AS ?constr1) " + - "?place (?placegeo AS ?tt1) (strdf:union(?placegeo,?placegeo) AS ?constr2) "+ - "WHERE { "+ - "?place "+ - " a ?type ; "+ - " geo:geometry ?placegeo ; "+ - " rdfs:label ?placename . "+ - "FILTER(strdf:mbbIntersects(strdf:union(?placegeo,?placegeo),?placegeo)) "+ - "}"; - - protected String query7 = - prefixes+ - "SELECT ?place (?placegeo AS ?tt1) (strdf:union(?placegeo,?placegeo) AS ?constr) "+ - "WHERE { "+ - "?place "+ - " a ?type ; "+ - " geo:geometry ?placegeo ; "+ - " rdfs:label ?placename . "+ - "} "; - - protected String query8 = - prefixes+ - "SELECT ?place "+ - "WHERE { "+ - "?place "+ - " a ?type ; "+ - " geo:geometry ?placegeo ; "+ - " rdfs:label ?placename . "+ - "FILTER(strdf:mbbIntersects(?placegeo,?placegeo)) "+ - "}"; - - protected String queryBufferVar = - prefixes+ - "SELECT ?place (?placegeo AS ?tt1) "+ - "WHERE { ?x lgdo:bufferExtent ?ext . "+ - "?place "+ - " a ?type ; "+ - " geo:geometry ?placegeo ; "+ - " rdfs:label ?placename . "+ - "FILTER(strdf:mbbIntersects(strdf:buffer(?placegeo,?ext),?placegeo)) "+ - "}"; - - protected String queryBufferConst = - prefixes+ - "SELECT ?place (?placegeo AS ?tt1) "+ - "WHERE { ?x lgdo:bufferExtent ?ext . "+ - "?place "+ - " a ?type ; "+ - " geo:geometry ?placegeo ; "+ - " rdfs:label ?placename . "+ - "FILTER(strdf:mbbIntersects(strdf:buffer(?placegeo,2),?placegeo)) "+ - "}"; - - protected String queryBufferConst2 = - prefixes+ - "SELECT ?place (?placegeo AS ?tt1) "+ - "WHERE { ?x lgdo:bufferExtent ?ext . "+ - "?place "+ - " a ?type ; "+ - " geo:geometry ?placegeo ; "+ - " rdfs:label ?placename . "+ - "FILTER(strdf:mbbIntersects(strdf:buffer(\"POINT(23.72873 37.97205)\"^^,0.0572),?placegeo)) "+ - "}"; - - protected String queryBufferConstInSelect = - prefixes+ - "SELECT ?place (?placegeo AS ?tt1) (strdf:buffer(?placegeo,2.5) AS ?buf) "+ - "WHERE { ?x lgdo:bufferExtent ?ext . "+ - "?place "+ - " a ?type ; "+ - " geo:geometry ?placegeo ; "+ - " rdfs:label ?placename . "+ - "FILTER(strdf:mbbIntersects(strdf:buffer(?placegeo,2.5),?placegeo)) "+ - "}"; - - - protected String queryBufferSelectFilterA = - prefixes+ - "SELECT ?place (?placegeo AS ?tt1) (strdf:buffer(?placegeo,?ext) AS ?buf) "+ - "WHERE { ?x lgdo:bufferExtent ?ext . "+ - "?place "+ - " a ?type ; "+ - " geo:geometry ?placegeo ; "+ - " rdfs:label ?placename . "+ - "FILTER(strdf:mbbIntersects(strdf:buffer(?placegeo,2),?placegeo)) "+ - "}"; - - protected String queryBufferSelectFilterB = - prefixes+ - "SELECT ?place (?placegeo AS ?tt1) (strdf:buffer(?placegeo,3) AS ?buf) "+ - "WHERE { ?x lgdo:bufferExtent ?ext . "+ - "?place "+ - " a ?type ; "+ - " geo:geometry ?placegeo ; "+ - " rdfs:label ?placename . "+ - "FILTER(strdf:mbbIntersects(strdf:buffer(?placegeo,?ext),?placegeo)) "+ - "}"; - - protected String queryEnvelopeConvexHull = - prefixes+ - "SELECT ?place (?placegeo AS ?tt1) (strdf:envelope(?placegeo) AS ?constr) (strdf:convexHull(?placegeo) AS ?constr2) "+ - "WHERE { "+ - "?place "+ - " a ?type ; "+ - " geo:geometry ?placegeo ; "+ - " rdfs:label ?placename . "+ - "FILTER(strdf:mbbIntersects(strdf:union(?placegeo,strdf:envelope(?placegeo)),?placegeo) && strdf:mbbIntersects(strdf:convexHull(?placegeo),?placegeo)) "+ - "}"; - - protected String queryMetrics1 = - prefixes+ - "SELECT ?place ?placegeo ( strdf:area(?placegeo) AS ?area) "+ - "( strdf:envelope(?placegeo) AS ?mbb) "+ - "WHERE { ?x lgdo:bufferExtent ?ext . "+ - "?place "+ - " rdfs:label ?placename ; "+ - " geo:geometry ?placegeo ; "+ - " a ?type. "+ - "FILTER(2*strdf:distance(?placegeo,?placegeo) + strdf:area(?placegeo) - 3 + ?ext "+ - "< ?ext + 8 - strdf:distance(?placegeo,?placegeo)) "+ - "}"; - - protected String queryMetricsLightOptimized = - prefixes+ - "SELECT ?place ?placegeo ( 33*strdf:area(?placegeo) + 114 AS ?area) ( strdf:envelope(?placegeo) AS ?mbb) "+ - "WHERE { ?x lgdo:bufferExtent ?ext . "+ - "?place "+ - " rdfs:label ?placename ; "+ - " geo:geometry ?placegeo ; "+ - " a ?type. "+ - "FILTER(2*strdf:distance(?placegeo,?placegeo) < 8) "+ - "}"; - - //Metrics with only one var must not be optimized - protected String queryMetricsAreaMustNotBeOptimized = - prefixes+ - "SELECT ?place ?placegeo ( 33*strdf:area(?placegeo) + 114 AS ?area) ( strdf:envelope(?placegeo) AS ?mbb) "+ - "WHERE { ?x lgdo:bufferExtent ?ext . "+ - "?place "+ - " rdfs:label ?placename ; "+ - " geo:geometry ?placegeo ; "+ - " a ?type. "+ - "FILTER(2*strdf:area(?placegeo) < 8) "+ - "}"; - - protected String queryMetricsMathInSelect = - prefixes+ - "SELECT ?place ?placegeo ( 33*strdf:area(?placegeo) + 114 AS ?area) ( strdf:envelope(?placegeo) AS ?mbb) "+ - "WHERE { ?x lgdo:bufferExtent ?ext . "+ - "?place "+ - " rdfs:label ?placename ; "+ - " geo:geometry ?placegeo ; "+ - " a ?type. "+ - "FILTER(2*strdf:distance(?placegeo,?placegeo) + strdf:area(?placegeo) - 3 + ?ext " + - "< ?ext + 8 - strdf:distance(?placegeo,?placegeo)) "+ - "}"; - - protected String querySpatialPropertiesMonetDB = - prefixes+ - "SELECT ?place ?placegeo (strdf:dimension(?placegeo) + 2 AS ?dim) (strdf:srid(?placegeo) AS ?srid) "+ - "WHERE { "+ - "?place "+ - " rdfs:label ?placename ; "+ - " geo:geometry ?placegeo ; "+ - " a ?type. "+ - "FILTER(strdf:mbbIntersects(strdf:union(?placegeo,?placegeo),?placegeo) && strdf:isSimple(?placegeo) "+ -// "&& strdf:dimension(?placegeo) - 1 < 3" + - ") "+ - "}"; - - protected String querySpatialPropertiesPostGIS = - prefixes+ - "SELECT ?place ?placegeo (strdf:dimension(?placegeo) + 2 AS ?dim) (strdf:srid(?placegeo) AS ?srid) "+ - "WHERE { "+ - "?place "+ - " rdfs:label ?placename ; "+ - " geo:geometry ?placegeo ; "+ - " a ?type. "+ - "FILTER(strdf:mbbIntersects(strdf:union(?placegeo,?placegeo),?placegeo) && strdf:isSimple(?placegeo) "+ - "&& strdf:dimension(?placegeo) - 1 < 3) "+ - "}"; - - protected String querySpatialPropertiesConstMonetDB = - prefixes+ - "SELECT ?place ?placegeo (strdf:srid(?placegeo) AS ?srid) (strdf:dimension(?placegeo) + 2 AS ?dim) "+ - "WHERE { "+ - "?place "+ - " rdfs:label ?placename ; "+ - " geo:geometry ?placegeo ; "+ - " a ?type. "+ - "FILTER(strdf:mbbIntersects(strdf:union(?placegeo,?placegeo),?placegeo) && strdf:isSimple(?placegeo) "+ -// "&& strdf:dimension(\"POINT(0 0)\") - 1 < 3" + - ") "+ - "}"; - - protected String querySpatialPropertiesConstPostGIS = - prefixes+ - "SELECT ?place ?placegeo (strdf:srid(?placegeo) AS ?srid) (strdf:dimension(?placegeo) + 2 AS ?dim) "+ - "WHERE { "+ - "?place "+ - " rdfs:label ?placename ; "+ - " geo:geometry ?placegeo ; "+ - " a ?type. "+ - "FILTER(strdf:mbbIntersects(strdf:union(?placegeo,?placegeo),?placegeo) && strdf:isSimple(?placegeo) "+ - "&& strdf:dimension(\"POINT(0 0)\") - 1 < 3) "+ - "}"; - - protected String queryRelate = - prefixes+ - "SELECT ?place ?placegeo "+ - "WHERE { "+ - "?place "+ - "rdfs:label ?placename ; "+ - "geo:geometry ?placegeo ; "+ - "a ?type. "+ - "FILTER(strdf:relate(?placegeo,?placegeo,\"0FFFFF212\")) "+ - "}"; - - // protected String queryThematicUnion = - // prefixes+ - // "SELECT ?place "+ - // "WHERE { "+ - // "?place "+ - // "rdfs:label ?placename ; "+ - // "geo:geometry ?placegeo. "+ - // "{?place a lgdo:Pier . } " + - // "UNION" + - // "{?place a lgdo:Harbour . } }"; - - - /** - * The following three queries test potential bugs noticed during the evaluation process for www2012. - * No issue seems to be present. - */ - protected String queryThematicUnion = - prefixes+ - "SELECT ?place2 ?placename "+ - " WHERE { "+ - " ?place2 rdfs:label ?placename. "+ - " ?place2 strdf:hasGeometry ?placegeo. " + - "{" + - " ?place2 a ." + - " } " + - "UNION" + - "{" + - " ?place2 a ." + - " } " + - " strdf:hasGeometry ?ar . " + - "FILTER(strdf:disjoint(?placegeo,?ar))" + - "}"; - - protected String query6_real = prefixes+ - "SELECT ?capital ?pierLabel "+ - "WHERE "+ - "{ "+ - "?country a . "+ - "?country ?capital_label . "+ - "?capital ?capital_label . "+ - "?capitalGeoNames ?capital . "+ - "?capitalGeoNames strdf:hasGeometry ?capitalGeo . "+ - "OPTIONAL "+ - "{ "+ - " ?pier a . " + - " ?pier rdfs:label ?pierLabel . "+ - " ?pier strdf:hasGeometry ?pierGeo . "+ - " FILTER(strdf:distance(?capitalGeo,?pierGeo) < 3.7) "+ - "} "+ - "} "; - - protected String query6_real_union = prefixes+ - "SELECT ?capital ?pierLabel "+ - "WHERE "+ - "{ "+ - "?country a . "+ - "?country ?capital_label . "+ - "?capital ?capital_label . "+ - "?capitalGeoNames ?capital . "+ - "?capitalGeoNames strdf:hasGeometry ?capitalGeo . "+ - "OPTIONAL "+ - "{ "+ - " { " + - "?pier a . " + - "}" + - " UNION" + - " { " + - "?pier a . " + - "}" + - " ?pier rdfs:label ?pierLabel . "+ - " ?pier strdf:hasGeometry ?pierGeo . "+ - " FILTER(strdf:distance(?capitalGeo,?pierGeo) < 3.7) "+ - "} "+ - "} "; - - protected String queryNegation = prefixes+ - "SELECT ?capital ?pier "+ - "WHERE "+ - "{ "+ - " ?country a . "+ - " ?country ?capital_label . "+ - " ?capital ?capital_label . "+ - " ?capitalGeoNames ?capital . "+ - " ?capitalGeoNames strdf:hasGeometry ?capitalGeo . "+ - "OPTIONAL "+ - "{ "+ - " ?pier a . " + - " ?pier rdfs:label ?pierLabel . "+ - " ?pier strdf:hasGeometry ?pierGeo . "+ - " FILTER(strdf:distance(?capitalGeo,?pierGeo) < 3.7) "+ - "} . " + - "FILTER (!bound(?pier))" + - "} "+ - ""; - - //Representative of functionality. If I remove !bound, 3 more results appear - protected String queryNegation2 = prefixes+ - "SELECT ?s ?pier "+ - "WHERE "+ - "{ "+ - " ?s strdf:hasGeometry ?geo1 . "+ - "OPTIONAL "+ - "{ "+ - " ?pier a . " + - " ?pier rdfs:label ?pierLabel . "+ - " ?pier strdf:hasGeometry ?pierGeo . "+ - " FILTER(strdf:distance(?geo1,?pierGeo) < 0.6) "+ - "} . " + - "FILTER (!bound(?pier))" + - "} "+ - ""; - - - protected String queryNotExists = - prefixes+ - "SELECT ?capital ?pierLabel "+ - "WHERE "+ - "{ "+ - "?country a . "+ - "?country ?capital_label . "+ - "?capital ?capital_label . "+ - "?capitalGeoNames ?capital . "+ - "?capitalGeoNames strdf:hasGeometry ?capitalGeo . "+ - " ?pier a . " + - " ?pier rdfs:label ?pierLabel . "+ - " ?pier strdf:hasGeometry ?pierGeo . "+ -// " FILTER NOT EXISTS { ?pier rdfs:label \"Kikirikou\". " + -// "FILTER(strdf:distance(?capitalGeo,?pierGeo) > 3.7) " + - " FILTER NOT EXISTS { ?pier rdfs:label ?label2. FILTER(?label2 != ?pierLabel)" + - "}"+ - "} "; - - //TODO At some point I should also add a test where the 3rd argument of strdf:relate is a variable - - @Test - public void testQuery1() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - strabon.query(query1,strabon.getSailRepoConnection()); - - } - - @Test - public void testQuery2() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - strabon.query(query2,strabon.getSailRepoConnection()); - - } - - @Test - public void testQuery3() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - strabon.query(query3,strabon.getSailRepoConnection()); - - } - - @Test - public void testQuery4() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - strabon.query(query4,strabon.getSailRepoConnection()); - - } - - @Test - public void testQuery5() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - strabon.query(query5,strabon.getSailRepoConnection()); - - } - - @Test - public void testQuery6() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - strabon.query(query6,strabon.getSailRepoConnection()); - - } - - @Test - public void testQuery7() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - strabon.query(query7,strabon.getSailRepoConnection()); - - } - - @Test - public void testQuery8() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - strabon.query(query8,strabon.getSailRepoConnection()); - - } - - @Test - public void testQueryBufferVar() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - strabon.query(queryBufferVar,strabon.getSailRepoConnection()); - - } - - @Test - public void testQueryBufferConst() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - strabon.query(queryBufferConst,strabon.getSailRepoConnection()); - - } - - @Test - public void testQueryBufferConst2() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - strabon.query(queryBufferConst2,strabon.getSailRepoConnection()); - - } - - @Test - public void testQueryBufferConstInSelect() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - strabon.query(queryBufferConstInSelect,strabon.getSailRepoConnection()); - - } - - @Test - public void testQueryBufferSelectFilterA() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - strabon.query(queryBufferSelectFilterA,strabon.getSailRepoConnection()); - - } - - @Test - public void testQueryBufferSelectFilterB() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - strabon.query(queryBufferSelectFilterB,strabon.getSailRepoConnection()); - - } - - @Test - public void testQueryEnvelopeConvexHull() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - strabon.query(queryBufferSelectFilterB,strabon.getSailRepoConnection()); - - } - - @Test - public void testQueryMetrics1() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - strabon.query(queryMetrics1,strabon.getSailRepoConnection()); - - } - - @Test - public void testQueryMetricsLightOptimized() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - strabon.query(queryMetricsLightOptimized,strabon.getSailRepoConnection()); - - } - - @Test - public void testQueryMetricsAreaMustNotBeOptimized() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - strabon.query(queryMetricsLightOptimized,strabon.getSailRepoConnection()); - - } - - @Test - public void testQueryMetricsMathInSelect() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - strabon.query(queryMetricsMathInSelect,strabon.getSailRepoConnection()); - - } - - @Test - // MonetDB has not function Dimension - abstract public void testQuerySpatialProperties() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException ; - - @Test - // MonetDB has not function Dimension - abstract public void testQuerySpatialPropertiesConst() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException ; - - @Test - public void testQueryRelate() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - strabon.query(queryRelate,strabon.getSailRepoConnection()); - - } - - @Test - public void testQueryThematicUnion() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - strabon.query(queryThematicUnion,strabon.getSailRepoConnection()); - - } - - @Test - public void testQuery6_real() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - strabon.query(query6_real,strabon.getSailRepoConnection()); - - } - - @Test - public void testQuery6_real_union() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - strabon.query(query6_real_union,strabon.getSailRepoConnection()); - - } - @Test - public void testQueryNegation() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - strabon.query(queryNegation,strabon.getSailRepoConnection()); - - } - @Test - public void testQueryNegation2() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - strabon.query(queryNegation2,strabon.getSailRepoConnection()); - - } - -// @Test -// public void testPrintDataset() throws MalformedQueryException -// { -// String query = "SELECT ?s ?p ?o WHERE { ?s ?p ?o }"; -// strabon.query(query,strabon.getSailRepoConnection()); -// -// } -} diff -r 38b0c0a12614 -r 6521e8989dc9 runtime/src/test/java/eu/earthobservatory/runtime/generaldb/HavingTests.java --- a/runtime/src/test/java/eu/earthobservatory/runtime/generaldb/HavingTests.java Thu May 14 11:24:32 2015 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,124 +0,0 @@ -/** - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * Copyright (C) 2010, 2011, 2012, Pyravlos Team - * - * http://www.strabon.di.uoa.gr/ - */ -package eu.earthobservatory.runtime.generaldb; - -import java.io.IOException; - -import org.junit.Test; -import org.openrdf.query.MalformedQueryException; -import org.openrdf.query.QueryEvaluationException; -import org.openrdf.query.TupleQueryResultHandlerException; - -public class HavingTests { - public static Strabon strabon; - - - protected static String jdbcDriver= "org.postgresql.Driver"; - protected static String serverName = "localhost"; - protected static String username = "postgres"; - protected static String password = "postgres"; - protected static Integer port = 5432; - protected static java.sql.Connection conn = null; - protected static String databaseName = null; - - // @BeforeClass - // public abstract static void initialize() throws SQLException, ClassNotFoundException - // { - // strabon = new Strabon("cco2","postgres","p1r3as", 5432, "localhost", true); - // } - - - - String prefixes = - " PREFIX noa:"+ - " PREFIX rdf:"+ - " PREFIX strdf: "; - - - - - String query1Having = prefixes + - "SELECT ?burntArea ?baGeo "+ - "WHERE { "+ - "?burntArea a noa:BurntArea; "+ - "strdf:hasGeometry ?baGeo. "+ - "?urbanArea a noa:UrbanArea; "+ - "strdf:hasGeometry ?uaGeo; "+ - "FILTER(strdf:mbbIntersects(?baGeo,?uaGeo)). "+ - "} "+ - "GROUP BY ?burntArea ?baGeo "+ - "HAVING (strdf:area(strdf:union(?uaGeo)) > 8) "; - - String query2HavingA = prefixes + - "SELECT ?burntArea ?baGeo (strdf:extent(?uaGeo) AS ?totalMBB) "+ - "WHERE { "+ - "?burntArea a noa:BurntArea; "+ - "strdf:hasGeometry ?baGeo. "+ - "?urbanArea a noa:UrbanArea; "+ - "strdf:hasGeometry ?uaGeo; "+ - "FILTER(strdf:mbbIntersects(?baGeo,?uaGeo)). "+ - "} "+ - "GROUP BY ?burntArea ?baGeo "+ - "HAVING (strdf:area(strdf:extent(?uaGeo)) > 8) "; - - String query2HavingB = prefixes + - "SELECT ?burntArea ?baGeo (strdf:difference(strdf:extent(?uaGeo),strdf:union(?uaGeo)) AS ?MBBdiff) "+ - "WHERE { "+ - "?burntArea a noa:BurntArea; "+ - "strdf:hasGeometry ?baGeo. "+ - "?urbanArea a noa:UrbanArea; "+ - "strdf:hasGeometry ?uaGeo; "+ - "FILTER(strdf:mbbIntersects(?baGeo,?uaGeo)). "+ - "} "+ - "GROUP BY ?burntArea ?baGeo "+ - "HAVING (strdf:area(strdf:extent(?uaGeo)) > 8) "; - - String query2HavingC = prefixes + - "SELECT ?burntArea (strdf:extent(?uaGeo) AS ?totalMBB) "+ - "WHERE { "+ - "?burntArea a noa:BurntArea; "+ - "strdf:hasGeometry ?baGeo. "+ - "?urbanArea a noa:UrbanArea; "+ - "strdf:hasGeometry ?uaGeo; "+ - "FILTER(strdf:mbbIntersects(?baGeo,?uaGeo)). "+ - "} "+ - "GROUP BY ?burntArea "+ - "HAVING (strdf:area(strdf:extent(?uaGeo)) < 8) "; - - @Test - public void testQuery1Having() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - strabon.query(query1Having,strabon.getSailRepoConnection()); - - } - - @Test - public void testQuery2HavingA() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - strabon.query(query2HavingA,strabon.getSailRepoConnection()); - - } - - @Test - public void testQuery2HavingB() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - strabon.query(query2HavingB,strabon.getSailRepoConnection()); - - } - - @Test - public void testQuery2HavingC() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - strabon.query(query2HavingC,strabon.getSailRepoConnection()); - - } - - -} diff -r 38b0c0a12614 -r 6521e8989dc9 runtime/src/test/java/eu/earthobservatory/runtime/generaldb/JoinTests.java --- a/runtime/src/test/java/eu/earthobservatory/runtime/generaldb/JoinTests.java Thu May 14 11:24:32 2015 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,207 +0,0 @@ -/** - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * Copyright (C) 2010, 2011, 2012, Pyravlos Team - * - * http://www.strabon.di.uoa.gr/ - */ -package eu.earthobservatory.runtime.generaldb; - -import java.io.IOException; - -import org.junit.Test; -import org.openrdf.query.MalformedQueryException; -import org.openrdf.query.QueryEvaluationException; -import org.openrdf.query.TupleQueryResultHandlerException; - -public class JoinTests { - - public static Strabon strabon; - - protected static String jdbcDriver= "org.postgresql.Driver"; - protected static String serverName = "localhost"; - protected static String username = "postgres"; - protected static String password = "postgres"; - protected static Integer port = 5432; - protected static java.sql.Connection conn = null; - protected static String databaseName = null; - - -// @BeforeClass -// public static void initialize() throws SQLException, ClassNotFoundException -// { -// strabon = new Strabon("join-tests","postgres","p1r3as", 5432, "localhost", true); -// -// } - - - - String query5a = - "PREFIX strdf: "+ - "SELECT ?sensor ?place WHERE "+ - "{"+ - "?place a . "+ - "?place ?placeGeo. "+ - "?areaOfInterest \"London\". "+ - "?areaOfInterest ?areaGeo . "+ - "?sensorsDeployment ?sensorSystem . "+ - "?sensorSystem ?sensor . "+ - "?sensorsDeployment ?sensorPlatform . "+ - "?sensorPlatform ?spaceRegion . "+ - "?spaceRegion ?sensorsGeo . "+ - "FILTER(strdf:mbbIntersects(?sensorsGeo,?areaGeo) && strdf:mbbIntersects(?sensorsGeo,?placeGeo)) . "+ - "}"; - - String query5b = - "PREFIX strdf: "+ - "SELECT ?sensor ?place WHERE "+ - "{ "+ - "?place a . "+ - "?place ?placeGeo. "+ - "?sensorSystem ?sensor . "+ - "?sensorsDeployment ?sensorSystem . "+ - "?sensorsDeployment ?sensorPlatform . "+ - "?sensorPlatform ?spaceRegion . "+ - "?spaceRegion ?sensorsGeo . "+ - "?areaOfInterest ?areaGeo . "+ - "?areaOfInterest \"London\". "+ - "FILTER(strdf:mbbIntersects(?sensorsGeo,?areaGeo)) . "+ - "FILTER(strdf:mbbIntersects(?sensorsGeo,?placeGeo)). }"; - - String query5c = - "PREFIX strdf: "+ - "SELECT ?sensor ?place WHERE "+ - "{ "+ - "?place a . "+ - "?place ?placeGeo. "+ - "?areaOfInterest \"London\". "+ - "?areaOfInterest ?areaGeo . "+ - "?sensorsDeployment ?sensorSystem . "+ - "?sensorSystem ?sensor . "+ - "?sensorsDeployment ?sensorPlatform . "+ - "?sensorPlatform ?spaceRegion . "+ - "?spaceRegion ?sensorsGeo . "+ - "FILTER(strdf:mbbIntersects(?sensorsGeo,?areaGeo)) . "+ - "FILTER(strdf:mbbIntersects(?sensorsGeo,?placeGeo)). }"; - - String query9a = - "PREFIX strdf: " + - "SELECT ?populatedArea ?sensor ?portArea " + - "WHERE " + - "{ " + - "?sensorSystem ?sensor . " + - " ?sensorsDeployment ?sensorSystem . " + - " ?sensorsDeployment ?sensorPlatform . " + - " ?sensorPlatform ?spaceRegion . " + - " ?spaceRegion ?sensorsGeo . " + - " ?portArea . " + - " ?portArea a . " + - " ?portArea ?seaGeo . " + - " ?populatedArea . " + - " ?populatedAreaGeoNames ?populatedArea . " + - " ?populatedAreaGeoNames ?areaGeo . " + - " FILTER( strdf:mbbIntersects(?areaGeo,?sensorsGeo) ) . " + - " FILTER( strdf:mbbIntersects(?seaGeo,?sensorsGeo) ) . " + - "}"; - - String query3way = - "PREFIX strdf: "+ - "SELECT ?sensor ?place WHERE "+ - "{ "+ - "?place a . "+ - "?place ?placeGeo. "+ - "?areaOfInterest \"London\". "+ - "?areaOfInterest ?areaGeo . "+ - "?sensorsDeployment ?sensorSystem . "+ - "?sensorSystem ?sensor . "+ - "?sensorsDeployment ?sensorPlatform . "+ - "?sensorPlatform ?spaceRegion . "+ - "?spaceRegion ?sensorsGeo . "+ - "FILTER(strdf:mbbIntersects(?sensorsGeo,strdf:union(?areaGeo,?placeGeo)) " + - "&& strdf:mbbIntersects(?sensorsGeo,?placeGeo) && ?place = ?spaceRegion) . "+ - "}"; - - String query5_3filters = - "PREFIX strdf: "+ - "SELECT ?sensor ?place WHERE "+ - "{ "+ - " ?place a . "+ - " ?place ?placeGeo. "+ - " ?sensorSystem ?sensor . "+ - " ?sensorsDeployment ?sensorSystem . "+ - " ?sensorsDeployment ?sensorPlatform . "+ - "?sensorPlatform ?spaceRegion . "+ - " ?spaceRegion ?sensorsGeo . "+ - "?areaOfInterest ?areaGeo . "+ - "?areaOfInterest \"London\". "+ - " FILTER(strdf:mbbIntersects(?sensorsGeo,?areaGeo)) . "+ - "FILTER(strdf:mbbIntersects(?sensorsGeo,?placeGeo)). "+ - " FILTER(strdf:mbbIntersects(?areaGeo,?placeGeo)).}"; - - String query5_properties = - "PREFIX strdf: "+ - "SELECT ?sensor ?place WHERE "+ - "{ "+ - " ?place a . "+ - " ?place ?placeGeo. "+ - " ?sensorSystem ?sensor . "+ - " ?sensorsDeployment ?sensorSystem . "+ - " ?sensorsDeployment ?sensorPlatform . "+ - "?sensorPlatform ?spaceRegion . "+ - " ?spaceRegion ?sensorsGeo . "+ - "?areaOfInterest ?areaGeo . "+ - "?areaOfInterest \"London\". "+ - " FILTER(strdf:mbbIntersects(?sensorsGeo,?areaGeo)) . "+ - "FILTER(strdf:dimension(?sensorsGeo) = strdf:dimension(?placeGeo)). }"; - - @Test - public void testQuery5a() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - strabon.query(query5a,strabon.getSailRepoConnection()); - - } - - @Test - public void testQuery5b() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - strabon.query(query5b,strabon.getSailRepoConnection()); - - } - - @Test - public void testQuery5c() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - strabon.query(query5c,strabon.getSailRepoConnection()); - - } - - @Test - public void testQuery9a() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - strabon.query(query9a,strabon.getSailRepoConnection()); - - } - - @Test - public void testQuery3way() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - strabon.query(query3way,strabon.getSailRepoConnection()); - - } - - @Test - public void testQuery5_3filters() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - strabon.query(query5_3filters,strabon.getSailRepoConnection()); - - } - - @Test - public void testQuery5_properties() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - strabon.query(query5_properties,strabon.getSailRepoConnection()); - - } -} diff -r 38b0c0a12614 -r 6521e8989dc9 runtime/src/test/java/eu/earthobservatory/runtime/generaldb/MeaningfulAggregateTests.java --- a/runtime/src/test/java/eu/earthobservatory/runtime/generaldb/MeaningfulAggregateTests.java Thu May 14 11:24:32 2015 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,193 +0,0 @@ -/** - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * Copyright (C) 2010, 2011, 2012, Pyravlos Team - * - * http://www.strabon.di.uoa.gr/ - */ -package eu.earthobservatory.runtime.generaldb; - -import java.io.IOException; - -import org.junit.Test; -import org.openrdf.query.MalformedQueryException; -import org.openrdf.query.QueryEvaluationException; -import org.openrdf.query.TupleQueryResultHandlerException; - -public class MeaningfulAggregateTests { - public static Strabon strabon; - - protected static String jdbcDriver= "org.postgresql.Driver"; - protected static String serverName = "localhost"; - protected static String username = "postgres"; - protected static String password = "postgres"; - protected static Integer port = 5432; - protected static java.sql.Connection conn = null; - protected static String databaseName = null; - - -// @BeforeClass -// public abstract static void initialize() throws SQLException, ClassNotFoundException -// { -// strabon = new Strabon("cco2","postgres","p1r3as", 5432, "localhost", true); -// } - - - - String prefixes = - " PREFIX noa:"+ - " PREFIX rdf:"+ - " PREFIX strdf: "; - - - /** - * May seem like this query has a spatial dimension, - * but since the spatial literal is not involved in any - * spatial operations, it is evaluated as a plain literal - */ - String query1NotSpatial = prefixes + - "SELECT ( COUNT(?hotspot) AS ?count) ?geo "+ - "WHERE " + - "{ " + - " ?hotspot a noa:Hotspot;" + - " strdf:hasGeometry ?geo. " + - "}"+ - "GROUP BY ?geo"; - - /** - * Current results: 6 - 4 - 2 - */ - String query1Spatial = prefixes + - "SELECT ( COUNT(?hotspot) AS ?count) ?geo "+ - "WHERE " + - "{ " + - " ?hotspot a noa:Hotspot;" + - " strdf:hasGeometry ?geo. " + - " ?urbanArea a noa:UrbanArea; " + - " strdf:hasGeometry ?uaGeo."+ - " FILTER(strdf:disjoint(?geo,?uaGeo)) "+ - "}"+ - "GROUP BY ?geo"; - - - /** - * Functionality seems ok - */ - String query2simple = prefixes + - "SELECT ?burntArea ?baGeo " + - "(strdf:union(?uaGeo) AS ?urban) "+ - "WHERE { " + - " ?burntArea a noa:BurntArea; " + - " strdf:hasGeometry ?baGeo. " + - " ?urbanArea a noa:UrbanArea; " + - " strdf:hasGeometry ?uaGeo. " + - " FILTER(strdf:mbbIntersects(?baGeo,?uaGeo))" + - " } " + - " GROUP BY ?burntArea ?baGeo "+ - " "; - - String query2complexA = prefixes + - "SELECT ?burntArea " + -// "?baGeo " + - "(strdf:difference(?baGeo, strdf:union(?uaGeo)) AS ?urbanPiece) "+ - " WHERE { " + - " ?burntArea a noa:BurntArea; " + - " strdf:hasGeometry ?baGeo. " + - " ?urbanArea a noa:UrbanArea; " + - " strdf:hasGeometry ?uaGeo. " + - " FILTER(strdf:mbbIntersects(?baGeo,?uaGeo))" + - " } " + - " GROUP BY ?burntArea" + -// " ?baGeo "+ - " "; - - String query2complexB = prefixes + - "SELECT ?burntArea ?baGeo " + - "(strdf:difference(strdf:union(?uaGeo) , ?baGeo) AS ?urbanPiece) "+ - " WHERE { " + - " ?burntArea a noa:BurntArea; " + - " strdf:hasGeometry ?baGeo. " + - " ?urbanArea a noa:UrbanArea; " + - " strdf:hasGeometry ?uaGeo. " + - " FILTER(strdf:mbbIntersects(?baGeo,?uaGeo))" + - " } " + - " GROUP BY ?burntArea ?baGeo "+ - " "; - - String query2complexC = prefixes + - "SELECT ?burntArea ?baGeo " + - "(strdf:buffer(strdf:union(?uaGeo) , 5) AS ?urbanPiece) "+ - " WHERE { " + - " ?burntArea a noa:BurntArea; " + - " strdf:hasGeometry ?baGeo. " + - " ?urbanArea a noa:UrbanArea; " + - " strdf:hasGeometry ?uaGeo. " + - " FILTER(strdf:mbbIntersects(?baGeo,?uaGeo))" + - " } " + - " GROUP BY ?burntArea ?baGeo "+ - " "; - - String query2complexD = prefixes + - "SELECT " + - " ?burntArea " + -// " ?baGeo " + -// " (strdf:union(?uaGeo) AS ?urban) " + - " (COUNT(?uaGeo) AS ?urbanNo) "+ - "WHERE { " + - " ?burntArea a noa:BurntArea; " + - " strdf:hasGeometry ?baGeo. " + - " ?urbanArea a noa:UrbanArea; " + - " strdf:hasGeometry ?uaGeo. " + - " FILTER(strdf:mbbIntersects(?baGeo,?uaGeo))" + - " } " + - " GROUP BY ?burntArea ?baGeo "+ - " HAVING (COUNT(?uaGeo) > 1 )"+ - " " - ; - - @Test - public void testQuery1NotSpatial() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - strabon.query(query1NotSpatial,strabon.getSailRepoConnection()); - - } - @Test - public void testQuery1Spatial() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - strabon.query(query1Spatial,strabon.getSailRepoConnection()); - - } - @Test - public void testQuery2() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - strabon.query(query2simple,strabon.getSailRepoConnection()); - - } - @Test - public void testQuery2complexA() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - strabon.query(query2complexA,strabon.getSailRepoConnection()); - - } - @Test - public void testQuery2complexB() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - strabon.query(query2complexB,strabon.getSailRepoConnection()); - - } - @Test - public void testQuery2complexC() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - strabon.query(query2complexC,strabon.getSailRepoConnection()); - - } - @Test - public void testQuery2complexD() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - strabon.query(query2complexD,strabon.getSailRepoConnection()); - - } - -} diff -r 38b0c0a12614 -r 6521e8989dc9 runtime/src/test/java/eu/earthobservatory/runtime/generaldb/NOATests.java --- a/runtime/src/test/java/eu/earthobservatory/runtime/generaldb/NOATests.java Thu May 14 11:24:32 2015 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,167 +0,0 @@ -/** - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * Copyright (C) 2010, 2011, 2012, Pyravlos Team - * - * http://www.strabon.di.uoa.gr/ - */ -package eu.earthobservatory.runtime.generaldb; - -import java.io.IOException; - -import org.junit.Test; -import org.openrdf.query.MalformedQueryException; -import org.openrdf.query.QueryEvaluationException; -import org.openrdf.query.TupleQueryResultHandlerException; - -public class NOATests { - public static Strabon strabon; - - - protected static String jdbcDriver= "org.postgresql.Driver"; - protected static String serverName = "localhost"; - protected static String username = "postgres"; - protected static String password = "postgres"; - protected static Integer port = 5432; - protected static java.sql.Connection conn = null; - protected static String databaseName = null; - - - - String prefixes = - "PREFIX imAn: "+ - "PREFIX noa: "+ - "PREFIX rdf: "+ - "PREFIX eolo: "+ - "PREFIX strdf: "+ - "PREFIX base: "+ - "PREFIX ex: "+ - "PREFIX rdfs: "; - - String query1 = prefixes+ - "SELECT ?FILENAME { "+ - "?COLLECTION rdf:type imAn:NOA-UC . "+ - "?FILE noa:belongToCollection ?COLLECTION . "+ - "?FILE noa:hasFilename ?FILENAME .}"; - - String query2 = prefixes+ - "SELECT ?FILENAME { "+ - "?COLLECTION rdf:type imAn:NOA-UC . "+ - "?FILE noa:belongToCollection ?COLLECTION . "+ - "?FILE noa:hasFilename ?FILENAME . "+ - "?COLLECTION eolo:hasProcessingLevel eolo:L1 . "+ - "?COLLECTION eolo:hasResolution eolo:LowResolution .}"; - - String query3 = prefixes+ - "SELECT ?FILENAME "+ - "WHERE { ?FILE rdf:type noa:ShpFile . "+ - "?FILE noa:hasFilename ?FILENAME . "+ - "?FILE noa:hasAcquisitionTime ?SENSING_TIME . "+ - "FILTER( str(?SENSING_TIME) > \"2010-08-21T20:00:00\" ) . "+ - "FILTER( str(?SENSING_TIME) < \"2010-08-21T20:30:00\" ) . "+ - "?FILE noa:isDerivedFromSensor ?SENSOR . "+ - "FILTER( str(?SENSOR) = \"MSG1_RSS\" ) . }"; - - - protected String query4 = prefixes+ - "SELECT DISTINCT ?H1 ?HGEO1 ?CONFIRMATION1 ?SATTELITE1 ?HCONF1 ?PC1 "+ - "WHERE { "+ - "?H1 rdf:type noa:Hotspot . "+ - "?H1 noa:hasConfidence ?HCONF1 . "+ - "?H1 noa:hasGeometry ?HGEO1 . "+ - "?H1 noa:hasAcquisitionTime ?HAT1 . "+ - "?H1 noa:isDerivedFromSensor ?SENSOR1 . "+ - "?H1 noa:isDerivedFromSatellite ?SATTELITE1 . "+ - "?H1 noa:producedFromProcessingChain ?PC1 . "+ - "?H1 noa:hasConfirmation ?CONFIRMATION1 . "+ - "FILTER( \"2010-08-22T15:35:00\" < str(?HAT1) " + - "&& str(?HAT1) < \"2010-08-22T16:10:00\" && str(?SENSOR1) = \"MSG1_RSS\" && str(?PC1) = \"plain\" ) . "+ - "OPTIONAL { "+ - "?H2 rdf:type noa:Hotspot . "+ - "?H2 noa:hasGeometry ?HGEO2 . "+ - "?H2 noa:hasAcquisitionTime ?HAT2 . "+ - "?H2 noa:isDerivedFromSensor ?SENSOR2 . "+ - "?H2 noa:producedFromProcessingChain ?PC2 . "+ - "FILTER( strdf:equals(?HGEO1 , ?HGEO2) ) . "+ - "FILTER( str(?HAT2) = \"2010-08-22T16:10:00\" && str(?SENSOR2) = \"MSG1_RSS\" " + - "&& str(?PC2) = \"plain\" ) . "+ - "} . "+ - "FILTER (!bound(?H2)) .} "; - - String query5 = prefixes+ - "SELECT DISTINCT ?H "+ - "WHERE { "+ - "?H rdf:type noa:Hotspot . "+ - "?H noa:hasGeometry ?HGEO . "+ - "?H noa:isDerivedFromSensor ?HS . "+ - "FILTER( str(?HS) = \"MSG2\" ) . "+ - "?H noa:hasAcquisitionTime ?HAT . "+ - "FILTER(str(?HAT) = \"2007-08-24T12:45:00\") . "+ - "OPTIONAL { "+ - "?C rdf:type noa:Coastline . "+ - "?C noa:hasGeometry ?CGEO . "+ - "filter ( strdf:mbbIntersects(?HGEO , ?CGEO) ) . "+ - "} FILTER( !bound(?C) ) "+ - "}"; - - protected String query6 = prefixes+ - "SELECT ?H (strdf:intersection(?HGEO, ?CGEO) AS ?REFINEDGEO) "+ - "WHERE { "+ - "?H rdf:type noa:Hotspot . "+ - "?H noa:hasGeometry ?HGEO . "+ - "?H noa:isDerivedFromSensor ?HS . "+ - "FILTER( str(?HS) = \"MSG2\" ) . "+ - "?H noa:hasAcquisitionTime ?HAT . "+ - "FILTER(str(?HAT) = \"2007-08-24T12:45:00\") . "+ - "?C rdf:type noa:Coastline . "+ - "?C noa:hasGeometry ?CGEO . "+ - "FILTER( strdf:overlap(?HGEO,?CGEO) ) . "+ - "} ORDER BY ?H "; - - protected String query7 = prefixes+ - //"SELECT ?H (strdf:intersection(?HGEO, ?CGEO) AS ?REFINEDGEO) "+ - "INSERT {?H noa:hasGeometry (strdf:intersection(?HGEO, ?CGEO) AS ?REFINEDGEO)} \n"+ - "WHERE { "+ - "?H rdf:type noa:Hotspot . "+ - "?H noa:hasGeometry ?HGEO . "+ - "?H noa:isDerivedFromSensor ?HS . "+ - "FILTER( str(?HS) = \"MSG2\" ) . "+ - "?H noa:hasAcquisitionTime ?HAT . "+ - "FILTER(str(?HAT) = \"2007-08-24T12:45:00\") . "+ - "?C rdf:type noa:Coastline . "+ - "?C noa:hasGeometry ?CGEO . "+ - "FILTER( strdf:overlap(?HGEO,?CGEO) ) . "+ - "} "; - - - @Test - public void testQuery1() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - strabon.query(query1,strabon.getSailRepoConnection()); - - } - - @Test - public void testQuery2() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - strabon.query(query2,strabon.getSailRepoConnection()); - - } - - @Test - public void testQuery3() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - strabon.query(query3,strabon.getSailRepoConnection()); - - } - - @Test - public void testQuery7() throws MalformedQueryException - { - strabon.update(query7,strabon.getSailRepoConnection()); - - } - -} diff -r 38b0c0a12614 -r 6521e8989dc9 runtime/src/test/java/eu/earthobservatory/runtime/generaldb/SPARQL11Tests.java --- a/runtime/src/test/java/eu/earthobservatory/runtime/generaldb/SPARQL11Tests.java Thu May 14 11:24:32 2015 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,356 +0,0 @@ -/** - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * Copyright (C) 2010, 2011, 2012, Pyravlos Team - * - * http://www.strabon.di.uoa.gr/ - */ -package eu.earthobservatory.runtime.generaldb; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.io.IOException; -import java.util.ArrayList; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.openrdf.model.vocabulary.RDF; -import org.openrdf.model.vocabulary.XMLSchema; -import org.openrdf.query.MalformedQueryException; -import org.openrdf.query.QueryEvaluationException; -import org.openrdf.query.TupleQueryResultHandlerException; -import org.openrdf.repository.RepositoryException; - -public class SPARQL11Tests { - public static Strabon strabon; - - public String FOAF_NS = "http://xmlns.com/foaf/0.1/", - DT_NS = "http://example.org/datatype#", - NS_NS = "http://example.org/ns#", - DEF_NS = "http://example.org#", - ORG_NS = "http://example.com/org#", - DC_NS = "http://purl.org/dc/elements/1.1/", - DC10_NS = "http://purl.org/dc/elements/1.0/", - DC11_NS = "http://purl.org/dc/elements/1.1/"; - - protected String prefixes = - "PREFIX rdf: <"+RDF.NAMESPACE+"> \n" + - "PREFIX xsd: <"+XMLSchema.NAMESPACE+"> \n" + - "PREFIX foaf: <"+FOAF_NS+"> \n" + - "PREFIX dt: <"+DT_NS+"> "+ - "PREFIX ns: <"+NS_NS+"> \n" + - "PREFIX def: <"+DEF_NS+"> \n" + - "PREFIX org: <"+ORG_NS+"> \n" + - "PREFIX dc: <"+DC_NS+"> \n" + - "PREFIX dc10: <"+DC10_NS+"> \n" + - "PREFIX dc11: <"+DC11_NS+"> \n"; - -// @BeforeClass -// public static void initialize() throws Exception -// { -// strabon = new eu.earthobservatory.runtime.postgis.Strabon("test", "postgres", "postgres", 5432, "localhost", true); -// -// } - - @Test - public void testRetrieveEveryEntry() throws MalformedQueryException, RepositoryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - String queryString = prefixes+ - "SELECT ?s ?p ?o \n" + - "WHERE \n" + - "{ ?s ?p ?o . } \n"; - - @SuppressWarnings("unchecked") - ArrayList results = (ArrayList )strabon.query(queryString, strabon.getSailRepoConnection()); - assertEquals(62, results.size()); - } - - @Test - public void testMultipleMatches() throws MalformedQueryException, RepositoryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - String queryString = prefixes+ - "SELECT DISTINCT ?name ?mbox \n" + - "WHERE \n" + - "{ ?x foaf:name ?name . \n" + - " ?x foaf:mbox ?mbox ." + - " } \n"; - - @SuppressWarnings("unchecked") - ArrayList results = (ArrayList ) strabon.query(queryString, strabon.getSailRepoConnection()); - assertEquals(11, results.size()); - } - - @Test - public void testMatchingLiterals() throws MalformedQueryException, RepositoryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - String queryString = prefixes+ - "SELECT ?v WHERE { ?v ns:p ?s . FILTER(str(?s) = \"cat\") } \n"; -// "SELECT ?v WHERE { ?v ns:p \"cat\" } \n"; - - @SuppressWarnings("unchecked") - ArrayList results = (ArrayList ) strabon.query(queryString, strabon.getSailRepoConnection()); - assertEquals(1, results.size()); - assertTrue(-1 results = (ArrayList ) strabon.query(queryString, strabon.getSailRepoConnection()); - assertEquals(1, results.size()); - assertTrue(-1 results = (ArrayList ) strabon.query(queryString, strabon.getSailRepoConnection()); - assertEquals(1, results.size()); - assertTrue(-1 results = (ArrayList ) strabon.query(queryString, strabon.getSailRepoConnection()); - assertEquals(1, results.size()); - assertTrue(-1 results = (ArrayList) strabon.query(queryString, strabon.getSailRepoConnection()); - assertEquals(1, results.size()); - assertTrue(-1 results = (ArrayList) strabon.query(queryString, strabon.getSailRepoConnection()); - assertEquals(1, results.size()); - assertTrue(-1 results = (ArrayList)strabon.query(queryString, strabon.getSailRepoConnection()); - assertEquals(13, results.size()); - assertTrue(-1 results = (ArrayList) strabon.query(queryString, strabon.getSailRepoConnection()); - assertEquals(4, results.size()); - assertTrue(-1]")); - } - - @Test - public void testTwoOptionals() throws MalformedQueryException, RepositoryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - String queryString = prefixes+ - "SELECT ?name ?mbox ?hpage \n"+ - "WHERE { ?x foaf:name ?name \n"+ - " OPTIONAL { ?x foaf:mbox ?mbox } . \n"+ - " OPTIONAL { ?x foaf:homepage ?hpage } . \n"+ - "} ORDER BY ?name \n"; - - @SuppressWarnings("unchecked") - ArrayList results = (ArrayList)strabon.query(queryString, strabon.getSailRepoConnection()); - - assertEquals(13, results.size()); - assertTrue(-1 results = (ArrayList) strabon.query(queryString, strabon.getSailRepoConnection()); - assertEquals(0, results.size()); // TODO add such an item - } - - @Test - public void testFilterExists() throws MalformedQueryException, RepositoryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - String queryString = prefixes+ - "SELECT ?person \n"+ - "WHERE { \n"+ - " ?person rdf:type foaf:Person . \n"+ - " FILTER EXISTS { ?person foaf:name ?name } \n"+ - "} \n"; - - @SuppressWarnings("unchecked") - ArrayList results = (ArrayList) strabon.query(queryString, strabon.getSailRepoConnection()); - assertEquals(2, results.size()); - assertTrue(-1 results = (ArrayList) strabon.query(queryString, strabon.getSailRepoConnection()); - assertEquals(19, results.size()); - } - - @Test - public void testQuerySumGroupByHaving() throws MalformedQueryException, RepositoryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - String queryString = prefixes+ - "SELECT (SUM(?lprice) AS ?totalPrice) \n"+ - "WHERE { \n"+ - " ?org def:affiliates ?auth . \n"+ - " ?auth def:writesBook ?book . \n"+ - " ?book def:price ?lprice . \n"+ - "} \n" - +"GROUP BY ?org HAVING (SUM(?lprice) > 10) \n" - ; - - @SuppressWarnings("unchecked") - ArrayList results = (ArrayList) strabon.query(queryString, strabon.getSailRepoConnection()); - assertEquals(1, results.size()); - assertTrue(-1]")); - } - - @Test - public void testRegex() throws MalformedQueryException, RepositoryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - String queryString = prefixes+ - "SELECT ?title \n"+ - "WHERE { ?x dc:title ?title \n"+ - " FILTER regex(?title, \"^SPARQL\") \n"+ - "} ORDER BY ?title\n"; - - @SuppressWarnings("unchecked") - ArrayList results = (ArrayList) strabon.query(queryString, strabon.getSailRepoConnection()); - assertEquals(3, results.size()); - assertTrue(-1 results = (ArrayList) strabon.query(queryString, strabon.getSailRepoConnection()); - assertEquals(1, results.size()); - assertTrue(-1 results = (ArrayList) strabon.query(queryString, strabon.getSailRepoConnection()); - assertEquals(6, results.size()); - assertTrue(-1 results = (ArrayList) strabon.query(queryString, strabon.getSailRepoConnection()); - assertEquals(6, results.size()); - assertTrue(-1 - */ -public class SimpleTests { - - protected static Strabon strabon; - - protected static java.sql.Connection conn = null; - protected static String databaseName = null; - - protected static String jdbcDriver = null; - protected static String serverName = null; - protected static String username = null; - protected static String password = null; - protected static Integer port = null; - - protected static final String - STRDF_NS = "http://strdf.di.uoa.gr/ontology#", - EX_NS = "http://example.org/", - NOA_NS = "http://teleios.di.uoa.gr/ontologies/noaOntology.owl#"; - - - protected static final String prefixes = - "PREFIX rdf: <"+RDF.NAMESPACE+"> \n" + - "PREFIX strdf: <"+STRDF_NS+"> \n" + - "PREFIX xsd: <"+XMLSchema.NAMESPACE+"> \n" + - "PREFIX ex: <"+EX_NS+"> \n" + - "PREFIX noa: <"+NOA_NS+"> \n"; - - @Test - public void testSimpleFilter() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException, QueryEvaluationException - { - - String query = - prefixes+ - "SELECT ?id "+ - "WHERE { "+ - "?s ex:id ?id . "+ - "?s ex:value ?value . "+ - "FILTER( ?id<2 ) . " + - "}"; - - @SuppressWarnings("unchecked") - ArrayList bindings = (ArrayList) strabon.query(query,strabon.getSailRepoConnection()); - - assertEquals(1, bindings.size()); - assertTrue(-1]")); - } - - @Test - public void testMatchLiteralWithWKTType() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException, QueryEvaluationException - { - String query = - prefixes+ - "SELECT ?s2 "+ - "WHERE { "+ - " ?s2 noa:hasGeometry \"POINT(1 0)\"^^strdf:WKT . "+ - "}"; - - @SuppressWarnings("unchecked") - ArrayList bindings = (ArrayList) strabon.query(query,strabon.getSailRepoConnection()); - - assertEquals(1, bindings.size()); - assertTrue(-120 || ?id<2 ) . " + - "}"; - - @SuppressWarnings("unchecked") - ArrayList bindings = (ArrayList) strabon.query(query,strabon.getSailRepoConnection()); - - assertEquals(1, bindings.size()); - assertTrue(-1;s=http://example.org/item1]")); - } - - @Test - public void testNotExistingPredicate() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException, QueryEvaluationException - { - - String query = - prefixes+ - "SELECT ?s ?o "+ - "WHERE { "+ - "?s ex:notExisting ?o . "+ - "}"; - - @SuppressWarnings("unchecked") - ArrayList bindings = (ArrayList) strabon.query(query,strabon.getSailRepoConnection()); - - assertEquals(0, bindings.size()); - } - -} diff -r 38b0c0a12614 -r 6521e8989dc9 runtime/src/test/java/eu/earthobservatory/runtime/generaldb/SpatialTests.java --- a/runtime/src/test/java/eu/earthobservatory/runtime/generaldb/SpatialTests.java Thu May 14 11:24:32 2015 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1242 +0,0 @@ -/** - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * Copyright (C) 2010, 2011, 2012, Pyravlos Team - * - * http://www.strabon.di.uoa.gr/ - */ -package eu.earthobservatory.runtime.generaldb; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.io.IOException; -import java.util.ArrayList; - -import org.junit.Test; -import org.openrdf.model.vocabulary.RDF; -import org.openrdf.model.vocabulary.XMLSchema; -import org.openrdf.query.MalformedQueryException; -import org.openrdf.query.QueryEvaluationException; -import org.openrdf.query.TupleQueryResultHandlerException; - -public class SpatialTests { - public static Strabon strabon; - - public String STRDF_NS = "http://strdf.di.uoa.gr/ontology#", - EX_NS = "http://example.org/", - NOA_NS = "http://teleios.di.uoa.gr/ontologies/noaOntology.owl#", - GEOF_NS ="http://www.opengis.net/def/function/geosparql/"; - - protected String prefixes = - "PREFIX rdf: <"+RDF.NAMESPACE+"> \n" + - "PREFIX strdf: <"+STRDF_NS+"> \n" + - "PREFIX xsd: <"+XMLSchema.NAMESPACE+"> \n" + - "PREFIX ex: <"+EX_NS+"> \n" + - "PREFIX noa: <"+NOA_NS+"> \n" + - "PREFIX geof: <"+GEOF_NS+"> \n"; - - // -- Spatial Relationships -- // - - @Test - public void testStrdfEquals() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - String query = - prefixes+ - "SELECT DISTINCT ?s1 ?s2 \n"+ - "WHERE { \n" + - " ?s1 ex:geometry ?g1 . \n"+ - " ?s2 ex:geometry ?g2 . \n" + - " FILTER( str(?s1) < str(?s2) ) . \n"+ - " FILTER( strdf:equals(?g1, ?g2 )) . \n"+ - "}"; - - @SuppressWarnings("unchecked") - ArrayList bindings = (ArrayList) strabon.query(query,strabon.getSailRepoConnection()); - assertEquals(1, bindings.size()); - assertTrue(-1 bindings = (ArrayList) strabon.query(query,strabon.getSailRepoConnection()); - assertEquals(60, bindings.size()); - // too many results - //assertTrue(-1 bindings = (ArrayList) strabon.query(query,strabon.getSailRepoConnection()); - assertEquals(5, bindings.size()); - assertTrue(-1;id1=\"B\"^^]")); - assertTrue(-1;id1=\"E\"^^]")); - assertTrue(-1;id1=\"F\"^^]")); - assertTrue(-1;id1=\"G\"^^]")); - assertTrue(-1;id1=\"L1\"^^]")); - } - - @Test - public void testStrdfTouches() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - String query = - prefixes+ - "SELECT DISTINCT ?id1 ?id2 \n"+ - "WHERE { \n" + - " ?s1 ex:id ?id1 . \n"+ - " ?s2 ex:id ?id2 . \n"+ - " FILTER( str(?id1) < str(?id2) ) . \n"+ - " ?s2 ex:geometry ?g2 . \n" + - " ?s1 ex:geometry ?g1 . \n"+ - " FILTER( strdf:touches(?g1, ?g2 )) . \n"+ - "}"; - - @SuppressWarnings("unchecked") - ArrayList bindings = (ArrayList) strabon.query(query,strabon.getSailRepoConnection()); - assertEquals(1, bindings.size()); - assertTrue(-1;id1=\"G\"^^]")); - } - - @Test - public void testStrdfCrosses() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - String query = - prefixes+ - "SELECT DISTINCT ?id1 ?id2 \n"+ - "WHERE { \n" + - " ?s1 ex:id ?id1 . \n"+ - " ?s2 ex:id ?id2 . \n"+ - " FILTER( str(?id1) != str(?id2) ) . \n"+ - " ?s2 ex:geometry ?g2 . \n" + - " ?s1 ex:geometry ?g1 . \n"+ - " FILTER( strdf:crosses(?g1, ?g2 )) . \n"+ - "}"; - - @SuppressWarnings("unchecked") - ArrayList bindings = (ArrayList) strabon.query(query,strabon.getSailRepoConnection()); - assertEquals(2, bindings.size()); - assertTrue(-1;id1=\"L2\"^^]")); - assertTrue(-1;id1=\"L1\"^^]")); - } - - @Test - public void testStrdfWithin() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - String query = - prefixes+ - "SELECT DISTINCT ?id1 ?id2 \n"+ - "WHERE { \n" + - " ?s1 ex:id ?id1 . \n"+ - " ?s2 ex:id ?id2 . \n"+ - " FILTER( str(?id1) != str(?id2) ) . \n"+ - " ?s2 ex:geometry ?g2 . \n" + - " ?s1 ex:geometry ?g1 . \n"+ - " FILTER( strdf:within(?g1, ?g2)) . \n"+ - "}"; - - @SuppressWarnings("unchecked") - ArrayList bindings = (ArrayList) strabon.query(query,strabon.getSailRepoConnection()); - assertEquals(2, bindings.size()); - assertTrue(-1;id1=\"E\"^^]")); - assertTrue(-1;id1=\"F\"^^]")); - } - - @Test - public void testStrdfContains() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - String query = - prefixes+ - "SELECT DISTINCT ?id1 ?id2 \n"+ - "WHERE { \n" + - " ?s1 ex:id ?id1 . \n"+ - " ?s2 ex:id ?id2 . \n"+ - " FILTER( str(?id1) != str(?id2) ) . \n"+ - " ?s2 ex:geometry ?g2 . \n" + - " ?s1 ex:geometry ?g1 . \n"+ - " FILTER( strdf:contains(?g1, ?g2 )) . \n"+ - "}"; - - @SuppressWarnings("unchecked") - ArrayList bindings = (ArrayList) strabon.query(query,strabon.getSailRepoConnection()); - assertEquals(2, bindings.size()); - assertTrue(-1;id1=\"Z\"^^]")); - assertTrue(-1;id1=\"Z\"^^]")); - } - - @Test - public void testStrdfOverlaps() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - String query = - prefixes+ - "SELECT DISTINCT ?id1 ?id2 \n"+ - "WHERE { \n" + - " ?s1 ex:id ?id1 . \n"+ - " ?s2 ex:id ?id2 . \n"+ - " FILTER( str(?id1) != str(?id2) ) . \n"+ - " ?s2 ex:geometry ?g2 . \n" + - " ?s1 ex:geometry ?g1 . \n"+ - " FILTER( strdf:overlaps(?g1, ?g2 )) . \n"+ - "}"; - - @SuppressWarnings("unchecked") - ArrayList bindings = (ArrayList) strabon.query(query,strabon.getSailRepoConnection()); - assertEquals(2, bindings.size()); - assertTrue(-1;id1=\"B\"^^]")); - assertTrue(-1;id1=\"Z\"^^]")); - } - - @Test - public void testStrdfmbbIntersects() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - String query = - prefixes+ - "SELECT DISTINCT ?id1 ?id2 \n"+ - "WHERE { \n" + - " ?s1 ex:id ?id1 . \n"+ - " ?s2 ex:id ?id2 . \n"+ - " FILTER( str(?id1) < str(?id2) ) . \n"+ - " ?s2 ex:geometry ?g2 . \n" + - " ?s1 ex:geometry ?g1 . \n"+ - " FILTER( strdf:mbbIntersects(?g1, ?g2 ) ) . \n"+ - "}"; - - @SuppressWarnings("unchecked") - ArrayList bindings = (ArrayList) strabon.query(query,strabon.getSailRepoConnection()); - - assertEquals(5, bindings.size()); - assertTrue(-1;id1=\"B\"^^]")); - assertTrue(-1;id1=\"E\"^^]")); - assertTrue(-1;id1=\"L1\"^^]")); - assertTrue(-1;id1=\"F\"^^]")); - assertTrue(-1;id1=\"G\"^^]")); - } - -// @Test -// public void testStrdfCovers() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException -// { -// String query = -// prefixes+ -// "SELECT DISTINCT ?id1 ?id2 \n"+ -// "WHERE { \n" + -// " ?s1 ex:id ?id1 . \n"+ -// " ?s2 ex:id ?id2 . \n"+ -// " FILTER( str(?id1) != str(?id2) ) . \n"+ -// " ?s2 ex:geometry ?g2 . \n" + -// " ?s1 ex:geometry ?g1 . \n"+ -// " FILTER( strdf:covers(?g1, ?g2 )) . \n"+ -// "}"; -// -// @SuppressWarnings("unchecked") -// ArrayList bindings = (ArrayList) strabon.query(query,strabon.getSailRepoConnection()); -// assertEquals(2, bindings.size()); -// assertTrue(-1;id1=\"Z\"^^]")); -// assertTrue(-1;id1=\"Z\"^^]")); -// } -// -// @Test -// public void testStrdfCoveredBy() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException -// { -// String query = -// prefixes+ -// "SELECT DISTINCT ?id1 ?id2 \n"+ -// "WHERE { \n" + -// " ?s1 ex:id ?id1 . \n"+ -// " ?s2 ex:id ?id2 . \n"+ -// " FILTER( str(?id1) != str(?id2) ) . \n"+ -// " ?s2 ex:geometry ?g2 . \n" + -// " ?s1 ex:geometry ?g1 . \n"+ -// " FILTER( strdf:coveredBy(?g1, ?g2 )) . \n"+ -// "}"; -// -// @SuppressWarnings("unchecked") -// ArrayList bindings = (ArrayList) strabon.query(query,strabon.getSailRepoConnection()); -// assertEquals(2, bindings.size()); -// assertTrue(-1;id1=\"F\"^^]")); -// assertTrue(-1;id1=\"E\"^^]")); -// } - - @Test - public void testStrdfRelate() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - String query = - prefixes+ - "SELECT DISTINCT ?id1 ?id2 \n"+ - "WHERE { \n" + - " ?s1 ex:id ?id1 . \n"+ - " ?s2 ex:id ?id2 . \n"+ - " FILTER( str(?id1) != str(?id2) ) . \n"+ - " ?s2 ex:geometry ?g2 . \n" + - " ?s1 ex:geometry ?g1 . \n"+ - " FILTER( strdf:relate(?g1, ?g2, \"T*F**F***\" )) . \n"+ - "}"; - - @SuppressWarnings("unchecked") - ArrayList bindings = (ArrayList) strabon.query(query,strabon.getSailRepoConnection()); - assertEquals(2, bindings.size()); - assertTrue(-1;id1=\"E\"^^]")); - assertTrue(-1;id1=\"F\"^^]")); - } - -// TODO these tests run only in postgis -// @Test -// public void testStrdfLeft() throws MalformedQueryException, QueryEvaluationException -// @Test -// public void testStrdfRight() throws MalformedQueryException, QueryEvaluationException -// @Test -// public void testStrdfAbove() throws MalformedQueryException, QueryEvaluationException -// @Test -// public void testStrdfBelow() throws MalformedQueryException, QueryEvaluationException - - // -- Spatial Constructs -- // - @Test - public void testStrdfUnion() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - String query = - prefixes+ - "SELECT DISTINCT ( strdf:union(?g, \"POLYGON((5 3, 10 3, 10 8, 5 8, 5 3))\"^^strdf:WKT) AS ?ret ) \n"+ - "WHERE { \n" + - " ?s ex:id ?id . \n"+ - " ?s ex:geometry ?g . \n" + - " FILTER( str(?id) = \"Z\"^^xsd:string ) . \n" + - "}"; - - @SuppressWarnings("unchecked") - ArrayList bindings = (ArrayList) strabon.query(query,strabon.getSailRepoConnection()); - - assertEquals(1, bindings.size()); - assertTrue(-1]")); - } - - @Test - public void testStrdfEnvelopeBuffer() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - String query = - prefixes+ - "SELECT DISTINCT ( strdf:envelope(strdf:buffer(?g, \"0.5\"^^xsd:float)) AS ?ret ) \n"+ -// "SELECT DISTINCT ?g (strdf:buffer(?g, \"0.5\"^^xsd:float) as ?buf) ( strdf:envelope(strdf:buffer(?g, \"0.5\"^^xsd:float)) AS ?ret ) \n"+ - "WHERE { \n" + - " ?s ex:id ?id . \n"+ - " ?s ex:geometry ?g . \n" + - " FILTER( str(?id) = \"C\"^^xsd:string ) . \n" + - "}"; - - @SuppressWarnings("unchecked") - ArrayList bindings = (ArrayList) strabon.query(query,strabon.getSailRepoConnection()); - - assertEquals(1, bindings.size()); - - if ( -1]") || - -1]") - ) - assertTrue(true); - else - fail(); - } - - @Test - public void testStrdfConvexHull() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - String query = - prefixes+ - "SELECT DISTINCT ( strdf:convexHull(\"GEOMETRYCOLLECTION( MULTILINESTRING((100 190,10 8),(150 10, 20 30)), MULTIPOINT(50 5, 150 30, 50 10, 10 10) )\"^^strdf:WKT) AS ?ret ) \n"+ - "WHERE { \n" + - " ?s ex:id ?id . \n"+ - " ?s ex:geometry ?g . \n" + - " FILTER( str(?id) = \"C\"^^xsd:string ) . \n" + - "}"; - - @SuppressWarnings("unchecked") - ArrayList bindings = (ArrayList) strabon.query(query,strabon.getSailRepoConnection()); - - assertEquals(1, bindings.size()); - assertTrue(-1]")); - } - - @Test - public void testStrdfBoundary() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - String query = - prefixes+ - "SELECT DISTINCT ( strdf:boundary(?g) AS ?ret ) \n"+ - "WHERE { \n" + - " ?s ex:id ?id . \n"+ - " ?s ex:geometry ?g . \n" + - " FILTER( str(?id) = \"C\"^^xsd:string ) . \n" + - "}"; - - @SuppressWarnings("unchecked") - ArrayList bindings = (ArrayList) strabon.query(query,strabon.getSailRepoConnection()); - - assertEquals(1, bindings.size()); - assertTrue(-1]")); } - - @Test - public void testStrdfIntersection() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - String query = - prefixes+ - "SELECT DISTINCT ( strdf:intersection(?g, \"POLYGON((5 3, 10 3, 10 8, 5 8, 5 3));http://www.opengis.net/def/crs/EPSG/0/4326\"^^strdf:WKT) AS ?ret ) \n"+ - "WHERE { \n" + - " ?s ex:id ?id . \n"+ - " ?s ex:geometry ?g . \n" + - " FILTER( str(?id) = \"Z\"^^xsd:string ) . \n" + - "}"; - - @SuppressWarnings("unchecked") - ArrayList bindings = (ArrayList) strabon.query(query,strabon.getSailRepoConnection()); - - assertEquals(1, bindings.size()); - assertTrue(-1]")); - } - - @Test - public void testStrdfDifference() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - String query = - prefixes+ - "SELECT DISTINCT ( strdf:difference(?g, \"POLYGON((5 3, 10 3, 10 8, 5 8, 5 3))\"^^strdf:WKT) AS ?ret ) \n"+ - "WHERE { \n" + - " ?s ex:id ?id . \n"+ - " ?s ex:geometry ?g . \n" + - " FILTER( str(?id) = \"Z\"^^xsd:string ) . \n" + - "}"; - - @SuppressWarnings("unchecked") - ArrayList bindings = (ArrayList) strabon.query(query,strabon.getSailRepoConnection()); - - assertEquals(1, bindings.size()); - assertTrue(-1]")); - } - - @Test - public void testStrdfSymDifference() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - String query = - prefixes+ - "SELECT DISTINCT ( strdf:symDifference(?g, \"POLYGON((5 3, 12 3, 12 8, 5 8, 5 3));http://www.opengis.net/def/crs/EPSG/0/4326\"^^strdf:WKT) AS ?ret ) \n"+ - "WHERE { \n" + - " ?s ex:id ?id . \n"+ - " ?s ex:geometry ?g . \n" + - " FILTER( str(?id) = \"Z\"^^xsd:string ) . \n" + - "}"; - - @SuppressWarnings("unchecked") - ArrayList bindings = (ArrayList) strabon.query(query,strabon.getSailRepoConnection()); - - assertEquals(1, bindings.size()); - assertTrue(-1]")); - } - -// // -- Spatial Metric Functions -- // - - @Test - public void testStrdfDistance() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - String query = - prefixes+ - "SELECT DISTINCT ( strdf:distance(?g, \"POINT( 10 1 )\"^^strdf:WKT) AS ?ret ) \n"+ - "WHERE { \n" + - " ?s ex:id ?id . \n"+ - " ?s ex:geometry ?g . \n" + - " FILTER( str(?id) = \"C\"^^xsd:string ) . \n" + - "}"; - - @SuppressWarnings("unchecked") - ArrayList bindings = (ArrayList) strabon.query(query,strabon.getSailRepoConnection()); - - assertEquals(1, bindings.size()); - assertTrue(-1]")); - } - - @Test - public void testStrdfArea() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - String query = - prefixes+ - "SELECT DISTINCT ( strdf:area(?g) AS ?ret ) \n"+ - "WHERE { \n" + - " ?s ex:id ?id . \n"+ - " ?s ex:geometry ?g . \n" + - " FILTER( str(?id) = \"C\"^^xsd:string ) . \n" + - "}"; - - @SuppressWarnings("unchecked") - ArrayList bindings = (ArrayList) strabon.query(query,strabon.getSailRepoConnection()); - - assertEquals(1, bindings.size()); - assertTrue(-1]")); - } - - @Test - public void testStrdfDimension() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - String query = - prefixes+ - "SELECT DISTINCT (strdf:dimension(?g) AS ?ret2) " + - "(strdf:dimension(strdf:boundary(?g)) AS ?ret1) " + - "(strdf:dimension(\"POINT(0 0)\"^^strdf:WKT) AS ?ret0) \n"+ - "WHERE { \n" + - " ?s ex:id ?id . \n"+ - " ?s ex:geometry ?g . \n" + - " FILTER( str(?id) = \"C\"^^xsd:string ) . \n" + - "}"; - - @SuppressWarnings("unchecked") - ArrayList bindings = (ArrayList) strabon.query(query,strabon.getSailRepoConnection()); - - assertEquals(1, bindings.size()); - // TODO monetdb returns as dimension only 3 (because of GEOS lib) - if ( -1;ret1=\"1\"^^;ret0=\"0\"^^]") || - -1;ret1=\"3\"^^;ret0=\"3\"^^]") ) - assertTrue(true); - else - fail(); - - } - - @Test - public void testStrdfGeometryType() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - String query = - prefixes+ - "SELECT DISTINCT (strdf:geometryType(?g) AS ?ret2) " + - "(strdf:geometryType(strdf:boundary(?g)) AS ?ret1) " + - "(strdf:geometryType(\"POINT(0 0)\"^^strdf:WKT) AS ?ret0) \n"+ - "WHERE { \n" + - " ?s ex:id ?id . \n"+ - " ?s ex:geometry ?g . \n" + - " FILTER( str(?id) = \"C\"^^xsd:string ) . \n" + - "}"; - - @SuppressWarnings("unchecked") - ArrayList bindings = (ArrayList) strabon.query(query,strabon.getSailRepoConnection()); - - assertEquals(1, bindings.size()); - // TODO different results between dbms in strdf:geometryType - if ( -1 bindings = (ArrayList) strabon.query(query,strabon.getSailRepoConnection()); - - assertEquals(1, bindings.size()); - if ( -1 bindings = (ArrayList) strabon.query(query,strabon.getSailRepoConnection()); - // TODO test srid uri arguments - assertEquals(1, bindings.size()); - if ( -1;ret1=\"4326\"^^;ret0=\"4326\"^^]") || - -1;ret1=\"0\"^^;ret0=\"0\"^^]") - ) - assertTrue(true); - else - fail(); - } - - @Test - public void testStrdfIsEmpty() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - String query = - prefixes+ - "SELECT DISTINCT (strdf:isEmpty(?g) AS ?ret2) " + - "(strdf:isEmpty(strdf:boundary(?g)) AS ?ret1) " + - "(strdf:isEmpty(\"POINT(0 0)\"^^strdf:WKT) AS ?ret0) \n"+ - "WHERE { \n" + - " ?s ex:id ?id . \n"+ - " ?s ex:geometry ?g . \n" + - " FILTER( str(?id) = \"C\"^^xsd:string ) . \n" + - "}"; - - @SuppressWarnings("unchecked") - ArrayList bindings = (ArrayList) strabon.query(query,strabon.getSailRepoConnection()); - - assertEquals(1, bindings.size()); - assertTrue(-1;ret1=\"false\"^^;ret0=\"false\"^^]")); - } - - @Test - public void testStrdfIsSimple() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - String query = - prefixes+ - "SELECT DISTINCT (strdf:isSimple(?g) AS ?ret2) " + - "(strdf:isSimple(strdf:boundary(?g)) AS ?ret1) " + - "(strdf:isSimple(\"POINT(0 0)\"^^strdf:WKT) AS ?ret0) \n"+ - "WHERE { \n" + - " ?s ex:id ?id . \n"+ - " ?s ex:geometry ?g . \n" + - " FILTER( str(?id) = \"C\"^^xsd:string ) . \n" + - "}"; - - @SuppressWarnings("unchecked") - ArrayList bindings = (ArrayList) strabon.query(query,strabon.getSailRepoConnection()); - - assertEquals(1, bindings.size()); - assertTrue(-1;ret1=\"true\"^^;ret0=\"true\"^^]")); - } - - // -- GEOSPARQL -- // - - // -- Non-topological -- // - - @Test - public void testGeofConvexHull() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - String query = - prefixes+ - "SELECT DISTINCT ( geof:convexHull(\"GEOMETRYCOLLECTION( MULTILINESTRING((100 190,10 8),(150 10, 20 30)), MULTIPOINT(50 5, 150 30, 50 10, 10 10) )\"^^strdf:WKT) AS ?ret ) \n"+ - "WHERE { \n" + - " ?s ex:id ?id . \n"+ - " ?s ex:geometry ?g . \n" + - " FILTER( str(?id) = \"C\"^^xsd:string ) . \n" + - "}"; - - @SuppressWarnings("unchecked") - ArrayList bindings = (ArrayList) strabon.query(query,strabon.getSailRepoConnection()); - - assertEquals(1, bindings.size()); - assertTrue(-1]")); - } - - @Test - public void testGeofIntersection() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - String query = - prefixes+ - "SELECT DISTINCT ( geof:intersection(?g, \"POLYGON((5 3, 10 3, 10 8, 5 8, 5 3))\"^^strdf:WKT) AS ?ret ) \n"+ - "WHERE { \n" + - " ?s ex:id ?id . \n"+ - " ?s ex:geometry ?g . \n" + - " FILTER( str(?id) = \"Z\"^^xsd:string ) . \n" + - "}"; - - @SuppressWarnings("unchecked") - ArrayList bindings = (ArrayList) strabon.query(query,strabon.getSailRepoConnection()); - - assertEquals(1, bindings.size()); - assertTrue(-1]")); - } - - @Test - public void testGeofDifference() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - String query = - prefixes+ - "SELECT DISTINCT ( geof:difference(?g, \"POLYGON((5 3, 10 3, 10 8, 5 8, 5 3))\"^^strdf:WKT) AS ?ret ) \n"+ - "WHERE { \n" + - " ?s ex:id ?id . \n"+ - " ?s ex:geometry ?g . \n" + - " FILTER( str(?id) = \"Z\"^^xsd:string ) . \n" + - "}"; - - @SuppressWarnings("unchecked") - ArrayList bindings = (ArrayList) strabon.query(query,strabon.getSailRepoConnection()); - - assertEquals(1, bindings.size()); - assertTrue(-1]")); - } - - @Test - public void testGeofSymDifference() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - String query = - prefixes+ - "SELECT DISTINCT ( geof:symmetricDifference(?g, \"POLYGON((5 3, 12 3, 12 8, 5 8, 5 3))\"^^strdf:WKT) AS ?ret ) \n"+ - "WHERE { \n" + - " ?s ex:id ?id . \n"+ - " ?s ex:geometry ?g . \n" + - " FILTER( str(?id) = \"Z\"^^xsd:string ) . \n" + - "}"; - - @SuppressWarnings("unchecked") - ArrayList bindings = (ArrayList) strabon.query(query,strabon.getSailRepoConnection()); - - assertEquals(1, bindings.size()); - assertTrue(-1]")); - } - - @Test - public void testGeofEnvelope() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - String query = - prefixes+ - "SELECT DISTINCT ( strdf:envelope(strdf:buffer(?g, \"0.5\"^^xsd:float)) AS ?ret ) \n"+ - "WHERE { \n" + - " ?s ex:id ?id . \n"+ - " ?s ex:geometry ?g . \n" + - " FILTER( str(?id) = \"C\"^^xsd:string ) . \n" + - "}"; - - @SuppressWarnings("unchecked") - ArrayList bindings = (ArrayList) strabon.query(query,strabon.getSailRepoConnection()); - - assertEquals(1, bindings.size()); - - if ( -1]") || - -1]") - ) - assertTrue(true); - else - fail(); - } - -// @Test -// public void testGeofEnvelopeBuffer() throws MalformedQueryException, QueryEvaluationException -// { // TODO 3 arguments -// String query = -// prefixes+ -// "SELECT DISTINCT ( geof:envelope(geof:buffer(?g, \"1.0\"^^xsd:float)) AS ?ret ) \n"+ -// "WHERE { \n" + -// " ?s noa:hasGeometry ?g . \n"+ -// " ?s ex:id ?id . \n"+ -// "}"; -// -// ArrayList bindings = strabon.query(query,strabon.getSailRepoConnection()); -// -// assertTrue(-1]")); -// assertTrue(-1]")); -// assertTrue(-1]")); -// } - - //Simple Features - 8 functions - all with 2 arguments + boolean - - @Test - public void testGeofSfEquals() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - String query = - prefixes+ - "SELECT DISTINCT ?s1 ?s2 \n"+ - "WHERE { \n" + - " ?s1 ex:geometry ?g1 . \n"+ - " ?s2 ex:geometry ?g2 . \n" + - " FILTER( str(?s1) < str(?s2) ) . \n"+ - " FILTER( geof:sfEquals(?g1, ?g2 )) . \n"+ - "}"; - - @SuppressWarnings("unchecked") - ArrayList bindings = (ArrayList) strabon.query(query,strabon.getSailRepoConnection()); - assertEquals(1, bindings.size()); - assertTrue(-1 bindings = (ArrayList) strabon.query(query,strabon.getSailRepoConnection()); - assertEquals(60, bindings.size()); - // too many results :) -// assertTrue(-1 bindings = (ArrayList) strabon.query(query,strabon.getSailRepoConnection()); - assertEquals(5, bindings.size()); - assertTrue(-1;id1=\"B\"^^]")); - assertTrue(-1;id1=\"E\"^^]")); - assertTrue(-1;id1=\"F\"^^]")); - assertTrue(-1;id1=\"G\"^^]")); - assertTrue(-1;id1=\"L1\"^^]")); - } - - @Test - public void testGeofSfTouches() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - String query = - prefixes+ - "SELECT DISTINCT ?id1 ?id2 \n"+ - "WHERE { \n" + - " ?s1 ex:id ?id1 . \n"+ - " ?s2 ex:id ?id2 . \n"+ - " FILTER( str(?id1) < str(?id2) ) . \n"+ - " ?s2 ex:geometry ?g2 . \n" + - " ?s1 ex:geometry ?g1 . \n"+ - " FILTER( geof:sfTouches(?g1, ?g2 )) . \n"+ - "}"; - - @SuppressWarnings("unchecked") - ArrayList bindings = (ArrayList) strabon.query(query,strabon.getSailRepoConnection()); - assertEquals(1, bindings.size()); - assertTrue(-1;id1=\"G\"^^]")); - } - - @Test - public void testGeofSfCrosses() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - String query = - prefixes+ - "SELECT DISTINCT ?id1 ?id2 \n"+ - "WHERE { \n" + - " ?s1 ex:id ?id1 . \n"+ - " ?s2 ex:id ?id2 . \n"+ - " FILTER( str(?id1) != str(?id2) ) . \n"+ - " ?s2 ex:geometry ?g2 . \n" + - " ?s1 ex:geometry ?g1 . \n"+ - " FILTER( geof:sfCrosses(?g1, ?g2 )) . \n"+ - "}"; - - @SuppressWarnings("unchecked") - ArrayList bindings = (ArrayList) strabon.query(query,strabon.getSailRepoConnection()); - assertEquals(2, bindings.size()); - assertTrue(-1;id1=\"L2\"^^]")); - assertTrue(-1;id1=\"L1\"^^]")); - } - - @Test - public void testGeofSfWithin() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - String query = - prefixes+ - "SELECT DISTINCT ?id1 ?id2 \n"+ - "WHERE { \n" + - " ?s1 ex:id ?id1 . \n"+ - " ?s2 ex:id ?id2 . \n"+ - " FILTER( str(?id1) != str(?id2) ) . \n"+ - " ?s2 ex:geometry ?g2 . \n" + - " ?s1 ex:geometry ?g1 . \n"+ - " FILTER( geof:sfWithin(?g1, ?g2 )) . \n"+ - "}"; - - @SuppressWarnings("unchecked") - ArrayList bindings = (ArrayList) strabon.query(query,strabon.getSailRepoConnection()); - assertEquals(2, bindings.size()); - assertTrue(-1;id1=\"F\"^^]")); - assertTrue(-1;id1=\"E\"^^]")); - } - - @Test - public void testGeofSfContains() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - String query = - prefixes+ - "SELECT DISTINCT ?id1 ?id2 \n"+ - "WHERE { \n" + - " ?s1 ex:id ?id1 . \n"+ - " ?s2 ex:id ?id2 . \n"+ - " FILTER( str(?id1) != str(?id2) ) . \n"+ - " ?s2 ex:geometry ?g2 . \n" + - " ?s1 ex:geometry ?g1 . \n"+ - " FILTER( geof:sfContains(?g1, ?g2 )) . \n"+ - "}"; - - @SuppressWarnings("unchecked") - ArrayList bindings = (ArrayList) strabon.query(query,strabon.getSailRepoConnection()); - assertEquals(2, bindings.size()); - assertTrue(-1;id1=\"Z\"^^]")); - assertTrue(-1;id1=\"Z\"^^]")); - } - - @Test - public void testGeofSfOverlaps() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - String query = - prefixes+ - "SELECT DISTINCT ?id1 ?id2 \n"+ - "WHERE { \n" + - " ?s1 ex:id ?id1 . \n"+ - " ?s2 ex:id ?id2 . \n"+ - " FILTER( str(?id1) != str(?id2) ) . \n"+ - " ?s2 ex:geometry ?g2 . \n" + - " ?s1 ex:geometry ?g1 . \n"+ - " FILTER( geof:sfOverlaps(?g1, ?g2 )) . \n"+ - "}"; - - @SuppressWarnings("unchecked") - ArrayList bindings = (ArrayList) strabon.query(query,strabon.getSailRepoConnection()); - assertEquals(2, bindings.size()); - assertTrue(-1;id1=\"B\"^^]")); - assertTrue(-1;id1=\"Z\"^^]")); - } - - //Egenhofer - 8 functions - all with 2 arguments + boolean - - @Test - public void testGeofEhEquals() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - String query = - prefixes+ - "SELECT DISTINCT ?s1 ?s2 \n"+ - "WHERE { \n" + - " ?s1 ex:geometry ?g1 . \n"+ - " ?s2 ex:geometry ?g2 . \n" + - " FILTER( str(?s1) < str(?s2) ) . \n"+ - " FILTER( geof:ehEquals(?g1, ?g2 )) . \n"+ - "}"; - - @SuppressWarnings("unchecked") - ArrayList bindings = (ArrayList) strabon.query(query,strabon.getSailRepoConnection()); - assertEquals(1, bindings.size()); - assertTrue(-1 bindings = (ArrayList) strabon.query(query,strabon.getSailRepoConnection()); - assertEquals(60, bindings.size()); - // too many results :) -// assertTrue(-1 bindings = (ArrayList) strabon.query(query,strabon.getSailRepoConnection()); - assertEquals(2, bindings.size()); - assertTrue(-1;id1=\"G\"^^]")); - assertTrue(-1;id1=\"Z\"^^]")); - } - - @Test - public void testGeofEhOverlap() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - String query = - prefixes+ - "SELECT DISTINCT ?id1 ?id2 \n"+ - "WHERE { \n" + - " ?s1 ex:id ?id1 . \n"+ - " ?s2 ex:id ?id2 . \n"+ - " FILTER( str(?id1) != str(?id2) ) . \n"+ - " ?s2 ex:geometry ?g2 . \n" + - " ?s1 ex:geometry ?g1 . \n"+ - " FILTER( geof:ehOverlap(?g1, ?g2 )) . \n"+ - "}"; - - @SuppressWarnings("unchecked") - ArrayList bindings = (ArrayList) strabon.query(query,strabon.getSailRepoConnection()); - assertEquals(2, bindings.size()); - assertTrue(-1;id1=\"B\"^^]")); - assertTrue(-1;id1=\"Z\"^^]")); - } - - @Test - public void testGeofEhCovers() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - String query = - prefixes+ - "SELECT DISTINCT ?id1 ?id2 \n"+ - "WHERE { \n" + - " ?s1 ex:id ?id1 . \n"+ - " ?s2 ex:id ?id2 . \n"+ - " FILTER( str(?id1) != str(?id2) ) . \n"+ - " ?s2 ex:geometry ?g2 . \n" + - " ?s1 ex:geometry ?g1 . \n"+ - " FILTER( geof:ehCovers(?g1, ?g2 )) . \n"+ - "}"; - - @SuppressWarnings("unchecked") - ArrayList bindings = (ArrayList) strabon.query(query,strabon.getSailRepoConnection()); - assertEquals(1, bindings.size()); - assertTrue(-1;id1=\"Z\"^^]")); - } - - @Test - public void testGeofEhCoveredBy() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - String query = - prefixes+ - "SELECT DISTINCT ?id1 ?id2 \n"+ - "WHERE { \n" + - " ?s1 ex:id ?id1 . \n"+ - " ?s2 ex:id ?id2 . \n"+ - " FILTER( str(?id1) != str(?id2) ) . \n"+ - " ?s2 ex:geometry ?g2 . \n" + - " ?s1 ex:geometry ?g1 . \n"+ - " FILTER( geof:ehCoveredBy(?g1, ?g2 )) . \n"+ - "}"; - - @SuppressWarnings("unchecked") - ArrayList bindings = (ArrayList) strabon.query(query,strabon.getSailRepoConnection()); - assertEquals(1, bindings.size()); - assertTrue(-1;id1=\"F\"^^]")); - } - - @Test - public void testGeofEhInside() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - String query = - prefixes+ - "SELECT DISTINCT ?id1 ?id2 \n"+ - "WHERE { \n" + - " ?s1 ex:id ?id1 . \n"+ - " ?s2 ex:id ?id2 . \n"+ - " FILTER( str(?id1) != str(?id2) ) . \n"+ - " ?s2 ex:geometry ?g2 . \n" + - " ?s1 ex:geometry ?g1 . \n"+ - " FILTER( geof:ehInside(?g1, ?g2 )) . \n"+ - "}"; - - @SuppressWarnings("unchecked") - ArrayList bindings = (ArrayList) strabon.query(query,strabon.getSailRepoConnection()); - assertEquals(1, bindings.size()); - assertTrue(-1;id1=\"E\"^^]")); - } - - @Test - public void testGeofEhContains() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - String query = - prefixes+ - "SELECT DISTINCT ?id1 ?id2 \n"+ - "WHERE { \n" + - " ?s1 ex:id ?id1 . \n"+ - " ?s2 ex:id ?id2 . \n"+ - " FILTER( str(?id1) != str(?id2) ) . \n"+ - " ?s2 ex:geometry ?g2 . \n" + - " ?s1 ex:geometry ?g1 . \n"+ - " FILTER( geof:ehContains(?g1, ?g2 )) . \n"+ - "}"; - - @SuppressWarnings("unchecked") - ArrayList bindings = (ArrayList) strabon.query(query,strabon.getSailRepoConnection()); - assertEquals(1, bindings.size()); - assertTrue(-1;id1=\"Z\"^^]")); - } - - //RCC8 - 8 functions - all with 2 arguments + boolean - - @Test - public void testGeofRcc8Dc() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - String query = - prefixes+ - "SELECT DISTINCT ?s1 ?s2 \n"+ - "WHERE { \n" + - " ?s1 ex:geometry ?g1 . \n"+ - " ?s2 ex:geometry ?g2 . \n" + - " FILTER( str(?s1) < str(?s2) ) . \n"+ - " FILTER( geof:rcc8dc(?g1, ?g2 )) . \n"+ - "}"; - - @SuppressWarnings("unchecked") - ArrayList bindings = (ArrayList) strabon.query(query,strabon.getSailRepoConnection()); - assertEquals(60, bindings.size()); - // too many results :) -// assertTrue(-1 bindings = (ArrayList) strabon.query(query,strabon.getSailRepoConnection()); - assertEquals(2, bindings.size()); - assertTrue(-1;id1=\"Z\"^^]")); - assertTrue(-1;id1=\"B\"^^]")); - } - - @Test - public void testGeofRcc8Tppi() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - String query = - prefixes+ - "SELECT DISTINCT ?id1 ?id2 \n"+ - "WHERE { \n" + - " ?s1 ex:id ?id1 . \n"+ - " ?s2 ex:id ?id2 . \n"+ - " FILTER( str(?id1) != str(?id2) ) . \n"+ - " ?s2 ex:geometry ?g2 . \n" + - " ?s1 ex:geometry ?g1 . \n"+ - " FILTER( geof:rcc8tppi(?g1, ?g2 )) . \n"+ - "}"; - - @SuppressWarnings("unchecked") - ArrayList bindings = (ArrayList) strabon.query(query,strabon.getSailRepoConnection()); - assertEquals(1, bindings.size()); - assertTrue(-1;id1=\"Z\"^^]")); - } - - @Test - public void testGeofRcc8Tpp() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - String query = - prefixes+ - "SELECT DISTINCT ?id1 ?id2 \n"+ - "WHERE { \n" + - " ?s1 ex:id ?id1 . \n"+ - " ?s2 ex:id ?id2 . \n"+ - " FILTER( str(?id1) != str(?id2) ) . \n"+ - " ?s2 ex:geometry ?g2 . \n" + - " ?s1 ex:geometry ?g1 . \n"+ - " FILTER( geof:rcc8tpp(?g1, ?g2 )) . \n"+ - "}"; - - @SuppressWarnings("unchecked") - ArrayList bindings = (ArrayList) strabon.query(query,strabon.getSailRepoConnection()); - assertEquals(1, bindings.size()); - assertTrue(-1;id1=\"F\"^^]")); - } - - - @Test - public void testGeofRcc8Ntpp() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - String query = - prefixes+ - "SELECT DISTINCT ?id1 ?id2 \n"+ - "WHERE { \n" + - " ?s1 ex:id ?id1 . \n"+ - " ?s2 ex:id ?id2 . \n"+ - " FILTER( str(?id1) != str(?id2) ) . \n"+ - " ?s2 ex:geometry ?g2 . \n" + - " ?s1 ex:geometry ?g1 . \n"+ - " FILTER( geof:rcc8ntpp(?g1, ?g2 )) . \n"+ - "}"; - - @SuppressWarnings("unchecked") - ArrayList bindings = (ArrayList) strabon.query(query,strabon.getSailRepoConnection()); - assertEquals(1, bindings.size()); - assertTrue(-1;id1=\"E\"^^]")); - } - @Test - public void testGeofRcc8Ntppi() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - String query = - prefixes+ - "SELECT DISTINCT ?id1 ?id2 \n"+ - "WHERE { \n" + - " ?s1 ex:id ?id1 . \n"+ - " ?s2 ex:id ?id2 . \n"+ - " FILTER( str(?id1) != str(?id2) ) . \n"+ - " ?s2 ex:geometry ?g2 . \n" + - " ?s1 ex:geometry ?g1 . \n"+ - " FILTER( geof:rcc8ntpp(?g1, ?g2 )) . \n"+ - "}"; - - @SuppressWarnings("unchecked") - ArrayList bindings = (ArrayList) strabon.query(query,strabon.getSailRepoConnection()); - assertEquals(1, bindings.size()); - assertTrue(-1;id1=\"E\"^^]")); - } -} diff -r 38b0c0a12614 -r 6521e8989dc9 runtime/src/test/java/eu/earthobservatory/runtime/generaldb/TransformTests.java --- a/runtime/src/test/java/eu/earthobservatory/runtime/generaldb/TransformTests.java Thu May 14 11:24:32 2015 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,85 +0,0 @@ -/** - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * Copyright (C) 2010, 2011, 2012, Pyravlos Team - * - * http://www.strabon.di.uoa.gr/ - */ -package eu.earthobservatory.runtime.generaldb; - -public class TransformTests { - - public static Strabon strabon; - - protected static String jdbcDriver= "org.postgresql.Driver"; - protected static String serverName = "localhost"; - protected static String username = "postgres"; - protected static String password = "postgres"; - protected static Integer port = 5432; - protected static java.sql.Connection conn = null; - protected static String databaseName = null; - - - - String prefixes = "PREFIX gag: \n"+ - "PREFIX rdf: \n"+ - "PREFIX strdf: \n"+ - "PREFIX noa: \n"+ - "PREFIX base: \n"+ - "PREFIX ex: \n"+ - "PREFIX rdfs: \n" + - "PREFIX geof: \n"; - - protected String query1 = prefixes + - "SELECT ?H1 ?HAT1 ?HGEO1 " + - "(strdf:transform(?HGEO1, ) AS ?converted)" + - "(strdf:transform(strdf:union(?HGEO1,?HGEO1),) AS ?united) " + - "WHERE { \n"+ - "?H1 rdf:type noa:Hotspot . \n"+ - "?H1 noa:hasConfidence ?HCONF1 . \n"+ - "?H1 noa:hasGeometry ?HGEO1 . \n"+ - "?H1 noa:hasAcquisitionTime ?HAT1 . \n"+ -// " FILTER(strdf:mbbIntersects(?HGEO1,?HGEO1)) "+ - "}" + - " LIMIT 5 \n"; - -// protected String query2 = prefixes + -// "SELECT ?H1 ?H2 (strdf:transform(strdf:union(?HGEO1,?HGEO2),) AS ?united)" + -// "WHERE { \n"+ -//// "?H1 rdf:type noa:Hotspot . \n"+ -//// "?H2 rdf:type noa:Hotspot . \n"+ -// "?H1 noa:hasGeometry ?HGEO1 . \n"+ -// "?H2 noa:hasGeometry ?HGEO2 . \n"+ -//// "?H1 noa:producedFromProcessingChain ?PC1 . \n"+ -//// "?H2 noa:producedFromProcessingChain ?PC2 . \n"+ -//// " FILTER(strdf:mbbIntersects(?HGEO1,?HGEO2)) "+ -// " FILTER(?H1 != ?H2) "+ -// "}" + -// " LIMIT 5 \n"; - - - - protected String query3= prefixes + - "SELECT ?H ?HGEO ?HAT " + - "(strdf:transform(strdf:intersection(?HGEO, strdf:union(?CGEO)),) AS ?DIF) \n"+ - "WHERE { \n"+ - " ?H rdf:type noa:Hotspot ; \n"+ - " noa:hasAcquisitionTime ?HAT ; \n"+ - " noa:isDerivedFromSensor ?HS ; \n"+ - " noa:hasGeometry ?HGEO . \n"+ - " FILTER(str(?HS) = \"MSG2\") . \n"+ - " FILTER(str(?HAT) = \"2007-08-24T14:45:00\") . \n"+ - " ?C rdf:type noa:Coastline ; \n"+ - " noa:hasGeometry ?CGEO . \n"+ - " FILTER( strdf:mbbIntersects(?HGEO, ?CGEO) ) . \n"+ - "} \n"+ - "GROUP BY ?H ?HAT ?HGEO\n"+ - "HAVING strdf:overlap(strdf:union(?CGEO), ?HGEO) " + - " "; - - - - -} diff -r 38b0c0a12614 -r 6521e8989dc9 runtime/src/test/java/eu/earthobservatory/runtime/monetdb/AggregateTests.java --- a/runtime/src/test/java/eu/earthobservatory/runtime/monetdb/AggregateTests.java Thu May 14 11:24:32 2015 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,38 +0,0 @@ -/** - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * Copyright (C) 2010, 2011, 2012, Pyravlos Team - * - * http://www.strabon.di.uoa.gr/ - */ -package eu.earthobservatory.runtime.monetdb; - -import java.sql.SQLException; - -import org.junit.AfterClass; -import org.junit.BeforeClass; - -/** - * A set of simple tests on SPARQL query functionality - * - * @author George Garbis - */ -public class AggregateTests extends eu.earthobservatory.runtime.generaldb.AggregateTests { - - @BeforeClass - public static void beforeClass(String inputfile) throws Exception - { - strabon = TemplateTests.beforeClass("/aggregate-tests-srid.nt"); - - } - - @AfterClass - public static void afterClass() throws SQLException - { - TemplateTests.afterClass(strabon); - } - - -} diff -r 38b0c0a12614 -r 6521e8989dc9 runtime/src/test/java/eu/earthobservatory/runtime/monetdb/GeneralTests.java --- a/runtime/src/test/java/eu/earthobservatory/runtime/monetdb/GeneralTests.java Thu May 14 11:24:32 2015 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,87 +0,0 @@ -/** - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * Copyright (C) 2010, 2011, 2012, Pyravlos Team - * - * http://www.strabon.di.uoa.gr/ - */ -package eu.earthobservatory.runtime.monetdb; - -import java.io.IOException; -import java.sql.SQLException; - -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.openrdf.query.MalformedQueryException; -import org.openrdf.query.QueryEvaluationException; -import org.openrdf.query.TupleQueryResultHandlerException; - -/** - * A set of simple tests on SPARQL query functionality - * - * @author George Garbis - */ -public class GeneralTests extends eu.earthobservatory.runtime.generaldb.GeneralTests { - - @BeforeClass - public static void beforeClass() throws Exception - { - strabon = TemplateTests.beforeClass("/more-tests.nt"); - } - - @AfterClass - public static void afterClass() throws SQLException - { - TemplateTests.afterClass(strabon); - } - - @Test - public void testQuerySpatialProperties() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - strabon.query(querySpatialPropertiesMonetDB,strabon.getSailRepoConnection()); - - } - - @Test - public void testQuerySpatialPropertiesConst() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - strabon.query(querySpatialPropertiesConstMonetDB,strabon.getSailRepoConnection()); - - } - -// /** -// * @throws java.lang.Exception -// */ -// @Before -// public void before() -// throws Exception -// { -// -// } -// -// /** -// * @throws java.lang.Exception -// */ -// @After -// public void after() -// throws Exception -// { -// // Clean database -// Statement stmt = conn.createStatement(); -// ResultSet results = stmt.executeQuery("SELECT table_name FROM information_schema.tables WHERE " + -// "table_schema='public' and table_name <> 'spatial_ref_sys' " + -// "and table_name <> 'geometry_columns' and " + -// "table_name <> 'geography_columns' and table_name <> 'locked'"); -// while (results.next()) { -// String table_name = results.getString("table_name"); -// Statement stmt2 = conn.createStatement(); -// stmt2.executeUpdate("DROP TABLE \""+table_name+"\""); -// stmt2.close(); -// } -// -// stmt.close(); -// } -} diff -r 38b0c0a12614 -r 6521e8989dc9 runtime/src/test/java/eu/earthobservatory/runtime/monetdb/HavingTests.java --- a/runtime/src/test/java/eu/earthobservatory/runtime/monetdb/HavingTests.java Thu May 14 11:24:32 2015 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,68 +0,0 @@ -/** - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * Copyright (C) 2010, 2011, 2012, Pyravlos Team - * - * http://www.strabon.di.uoa.gr/ - */ -package eu.earthobservatory.runtime.monetdb; - -import java.sql.SQLException; - -import org.junit.AfterClass; -import org.junit.BeforeClass; - -/** - * - * @author George Garbis - * - */ -public class HavingTests extends eu.earthobservatory.runtime.generaldb.HavingTests { - - @BeforeClass - public static void beforeClass() throws Exception - { - strabon = TemplateTests.beforeClass("/having-tests-srid.nt"); - } - - @AfterClass - public static void afterClass() throws SQLException - { - TemplateTests.afterClass(strabon); - } - -// /** -// * @throws java.lang.Exception -// */ -// @Before -// public void before() -// throws Exception -// { -// -// } -// -// /** -// * @throws java.lang.Exception -// */ -// @After -// public void after() -// throws Exception -// { -// // Clean database -// Statement stmt = conn.createStatement(); -// ResultSet results = stmt.executeQuery("SELECT table_name FROM information_schema.tables WHERE " + -// "table_schema='public' and table_name <> 'spatial_ref_sys' " + -// "and table_name <> 'geometry_columns' and " + -// "table_name <> 'geography_columns' and table_name <> 'locked'"); -// while (results.next()) { -// String table_name = results.getString("table_name"); -// Statement stmt2 = conn.createStatement(); -// stmt2.executeUpdate("DROP TABLE \""+table_name+"\""); -// stmt2.close(); -// } -// -// stmt.close(); -// } -} diff -r 38b0c0a12614 -r 6521e8989dc9 runtime/src/test/java/eu/earthobservatory/runtime/monetdb/JoinTests.java --- a/runtime/src/test/java/eu/earthobservatory/runtime/monetdb/JoinTests.java Thu May 14 11:24:32 2015 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,36 +0,0 @@ -/** - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * Copyright (C) 2010, 2011, 2012, Pyravlos Team - * - * http://www.strabon.di.uoa.gr/ - */ -package eu.earthobservatory.runtime.monetdb; - -import java.sql.SQLException; - -import org.junit.AfterClass; -import org.junit.BeforeClass; - -/** - * - * @author George Garbis - * - */ -public class JoinTests extends eu.earthobservatory.runtime.generaldb.JoinTests { - - @BeforeClass - public static void beforeClass() throws Exception - { - strabon = TemplateTests.beforeClass("/join-tests-srid.nt"); - } - - @AfterClass - public static void afterClass() throws SQLException - { - TemplateTests.afterClass(strabon); - } - -} diff -r 38b0c0a12614 -r 6521e8989dc9 runtime/src/test/java/eu/earthobservatory/runtime/monetdb/MeaningfulAggregateTests.java --- a/runtime/src/test/java/eu/earthobservatory/runtime/monetdb/MeaningfulAggregateTests.java Thu May 14 11:24:32 2015 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,32 +0,0 @@ -/** - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * Copyright (C) 2010, 2011, 2012, Pyravlos Team - * - * http://www.strabon.di.uoa.gr/ - */ -package eu.earthobservatory.runtime.monetdb; - -import java.sql.SQLException; - -import org.junit.AfterClass; -import org.junit.BeforeClass; - -public class MeaningfulAggregateTests extends eu.earthobservatory.runtime.generaldb.SimpleTests { - - @BeforeClass - public static void beforeClass() throws Exception - { - strabon = TemplateTests.beforeClass("/more-tests.nt"); - } - - @AfterClass - public static void afterClass() throws SQLException - { - TemplateTests.afterClass(strabon); - } - - -} diff -r 38b0c0a12614 -r 6521e8989dc9 runtime/src/test/java/eu/earthobservatory/runtime/monetdb/SimpleTests.java --- a/runtime/src/test/java/eu/earthobservatory/runtime/monetdb/SimpleTests.java Thu May 14 11:24:32 2015 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,68 +0,0 @@ -/** - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * Copyright (C) 2010, 2011, 2012, Pyravlos Team - * - * http://www.strabon.di.uoa.gr/ - */ -package eu.earthobservatory.runtime.monetdb; - -import java.sql.SQLException; - -import org.junit.AfterClass; -import org.junit.BeforeClass; - -/** - * A set of simple tests on SPARQL query functionality - * - * @author George Garbis - */ -public class SimpleTests extends eu.earthobservatory.runtime.generaldb.SimpleTests { - - @BeforeClass - public static void beforeClass() throws Exception - { - strabon = TemplateTests.beforeClass("/simple-tests.nt"); - } - - @AfterClass - public static void afterClass() throws SQLException - { - TemplateTests.afterClass(strabon); - } - -// /** -// * @throws java.lang.Exception -// */ -// @Before -// public void before() -// throws Exception -// { -// -// } -// -// /** -// * @throws java.lang.Exception -// */ -// @After -// public void after() -// throws Exception -// { -// // Clean database -// Statement stmt = conn.createStatement(); -// ResultSet results = stmt.executeQuery("SELECT table_name FROM information_schema.tables WHERE " + -// "table_schema='public' and table_name <> 'spatial_ref_sys' " + -// "and table_name <> 'geometry_columns' and " + -// "table_name <> 'geography_columns' and table_name <> 'locked'"); -// while (results.next()) { -// String table_name = results.getString("table_name"); -// Statement stmt2 = conn.createStatement(); -// stmt2.executeUpdate("DROP TABLE \""+table_name+"\""); -// stmt2.close(); -// } -// -// stmt.close(); -// } -} diff -r 38b0c0a12614 -r 6521e8989dc9 runtime/src/test/java/eu/earthobservatory/runtime/monetdb/SpatialTests.java --- a/runtime/src/test/java/eu/earthobservatory/runtime/monetdb/SpatialTests.java Thu May 14 11:24:32 2015 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,68 +0,0 @@ -/** - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * Copyright (C) 2010, 2011, 2012, Pyravlos Team - * - * http://www.strabon.di.uoa.gr/ - */ -package eu.earthobservatory.runtime.monetdb; - -import java.sql.SQLException; - -import org.junit.AfterClass; -import org.junit.BeforeClass; - -/** - * A set of simple tests on SPARQL query functionality - * - * @author George Garbis - */ -public class SpatialTests extends eu.earthobservatory.runtime.generaldb.SpatialTests { - - @BeforeClass - public static void beforeClass() throws Exception - { - strabon = TemplateTests.beforeClass("/spatial-tests-srid.nt"); - } - - @AfterClass - public static void afterClass() throws SQLException - { - TemplateTests.afterClass(strabon); - } - -// /** -// * @throws java.lang.Exception -// */ -// @Before -// public void before() -// throws Exception -// { -// -// } -// -// /** -// * @throws java.lang.Exception -// */ -// @After -// public void after() -// throws Exception -// { -// // Clean database -// Statement stmt = conn.createStatement(); -// ResultSet results = stmt.executeQuery("SELECT table_name FROM information_schema.tables WHERE " + -// "table_schema='public' and table_name <> 'spatial_ref_sys' " + -// "and table_name <> 'geometry_columns' and " + -// "table_name <> 'geography_columns' and table_name <> 'locked'"); -// while (results.next()) { -// String table_name = results.getString("table_name"); -// Statement stmt2 = conn.createStatement(); -// stmt2.executeUpdate("DROP TABLE \""+table_name+"\""); -// stmt2.close(); -// } -// -// stmt.close(); -// } -} diff -r 38b0c0a12614 -r 6521e8989dc9 runtime/src/test/java/eu/earthobservatory/runtime/monetdb/TemplateTests.java --- a/runtime/src/test/java/eu/earthobservatory/runtime/monetdb/TemplateTests.java Thu May 14 11:24:32 2015 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,143 +0,0 @@ -/** - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * Copyright (C) 2010, 2011, 2012, Pyravlos Team - * - * http://www.strabon.di.uoa.gr/ - */ -package eu.earthobservatory.runtime.monetdb; - -import java.io.IOException; -import java.io.InputStream; -import java.sql.DriverManager; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; -import java.util.Properties; - -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.openrdf.repository.RepositoryException; -import org.openrdf.rio.RDFHandlerException; -import org.openrdf.rio.RDFParseException; - -import eu.earthobservatory.runtime.generaldb.InvalidDatasetFormatFault; -import eu.earthobservatory.runtime.generaldb.Strabon; - -/** - * A set of simple tests on SPARQL query functionality - * - * @author George Garbis - */ -public class TemplateTests extends eu.earthobservatory.runtime.generaldb.SimpleTests { - - @BeforeClass - public static Strabon beforeClass(String inputfile) throws Exception - { - // Read properties - Properties properties = new Properties(); - InputStream propertiesStream = TemplateTests.class.getResourceAsStream("/databases.properties"); - properties.load(propertiesStream); - - serverName = properties.getProperty("monetdb.serverName"); - databaseName = properties.getProperty("monetdb.databaseName"); - port = Integer.parseInt(properties.getProperty("monetdb.port")); - username = properties.getProperty("monetdb.username"); - password = properties.getProperty("monetdb.password"); - - // Connect to database - Class.forName("nl.cwi.monetdb.jdbc.MonetDriver"); - String url = "jdbc:monetdb://"+serverName+":"+port+"/"+databaseName; - conn = DriverManager.getConnection(url, username, password); - -// // Clean database - Statement stmt = conn.createStatement(); - ResultSet results = stmt.executeQuery("SELECT name FROM tables WHERE system=false AND name <> 'locked'"); - while (results.next()) { - String table_name = results.getString("name"); - Statement stmt2 = conn.createStatement(); - stmt2.executeUpdate("DROP TABLE \""+table_name+"\""); - stmt2.close(); - } - stmt.close(); - - Strabon strabon = new eu.earthobservatory.runtime.monetdb.Strabon(databaseName, username, password, port, serverName, true); - - TemplateTests.loadTestData(inputfile, strabon); - - // This is a workaround for http://bug.strabon.di.uoa.gr/ticket/1 - strabon.close(); - strabon = new eu.earthobservatory.runtime.monetdb.Strabon(databaseName, username, password, port, serverName, true); - // - - return strabon; - } - - @AfterClass - public static void afterClass(Strabon strabon) throws SQLException - { - strabon.close(); - } - - protected static void loadTestData(String inputfile, Strabon strabon) - throws RDFParseException, RepositoryException, IOException, RDFHandlerException, InvalidDatasetFormatFault - { - strabon.storeInRepo(inputfile, "NTRIPLES", false); - } - -// /** -// * @throws java.lang.Exception -// */ -// @Before -// public void before() -// throws Exception -// { -// -// } -// -// /** -// * @throws java.lang.Exception -// */ -// @After -// public void after() -// throws Exception -// { -// // Clean database -// Statement stmt = conn.createStatement(); -// ResultSet results = stmt.executeQuery("SELECT table_name FROM information_schema.tables WHERE " + -// "table_schema='public' and table_name <> 'spatial_ref_sys' " + -// "and table_name <> 'geometry_columns' and " + -// "table_name <> 'geography_columns' and table_name <> 'locked'"); -// while (results.next()) { -// String table_name = results.getString("table_name"); -// Statement stmt2 = conn.createStatement(); -// stmt2.executeUpdate("DROP TABLE \""+table_name+"\""); -// stmt2.close(); -// } -// -// stmt.close(); -// } -} -// */ -// @After -// public void after() -// throws Exception -// { -// // Clean database -// Statement stmt = conn.createStatement(); -// ResultSet results = stmt.executeQuery("SELECT table_name FROM information_schema.tables WHERE " + -// "table_schema='public' and table_name <> 'spatial_ref_sys' " + -// "and table_name <> 'geometry_columns' and " + -// "table_name <> 'geography_columns' and table_name <> 'locked'"); -// while (results.next()) { -// String table_name = results.getString("table_name"); -// Statement stmt2 = conn.createStatement(); -// stmt2.executeUpdate("DROP TABLE \""+table_name+"\""); -// stmt2.close(); -// } -// -// stmt.close(); -// } - diff -r 38b0c0a12614 -r 6521e8989dc9 runtime/src/test/java/eu/earthobservatory/runtime/monetdb/TransformTests.java --- a/runtime/src/test/java/eu/earthobservatory/runtime/monetdb/TransformTests.java Thu May 14 11:24:32 2015 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,36 +0,0 @@ -/** - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * Copyright (C) 2010, 2011, 2012, Pyravlos Team - * - * http://www.strabon.di.uoa.gr/ - */ -package eu.earthobservatory.runtime.monetdb; - -import java.sql.SQLException; - -import org.junit.AfterClass; -import org.junit.BeforeClass; - -/** - * A set of simple tests on SPARQL query functionality - * - * @author George Garbis - */ -public class TransformTests extends eu.earthobservatory.runtime.generaldb.TransformTests { - - @BeforeClass - public static void beforeClass() throws Exception - { - strabon = TemplateTests.beforeClass("/transform-tests.nt"); - } - - @AfterClass - public static void afterClass() throws SQLException - { - TemplateTests.afterClass(strabon); - } - -} diff -r 38b0c0a12614 -r 6521e8989dc9 runtime/src/test/java/eu/earthobservatory/runtime/postgis/AggregateTests.java --- a/runtime/src/test/java/eu/earthobservatory/runtime/postgis/AggregateTests.java Thu May 14 11:24:32 2015 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,32 +0,0 @@ -/** - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * Copyright (C) 2010, 2011, 2012, Pyravlos Team - * - * http://www.strabon.di.uoa.gr/ - */ -package eu.earthobservatory.runtime.postgis; - -import java.sql.SQLException; - -import org.junit.AfterClass; -import org.junit.BeforeClass; - - -public class AggregateTests extends eu.earthobservatory.runtime.generaldb.AggregateTests { - - @BeforeClass - public static void beforeClass() throws Exception - { - strabon = TemplateTests.beforeClass("/aggregate-tests-srid.nt"); - } - - @AfterClass - public static void afterClass() throws SQLException - { - TemplateTests.afterClass(strabon); - } - -} diff -r 38b0c0a12614 -r 6521e8989dc9 runtime/src/test/java/eu/earthobservatory/runtime/postgis/AllTests.java --- a/runtime/src/test/java/eu/earthobservatory/runtime/postgis/AllTests.java Thu May 14 11:24:32 2015 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,13 +0,0 @@ -package eu.earthobservatory.runtime.postgis; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - -@RunWith(Suite.class) -@SuiteClasses({ AggregateTests.class, GeneralTests.class, HavingTests.class, - JoinTests.class, MeaningfulAggregateTests.class, SimpleTests.class, - SPARQL11Tests.class, SpatialTests.class }) -public class AllTests { - -} diff -r 38b0c0a12614 -r 6521e8989dc9 runtime/src/test/java/eu/earthobservatory/runtime/postgis/GeneralTests.java --- a/runtime/src/test/java/eu/earthobservatory/runtime/postgis/GeneralTests.java Thu May 14 11:24:32 2015 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,88 +0,0 @@ -/** - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * Copyright (C) 2010, 2011, 2012, Pyravlos Team - * - * http://www.strabon.di.uoa.gr/ - */ -package eu.earthobservatory.runtime.postgis; - -import java.io.IOException; -import java.sql.SQLException; - -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.openrdf.query.MalformedQueryException; -import org.openrdf.query.QueryEvaluationException; -import org.openrdf.query.TupleQueryResultHandlerException; - -/** - * A set of simple tests on SPARQL query functionality - * - * @author George Garbis - */ -public class GeneralTests extends eu.earthobservatory.runtime.generaldb.GeneralTests { - - @BeforeClass - public static void beforeClass() throws Exception - { - strabon = TemplateTests.beforeClass("/more-tests.nt"); - } - - @AfterClass - public static void afterClass() throws SQLException - { - TemplateTests.afterClass(strabon); - } - - @Test - public void testQuerySpatialProperties() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - strabon.query(querySpatialPropertiesPostGIS,strabon.getSailRepoConnection()); - - } - - @Test - public void testQuerySpatialPropertiesConst() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException - { - strabon.query(querySpatialPropertiesConstPostGIS,strabon.getSailRepoConnection()); - - } - - -// /** -// * @throws java.lang.Exception -// */ -// @Before -// public void before() -// throws Exception -// { -// -// } -// -// /** -// * @throws java.lang.Exception -// */ -// @After -// public void after() -// throws Exception -// { -// // Clean database -// Statement stmt = conn.createStatement(); -// ResultSet results = stmt.executeQuery("SELECT table_name FROM information_schema.tables WHERE " + -// "table_schema='public' and table_name <> 'spatial_ref_sys' " + -// "and table_name <> 'geometry_columns' and " + -// "table_name <> 'geography_columns' and table_name <> 'locked'"); -// while (results.next()) { -// String table_name = results.getString("table_name"); -// Statement stmt2 = conn.createStatement(); -// stmt2.executeUpdate("DROP TABLE \""+table_name+"\""); -// stmt2.close(); -// } -// -// stmt.close(); -// } -} diff -r 38b0c0a12614 -r 6521e8989dc9 runtime/src/test/java/eu/earthobservatory/runtime/postgis/HavingTests.java --- a/runtime/src/test/java/eu/earthobservatory/runtime/postgis/HavingTests.java Thu May 14 11:24:32 2015 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,32 +0,0 @@ -/** - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * Copyright (C) 2010, 2011, 2012, Pyravlos Team - * - * http://www.strabon.di.uoa.gr/ - */ -package eu.earthobservatory.runtime.postgis; - -import java.sql.SQLException; - -import org.junit.AfterClass; -import org.junit.BeforeClass; - - -public class HavingTests extends eu.earthobservatory.runtime.generaldb.HavingTests { - - @BeforeClass - public static void beforeClass() throws Exception - { - strabon = TemplateTests.beforeClass("/having-tests-srid.nt"); - } - - @AfterClass - public static void afterClass() throws SQLException - { - TemplateTests.afterClass(strabon); - } - -} diff -r 38b0c0a12614 -r 6521e8989dc9 runtime/src/test/java/eu/earthobservatory/runtime/postgis/JoinTests.java --- a/runtime/src/test/java/eu/earthobservatory/runtime/postgis/JoinTests.java Thu May 14 11:24:32 2015 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,31 +0,0 @@ -/** - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * Copyright (C) 2010, 2011, 2012, Pyravlos Team - * - * http://www.strabon.di.uoa.gr/ - */ -package eu.earthobservatory.runtime.postgis; - -import java.sql.SQLException; - -import org.junit.AfterClass; -import org.junit.BeforeClass; - -public class JoinTests extends eu.earthobservatory.runtime.generaldb.JoinTests { - - @BeforeClass - public static void beforeClass() throws Exception - { - strabon = TemplateTests.beforeClass("/join-tests-srid.nt"); - } - - @AfterClass - public static void afterClass() throws SQLException - { - TemplateTests.afterClass(strabon); - } - -} diff -r 38b0c0a12614 -r 6521e8989dc9 runtime/src/test/java/eu/earthobservatory/runtime/postgis/MeaningfulAggregateTests.java --- a/runtime/src/test/java/eu/earthobservatory/runtime/postgis/MeaningfulAggregateTests.java Thu May 14 11:24:32 2015 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -/** - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * Copyright (C) 2010, 2011, 2012, Pyravlos Team - * - * http://www.strabon.di.uoa.gr/ - */ -package eu.earthobservatory.runtime.postgis; - -import java.sql.SQLException; - -import org.junit.AfterClass; -import org.junit.BeforeClass; - - -public class MeaningfulAggregateTests extends eu.earthobservatory.runtime.generaldb.MeaningfulAggregateTests { - - - @BeforeClass - public static void beforeClass() throws Exception - { - strabon = TemplateTests.beforeClass("/group-tests-srid.nt"); - } - - @AfterClass - public static void afterClass() throws SQLException - { - TemplateTests.afterClass(strabon); - } - - - -} \ No newline at end of file diff -r 38b0c0a12614 -r 6521e8989dc9 runtime/src/test/java/eu/earthobservatory/runtime/postgis/SPARQL11Tests.java --- a/runtime/src/test/java/eu/earthobservatory/runtime/postgis/SPARQL11Tests.java Thu May 14 11:24:32 2015 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,71 +0,0 @@ -/** - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * Copyright (C) 2010, 2011, 2012, Pyravlos Team - * - * http://www.strabon.di.uoa.gr/ - */ -package eu.earthobservatory.runtime.postgis; - -import java.sql.SQLException; - -import org.junit.AfterClass; -import org.junit.BeforeClass; - -/** - * A set of simple tests on SPARQL query functionality - * - * @author George Garbis - */ - -public class SPARQL11Tests extends eu.earthobservatory.runtime.generaldb.SPARQL11Tests { - - @BeforeClass - public static void beforeClass() throws Exception - { - strabon = TemplateTests.beforeClass("/sparql11-tests.nt"); - } - - @AfterClass - public static void afterClass() throws SQLException - { - TemplateTests.afterClass(strabon); - } - - - -// /** -// * @throws java.lang.Exception -// */ -// @Before -// public void before() -// throws Exception -// { -// -// } -// -// /** -// * @throws java.lang.Exception -// */ -// @After -// public void after() -// throws Exception -// { -// // Clean database -// Statement stmt = conn.createStatement(); -// ResultSet results = stmt.executeQuery("SELECT table_name FROM information_schema.tables WHERE " + -// "table_schema='public' and table_name <> 'spatial_ref_sys' " + -// "and table_name <> 'geometry_columns' and " + -// "table_name <> 'geography_columns' and table_name <> 'locked'"); -// while (results.next()) { -// String table_name = results.getString("table_name"); -// Statement stmt2 = conn.createStatement(); -// stmt2.executeUpdate("DROP TABLE \""+table_name+"\""); -// stmt2.close(); -// } -// -// stmt.close(); -// } -} diff -r 38b0c0a12614 -r 6521e8989dc9 runtime/src/test/java/eu/earthobservatory/runtime/postgis/SimpleTests.java --- a/runtime/src/test/java/eu/earthobservatory/runtime/postgis/SimpleTests.java Thu May 14 11:24:32 2015 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,68 +0,0 @@ -/** - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * Copyright (C) 2010, 2011, 2012, Pyravlos Team - * - * http://www.strabon.di.uoa.gr/ - */ -package eu.earthobservatory.runtime.postgis; - -import java.sql.SQLException; - -import org.junit.AfterClass; -import org.junit.BeforeClass; - -/** - * A set of simple tests on SPARQL query functionality - * - * @author George Garbis 'spatial_ref_sys' " + -// "and table_name <> 'geometry_columns' and " + -// "table_name <> 'geography_columns' and table_name <> 'locked'"); -// while (results.next()) { -// String table_name = results.getString("table_name"); -// Statement stmt2 = conn.createStatement(); -// stmt2.executeUpdate("DROP TABLE \""+table_name+"\""); -// stmt2.close(); -// } -// -// stmt.close(); -// } -} diff -r 38b0c0a12614 -r 6521e8989dc9 runtime/src/test/java/eu/earthobservatory/runtime/postgis/SpatialTests.java --- a/runtime/src/test/java/eu/earthobservatory/runtime/postgis/SpatialTests.java Thu May 14 11:24:32 2015 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,69 +0,0 @@ -/** - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * Copyright (C) 2010, 2011, 2012, Pyravlos Team - * - * http://www.strabon.di.uoa.gr/ - */ -package eu.earthobservatory.runtime.postgis; - -import java.sql.SQLException; - -import org.junit.AfterClass; -import org.junit.BeforeClass; - -/** - * A set of simple tests on SPARQL query functionality - * - * @author George Garbis - */ - -public class SpatialTests extends eu.earthobservatory.runtime.generaldb.SpatialTests { - - @BeforeClass - public static void beforeClass() throws Exception - { - strabon = TemplateTests.beforeClass("/spatial-tests-srid.nt"); - } - - @AfterClass - public static void afterClass() throws SQLException - { - TemplateTests.afterClass(strabon); - } - -// /** -// * @throws java.lang.Exception -// */ -// @Before -// public void before() -// throws Exception -// { -// -// } -// -// /** -// * @throws java.lang.Exception -// */ -// @After -// public void after() -// throws Exception -// { -// // Clean database -// Statement stmt = conn.createStatement(); -// ResultSet results = stmt.executeQuery("SELECT table_name FROM information_schema.tables WHERE " + -// "table_schema='public' and table_name <> 'spatial_ref_sys' " + -// "and table_name <> 'geometry_columns' and " + -// "table_name <> 'geography_columns' and table_name <> 'locked'"); -// while (results.next()) { -// String table_name = results.getString("table_name"); -// Statement stmt2 = conn.createStatement(); -// stmt2.executeUpdate("DROP TABLE \""+table_name+"\""); -// stmt2.close(); -// } -// -// stmt.close(); -// } -} diff -r 38b0c0a12614 -r 6521e8989dc9 runtime/src/test/java/eu/earthobservatory/runtime/postgis/TemplateTests.java --- a/runtime/src/test/java/eu/earthobservatory/runtime/postgis/TemplateTests.java Thu May 14 11:24:32 2015 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,180 +0,0 @@ -/** - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * Copyright (C) 2010, 2011, 2012, Pyravlos Team - * - * http://www.strabon.di.uoa.gr/ - */ -package eu.earthobservatory.runtime.postgis; - -import static org.junit.Assert.assertNull; - -import java.io.IOException; -import java.io.InputStream; -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Properties; - -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.openrdf.repository.RepositoryException; -import org.openrdf.rio.RDFHandlerException; -import org.openrdf.rio.RDFParseException; - -import eu.earthobservatory.runtime.generaldb.InvalidDatasetFormatFault; -import eu.earthobservatory.runtime.generaldb.SimpleTests; -import eu.earthobservatory.runtime.generaldb.Strabon; - -/** - * A set of simple tests on SPARQL query functionality - * - * @author George Garbis - * @author Panayiotis Smeros - */ -public class TemplateTests { - - public static String databaseTemplateName = null; - public static String defaultUser = null; - public static String serverName = null; - public static String username = null; - public static String password = null; - public static Integer port = null; - - public static Connection conn = null; - public static String databaseName = null; - - @BeforeClass - public static Strabon beforeClass(String inputFile) throws Exception - { - String url=""; - ArrayList databases=new ArrayList(); - PreparedStatement pst = null; - - // Read properties - Properties properties = new Properties(); - InputStream propertiesStream = SimpleTests.class.getResourceAsStream("/databases.properties"); - properties.load(propertiesStream); - - databaseTemplateName = properties.getProperty("postgis.databaseTemplateName");; - defaultUser = properties.getProperty("postgis.defaultUser"); - serverName = properties.getProperty("postgis.serverName"); - username = properties.getProperty("postgis.username"); - password = properties.getProperty("postgis.password"); - port = Integer.parseInt(properties.getProperty("postgis.port")); - - //Connect to server and create the temp database - url = "jdbc:postgresql://"+serverName+":"+port+"/"+defaultUser; - conn = DriverManager.getConnection(url, username, password); - assertNull(conn.getWarnings()); - - pst = conn.prepareStatement("SELECT * FROM pg_catalog.pg_database"); - ResultSet rs = pst.executeQuery(); - - while (rs.next()) { - databases.add(rs.getString(1)); - } - rs.close(); - pst.close(); - - databaseName="teststrabon"+(int)(Math.random()*10000); - while(databases.contains(databaseName)){ - databaseName+="0"; - } - - - pst = conn.prepareStatement("CREATE DATABASE "+databaseName+" TEMPLATE " + databaseTemplateName); - pst.executeUpdate(); - pst.close(); - conn.close(); - - url = "jdbc:postgresql://"+serverName+":"+port+"/"+databaseName; - conn = DriverManager.getConnection(url, username, password); - assertNull(conn.getWarnings()); - - Strabon strabon = new eu.earthobservatory.runtime.postgis.Strabon(databaseName, username, password, port, serverName, true); - - loadTestData(inputFile, strabon); - - return strabon; - } - - - @AfterClass - public static void afterClass(Strabon strabon) throws SQLException - { - strabon.close(); - - //Drop the temp database - conn.close(); - String url = "jdbc:postgresql://"+serverName+":"+port+"/"+defaultUser; - conn = DriverManager.getConnection(url, username, password); - assertNull(conn.getWarnings()); - - PreparedStatement pst = conn.prepareStatement("DROP DATABASE "+databaseName); - pst.executeUpdate(); - pst.close(); - conn.close(); - } - - protected static void loadTestData(String inputfile, Strabon strabon) - throws RDFParseException, RepositoryException, IOException, RDFHandlerException, InvalidDatasetFormatFault - { - strabon.storeInRepo(inputfile, "NTRIPLES", false); - } - - - // Clean database -// Statement stmt = conn.createStatement(); -// ResultSet results = stmt.executeQuery("SELECT table_name FROM information_schema.tables WHERE " + -// "table_schema='public' AND table_name <> 'spatial_ref_sys' " + -// "AND table_name <> 'geometry_columns' AND table_name <> 'geography_columns' " + -// "AND table_name <> 'raster_columns' AND table_name <> 'raster_overviews' " + -// "AND table_name <> 'locked'" -// ); -// while (results.next()) { -// String table_name = results.getString("table_name"); -// Statement stmt2 = conn.createStatement(); -// stmt2.executeUpdate("DROP TABLE \""+table_name+"\""); -// stmt2.close(); -// } -// stmt.close(); - -// /** -// * @throws java.lang.Exception -// */ -// @Before -// public void before() -// throws Exception -// { -// -// } -// -// /** -// * @throws java.lang.Exception -// */ -// @After -// public void after() -// throws Exception -// { -// // Clean database -// Statement stmt = conn.createStatement(); -// ResultSet results = stmt.executeQuery("SELECT table_name FROM information_schema.tables WHERE " + -// "table_schema='public' and table_name <> 'spatial_ref_sys' " + -// "and table_name <> 'geometry_columns' and " + -// "table_name <> 'geography_columns' and table_name <> 'locked'"); -// while (results.next()) { -// String table_name = results.getString("table_name"); -// Statement stmt2 = conn.createStatement(); -// stmt2.executeUpdate("DROP TABLE \""+table_name+"\""); -// stmt2.close(); -// } -// -// stmt.close(); -// } -} diff -r 38b0c0a12614 -r 6521e8989dc9 runtime/src/test/java/eu/earthobservatory/runtime/postgis/TransformTests.java --- a/runtime/src/test/java/eu/earthobservatory/runtime/postgis/TransformTests.java Thu May 14 11:24:32 2015 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,69 +0,0 @@ -/** - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * Copyright (C) 2010, 2011, 2012, Pyravlos Team - * - * http://www.strabon.di.uoa.gr/ - */ -package eu.earthobservatory.runtime.postgis; - -import java.sql.SQLException; - -import org.junit.AfterClass; -import org.junit.BeforeClass; - -/** - * A set of simple tests on SPARQL query functionality - * - * @author George Garbis - */ - -public class TransformTests extends eu.earthobservatory.runtime.generaldb.TransformTests { - - @BeforeClass - public static void beforeClass() throws Exception - { - strabon = TemplateTests.beforeClass("/transform-tests.nt"); - } - - @AfterClass - public static void afterClass() throws SQLException - { - TemplateTests.afterClass(strabon); - } - -// /** -// * @throws java.lang.Exception -// */ -// @Before -// public void before() -// throws Exception -// { -// -// } -// -// /** -// * @throws java.lang.Exception -// */ -// @After -// public void after() -// throws Exception -// { -// // Clean database -// Statement stmt = conn.createStatement(); -// ResultSet results = stmt.executeQuery("SELECT table_name FROM information_schema.tables WHERE " + -// "table_schema='public' and table_name <> 'spatial_ref_sys' " + -// "and table_name <> 'geometry_columns' and " + -// "table_name <> 'geography_columns' and table_name <> 'locked'"); -// while (results.next()) { -// String table_name = results.getString("table_name"); -// Statement stmt2 = conn.createStatement(); -// stmt2.executeUpdate("DROP TABLE \""+table_name+"\""); -// stmt2.close(); -// } -// -// stmt.close(); -// } -} diff -r 38b0c0a12614 -r 6521e8989dc9 runtime/src/test/resources/aggregate-tests-srid.nt --- a/runtime/src/test/resources/aggregate-tests-srid.nt Thu May 14 11:24:32 2015 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ - "POINT(-1.87631 50.7213)"^^. - "Rosie's". - "Coffee Republic". - "Norwegian Wood". - "POINT(-1.87647 50.721)"^^. - "POINT(-1.83702 50.7272)"^^. - . - . - . - . - . - . - . - . - . - "POINT(-1.81769 50.7218)"^^. - "The Clock Café". - "POINT(-1.84845 50.7231)"^^. - "POINT(-1.84667 50.7317)"^^. - "POINT(-1.87346 50.7214)"^^. - "2"^^. - "POINT(-1.87652 50.7214)"^^. - "Café Riva". - "Curzon Diner". - "POINT(-1.84186 50.7255)"^^. - "Boscanova". - "Caffe Nero". - "Costa". - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . diff -r 38b0c0a12614 -r 6521e8989dc9 runtime/src/test/resources/cco2.nt --- a/runtime/src/test/resources/cco2.nt Thu May 14 11:24:32 2015 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ - "POINT(-1.87631 50.7213)"^^. - "Rosie's". - "Coffee Republic". - "Norwegian Wood". - "POINT(-1.87647 50.721)"^^. - "POINT(-1.83702 50.7272)"^^. - . - . - . - . - . - . - . - . - . - "POINT(-1.81769 50.7218)"^^. - "The Clock Café". - "POINT(-1.84845 50.7231)"^^. - "POINT(-1.84667 50.7317)"^^. - "POINT(-1.87346 50.7214)"^^. - "2"^^. - "POINT(-1.87652 50.7214)"^^. - "Café Riva". - "Curzon Diner". - "POINT(-1.84186 50.7255)"^^. - "Boscanova". - "Caffe Nero". - "Costa". - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . diff -r 38b0c0a12614 -r 6521e8989dc9 runtime/src/test/resources/databases.properties --- a/runtime/src/test/resources/databases.properties Thu May 14 11:24:32 2015 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,14 +0,0 @@ -# PostGIS -postgis.databaseTemplateName = template_postgis -postgis.defaultUser = postgres -postgis.serverName = localhost -postgis.username = postgres -postgis.password = postgres -postgis.port = 5432 - -! MonetDB -monetdb.databaseName = strabon-test -monetdb.serverName = localhost -monetdb.username = monetdb -monetdb.password = monetdb -monetdb.port = 50000 diff -r 38b0c0a12614 -r 6521e8989dc9 runtime/src/test/resources/group-tests-srid.nt --- a/runtime/src/test/resources/group-tests-srid.nt Thu May 14 11:24:32 2015 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,22 +0,0 @@ - . - . - . - . - . - . - . - . - . - . - . - "POINT(10 10)"^^. - "POINT(5 6)"^^. - "POINT(10 10)"^^. - "POINT(0 0)"^^. - "POINT(10 10)"^^. - "POINT(5 6)"^^. - "POLYGON((20 20, 20 22, 22 22, 22 20, 20 20))"^^. - "POLYGON((23 18, 24 19, 23 19, 23 18))"^^. - "POLYGON((20 15, 21 15, 21 16, 20 15))"^^. - "POLYGON((21.5 18.5, 23.5 18.5, 23.5 21, 21.5 21, 21.5 18.5))"^^. - "POLYGON((19 19, 21 19, 21 21, 19 21, 19 19))"^^. diff -r 38b0c0a12614 -r 6521e8989dc9 runtime/src/test/resources/having-tests-srid.nt --- a/runtime/src/test/resources/having-tests-srid.nt Thu May 14 11:24:32 2015 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,26 +0,0 @@ - . - . - . - . - . - . - . - . - . - . - . - "52"^^. - "47"^^. - "11"^^. - "19"^^. - "POINT(10 10)"^^. - "POINT(5 6)"^^. - "POINT(10 10)"^^. - "POINT(0 0)"^^. - "POINT(10 10)"^^. - "POINT(5 6)"^^. - "POLYGON((20 20, 20 22, 22 22, 22 20, 20 20))"^^. - "POLYGON((23 18, 24 19, 23 19, 23 18))"^^. - "POLYGON((20 15, 21 15, 21 16, 20 15))"^^. - "POLYGON((21.5 18.5, 23.5 18.5, 23.5 21, 21.5 21, 21.5 18.5))"^^. - "POLYGON((19 19, 21 19, 21 21, 19 21, 19 19))"^^. diff -r 38b0c0a12614 -r 6521e8989dc9 runtime/src/test/resources/join-tests-srid.nt --- a/runtime/src/test/resources/join-tests-srid.nt Thu May 14 11:24:32 2015 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,20 +0,0 @@ - "POINT(0 1)"^^. - "POINT(3 5)"^^. - . - . - . - . - "London". - "POINT(1 0)"^^. - . - . - . - . - . - . - . - . - . - "POINT(0 5)"^^. - "POINT(0 0)"^^. - "POINT(2 0)"^^. diff -r 38b0c0a12614 -r 6521e8989dc9 runtime/src/test/resources/join-tests.nt --- a/runtime/src/test/resources/join-tests.nt Thu May 14 11:24:32 2015 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,20 +0,0 @@ - "POINT(0 0)"^^. - . - . - . - . - "POINT(1 0)"^^. - "POINT(2 0)"^^. - . - "POINT(0 1)"^^. - . - "POINT(3 5)"^^. - "POINT(0 5)"^^. - . - "London". - . - . - . - . - . - . diff -r 38b0c0a12614 -r 6521e8989dc9 runtime/src/test/resources/more-tests-srid.nt --- a/runtime/src/test/resources/more-tests-srid.nt Thu May 14 11:24:32 2015 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,58 +0,0 @@ - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . - "2"^^. - "Rosie's". - "Curzon Diner". - "Café Riva". - "The Clock Café". - "Costa". - "Coffee Republic". - "Caffe Nero". - "Norwegian Wood". - "Boscanova". - "Athens". - "Piraeus Pier". - "Pearl Harbor". - "Athens". - "POINT(-1.84186 50.7255)"^^. - "POINT(-1.84667 50.7317)"^^. - "POINT(-1.81769 50.7218)"^^. - "POINT(-1.84845 50.7231)"^^. - "POINT(-1.87652 50.7214)"^^. - "POINT(-1.87647 50.721)"^^. - "POINT(-1.87631 50.7213)"^^. - "POINT(-1.87346 50.7214)"^^. - "POINT(-1.83702 50.7272)"^^. - "POINT(22.0 39.0)"^^. - "POINT(23.71 37.97)"^^. - "POLYGON((23.65 37.94,23.64 37.935,23.64 37.934,23.65 37.94))"^^. - "POINT(23.63 37.96)"^^. diff -r 38b0c0a12614 -r 6521e8989dc9 runtime/src/test/resources/more-tests.nt --- a/runtime/src/test/resources/more-tests.nt Thu May 14 11:24:32 2015 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,58 +0,0 @@ - "POINT(-1.87631 50.7213)"^^. - "POLYGON((23.65 37.94,23.64 37.935,23.64 37.934,23.65 37.94))"^^. - . - "Piraeus Pier". - "Rosie's". - "Coffee Republic". - . - "Norwegian Wood". - "POINT(-1.87647 50.721)"^^. - "POINT(-1.83702 50.7272)"^^. - . - . - . - . - . - . - . - . - . - "POINT(-1.81769 50.7218)"^^. - "The Clock Café". - "POINT(-1.84845 50.7231)"^^. - "POINT(-1.84667 50.7317)"^^. - "POINT(-1.87346 50.7214)"^^. - "Pearl Harbor". - "2"^^. - . - "POINT(-1.87652 50.7214)"^^. - "Café Riva". - "Curzon Diner". - "POINT(-1.84186 50.7255)"^^. - "Boscanova". - "Caffe Nero". - "POINT(23.63 37.96)"^^. - "POINT(23.71 37.97)"^^. - . - "Costa". - "POINT(22.0 39.0)"^^. - "Athens". - "Athens". - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . - . diff -r 38b0c0a12614 -r 6521e8989dc9 runtime/src/test/resources/simple-tests.nt --- a/runtime/src/test/resources/simple-tests.nt Thu May 14 11:24:32 2015 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ - "1"^^. - "2"^^. - "3"^^. - "10"^^. - "20"^^. - "POINT(1 0)"^^. - "POINT(2 0)"^^. - "POINT(3 0)"^^. diff -r 38b0c0a12614 -r 6521e8989dc9 runtime/src/test/resources/sparql11-tests.nt --- a/runtime/src/test/resources/sparql11-tests.nt Thu May 14 11:24:32 2015 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,62 +0,0 @@ - "SPARQL Query Language Tutorial". - "SPARQL". - "Johnny Lee Outlaw". - "Peter Goodguy". - "Alice". - "Bob". - "Alice Foo". - "A. Foo". - "Bob Bar". - "B. Bar". - "Carol Baz". - "C. Baz". - . - . - . - . - . - . - . - "Smith". - "Jones". - "Smith". - "Alice". - "Bob". - . - . - . - "cat"@en. - "42"^^. - "abc"^^. - "1"^^. - "3.0"^^. - "1"^^. - "2"^^. - "4.0"^^. - "5.0"^^. - . - . - . - . - "9"^^. - "5"^^. - "7"^^. - "7"^^. - "Doe". - "John". - "12345"^^. - "67890"^^. - "Alice". - "Bob". - "SPARQL Tutorial". - "The Semantic Web". - "SPARQL Protocol Tutorial". - "SPARQL (updated)". - . - . - "0.2"^^. - "0.25"^^. - "42"^^. - "23"^^. - . - . diff -r 38b0c0a12614 -r 6521e8989dc9 runtime/src/test/resources/spatial-tests-srid.nt --- a/runtime/src/test/resources/spatial-tests-srid.nt Thu May 14 11:24:32 2015 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,36 +0,0 @@ - . - . - . - . - . - . - . - . - . - . - . - . - "A"^^. - "A"^^. - "B"^^. - "C"^^. - "D"^^. - "E"^^. - "F"^^. - "G"^^. - "H"^^. - "Z"^^. - "L1"^^. - "L2"^^. - "POLYGON((1 6, 2 6, 2 7, 1 7, 1 6))"^^. - "POLYGON((1 6, 2 6, 2 7, 1 7, 1 6))"^^. - "POLYGON((4 2, 5 2, 5 4, 4 4, 4 2))"^^. - "POLYGON((8 1, 9 1, 9 2, 8 2, 8 1))"^^. - "POLYGON((11 6, 12 6, 12 7, 11 7, 11 6))"^^. - "POLYGON((8 6, 9 6, 9 7, 8 7, 8 6))"^^. - "POLYGON((6 7, 7 7, 7 8, 6 8, 6 7))"^^. - "POLYGON((4 8, 5 8, 5 9, 4 9, 4 8))"^^. - "POLYGON((8 9, 9 9, 9 10, 8 10, 8 9))"^^. - "POLYGON((3 3, 10 3, 10 8, 3 8, 3 3))"^^. - "LINESTRING(11 3, 12 4)"^^. - "LINESTRING(11 4, 12 3)"^^. \ No newline at end of file