Strabon

changeset 153:3c20be4822f7

added Aggregate, General and HavingTests to strabon runtime test-suite (atsss)
author Konstantina Mpereta <grad1110@di.uoa.gr>
date Thu May 17 16:35:56 2012 +0300 (2012-05-17)
parents 362c84669d89
children aaba72872423
files mod.txt runtime/src/test/java/eu/earthobservatory/runtime/generaldb/AggregateTests.java runtime/src/test/java/eu/earthobservatory/runtime/generaldb/GeneralTests.java runtime/src/test/java/eu/earthobservatory/runtime/generaldb/HavingTests.java runtime/src/test/java/eu/earthobservatory/runtime/postgis/AggregateTests.java runtime/src/test/java/eu/earthobservatory/runtime/postgis/GeneralTests.java runtime/src/test/java/eu/earthobservatory/runtime/postgis/HavingTests.java
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/mod.txt	Thu May 17 16:35:56 2012 +0300
     1.3 @@ -0,0 +1,7 @@
     1.4 +mod.txt
     1.5 +runtime/src/test/java/eu/earthobservatory/runtime/generaldb/AggregateTests.java
     1.6 +runtime/src/test/java/eu/earthobservatory/runtime/generaldb/GeneralTests.java
     1.7 +runtime/src/test/java/eu/earthobservatory/runtime/generaldb/HavingTests.java
     1.8 +runtime/src/test/java/eu/earthobservatory/runtime/postgis/AggregateTests.java
     1.9 +runtime/src/test/java/eu/earthobservatory/runtime/postgis/GeneralTests.java
    1.10 +runtime/src/test/java/eu/earthobservatory/runtime/postgis/HavingTests.java
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/runtime/src/test/java/eu/earthobservatory/runtime/generaldb/AggregateTests.java	Thu May 17 16:35:56 2012 +0300
     2.3 @@ -0,0 +1,169 @@
     2.4 +package eu.earthobservatory.runtime.generaldb;
     2.5 +
     2.6 +import java.io.IOException;
     2.7 +import java.net.URL;
     2.8 +import java.sql.DriverManager;
     2.9 +import java.sql.SQLException;
    2.10 +import java.sql.Statement;
    2.11 +
    2.12 +import org.junit.AfterClass;
    2.13 +import org.junit.Test;
    2.14 +import org.openrdf.query.MalformedQueryException;
    2.15 +import org.openrdf.query.QueryEvaluationException;
    2.16 +import org.openrdf.query.TupleQueryResultHandlerException;
    2.17 +import org.openrdf.repository.RepositoryException;
    2.18 +import org.openrdf.rio.RDFHandlerException;
    2.19 +import org.openrdf.rio.RDFParseException;
    2.20 +
    2.21 +import eu.earthobservatory.runtime.generaldb.Strabon;
    2.22 +import eu.earthobservatory.runtime.postgis.SimpleTests;
    2.23 +
    2.24 +public class AggregateTests {
    2.25 +	public static Strabon strabon;
    2.26 +	
    2.27 +	
    2.28 +	protected static String jdbcDriver= "org.postgresql.Driver";  
    2.29 +	protected static String serverName = "localhost";
    2.30 +	protected static String username = "postgres";
    2.31 +	protected static String password = "postgres";
    2.32 +	protected static Integer port = 5432;
    2.33 +	protected static java.sql.Connection conn = null;
    2.34 +	protected static String databaseName = null; 
    2.35 +
    2.36 +//	@BeforeClass
    2.37 +//	public abstract static void initialize() throws SQLException, ClassNotFoundException
    2.38 +//	{
    2.39 +//		strabon = new Strabon("cco2","postgres","p1r3as", 5432, "localhost", true);
    2.40 +//	}
    2.41 +	
    2.42 +	protected static void loadTestData()
    2.43 +			throws RDFParseException, RepositoryException, IOException, RDFHandlerException, InvalidDatasetFormatFault
    2.44 +		{
    2.45 +			URL src = SimpleTests.class.getResource("/simple-tests.ntriples");
    2.46 +			strabon.storeInRepo(src, "NTRIPLES");
    2.47 +		}
    2.48 +
    2.49 +	@AfterClass
    2.50 +	public static void afterclass() throws SQLException
    2.51 +	{
    2.52 +strabon.close();
    2.53 +		
    2.54 +		conn.close();
    2.55 +		String url = "jdbc:postgresql://"+serverName+":"+port+"/template1";
    2.56 +		conn = DriverManager.getConnection(url, username, password);
    2.57 +		Statement stmt = conn.createStatement();
    2.58 +		stmt.executeUpdate("DROP DATABASE \""+databaseName+"\"");
    2.59 +		conn.close();
    2.60 +
    2.61 +	}
    2.62 +
    2.63 +	String prefixes = 
    2.64 +		"PREFIX lgdo:<http://linkedgeodata.org/ontology/> "+
    2.65 +		"PREFIX geo:<http://www.w3.org/2003/01/geo/wgs84_pos#> "+
    2.66 +		"PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#> "+
    2.67 +		"PREFIX strdf:<http://strdf.di.uoa.gr/ontology#> ";
    2.68 +
    2.69 +	String queryGroupBy1 = 
    2.70 +		prefixes+
    2.71 +		"SELECT (?placegeo AS ?xxx)  (AVG(?placegeo) AS ?av)  (strdf:union(?placegeo) AS ?united) "+
    2.72 +		"WHERE {  "+
    2.73 +		"?place  "+
    2.74 +		"rdfs:label ?placename ; "+ 	
    2.75 +		"geo:geometry ?placegeo ; "+
    2.76 +		"a ?type.  "+
    2.77 +		"FILTER(strdf:anyInteract(?placegeo,?placegeo)) "+ 
    2.78 +		"} "+
    2.79 +		"GROUP BY ?placegeo (STR(?place) AS ?str) strdf:union(?placegeo,?placegeo) "+
    2.80 +		"HAVING (AVG(?str) < 1) "+
    2.81 +		"ORDER BY ?placegeo strdf:union(?placegeo,?placegeo) "+
    2.82 +		"";
    2.83 +
    2.84 +	String queryGroupBy2 = 
    2.85 +		prefixes+
    2.86 +		"SELECT  (strdf:union(strdf:intersection(?placegeo,?placegeo2)) AS ?united) "+
    2.87 +		"WHERE {  "+
    2.88 +		"?place  "+
    2.89 +		"rdfs:label ?placename ; "+ 	
    2.90 +		"geo:geometry ?placegeo ; "+
    2.91 +		"geo:geometry ?placegeo2 ; "+
    2.92 +		"a ?type.  "+
    2.93 +		"FILTER(strdf:anyInteract(?placegeo,?placegeo)) "+ 
    2.94 +		"} "+
    2.95 +		"GROUP BY ?placegeo ?placegeo2";
    2.96 +
    2.97 +	String queryGroupBy3 = 
    2.98 +		prefixes+
    2.99 +		"SELECT  (strdf:union(strdf:intersection(?placegeo,?placegeo2)) AS ?united) "+
   2.100 +		"WHERE {  "+
   2.101 +		"?place  "+
   2.102 +		"rdfs:label ?placename ; 	 "+
   2.103 +		"geo:geometry ?placegeo ; "+
   2.104 +		"geo:geometry ?placegeo2 ; "+
   2.105 +		"a ?type.  "+
   2.106 +		"FILTER(strdf:anyInteract(?placegeo,?placegeo)) "+ 
   2.107 +		"} "+
   2.108 +		"GROUP BY ?placegeo ?placegeo2";
   2.109 +		
   2.110 +
   2.111 +	String queryOrder1 =
   2.112 +		prefixes+
   2.113 +		"SELECT ?placegeo ?place (strdf:union(?placegeo,?placegeo) AS ?koko) (strdf:union(?placegeo,?placegeo) AS ?kiki) "+ 
   2.114 +		"WHERE { "+ 
   2.115 +		"?place "+ 
   2.116 +		"rdfs:label ?placename ; "+ 	
   2.117 +		"geo:geometry ?placegeo ; "+
   2.118 +		"a ?type. "+ 
   2.119 +		"FILTER(strdf:anyInteract(?placegeo,?placegeo)) "+ 
   2.120 +		"} "+
   2.121 +		"ORDER BY strdf:union(?placegeo,?placegeo) ?placegeo ?place";
   2.122 +		
   2.123 +
   2.124 +	String queryOrder2 =
   2.125 +		prefixes+
   2.126 +		"SELECT (?place AS ?xx) (strdf:union(?placegeo,?placegeo) AS ?koko) ?place "+
   2.127 +		"WHERE {  "+
   2.128 +		"?place  "+
   2.129 +		"rdfs:label ?placename ; "+ 	
   2.130 +		"geo:geometry ?placegeo ; "+
   2.131 +		"a ?type.  "+
   2.132 +		"FILTER(strdf:anyInteract(?placegeo,?placegeo)) "+ 
   2.133 +		"} "+
   2.134 +		"ORDER BY ?placegeo ";
   2.135 +		
   2.136 +
   2.137 +	
   2.138 +	@Test
   2.139 +	public void testQueryGroupBy1() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   2.140 +	{
   2.141 +		strabon.query(queryGroupBy1,strabon.getSailRepoConnection());
   2.142 +
   2.143 +	}
   2.144 +
   2.145 +	@Test
   2.146 +	public void testQueryGroupBy2() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   2.147 +	{
   2.148 +		strabon.query(queryGroupBy2,strabon.getSailRepoConnection());
   2.149 +
   2.150 +	}
   2.151 +
   2.152 +	@Test
   2.153 +	public void testQueryGroupBy3() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   2.154 +	{
   2.155 +		strabon.query(queryGroupBy3,strabon.getSailRepoConnection());
   2.156 +
   2.157 +	}
   2.158 +
   2.159 +	@Test
   2.160 +	public void testQueryOrder1() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   2.161 +	{
   2.162 +		strabon.query(queryOrder1,strabon.getSailRepoConnection());
   2.163 +
   2.164 +	}
   2.165 +
   2.166 +	@Test
   2.167 +	public void testQueryOrder2() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   2.168 +	{
   2.169 +		strabon.query(queryOrder2,strabon.getSailRepoConnection());
   2.170 +
   2.171 +	}
   2.172 +}
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/runtime/src/test/java/eu/earthobservatory/runtime/generaldb/GeneralTests.java	Thu May 17 16:35:56 2012 +0300
     3.3 @@ -0,0 +1,636 @@
     3.4 +package eu.earthobservatory.runtime.generaldb;
     3.5 +
     3.6 +import java.io.IOException;
     3.7 +import java.sql.DriverManager;
     3.8 +import java.sql.SQLException;
     3.9 +import java.sql.Statement;
    3.10 +
    3.11 +import org.junit.AfterClass;
    3.12 +import org.junit.Test;
    3.13 +import org.openrdf.query.MalformedQueryException;
    3.14 +import org.openrdf.query.QueryEvaluationException;
    3.15 +import org.openrdf.query.TupleQueryResultHandlerException;
    3.16 +
    3.17 +import eu.earthobservatory.runtime.generaldb.Strabon;
    3.18 +
    3.19 +public class GeneralTests {
    3.20 +	public static Strabon strabon;
    3.21 +	
    3.22 +	
    3.23 +	protected static String jdbcDriver= "org.postgresql.Driver";  
    3.24 +	protected static String serverName = "localhost";
    3.25 +	protected static String username = "postgres";
    3.26 +	protected static String password = "postgres";
    3.27 +	protected static Integer port = 5432;
    3.28 +	protected static java.sql.Connection conn = null;
    3.29 +	protected static String databaseName = null; 
    3.30 +
    3.31 +	//	@BeforeClass
    3.32 +	//	public static void initialize() throws SQLException, ClassNotFoundException
    3.33 +	//	{
    3.34 +	//		strabon = new Strabon("cco2","postgres","p1r3as", 5432, "localhost", true);
    3.35 +	//
    3.36 +	//	}
    3.37 +
    3.38 +	@AfterClass
    3.39 +	public static void afterClass() throws SQLException
    3.40 +	{
    3.41 +		strabon.close();
    3.42 +		
    3.43 +		conn.close();
    3.44 +		String url = "jdbc:postgresql://"+serverName+":"+port+"/template1";
    3.45 +		conn = DriverManager.getConnection(url, username, password);
    3.46 +		Statement stmt = conn.createStatement();
    3.47 +		stmt.executeUpdate("DROP DATABASE \""+databaseName+"\"");
    3.48 +		conn.close();
    3.49 +	}
    3.50 +	
    3.51 +	
    3.52 +
    3.53 +	String prefixes = 
    3.54 +			"PREFIX lgdo:<http://linkedgeodata.org/ontology/> "+
    3.55 +					"PREFIX geo:<http://www.w3.org/2003/01/geo/wgs84_pos#> "+
    3.56 +					"PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#> "+
    3.57 +					"PREFIX strdf:<http://strdf.di.uoa.gr/ontology#> "+
    3.58 +					"PREFIX geonames:<http://www.geonames.org/ontology/>";
    3.59 +
    3.60 +	String query1 = 
    3.61 +			prefixes+
    3.62 +			"SELECT ?place ?placegeo "+ 
    3.63 +			"WHERE { "+
    3.64 +			"?place "+
    3.65 +			"rdfs:label ?placename ; "+	
    3.66 +			"geo:geometry ?placegeo ; "+
    3.67 +			"a ?type. "+
    3.68 +			"FILTER(strdf:anyInteract(strdf:union(?placegeo,?placegeo),?placegeo)) "+
    3.69 +			"}";
    3.70 +
    3.71 +	String query2 = 
    3.72 +			prefixes+
    3.73 +			"SELECT ?place (?placegeo AS ?tt1) (strdf:union(?placegeo,?placegeo) AS ?constr) "+
    3.74 +			"WHERE { "+
    3.75 +			"?place "+
    3.76 +			"a ?type ; "+
    3.77 +			"geo:geometry ?placegeo ; "+
    3.78 +			"rdfs:label ?placename . "+
    3.79 +			"FILTER(strdf:anyInteract(strdf:union(?placegeo,?placegeo),?placegeo)) "+
    3.80 +			"}";
    3.81 +
    3.82 +	String query3 = 
    3.83 +			prefixes+
    3.84 +			"SELECT ?place (?placegeo AS ?constr) "+
    3.85 +			"WHERE { "+
    3.86 +			"?place "+
    3.87 +			"a ?type ; "+
    3.88 +			"geo:geometry ?placegeo ; "+
    3.89 +			"rdfs:label ?placename . "+
    3.90 +			"FILTER(strdf:anyInteract(strdf:union(?placegeo,?placegeo),?placegeo)) "+
    3.91 +			"}";
    3.92 +
    3.93 +	String query4 =
    3.94 +			prefixes+
    3.95 +			"SELECT ?place ?placegeo "+
    3.96 +			"WHERE { "+
    3.97 +			"?place "+
    3.98 +			"a ?type ; "+
    3.99 +			"geo:geometry ?placegeo ; "+
   3.100 +			"rdfs:label ?placename . "+
   3.101 +			"FILTER(strdf:anyInteract(strdf:union(?placegeo,?placegeo),?placegeo) " +
   3.102 +			"&& strdf:anyInteract(strdf:union(?placegeo,?placegeo),?placegeo)) "+
   3.103 +			"}";
   3.104 +
   3.105 +	String query5 =
   3.106 +			prefixes+
   3.107 +			"SELECT ?place ?placegeo "+
   3.108 +			"WHERE { "+
   3.109 +			"?place "+
   3.110 +			"a ?type ; "+
   3.111 +			"geo:geometry ?placegeo ; "+
   3.112 +			"rdfs:label ?placename . "+
   3.113 +			"FILTER(strdf:anyInteract(strdf:union(?placegeo,?placegeo),?placegeo)). "+
   3.114 +			"FILTER(strdf:anyInteract(strdf:union(?placegeo,?placegeo),?placegeo)). "+
   3.115 +			"}";
   3.116 +
   3.117 +	String query6 =
   3.118 +			prefixes+
   3.119 +			"SELECT (strdf:union(?placegeo,strdf:union(?placegeo,?placegeo)) AS ?constr1) " +
   3.120 +			"?place (?placegeo AS ?tt1) (strdf:union(?placegeo,?placegeo) AS ?constr2) "+
   3.121 +			"WHERE { "+
   3.122 +			"?place "+
   3.123 +			"a ?type ; "+
   3.124 +			"geo:geometry ?placegeo ; "+
   3.125 +			"rdfs:label ?placename . "+
   3.126 +			"FILTER(strdf:anyInteract(strdf:union(?placegeo,?placegeo),?placegeo)) "+
   3.127 +			"}";
   3.128 +
   3.129 +	String query7 = 
   3.130 +			prefixes+
   3.131 +			"SELECT ?place (?placegeo AS ?tt1) (strdf:union(?placegeo,?placegeo) AS ?constr) "+
   3.132 +			"WHERE { "+
   3.133 +			"?place "+
   3.134 +			"      a ?type ; "+
   3.135 +			"       geo:geometry ?placegeo ; "+
   3.136 +			"        rdfs:label ?placename . "+
   3.137 +			"} ";
   3.138 +
   3.139 +	String query8 = 
   3.140 +			prefixes+
   3.141 +			"SELECT ?place "+  
   3.142 +			"WHERE { "+
   3.143 +			"?place "+
   3.144 +			"a ?type ; "+
   3.145 +			"geo:geometry ?placegeo ; "+
   3.146 +			"rdfs:label ?placename . "+
   3.147 +			"FILTER(strdf:anyInteract(?placegeo,?placegeo)) "+
   3.148 +			"}";
   3.149 +
   3.150 +	String queryBufferVar =
   3.151 +			prefixes+
   3.152 +			"SELECT  ?place (?placegeo AS ?tt1)  "+
   3.153 +			"WHERE {  ?x lgdo:bufferExtent ?ext .  "+ 
   3.154 +			"?place "+
   3.155 +			"a ?type ; "+
   3.156 +			"geo:geometry ?placegeo ; "+
   3.157 +			"rdfs:label ?placename . "+
   3.158 +			"FILTER(strdf:anyInteract(strdf:buffer(?placegeo,?ext),?placegeo)) "+
   3.159 +			"}";
   3.160 +
   3.161 +	String queryBufferConst =
   3.162 +			prefixes+
   3.163 +			"SELECT  ?place (?placegeo AS ?tt1)  "+
   3.164 +			"WHERE {  ?x lgdo:bufferExtent ?ext .  "+ 
   3.165 +			"?place "+
   3.166 +			"a ?type ; "+
   3.167 +			"geo:geometry ?placegeo ; "+
   3.168 +			"rdfs:label ?placename . "+
   3.169 +			"FILTER(strdf:anyInteract(strdf:buffer(?placegeo,2),?placegeo)) "+
   3.170 +			"}";
   3.171 +
   3.172 +	String queryBufferConst2 =
   3.173 +			prefixes+
   3.174 +			"SELECT  ?place (?placegeo AS ?tt1)  "+
   3.175 +			"WHERE {  ?x lgdo:bufferExtent ?ext .  "+ 
   3.176 +			"?place "+
   3.177 +			"a ?type ; "+
   3.178 +			"geo:geometry ?placegeo ; "+
   3.179 +			"rdfs:label ?placename . "+
   3.180 +			"FILTER(strdf:anyInteract(strdf:buffer(\"POINT(23.72873 37.97205)\"^^<http://strdf.di.uoa.gr/ontology#WKT>,0.0572),?placegeo)) "+
   3.181 +			"}";
   3.182 +
   3.183 +	String queryBufferConstInSelect =
   3.184 +			prefixes+
   3.185 +			"SELECT  ?place (?placegeo AS ?tt1) (strdf:buffer(?placegeo,2) AS ?buf) "+
   3.186 +			"WHERE {  ?x lgdo:bufferExtent ?ext .  "+ 
   3.187 +			"?place "+
   3.188 +			"a ?type ; "+
   3.189 +			"geo:geometry ?placegeo ; "+
   3.190 +			"rdfs:label ?placename . "+
   3.191 +			"FILTER(strdf:anyInteract(strdf:buffer(?placegeo,2),?placegeo)) "+
   3.192 +			"}";
   3.193 +
   3.194 +
   3.195 +	String queryBufferSelectFilterA =
   3.196 +			prefixes+
   3.197 +			"SELECT  ?place (?placegeo AS ?tt1) (strdf:buffer(?placegeo,?ext) AS ?buf) "+
   3.198 +			"WHERE { ?x lgdo:bufferExtent ?ext . "+ 
   3.199 +			"?place "+
   3.200 +			"a ?type ; "+
   3.201 +			"geo:geometry ?placegeo ; "+
   3.202 +			"rdfs:label ?placename . "+
   3.203 +			"FILTER(strdf:anyInteract(strdf:buffer(?placegeo,2),?placegeo)) "+
   3.204 +			"}";
   3.205 +
   3.206 +	String queryBufferSelectFilterB =
   3.207 +			prefixes+
   3.208 +			"SELECT  ?place (?placegeo AS ?tt1) (strdf:buffer(?placegeo,3) AS ?buf) "+
   3.209 +			"WHERE { ?x lgdo:bufferExtent ?ext . "+ 
   3.210 +			"?place "+
   3.211 +			"a ?type ; "+
   3.212 +			"geo:geometry ?placegeo ; "+
   3.213 +			"rdfs:label ?placename . "+
   3.214 +			"FILTER(strdf:anyInteract(strdf:buffer(?placegeo,?ext),?placegeo)) "+
   3.215 +			"}";
   3.216 +
   3.217 +	String queryEnvelopeConvexHull = 
   3.218 +			prefixes+
   3.219 +			"SELECT ?place (?placegeo AS ?tt1) (strdf:envelope(?placegeo) AS ?constr)  (strdf:convexHull(?placegeo) AS ?constr2) "+ 
   3.220 +			"WHERE { "+
   3.221 +			"                     ?place "+
   3.222 +			"                            a ?type ; "+
   3.223 +			"                            geo:geometry ?placegeo ; "+
   3.224 +			"                           rdfs:label ?placename . "+
   3.225 +			"		     FILTER(strdf:anyInteract(strdf:union(?placegeo,strdf:envelope(?placegeo)),?placegeo) && strdf:anyInteract(strdf:convexHull(?placegeo),?placegeo)) "+
   3.226 +			"}";
   3.227 +
   3.228 +	String queryMetrics1 =
   3.229 +			prefixes+
   3.230 +			"SELECT ?place ?placegeo  ( strdf:area(?placegeo) AS ?area) "+
   3.231 +			"( strdf:envelope(?placegeo) AS ?mbb) "+
   3.232 +			"WHERE {   ?x lgdo:bufferExtent ?ext .  "+
   3.233 +			"?place "+
   3.234 +			"rdfs:label ?placename ; "+	
   3.235 +			"geo:geometry ?placegeo ; "+
   3.236 +			"a ?type. "+
   3.237 +			"FILTER(2*strdf:distance(?placegeo,?placegeo) + strdf:area(?placegeo) - 3 + ?ext  "+
   3.238 +			"< ?ext + 8 - strdf:distance(?placegeo,?placegeo)) "+
   3.239 +			"}";
   3.240 +
   3.241 +	String queryMetricsLightOptimized = 
   3.242 +			prefixes+
   3.243 +			"SELECT ?place ?placegeo  ( 33*strdf:area(?placegeo) + 114 AS ?area) ( strdf:envelope(?placegeo) AS ?mbb) "+
   3.244 +			"WHERE {   ?x lgdo:bufferExtent ?ext . "+ 
   3.245 +			"?place "+
   3.246 +			"rdfs:label ?placename ; "+	
   3.247 +			"geo:geometry ?placegeo ; "+
   3.248 +			"a ?type. "+
   3.249 +			"FILTER(2*strdf:distance(?placegeo,?placegeo) < 8) "+
   3.250 +			"}";
   3.251 +
   3.252 +	//Metrics with only one var must not be optimized
   3.253 +	String queryMetricsAreaMustNotBeOptimized =
   3.254 +			prefixes+
   3.255 +			"SELECT ?place ?placegeo  ( 33*strdf:area(?placegeo) + 114 AS ?area) ( strdf:envelope(?placegeo) AS ?mbb) "+
   3.256 +			"WHERE {   ?x lgdo:bufferExtent ?ext . "+ 
   3.257 +			"?place "+
   3.258 +			"rdfs:label ?placename ; "+	
   3.259 +			"geo:geometry ?placegeo ; "+
   3.260 +			"a ?type. "+
   3.261 +			"FILTER(2*strdf:area(?placegeo) < 8) "+
   3.262 +			"}";
   3.263 +
   3.264 +	String queryMetricsMathInSelect =
   3.265 +			prefixes+
   3.266 +			"SELECT ?place ?placegeo  ( 33*strdf:area(?placegeo) + 114 AS ?area) ( strdf:envelope(?placegeo) AS ?mbb) "+
   3.267 +			"WHERE {   ?x lgdo:bufferExtent ?ext . "+ 
   3.268 +			"?place "+
   3.269 +			"rdfs:label ?placename ; "+	
   3.270 +			"geo:geometry ?placegeo ; "+
   3.271 +			"a ?type. "+
   3.272 +			"FILTER(2*strdf:distance(?placegeo,?placegeo) + strdf:area(?placegeo) - 3 + ?ext " +
   3.273 +			"< ?ext + 8 - strdf:distance(?placegeo,?placegeo)) "+
   3.274 +			"}";
   3.275 +
   3.276 +	String querySpatialProperties = 
   3.277 +			prefixes+
   3.278 +			"SELECT ?place ?placegeo (strdf:dimension(?placegeo) + 2 AS ?dim) (strdf:srid(?placegeo) AS ?srid) "+
   3.279 +			"WHERE { "+
   3.280 +			"?place "+
   3.281 +			"rdfs:label ?placename ; "+	
   3.282 +			"geo:geometry ?placegeo ; "+
   3.283 +			"a ?type. "+
   3.284 +			"FILTER(strdf:anyInteract(strdf:union(?placegeo,?placegeo),?placegeo) && strdf:isSimple(?placegeo) "+ 
   3.285 +			"&& strdf:dimension(?placegeo) - 1 < 3) "+
   3.286 +			"}";
   3.287 +
   3.288 +	String querySpatialPropertiesConst = 
   3.289 +			prefixes+
   3.290 +			"SELECT ?place ?placegeo (strdf:srid(?placegeo) AS ?srid) (strdf:dimension(?placegeo) + 2 AS ?dim)  "+
   3.291 +			"WHERE { "+
   3.292 +			"?place "+
   3.293 +			"rdfs:label ?placename ; "+	
   3.294 +			"geo:geometry ?placegeo ; "+
   3.295 +			"a ?type. "+
   3.296 +			"FILTER(strdf:anyInteract(strdf:union(?placegeo,?placegeo),?placegeo) && strdf:isSimple(?placegeo) "+ 
   3.297 +			"&& strdf:dimension(\"POINT(0 0)\") - 1 < 3) "+
   3.298 +			"}";
   3.299 +
   3.300 +	String queryRelate = 
   3.301 +			prefixes+
   3.302 +			"SELECT ?place ?placegeo "+
   3.303 +			"WHERE { "+
   3.304 +			"?place "+
   3.305 +			"rdfs:label ?placename ; "+	
   3.306 +			"geo:geometry ?placegeo ; "+
   3.307 +			"a ?type. "+
   3.308 +			"FILTER(strdf:relate(?placegeo,?placegeo,\"0FFFFF212\")) "+
   3.309 +			"}";
   3.310 +
   3.311 +	//	String queryThematicUnion = 
   3.312 +	//			prefixes+
   3.313 +	//			"SELECT ?place "+
   3.314 +	//			"WHERE { "+
   3.315 +	//			"?place "+
   3.316 +	//			"rdfs:label ?placename ; "+	
   3.317 +	//			"geo:geometry ?placegeo. "+ 
   3.318 +	//			"{?place a lgdo:Pier . } " +
   3.319 +	//			"UNION" +
   3.320 +	//			"{?place a lgdo:Harbour . } }";
   3.321 +
   3.322 +	
   3.323 +	/**
   3.324 +	 * The following three queries test potential bugs noticed during the evaluation process for www2012.
   3.325 +	 * No issue seems to be present.
   3.326 +	 */
   3.327 +	String queryThematicUnion = 
   3.328 +			prefixes+
   3.329 +			"SELECT ?place2 ?placename "+
   3.330 +			" WHERE { "+
   3.331 +			" ?place2 rdfs:label ?placename. "+	
   3.332 +			" ?place2 strdf:hasGeometry ?placegeo.  " +
   3.333 +			"{" +
   3.334 +			" ?place2 a <http://linkedgeodata.org/ontology#Harbour> ." +
   3.335 +			" } " +
   3.336 +			"UNION" +
   3.337 +			"{" +
   3.338 +			" ?place2 a <http://linkedgeodata.org/ontology#Pier> ." +
   3.339 +			" } " +
   3.340 +			"<http://www.geonames.org/ontology/Athens> strdf:hasGeometry ?ar . " +
   3.341 +			"FILTER(strdf:disjoint(?placegeo,?ar))" +
   3.342 +			"}";
   3.343 +
   3.344 +	String query6_real = prefixes+
   3.345 +			"SELECT ?capital ?pierLabel "+
   3.346 +			"WHERE  "+
   3.347 +			"{ "+
   3.348 +			"?country a <http://dbpedia.org/resource/Country> . "+
   3.349 +			"?country <http://dbpedia.org/property/capital> ?capital_label . "+
   3.350 +			"?capital <http://www.w3.org/2000/01/rdf-schema#label> ?capital_label . "+
   3.351 +			"?capitalGeoNames <http://www.w3.org/2002/07/owl#sameAs> ?capital . "+
   3.352 +			"?capitalGeoNames strdf:hasGeometry ?capitalGeo . "+
   3.353 +			"OPTIONAL "+ 
   3.354 +			"{ "+ 
   3.355 +			" ?pier a <http://linkedgeodata.org/ontology#Pier> . " +
   3.356 +			" ?pier rdfs:label ?pierLabel . "+
   3.357 +			" ?pier strdf:hasGeometry ?pierGeo . "+
   3.358 +			" FILTER(strdf:distance(?capitalGeo,?pierGeo) < 3.7) "+
   3.359 +			"} "+
   3.360 +			"} ";
   3.361 +
   3.362 +	String query6_real_union = prefixes+
   3.363 +			"SELECT ?capital ?pierLabel "+
   3.364 +			"WHERE  "+
   3.365 +			"{ "+
   3.366 +			"?country a <http://dbpedia.org/resource/Country> . "+
   3.367 +			"?country <http://dbpedia.org/property/capital> ?capital_label . "+
   3.368 +			"?capital <http://www.w3.org/2000/01/rdf-schema#label> ?capital_label . "+
   3.369 +			"?capitalGeoNames <http://www.w3.org/2002/07/owl#sameAs> ?capital . "+
   3.370 +			"?capitalGeoNames strdf:hasGeometry ?capitalGeo . "+
   3.371 +			"OPTIONAL "+ 
   3.372 +			"{ "+ 
   3.373 +			" { " +
   3.374 +			"?pier a <http://linkedgeodata.org/ontology#Pier> . " +
   3.375 +			"}" +
   3.376 +			" UNION" +
   3.377 +			" { " +
   3.378 +			"?pier a <http://linkedgeodata.org/ontology#Harbour> . " +
   3.379 +			"}" +
   3.380 +			" ?pier rdfs:label ?pierLabel . "+
   3.381 +			" ?pier strdf:hasGeometry ?pierGeo . "+
   3.382 +			" FILTER(strdf:distance(?capitalGeo,?pierGeo) < 3.7) "+
   3.383 +			"} "+
   3.384 +			"} ";
   3.385 +
   3.386 +	String queryNegation = prefixes+
   3.387 +			"SELECT ?capital ?pier "+
   3.388 +			"WHERE  "+
   3.389 +			"{ "+
   3.390 +			" ?country a <http://dbpedia.org/resource/Country> . "+
   3.391 +			" ?country <http://dbpedia.org/property/capital> ?capital_label . "+
   3.392 +			" ?capital <http://www.w3.org/2000/01/rdf-schema#label> ?capital_label . "+
   3.393 +			" ?capitalGeoNames <http://www.w3.org/2002/07/owl#sameAs> ?capital . "+
   3.394 +			" ?capitalGeoNames strdf:hasGeometry ?capitalGeo . "+
   3.395 +			"OPTIONAL "+
   3.396 +			"{ "+ 
   3.397 +			" ?pier a <http://linkedgeodata.org/ontology#Harbour> . " +
   3.398 +			" ?pier rdfs:label ?pierLabel . "+
   3.399 +			" ?pier strdf:hasGeometry ?pierGeo . "+
   3.400 +			" FILTER(strdf:distance(?capitalGeo,?pierGeo) < 3.7) "+
   3.401 +			"} . " +
   3.402 +			"FILTER (!bound(?pier))" +
   3.403 +			"} "+
   3.404 +			"";
   3.405 +	
   3.406 +	//Representative of functionality. If I remove !bound, 3 more results appear
   3.407 +	String queryNegation2 = prefixes+
   3.408 +			"SELECT ?s ?pier "+
   3.409 +			"WHERE  "+
   3.410 +			"{ "+
   3.411 +			" ?s strdf:hasGeometry ?geo1 . "+
   3.412 +			"OPTIONAL "+
   3.413 +			"{ "+ 
   3.414 +			" ?pier a <http://linkedgeodata.org/ontology#Harbour> . " +
   3.415 +			" ?pier rdfs:label ?pierLabel . "+
   3.416 +			" ?pier strdf:hasGeometry ?pierGeo . "+
   3.417 +			" FILTER(strdf:distance(?geo1,?pierGeo) < 0.6) "+
   3.418 +			"} . " +
   3.419 +			"FILTER (!bound(?pier))" +
   3.420 +			"} "+
   3.421 +			"";
   3.422 +	
   3.423 +	
   3.424 +	String queryNotExists = 
   3.425 +		prefixes+
   3.426 +		"SELECT ?capital ?pierLabel "+
   3.427 +		"WHERE  "+
   3.428 +		"{ "+
   3.429 +		"?country a <http://dbpedia.org/resource/Country> . "+
   3.430 +		"?country <http://dbpedia.org/property/capital> ?capital_label . "+
   3.431 +		"?capital <http://www.w3.org/2000/01/rdf-schema#label> ?capital_label . "+
   3.432 +		"?capitalGeoNames <http://www.w3.org/2002/07/owl#sameAs> ?capital . "+
   3.433 +		"?capitalGeoNames strdf:hasGeometry ?capitalGeo . "+
   3.434 +		" ?pier a <http://linkedgeodata.org/ontology#Pier> . " +
   3.435 +		" ?pier rdfs:label ?pierLabel . "+
   3.436 +		" ?pier strdf:hasGeometry ?pierGeo . "+
   3.437 +//		" FILTER NOT EXISTS { ?pier rdfs:label \"Kikirikou\". " +
   3.438 +//		"FILTER(strdf:distance(?capitalGeo,?pierGeo) > 3.7) " +
   3.439 +		" FILTER NOT EXISTS { ?pier rdfs:label ?label2. FILTER(?label2 != ?pierLabel)" +
   3.440 +		"}"+
   3.441 +		"} ";
   3.442 +	
   3.443 +	//TODO At some point I should also add a test where the 3rd argument of strdf:relate is a variable
   3.444 +
   3.445 +	@Test
   3.446 +	public void testQuery1() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   3.447 +	{
   3.448 +		strabon.query(query1,strabon.getSailRepoConnection());
   3.449 +
   3.450 +	}
   3.451 +
   3.452 +	@Test
   3.453 +	public void testQuery2() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   3.454 +	{
   3.455 +		strabon.query(query2,strabon.getSailRepoConnection());
   3.456 +
   3.457 +	}
   3.458 +
   3.459 +	@Test
   3.460 +	public void testQuery3() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   3.461 +	{
   3.462 +		strabon.query(query3,strabon.getSailRepoConnection());
   3.463 +
   3.464 +	}
   3.465 +
   3.466 +	@Test
   3.467 +	public void testQuery4() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   3.468 +	{
   3.469 +		strabon.query(query4,strabon.getSailRepoConnection());
   3.470 +
   3.471 +	}
   3.472 +
   3.473 +	@Test
   3.474 +	public void testQuery5() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   3.475 +	{
   3.476 +		strabon.query(query5,strabon.getSailRepoConnection());
   3.477 +
   3.478 +	}
   3.479 +
   3.480 +	@Test
   3.481 +	public void testQuery6() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   3.482 +	{
   3.483 +		strabon.query(query6,strabon.getSailRepoConnection());
   3.484 +
   3.485 +	}
   3.486 +
   3.487 +	@Test
   3.488 +	public void testQuery7() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   3.489 +	{
   3.490 +		strabon.query(query7,strabon.getSailRepoConnection());
   3.491 +
   3.492 +	}
   3.493 +
   3.494 +	@Test
   3.495 +	public void testQuery8() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   3.496 +	{
   3.497 +		strabon.query(query8,strabon.getSailRepoConnection());
   3.498 +
   3.499 +	}
   3.500 +
   3.501 +	@Test
   3.502 +	public void testQueryBufferVar() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   3.503 +	{
   3.504 +		strabon.query(queryBufferVar,strabon.getSailRepoConnection());
   3.505 +
   3.506 +	}
   3.507 +
   3.508 +	@Test
   3.509 +	public void testQueryBufferConst() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   3.510 +	{
   3.511 +		strabon.query(queryBufferConst,strabon.getSailRepoConnection());
   3.512 +
   3.513 +	}
   3.514 +
   3.515 +	@Test
   3.516 +	public void testQueryBufferConst2() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   3.517 +	{
   3.518 +		strabon.query(queryBufferConst2,strabon.getSailRepoConnection());
   3.519 +
   3.520 +	}
   3.521 +
   3.522 +	@Test
   3.523 +	public void testQueryBufferConstInSelect() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   3.524 +	{
   3.525 +		strabon.query(queryBufferConstInSelect,strabon.getSailRepoConnection());
   3.526 +
   3.527 +	}
   3.528 +
   3.529 +	@Test
   3.530 +	public void testQueryBufferSelectFilterA() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   3.531 +	{
   3.532 +		strabon.query(queryBufferSelectFilterA,strabon.getSailRepoConnection());
   3.533 +
   3.534 +	}
   3.535 +
   3.536 +	@Test
   3.537 +	public void testQueryBufferSelectFilterB() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   3.538 +	{
   3.539 +		strabon.query(queryBufferSelectFilterB,strabon.getSailRepoConnection());
   3.540 +
   3.541 +	}
   3.542 +
   3.543 +	@Test
   3.544 +	public void testQueryEnvelopeConvexHull() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   3.545 +	{
   3.546 +		strabon.query(queryBufferSelectFilterB,strabon.getSailRepoConnection());
   3.547 +
   3.548 +	}
   3.549 +
   3.550 +	@Test
   3.551 +	public void testQueryMetrics1() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   3.552 +	{
   3.553 +		strabon.query(queryMetrics1,strabon.getSailRepoConnection());
   3.554 +
   3.555 +	}
   3.556 +
   3.557 +	@Test
   3.558 +	public void testQueryMetricsLightOptimized() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   3.559 +	{
   3.560 +		strabon.query(queryMetricsLightOptimized,strabon.getSailRepoConnection());
   3.561 +
   3.562 +	}
   3.563 +
   3.564 +	@Test
   3.565 +	public void testQueryMetricsAreaMustNotBeOptimized() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   3.566 +	{
   3.567 +		strabon.query(queryMetricsLightOptimized,strabon.getSailRepoConnection());
   3.568 +
   3.569 +	}
   3.570 +
   3.571 +	@Test
   3.572 +	public void testQueryMetricsMathInSelect() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   3.573 +	{
   3.574 +		strabon.query(queryMetricsMathInSelect,strabon.getSailRepoConnection());
   3.575 +
   3.576 +	}
   3.577 +
   3.578 +	@Test
   3.579 +	public void testQuerySpatialProperties() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   3.580 +	{
   3.581 +		strabon.query(querySpatialProperties,strabon.getSailRepoConnection());
   3.582 +
   3.583 +	}
   3.584 +
   3.585 +	@Test
   3.586 +	public void testQuerySpatialPropertiesConst() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   3.587 +	{
   3.588 +		strabon.query(querySpatialPropertiesConst,strabon.getSailRepoConnection());
   3.589 +
   3.590 +	}
   3.591 +
   3.592 +	@Test
   3.593 +	public void testQueryRelate() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   3.594 +	{
   3.595 +		strabon.query(queryRelate,strabon.getSailRepoConnection());
   3.596 +
   3.597 +	}
   3.598 +
   3.599 +	@Test
   3.600 +	public void testQueryThematicUnion() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   3.601 +	{
   3.602 +		strabon.query(queryThematicUnion,strabon.getSailRepoConnection());
   3.603 +
   3.604 +	}
   3.605 +
   3.606 +	@Test
   3.607 +	public void testQuery6_real() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   3.608 +	{
   3.609 +		strabon.query(query6_real,strabon.getSailRepoConnection());
   3.610 +
   3.611 +	}
   3.612 +
   3.613 +	@Test
   3.614 +	public void testQuery6_real_union() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   3.615 +	{
   3.616 +		strabon.query(query6_real_union,strabon.getSailRepoConnection());
   3.617 +
   3.618 +	}
   3.619 +	@Test
   3.620 +	public void testQueryNegation() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   3.621 +	{
   3.622 +		strabon.query(queryNegation,strabon.getSailRepoConnection());
   3.623 +
   3.624 +	}	
   3.625 +	@Test
   3.626 +	public void testQueryNegation2() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   3.627 +	{
   3.628 +		strabon.query(queryNegation2,strabon.getSailRepoConnection());
   3.629 +
   3.630 +	}	
   3.631 +
   3.632 +//		@Test
   3.633 +//		public void testPrintDataset() throws MalformedQueryException
   3.634 +//		{
   3.635 +//				String query = "SELECT ?s ?p ?o WHERE { ?s ?p ?o }";
   3.636 +//				strabon.query(query,strabon.getSailRepoConnection());
   3.637 +//	
   3.638 +//		}
   3.639 +}
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/runtime/src/test/java/eu/earthobservatory/runtime/generaldb/HavingTests.java	Thu May 17 16:35:56 2012 +0300
     4.3 @@ -0,0 +1,142 @@
     4.4 +package eu.earthobservatory.runtime.generaldb;
     4.5 +
     4.6 +import java.io.IOException;
     4.7 +import java.net.URL;
     4.8 +import java.sql.DriverManager;
     4.9 +import java.sql.SQLException;
    4.10 +import java.sql.Statement;
    4.11 +
    4.12 +import org.junit.AfterClass;
    4.13 +import org.junit.Test;
    4.14 +import org.openrdf.query.MalformedQueryException;
    4.15 +import org.openrdf.query.QueryEvaluationException;
    4.16 +import org.openrdf.query.TupleQueryResultHandlerException;
    4.17 +import org.openrdf.repository.RepositoryException;
    4.18 +import org.openrdf.rio.RDFHandlerException;
    4.19 +import org.openrdf.rio.RDFParseException;
    4.20 +
    4.21 +import eu.earthobservatory.runtime.generaldb.Strabon;
    4.22 +import eu.earthobservatory.runtime.postgis.SimpleTests;
    4.23 +
    4.24 +public class HavingTests {
    4.25 +	public static Strabon strabon;
    4.26 +	
    4.27 +
    4.28 +	protected static String jdbcDriver= "org.postgresql.Driver";  
    4.29 +	protected static String serverName = "localhost";
    4.30 +	protected static String username = "postgres";
    4.31 +	protected static String password = "postgres";
    4.32 +	protected static Integer port = 5432;
    4.33 +	protected static java.sql.Connection conn = null;
    4.34 +	protected static String databaseName = null; 
    4.35 +
    4.36 +	//	@BeforeClass
    4.37 +	//	public abstract static void initialize() throws SQLException, ClassNotFoundException
    4.38 +	//	{
    4.39 +	//		strabon = new Strabon("cco2","postgres","p1r3as", 5432, "localhost", true);
    4.40 +	//	}
    4.41 +	@AfterClass
    4.42 +	public static void afterClass() throws SQLException
    4.43 +	{
    4.44 +		strabon.close();
    4.45 +		
    4.46 +		conn.close();
    4.47 +		String url = "jdbc:postgresql://"+serverName+":"+port+"/template1";
    4.48 +		conn = DriverManager.getConnection(url, username, password);
    4.49 +		Statement stmt = conn.createStatement();
    4.50 +		stmt.executeUpdate("DROP DATABASE \""+databaseName+"\"");
    4.51 +		conn.close();
    4.52 +	}
    4.53 +
    4.54 +	String prefixes =
    4.55 +			" PREFIX noa:<http://www.earthobservatory.eu/ontologies/noaOntology.owl#>"+
    4.56 +					" PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>"+
    4.57 +					" PREFIX strdf:<http://strdf.di.uoa.gr/ontology#> ";
    4.58 +
    4.59 +
    4.60 +
    4.61 +
    4.62 +	String query1Having = prefixes + 
    4.63 +			"SELECT ?burntArea ?baGeo "+ 
    4.64 +			"WHERE { "+ 
    4.65 +			"?burntArea a noa:BurntArea; "+ 
    4.66 +			"strdf:hasGeometry ?baGeo. "+ 
    4.67 +			"?urbanArea a noa:UrbanArea; "+ 
    4.68 +			"strdf:hasGeometry ?uaGeo; "+ 
    4.69 +			"FILTER(strdf:anyInteract(?baGeo,?uaGeo)). "+
    4.70 +			"} "+
    4.71 +			"GROUP BY ?burntArea ?baGeo "+
    4.72 +			"HAVING (strdf:area(strdf:union(?uaGeo)) > 8) ";
    4.73 +
    4.74 +	String query2HavingA = prefixes + 
    4.75 +	"SELECT ?burntArea ?baGeo (strdf:extent(?uaGeo) AS ?totalMBB) "+ 
    4.76 +	"WHERE { "+ 
    4.77 +	"?burntArea a noa:BurntArea; "+ 
    4.78 +	"strdf:hasGeometry ?baGeo. "+ 
    4.79 +	"?urbanArea a noa:UrbanArea; "+ 
    4.80 +	"strdf:hasGeometry ?uaGeo; "+ 
    4.81 +	"FILTER(strdf:anyInteract(?baGeo,?uaGeo)). "+
    4.82 +	"} "+
    4.83 +	"GROUP BY ?burntArea ?baGeo "+
    4.84 +	"HAVING (strdf:area(strdf:extent(?uaGeo)) > 8) ";
    4.85 +	
    4.86 +	String query2HavingB = prefixes + 
    4.87 +	"SELECT ?burntArea ?baGeo (strdf:difference(strdf:extent(?uaGeo),strdf:union(?uaGeo)) AS ?MBBdiff) "+ 
    4.88 +	"WHERE { "+ 
    4.89 +	"?burntArea a noa:BurntArea; "+ 
    4.90 +	"strdf:hasGeometry ?baGeo. "+ 
    4.91 +	"?urbanArea a noa:UrbanArea; "+ 
    4.92 +	"strdf:hasGeometry ?uaGeo; "+ 
    4.93 +	"FILTER(strdf:anyInteract(?baGeo,?uaGeo)). "+
    4.94 +	"} "+
    4.95 +	"GROUP BY ?burntArea ?baGeo "+
    4.96 +	"HAVING (strdf:area(strdf:extent(?uaGeo)) > 8) ";
    4.97 +	
    4.98 +	String query2HavingC = prefixes + 
    4.99 +	"SELECT ?burntArea (strdf:extent(?uaGeo) AS ?totalMBB) "+ 
   4.100 +	"WHERE { "+ 
   4.101 +	"?burntArea a noa:BurntArea; "+ 
   4.102 +	"strdf:hasGeometry ?baGeo. "+ 
   4.103 +	"?urbanArea a noa:UrbanArea; "+ 
   4.104 +	"strdf:hasGeometry ?uaGeo; "+ 
   4.105 +	"FILTER(strdf:anyInteract(?baGeo,?uaGeo)). "+
   4.106 +	"} "+
   4.107 +	"GROUP BY ?burntArea "+
   4.108 +	"HAVING (strdf:area(strdf:extent(?uaGeo)) < 8) ";
   4.109 +	
   4.110 +	@Test
   4.111 +	public void testQuery1Having() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   4.112 +	{
   4.113 +		strabon.query(query1Having,strabon.getSailRepoConnection());
   4.114 +
   4.115 +	}
   4.116 +	
   4.117 +	@Test
   4.118 +	public void testQuery2HavingA() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   4.119 +	{
   4.120 +		strabon.query(query2HavingA,strabon.getSailRepoConnection());
   4.121 +
   4.122 +	}
   4.123 +	
   4.124 +	@Test
   4.125 +	public void testQuery2HavingB() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   4.126 +	{
   4.127 +		strabon.query(query2HavingB,strabon.getSailRepoConnection());
   4.128 +
   4.129 +	}
   4.130 +	
   4.131 +	@Test
   4.132 +	public void testQuery2HavingC() throws MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, IOException
   4.133 +	{
   4.134 +		strabon.query(query2HavingC,strabon.getSailRepoConnection());
   4.135 +
   4.136 +	}
   4.137 +	
   4.138 +	protected static void loadTestData()
   4.139 +			throws RDFParseException, RepositoryException, IOException, RDFHandlerException, InvalidDatasetFormatFault
   4.140 +		{
   4.141 +			URL src = SimpleTests.class.getResource("/simple-tests.ntriples");
   4.142 +			strabon.storeInRepo(src, "NTRIPLES");
   4.143 +		}
   4.144 +
   4.145 +}
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/runtime/src/test/java/eu/earthobservatory/runtime/postgis/AggregateTests.java	Thu May 17 16:35:56 2012 +0300
     5.3 @@ -0,0 +1,44 @@
     5.4 +package eu.earthobservatory.runtime.postgis;
     5.5 +
     5.6 +import java.io.IOException;
     5.7 +import java.net.URL;
     5.8 +import java.sql.Date;
     5.9 +import java.sql.DriverManager;
    5.10 +import java.sql.SQLException;
    5.11 +import java.sql.Statement;
    5.12 +
    5.13 +import org.junit.BeforeClass;
    5.14 +import org.openrdf.repository.RepositoryException;
    5.15 +import org.openrdf.rio.RDFHandlerException;
    5.16 +import org.openrdf.rio.RDFParseException;
    5.17 +
    5.18 +import eu.earthobservatory.runtime.postgis.Strabon;
    5.19 +import eu.earthobservatory.runtime.generaldb.InvalidDatasetFormatFault;
    5.20 +
    5.21 +public class AggregateTests extends eu.earthobservatory.runtime.generaldb.AggregateTests {
    5.22 +
    5.23 +	@BeforeClass
    5.24 +	public static void beforeClass() throws SQLException, ClassNotFoundException, RDFParseException, RepositoryException, RDFHandlerException, IOException, InvalidDatasetFormatFault
    5.25 +	{
    5.26 +		// Create database
    5.27 +		Date date = new Date(0);
    5.28 +		databaseName = "strabon-test-"+date.getTime();
    5.29 +		Class.forName(jdbcDriver);
    5.30 +		String url = "jdbc:postgresql://"+serverName+":"+port+"/template1";
    5.31 +		conn = DriverManager.getConnection(url, username, password);
    5.32 +		Statement stmt = conn.createStatement();
    5.33 +	    String sql = "CREATE DATABASE \""+databaseName+"\" WITH TEMPLATE = template_postgis";
    5.34 +	    stmt.executeUpdate(sql);
    5.35 +	    stmt.close();
    5.36 +		conn.close();
    5.37 +		
    5.38 +	    // Connect to database
    5.39 +		url = "jdbc:postgresql://"+serverName+":"+port+"/"+databaseName;
    5.40 +		System.out.println("open database");
    5.41 +		conn = DriverManager.getConnection(url, username, password);
    5.42 +	    
    5.43 +		strabon = new Strabon(databaseName,"postgres","postgres", 5432, "localhost", true);
    5.44 +		
    5.45 +		loadTestData();
    5.46 +	}
    5.47 +}
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/runtime/src/test/java/eu/earthobservatory/runtime/postgis/GeneralTests.java	Thu May 17 16:35:56 2012 +0300
     6.3 @@ -0,0 +1,58 @@
     6.4 +package eu.earthobservatory.runtime.postgis;
     6.5 +
     6.6 +import java.io.IOException;
     6.7 +import java.net.URL;
     6.8 +import java.sql.Date;
     6.9 +import java.sql.DriverManager;
    6.10 +import java.sql.SQLException;
    6.11 +import java.sql.Statement;
    6.12 +
    6.13 +import org.junit.BeforeClass;
    6.14 +import org.openrdf.repository.RepositoryException;
    6.15 +import org.openrdf.rio.RDFHandlerException;
    6.16 +import org.openrdf.rio.RDFParseException;
    6.17 +
    6.18 +import eu.earthobservatory.runtime.generaldb.InvalidDatasetFormatFault;
    6.19 +import eu.earthobservatory.runtime.postgis.Strabon;
    6.20 +
    6.21 +public class GeneralTests extends eu.earthobservatory.runtime.generaldb.GeneralTests {
    6.22 +
    6.23 +//	@BeforeClass
    6.24 +//	public static void initialize() throws SQLException, ClassNotFoundException
    6.25 +//	{
    6.26 +//		strabon = new Strabon("cco2","postgres","p1r3as", 5432, "localhost", true);
    6.27 +//		//strabon = new Strabon("mashup","mashup","mashup", 5432, "strabon.di.uoa.gr", true);
    6.28 +//	}
    6.29 +	
    6.30 +	@BeforeClass
    6.31 +	public static void beforeClass() throws SQLException, ClassNotFoundException, RDFParseException, RepositoryException, RDFHandlerException, IOException, InvalidDatasetFormatFault
    6.32 +	{
    6.33 +		// Create database
    6.34 +		Date date = new Date(0);
    6.35 +		databaseName = "strabon-test-"+date.getTime();
    6.36 +		Class.forName(jdbcDriver);
    6.37 +		String url = "jdbc:postgresql://"+serverName+":"+port+"/template1";
    6.38 +		conn = DriverManager.getConnection(url, username, password);
    6.39 +		Statement stmt = conn.createStatement();
    6.40 +	    String sql = "CREATE DATABASE \""+databaseName+"\" WITH TEMPLATE = template_postgis";
    6.41 +	    stmt.executeUpdate(sql);
    6.42 +	    stmt.close();
    6.43 +		conn.close();
    6.44 +		
    6.45 +	    // Connect to database
    6.46 +		url = "jdbc:postgresql://"+serverName+":"+port+"/"+databaseName;
    6.47 +		System.out.println("open database");
    6.48 +		conn = DriverManager.getConnection(url, username, password);
    6.49 +	    
    6.50 +		strabon = new Strabon(databaseName,"postgres","postgres", 5432, "localhost", true);
    6.51 +		
    6.52 +		loadTestData();
    6.53 +	}
    6.54 +	
    6.55 +	protected static void loadTestData()
    6.56 +			throws RDFParseException, RepositoryException, IOException, RDFHandlerException, InvalidDatasetFormatFault
    6.57 +		{
    6.58 +			URL src = SimpleTests.class.getResource("/simple-tests.ntriples");
    6.59 +			strabon.storeInRepo(src, "NTRIPLES");
    6.60 +		}
    6.61 +}
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/runtime/src/test/java/eu/earthobservatory/runtime/postgis/HavingTests.java	Thu May 17 16:35:56 2012 +0300
     7.3 @@ -0,0 +1,50 @@
     7.4 +package eu.earthobservatory.runtime.postgis;
     7.5 +
     7.6 +import java.io.IOException;
     7.7 +import java.sql.Date;
     7.8 +import java.sql.DriverManager;
     7.9 +import java.sql.SQLException;
    7.10 +import java.sql.Statement;
    7.11 +
    7.12 +import org.junit.AfterClass;
    7.13 +import org.junit.BeforeClass;
    7.14 +import org.junit.Test;
    7.15 +import org.openrdf.query.MalformedQueryException;
    7.16 +import org.openrdf.query.QueryEvaluationException;
    7.17 +import org.openrdf.query.TupleQueryResultHandlerException;
    7.18 +import org.openrdf.repository.RepositoryException;
    7.19 +import org.openrdf.rio.RDFHandlerException;
    7.20 +import org.openrdf.rio.RDFParseException;
    7.21 +
    7.22 +import eu.earthobservatory.runtime.generaldb.InvalidDatasetFormatFault;
    7.23 +import eu.earthobservatory.runtime.postgis.Strabon;
    7.24 +
    7.25 +public class HavingTests extends eu.earthobservatory.runtime.generaldb.HavingTests {
    7.26 +	
    7.27 +	@BeforeClass
    7.28 +	public static void beforeClass() throws SQLException, ClassNotFoundException, RDFParseException, RepositoryException, RDFHandlerException, IOException, InvalidDatasetFormatFault
    7.29 +	{
    7.30 +		// Create database
    7.31 +		Date date = new Date(0);
    7.32 +		databaseName = "strabon-test-"+date.getTime();
    7.33 +		Class.forName(jdbcDriver);
    7.34 +		String url = "jdbc:postgresql://"+serverName+":"+port+"/template1";
    7.35 +		conn = DriverManager.getConnection(url, username, password);
    7.36 +		Statement stmt = conn.createStatement();
    7.37 +	    String sql = "CREATE DATABASE \""+databaseName+"\" WITH TEMPLATE = template_postgis";
    7.38 +	    stmt.executeUpdate(sql);
    7.39 +	    stmt.close();
    7.40 +		conn.close();
    7.41 +		
    7.42 +	    // Connect to database
    7.43 +		url = "jdbc:postgresql://"+serverName+":"+port+"/"+databaseName;
    7.44 +		System.out.println("open database");
    7.45 +		conn = DriverManager.getConnection(url, username, password);
    7.46 +	    
    7.47 +		strabon = new Strabon(databaseName,"postgres","postgres", 5432, "localhost", true);
    7.48 +		
    7.49 +		loadTestData();
    7.50 +	}
    7.51 +
    7.52 +
    7.53 +}