Strabon

changeset 1030:c7fdfaa7ab52

Tests are now independent from bindings and results order.
author Panayiotis Smeros <psmeros@di.uoa.gr>
date Fri Apr 12 14:41:28 2013 +0300 (2013-04-12)
parents bcc5fff82a71
children baf571343765
files testsuite/src/test/java/eu/earthobservatory/runtime/postgis/Utils.java testsuite/src/test/resources/StoreTest/StoreTest.rq
line diff
     1.1 --- a/testsuite/src/test/java/eu/earthobservatory/runtime/postgis/Utils.java	Thu Apr 11 20:40:42 2013 +0300
     1.2 +++ b/testsuite/src/test/java/eu/earthobservatory/runtime/postgis/Utils.java	Fri Apr 12 14:41:28 2013 +0300
     1.3 @@ -10,18 +10,14 @@
     1.4  package eu.earthobservatory.runtime.postgis;
     1.5  
     1.6  import static org.junit.Assert.assertEquals;
     1.7 +import static org.junit.Assert.assertFalse;
     1.8  import static org.junit.Assert.assertTrue;
     1.9 -import static org.junit.Assert.assertFalse;
    1.10 -import java.io.BufferedReader;
    1.11  import java.io.ByteArrayInputStream;
    1.12  import java.io.ByteArrayOutputStream;
    1.13  import java.io.File;
    1.14  import java.io.IOException;
    1.15  import java.io.InputStream;
    1.16 -import java.io.InputStreamReader;
    1.17 -import java.io.OutputStream;
    1.18  import java.net.URISyntaxException;
    1.19 -import java.net.URL;
    1.20  import java.sql.Connection;
    1.21  import java.sql.DriverManager;
    1.22  import java.sql.PreparedStatement;
    1.23 @@ -33,7 +29,6 @@
    1.24  import java.util.List;
    1.25  import java.util.Properties;
    1.26  import org.apache.commons.io.FileUtils;
    1.27 -import org.openrdf.model.Value;
    1.28  import org.openrdf.query.BindingSet;
    1.29  import org.openrdf.query.MalformedQueryException;
    1.30  import org.openrdf.query.QueryEvaluationException;
    1.31 @@ -47,7 +42,6 @@
    1.32  import org.openrdf.rio.RDFHandlerException;
    1.33  import org.openrdf.rio.RDFParseException;
    1.34  import eu.earthobservatory.runtime.generaldb.InvalidDatasetFormatFault;
    1.35 -import eu.earthobservatory.runtime.postgis.Strabon;
    1.36  import eu.earthobservatory.utils.Format;
    1.37  
    1.38  /**
    1.39 @@ -165,10 +159,9 @@
    1.40  
    1.41  		List<String> eBindingNames = expectedResults.getBindingNames();
    1.42  		List<String> aBindingNames = actualResults.getBindingNames();
    1.43 -		assertTrue("Results are not the expected.", aBindingNames.containsAll(aBindingNames) && eBindingNames.containsAll(aBindingNames));
    1.44 +		assertTrue("Results are not the expected.", aBindingNames.containsAll(aBindingNames) && eBindingNames.containsAll(aBindingNames));		
    1.45  		
    1.46 -		
    1.47 -		//Sort expected and actual results' bindings by binding name
    1.48 +		//Sort each binding's values
    1.49  		List<String> eBindingList = new ArrayList<String>();
    1.50  		List<String> aBindingList = new ArrayList<String>();
    1.51  
    1.52 @@ -194,12 +187,18 @@
    1.53  		//Sort bindings alphabetically
    1.54  		Collections.sort(eBindingList);
    1.55  		Collections.sort(aBindingList);
    1.56 +		
    1.57 +		//Check bindings one by one
    1.58 +		Iterator<String> eBindingListIterator = eBindingList.iterator();
    1.59 +		Iterator<String> aBindingListIterator = aBindingList.iterator();
    1.60  
    1.61 -		//add here iterator and check the lists with assertEquals
    1.62 +		while(eBindingListIterator.hasNext() && aBindingListIterator.hasNext())
    1.63 +		{
    1.64 +			assertEquals("Results are not the expected.", eBindingListIterator.next(), aBindingListIterator.next());
    1.65 +		}
    1.66  		
    1.67  		actualResults.close();
    1.68  		expectedResults.close();
    1.69 -
    1.70  	}
    1.71  	
    1.72  	public static void dropdb() throws SQLException
     2.1 --- a/testsuite/src/test/resources/StoreTest/StoreTest.rq	Thu Apr 11 20:40:42 2013 +0300
     2.2 +++ b/testsuite/src/test/resources/StoreTest/StoreTest.rq	Fri Apr 12 14:41:28 2013 +0300
     2.3 @@ -1,3 +1,2 @@
     2.4  SELECT *
     2.5 -WHERE{?s ?p ?o}
     2.6 -ORDER BY ?s ?p ?o
     2.7 \ No newline at end of file
     2.8 +WHERE{?s ?p ?o}
     2.9 \ No newline at end of file