Strabon

changeset 978:23ec0f6954c2

Tests can read database properties from environment variables.
author Panayiotis Smeros <psmeros@di.uoa.gr>
date Fri Apr 05 11:59:22 2013 +0300 (2013-04-05)
parents f880f694108f
children 04f844c4e2b9
files testsuite/src/test/java/eu/earthobservatory/runtime/postgis/TemplateTest.java
line diff
     1.1 --- a/testsuite/src/test/java/eu/earthobservatory/runtime/postgis/TemplateTest.java	Thu Apr 04 17:17:16 2013 +0300
     1.2 +++ b/testsuite/src/test/java/eu/earthobservatory/runtime/postgis/TemplateTest.java	Fri Apr 05 11:59:22 2013 +0300
     1.3 @@ -37,13 +37,15 @@
     1.4   * @author Panayiotis Smeros <psmeros@di.uoa.gr>
     1.5   */
     1.6  public class TemplateTest
     1.7 -{	
     1.8 +{
     1.9 +	public static final String dbPropertiesFile="/databases.properties";
    1.10 +	
    1.11  	public static String databaseTemplateName = null;
    1.12  	public static String defaultUser = null;
    1.13  	public static String serverName = null;
    1.14  	public static String username = null;
    1.15  	public static String password = null;
    1.16 -	public static Integer port = null;
    1.17 +	public static String port = null;
    1.18  	
    1.19  	public static Connection conn = null;
    1.20  	public static String databaseName = null;
    1.21 @@ -58,16 +60,39 @@
    1.22  		
    1.23  		//Read properties
    1.24  		Properties properties = new Properties();
    1.25 -		InputStream propertiesStream =  TemplateTest.class.getResourceAsStream("/databases.properties");
    1.26 +		InputStream propertiesStream =  TemplateTest.class.getResourceAsStream(dbPropertiesFile);
    1.27  		properties.load(propertiesStream);
    1.28  
    1.29 -		databaseTemplateName = properties.getProperty("postgis.databaseTemplateName");
    1.30 -		defaultUser = properties.getProperty("postgis.defaultUser");
    1.31 -		serverName = properties.getProperty("postgis.serverName");
    1.32 -		username = properties.getProperty("postgis.username");
    1.33 -		password = properties.getProperty("postgis.password");
    1.34 -		port = Integer.parseInt(properties.getProperty("postgis.port"));
    1.35 +		if((databaseTemplateName = System.getProperty("postgis.databaseTemplateName"))==null)
    1.36 +		{
    1.37 +			databaseTemplateName = properties.getProperty("postgis.databaseTemplateName");
    1.38 +		}
    1.39  
    1.40 +		if((defaultUser = System.getProperty("postgis.defaultUser"))==null)
    1.41 +		{
    1.42 +			defaultUser = properties.getProperty("postgis.defaultUser");
    1.43 +		}
    1.44 +		
    1.45 +		if((serverName = System.getProperty("postgis.serverName"))==null)
    1.46 +		{
    1.47 +			serverName = properties.getProperty("postgis.serverName");
    1.48 +		}
    1.49 +		
    1.50 +		if((username = System.getProperty("postgis.username"))==null)
    1.51 +		{
    1.52 +			username = properties.getProperty("postgis.username");
    1.53 +		}
    1.54 +		
    1.55 +		if((password = System.getProperty("postgis.password"))==null)
    1.56 +		{
    1.57 +			password = properties.getProperty("postgis.password");
    1.58 +		}
    1.59 +
    1.60 +		if((port = System.getProperty("postgis.port"))==null)
    1.61 +		{
    1.62 +			port = properties.getProperty("postgis.port");
    1.63 +		}
    1.64 +		
    1.65  		//Connect to server and create the temp database
    1.66  		url = "jdbc:postgresql://"+serverName+":"+port+"/"+defaultUser;
    1.67  		conn = DriverManager.getConnection(url, username, password);
    1.68 @@ -96,7 +121,7 @@
    1.69  		url = "jdbc:postgresql://"+serverName+":"+port+"/"+databaseName;
    1.70  		conn = DriverManager.getConnection(url, username, password);
    1.71  		
    1.72 -	    strabon = new Strabon(databaseName, username, password, port, serverName, true);
    1.73 +	    strabon = new Strabon(databaseName, username, password, Integer.parseInt(port), serverName, true);
    1.74  	}
    1.75  	
    1.76  	public static void storeDataset(String datasetFile) throws RDFParseException, RepositoryException, RDFHandlerException, IOException, InvalidDatasetFormatFault