Strabon

changeset 1025:05312b76db52

Added TemplateTest class. Now test-classes only have to extend this class.
author Panayiotis Smeros <psmeros@di.uoa.gr>
date Thu Apr 11 13:48:07 2013 +0300 (2013-04-11)
parents e34e39809c55
children 4f594f5d8573
files testsuite/src/test/java/eu/earthobservatory/runtime/postgis/StoreTest.java testsuite/src/test/java/eu/earthobservatory/runtime/postgis/TemplateTest.java
line diff
     1.1 --- a/testsuite/src/test/java/eu/earthobservatory/runtime/postgis/StoreTest.java	Thu Apr 11 13:44:17 2013 +0300
     1.2 +++ b/testsuite/src/test/java/eu/earthobservatory/runtime/postgis/StoreTest.java	Thu Apr 11 13:48:07 2013 +0300
     1.3 @@ -9,37 +9,10 @@
     1.4   */
     1.5  package eu.earthobservatory.runtime.postgis;
     1.6  
     1.7 -import org.junit.After;
     1.8 -import org.junit.Before;
     1.9 -import org.junit.Test;
    1.10  
    1.11  /**
    1.12   * A simple store test. It tests if the input dataset is stored and retrieved correctly.
    1.13   * 
    1.14   * @author Panayiotis Smeros <psmeros@di.uoa.gr
    1.15   */
    1.16 -public class StoreTest
    1.17 -{	
    1.18 -	private final String datasetFile="/"+this.getClass().getSimpleName()+".nt";
    1.19 -	private final String queryFile="/"+this.getClass().getSimpleName()+".rq";
    1.20 -	private final String resultsFile="/"+this.getClass().getSimpleName()+".sr";
    1.21 -
    1.22 -	@Before
    1.23 -	public void before() throws Exception
    1.24 -	{
    1.25 -		Utils.createdb();
    1.26 -		Utils.storeDataset(datasetFile);
    1.27 -	}
    1.28 -	
    1.29 -	@Test
    1.30 -	public void test() throws Exception
    1.31 -	{
    1.32 -		Utils.testQuery(queryFile, resultsFile);
    1.33 -	}
    1.34 -	
    1.35 -	@After
    1.36 -	public void after() throws Exception
    1.37 -	{
    1.38 -		Utils.dropdb();
    1.39 -	}
    1.40 -}
    1.41 +public class StoreTest extends TemplateTest{}
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/testsuite/src/test/java/eu/earthobservatory/runtime/postgis/TemplateTest.java	Thu Apr 11 13:48:07 2013 +0300
     2.3 @@ -0,0 +1,64 @@
     2.4 +/**
     2.5 + * This Source Code Form is subject to the terms of the Mozilla Public
     2.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     2.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/.
     2.8 + * 
     2.9 + * Copyright (C) 2010, 2011, 2012, 2013 Pyravlos Team
    2.10 + * 
    2.11 + * http://www.strabon.di.uoa.gr/
    2.12 + */
    2.13 +package eu.earthobservatory.runtime.postgis;
    2.14 +
    2.15 +import org.junit.After;
    2.16 +import org.junit.Before;
    2.17 +import org.junit.Test;
    2.18 +
    2.19 +/**
    2.20 + * A template test. It: 
    2.21 + * 1) creates a database
    2.22 + * 2) stores a dataset
    2.23 + * 3) poses a query
    2.24 + * 4) checks if the results of the query are the expected 
    2.25 + * 5) drops the database
    2.26 + * 
    2.27 + * @author Panayiotis Smeros <psmeros@di.uoa.gr
    2.28 + */
    2.29 +public abstract class TemplateTest
    2.30 +{	
    2.31 +	private String datasetFile;
    2.32 +	private String queryFile;
    2.33 +	private String resultsFile;
    2.34 +
    2.35 +	public TemplateTest(String datasetFile, String queryFile, String resultsFile)
    2.36 +	{
    2.37 +		this.datasetFile = datasetFile;
    2.38 +		this.queryFile = queryFile;
    2.39 +		this.resultsFile = resultsFile;
    2.40 +	}
    2.41 +
    2.42 +	public TemplateTest()
    2.43 +	{
    2.44 +		this.datasetFile="/"+this.getClass().getSimpleName()+".nt";
    2.45 +		this.queryFile="/"+this.getClass().getSimpleName()+".rq";
    2.46 +		this.resultsFile="/"+this.getClass().getSimpleName()+".sr";
    2.47 +	}
    2.48 +
    2.49 +	@Before
    2.50 +	public void before() throws Exception
    2.51 +	{
    2.52 +		Utils.createdb();
    2.53 +		Utils.storeDataset(datasetFile);
    2.54 +	}
    2.55 +	
    2.56 +	@Test
    2.57 +	public void test() throws Exception
    2.58 +	{
    2.59 +		Utils.testQuery(queryFile, resultsFile);
    2.60 +	}
    2.61 +	
    2.62 +	@After
    2.63 +	public void after() throws Exception
    2.64 +	{
    2.65 +		Utils.dropdb();
    2.66 +	}
    2.67 +}