Strabon

changeset 1050:c71d43100552

More than one queries can be tested against the same dataset.
author Panayiotis Smeros <psmeros@di.uoa.gr>
date Fri Apr 19 13:08:28 2013 +0300 (2013-04-19)
parents c3bf7385caf7
children cd170a3682dd
files testsuite/src/test/java/eu/earthobservatory/testsuite/utils/TemplateTest.java
line diff
     1.1 --- a/testsuite/src/test/java/eu/earthobservatory/testsuite/utils/TemplateTest.java	Fri Apr 19 11:30:01 2013 +0300
     1.2 +++ b/testsuite/src/test/java/eu/earthobservatory/testsuite/utils/TemplateTest.java	Fri Apr 19 13:08:28 2013 +0300
     1.3 @@ -9,6 +9,10 @@
     1.4   */
     1.5  package eu.earthobservatory.testsuite.utils;
     1.6  
     1.7 +import java.io.File;
     1.8 +import java.util.ArrayList;
     1.9 +import java.util.Iterator;
    1.10 +
    1.11  import org.junit.After;
    1.12  import org.junit.Before;
    1.13  import org.junit.Test;
    1.14 @@ -27,10 +31,10 @@
    1.15  public abstract class TemplateTest
    1.16  {	
    1.17  	private String datasetFile;
    1.18 -	private String queryFile;
    1.19 -	private String resultsFile;
    1.20 +	private ArrayList<String> queryFile;
    1.21 +	private ArrayList<String> resultsFile;
    1.22  
    1.23 -	public TemplateTest(String datasetFile, String queryFile, String resultsFile)
    1.24 +	public TemplateTest(String datasetFile, ArrayList<String> queryFile, ArrayList<String> resultsFile)
    1.25  	{
    1.26  		this.datasetFile = datasetFile;
    1.27  		this.queryFile = queryFile;
    1.28 @@ -39,12 +43,27 @@
    1.29  
    1.30  	public TemplateTest()
    1.31  	{
    1.32 +		queryFile=new ArrayList<String>();
    1.33 +		resultsFile=new ArrayList<String>();
    1.34 +		
    1.35  		String testname=this.getClass().getSimpleName();
    1.36  		String testpackage=this.getClass().getPackage().getName().substring(this.getClass().getPackage().getName().lastIndexOf('.')+1);
    1.37 +		File testfolder = new File(this.getClass().getResource("/"+testpackage+"/"+testname+"/").getPath());
    1.38  		
    1.39 -		this.datasetFile="/"+testpackage+"/"+testname+"/"+testname+".nt";
    1.40 -		this.queryFile="/"+testpackage+"/"+testname+"/"+testname+".rq";
    1.41 -		this.resultsFile="/"+testpackage+"/"+testname+"/"+testname+".srx";
    1.42 +		String[] files = testfolder.list();
    1.43 +		
    1.44 +		for(String file : files)
    1.45 +		{
    1.46 +			if(file.endsWith(".nt") || file.endsWith(".nq"))
    1.47 +			{
    1.48 +				this.datasetFile="/"+testpackage+"/"+testname+"/"+file;
    1.49 +			}
    1.50 +			else if(file.endsWith(".rq"))
    1.51 +			{
    1.52 +				this.queryFile.add("/"+testpackage+"/"+testname+"/"+file);
    1.53 +				this.resultsFile.add("/"+testpackage+"/"+testname+"/"+file.substring(0, file.length()-3)+".srx");
    1.54 +			}
    1.55 +		}
    1.56  	}
    1.57  
    1.58  	@Before
    1.59 @@ -57,7 +76,13 @@
    1.60  	@Test
    1.61  	public void test() throws Exception
    1.62  	{
    1.63 -		Utils.testQuery(queryFile, resultsFile);
    1.64 +		Iterator<String> queryFileIterator = this.queryFile.iterator();
    1.65 +		Iterator<String> resultsFileIterator = this.resultsFile.iterator();
    1.66 +		
    1.67 +		while(queryFileIterator.hasNext() && resultsFileIterator.hasNext())
    1.68 +		{
    1.69 +			Utils.testQuery(queryFileIterator.next(), resultsFileIterator.next());
    1.70 +		}
    1.71  	}
    1.72  	
    1.73  	@After