Strabon

changeset 159:18a4e7fd3922

Merging with kon's commit
author Manos Karpathiotakis <mk@di.uoa.gr>
date Fri May 18 13:48:39 2012 +0300 (2012-05-18)
parents ffff6d31c23d ee3332ca05c4
children b73979490392 3b5c0610b747
files
line diff
     1.1 --- a/mod.txt	Fri May 18 13:48:04 2012 +0300
     1.2 +++ b/mod.txt	Fri May 18 13:48:39 2012 +0300
     1.3 @@ -1,11 +1,15 @@
     1.4 -mod.txt
     1.5 -runtime/src/test/java/eu/earthobservatory/runtime/generaldb/JoinTests.java
     1.6 -runtime/src/test/java/eu/earthobservatory/runtime/generaldb/MeaningfulAggregateTests.java
     1.7 -runtime/src/test/java/eu/earthobservatory/runtime/generaldb/NOATests.java
     1.8 -runtime/src/test/java/eu/earthobservatory/runtime/generaldb/TransformTests.java
     1.9 -runtime/src/test/java/eu/earthobservatory/runtime/postgis/AggregateTests.java
    1.10 -runtime/src/test/java/eu/earthobservatory/runtime/postgis/GeneralTests.java
    1.11 -runtime/src/test/java/eu/earthobservatory/runtime/postgis/HavingTests.java
    1.12 -runtime/src/test/java/eu/earthobservatory/runtime/postgis/TransformTests.java
    1.13 -runtime/src/test/java/eu/earthobservatory/runtime/postgis/JoinTests.java
    1.14 -runtime/src/test/java/eu/earthobservatory/runtime/postgis/MeaningfulAggregateTests.java
    1.15 +M mod.txt
    1.16 +M runtime/src/test/java/eu/earthobservatory/runtime/generaldb/AggregateTests.java
    1.17 +M runtime/src/test/java/eu/earthobservatory/runtime/generaldb/GeneralTests.java
    1.18 +M runtime/src/test/java/eu/earthobservatory/runtime/generaldb/HavingTests.java
    1.19 +M runtime/src/test/java/eu/earthobservatory/runtime/postgis/AggregateTests.java
    1.20 +M runtime/src/test/java/eu/earthobservatory/runtime/postgis/GeneralTests.java
    1.21 +M runtime/src/test/java/eu/earthobservatory/runtime/postgis/HavingTests.java
    1.22 +M runtime/src/test/java/eu/earthobservatory/runtime/postgis/JoinTests.java
    1.23 +M runtime/src/test/java/eu/earthobservatory/runtime/postgis/MeaningfulAggregateTests.java
    1.24 +M runtime/src/test/java/eu/earthobservatory/runtime/postgis/TransformTests.java
    1.25 +? runtime/src/test/java/eu/earthobservatory/runtime/generaldb/SPARQL11Tests.java
    1.26 +? runtime/src/test/java/eu/earthobservatory/runtime/generaldb/SpatialTests.java
    1.27 +? runtime/src/test/java/eu/earthobservatory/runtime/postgis/SPARQL11Tests.java
    1.28 +? runtime/src/test/java/eu/earthobservatory/runtime/postgis/SpatialTests.java
    1.29 +? runtime/src/test/java/eu/earthobservatory/runtime/postgis/TemplateTests.java
     2.1 --- a/runtime/src/test/java/eu/earthobservatory/runtime/generaldb/AggregateTests.java	Fri May 18 13:48:04 2012 +0300
     2.2 +++ b/runtime/src/test/java/eu/earthobservatory/runtime/generaldb/AggregateTests.java	Fri May 18 13:48:39 2012 +0300
     2.3 @@ -43,19 +43,7 @@
     2.4  			strabon.storeInRepo(src, "NTRIPLES");
     2.5  		}
     2.6  
     2.7 -	@AfterClass
     2.8 -	public static void afterclass() throws SQLException
     2.9 -	{
    2.10 -strabon.close();
    2.11 -		
    2.12 -		conn.close();
    2.13 -		String url = "jdbc:postgresql://"+serverName+":"+port+"/template1";
    2.14 -		conn = DriverManager.getConnection(url, username, password);
    2.15 -		Statement stmt = conn.createStatement();
    2.16 -		stmt.executeUpdate("DROP DATABASE \""+databaseName+"\"");
    2.17 -		conn.close();
    2.18  
    2.19 -	}
    2.20  
    2.21  	String prefixes = 
    2.22  		"PREFIX lgdo:<http://linkedgeodata.org/ontology/> "+
     3.1 --- a/runtime/src/test/java/eu/earthobservatory/runtime/generaldb/GeneralTests.java	Fri May 18 13:48:04 2012 +0300
     3.2 +++ b/runtime/src/test/java/eu/earthobservatory/runtime/generaldb/GeneralTests.java	Fri May 18 13:48:39 2012 +0300
     3.3 @@ -37,18 +37,7 @@
     3.4  	//
     3.5  	//	}
     3.6  
     3.7 -	@AfterClass
     3.8 -	public static void afterClass() throws SQLException
     3.9 -	{
    3.10 -		strabon.close();
    3.11 -		
    3.12 -		conn.close();
    3.13 -		String url = "jdbc:postgresql://"+serverName+":"+port+"/template1";
    3.14 -		conn = DriverManager.getConnection(url, username, password);
    3.15 -		Statement stmt = conn.createStatement();
    3.16 -		stmt.executeUpdate("DROP DATABASE \""+databaseName+"\"");
    3.17 -		conn.close();
    3.18 -	}
    3.19 +
    3.20  	protected static void loadTestData()
    3.21  		throws RDFParseException, RepositoryException, IOException, RDFHandlerException, InvalidDatasetFormatFault
    3.22  	{
     4.1 --- a/runtime/src/test/java/eu/earthobservatory/runtime/generaldb/HavingTests.java	Fri May 18 13:48:04 2012 +0300
     4.2 +++ b/runtime/src/test/java/eu/earthobservatory/runtime/generaldb/HavingTests.java	Fri May 18 13:48:39 2012 +0300
     4.3 @@ -35,19 +35,7 @@
     4.4  	//	{
     4.5  	//		strabon = new Strabon("cco2","postgres","p1r3as", 5432, "localhost", true);
     4.6  	//	}
     4.7 -	@AfterClass
     4.8 -	public static void afterClass() throws SQLException
     4.9 -	{
    4.10 -		strabon.close();
    4.11 -		
    4.12 -		conn.close();
    4.13 -		String url = "jdbc:postgresql://"+serverName+":"+port+"/template1";
    4.14 -		conn = DriverManager.getConnection(url, username, password);
    4.15 -		Statement stmt = conn.createStatement();
    4.16 -		stmt.executeUpdate("DROP DATABASE \""+databaseName+"\"");
    4.17 -		conn.close();
    4.18 -	}
    4.19 -	
    4.20 +
    4.21  
    4.22  
    4.23  	String prefixes =
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/runtime/src/test/java/eu/earthobservatory/runtime/generaldb/SPARQL11Tests.java	Fri May 18 13:48:39 2012 +0300
     5.3 @@ -0,0 +1,332 @@
     5.4 +package eu.earthobservatory.runtime.generaldb;
     5.5 +
     5.6 +import static org.junit.Assert.assertEquals;
     5.7 +import static org.junit.Assert.assertTrue;
     5.8 +
     5.9 +import java.io.IOException;
    5.10 +import java.util.ArrayList;
    5.11 +
    5.12 +import org.junit.AfterClass;
    5.13 +import org.junit.Test;
    5.14 +import org.openrdf.model.vocabulary.RDF;
    5.15 +import org.openrdf.model.vocabulary.XMLSchema;
    5.16 +import org.openrdf.query.MalformedQueryException;
    5.17 +import org.openrdf.query.QueryEvaluationException;
    5.18 +import org.openrdf.query.TupleQueryResultHandlerException;
    5.19 +import org.openrdf.repository.RepositoryException;
    5.20 +
    5.21 +import eu.earthobservatory.runtime.generaldb.Strabon;
    5.22 +
    5.23 +
    5.24 +public class SPARQL11Tests {
    5.25 +	public static Strabon strabon;
    5.26 +
    5.27 +	public String 	FOAF_NS = "http://xmlns.com/foaf/0.1/",
    5.28 +	DT_NS = "http://example.org/datatype#",
    5.29 +	NS_NS = "http://example.org/ns#",
    5.30 +	DEF_NS = "http://example.org#",
    5.31 +	ORG_NS = "http://example.com/org#",
    5.32 +	DC_NS = "http://purl.org/dc/elements/1.1/",
    5.33 +	DC10_NS = "http://purl.org/dc/elements/1.0/",
    5.34 +	DC11_NS = "http://purl.org/dc/elements/1.1/";
    5.35 +
    5.36 +	protected String prefixes = 
    5.37 +		"PREFIX rdf: <"+RDF.NAMESPACE+"> \n" +
    5.38 +		"PREFIX xsd: <"+XMLSchema.NAMESPACE+"> \n" +
    5.39 +		"PREFIX foaf: <"+FOAF_NS+"> \n" +
    5.40 +		"PREFIX dt: <"+DT_NS+"> "+
    5.41 +		"PREFIX ns: <"+NS_NS+"> \n" +
    5.42 +		"PREFIX def: <"+DEF_NS+"> \n" +
    5.43 +		"PREFIX org: <"+ORG_NS+"> \n" +
    5.44 +		"PREFIX dc: <"+DC_NS+"> \n" +
    5.45 +		"PREFIX dc10: <"+DC10_NS+"> \n" +
    5.46 +		"PREFIX dc11: <"+DC11_NS+"> \n";
    5.47 +	
    5.48 +//	@BeforeClass
    5.49 +//	public static void initialize() throws SQLException, ClassNotFoundException
    5.50 +//	{
    5.51 +//		strabon = new Strabon("sparql11-tests","postgres","p1r3as", 5432, "localhost", true);
    5.52 +//
    5.53 +//	}
    5.54 +
    5.55 +
    5.56 +	
    5.57 +	@Test
    5.58 +	public void testRetrieveEveryEntry() throws MalformedQueryException, RepositoryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
    5.59 +	{		
    5.60 +		String queryString = prefixes+
    5.61 +			"SELECT ?s ?p ?o \n" +
    5.62 +			"WHERE \n" +
    5.63 +			"{ ?s ?p ?o . } \n";
    5.64 +		
    5.65 +		ArrayList<String> results =  (ArrayList <String>)strabon.query(queryString, strabon.getSailRepoConnection());
    5.66 +		assertEquals(62, results.size());
    5.67 +	}
    5.68 +	
    5.69 +	@Test
    5.70 +	public void testMultipleMatches() throws MalformedQueryException, RepositoryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
    5.71 +	{		
    5.72 +		String queryString = prefixes+
    5.73 +			"SELECT DISTINCT ?name ?mbox \n" +
    5.74 +			"WHERE \n" +
    5.75 +			"{ ?x foaf:name ?name . \n" +
    5.76 +			" ?x foaf:mbox ?mbox ." +
    5.77 +			" } \n";
    5.78 +		
    5.79 +		ArrayList<String> results = (ArrayList <String>) strabon.query(queryString, strabon.getSailRepoConnection());
    5.80 +		assertEquals(11, results.size());
    5.81 +	}
    5.82 +	
    5.83 +	@Test
    5.84 +	public void testMatchingLiterals() throws MalformedQueryException, RepositoryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
    5.85 +	{				
    5.86 +		String queryString = prefixes+
    5.87 +		"SELECT ?v WHERE { ?v ns:p ?s . FILTER(str(?s) = \"cat\") } \n";
    5.88 +//		"SELECT ?v WHERE { ?v ns:p \"cat\" } \n";
    5.89 +		
    5.90 +		ArrayList<String> results = (ArrayList <String>) strabon.query(queryString, strabon.getSailRepoConnection());
    5.91 +		assertEquals(1, results.size());
    5.92 +		assertTrue(-1<results.indexOf("[v=http://example.org#x]"));
    5.93 +	}
    5.94 +	
    5.95 +	@Test
    5.96 +	public void testMatchingLiteralsWithLanguage() throws MalformedQueryException, RepositoryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
    5.97 +	{	
    5.98 +		String queryString = prefixes+
    5.99 +			"SELECT ?v WHERE { ?v ns:p \"cat\"@en } \n";
   5.100 +		
   5.101 +		ArrayList<String> results = (ArrayList <String>) strabon.query(queryString, strabon.getSailRepoConnection());
   5.102 +		assertEquals(1, results.size());
   5.103 +		assertTrue(-1<results.indexOf("[v=http://example.org#x]"));
   5.104 +	}
   5.105 +	
   5.106 +	@Test
   5.107 +	public void testMatchingLiteralsWithNumericTypes() throws MalformedQueryException, RepositoryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   5.108 +	{	
   5.109 +		String queryString = prefixes+
   5.110 +			"SELECT ?v WHERE { ?v ns:p 42 } \n";
   5.111 +		
   5.112 +		ArrayList<String> results = (ArrayList <String>) strabon.query(queryString, strabon.getSailRepoConnection());
   5.113 +		assertEquals(1, results.size());
   5.114 +		assertTrue(-1<results.indexOf("[v=http://example.org#y]"));
   5.115 +	}
   5.116 +	
   5.117 +	@Test
   5.118 +	public void testMatchingLiteralWithArbitraryTypes() throws MalformedQueryException, RepositoryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   5.119 +	{	
   5.120 +		String queryString = prefixes+
   5.121 +			"SELECT ?v WHERE { ?v ?p \"abc\"^^dt:specialDatatype } \n";
   5.122 +		
   5.123 +		ArrayList<String> results = (ArrayList <String>) strabon.query(queryString, strabon.getSailRepoConnection());
   5.124 +		assertEquals(1, results.size());
   5.125 +		assertTrue(-1<results.indexOf("[v=http://example.org#z]"));
   5.126 +	}
   5.127 +
   5.128 +	@Test
   5.129 +	public void testBind() throws MalformedQueryException, RepositoryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   5.130 +	{	
   5.131 +		String queryString = prefixes+
   5.132 +			"SELECT ?name  \n" +
   5.133 +			"WHERE  { \n" +
   5.134 +			" ?P foaf:givenName ?G . \n" +
   5.135 +			" ?P foaf:surname ?S . \n" +
   5.136 +			" BIND( CONCAT(?G, \" \", ?S) AS ?name ) . \n"+
   5.137 +			"} \n";
   5.138 +		
   5.139 +		ArrayList<String> results = (ArrayList<String>) strabon.query(queryString, strabon.getSailRepoConnection());
   5.140 +		assertEquals(1, results.size());
   5.141 +		assertTrue(-1<results.indexOf("[name=\"John Doe\"]"));
   5.142 +	}
   5.143 +
   5.144 +	
   5.145 +	@Test
   5.146 +	public void testConcat() throws MalformedQueryException, RepositoryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   5.147 +	{	
   5.148 +		String queryString = prefixes+
   5.149 +			"SELECT ( CONCAT(?G, \" \", ?S) AS ?name ) \n" +
   5.150 +			"WHERE  { ?P foaf:givenName ?G ; foaf:surname ?S } \n";
   5.151 +		
   5.152 +		ArrayList<String> results = (ArrayList<String>) strabon.query(queryString, strabon.getSailRepoConnection());
   5.153 +		assertEquals(1, results.size());
   5.154 +		assertTrue(-1<results.indexOf("[name=\"John Doe\"]"));
   5.155 +	}
   5.156 +	
   5.157 +	@Test
   5.158 +	public void testOptional() throws MalformedQueryException, RepositoryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   5.159 +	{	
   5.160 +		String queryString = prefixes+
   5.161 +			"SELECT ?name ?mbox \n"+
   5.162 +			"WHERE  { ?x foaf:name  ?name . \n"+
   5.163 +			"	OPTIONAL { ?x  foaf:mbox  ?mbox } \n"+
   5.164 +       		"} \n";
   5.165 +		
   5.166 +		ArrayList<String> results = (ArrayList<String>)strabon.query(queryString, strabon.getSailRepoConnection());
   5.167 +		assertEquals(13, results.size());
   5.168 +		assertTrue(-1<results.indexOf("[name=\"Alice\";mbox=mailto:alice@example.com]"));
   5.169 +		assertTrue(-1<results.indexOf("[name=\"Alice\";mbox=mailto:alice@work.example]"));
   5.170 +		assertTrue(-1<results.indexOf("[name=\"Carol Baz\"]"));
   5.171 +	}
   5.172 +	
   5.173 +	@Test
   5.174 +	public void testOptionalFilter() throws MalformedQueryException, RepositoryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   5.175 +	{	
   5.176 +		String queryString = prefixes+
   5.177 +			"SELECT  ?title ?price \n"+
   5.178 +			"WHERE   { ?x dc:title ?title . \n"+
   5.179 +			"	OPTIONAL { ?x ns:price ?price . FILTER (?price < 30) } \n"+
   5.180 +        	"}\n";
   5.181 +		
   5.182 +		ArrayList<String> results = (ArrayList<String>) strabon.query(queryString, strabon.getSailRepoConnection());
   5.183 +		assertEquals(4, results.size());
   5.184 +		assertTrue(-1<results.indexOf("[title=\"SPARQL Tutorial\"]"));
   5.185 +		assertTrue(-1<results.indexOf("[title=\"SPARQL Protocol Tutorial\"]"));
   5.186 +		assertTrue(-1<results.indexOf("[title=\"SPARQL (updated)\"]"));
   5.187 +		assertTrue(-1<results.indexOf("[title=\"The Semantic Web\";price=\"23\"^^<http://www.w3.org/2001/XMLSchema#integer>]"));
   5.188 +	}
   5.189 +	
   5.190 +	@Test
   5.191 +	public void testTwoOptionals() throws MalformedQueryException, RepositoryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   5.192 +	{	
   5.193 +		String queryString = prefixes+
   5.194 +			"SELECT ?name ?mbox ?hpage \n"+
   5.195 +			"WHERE  { ?x foaf:name  ?name \n"+
   5.196 +			"	OPTIONAL { ?x foaf:mbox ?mbox } . \n"+
   5.197 +			"	OPTIONAL { ?x foaf:homepage ?hpage } . \n"+
   5.198 +       		"} ORDER BY ?name \n";
   5.199 +		
   5.200 +		ArrayList<String> results = (ArrayList<String>)strabon.query(queryString, strabon.getSailRepoConnection());
   5.201 +		assertEquals(13, results.size());
   5.202 +		assertTrue(-1<results.indexOf("[hpage=http://work.example.org/alice/;mbox=mailto:alice@example.com;name=\"A. Foo\"]"));
   5.203 +		assertTrue(-1<results.indexOf("[name=\"Bob\";mbox=mailto:bob@work.example]"));
   5.204 +		assertTrue(-1<results.indexOf("[name=\"C. Baz\"]"));
   5.205 +	}
   5.206 +
   5.207 +	
   5.208 +	@Test
   5.209 +	public void testFilterNotExists() throws MalformedQueryException, RepositoryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   5.210 +	{	
   5.211 +		String queryString = prefixes+
   5.212 +			"SELECT ?person \n"+
   5.213 +			"WHERE { \n"+
   5.214 +			"	?person rdf:type  foaf:Person . \n"+
   5.215 +			"	FILTER NOT EXISTS { ?person foaf:name ?name } . \n"+
   5.216 +			"}    \n";
   5.217 +		
   5.218 +		ArrayList<String> results = (ArrayList<String>) strabon.query(queryString, strabon.getSailRepoConnection());
   5.219 +		assertEquals(0, results.size()); // TODO add such an item
   5.220 +	}
   5.221 +	
   5.222 +	@Test
   5.223 +	public void testFilterExists() throws MalformedQueryException, RepositoryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   5.224 +	{	
   5.225 +		String queryString = prefixes+
   5.226 +			"SELECT ?person \n"+
   5.227 +			"WHERE { \n"+
   5.228 +			"	?person rdf:type  foaf:Person . \n"+
   5.229 +			"	FILTER EXISTS { ?person foaf:name ?name } \n"+
   5.230 +			"} \n";
   5.231 +		
   5.232 +		ArrayList<String> results = (ArrayList<String>) strabon.query(queryString, strabon.getSailRepoConnection());
   5.233 +		assertEquals(2, results.size());
   5.234 +		assertTrue(-1<results.indexOf("[person=http://example.org#bob]"));
   5.235 +		assertTrue(-1<results.indexOf("[person=http://example.org#alice]"));
   5.236 +	}
   5.237 +	
   5.238 +	@Test
   5.239 +	public void testMinus() throws MalformedQueryException, RepositoryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   5.240 +	{	
   5.241 +		String queryString = prefixes+
   5.242 +			"SELECT DISTINCT ?s \n"+
   5.243 +			"WHERE { \n"+
   5.244 +			"	?s ?p ?o . \n"+
   5.245 +			"MINUS { \n"+
   5.246 +			"	?s foaf:givenName \"Bob\" . \n"+
   5.247 +			"} } \n";
   5.248 +		
   5.249 +		ArrayList<String> results = (ArrayList<String>) strabon.query(queryString, strabon.getSailRepoConnection());
   5.250 +		assertEquals(19, results.size());
   5.251 +	}
   5.252 +	
   5.253 +	@Test
   5.254 +	public void testQuerySumGroupByHaving() throws MalformedQueryException, RepositoryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   5.255 +	{	
   5.256 +		String queryString = prefixes+
   5.257 +			"SELECT (SUM(?lprice) AS ?totalPrice) \n"+
   5.258 +			"WHERE { \n"+
   5.259 +			"	?org def:affiliates ?auth . \n"+
   5.260 +			"	?auth def:writesBook ?book . \n"+
   5.261 +			"	?book def:price ?lprice . \n"+
   5.262 +			"} \n" 
   5.263 +			+"GROUP BY ?org HAVING (SUM(?lprice) > 10) \n"
   5.264 +			;
   5.265 +		
   5.266 +		ArrayList<String> results = (ArrayList<String>) strabon.query(queryString, strabon.getSailRepoConnection());
   5.267 +		assertEquals(1, results.size());
   5.268 +		assertTrue(-1<results.indexOf("[totalPrice=\"21\"^^<http://www.w3.org/2001/XMLSchema#integer>]"));
   5.269 +	}
   5.270 +
   5.271 +	@Test
   5.272 +	public void testRegex() throws MalformedQueryException, RepositoryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   5.273 +	{	
   5.274 +		String queryString = prefixes+
   5.275 +			"SELECT  ?title \n"+
   5.276 +			"WHERE   { ?x dc:title ?title \n"+
   5.277 +			"	FILTER regex(?title, \"^SPARQL\") \n"+ 
   5.278 +        	"} ORDER BY ?title\n";
   5.279 +		
   5.280 +		ArrayList<String> results = (ArrayList<String>) strabon.query(queryString, strabon.getSailRepoConnection());
   5.281 +		assertEquals(3, results.size());
   5.282 +		assertTrue(-1<results.indexOf("[title=\"SPARQL Protocol Tutorial\"]"));
   5.283 +		assertTrue(-1<results.indexOf("[title=\"SPARQL Tutorial\"]"));
   5.284 +		assertTrue(-1<results.indexOf("[title=\"SPARQL (updated)\"]"));
   5.285 +	}
   5.286 +	
   5.287 +	@Test
   5.288 +	public void testRegexI() throws MalformedQueryException, RepositoryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   5.289 +	{	
   5.290 +		String queryString = prefixes+
   5.291 +			"SELECT  ?title \n"+
   5.292 +			"WHERE   { ?x dc:title ?title . \n"+
   5.293 +			"	FILTER regex(?title, \"web\", \"i\" ) ."+ 
   5.294 +        	"} \n";
   5.295 +		
   5.296 +		ArrayList<String> results = (ArrayList<String>) strabon.query(queryString, strabon.getSailRepoConnection());
   5.297 +		assertEquals(1, results.size());
   5.298 +		assertTrue(-1<results.indexOf("[title=\"The Semantic Web\"]"));
   5.299 +	}
   5.300 +	
   5.301 +	@Test
   5.302 +	public void testUnionWithCommonObject() throws MalformedQueryException, RepositoryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   5.303 +	{	
   5.304 +		String queryString = prefixes+
   5.305 +			"SELECT ?title \n"+
   5.306 +			"WHERE  { { ?book dc10:title  ?title } UNION { ?book dc11:title  ?title } } \n";
   5.307 +		
   5.308 +		ArrayList<String> results = (ArrayList<String>) strabon.query(queryString, strabon.getSailRepoConnection());
   5.309 +		assertEquals(6, results.size());
   5.310 +		assertTrue(-1<results.indexOf("[title=\"SPARQL Query Language Tutorial\"]"));
   5.311 +		assertTrue(-1<results.indexOf("[title=\"SPARQL\"]"));
   5.312 +		assertTrue(-1<results.indexOf("[title=\"SPARQL Tutorial\"]"));
   5.313 +		assertTrue(-1<results.indexOf("[title=\"The Semantic Web\"]"));
   5.314 +		assertTrue(-1<results.indexOf("[title=\"SPARQL Protocol Tutorial\"]"));
   5.315 +		assertTrue(-1<results.indexOf("[title=\"SPARQL (updated)\"]"));
   5.316 +	}
   5.317 +	
   5.318 +	@Test
   5.319 +	public void testUnionWithDifferenceObject() throws MalformedQueryException, RepositoryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   5.320 +	{	
   5.321 +		String queryString = prefixes+
   5.322 +			"SELECT ?x ?y \n"+
   5.323 +			"WHERE  { { ?book dc10:title  ?x } UNION { ?book dc11:title  ?y } } \n";
   5.324 +		
   5.325 +		ArrayList<String> results = (ArrayList<String>) strabon.query(queryString, strabon.getSailRepoConnection());
   5.326 +		assertEquals(6, results.size());
   5.327 +		assertTrue(-1<results.indexOf("[x=\"SPARQL Query Language Tutorial\"]"));
   5.328 +		assertTrue(-1<results.indexOf("[x=\"SPARQL\"]"));
   5.329 +		assertTrue(-1<results.indexOf("[y=\"SPARQL Tutorial\"]"));
   5.330 +		assertTrue(-1<results.indexOf("[y=\"The Semantic Web\"]"));
   5.331 +		assertTrue(-1<results.indexOf("[y=\"SPARQL Protocol Tutorial\"]"));
   5.332 +		assertTrue(-1<results.indexOf("[y=\"SPARQL (updated)\"]"));
   5.333 +	}
   5.334 +
   5.335 +}
   5.336 \ No newline at end of file
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/runtime/src/test/java/eu/earthobservatory/runtime/generaldb/SpatialTests.java	Fri May 18 13:48:39 2012 +0300
     6.3 @@ -0,0 +1,1143 @@
     6.4 +package eu.earthobservatory.runtime.generaldb;
     6.5 +
     6.6 +import static org.junit.Assert.assertEquals;
     6.7 +import static org.junit.Assert.assertTrue;
     6.8 +import static org.junit.Assert.fail;
     6.9 +
    6.10 +import java.io.IOException;
    6.11 +import java.util.ArrayList;
    6.12 +
    6.13 +import org.junit.AfterClass;
    6.14 +import org.junit.Test;
    6.15 +import org.openrdf.model.vocabulary.RDF;
    6.16 +import org.openrdf.model.vocabulary.XMLSchema;
    6.17 +import org.openrdf.query.MalformedQueryException;
    6.18 +import org.openrdf.query.QueryEvaluationException;
    6.19 +import org.openrdf.query.TupleQueryResultHandlerException;
    6.20 +
    6.21 +import eu.earthobservatory.runtime.generaldb.Strabon;
    6.22 +
    6.23 +public class SpatialTests {
    6.24 +	public static Strabon strabon;
    6.25 +
    6.26 +	public String 	STRDF_NS = "http://strdf.di.uoa.gr/ontology#",
    6.27 +					EX_NS = "http://example.org/",
    6.28 +					NOA_NS = "http://teleios.di.uoa.gr/ontologies/noaOntology.owl#",
    6.29 +					GEOF_NS ="http://www.opengis.net/def/queryLanguage/OGC-GeoSPARQL/1.0/function/";
    6.30 +	
    6.31 +//	@BeforeClass
    6.32 +//	public static void initialize() throws SQLException, ClassNotFoundException
    6.33 +//	{
    6.34 +//		strabon = new Strabon("spatial-tests","postgres","postgres", 5432, "localhost", true);
    6.35 +//	}
    6.36 +
    6.37 +
    6.38 +	protected String prefixes = 
    6.39 +		"PREFIX rdf: <"+RDF.NAMESPACE+"> \n" +
    6.40 +		"PREFIX strdf: <"+STRDF_NS+"> \n" +
    6.41 +		"PREFIX xsd: <"+XMLSchema.NAMESPACE+"> \n" +
    6.42 +		"PREFIX ex: <"+EX_NS+"> \n" +
    6.43 +		"PREFIX noa: <"+NOA_NS+"> \n" +
    6.44 +		"PREFIX geof: <"+GEOF_NS+"> \n";
    6.45 +	
    6.46 +	// -- Spatial Relationships -- //
    6.47 +	
    6.48 +	@Test
    6.49 +	public void testStrdfAnyInteract() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
    6.50 +	{
    6.51 +		String query = 
    6.52 +			prefixes+
    6.53 +			"SELECT DISTINCT ?id1 ?id2 \n"+
    6.54 +			"WHERE { \n" +
    6.55 +			" ?s1 ex:id ?id1 . \n"+
    6.56 +			" ?s2 ex:id ?id2 . \n"+
    6.57 +			" FILTER( str(?id1) < str(?id2) ) . \n"+
    6.58 +			" ?s2 ex:geometry ?g2 . \n" +
    6.59 +			" ?s1 ex:geometry ?g1 . \n"+
    6.60 +			" FILTER( strdf:anyInteract(?g1, ?g2 ) ) . \n"+
    6.61 +			"}";
    6.62 +		
    6.63 +		ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection());
    6.64 +
    6.65 +		assertEquals(4, bindings.size());
    6.66 +		assertTrue(-1<bindings.indexOf("[id2=\"Z\"^^<http://www.w3.org/2001/XMLSchema#string>;id1=\"B\"^^<http://www.w3.org/2001/XMLSchema#string>]"));
    6.67 +		assertTrue(-1<bindings.indexOf("[id2=\"Z\"^^<http://www.w3.org/2001/XMLSchema#string>;id1=\"E\"^^<http://www.w3.org/2001/XMLSchema#string>]"));
    6.68 +		assertTrue(-1<bindings.indexOf("[id2=\"Z\"^^<http://www.w3.org/2001/XMLSchema#string>;id1=\"F\"^^<http://www.w3.org/2001/XMLSchema#string>]"));
    6.69 +		assertTrue(-1<bindings.indexOf("[id2=\"Z\"^^<http://www.w3.org/2001/XMLSchema#string>;id1=\"G\"^^<http://www.w3.org/2001/XMLSchema#string>]"));
    6.70 +	}
    6.71 +	
    6.72 +	@Test
    6.73 +	public void testStrdfContains() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
    6.74 +	{
    6.75 +		String query = 
    6.76 +			prefixes+
    6.77 +			"SELECT DISTINCT ?id1 ?id2 \n"+
    6.78 +			"WHERE { \n" +
    6.79 +			" ?s1 ex:id ?id1 . \n"+
    6.80 +			" ?s2 ex:id ?id2 . \n"+
    6.81 +			" FILTER( str(?id1) != str(?id2) ) . \n"+
    6.82 +			" ?s2 ex:geometry ?g2 . \n" +
    6.83 +			" ?s1 ex:geometry ?g1 . \n"+
    6.84 +			" FILTER( strdf:contains(?g1, ?g2 )) . \n"+
    6.85 +			"}";
    6.86 +		
    6.87 +		ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection());
    6.88 +		assertEquals(2, bindings.size());
    6.89 +		assertTrue(-1<bindings.indexOf("[id2=\"E\"^^<http://www.w3.org/2001/XMLSchema#string>;id1=\"Z\"^^<http://www.w3.org/2001/XMLSchema#string>]"));
    6.90 +		assertTrue(-1<bindings.indexOf("[id2=\"F\"^^<http://www.w3.org/2001/XMLSchema#string>;id1=\"Z\"^^<http://www.w3.org/2001/XMLSchema#string>]"));
    6.91 +	}
    6.92 +	
    6.93 +	@Test
    6.94 +	public void testStrdfCovers() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
    6.95 +	{
    6.96 +		String query = 
    6.97 +			prefixes+
    6.98 +			"SELECT DISTINCT ?id1 ?id2 \n"+
    6.99 +			"WHERE { \n" +
   6.100 +			" ?s1 ex:id ?id1 . \n"+
   6.101 +			" ?s2 ex:id ?id2 . \n"+
   6.102 +			" FILTER( str(?id1) != str(?id2) ) . \n"+
   6.103 +			" ?s2 ex:geometry ?g2 . \n" +
   6.104 +			" ?s1 ex:geometry ?g1 . \n"+
   6.105 +			" FILTER( strdf:covers(?g1, ?g2 )) . \n"+
   6.106 +			"}";
   6.107 +		
   6.108 +		ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection());
   6.109 +		assertEquals(2, bindings.size());
   6.110 +		assertTrue(-1<bindings.indexOf("[id2=\"F\"^^<http://www.w3.org/2001/XMLSchema#string>;id1=\"Z\"^^<http://www.w3.org/2001/XMLSchema#string>]"));
   6.111 +		assertTrue(-1<bindings.indexOf("[id2=\"E\"^^<http://www.w3.org/2001/XMLSchema#string>;id1=\"Z\"^^<http://www.w3.org/2001/XMLSchema#string>]"));
   6.112 +	}
   6.113 +	
   6.114 +	@Test
   6.115 +	public void testStrdfCoveredBy() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   6.116 +	{
   6.117 +		String query = 
   6.118 +			prefixes+
   6.119 +			"SELECT DISTINCT ?id1 ?id2 \n"+
   6.120 +			"WHERE { \n" +
   6.121 +			" ?s1 ex:id ?id1 . \n"+
   6.122 +			" ?s2 ex:id ?id2 . \n"+
   6.123 +			" FILTER( str(?id1) != str(?id2) ) . \n"+
   6.124 +			" ?s2 ex:geometry ?g2 . \n" +
   6.125 +			" ?s1 ex:geometry ?g1 . \n"+
   6.126 +			" FILTER( strdf:coveredBy(?g1, ?g2 )) . \n"+
   6.127 +			"}";
   6.128 +
   6.129 +		ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection());
   6.130 +		assertEquals(2, bindings.size());
   6.131 +		assertTrue(-1<bindings.indexOf("[id2=\"Z\"^^<http://www.w3.org/2001/XMLSchema#string>;id1=\"F\"^^<http://www.w3.org/2001/XMLSchema#string>]"));
   6.132 +		assertTrue(-1<bindings.indexOf("[id2=\"Z\"^^<http://www.w3.org/2001/XMLSchema#string>;id1=\"E\"^^<http://www.w3.org/2001/XMLSchema#string>]"));
   6.133 +	}
   6.134 +
   6.135 +	@Test
   6.136 +	public void testStrdfDisjoint() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   6.137 +	{
   6.138 +		String query = 
   6.139 +			prefixes+
   6.140 +			"SELECT DISTINCT ?s1 ?s2 \n"+
   6.141 +			"WHERE { \n" +
   6.142 +			" ?s1 ex:geometry ?g1 . \n"+
   6.143 +			" ?s2 ex:geometry ?g2 . \n" +
   6.144 +			" FILTER( str(?s1) < str(?s2) ) . \n"+
   6.145 +			" FILTER( strdf:disjoint(?g1, ?g2 )) . \n"+
   6.146 +			"}";
   6.147 +
   6.148 +		ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection());
   6.149 +		assertEquals(40, bindings.size());
   6.150 +		// too many results
   6.151 +		//assertTrue(-1<bindings.indexOf("[s2=http://example.org/pol11;s1=http://example.org/pol1]"));
   6.152 +	}
   6.153 +
   6.154 +	@Test
   6.155 +	public void testStrdfEquals() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   6.156 +	{
   6.157 +		String query = 
   6.158 +			prefixes+
   6.159 +			"SELECT DISTINCT ?s1 ?s2 \n"+
   6.160 +			"WHERE { \n" +
   6.161 +			" ?s1 ex:geometry ?g1 . \n"+
   6.162 +			" ?s2 ex:geometry ?g2 . \n" +
   6.163 +			" FILTER( str(?s1) < str(?s2) ) . \n"+
   6.164 +			" FILTER( strdf:equals(?g1, ?g2 )) . \n"+
   6.165 +			"}";
   6.166 +		
   6.167 +			ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection());
   6.168 +			assertEquals(1, bindings.size());
   6.169 +			assertTrue(-1<bindings.indexOf("[s2=http://example.org/pol11;s1=http://example.org/pol1]"));
   6.170 +		}
   6.171 +
   6.172 +	@Test
   6.173 +	public void testStrdfInside() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   6.174 +	{
   6.175 +		String query = 
   6.176 +			prefixes+
   6.177 +			"SELECT DISTINCT ?id1 ?id2 \n"+
   6.178 +			"WHERE { \n" +
   6.179 +			" ?s1 ex:id ?id1 . \n"+
   6.180 +			" ?s2 ex:id ?id2 . \n"+
   6.181 +			" FILTER( str(?id1) != str(?id2) ) . \n"+
   6.182 +			" ?s2 ex:geometry ?g2 . \n" +
   6.183 +			" ?s1 ex:geometry ?g1 . \n"+
   6.184 +			" FILTER( strdf:inside(?g1, ?g2 )) . \n"+
   6.185 +			"}";
   6.186 +		
   6.187 +			ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection());
   6.188 +			assertEquals(2, bindings.size());
   6.189 +			assertTrue(-1<bindings.indexOf("[id2=\"Z\"^^<http://www.w3.org/2001/XMLSchema#string>;id1=\"E\"^^<http://www.w3.org/2001/XMLSchema#string>]"));
   6.190 +			assertTrue(-1<bindings.indexOf("[id2=\"Z\"^^<http://www.w3.org/2001/XMLSchema#string>;id1=\"F\"^^<http://www.w3.org/2001/XMLSchema#string>]"));
   6.191 +	}
   6.192 +
   6.193 +	@Test
   6.194 +	public void testStrdfOverlap() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   6.195 +	{
   6.196 +		String query = 
   6.197 +			prefixes+
   6.198 +			"SELECT DISTINCT ?id1 ?id2 \n"+
   6.199 +			"WHERE { \n" +
   6.200 +			" ?s1 ex:id ?id1 . \n"+
   6.201 +			" ?s2 ex:id ?id2 . \n"+
   6.202 +			" FILTER( str(?id1) != str(?id2) ) . \n"+
   6.203 +			" ?s2 ex:geometry ?g2 . \n" +
   6.204 +			" ?s1 ex:geometry ?g1 . \n"+
   6.205 +			" FILTER( strdf:overlap(?g1, ?g2 )) . \n"+
   6.206 +			"}";
   6.207 +		
   6.208 +		ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection());
   6.209 +		assertEquals(2, bindings.size());
   6.210 +		assertTrue(-1<bindings.indexOf("[id2=\"Z\"^^<http://www.w3.org/2001/XMLSchema#string>;id1=\"B\"^^<http://www.w3.org/2001/XMLSchema#string>]"));
   6.211 +		assertTrue(-1<bindings.indexOf("[id2=\"B\"^^<http://www.w3.org/2001/XMLSchema#string>;id1=\"Z\"^^<http://www.w3.org/2001/XMLSchema#string>]"));
   6.212 +	}
   6.213 +
   6.214 +	@Test
   6.215 +	public void testStrdfTouch() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   6.216 +	{
   6.217 +		String query = 
   6.218 +			prefixes+
   6.219 +			"SELECT DISTINCT ?id1 ?id2 \n"+
   6.220 +			"WHERE { \n" +
   6.221 +			" ?s1 ex:id ?id1 . \n"+
   6.222 +			" ?s2 ex:id ?id2 . \n"+
   6.223 +			" FILTER( str(?id1) < str(?id2) ) . \n"+
   6.224 +			" ?s2 ex:geometry ?g2 . \n" +
   6.225 +			" ?s1 ex:geometry ?g1 . \n"+
   6.226 +			" FILTER( geof:sf-touches(?g1, ?g2 )) . \n"+
   6.227 +			"}";
   6.228 +		
   6.229 +		ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection());
   6.230 +		assertEquals(1, bindings.size());
   6.231 +		assertTrue(-1<bindings.indexOf("[id2=\"Z\"^^<http://www.w3.org/2001/XMLSchema#string>;id1=\"G\"^^<http://www.w3.org/2001/XMLSchema#string>]"));
   6.232 +	}
   6.233 +	
   6.234 +	@Test
   6.235 +	public void testStrdfRelate() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   6.236 +	{
   6.237 +		String query = 
   6.238 +			prefixes+
   6.239 +			"SELECT DISTINCT ?id1 ?id2 \n"+
   6.240 +			"WHERE { \n" +
   6.241 +			" ?s1 ex:id ?id1 . \n"+
   6.242 +			" ?s2 ex:id ?id2 . \n"+
   6.243 +			" FILTER( str(?id1) != str(?id2) ) . \n"+
   6.244 +			" ?s2 ex:geometry ?g2 . \n" +
   6.245 +			" ?s1 ex:geometry ?g1 . \n"+
   6.246 +			" FILTER( strdf:relate(?g1, ?g2, \"T*F**F***\" )) . \n"+
   6.247 +			"}";
   6.248 +		
   6.249 +		ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection());
   6.250 +		assertEquals(2, bindings.size());
   6.251 +		assertTrue(-1<bindings.indexOf("[id2=\"Z\"^^<http://www.w3.org/2001/XMLSchema#string>;id1=\"E\"^^<http://www.w3.org/2001/XMLSchema#string>]"));
   6.252 +		assertTrue(-1<bindings.indexOf("[id2=\"Z\"^^<http://www.w3.org/2001/XMLSchema#string>;id1=\"F\"^^<http://www.w3.org/2001/XMLSchema#string>]"));	
   6.253 +	}
   6.254 +	
   6.255 +//	TODO these tests run only in postgis
   6.256 +//	@Test
   6.257 +//	public void testStrdfLeft() throws MalformedQueryException, QueryEvaluationException	
   6.258 +//	@Test
   6.259 +//	public void testStrdfRight() throws MalformedQueryException, QueryEvaluationException
   6.260 +//	@Test
   6.261 +//	public void testStrdfAbove() throws MalformedQueryException, QueryEvaluationException	
   6.262 +//	@Test
   6.263 +//	public void testStrdfBelow() throws MalformedQueryException, QueryEvaluationException
   6.264 +	
   6.265 +	// -- Spatial Constructs -- //
   6.266 +	@Test
   6.267 +	public void testStrdfUnion() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   6.268 +	{ 
   6.269 +		String query = 
   6.270 +			prefixes+
   6.271 +			"SELECT DISTINCT ( strdf:union(?g, \"POLYGON((5 3, 10 3, 10 8, 5 8, 5 3))\"^^strdf:WKT) AS ?ret ) \n"+
   6.272 +			"WHERE { \n" +
   6.273 +			" ?s ex:id ?id . \n"+
   6.274 +			" ?s ex:geometry ?g . \n" +
   6.275 +			" FILTER( str(?id) = \"Z\"^^xsd:string ) . \n" +
   6.276 +			"}";
   6.277 +		
   6.278 +		ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection());
   6.279 +		
   6.280 +		assertEquals(1, bindings.size());
   6.281 +		assertTrue(-1<bindings.indexOf("[ret=\"POLYGON ((5 3, 3 3, 3 8, 5 8, 10 8, 10 3, 5 3))\"^^<http://strdf.di.uoa.gr/ontology#WKT>]"));
   6.282 +	}
   6.283 +	
   6.284 +	@Test
   6.285 +	public void testStrdfEnvelopeBuffer() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   6.286 +	{ 
   6.287 +		String query = 
   6.288 +			prefixes+
   6.289 +			"SELECT DISTINCT ( strdf:envelope(strdf:buffer(?g, \"0.5\"^^xsd:float)) AS ?ret ) \n"+
   6.290 +			"WHERE { \n" +
   6.291 +			" ?s ex:id ?id . \n"+
   6.292 +			" ?s ex:geometry ?g . \n" +
   6.293 +			" FILTER( str(?id) = \"C\"^^xsd:string ) . \n" +
   6.294 +			"}";
   6.295 +		
   6.296 +		ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection());
   6.297 +				
   6.298 +		assertEquals(1, bindings.size());
   6.299 +				
   6.300 +		if ( -1<bindings.indexOf("[ret=\"POLYGON ((7.5 0.5, 7.5 2.5, 9.5 2.5, 9.5 0.5, 7.5 0.5))\"^^<http://strdf.di.uoa.gr/ontology#WKT>]") ||
   6.301 +			 -1<bindings.indexOf("[ret=\"POLYGON ((7.542893218813453 0.5428932188134517, 9.457106781186548 0.5428932188134517, 9.457106781186548 2.4571067811865483, 7.542893218813453 2.4571067811865483, 7.542893218813453 0.5428932188134517))\"^^<http://strdf.di.uoa.gr/ontology#WKT>]")
   6.302 +		)
   6.303 +			assertTrue(true);
   6.304 +		else
   6.305 +			fail();
   6.306 +	}
   6.307 +
   6.308 +	@Test
   6.309 +	public void testStrdfConvexHull() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   6.310 +	{
   6.311 +		String query = 
   6.312 +			prefixes+
   6.313 +			"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"+
   6.314 +			"WHERE { \n" +
   6.315 +			" ?s ex:id ?id . \n"+
   6.316 +			" ?s ex:geometry ?g . \n" +
   6.317 +			" FILTER( str(?id) = \"C\"^^xsd:string ) . \n" +
   6.318 +			"}";
   6.319 +		
   6.320 +		ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection());
   6.321 +				
   6.322 +		assertEquals(1, bindings.size());
   6.323 +		assertTrue(-1<bindings.indexOf("[ret=\"POLYGON ((50 5, 10 8, 10 10, 100 190, 150 30, 150 10, 50 5))\"^^<http://strdf.di.uoa.gr/ontology#WKT>]"));
   6.324 +	}
   6.325 +	
   6.326 +	@Test
   6.327 +	public void testStrdfBoundary() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   6.328 +	{ 
   6.329 +		String query = 
   6.330 +			prefixes+
   6.331 +			"SELECT DISTINCT ( strdf:boundary(?g) AS ?ret ) \n"+
   6.332 +			"WHERE { \n" +
   6.333 +			" ?s ex:id ?id . \n"+
   6.334 +			" ?s ex:geometry ?g . \n" +
   6.335 +			" FILTER( str(?id) = \"C\"^^xsd:string ) . \n" +
   6.336 +			"}";
   6.337 +		
   6.338 +		ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection());
   6.339 +				
   6.340 +		assertEquals(1, bindings.size());
   6.341 +		assertTrue(-1<bindings.indexOf("[ret=\"LINESTRING (8 1, 9 1, 9 2, 8 2, 8 1)\"^^<http://strdf.di.uoa.gr/ontology#WKT>]"));	}
   6.342 +
   6.343 +	@Test
   6.344 +	public void testStrdfIntersection() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   6.345 +	{ 
   6.346 +		String query = 
   6.347 +			prefixes+
   6.348 +			"SELECT DISTINCT ( strdf:intersection(?g, \"POLYGON((5 3, 10 3, 10 8, 5 8, 5 3))\"^^strdf:WKT) AS ?ret ) \n"+
   6.349 +			"WHERE { \n" +
   6.350 +			" ?s ex:id ?id . \n"+
   6.351 +			" ?s ex:geometry ?g . \n" +
   6.352 +			" FILTER( str(?id) = \"Z\"^^xsd:string ) . \n" +
   6.353 +			"}";
   6.354 +		
   6.355 +		ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection());
   6.356 +		
   6.357 +		assertEquals(1, bindings.size());
   6.358 +		assertTrue(-1<bindings.indexOf("[ret=\"POLYGON ((10 3, 5 3, 5 8, 10 8, 10 3))\"^^<http://strdf.di.uoa.gr/ontology#WKT>]"));
   6.359 +	}
   6.360 +	
   6.361 +	@Test
   6.362 +	public void testStrdfDifference() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   6.363 +	{ 
   6.364 +		String query = 
   6.365 +			prefixes+
   6.366 +			"SELECT DISTINCT ( strdf:difference(?g, \"POLYGON((5 3, 10 3, 10 8, 5 8, 5 3))\"^^strdf:WKT) AS ?ret ) \n"+
   6.367 +			"WHERE { \n" +
   6.368 +			" ?s ex:id ?id . \n"+
   6.369 +			" ?s ex:geometry ?g . \n" +
   6.370 +			" FILTER( str(?id) = \"Z\"^^xsd:string ) . \n" +
   6.371 +			"}";
   6.372 +		
   6.373 +		ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection());
   6.374 +				
   6.375 +		assertEquals(1, bindings.size());
   6.376 +		assertTrue(-1<bindings.indexOf("[ret=\"POLYGON ((5 3, 3 3, 3 8, 5 8, 5 3))\"^^<http://strdf.di.uoa.gr/ontology#WKT>]"));
   6.377 +	}
   6.378 +
   6.379 +	@Test
   6.380 +	public void testStrdfSymDifference() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   6.381 +	{
   6.382 +	String query = 
   6.383 +		prefixes+
   6.384 +		"SELECT DISTINCT ( strdf:symDifference(?g, \"POLYGON((5 3, 12 3, 12 8, 5 8, 5 3))\"^^strdf:WKT) AS ?ret ) \n"+
   6.385 +		"WHERE { \n" +
   6.386 +		" ?s ex:id ?id . \n"+
   6.387 +		" ?s ex:geometry ?g . \n" +
   6.388 +		" FILTER( str(?id) = \"Z\"^^xsd:string ) . \n" +
   6.389 +		"}";
   6.390 +	
   6.391 +	ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection());
   6.392 +			
   6.393 +	assertEquals(1, bindings.size());
   6.394 +	assertTrue(-1<bindings.indexOf("[ret=\"MULTIPOLYGON (((5 3, 3 3, 3 8, 5 8, 5 3)), ((10 3, 10 8, 12 8, 12 3, 10 3)))\"^^<http://strdf.di.uoa.gr/ontology#WKT>]"));
   6.395 +	}
   6.396 +
   6.397 +//	// -- Spatial Metric Functions -- //
   6.398 +
   6.399 +	@Test
   6.400 +	public void testStrdfDistance() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   6.401 +	{ 
   6.402 +		String query = 
   6.403 +			prefixes+
   6.404 +			"SELECT DISTINCT ( strdf:distance(?g, \"POINT( 10 1 )\"^^strdf:WKT) AS ?ret ) \n"+
   6.405 +			"WHERE { \n" +
   6.406 +			" ?s ex:id ?id . \n"+
   6.407 +			" ?s ex:geometry ?g . \n" +
   6.408 +			" FILTER( str(?id) = \"C\"^^xsd:string ) . \n" +
   6.409 +			"}";
   6.410 +		
   6.411 +		ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection());
   6.412 +				
   6.413 +		assertEquals(1, bindings.size());
   6.414 +		assertTrue(-1<bindings.indexOf("[ret=\"1.0\"^^<http://www.w3.org/2001/XMLSchema#double>]"));
   6.415 +	}
   6.416 +
   6.417 +	@Test
   6.418 +	public void testStrdfArea() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   6.419 +	{
   6.420 +		String query = 
   6.421 +			prefixes+
   6.422 +			"SELECT DISTINCT ( strdf:area(?g) AS ?ret ) \n"+
   6.423 +			"WHERE { \n" +
   6.424 +			" ?s ex:id ?id . \n"+
   6.425 +			" ?s ex:geometry ?g . \n" +
   6.426 +			" FILTER( str(?id) = \"C\"^^xsd:string ) . \n" +
   6.427 +			"}";
   6.428 +		
   6.429 +		ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection());
   6.430 +				
   6.431 +		assertEquals(1, bindings.size());
   6.432 +		assertTrue(-1<bindings.indexOf("[ret=\"1.0\"^^<http://www.w3.org/2001/XMLSchema#double>]"));
   6.433 +	}
   6.434 +
   6.435 +	@Test
   6.436 +	public void testStrdfDimension() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   6.437 +	{
   6.438 +		String query = 
   6.439 +			prefixes+
   6.440 +			"SELECT DISTINCT (strdf:dimension(?g) AS ?ret2) " +
   6.441 +							"(strdf:dimension(strdf:boundary(?g)) AS ?ret1) " +
   6.442 +							"(strdf:dimension(\"POINT(0 0)\"^^strdf:WKT) AS ?ret0) \n"+
   6.443 +			"WHERE { \n" +
   6.444 +			" ?s ex:id ?id . \n"+
   6.445 +			" ?s ex:geometry ?g . \n" +
   6.446 +			" FILTER( str(?id) = \"C\"^^xsd:string ) . \n" +
   6.447 +			"}";
   6.448 +		
   6.449 +		ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection());
   6.450 +		
   6.451 +		assertEquals(1, bindings.size());
   6.452 +		// TODO monetdb returns as dimension only 3 (because of GEOS lib)
   6.453 +		if ( -1<bindings.indexOf("[ret2=\"2\"^^<http://www.w3.org/2001/XMLSchema#int>;ret1=\"1\"^^<http://www.w3.org/2001/XMLSchema#int>;ret0=\"0\"^^<http://www.w3.org/2001/XMLSchema#int>]") ||
   6.454 +				-1<bindings.indexOf("[ret2=\"3\"^^<http://www.w3.org/2001/XMLSchema#int>;ret1=\"3\"^^<http://www.w3.org/2001/XMLSchema#int>;ret0=\"3\"^^<http://www.w3.org/2001/XMLSchema#int>]") )
   6.455 +			assertTrue(true);
   6.456 +		else
   6.457 +			fail();
   6.458 +		
   6.459 +	}
   6.460 +	
   6.461 +	@Test
   6.462 +	public void testStrdfGeometryType() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   6.463 +	{
   6.464 +		String query = 
   6.465 +			prefixes+
   6.466 +			"SELECT DISTINCT (strdf:geometryType(?g) AS ?ret2) " +
   6.467 +							"(strdf:geometryType(strdf:boundary(?g)) AS ?ret1) " +
   6.468 +							"(strdf:geometryType(\"POINT(0 0)\"^^strdf:WKT) AS ?ret0) \n"+
   6.469 +			"WHERE { \n" +
   6.470 +			" ?s ex:id ?id . \n"+
   6.471 +			" ?s ex:geometry ?g . \n" +
   6.472 +			" FILTER( str(?id) = \"C\"^^xsd:string ) . \n" +
   6.473 +			"}";
   6.474 +		
   6.475 +		ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection());
   6.476 +
   6.477 +		assertEquals(1, bindings.size());
   6.478 +		// TODO different results between dbms in strdf:geometryType
   6.479 +		if ( -1<bindings.indexOf("[ret2=\"3\";ret1=\"1\";ret0=\"0\"]") ||
   6.480 +			 -1<bindings.indexOf("[ret2=\"ST_Polygon\";ret1=\"ST_LineString\";ret0=\"ST_Point\"]")	
   6.481 +			)
   6.482 +			assertTrue(true);
   6.483 +		else
   6.484 +			fail();
   6.485 +	}
   6.486 +	
   6.487 +	@Test
   6.488 +	public void testStrdfAsText() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   6.489 +	{
   6.490 +		String query = 
   6.491 +			prefixes+
   6.492 +			"SELECT DISTINCT (strdf:asText(?g) AS ?ret2) " +
   6.493 +							"(strdf:asText(strdf:boundary(?g)) AS ?ret1) " +
   6.494 +							"(strdf:asText(\"POINT(0 0)\"^^strdf:WKT) AS ?ret0) \n"+
   6.495 +			"WHERE { \n" +
   6.496 +			" ?s ex:id ?id . \n"+
   6.497 +			" ?s ex:geometry ?g . \n" +
   6.498 +			" FILTER( str(?id) = \"C\"^^xsd:string ) . \n" +
   6.499 +			"}";
   6.500 +		
   6.501 +		ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection());
   6.502 +
   6.503 +		assertEquals(1, bindings.size());
   6.504 +		if ( -1<bindings.indexOf("[ret2=\"POLYGON((8 1,9 1,9 2,8 2,8 1))\";ret1=\"LINESTRING(8 1,9 1,9 2,8 2,8 1)\";ret0=\"POINT(0 0)\"]") ||
   6.505 +				-1<bindings.indexOf("[ret2=\"POLYGON ((8.0000000000000000 1.0000000000000000, 9.0000000000000000 1.0000000000000000, 9.0000000000000000 2.0000000000000000, 8.0000000000000000 2.0000000000000000, 8.0000000000000000 1.0000000000000000))\";ret1=\"LINESTRING (8.0000000000000000 1.0000000000000000, 9.0000000000000000 1.0000000000000000, 9.0000000000000000 2.0000000000000000, 8.0000000000000000 2.0000000000000000, 8.0000000000000000 1.0000000000000000)\";ret0=\"POINT (0.0000000000000000 0.0000000000000000)\"]")
   6.506 +			)
   6.507 +			assertTrue(true);
   6.508 +		else
   6.509 +			fail();
   6.510 +		
   6.511 +	}
   6.512 +	
   6.513 +	@Test
   6.514 +	public void testStrdfSrid() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   6.515 +	{
   6.516 +		String query = 
   6.517 +			prefixes+
   6.518 +			"SELECT DISTINCT (strdf:srid(?g) AS ?ret2) " +
   6.519 +							"(strdf:srid(strdf:boundary(?g)) AS ?ret1) " +
   6.520 +							"(strdf:srid(\"POINT(0 0)\"^^strdf:WKT) AS ?ret0) \n"+
   6.521 +			"WHERE { \n" +
   6.522 +			" ?s ex:id ?id . \n"+
   6.523 +			" ?s ex:geometry ?g . \n" +
   6.524 +			" FILTER( str(?id) = \"C\"^^xsd:string ) . \n" +
   6.525 +			"}";
   6.526 +		
   6.527 +		ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection());
   6.528 +		// TODO test srid uri arguments
   6.529 +		assertEquals(1, bindings.size());		
   6.530 +		if 	( -1<bindings.indexOf("[ret2=\"4326\"^^<http://www.w3.org/2001/XMLSchema#int>;ret1=\"4326\"^^<http://www.w3.org/2001/XMLSchema#int>;ret0=\"4326\"^^<http://www.w3.org/2001/XMLSchema#int>]") ||
   6.531 +				-1<bindings.indexOf("[ret2=\"0\"^^<http://www.w3.org/2001/XMLSchema#int>;ret1=\"0\"^^<http://www.w3.org/2001/XMLSchema#int>;ret0=\"0\"^^<http://www.w3.org/2001/XMLSchema#int>]")
   6.532 +			) 
   6.533 +			assertTrue(true);
   6.534 +		else
   6.535 +			fail();
   6.536 +	}
   6.537 +	
   6.538 +	@Test
   6.539 +	public void testStrdfIsEmpty() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   6.540 +	{
   6.541 +		String query =
   6.542 +			prefixes+
   6.543 +			"SELECT DISTINCT (strdf:isEmpty(?g) AS ?ret2) " +
   6.544 +							"(strdf:isEmpty(strdf:boundary(?g)) AS ?ret1) " +
   6.545 +							"(strdf:isEmpty(\"POINT(0 0)\"^^strdf:WKT) AS ?ret0) \n"+
   6.546 +			"WHERE { \n" +
   6.547 +			" ?s ex:id ?id . \n"+
   6.548 +			" ?s ex:geometry ?g . \n" +
   6.549 +			" FILTER( str(?id) = \"C\"^^xsd:string ) . \n" +
   6.550 +			"}";
   6.551 +	
   6.552 +	ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection());
   6.553 +
   6.554 +	assertEquals(1, bindings.size());		
   6.555 +	assertTrue(-1<bindings.indexOf("[ret2=\"false\"^^<http://www.w3.org/2001/XMLSchema#boolean>;ret1=\"false\"^^<http://www.w3.org/2001/XMLSchema#boolean>;ret0=\"false\"^^<http://www.w3.org/2001/XMLSchema#boolean>]"));
   6.556 +	}
   6.557 +	
   6.558 +	@Test
   6.559 +	public void testStrdfIsSimple() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   6.560 +	{
   6.561 +		String query =
   6.562 +			prefixes+
   6.563 +			"SELECT DISTINCT (strdf:isSimple(?g) AS ?ret2) " +
   6.564 +							"(strdf:isSimple(strdf:boundary(?g)) AS ?ret1) " +
   6.565 +							"(strdf:isSimple(\"POINT(0 0)\"^^strdf:WKT) AS ?ret0) \n"+
   6.566 +			"WHERE { \n" +
   6.567 +			" ?s ex:id ?id . \n"+
   6.568 +			" ?s ex:geometry ?g . \n" +
   6.569 +			" FILTER( str(?id) = \"C\"^^xsd:string ) . \n" +
   6.570 +			"}";
   6.571 +	
   6.572 +	ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection());
   6.573 +
   6.574 +	assertEquals(1, bindings.size());		
   6.575 +	assertTrue(-1<bindings.indexOf("[ret2=\"true\"^^<http://www.w3.org/2001/XMLSchema#boolean>;ret1=\"true\"^^<http://www.w3.org/2001/XMLSchema#boolean>;ret0=\"true\"^^<http://www.w3.org/2001/XMLSchema#boolean>]"));
   6.576 +	}
   6.577 +	
   6.578 +	// -- GEOSPARQL -- //
   6.579 +	
   6.580 +	// -- Non-topological -- //
   6.581 +	
   6.582 +	@Test
   6.583 +	public void testGeofConvexHull() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   6.584 +	{ 
   6.585 +		String query = 
   6.586 +			prefixes+
   6.587 +			"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"+
   6.588 +			"WHERE { \n" +
   6.589 +			" ?s ex:id ?id . \n"+
   6.590 +			" ?s ex:geometry ?g . \n" +
   6.591 +			" FILTER( str(?id) = \"C\"^^xsd:string ) . \n" +
   6.592 +			"}";
   6.593 +		
   6.594 +		ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection());
   6.595 +				
   6.596 +		assertEquals(1, bindings.size());
   6.597 +		assertTrue(-1<bindings.indexOf("[ret=\"POLYGON ((50 5, 10 8, 10 10, 100 190, 150 30, 150 10, 50 5))\"^^<http://strdf.di.uoa.gr/ontology#WKT>]"));
   6.598 +	}
   6.599 +	
   6.600 +	@Test
   6.601 +	public void testGeofIntersection() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   6.602 +	{ 
   6.603 +		String query = 
   6.604 +			prefixes+
   6.605 +			"SELECT DISTINCT ( geof:intersection(?g, \"POLYGON((5 3, 10 3, 10 8, 5 8, 5 3))\"^^strdf:WKT) AS ?ret ) \n"+
   6.606 +			"WHERE { \n" +
   6.607 +			" ?s ex:id ?id . \n"+
   6.608 +			" ?s ex:geometry ?g . \n" +
   6.609 +			" FILTER( str(?id) = \"Z\"^^xsd:string ) . \n" +
   6.610 +			"}";
   6.611 +		
   6.612 +		ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection());
   6.613 +		
   6.614 +		assertEquals(1, bindings.size());
   6.615 +		assertTrue(-1<bindings.indexOf("[ret=\"POLYGON ((10 3, 5 3, 5 8, 10 8, 10 3))\"^^<http://strdf.di.uoa.gr/ontology#WKT>]"));
   6.616 +	}
   6.617 +	
   6.618 +	@Test
   6.619 +	public void testGeofDifference() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   6.620 +	{ 
   6.621 +		String query = 
   6.622 +			prefixes+
   6.623 +			"SELECT DISTINCT ( geof:difference(?g, \"POLYGON((5 3, 10 3, 10 8, 5 8, 5 3))\"^^strdf:WKT) AS ?ret ) \n"+
   6.624 +			"WHERE { \n" +
   6.625 +			" ?s ex:id ?id . \n"+
   6.626 +			" ?s ex:geometry ?g . \n" +
   6.627 +			" FILTER( str(?id) = \"Z\"^^xsd:string ) . \n" +
   6.628 +			"}";
   6.629 +		
   6.630 +		ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection());
   6.631 +				
   6.632 +		assertEquals(1, bindings.size());
   6.633 +		assertTrue(-1<bindings.indexOf("[ret=\"POLYGON ((5 3, 3 3, 3 8, 5 8, 5 3))\"^^<http://strdf.di.uoa.gr/ontology#WKT>]"));
   6.634 +	}
   6.635 +
   6.636 +	@Test
   6.637 +	public void testGeofSymDifference() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   6.638 +	{
   6.639 +	String query = 
   6.640 +		prefixes+
   6.641 +		"SELECT DISTINCT ( geof:symmetricDifference(?g, \"POLYGON((5 3, 12 3, 12 8, 5 8, 5 3))\"^^strdf:WKT) AS ?ret ) \n"+
   6.642 +		"WHERE { \n" +
   6.643 +		" ?s ex:id ?id . \n"+
   6.644 +		" ?s ex:geometry ?g . \n" +
   6.645 +		" FILTER( str(?id) = \"Z\"^^xsd:string ) . \n" +
   6.646 +		"}";
   6.647 +	
   6.648 +	ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection());
   6.649 +			
   6.650 +	assertEquals(1, bindings.size());
   6.651 +	assertTrue(-1<bindings.indexOf("[ret=\"MULTIPOLYGON (((5 3, 3 3, 3 8, 5 8, 5 3)), ((10 3, 10 8, 12 8, 12 3, 10 3)))\"^^<http://strdf.di.uoa.gr/ontology#WKT>]"));
   6.652 +	}
   6.653 +
   6.654 +	@Test
   6.655 +	public void testGeofEnvelope() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   6.656 +	{
   6.657 +		String query = 
   6.658 +			prefixes+
   6.659 +			"SELECT DISTINCT ( strdf:envelope(strdf:buffer(?g, \"0.5\"^^xsd:float)) AS ?ret ) \n"+
   6.660 +			"WHERE { \n" +
   6.661 +			" ?s ex:id ?id . \n"+
   6.662 +			" ?s ex:geometry ?g . \n" +
   6.663 +			" FILTER( str(?id) = \"C\"^^xsd:string ) . \n" +
   6.664 +			"}";
   6.665 +		
   6.666 +		ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection());
   6.667 +				
   6.668 +		assertEquals(1, bindings.size());
   6.669 +				
   6.670 +		if ( -1<bindings.indexOf("[ret=\"POLYGON ((7.5 0.5, 7.5 2.5, 9.5 2.5, 9.5 0.5, 7.5 0.5))\"^^<http://strdf.di.uoa.gr/ontology#WKT>]") ||
   6.671 +			 -1<bindings.indexOf("[ret=\"POLYGON ((7.542893218813453 0.5428932188134517, 9.457106781186548 0.5428932188134517, 9.457106781186548 2.4571067811865483, 7.542893218813453 2.4571067811865483, 7.542893218813453 0.5428932188134517))\"^^<http://strdf.di.uoa.gr/ontology#WKT>]")
   6.672 +		)
   6.673 +			assertTrue(true);
   6.674 +		else
   6.675 +			fail();
   6.676 +	}
   6.677 +	
   6.678 +//	@Test
   6.679 +//	public void testGeofEnvelopeBuffer() throws MalformedQueryException, QueryEvaluationException
   6.680 +//	{ // TODO 3 arguments
   6.681 +//		String query = 
   6.682 +//			prefixes+
   6.683 +//			"SELECT DISTINCT ( geof:envelope(geof:buffer(?g, \"1.0\"^^xsd:float)) AS ?ret ) \n"+
   6.684 +//			"WHERE { \n" +
   6.685 +//			" ?s noa:hasGeometry ?g . \n"+
   6.686 +//			" ?s ex:id ?id . \n"+
   6.687 +//			"}";
   6.688 +//		
   6.689 +//		ArrayList<String> bindings = strabon.query(query,strabon.getSailRepoConnection());
   6.690 +//				
   6.691 +//		assertTrue(-1<bindings.indexOf("[ret=\"POLYGON ((0 -1, 0 1, 2 1, 2 -1, 0 -1))\"^^<http://strdf.di.uoa.gr/ontology#WKT>]"));
   6.692 +//		assertTrue(-1<bindings.indexOf("[ret=\"POLYGON ((1 -1, 1 1, 3 1, 3 -1, 1 -1))\"^^<http://strdf.di.uoa.gr/ontology#WKT>]"));
   6.693 +//		assertTrue(-1<bindings.indexOf("[ret=\"POLYGON ((2 -1, 2 1, 4 1, 4 -1, 2 -1))\"^^<http://strdf.di.uoa.gr/ontology#WKT>]"));
   6.694 +//	}
   6.695 +	
   6.696 +	//Simple Features - 8 functions - all with 2 arguments + boolean
   6.697 +	
   6.698 +	@Test
   6.699 +	public void testGeofSfEquals() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   6.700 +	{
   6.701 +		String query = 
   6.702 +			prefixes+
   6.703 +			"SELECT DISTINCT ?s1 ?s2 \n"+
   6.704 +			"WHERE { \n" +
   6.705 +			" ?s1 ex:geometry ?g1 . \n"+
   6.706 +			" ?s2 ex:geometry ?g2 . \n" +
   6.707 +			" FILTER( str(?s1) < str(?s2) ) . \n"+
   6.708 +			" FILTER( geof:sf-equals(?g1, ?g2 )) . \n"+
   6.709 +			"}";
   6.710 +		
   6.711 +		ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection());
   6.712 +		assertEquals(1, bindings.size());
   6.713 +		assertTrue(-1<bindings.indexOf("[s2=http://example.org/pol11;s1=http://example.org/pol1]"));
   6.714 +	}
   6.715 +	
   6.716 +	@Test
   6.717 +	public void testGeofSfDisjoint() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   6.718 +	{
   6.719 +		String query = 
   6.720 +			prefixes+
   6.721 +			"SELECT DISTINCT ?s1 ?s2 \n"+
   6.722 +			"WHERE { \n" +
   6.723 +			" ?s1 ex:geometry ?g1 . \n"+
   6.724 +			" ?s2 ex:geometry ?g2 . \n" +
   6.725 +			" FILTER( str(?s1) < str(?s2) ) . \n"+
   6.726 +			" FILTER( geof:sf-disjoint(?g1, ?g2 )) . \n"+
   6.727 +			"}";
   6.728 +		
   6.729 +		ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection());
   6.730 +		assertEquals(40, bindings.size());
   6.731 +		// too many results :)
   6.732 +//		assertTrue(-1<bindings.indexOf("[s2=http://example.org/pol11;s1=http://example.org/pol1]"));
   6.733 +	}
   6.734 +	
   6.735 +	@Test
   6.736 +	public void testGeofSfIntesects() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   6.737 +	{
   6.738 +		String query = 
   6.739 +			prefixes+
   6.740 +			"SELECT DISTINCT ?id1 ?id2 \n"+
   6.741 +			"WHERE { \n" +
   6.742 +			" ?s1 ex:id ?id1 . \n"+
   6.743 +			" ?s2 ex:id ?id2 . \n"+
   6.744 +			" FILTER( str(?id1) < str(?id2) ) . \n"+
   6.745 +			" ?s2 ex:geometry ?g2 . \n" +
   6.746 +			" ?s1 ex:geometry ?g1 . \n"+
   6.747 +			" FILTER( geof:sf-intersects(?g1, ?g2 )) . \n"+
   6.748 +			"}";
   6.749 +		
   6.750 +		ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection());
   6.751 +		assertEquals(4, bindings.size());
   6.752 +		assertTrue(-1<bindings.indexOf("[id2=\"Z\"^^<http://www.w3.org/2001/XMLSchema#string>;id1=\"B\"^^<http://www.w3.org/2001/XMLSchema#string>]"));
   6.753 +		assertTrue(-1<bindings.indexOf("[id2=\"Z\"^^<http://www.w3.org/2001/XMLSchema#string>;id1=\"E\"^^<http://www.w3.org/2001/XMLSchema#string>]"));
   6.754 +		assertTrue(-1<bindings.indexOf("[id2=\"Z\"^^<http://www.w3.org/2001/XMLSchema#string>;id1=\"F\"^^<http://www.w3.org/2001/XMLSchema#string>]"));
   6.755 +		assertTrue(-1<bindings.indexOf("[id2=\"Z\"^^<http://www.w3.org/2001/XMLSchema#string>;id1=\"G\"^^<http://www.w3.org/2001/XMLSchema#string>]"));
   6.756 +	}
   6.757 +	
   6.758 +	@Test
   6.759 +	public void testGeofSfTouches() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   6.760 +	{
   6.761 +		String query = 
   6.762 +			prefixes+
   6.763 +			"SELECT DISTINCT ?id1 ?id2 \n"+
   6.764 +			"WHERE { \n" +
   6.765 +			" ?s1 ex:id ?id1 . \n"+
   6.766 +			" ?s2 ex:id ?id2 . \n"+
   6.767 +			" FILTER( str(?id1) < str(?id2) ) . \n"+
   6.768 +			" ?s2 ex:geometry ?g2 . \n" +
   6.769 +			" ?s1 ex:geometry ?g1 . \n"+
   6.770 +			" FILTER( geof:sf-touches(?g1, ?g2 )) . \n"+
   6.771 +			"}";
   6.772 +		
   6.773 +		ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection());
   6.774 +		assertEquals(1, bindings.size());
   6.775 +		assertTrue(-1<bindings.indexOf("[id2=\"Z\"^^<http://www.w3.org/2001/XMLSchema#string>;id1=\"G\"^^<http://www.w3.org/2001/XMLSchema#string>]"));
   6.776 +	}
   6.777 +	
   6.778 +	@Test
   6.779 +	public void testGeofSfCrosses() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   6.780 +	{
   6.781 +		String query = 
   6.782 +			prefixes+
   6.783 +			"SELECT DISTINCT ?id1 ?id2 \n"+
   6.784 +			"WHERE { \n" +
   6.785 +			" ?s1 ex:id ?id1 . \n"+
   6.786 +			" ?s2 ex:id ?id2 . \n"+
   6.787 +			" FILTER( str(?id1) != str(?id2) ) . \n"+
   6.788 +			" ?s2 ex:geometry ?g2 . \n" +
   6.789 +			" ?s1 ex:geometry ?g1 . \n"+
   6.790 +			" FILTER( geof:sf-crosses(?g1, ?g2 )) . \n"+
   6.791 +			"}";
   6.792 +		
   6.793 +		ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection());
   6.794 +		assertEquals(4, bindings.size());
   6.795 +		assertTrue(-1<bindings.indexOf("[id2=\"Z\"^^<http://www.w3.org/2001/XMLSchema#string>;id1=\"B\"^^<http://www.w3.org/2001/XMLSchema#string>]"));
   6.796 +		assertTrue(-1<bindings.indexOf("[id2=\"B\"^^<http://www.w3.org/2001/XMLSchema#string>;id1=\"Z\"^^<http://www.w3.org/2001/XMLSchema#string>]"));
   6.797 +		assertTrue(-1<bindings.indexOf("[id2=\"E\"^^<http://www.w3.org/2001/XMLSchema#string>;id1=\"Z\"^^<http://www.w3.org/2001/XMLSchema#string>]"));
   6.798 +		assertTrue(-1<bindings.indexOf("[id2=\"F\"^^<http://www.w3.org/2001/XMLSchema#string>;id1=\"Z\"^^<http://www.w3.org/2001/XMLSchema#string>]"));
   6.799 +	}
   6.800 +	
   6.801 +	@Test
   6.802 +	public void testGeofSfWithin() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   6.803 +	{
   6.804 +		String query = 
   6.805 +			prefixes+
   6.806 +			"SELECT DISTINCT ?id1 ?id2 \n"+
   6.807 +			"WHERE { \n" +
   6.808 +			" ?s1 ex:id ?id1 . \n"+
   6.809 +			" ?s2 ex:id ?id2 . \n"+
   6.810 +			" FILTER( str(?id1) != str(?id2) ) . \n"+
   6.811 +			" ?s2 ex:geometry ?g2 . \n" +
   6.812 +			" ?s1 ex:geometry ?g1 . \n"+
   6.813 +			" FILTER( geof:sf-within(?g1, ?g2 )) . \n"+
   6.814 +			"}";
   6.815 +		
   6.816 +		ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection());
   6.817 +		assertEquals(2, bindings.size());
   6.818 +		assertTrue(-1<bindings.indexOf("[id2=\"Z\"^^<http://www.w3.org/2001/XMLSchema#string>;id1=\"F\"^^<http://www.w3.org/2001/XMLSchema#string>]"));
   6.819 +		assertTrue(-1<bindings.indexOf("[id2=\"Z\"^^<http://www.w3.org/2001/XMLSchema#string>;id1=\"E\"^^<http://www.w3.org/2001/XMLSchema#string>]"));
   6.820 +	}
   6.821 +	
   6.822 +	@Test
   6.823 +	public void testGeofSfContains() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   6.824 +	{
   6.825 +		String query = 
   6.826 +			prefixes+
   6.827 +			"SELECT DISTINCT ?id1 ?id2 \n"+
   6.828 +			"WHERE { \n" +
   6.829 +			" ?s1 ex:id ?id1 . \n"+
   6.830 +			" ?s2 ex:id ?id2 . \n"+
   6.831 +			" FILTER( str(?id1) != str(?id2) ) . \n"+
   6.832 +			" ?s2 ex:geometry ?g2 . \n" +
   6.833 +			" ?s1 ex:geometry ?g1 . \n"+
   6.834 +			" FILTER( geof:sf-contains(?g1, ?g2 )) . \n"+
   6.835 +			"}";
   6.836 +		
   6.837 +		ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection());
   6.838 +		assertEquals(2, bindings.size());
   6.839 +		assertTrue(-1<bindings.indexOf("[id2=\"E\"^^<http://www.w3.org/2001/XMLSchema#string>;id1=\"Z\"^^<http://www.w3.org/2001/XMLSchema#string>]"));
   6.840 +		assertTrue(-1<bindings.indexOf("[id2=\"F\"^^<http://www.w3.org/2001/XMLSchema#string>;id1=\"Z\"^^<http://www.w3.org/2001/XMLSchema#string>]"));
   6.841 +	}
   6.842 +	
   6.843 +	@Test
   6.844 +	public void testGeofSfOverlaps() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   6.845 +	{
   6.846 +		String query = 
   6.847 +			prefixes+
   6.848 +			"SELECT DISTINCT ?id1 ?id2 \n"+
   6.849 +			"WHERE { \n" +
   6.850 +			" ?s1 ex:id ?id1 . \n"+
   6.851 +			" ?s2 ex:id ?id2 . \n"+
   6.852 +			" FILTER( str(?id1) != str(?id2) ) . \n"+
   6.853 +			" ?s2 ex:geometry ?g2 . \n" +
   6.854 +			" ?s1 ex:geometry ?g1 . \n"+
   6.855 +			" FILTER( geof:sf-overlaps(?g1, ?g2 )) . \n"+
   6.856 +			"}";
   6.857 +		
   6.858 +		ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection());
   6.859 +		assertEquals(2, bindings.size());
   6.860 +		assertTrue(-1<bindings.indexOf("[id2=\"Z\"^^<http://www.w3.org/2001/XMLSchema#string>;id1=\"B\"^^<http://www.w3.org/2001/XMLSchema#string>]"));
   6.861 +		assertTrue(-1<bindings.indexOf("[id2=\"B\"^^<http://www.w3.org/2001/XMLSchema#string>;id1=\"Z\"^^<http://www.w3.org/2001/XMLSchema#string>]"));
   6.862 +	}
   6.863 +	
   6.864 +	//Egenhofer - 8 functions - all with 2 arguments + boolean
   6.865 +	
   6.866 +	@Test
   6.867 +	public void testGeofEhEquals() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   6.868 +	{
   6.869 +		String query = 
   6.870 +			prefixes+
   6.871 +			"SELECT DISTINCT ?s1 ?s2 \n"+
   6.872 +			"WHERE { \n" +
   6.873 +			" ?s1 ex:geometry ?g1 . \n"+
   6.874 +			" ?s2 ex:geometry ?g2 . \n" +
   6.875 +			" FILTER( str(?s1) < str(?s2) ) . \n"+
   6.876 +			" FILTER( geof:eh-equals(?g1, ?g2 )) . \n"+
   6.877 +			"}";
   6.878 +		
   6.879 +		ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection());
   6.880 +		assertEquals(1, bindings.size());
   6.881 +		assertTrue(-1<bindings.indexOf("[s2=http://example.org/pol11;s1=http://example.org/pol1]"));
   6.882 +	}
   6.883 +	
   6.884 +	@Test
   6.885 +	public void testGeofEhDisjoint() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   6.886 +	{
   6.887 +		String query = 
   6.888 +			prefixes+
   6.889 +			"SELECT DISTINCT ?s1 ?s2 \n"+
   6.890 +			"WHERE { \n" +
   6.891 +			" ?s1 ex:geometry ?g1 . \n"+
   6.892 +			" ?s2 ex:geometry ?g2 . \n" +
   6.893 +			" FILTER( str(?s1) < str(?s2) ) . \n"+
   6.894 +			" FILTER( geof:eh-disjoint(?g1, ?g2 )) . \n"+
   6.895 +			"}";
   6.896 +		
   6.897 +		ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection());
   6.898 +		assertEquals(40, bindings.size());
   6.899 +		// too many results :)
   6.900 +//		assertTrue(-1<bindings.indexOf("[s2=http://example.org/pol11;s1=http://example.org/pol1]"));
   6.901 +	}
   6.902 +	
   6.903 +	@Test
   6.904 +	public void testGeofEhMeet() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   6.905 +	{
   6.906 +		String query = 
   6.907 +			prefixes+
   6.908 +			"SELECT DISTINCT ?id1 ?id2 \n"+
   6.909 +			"WHERE { \n" +
   6.910 +			" ?s1 ex:id ?id1 . \n"+
   6.911 +			" ?s2 ex:id ?id2 . \n"+
   6.912 +			" FILTER( str(?id1) != str(?id2) ) . \n"+
   6.913 +			" ?s2 ex:geometry ?g2 . \n" +
   6.914 +			" ?s1 ex:geometry ?g1 . \n"+
   6.915 +			" FILTER( geof:eh-meet(?g1, ?g2 )) . \n"+
   6.916 +			"}";
   6.917 +		
   6.918 +		ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection());
   6.919 +		assertEquals(2, bindings.size());
   6.920 +		assertTrue(-1<bindings.indexOf("[id2=\"Z\"^^<http://www.w3.org/2001/XMLSchema#string>;id1=\"G\"^^<http://www.w3.org/2001/XMLSchema#string>]"));
   6.921 +		assertTrue(-1<bindings.indexOf("[id2=\"G\"^^<http://www.w3.org/2001/XMLSchema#string>;id1=\"Z\"^^<http://www.w3.org/2001/XMLSchema#string>]"));
   6.922 +	}
   6.923 +	
   6.924 +	@Test
   6.925 +	public void testGeofEhOverlap() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   6.926 +	{
   6.927 +		String query = 
   6.928 +			prefixes+
   6.929 +			"SELECT DISTINCT ?id1 ?id2 \n"+
   6.930 +			"WHERE { \n" +
   6.931 +			" ?s1 ex:id ?id1 . \n"+
   6.932 +			" ?s2 ex:id ?id2 . \n"+
   6.933 +			" FILTER( str(?id1) != str(?id2) ) . \n"+
   6.934 +			" ?s2 ex:geometry ?g2 . \n" +
   6.935 +			" ?s1 ex:geometry ?g1 . \n"+
   6.936 +			" FILTER( geof:eh-overlap(?g1, ?g2 )) . \n"+
   6.937 +			"}";
   6.938 +		
   6.939 +		ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection());
   6.940 +		assertEquals(2, bindings.size());
   6.941 +		assertTrue(-1<bindings.indexOf("[id2=\"Z\"^^<http://www.w3.org/2001/XMLSchema#string>;id1=\"B\"^^<http://www.w3.org/2001/XMLSchema#string>]"));
   6.942 +		assertTrue(-1<bindings.indexOf("[id2=\"B\"^^<http://www.w3.org/2001/XMLSchema#string>;id1=\"Z\"^^<http://www.w3.org/2001/XMLSchema#string>]"));
   6.943 +	}
   6.944 +	
   6.945 +	@Test
   6.946 +	public void testGeofEhCovers() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   6.947 +	{
   6.948 +		String query = 
   6.949 +			prefixes+
   6.950 +			"SELECT DISTINCT ?id1 ?id2 \n"+
   6.951 +			"WHERE { \n" +
   6.952 +			" ?s1 ex:id ?id1 . \n"+
   6.953 +			" ?s2 ex:id ?id2 . \n"+
   6.954 +			" FILTER( str(?id1) != str(?id2) ) . \n"+
   6.955 +			" ?s2 ex:geometry ?g2 . \n" +
   6.956 +			" ?s1 ex:geometry ?g1 . \n"+
   6.957 +			" FILTER( geof:eh-covers(?g1, ?g2 )) . \n"+
   6.958 +			"}";
   6.959 +		
   6.960 +		ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection());
   6.961 +		assertEquals(1, bindings.size());
   6.962 +		assertTrue(-1<bindings.indexOf("[id2=\"F\"^^<http://www.w3.org/2001/XMLSchema#string>;id1=\"Z\"^^<http://www.w3.org/2001/XMLSchema#string>]"));
   6.963 +	}
   6.964 +	
   6.965 +	@Test
   6.966 +	public void testGeofEhCoveredBy() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   6.967 +	{
   6.968 +		String query = 
   6.969 +			prefixes+
   6.970 +			"SELECT DISTINCT ?id1 ?id2 \n"+
   6.971 +			"WHERE { \n" +
   6.972 +			" ?s1 ex:id ?id1 . \n"+
   6.973 +			" ?s2 ex:id ?id2 . \n"+
   6.974 +			" FILTER( str(?id1) != str(?id2) ) . \n"+
   6.975 +			" ?s2 ex:geometry ?g2 . \n" +
   6.976 +			" ?s1 ex:geometry ?g1 . \n"+
   6.977 +			" FILTER( geof:eh-coveredBy(?g1, ?g2 )) . \n"+
   6.978 +			"}";
   6.979 +		
   6.980 +		ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection());
   6.981 +		assertEquals(1, bindings.size());
   6.982 +		assertTrue(-1<bindings.indexOf("[id2=\"Z\"^^<http://www.w3.org/2001/XMLSchema#string>;id1=\"F\"^^<http://www.w3.org/2001/XMLSchema#string>]"));
   6.983 +	}
   6.984 +	
   6.985 +	@Test
   6.986 +	public void testGeofEhInside() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   6.987 +	{
   6.988 +		String query = 
   6.989 +			prefixes+
   6.990 +			"SELECT DISTINCT ?id1 ?id2 \n"+
   6.991 +			"WHERE { \n" +
   6.992 +			" ?s1 ex:id ?id1 . \n"+
   6.993 +			" ?s2 ex:id ?id2 . \n"+
   6.994 +			" FILTER( str(?id1) != str(?id2) ) . \n"+
   6.995 +			" ?s2 ex:geometry ?g2 . \n" +
   6.996 +			" ?s1 ex:geometry ?g1 . \n"+
   6.997 +			" FILTER( geof:eh-inside(?g1, ?g2 )) . \n"+
   6.998 +			"}";
   6.999 +		
  6.1000 +		ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection());
  6.1001 +		assertEquals(1, bindings.size());
  6.1002 +		assertTrue(-1<bindings.indexOf("[id2=\"Z\"^^<http://www.w3.org/2001/XMLSchema#string>;id1=\"E\"^^<http://www.w3.org/2001/XMLSchema#string>]"));
  6.1003 +	}
  6.1004 +	
  6.1005 +	@Test
  6.1006 +	public void testGeofEhContains() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
  6.1007 +	{
  6.1008 +		String query = 
  6.1009 +			prefixes+
  6.1010 +			"SELECT DISTINCT ?id1 ?id2 \n"+
  6.1011 +			"WHERE { \n" +
  6.1012 +			" ?s1 ex:id ?id1 . \n"+
  6.1013 +			" ?s2 ex:id ?id2 . \n"+
  6.1014 +			" FILTER( str(?id1) != str(?id2) ) . \n"+
  6.1015 +			" ?s2 ex:geometry ?g2 . \n" +
  6.1016 +			" ?s1 ex:geometry ?g1 . \n"+
  6.1017 +			" FILTER( geof:eh-contains(?g1, ?g2 )) . \n"+
  6.1018 +			"}";
  6.1019 +		
  6.1020 +		ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection());
  6.1021 +		assertEquals(1, bindings.size());
  6.1022 +		assertTrue(-1<bindings.indexOf("[id2=\"E\"^^<http://www.w3.org/2001/XMLSchema#string>;id1=\"Z\"^^<http://www.w3.org/2001/XMLSchema#string>]"));
  6.1023 +	}
  6.1024 +	
  6.1025 +	//RCC8 - 8 functions - all with 2 arguments + boolean
  6.1026 +
  6.1027 +	@Test
  6.1028 +	public void testGeofRcc8Dc() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
  6.1029 +	{
  6.1030 +		String query = 
  6.1031 +			prefixes+
  6.1032 +			"SELECT DISTINCT ?s1 ?s2 \n"+
  6.1033 +			"WHERE { \n" +
  6.1034 +			" ?s1 ex:geometry ?g1 . \n"+
  6.1035 +			" ?s2 ex:geometry ?g2 . \n" +
  6.1036 +			" FILTER( str(?s1) < str(?s2) ) . \n"+
  6.1037 +			" FILTER( geof:rcc8-dc(?g1, ?g2 )) . \n"+
  6.1038 +			"}";
  6.1039 +		
  6.1040 +		ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection());
  6.1041 +		assertEquals(40, bindings.size());
  6.1042 +		// too many results :)
  6.1043 +//		assertTrue(-1<bindings.indexOf("[s2=http://example.org/pol11;s1=http://example.org/pol1]"));
  6.1044 +	}
  6.1045 +	
  6.1046 +	@Test
  6.1047 +	public void testGeofRcc8Ec() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
  6.1048 +	{
  6.1049 +		String query = 
  6.1050 +			prefixes+
  6.1051 +			"SELECT DISTINCT ?id1 ?id2 \n"+
  6.1052 +			"WHERE { \n" +
  6.1053 +			" ?s1 ex:id ?id1 . \n"+
  6.1054 +			" ?s2 ex:id ?id2 . \n"+
  6.1055 +			" FILTER( str(?id1) != str(?id2) ) . \n"+
  6.1056 +			" ?s2 ex:geometry ?g2 . \n" +
  6.1057 +			" ?s1 ex:geometry ?g1 . \n"+
  6.1058 +			" FILTER( geof:rcc8-po(?g1, ?g2 )) . \n"+
  6.1059 +			"}";
  6.1060 +		
  6.1061 +		ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection());
  6.1062 +		assertEquals(2, bindings.size());
  6.1063 +		assertTrue(-1<bindings.indexOf("[id2=\"B\"^^<http://www.w3.org/2001/XMLSchema#string>;id1=\"Z\"^^<http://www.w3.org/2001/XMLSchema#string>]"));
  6.1064 +		assertTrue(-1<bindings.indexOf("[id2=\"Z\"^^<http://www.w3.org/2001/XMLSchema#string>;id1=\"B\"^^<http://www.w3.org/2001/XMLSchema#string>]"));
  6.1065 +	}
  6.1066 +
  6.1067 +	@Test
  6.1068 +	public void testGeofRcc8Tppi() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
  6.1069 +	{
  6.1070 +		String query = 
  6.1071 +			prefixes+
  6.1072 +			"SELECT DISTINCT ?id1 ?id2 \n"+
  6.1073 +			"WHERE { \n" +
  6.1074 +			" ?s1 ex:id ?id1 . \n"+
  6.1075 +			" ?s2 ex:id ?id2 . \n"+
  6.1076 +			" FILTER( str(?id1) != str(?id2) ) . \n"+
  6.1077 +			" ?s2 ex:geometry ?g2 . \n" +
  6.1078 +			" ?s1 ex:geometry ?g1 . \n"+
  6.1079 +			" FILTER( geof:rcc8-tppi(?g1, ?g2 )) . \n"+
  6.1080 +			"}";
  6.1081 +		
  6.1082 +		ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection());
  6.1083 +		assertEquals(1, bindings.size());
  6.1084 +		assertTrue(-1<bindings.indexOf("[id2=\"F\"^^<http://www.w3.org/2001/XMLSchema#string>;id1=\"Z\"^^<http://www.w3.org/2001/XMLSchema#string>]"));
  6.1085 +	}
  6.1086 +
  6.1087 +	@Test
  6.1088 +	public void testGeofRcc8Tpp() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
  6.1089 +	{
  6.1090 +		String query = 
  6.1091 +			prefixes+
  6.1092 +			"SELECT DISTINCT ?id1 ?id2 \n"+
  6.1093 +			"WHERE { \n" +
  6.1094 +			" ?s1 ex:id ?id1 . \n"+
  6.1095 +			" ?s2 ex:id ?id2 . \n"+
  6.1096 +			" FILTER( str(?id1) != str(?id2) ) . \n"+
  6.1097 +			" ?s2 ex:geometry ?g2 . \n" +
  6.1098 +			" ?s1 ex:geometry ?g1 . \n"+
  6.1099 +			" FILTER( geof:rcc8-tpp(?g1, ?g2 )) . \n"+
  6.1100 +			"}";
  6.1101 +		
  6.1102 +		ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection());
  6.1103 +		assertEquals(1, bindings.size());
  6.1104 +		assertTrue(-1<bindings.indexOf("[id2=\"Z\"^^<http://www.w3.org/2001/XMLSchema#string>;id1=\"F\"^^<http://www.w3.org/2001/XMLSchema#string>]"));
  6.1105 +	}
  6.1106 +	
  6.1107 +
  6.1108 +	@Test
  6.1109 +	public void testGeofRcc8Ntpp() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
  6.1110 +	{
  6.1111 +		String query = 
  6.1112 +			prefixes+
  6.1113 +			"SELECT DISTINCT ?id1 ?id2 \n"+
  6.1114 +			"WHERE { \n" +
  6.1115 +			" ?s1 ex:id ?id1 . \n"+
  6.1116 +			" ?s2 ex:id ?id2 . \n"+
  6.1117 +			" FILTER( str(?id1) != str(?id2) ) . \n"+
  6.1118 +			" ?s2 ex:geometry ?g2 . \n" +
  6.1119 +			" ?s1 ex:geometry ?g1 . \n"+
  6.1120 +			" FILTER( geof:rcc8-ntpp(?g1, ?g2 )) . \n"+
  6.1121 +			"}";
  6.1122 +		
  6.1123 +		ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection());
  6.1124 +		assertEquals(1, bindings.size());
  6.1125 +		assertTrue(-1<bindings.indexOf("[id2=\"Z\"^^<http://www.w3.org/2001/XMLSchema#string>;id1=\"E\"^^<http://www.w3.org/2001/XMLSchema#string>]"));
  6.1126 +	}
  6.1127 +	@Test
  6.1128 +	public void testGeofRcc8Ntppi() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
  6.1129 +	{
  6.1130 +		String query = 
  6.1131 +			prefixes+
  6.1132 +			"SELECT DISTINCT ?id1 ?id2 \n"+
  6.1133 +			"WHERE { \n" +
  6.1134 +			" ?s1 ex:id ?id1 . \n"+
  6.1135 +			" ?s2 ex:id ?id2 . \n"+
  6.1136 +			" FILTER( str(?id1) != str(?id2) ) . \n"+
  6.1137 +			" ?s2 ex:geometry ?g2 . \n" +
  6.1138 +			" ?s1 ex:geometry ?g1 . \n"+
  6.1139 +			" FILTER( geof:rcc8-ntpp(?g1, ?g2 )) . \n"+
  6.1140 +			"}";
  6.1141 +		
  6.1142 +		ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection());
  6.1143 +		assertEquals(1, bindings.size());
  6.1144 +		assertTrue(-1<bindings.indexOf("[id2=\"Z\"^^<http://www.w3.org/2001/XMLSchema#string>;id1=\"E\"^^<http://www.w3.org/2001/XMLSchema#string>]"));
  6.1145 +	}
  6.1146 +}
     7.1 --- a/runtime/src/test/java/eu/earthobservatory/runtime/postgis/AggregateTests.java	Fri May 18 13:48:04 2012 +0300
     7.2 +++ b/runtime/src/test/java/eu/earthobservatory/runtime/postgis/AggregateTests.java	Fri May 18 13:48:39 2012 +0300
     7.3 @@ -27,45 +27,45 @@
     7.4  	@BeforeClass
     7.5  	public static void beforeClass() throws SQLException, ClassNotFoundException, RDFParseException, RepositoryException, RDFHandlerException, IOException, InvalidDatasetFormatFault
     7.6  	{
     7.7 -		// Read properties
     7.8 -		Properties properties = new Properties();
     7.9 -		InputStream propertiesStream =  SimpleTests.class.getResourceAsStream("/databases.properties");
    7.10 -		properties.load(propertiesStream);
    7.11 -
    7.12 -		serverName = properties.getProperty("postgis.serverName");
    7.13 -		databaseName = properties.getProperty("postgis.databaseName");
    7.14 -		port = Integer.parseInt(properties.getProperty("postgis.port"));
    7.15 -		username = properties.getProperty("postgis.username");
    7.16 -		password = properties.getProperty("postgis.password");
    7.17 -				
    7.18 -		// Connect to database
    7.19 -		Class.forName("org.postgresql.Driver");
    7.20 -		String url = "jdbc:postgresql://"+serverName+":"+port+"/"+databaseName;
    7.21 -		conn = DriverManager.getConnection(url, username, password);
    7.22 -				
    7.23 -//		// Clean database
    7.24 -		Statement stmt = conn.createStatement();
    7.25 -		ResultSet results = stmt.executeQuery("SELECT table_name FROM information_schema.tables WHERE " +
    7.26 -						"table_schema='public' AND table_name <> 'spatial_ref_sys' " +
    7.27 -						"AND table_name <> 'geometry_columns' AND " +
    7.28 -						"table_name <> 'geography_columns' AND table_name <> 'locked'");
    7.29 -		while (results.next()) {
    7.30 -			String table_name = results.getString("table_name");
    7.31 -			Statement stmt2 = conn.createStatement();
    7.32 -			stmt2.executeUpdate("DROP TABLE \""+table_name+"\"");
    7.33 -			stmt2.close();
    7.34 -		}
    7.35 -		stmt.close();
    7.36 -		
    7.37 -	    strabon = new Strabon(databaseName, username, password, port, serverName, true);
    7.38 -		
    7.39 -		loadTestData();
    7.40 +	 TemplateTests.beforeClass();
    7.41  	}
    7.42  	
    7.43  	@AfterClass
    7.44  	public static void afterClass() throws SQLException
    7.45  	{
    7.46 -		strabon.close();
    7.47 +		TemplateTests.afterClass();
    7.48  	}
    7.49  	
    7.50 -}
    7.51 \ No newline at end of file
    7.52 +//	/**
    7.53 +//	 * @throws java.lang.Exception
    7.54 +//	 */
    7.55 +//	@Before
    7.56 +//	public void before()
    7.57 +//		throws Exception
    7.58 +//	{
    7.59 +//		
    7.60 +//	}
    7.61 +//
    7.62 +//	/**
    7.63 +//	 * @throws java.lang.Exception
    7.64 +//	 */
    7.65 +//	@After
    7.66 +//	public void after()
    7.67 +//		throws Exception
    7.68 +//	{
    7.69 +//		// Clean database
    7.70 +//		Statement stmt = conn.createStatement();
    7.71 +//		ResultSet results = stmt.executeQuery("SELECT table_name FROM information_schema.tables WHERE " +
    7.72 +//						"table_schema='public' and table_name <> 'spatial_ref_sys' " +
    7.73 +//						"and table_name <> 'geometry_columns' and " +
    7.74 +//						"table_name <> 'geography_columns' and table_name <> 'locked'");
    7.75 +//		while (results.next()) {
    7.76 +//			String table_name = results.getString("table_name");
    7.77 +//			Statement stmt2 = conn.createStatement();
    7.78 +//			stmt2.executeUpdate("DROP TABLE \""+table_name+"\"");
    7.79 +//			stmt2.close();
    7.80 +//		}
    7.81 +//			
    7.82 +//		stmt.close();
    7.83 +//	}
    7.84 +}
     8.1 --- a/runtime/src/test/java/eu/earthobservatory/runtime/postgis/GeneralTests.java	Fri May 18 13:48:04 2012 +0300
     8.2 +++ b/runtime/src/test/java/eu/earthobservatory/runtime/postgis/GeneralTests.java	Fri May 18 13:48:39 2012 +0300
     8.3 @@ -27,45 +27,45 @@
     8.4  	@BeforeClass
     8.5  	public static void beforeClass() throws SQLException, ClassNotFoundException, RDFParseException, RepositoryException, RDFHandlerException, IOException, InvalidDatasetFormatFault
     8.6  	{
     8.7 -		// Read properties
     8.8 -		Properties properties = new Properties();
     8.9 -		InputStream propertiesStream =  SimpleTests.class.getResourceAsStream("/databases.properties");
    8.10 -		properties.load(propertiesStream);
    8.11 -
    8.12 -		serverName = properties.getProperty("postgis.serverName");
    8.13 -		databaseName = properties.getProperty("postgis.databaseName");
    8.14 -		port = Integer.parseInt(properties.getProperty("postgis.port"));
    8.15 -		username = properties.getProperty("postgis.username");
    8.16 -		password = properties.getProperty("postgis.password");
    8.17 -				
    8.18 -		// Connect to database
    8.19 -		Class.forName("org.postgresql.Driver");
    8.20 -		String url = "jdbc:postgresql://"+serverName+":"+port+"/"+databaseName;
    8.21 -		conn = DriverManager.getConnection(url, username, password);
    8.22 -				
    8.23 -//		// Clean database
    8.24 -		Statement stmt = conn.createStatement();
    8.25 -		ResultSet results = stmt.executeQuery("SELECT table_name FROM information_schema.tables WHERE " +
    8.26 -						"table_schema='public' AND table_name <> 'spatial_ref_sys' " +
    8.27 -						"AND table_name <> 'geometry_columns' AND " +
    8.28 -						"table_name <> 'geography_columns' AND table_name <> 'locked'");
    8.29 -		while (results.next()) {
    8.30 -			String table_name = results.getString("table_name");
    8.31 -			Statement stmt2 = conn.createStatement();
    8.32 -			stmt2.executeUpdate("DROP TABLE \""+table_name+"\"");
    8.33 -			stmt2.close();
    8.34 -		}
    8.35 -		stmt.close();
    8.36 -		
    8.37 -	    strabon = new Strabon(databaseName, username, password, port, serverName, true);
    8.38 -		
    8.39 -		loadTestData();
    8.40 +	 TemplateTests.beforeClass();
    8.41  	}
    8.42  	
    8.43  	@AfterClass
    8.44  	public static void afterClass() throws SQLException
    8.45  	{
    8.46 -		strabon.close();
    8.47 +		TemplateTests.afterClass();
    8.48  	}
    8.49  	
    8.50 -}
    8.51 \ No newline at end of file
    8.52 +//	/**
    8.53 +//	 * @throws java.lang.Exception
    8.54 +//	 */
    8.55 +//	@Before
    8.56 +//	public void before()
    8.57 +//		throws Exception
    8.58 +//	{
    8.59 +//		
    8.60 +//	}
    8.61 +//
    8.62 +//	/**
    8.63 +//	 * @throws java.lang.Exception
    8.64 +//	 */
    8.65 +//	@After
    8.66 +//	public void after()
    8.67 +//		throws Exception
    8.68 +//	{
    8.69 +//		// Clean database
    8.70 +//		Statement stmt = conn.createStatement();
    8.71 +//		ResultSet results = stmt.executeQuery("SELECT table_name FROM information_schema.tables WHERE " +
    8.72 +//						"table_schema='public' and table_name <> 'spatial_ref_sys' " +
    8.73 +//						"and table_name <> 'geometry_columns' and " +
    8.74 +//						"table_name <> 'geography_columns' and table_name <> 'locked'");
    8.75 +//		while (results.next()) {
    8.76 +//			String table_name = results.getString("table_name");
    8.77 +//			Statement stmt2 = conn.createStatement();
    8.78 +//			stmt2.executeUpdate("DROP TABLE \""+table_name+"\"");
    8.79 +//			stmt2.close();
    8.80 +//		}
    8.81 +//			
    8.82 +//		stmt.close();
    8.83 +//	}
    8.84 +}
     9.1 --- a/runtime/src/test/java/eu/earthobservatory/runtime/postgis/HavingTests.java	Fri May 18 13:48:04 2012 +0300
     9.2 +++ b/runtime/src/test/java/eu/earthobservatory/runtime/postgis/HavingTests.java	Fri May 18 13:48:39 2012 +0300
     9.3 @@ -27,45 +27,45 @@
     9.4  	@BeforeClass
     9.5  	public static void beforeClass() throws SQLException, ClassNotFoundException, RDFParseException, RepositoryException, RDFHandlerException, IOException, InvalidDatasetFormatFault
     9.6  	{
     9.7 -		// Read properties
     9.8 -		Properties properties = new Properties();
     9.9 -		InputStream propertiesStream =  SimpleTests.class.getResourceAsStream("/databases.properties");
    9.10 -		properties.load(propertiesStream);
    9.11 -
    9.12 -		serverName = properties.getProperty("postgis.serverName");
    9.13 -		databaseName = properties.getProperty("postgis.databaseName");
    9.14 -		port = Integer.parseInt(properties.getProperty("postgis.port"));
    9.15 -		username = properties.getProperty("postgis.username");
    9.16 -		password = properties.getProperty("postgis.password");
    9.17 -				
    9.18 -		// Connect to database
    9.19 -		Class.forName("org.postgresql.Driver");
    9.20 -		String url = "jdbc:postgresql://"+serverName+":"+port+"/"+databaseName;
    9.21 -		conn = DriverManager.getConnection(url, username, password);
    9.22 -				
    9.23 -//		// Clean database
    9.24 -		Statement stmt = conn.createStatement();
    9.25 -		ResultSet results = stmt.executeQuery("SELECT table_name FROM information_schema.tables WHERE " +
    9.26 -						"table_schema='public' AND table_name <> 'spatial_ref_sys' " +
    9.27 -						"AND table_name <> 'geometry_columns' AND " +
    9.28 -						"table_name <> 'geography_columns' AND table_name <> 'locked'");
    9.29 -		while (results.next()) {
    9.30 -			String table_name = results.getString("table_name");
    9.31 -			Statement stmt2 = conn.createStatement();
    9.32 -			stmt2.executeUpdate("DROP TABLE \""+table_name+"\"");
    9.33 -			stmt2.close();
    9.34 -		}
    9.35 -		stmt.close();
    9.36 -		
    9.37 -	    strabon = new Strabon(databaseName, username, password, port, serverName, true);
    9.38 -		
    9.39 -		loadTestData();
    9.40 +	 TemplateTests.beforeClass();
    9.41  	}
    9.42  	
    9.43  	@AfterClass
    9.44  	public static void afterClass() throws SQLException
    9.45  	{
    9.46 -		strabon.close();
    9.47 +		TemplateTests.afterClass();
    9.48  	}
    9.49  	
    9.50 -}
    9.51 \ No newline at end of file
    9.52 +//	/**
    9.53 +//	 * @throws java.lang.Exception
    9.54 +//	 */
    9.55 +//	@Before
    9.56 +//	public void before()
    9.57 +//		throws Exception
    9.58 +//	{
    9.59 +//		
    9.60 +//	}
    9.61 +//
    9.62 +//	/**
    9.63 +//	 * @throws java.lang.Exception
    9.64 +//	 */
    9.65 +//	@After
    9.66 +//	public void after()
    9.67 +//		throws Exception
    9.68 +//	{
    9.69 +//		// Clean database
    9.70 +//		Statement stmt = conn.createStatement();
    9.71 +//		ResultSet results = stmt.executeQuery("SELECT table_name FROM information_schema.tables WHERE " +
    9.72 +//						"table_schema='public' and table_name <> 'spatial_ref_sys' " +
    9.73 +//						"and table_name <> 'geometry_columns' and " +
    9.74 +//						"table_name <> 'geography_columns' and table_name <> 'locked'");
    9.75 +//		while (results.next()) {
    9.76 +//			String table_name = results.getString("table_name");
    9.77 +//			Statement stmt2 = conn.createStatement();
    9.78 +//			stmt2.executeUpdate("DROP TABLE \""+table_name+"\"");
    9.79 +//			stmt2.close();
    9.80 +//		}
    9.81 +//			
    9.82 +//		stmt.close();
    9.83 +//	}
    9.84 +}
    10.1 --- a/runtime/src/test/java/eu/earthobservatory/runtime/postgis/JoinTests.java	Fri May 18 13:48:04 2012 +0300
    10.2 +++ b/runtime/src/test/java/eu/earthobservatory/runtime/postgis/JoinTests.java	Fri May 18 13:48:39 2012 +0300
    10.3 @@ -27,45 +27,45 @@
    10.4  	@BeforeClass
    10.5  	public static void beforeClass() throws SQLException, ClassNotFoundException, RDFParseException, RepositoryException, RDFHandlerException, IOException, InvalidDatasetFormatFault
    10.6  	{
    10.7 -		// Read properties
    10.8 -		Properties properties = new Properties();
    10.9 -		InputStream propertiesStream =  SimpleTests.class.getResourceAsStream("/databases.properties");
   10.10 -		properties.load(propertiesStream);
   10.11 -
   10.12 -		serverName = properties.getProperty("postgis.serverName");
   10.13 -		databaseName = properties.getProperty("postgis.databaseName");
   10.14 -		port = Integer.parseInt(properties.getProperty("postgis.port"));
   10.15 -		username = properties.getProperty("postgis.username");
   10.16 -		password = properties.getProperty("postgis.password");
   10.17 -				
   10.18 -		// Connect to database
   10.19 -		Class.forName("org.postgresql.Driver");
   10.20 -		String url = "jdbc:postgresql://"+serverName+":"+port+"/"+databaseName;
   10.21 -		conn = DriverManager.getConnection(url, username, password);
   10.22 -				
   10.23 -//		// Clean database
   10.24 -		Statement stmt = conn.createStatement();
   10.25 -		ResultSet results = stmt.executeQuery("SELECT table_name FROM information_schema.tables WHERE " +
   10.26 -						"table_schema='public' AND table_name <> 'spatial_ref_sys' " +
   10.27 -						"AND table_name <> 'geometry_columns' AND " +
   10.28 -						"table_name <> 'geography_columns' AND table_name <> 'locked'");
   10.29 -		while (results.next()) {
   10.30 -			String table_name = results.getString("table_name");
   10.31 -			Statement stmt2 = conn.createStatement();
   10.32 -			stmt2.executeUpdate("DROP TABLE \""+table_name+"\"");
   10.33 -			stmt2.close();
   10.34 -		}
   10.35 -		stmt.close();
   10.36 -		
   10.37 -	    strabon = new Strabon(databaseName, username, password, port, serverName, true);
   10.38 -		
   10.39 -		loadTestData();
   10.40 +	 TemplateTests.beforeClass();
   10.41  	}
   10.42  	
   10.43  	@AfterClass
   10.44  	public static void afterClass() throws SQLException
   10.45  	{
   10.46 -		strabon.close();
   10.47 +		TemplateTests.afterClass();
   10.48  	}
   10.49  	
   10.50 -}
   10.51 \ No newline at end of file
   10.52 +//	/**
   10.53 +//	 * @throws java.lang.Exception
   10.54 +//	 */
   10.55 +//	@Before
   10.56 +//	public void before()
   10.57 +//		throws Exception
   10.58 +//	{
   10.59 +//		
   10.60 +//	}
   10.61 +//
   10.62 +//	/**
   10.63 +//	 * @throws java.lang.Exception
   10.64 +//	 */
   10.65 +//	@After
   10.66 +//	public void after()
   10.67 +//		throws Exception
   10.68 +//	{
   10.69 +//		// Clean database
   10.70 +//		Statement stmt = conn.createStatement();
   10.71 +//		ResultSet results = stmt.executeQuery("SELECT table_name FROM information_schema.tables WHERE " +
   10.72 +//						"table_schema='public' and table_name <> 'spatial_ref_sys' " +
   10.73 +//						"and table_name <> 'geometry_columns' and " +
   10.74 +//						"table_name <> 'geography_columns' and table_name <> 'locked'");
   10.75 +//		while (results.next()) {
   10.76 +//			String table_name = results.getString("table_name");
   10.77 +//			Statement stmt2 = conn.createStatement();
   10.78 +//			stmt2.executeUpdate("DROP TABLE \""+table_name+"\"");
   10.79 +//			stmt2.close();
   10.80 +//		}
   10.81 +//			
   10.82 +//		stmt.close();
   10.83 +//	}
   10.84 +}
    11.1 --- a/runtime/src/test/java/eu/earthobservatory/runtime/postgis/MeaningfulAggregateTests.java	Fri May 18 13:48:04 2012 +0300
    11.2 +++ b/runtime/src/test/java/eu/earthobservatory/runtime/postgis/MeaningfulAggregateTests.java	Fri May 18 13:48:39 2012 +0300
    11.3 @@ -28,47 +28,13 @@
    11.4  	@BeforeClass
    11.5  	public static void beforeClass() throws SQLException, ClassNotFoundException, RDFParseException, RepositoryException, RDFHandlerException, IOException, InvalidDatasetFormatFault
    11.6  	{
    11.7 -		SimpleTests.beforeClass();
    11.8 +		TemplateTests.beforeClass();
    11.9  	}
   11.10 -	/*	// Read properties
   11.11 -		Properties properties = new Properties();
   11.12 -		InputStream propertiesStream =  SimpleTests.class.getResourceAsStream("/databases.properties");
   11.13 -		properties.load(propertiesStream);
   11.14 -
   11.15 -		serverName = properties.getProperty("postgis.serverName");
   11.16 -		databaseName = properties.getProperty("postgis.databaseName");
   11.17 -		port = Integer.parseInt(properties.getProperty("postgis.port"));
   11.18 -		username = properties.getProperty("postgis.username");
   11.19 -		password = properties.getProperty("postgis.password");
   11.20 -				
   11.21 -		// Connect to database
   11.22 -		Class.forName("org.postgresql.Driver");
   11.23 -		String url = "jdbc:postgresql://"+serverName+":"+port+"/"+databaseName;
   11.24 -		conn = DriverManager.getConnection(url, username, password);
   11.25 -				
   11.26 -//		// Clean database
   11.27 -		Statement stmt = conn.createStatement();
   11.28 -		ResultSet results = stmt.executeQuery("SELECT table_name FROM information_schema.tables WHERE " +
   11.29 -						"table_schema='public' AND table_name <> 'spatial_ref_sys' " +
   11.30 -						"AND table_name <> 'geometry_columns' AND " +
   11.31 -						"table_name <> 'geography_columns' AND table_name <> 'locked'");
   11.32 -		while (results.next()) {
   11.33 -			String table_name = results.getString("table_name");
   11.34 -			Statement stmt2 = conn.createStatement();
   11.35 -			stmt2.executeUpdate("DROP TABLE \""+table_name+"\"");
   11.36 -			stmt2.close();
   11.37 -		}
   11.38 -		stmt.close();
   11.39 -		
   11.40 -	    strabon = new Strabon(databaseName, username, password, port, serverName, true);
   11.41 -		
   11.42 -		loadTestData();
   11.43 -	}*/
   11.44  	
   11.45  	@AfterClass
   11.46  	public static void afterClass() throws SQLException
   11.47  	{
   11.48 -		SimpleTests.afterClass();
   11.49 +		TemplateTests.afterClass();
   11.50  	}
   11.51  	
   11.52  }
   11.53 \ No newline at end of file
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/runtime/src/test/java/eu/earthobservatory/runtime/postgis/SPARQL11Tests.java	Fri May 18 13:48:39 2012 +0300
    12.3 @@ -0,0 +1,71 @@
    12.4 +package eu.earthobservatory.runtime.postgis;
    12.5 +
    12.6 +import java.io.IOException;
    12.7 +import java.io.InputStream;
    12.8 +import java.sql.DriverManager;
    12.9 +import java.sql.ResultSet;
   12.10 +import java.sql.SQLException;
   12.11 +import java.sql.Statement;
   12.12 +import java.util.Properties;
   12.13 +
   12.14 +import org.junit.AfterClass;
   12.15 +import org.junit.BeforeClass;
   12.16 +import org.openrdf.repository.RepositoryException;
   12.17 +import org.openrdf.rio.RDFHandlerException;
   12.18 +import org.openrdf.rio.RDFParseException;
   12.19 +
   12.20 +import eu.earthobservatory.runtime.generaldb.InvalidDatasetFormatFault;
   12.21 +
   12.22 +/**
   12.23 + * A set of simple tests on SPARQL query functionality 
   12.24 + * 
   12.25 + * @author George Garbis
   12.26 + */
   12.27 +
   12.28 +public class SPARQL11Tests extends eu.earthobservatory.runtime.generaldb.SimpleTests {
   12.29 +	
   12.30 +	@BeforeClass
   12.31 +	public static void beforeClass() throws SQLException, ClassNotFoundException, RDFParseException, RepositoryException, RDFHandlerException, IOException, InvalidDatasetFormatFault
   12.32 +	{
   12.33 +	 TemplateTests.beforeClass();
   12.34 +	}
   12.35 +	
   12.36 +	@AfterClass
   12.37 +	public static void afterClass() throws SQLException
   12.38 +	{
   12.39 +		TemplateTests.afterClass();
   12.40 +	}
   12.41 +	
   12.42 +//	/**
   12.43 +//	 * @throws java.lang.Exception
   12.44 +//	 */
   12.45 +//	@Before
   12.46 +//	public void before()
   12.47 +//		throws Exception
   12.48 +//	{
   12.49 +//		
   12.50 +//	}
   12.51 +//
   12.52 +//	/**
   12.53 +//	 * @throws java.lang.Exception
   12.54 +//	 */
   12.55 +//	@After
   12.56 +//	public void after()
   12.57 +//		throws Exception
   12.58 +//	{
   12.59 +//		// Clean database
   12.60 +//		Statement stmt = conn.createStatement();
   12.61 +//		ResultSet results = stmt.executeQuery("SELECT table_name FROM information_schema.tables WHERE " +
   12.62 +//						"table_schema='public' and table_name <> 'spatial_ref_sys' " +
   12.63 +//						"and table_name <> 'geometry_columns' and " +
   12.64 +//						"table_name <> 'geography_columns' and table_name <> 'locked'");
   12.65 +//		while (results.next()) {
   12.66 +//			String table_name = results.getString("table_name");
   12.67 +//			Statement stmt2 = conn.createStatement();
   12.68 +//			stmt2.executeUpdate("DROP TABLE \""+table_name+"\"");
   12.69 +//			stmt2.close();
   12.70 +//		}
   12.71 +//			
   12.72 +//		stmt.close();
   12.73 +//	}
   12.74 +}
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/runtime/src/test/java/eu/earthobservatory/runtime/postgis/SpatialTests.java	Fri May 18 13:48:39 2012 +0300
    13.3 @@ -0,0 +1,113 @@
    13.4 +package eu.earthobservatory.runtime.postgis;
    13.5 +
    13.6 +import static org.junit.Assert.assertEquals;
    13.7 +import static org.junit.Assert.assertTrue;
    13.8 +
    13.9 +import java.io.IOException;
   13.10 +import java.sql.SQLException;
   13.11 +import java.util.ArrayList;
   13.12 +
   13.13 +import org.junit.BeforeClass;
   13.14 +import org.junit.Test;
   13.15 +import org.openrdf.query.MalformedQueryException;
   13.16 +import org.openrdf.query.QueryEvaluationException;
   13.17 +import org.openrdf.query.TupleQueryResultHandlerException;
   13.18 +
   13.19 +import eu.earthobservatory.runtime.postgis.Strabon;
   13.20 +
   13.21 +public class SpatialTests extends eu.earthobservatory.runtime.generaldb.SpatialTests {
   13.22 +
   13.23 +	@BeforeClass
   13.24 +	public static void initialize() throws SQLException, ClassNotFoundException
   13.25 +	{
   13.26 +		strabon = new Strabon("spatial-tests-srid","strabon","p1r3as", 5432, "strabon.di.uoa.gr", true);
   13.27 +	}
   13.28 +	
   13.29 +	@Test
   13.30 +	public void testStrdfLeft() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   13.31 +	{ // TODO left not implemented in monetdb
   13.32 +		String query = 
   13.33 +			prefixes+
   13.34 +				"SELECT DISTINCT ?id1 \n"+
   13.35 +				"WHERE { \n" +
   13.36 +				" ?s1 ex:id ?id1 . \n"+
   13.37 +				" ?s2 ex:id ?id2 . \n"+
   13.38 +				" FILTER( str(?id1) != str(?id2) ) . \n"+
   13.39 +				" FILTER( str(?id2) = \"Z\"^^xsd:string ) . \n"+
   13.40 +				" ?s2 ex:geometry ?g2 . \n" +
   13.41 +				" ?s1 ex:geometry ?g1 . \n"+
   13.42 +				" FILTER( strdf:left(?g1, ?g2 )) . \n"+
   13.43 +			"}";
   13.44 +		
   13.45 +		ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection());
   13.46 +		
   13.47 +		assertEquals(1, bindings.size());
   13.48 +		assertTrue(-1<bindings.indexOf("[id1=\"A\"^^<http://www.w3.org/2001/XMLSchema#string>]"));
   13.49 +	}
   13.50 +	
   13.51 +	@Test
   13.52 +	public void testStrdfRight() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   13.53 +	{ // TODO right not implemented in monetdb
   13.54 +		String query = 
   13.55 +			prefixes+
   13.56 +				"SELECT DISTINCT ?id1 \n"+
   13.57 +				"WHERE { \n" +
   13.58 +				" ?s1 ex:id ?id1 . \n"+
   13.59 +				" ?s2 ex:id ?id2 . \n"+
   13.60 +				" FILTER( str(?id1) != str(?id2) ) . \n"+
   13.61 +				" FILTER( str(?id2) = \"Z\"^^xsd:string ) . \n"+
   13.62 +				" ?s2 ex:geometry ?g2 . \n" +
   13.63 +				" ?s1 ex:geometry ?g1 . \n"+
   13.64 +				" FILTER( strdf:right(?g1, ?g2 )) . \n"+
   13.65 +			"}";
   13.66 +		
   13.67 +		ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection());
   13.68 +		
   13.69 +		assertEquals(1, bindings.size());
   13.70 +		assertTrue(-1<bindings.indexOf("[id1=\"D\"^^<http://www.w3.org/2001/XMLSchema#string>]"));
   13.71 +	}
   13.72 +	
   13.73 +	@Test
   13.74 +	public void testStrdfAbove() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   13.75 +	{ // TODO above not implemented in monetdb
   13.76 +		String query = 
   13.77 +			prefixes+
   13.78 +				"SELECT DISTINCT ?id1 \n"+
   13.79 +				"WHERE { \n" +
   13.80 +				" ?s1 ex:id ?id1 . \n"+
   13.81 +				" ?s2 ex:id ?id2 . \n"+
   13.82 +				" FILTER( str(?id1) != str(?id2) ) . \n"+
   13.83 +				" FILTER( str(?id2) = \"Z\"^^xsd:string ) . \n"+
   13.84 +				" ?s2 ex:geometry ?g2 . \n" +
   13.85 +				" ?s1 ex:geometry ?g1 . \n"+
   13.86 +				" FILTER( strdf:above(?g1, ?g2 )) . \n"+
   13.87 +			"}";
   13.88 +		
   13.89 +		ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection());
   13.90 +		
   13.91 +		assertEquals(1, bindings.size());
   13.92 +		assertTrue(-1<bindings.indexOf("[id1=\"H\"^^<http://www.w3.org/2001/XMLSchema#string>]"));
   13.93 +	}
   13.94 +	
   13.95 +	@Test
   13.96 +	public void testStrdfBelow() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   13.97 +	{ // TODO below not implemented in monetdb
   13.98 +		String query = 
   13.99 +			prefixes+
  13.100 +				"SELECT DISTINCT ?id1 \n"+
  13.101 +				"WHERE { \n" +
  13.102 +				" ?s1 ex:id ?id1 . \n"+
  13.103 +				" ?s2 ex:id ?id2 . \n"+
  13.104 +				" FILTER( str(?id1) != str(?id2) ) . \n"+
  13.105 +				" FILTER( str(?id2) = \"Z\"^^xsd:string ) . \n"+
  13.106 +				" ?s2 ex:geometry ?g2 . \n" +
  13.107 +				" ?s1 ex:geometry ?g1 . \n"+
  13.108 +				" FILTER( strdf:below(?g1, ?g2 )) . \n"+
  13.109 +			"}";
  13.110 +		
  13.111 +		ArrayList<String> bindings = (ArrayList<String>) strabon.query(query,strabon.getSailRepoConnection());
  13.112 +		
  13.113 +		assertEquals(1, bindings.size());
  13.114 +		assertTrue(-1<bindings.indexOf("[id1=\"C\"^^<http://www.w3.org/2001/XMLSchema#string>]"));
  13.115 +	}
  13.116 +}
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/runtime/src/test/java/eu/earthobservatory/runtime/postgis/TemplateTests.java	Fri May 18 13:48:39 2012 +0300
    14.3 @@ -0,0 +1,103 @@
    14.4 +package eu.earthobservatory.runtime.postgis;
    14.5 +
    14.6 +import java.io.IOException;
    14.7 +import java.io.InputStream;
    14.8 +import java.sql.DriverManager;
    14.9 +import java.sql.ResultSet;
   14.10 +import java.sql.SQLException;
   14.11 +import java.sql.Statement;
   14.12 +import java.util.Properties;
   14.13 +
   14.14 +import org.junit.AfterClass;
   14.15 +import org.junit.BeforeClass;
   14.16 +import org.openrdf.repository.RepositoryException;
   14.17 +import org.openrdf.rio.RDFHandlerException;
   14.18 +import org.openrdf.rio.RDFParseException;
   14.19 +
   14.20 +import eu.earthobservatory.runtime.generaldb.InvalidDatasetFormatFault;
   14.21 +
   14.22 +/**
   14.23 + * A set of simple tests on SPARQL query functionality 
   14.24 + * 
   14.25 + * @author George Garbis
   14.26 + */
   14.27 +
   14.28 +public class TemplateTests extends eu.earthobservatory.runtime.generaldb.SimpleTests {
   14.29 +	
   14.30 +	@BeforeClass
   14.31 +	public static void beforeClass() throws SQLException, ClassNotFoundException, RDFParseException, RepositoryException, RDFHandlerException, IOException, InvalidDatasetFormatFault
   14.32 +	{
   14.33 +		// Read properties
   14.34 +		Properties properties = new Properties();
   14.35 +		InputStream propertiesStream =  SimpleTests.class.getResourceAsStream("/databases.properties");
   14.36 +		properties.load(propertiesStream);
   14.37 +
   14.38 +		serverName = properties.getProperty("postgis.serverName");
   14.39 +		databaseName = properties.getProperty("postgis.databaseName");
   14.40 +		port = Integer.parseInt(properties.getProperty("postgis.port"));
   14.41 +		username = properties.getProperty("postgis.username");
   14.42 +		password = properties.getProperty("postgis.password");
   14.43 +				
   14.44 +		// Connect to database
   14.45 +		Class.forName("org.postgresql.Driver");
   14.46 +		String url = "jdbc:postgresql://"+serverName+":"+port+"/"+databaseName;
   14.47 +		conn = DriverManager.getConnection(url, username, password);
   14.48 +				
   14.49 +//		// Clean database
   14.50 +		Statement stmt = conn.createStatement();
   14.51 +		ResultSet results = stmt.executeQuery("SELECT table_name FROM information_schema.tables WHERE " +
   14.52 +						"table_schema='public' AND table_name <> 'spatial_ref_sys' " +
   14.53 +						"AND table_name <> 'geometry_columns' AND " +
   14.54 +						"table_name <> 'geography_columns' AND table_name <> 'locked'");
   14.55 +		while (results.next()) {
   14.56 +			String table_name = results.getString("table_name");
   14.57 +			Statement stmt2 = conn.createStatement();
   14.58 +			stmt2.executeUpdate("DROP TABLE \""+table_name+"\"");
   14.59 +			stmt2.close();
   14.60 +		}
   14.61 +		stmt.close();
   14.62 +		
   14.63 +	    strabon = new Strabon(databaseName, username, password, port, serverName, true);
   14.64 +		
   14.65 +		loadTestData();
   14.66 +	}
   14.67 +	
   14.68 +	@AfterClass
   14.69 +	public static void afterClass() throws SQLException
   14.70 +	{
   14.71 +		strabon.close();
   14.72 +	}
   14.73 +	
   14.74 +//	/**
   14.75 +//	 * @throws java.lang.Exception
   14.76 +//	 */
   14.77 +//	@Before
   14.78 +//	public void before()
   14.79 +//		throws Exception
   14.80 +//	{
   14.81 +//		
   14.82 +//	}
   14.83 +//
   14.84 +//	/**
   14.85 +//	 * @throws java.lang.Exception
   14.86 +//	 */
   14.87 +//	@After
   14.88 +//	public void after()
   14.89 +//		throws Exception
   14.90 +//	{
   14.91 +//		// Clean database
   14.92 +//		Statement stmt = conn.createStatement();
   14.93 +//		ResultSet results = stmt.executeQuery("SELECT table_name FROM information_schema.tables WHERE " +
   14.94 +//						"table_schema='public' and table_name <> 'spatial_ref_sys' " +
   14.95 +//						"and table_name <> 'geometry_columns' and " +
   14.96 +//						"table_name <> 'geography_columns' and table_name <> 'locked'");
   14.97 +//		while (results.next()) {
   14.98 +//			String table_name = results.getString("table_name");
   14.99 +//			Statement stmt2 = conn.createStatement();
  14.100 +//			stmt2.executeUpdate("DROP TABLE \""+table_name+"\"");
  14.101 +//			stmt2.close();
  14.102 +//		}
  14.103 +//			
  14.104 +//		stmt.close();
  14.105 +//	}
  14.106 +}
    15.1 --- a/runtime/src/test/java/eu/earthobservatory/runtime/postgis/TransformTests.java	Fri May 18 13:48:04 2012 +0300
    15.2 +++ b/runtime/src/test/java/eu/earthobservatory/runtime/postgis/TransformTests.java	Fri May 18 13:48:39 2012 +0300
    15.3 @@ -27,45 +27,45 @@
    15.4  	@BeforeClass
    15.5  	public static void beforeClass() throws SQLException, ClassNotFoundException, RDFParseException, RepositoryException, RDFHandlerException, IOException, InvalidDatasetFormatFault
    15.6  	{
    15.7 -		// Read properties
    15.8 -		Properties properties = new Properties();
    15.9 -		InputStream propertiesStream =  SimpleTests.class.getResourceAsStream("/databases.properties");
   15.10 -		properties.load(propertiesStream);
   15.11 -
   15.12 -		serverName = properties.getProperty("postgis.serverName");
   15.13 -		databaseName = properties.getProperty("postgis.databaseName");
   15.14 -		port = Integer.parseInt(properties.getProperty("postgis.port"));
   15.15 -		username = properties.getProperty("postgis.username");
   15.16 -		password = properties.getProperty("postgis.password");
   15.17 -				
   15.18 -		// Connect to database
   15.19 -		Class.forName("org.postgresql.Driver");
   15.20 -		String url = "jdbc:postgresql://"+serverName+":"+port+"/"+databaseName;
   15.21 -		conn = DriverManager.getConnection(url, username, password);
   15.22 -				
   15.23 -//		// Clean database
   15.24 -		Statement stmt = conn.createStatement();
   15.25 -		ResultSet results = stmt.executeQuery("SELECT table_name FROM information_schema.tables WHERE " +
   15.26 -						"table_schema='public' AND table_name <> 'spatial_ref_sys' " +
   15.27 -						"AND table_name <> 'geometry_columns' AND " +
   15.28 -						"table_name <> 'geography_columns' AND table_name <> 'locked'");
   15.29 -		while (results.next()) {
   15.30 -			String table_name = results.getString("table_name");
   15.31 -			Statement stmt2 = conn.createStatement();
   15.32 -			stmt2.executeUpdate("DROP TABLE \""+table_name+"\"");
   15.33 -			stmt2.close();
   15.34 -		}
   15.35 -		stmt.close();
   15.36 -		
   15.37 -	    strabon = new Strabon(databaseName, username, password, port, serverName, true);
   15.38 -		
   15.39 -		loadTestData();
   15.40 +	 TemplateTests.beforeClass();
   15.41  	}
   15.42  	
   15.43  	@AfterClass
   15.44  	public static void afterClass() throws SQLException
   15.45  	{
   15.46 -		strabon.close();
   15.47 +		TemplateTests.afterClass();
   15.48  	}
   15.49  	
   15.50 -}
   15.51 \ No newline at end of file
   15.52 +//	/**
   15.53 +//	 * @throws java.lang.Exception
   15.54 +//	 */
   15.55 +//	@Before
   15.56 +//	public void before()
   15.57 +//		throws Exception
   15.58 +//	{
   15.59 +//		
   15.60 +//	}
   15.61 +//
   15.62 +//	/**
   15.63 +//	 * @throws java.lang.Exception
   15.64 +//	 */
   15.65 +//	@After
   15.66 +//	public void after()
   15.67 +//		throws Exception
   15.68 +//	{
   15.69 +//		// Clean database
   15.70 +//		Statement stmt = conn.createStatement();
   15.71 +//		ResultSet results = stmt.executeQuery("SELECT table_name FROM information_schema.tables WHERE " +
   15.72 +//						"table_schema='public' and table_name <> 'spatial_ref_sys' " +
   15.73 +//						"and table_name <> 'geometry_columns' and " +
   15.74 +//						"table_name <> 'geography_columns' and table_name <> 'locked'");
   15.75 +//		while (results.next()) {
   15.76 +//			String table_name = results.getString("table_name");
   15.77 +//			Statement stmt2 = conn.createStatement();
   15.78 +//			stmt2.executeUpdate("DROP TABLE \""+table_name+"\"");
   15.79 +//			stmt2.close();
   15.80 +//		}
   15.81 +//			
   15.82 +//		stmt.close();
   15.83 +//	}
   15.84 +}