Strabon

changeset 156:af51dd4c3c37

updated tests
author constant
date Fri May 18 01:14:56 2012 +0300 (2012-05-18)
parents 1c755c037ade
children ee3332ca05c4 ffff6d31c23d
files mod.txt runtime/src/test/java/eu/earthobservatory/runtime/generaldb/JoinTests.java runtime/src/test/java/eu/earthobservatory/runtime/generaldb/MeaningfulAggregateTests.java runtime/src/test/java/eu/earthobservatory/runtime/generaldb/NOATests.java runtime/src/test/java/eu/earthobservatory/runtime/generaldb/TransformTests.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 runtime/src/test/java/eu/earthobservatory/runtime/postgis/JoinTests.java runtime/src/test/java/eu/earthobservatory/runtime/postgis/MeaningfulAggregateTests.java runtime/src/test/java/eu/earthobservatory/runtime/postgis/TransformTests.java
line diff
     1.1 --- a/mod.txt	Thu May 17 19:44:48 2012 +0300
     1.2 +++ b/mod.txt	Fri May 18 01:14:56 2012 +0300
     1.3 @@ -1,9 +1,11 @@
     1.4  mod.txt
     1.5 -runtime/src/test/java/eu/earthobservatory/runtime/generaldb/GeneralTests.java
     1.6 -runtime/src/test/java/eu/earthobservatory/runtime/generaldb/HavingTests.java
     1.7 -runtime/src/test/java/eu/earthobservatory/runtime/postgis/GeneralTests.java
     1.8  runtime/src/test/java/eu/earthobservatory/runtime/generaldb/JoinTests.java
     1.9  runtime/src/test/java/eu/earthobservatory/runtime/generaldb/MeaningfulAggregateTests.java
    1.10  runtime/src/test/java/eu/earthobservatory/runtime/generaldb/NOATests.java
    1.11  runtime/src/test/java/eu/earthobservatory/runtime/generaldb/TransformTests.java
    1.12 +runtime/src/test/java/eu/earthobservatory/runtime/postgis/AggregateTests.java
    1.13 +runtime/src/test/java/eu/earthobservatory/runtime/postgis/GeneralTests.java
    1.14 +runtime/src/test/java/eu/earthobservatory/runtime/postgis/HavingTests.java
    1.15  runtime/src/test/java/eu/earthobservatory/runtime/postgis/TransformTests.java
    1.16 +runtime/src/test/java/eu/earthobservatory/runtime/postgis/JoinTests.java
    1.17 +runtime/src/test/java/eu/earthobservatory/runtime/postgis/MeaningfulAggregateTests.java
     2.1 --- a/runtime/src/test/java/eu/earthobservatory/runtime/generaldb/JoinTests.java	Thu May 17 19:44:48 2012 +0300
     2.2 +++ b/runtime/src/test/java/eu/earthobservatory/runtime/generaldb/JoinTests.java	Fri May 18 01:14:56 2012 +0300
     2.3 @@ -38,19 +38,7 @@
     2.4  //
     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  	protected static void loadTestData()
    2.22  			throws RDFParseException, RepositoryException, IOException, RDFHandlerException, InvalidDatasetFormatFault
    2.23  		{
     3.1 --- a/runtime/src/test/java/eu/earthobservatory/runtime/generaldb/MeaningfulAggregateTests.java	Thu May 17 19:44:48 2012 +0300
     3.2 +++ b/runtime/src/test/java/eu/earthobservatory/runtime/generaldb/MeaningfulAggregateTests.java	Fri May 18 01:14:56 2012 +0300
     3.3 @@ -36,19 +36,7 @@
     3.4  //		strabon = new Strabon("cco2","postgres","p1r3as", 5432, "localhost", true);
     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 +
    3.21  	protected static void loadTestData()
    3.22  			throws RDFParseException, RepositoryException, IOException, RDFHandlerException, InvalidDatasetFormatFault
    3.23  		{
     4.1 --- a/runtime/src/test/java/eu/earthobservatory/runtime/generaldb/NOATests.java	Thu May 17 19:44:48 2012 +0300
     4.2 +++ b/runtime/src/test/java/eu/earthobservatory/runtime/generaldb/NOATests.java	Fri May 18 01:14:56 2012 +0300
     4.3 @@ -31,18 +31,7 @@
     4.4  	protected static String databaseName = null; 
     4.5  	
     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  	protected static void loadTestData()
    4.22  			throws RDFParseException, RepositoryException, IOException, RDFHandlerException, InvalidDatasetFormatFault
     5.1 --- a/runtime/src/test/java/eu/earthobservatory/runtime/generaldb/TransformTests.java	Thu May 17 19:44:48 2012 +0300
     5.2 +++ b/runtime/src/test/java/eu/earthobservatory/runtime/generaldb/TransformTests.java	Fri May 18 01:14:56 2012 +0300
     5.3 @@ -24,18 +24,6 @@
     5.4  	protected static java.sql.Connection conn = null;
     5.5  	protected static String databaseName = null; 
     5.6  	
     5.7 -	@AfterClass
     5.8 -	public static void afterClass() throws SQLException
     5.9 -	{
    5.10 -		strabon.close();
    5.11 -	
    5.12 -		conn.close();
    5.13 -		String url = "jdbc:postgresql://"+serverName+":"+port+"/template1";
    5.14 -		conn = DriverManager.getConnection(url, username, password);
    5.15 -		Statement stmt = conn.createStatement();
    5.16 -		stmt.executeUpdate("DROP DATABASE \""+databaseName+"\"");
    5.17 -		conn.close();
    5.18 -	}
    5.19  
    5.20  
    5.21  	String prefixes = "PREFIX gag: <http://www.semanticweb.org/ontologies/2011/gagKallikratis.rdf#> \n"+
     6.1 --- a/runtime/src/test/java/eu/earthobservatory/runtime/postgis/AggregateTests.java	Thu May 17 19:44:48 2012 +0300
     6.2 +++ b/runtime/src/test/java/eu/earthobservatory/runtime/postgis/AggregateTests.java	Fri May 18 01:14:56 2012 +0300
     6.3 @@ -1,44 +1,71 @@
     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.io.InputStream;
    6.10  import java.sql.DriverManager;
    6.11 +import java.sql.ResultSet;
    6.12  import java.sql.SQLException;
    6.13  import java.sql.Statement;
    6.14 +import java.util.Properties;
    6.15  
    6.16 +import org.junit.AfterClass;
    6.17  import org.junit.BeforeClass;
    6.18  import org.openrdf.repository.RepositoryException;
    6.19  import org.openrdf.rio.RDFHandlerException;
    6.20  import org.openrdf.rio.RDFParseException;
    6.21  
    6.22 -import eu.earthobservatory.runtime.postgis.Strabon;
    6.23  import eu.earthobservatory.runtime.generaldb.InvalidDatasetFormatFault;
    6.24  
    6.25 -public class AggregateTests extends eu.earthobservatory.runtime.generaldb.AggregateTests {
    6.26 +/**
    6.27 + * A set of simple tests on SPARQL query functionality 
    6.28 + * 
    6.29 + * @author George Garbis
    6.30 + */
    6.31  
    6.32 +public class AggregateTests extends eu.earthobservatory.runtime.generaldb.SimpleTests {
    6.33 +	
    6.34  	@BeforeClass
    6.35  	public static void beforeClass() throws SQLException, ClassNotFoundException, RDFParseException, RepositoryException, RDFHandlerException, IOException, InvalidDatasetFormatFault
    6.36  	{
    6.37 -		// Create database
    6.38 -		Date date = new Date(0);
    6.39 -		databaseName = "strabon-test-"+date.getTime();
    6.40 -		Class.forName(jdbcDriver);
    6.41 -		String url = "jdbc:postgresql://"+serverName+":"+port+"/template1";
    6.42 +		// Read properties
    6.43 +		Properties properties = new Properties();
    6.44 +		InputStream propertiesStream =  SimpleTests.class.getResourceAsStream("/databases.properties");
    6.45 +		properties.load(propertiesStream);
    6.46 +
    6.47 +		serverName = properties.getProperty("postgis.serverName");
    6.48 +		databaseName = properties.getProperty("postgis.databaseName");
    6.49 +		port = Integer.parseInt(properties.getProperty("postgis.port"));
    6.50 +		username = properties.getProperty("postgis.username");
    6.51 +		password = properties.getProperty("postgis.password");
    6.52 +				
    6.53 +		// Connect to database
    6.54 +		Class.forName("org.postgresql.Driver");
    6.55 +		String url = "jdbc:postgresql://"+serverName+":"+port+"/"+databaseName;
    6.56  		conn = DriverManager.getConnection(url, username, password);
    6.57 +				
    6.58 +//		// Clean database
    6.59  		Statement stmt = conn.createStatement();
    6.60 -	    String sql = "CREATE DATABASE \""+databaseName+"\" WITH TEMPLATE = template_postgis";
    6.61 -	    stmt.executeUpdate(sql);
    6.62 -	    stmt.close();
    6.63 -		conn.close();
    6.64 +		ResultSet results = stmt.executeQuery("SELECT table_name FROM information_schema.tables WHERE " +
    6.65 +						"table_schema='public' AND table_name <> 'spatial_ref_sys' " +
    6.66 +						"AND table_name <> 'geometry_columns' AND " +
    6.67 +						"table_name <> 'geography_columns' AND table_name <> 'locked'");
    6.68 +		while (results.next()) {
    6.69 +			String table_name = results.getString("table_name");
    6.70 +			Statement stmt2 = conn.createStatement();
    6.71 +			stmt2.executeUpdate("DROP TABLE \""+table_name+"\"");
    6.72 +			stmt2.close();
    6.73 +		}
    6.74 +		stmt.close();
    6.75  		
    6.76 -	    // Connect to database
    6.77 -		url = "jdbc:postgresql://"+serverName+":"+port+"/"+databaseName;
    6.78 -		System.out.println("open database");
    6.79 -		conn = DriverManager.getConnection(url, username, password);
    6.80 -	    
    6.81 -		strabon = new Strabon(databaseName,"postgres","postgres", 5432, "localhost", true);
    6.82 +	    strabon = new Strabon(databaseName, username, password, port, serverName, true);
    6.83  		
    6.84  		loadTestData();
    6.85  	}
    6.86 -}
    6.87 +	
    6.88 +	@AfterClass
    6.89 +	public static void afterClass() throws SQLException
    6.90 +	{
    6.91 +		strabon.close();
    6.92 +	}
    6.93 +	
    6.94 +}
    6.95 \ No newline at end of file
     7.1 --- a/runtime/src/test/java/eu/earthobservatory/runtime/postgis/GeneralTests.java	Thu May 17 19:44:48 2012 +0300
     7.2 +++ b/runtime/src/test/java/eu/earthobservatory/runtime/postgis/GeneralTests.java	Fri May 18 01:14:56 2012 +0300
     7.3 @@ -1,53 +1,71 @@
     7.4  package eu.earthobservatory.runtime.postgis;
     7.5  
     7.6  import java.io.IOException;
     7.7 -import java.net.URL;
     7.8 -import java.sql.Date;
     7.9 +import java.io.InputStream;
    7.10  import java.sql.DriverManager;
    7.11 +import java.sql.ResultSet;
    7.12  import java.sql.SQLException;
    7.13  import java.sql.Statement;
    7.14 +import java.util.Properties;
    7.15  
    7.16 +import org.junit.AfterClass;
    7.17  import org.junit.BeforeClass;
    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 GeneralTests extends eu.earthobservatory.runtime.generaldb.GeneralTests {
    7.26 +/**
    7.27 + * A set of simple tests on SPARQL query functionality 
    7.28 + * 
    7.29 + * @author George Garbis
    7.30 + */
    7.31  
    7.32 -//	@BeforeClass
    7.33 -//	public static void initialize() throws SQLException, ClassNotFoundException
    7.34 -//	{
    7.35 -//		strabon = new Strabon("cco2","postgres","p1r3as", 5432, "localhost", true);
    7.36 -//		//strabon = new Strabon("mashup","mashup","mashup", 5432, "strabon.di.uoa.gr", true);
    7.37 -//	}
    7.38 +public class GeneralTests extends eu.earthobservatory.runtime.generaldb.SimpleTests {
    7.39  	
    7.40  	@BeforeClass
    7.41  	public static void beforeClass() throws SQLException, ClassNotFoundException, RDFParseException, RepositoryException, RDFHandlerException, IOException, InvalidDatasetFormatFault
    7.42  	{
    7.43 -		// Create database
    7.44 -		Date date = new Date(0);
    7.45 -		databaseName = "strabon-test-"+date.getTime();
    7.46 -		Class.forName(jdbcDriver);
    7.47 -		String url = "jdbc:postgresql://"+serverName+":"+port+"/template1";
    7.48 +		// Read properties
    7.49 +		Properties properties = new Properties();
    7.50 +		InputStream propertiesStream =  SimpleTests.class.getResourceAsStream("/databases.properties");
    7.51 +		properties.load(propertiesStream);
    7.52 +
    7.53 +		serverName = properties.getProperty("postgis.serverName");
    7.54 +		databaseName = properties.getProperty("postgis.databaseName");
    7.55 +		port = Integer.parseInt(properties.getProperty("postgis.port"));
    7.56 +		username = properties.getProperty("postgis.username");
    7.57 +		password = properties.getProperty("postgis.password");
    7.58 +				
    7.59 +		// Connect to database
    7.60 +		Class.forName("org.postgresql.Driver");
    7.61 +		String url = "jdbc:postgresql://"+serverName+":"+port+"/"+databaseName;
    7.62  		conn = DriverManager.getConnection(url, username, password);
    7.63 +				
    7.64 +//		// Clean database
    7.65  		Statement stmt = conn.createStatement();
    7.66 -	    String sql = "CREATE DATABASE \""+databaseName+"\" WITH TEMPLATE = template_postgis";
    7.67 -	    stmt.executeUpdate(sql);
    7.68 -	    stmt.close();
    7.69 -		conn.close();
    7.70 +		ResultSet results = stmt.executeQuery("SELECT table_name FROM information_schema.tables WHERE " +
    7.71 +						"table_schema='public' AND table_name <> 'spatial_ref_sys' " +
    7.72 +						"AND table_name <> 'geometry_columns' AND " +
    7.73 +						"table_name <> 'geography_columns' AND table_name <> 'locked'");
    7.74 +		while (results.next()) {
    7.75 +			String table_name = results.getString("table_name");
    7.76 +			Statement stmt2 = conn.createStatement();
    7.77 +			stmt2.executeUpdate("DROP TABLE \""+table_name+"\"");
    7.78 +			stmt2.close();
    7.79 +		}
    7.80 +		stmt.close();
    7.81  		
    7.82 -	    // Connect to database
    7.83 -		url = "jdbc:postgresql://"+serverName+":"+port+"/"+databaseName;
    7.84 -		System.out.println("open database");
    7.85 -		conn = DriverManager.getConnection(url, username, password);
    7.86 -	    
    7.87 -		strabon = new Strabon(databaseName,"postgres","postgres", 5432, "localhost", true);
    7.88 +	    strabon = new Strabon(databaseName, username, password, port, serverName, true);
    7.89  		
    7.90  		loadTestData();
    7.91  	}
    7.92  	
    7.93 +	@AfterClass
    7.94 +	public static void afterClass() throws SQLException
    7.95 +	{
    7.96 +		strabon.close();
    7.97 +	}
    7.98  	
    7.99 -}
   7.100 +}
   7.101 \ No newline at end of file
     8.1 --- a/runtime/src/test/java/eu/earthobservatory/runtime/postgis/HavingTests.java	Thu May 17 19:44:48 2012 +0300
     8.2 +++ b/runtime/src/test/java/eu/earthobservatory/runtime/postgis/HavingTests.java	Fri May 18 01:14:56 2012 +0300
     8.3 @@ -1,50 +1,71 @@
     8.4  package eu.earthobservatory.runtime.postgis;
     8.5  
     8.6  import java.io.IOException;
     8.7 -import java.sql.Date;
     8.8 +import java.io.InputStream;
     8.9  import java.sql.DriverManager;
    8.10 +import java.sql.ResultSet;
    8.11  import java.sql.SQLException;
    8.12  import java.sql.Statement;
    8.13 +import java.util.Properties;
    8.14  
    8.15  import org.junit.AfterClass;
    8.16  import org.junit.BeforeClass;
    8.17 -import org.junit.Test;
    8.18 -import org.openrdf.query.MalformedQueryException;
    8.19 -import org.openrdf.query.QueryEvaluationException;
    8.20 -import org.openrdf.query.TupleQueryResultHandlerException;
    8.21  import org.openrdf.repository.RepositoryException;
    8.22  import org.openrdf.rio.RDFHandlerException;
    8.23  import org.openrdf.rio.RDFParseException;
    8.24  
    8.25  import eu.earthobservatory.runtime.generaldb.InvalidDatasetFormatFault;
    8.26 -import eu.earthobservatory.runtime.postgis.Strabon;
    8.27  
    8.28 -public class HavingTests extends eu.earthobservatory.runtime.generaldb.HavingTests {
    8.29 +/**
    8.30 + * A set of simple tests on SPARQL query functionality 
    8.31 + * 
    8.32 + * @author George Garbis
    8.33 + */
    8.34 +
    8.35 +public class HavingTests extends eu.earthobservatory.runtime.generaldb.SimpleTests {
    8.36  	
    8.37  	@BeforeClass
    8.38  	public static void beforeClass() throws SQLException, ClassNotFoundException, RDFParseException, RepositoryException, RDFHandlerException, IOException, InvalidDatasetFormatFault
    8.39  	{
    8.40 -		// Create database
    8.41 -		Date date = new Date(0);
    8.42 -		databaseName = "strabon-test-"+date.getTime();
    8.43 -		Class.forName(jdbcDriver);
    8.44 -		String url = "jdbc:postgresql://"+serverName+":"+port+"/template1";
    8.45 +		// Read properties
    8.46 +		Properties properties = new Properties();
    8.47 +		InputStream propertiesStream =  SimpleTests.class.getResourceAsStream("/databases.properties");
    8.48 +		properties.load(propertiesStream);
    8.49 +
    8.50 +		serverName = properties.getProperty("postgis.serverName");
    8.51 +		databaseName = properties.getProperty("postgis.databaseName");
    8.52 +		port = Integer.parseInt(properties.getProperty("postgis.port"));
    8.53 +		username = properties.getProperty("postgis.username");
    8.54 +		password = properties.getProperty("postgis.password");
    8.55 +				
    8.56 +		// Connect to database
    8.57 +		Class.forName("org.postgresql.Driver");
    8.58 +		String url = "jdbc:postgresql://"+serverName+":"+port+"/"+databaseName;
    8.59  		conn = DriverManager.getConnection(url, username, password);
    8.60 +				
    8.61 +//		// Clean database
    8.62  		Statement stmt = conn.createStatement();
    8.63 -	    String sql = "CREATE DATABASE \""+databaseName+"\" WITH TEMPLATE = template_postgis";
    8.64 -	    stmt.executeUpdate(sql);
    8.65 -	    stmt.close();
    8.66 -		conn.close();
    8.67 +		ResultSet results = stmt.executeQuery("SELECT table_name FROM information_schema.tables WHERE " +
    8.68 +						"table_schema='public' AND table_name <> 'spatial_ref_sys' " +
    8.69 +						"AND table_name <> 'geometry_columns' AND " +
    8.70 +						"table_name <> 'geography_columns' AND table_name <> 'locked'");
    8.71 +		while (results.next()) {
    8.72 +			String table_name = results.getString("table_name");
    8.73 +			Statement stmt2 = conn.createStatement();
    8.74 +			stmt2.executeUpdate("DROP TABLE \""+table_name+"\"");
    8.75 +			stmt2.close();
    8.76 +		}
    8.77 +		stmt.close();
    8.78  		
    8.79 -	    // Connect to database
    8.80 -		url = "jdbc:postgresql://"+serverName+":"+port+"/"+databaseName;
    8.81 -		System.out.println("open database");
    8.82 -		conn = DriverManager.getConnection(url, username, password);
    8.83 -	    
    8.84 -		strabon = new Strabon(databaseName,"postgres","postgres", 5432, "localhost", true);
    8.85 +	    strabon = new Strabon(databaseName, username, password, port, serverName, true);
    8.86  		
    8.87  		loadTestData();
    8.88  	}
    8.89 -
    8.90 -
    8.91 -}
    8.92 +	
    8.93 +	@AfterClass
    8.94 +	public static void afterClass() throws SQLException
    8.95 +	{
    8.96 +		strabon.close();
    8.97 +	}
    8.98 +	
    8.99 +}
   8.100 \ No newline at end of file
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/runtime/src/test/java/eu/earthobservatory/runtime/postgis/JoinTests.java	Fri May 18 01:14:56 2012 +0300
     9.3 @@ -0,0 +1,71 @@
     9.4 +package eu.earthobservatory.runtime.postgis;
     9.5 +
     9.6 +import java.io.IOException;
     9.7 +import java.io.InputStream;
     9.8 +import java.sql.DriverManager;
     9.9 +import java.sql.ResultSet;
    9.10 +import java.sql.SQLException;
    9.11 +import java.sql.Statement;
    9.12 +import java.util.Properties;
    9.13 +
    9.14 +import org.junit.AfterClass;
    9.15 +import org.junit.BeforeClass;
    9.16 +import org.openrdf.repository.RepositoryException;
    9.17 +import org.openrdf.rio.RDFHandlerException;
    9.18 +import org.openrdf.rio.RDFParseException;
    9.19 +
    9.20 +import eu.earthobservatory.runtime.generaldb.InvalidDatasetFormatFault;
    9.21 +
    9.22 +/**
    9.23 + * A set of simple tests on SPARQL query functionality 
    9.24 + * 
    9.25 + * @author George Garbis
    9.26 + */
    9.27 +
    9.28 +public class JoinTests extends eu.earthobservatory.runtime.generaldb.SimpleTests {
    9.29 +	
    9.30 +	@BeforeClass
    9.31 +	public static void beforeClass() throws SQLException, ClassNotFoundException, RDFParseException, RepositoryException, RDFHandlerException, IOException, InvalidDatasetFormatFault
    9.32 +	{
    9.33 +		// Read properties
    9.34 +		Properties properties = new Properties();
    9.35 +		InputStream propertiesStream =  SimpleTests.class.getResourceAsStream("/databases.properties");
    9.36 +		properties.load(propertiesStream);
    9.37 +
    9.38 +		serverName = properties.getProperty("postgis.serverName");
    9.39 +		databaseName = properties.getProperty("postgis.databaseName");
    9.40 +		port = Integer.parseInt(properties.getProperty("postgis.port"));
    9.41 +		username = properties.getProperty("postgis.username");
    9.42 +		password = properties.getProperty("postgis.password");
    9.43 +				
    9.44 +		// Connect to database
    9.45 +		Class.forName("org.postgresql.Driver");
    9.46 +		String url = "jdbc:postgresql://"+serverName+":"+port+"/"+databaseName;
    9.47 +		conn = DriverManager.getConnection(url, username, password);
    9.48 +				
    9.49 +//		// Clean database
    9.50 +		Statement stmt = conn.createStatement();
    9.51 +		ResultSet results = stmt.executeQuery("SELECT table_name FROM information_schema.tables WHERE " +
    9.52 +						"table_schema='public' AND table_name <> 'spatial_ref_sys' " +
    9.53 +						"AND table_name <> 'geometry_columns' AND " +
    9.54 +						"table_name <> 'geography_columns' AND table_name <> 'locked'");
    9.55 +		while (results.next()) {
    9.56 +			String table_name = results.getString("table_name");
    9.57 +			Statement stmt2 = conn.createStatement();
    9.58 +			stmt2.executeUpdate("DROP TABLE \""+table_name+"\"");
    9.59 +			stmt2.close();
    9.60 +		}
    9.61 +		stmt.close();
    9.62 +		
    9.63 +	    strabon = new Strabon(databaseName, username, password, port, serverName, true);
    9.64 +		
    9.65 +		loadTestData();
    9.66 +	}
    9.67 +	
    9.68 +	@AfterClass
    9.69 +	public static void afterClass() throws SQLException
    9.70 +	{
    9.71 +		strabon.close();
    9.72 +	}
    9.73 +	
    9.74 +}
    9.75 \ No newline at end of file
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/runtime/src/test/java/eu/earthobservatory/runtime/postgis/MeaningfulAggregateTests.java	Fri May 18 01:14:56 2012 +0300
    10.3 @@ -0,0 +1,74 @@
    10.4 +package eu.earthobservatory.runtime.postgis;
    10.5 +
    10.6 +import java.io.IOException;
    10.7 +import java.io.InputStream;
    10.8 +import java.sql.DriverManager;
    10.9 +import java.sql.ResultSet;
   10.10 +import java.sql.SQLException;
   10.11 +import java.sql.Statement;
   10.12 +import java.util.Properties;
   10.13 +
   10.14 +import org.junit.AfterClass;
   10.15 +import org.junit.BeforeClass;
   10.16 +import org.openrdf.repository.RepositoryException;
   10.17 +import org.openrdf.rio.RDFHandlerException;
   10.18 +import org.openrdf.rio.RDFParseException;
   10.19 +
   10.20 +import eu.earthobservatory.runtime.generaldb.InvalidDatasetFormatFault;
   10.21 +
   10.22 +/**
   10.23 + * A set of simple tests on SPARQL query functionality 
   10.24 + * 
   10.25 + * @author George Garbis
   10.26 + */
   10.27 +
   10.28 +public class MeaningfulAggregateTests extends eu.earthobservatory.runtime.generaldb.SimpleTests {
   10.29 +	
   10.30 +	
   10.31 +	@BeforeClass
   10.32 +	public static void beforeClass() throws SQLException, ClassNotFoundException, RDFParseException, RepositoryException, RDFHandlerException, IOException, InvalidDatasetFormatFault
   10.33 +	{
   10.34 +		SimpleTests.beforeClass();
   10.35 +	}
   10.36 +	/*	// Read properties
   10.37 +		Properties properties = new Properties();
   10.38 +		InputStream propertiesStream =  SimpleTests.class.getResourceAsStream("/databases.properties");
   10.39 +		properties.load(propertiesStream);
   10.40 +
   10.41 +		serverName = properties.getProperty("postgis.serverName");
   10.42 +		databaseName = properties.getProperty("postgis.databaseName");
   10.43 +		port = Integer.parseInt(properties.getProperty("postgis.port"));
   10.44 +		username = properties.getProperty("postgis.username");
   10.45 +		password = properties.getProperty("postgis.password");
   10.46 +				
   10.47 +		// Connect to database
   10.48 +		Class.forName("org.postgresql.Driver");
   10.49 +		String url = "jdbc:postgresql://"+serverName+":"+port+"/"+databaseName;
   10.50 +		conn = DriverManager.getConnection(url, username, password);
   10.51 +				
   10.52 +//		// Clean database
   10.53 +		Statement stmt = conn.createStatement();
   10.54 +		ResultSet results = stmt.executeQuery("SELECT table_name FROM information_schema.tables WHERE " +
   10.55 +						"table_schema='public' AND table_name <> 'spatial_ref_sys' " +
   10.56 +						"AND table_name <> 'geometry_columns' AND " +
   10.57 +						"table_name <> 'geography_columns' AND table_name <> 'locked'");
   10.58 +		while (results.next()) {
   10.59 +			String table_name = results.getString("table_name");
   10.60 +			Statement stmt2 = conn.createStatement();
   10.61 +			stmt2.executeUpdate("DROP TABLE \""+table_name+"\"");
   10.62 +			stmt2.close();
   10.63 +		}
   10.64 +		stmt.close();
   10.65 +		
   10.66 +	    strabon = new Strabon(databaseName, username, password, port, serverName, true);
   10.67 +		
   10.68 +		loadTestData();
   10.69 +	}*/
   10.70 +	
   10.71 +	@AfterClass
   10.72 +	public static void afterClass() throws SQLException
   10.73 +	{
   10.74 +		SimpleTests.afterClass();
   10.75 +	}
   10.76 +	
   10.77 +}
   10.78 \ No newline at end of file
    11.1 --- a/runtime/src/test/java/eu/earthobservatory/runtime/postgis/TransformTests.java	Thu May 17 19:44:48 2012 +0300
    11.2 +++ b/runtime/src/test/java/eu/earthobservatory/runtime/postgis/TransformTests.java	Fri May 18 01:14:56 2012 +0300
    11.3 @@ -1,83 +1,71 @@
    11.4  package eu.earthobservatory.runtime.postgis;
    11.5 +
    11.6  import java.io.IOException;
    11.7 +import java.io.InputStream;
    11.8 +import java.sql.DriverManager;
    11.9 +import java.sql.ResultSet;
   11.10 +import java.sql.SQLException;
   11.11 +import java.sql.Statement;
   11.12 +import java.util.Properties;
   11.13  
   11.14  import org.junit.AfterClass;
   11.15 -import org.junit.Test;
   11.16 -import org.openrdf.query.MalformedQueryException;
   11.17 -import org.openrdf.query.QueryEvaluationException;
   11.18 -import org.openrdf.query.TupleQueryResultHandlerException;
   11.19 -//import eu.earthobservatory.generaldb.main.Strabon;
   11.20 -import eu.earthobservatory.runtime.generaldb.Strabon;
   11.21 +import org.junit.BeforeClass;
   11.22 +import org.openrdf.repository.RepositoryException;
   11.23 +import org.openrdf.rio.RDFHandlerException;
   11.24 +import org.openrdf.rio.RDFParseException;
   11.25  
   11.26 -public class TransformTests {
   11.27 +import eu.earthobservatory.runtime.generaldb.InvalidDatasetFormatFault;
   11.28  
   11.29 -	public static Strabon strabon;
   11.30 +/**
   11.31 + * A set of simple tests on SPARQL query functionality 
   11.32 + * 
   11.33 + * @author George Garbis
   11.34 + */
   11.35  
   11.36 +public class TransformTests extends eu.earthobservatory.runtime.generaldb.SimpleTests {
   11.37 +	
   11.38 +	@BeforeClass
   11.39 +	public static void beforeClass() throws SQLException, ClassNotFoundException, RDFParseException, RepositoryException, RDFHandlerException, IOException, InvalidDatasetFormatFault
   11.40 +	{
   11.41 +		// Read properties
   11.42 +		Properties properties = new Properties();
   11.43 +		InputStream propertiesStream =  SimpleTests.class.getResourceAsStream("/databases.properties");
   11.44 +		properties.load(propertiesStream);
   11.45 +
   11.46 +		serverName = properties.getProperty("postgis.serverName");
   11.47 +		databaseName = properties.getProperty("postgis.databaseName");
   11.48 +		port = Integer.parseInt(properties.getProperty("postgis.port"));
   11.49 +		username = properties.getProperty("postgis.username");
   11.50 +		password = properties.getProperty("postgis.password");
   11.51 +				
   11.52 +		// Connect to database
   11.53 +		Class.forName("org.postgresql.Driver");
   11.54 +		String url = "jdbc:postgresql://"+serverName+":"+port+"/"+databaseName;
   11.55 +		conn = DriverManager.getConnection(url, username, password);
   11.56 +				
   11.57 +//		// Clean database
   11.58 +		Statement stmt = conn.createStatement();
   11.59 +		ResultSet results = stmt.executeQuery("SELECT table_name FROM information_schema.tables WHERE " +
   11.60 +						"table_schema='public' AND table_name <> 'spatial_ref_sys' " +
   11.61 +						"AND table_name <> 'geometry_columns' AND " +
   11.62 +						"table_name <> 'geography_columns' AND table_name <> 'locked'");
   11.63 +		while (results.next()) {
   11.64 +			String table_name = results.getString("table_name");
   11.65 +			Statement stmt2 = conn.createStatement();
   11.66 +			stmt2.executeUpdate("DROP TABLE \""+table_name+"\"");
   11.67 +			stmt2.close();
   11.68 +		}
   11.69 +		stmt.close();
   11.70 +		
   11.71 +	    strabon = new Strabon(databaseName, username, password, port, serverName, true);
   11.72 +		
   11.73 +		loadTestData();
   11.74 +	}
   11.75 +	
   11.76  	@AfterClass
   11.77 -	public static void shutDown()
   11.78 +	public static void afterClass() throws SQLException
   11.79  	{
   11.80  		strabon.close();
   11.81 -
   11.82  	}
   11.83 -
   11.84 -
   11.85 -	String prefixes = "PREFIX gag: <http://www.semanticweb.org/ontologies/2011/gagKallikratis.rdf#> \n"+
   11.86 -			"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n"+
   11.87 -			"PREFIX strdf: <http://strdf.di.uoa.gr/ontology#> \n"+
   11.88 -			"PREFIX noa: <http://teleios.di.uoa.gr/ontologies/noaOntology.owl#> \n"+
   11.89 -			"PREFIX base: <http://teleios.di.uoa.gr/ontologies/noaOntology.owl#> \n"+
   11.90 -			"PREFIX ex: <http://www.example.org/ontology#> \n"+
   11.91 -			"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" +
   11.92 -			"PREFIX geof: <http://www.opengis.net/def/queryLanguage/OGC-GeoSPARQL/1.0/function/> \n";
   11.93 -
   11.94 -	protected String query1 = prefixes +
   11.95 -			"SELECT    ?H1 ?HAT1 ?HGEO1 " +
   11.96 -			"(strdf:transform(?HGEO1, <http://www.opengis.net/def/crs/EPSG/0/4326> ) AS ?converted)" +
   11.97 -			"(strdf:transform(strdf:union(?HGEO1,?HGEO1),<http://www.opengis.net/def/crs/EPSG/0/4326>) AS ?united) "  +
   11.98 -			"WHERE { \n"+
   11.99 -			"?H1 rdf:type noa:Hotspot . \n"+
  11.100 -			"?H1 noa:hasConfidence ?HCONF1 . \n"+
  11.101 -			"?H1 noa:hasGeometry ?HGEO1 . \n"+
  11.102 -			"?H1 noa:hasAcquisitionTime ?HAT1 . \n"+
  11.103 -//			" FILTER(strdf:anyInteract(?HGEO1,?HGEO1)) "+
  11.104 -			"}" +
  11.105 -			" LIMIT 5 \n";
  11.106 -
  11.107 -//	protected String query2 = prefixes +
  11.108 -//			"SELECT    ?H1 ?H2 (strdf:transform(strdf:union(?HGEO1,?HGEO2),<http://www.opengis.net/def/crs/EPSG/0/4326>) AS ?united)"  +
  11.109 -//			"WHERE { \n"+
  11.110 -////			"?H1 rdf:type noa:Hotspot . \n"+
  11.111 -////			"?H2 rdf:type noa:Hotspot . \n"+
  11.112 -//			"?H1 noa:hasGeometry ?HGEO1 . \n"+
  11.113 -//			"?H2 noa:hasGeometry ?HGEO2 . \n"+
  11.114 -////			"?H1 noa:producedFromProcessingChain ?PC1 . \n"+
  11.115 -////			"?H2 noa:producedFromProcessingChain ?PC2 . \n"+
  11.116 -////			" FILTER(strdf:anyInteract(?HGEO1,?HGEO2)) "+
  11.117 -//			" FILTER(?H1 != ?H2) "+
  11.118 -//			"}" +
  11.119 -//			" LIMIT 5 \n";
  11.120 -
  11.121 -
  11.122 -
  11.123 -	protected String query3= prefixes +
  11.124 -			"SELECT ?H ?HGEO ?HAT " +
  11.125 -			"(strdf:transform(strdf:intersection(?HGEO, strdf:union(?CGEO)),<http://www.opengis.net/def/crs/EPSG/0/4326>) AS ?DIF) \n"+                                                      
  11.126 -			"WHERE { \n"+ 
  11.127 -			"	?H rdf:type noa:Hotspot ; \n"+
  11.128 -			"      noa:hasAcquisitionTime ?HAT ; \n"+    
  11.129 -			"	   noa:isDerivedFromSensor ?HS ; \n"+    
  11.130 -			"	   noa:hasGeometry ?HGEO . \n"+
  11.131 -			"	FILTER(str(?HS) = \"MSG2\") . \n"+  
  11.132 -			"	FILTER(str(?HAT) = \"2007-08-24T14:45:00\") . \n"+
  11.133 -			"	?C rdf:type noa:Coastline ; \n"+
  11.134 -			"	   noa:hasGeometry ?CGEO . \n"+    
  11.135 -			"	FILTER( strdf:anyInteract(?HGEO, ?CGEO) ) . \n"+
  11.136 -			"} \n"+
  11.137 -			"GROUP BY ?H ?HAT ?HGEO\n"+
  11.138 -			"HAVING strdf:overlap(strdf:union(?CGEO), ?HGEO) " +
  11.139 -			" ";
  11.140 -
  11.141  	
  11.142 -
  11.143 -
  11.144 -}
  11.145 +}
  11.146 \ No newline at end of file