Strabon

changeset 1076:07fb6408ccce

Added first GeoSPARQL test (inference option is enabled).
author Panayiotis Smeros <psmeros@di.uoa.gr>
date Thu Apr 25 14:00:09 2013 +0300 (2013-04-25)
parents 1e9d2bfc1662
children 36142847a6e9
files testsuite/src/test/java/eu/earthobservatory/testsuite/geoSPARQL/SpatialObjectClassTest.java testsuite/src/test/java/eu/earthobservatory/testsuite/utils/TemplateTest.java testsuite/src/test/java/eu/earthobservatory/testsuite/utils/Utils.java testsuite/src/test/resources/geoSPARQL/SpatialObjectClassTest/SpatialObjectClassTest.nt testsuite/src/test/resources/geoSPARQL/SpatialObjectClassTest/SpatialObjectClassTest.rq testsuite/src/test/resources/geoSPARQL/SpatialObjectClassTest/SpatialObjectClassTest.srx
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/testsuite/src/test/java/eu/earthobservatory/testsuite/geoSPARQL/SpatialObjectClassTest.java	Thu Apr 25 14:00:09 2013 +0300
     1.3 @@ -0,0 +1,27 @@
     1.4 +/**
     1.5 + * This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/.
     1.8 + * 
     1.9 + * Copyright (C) 2010, 2011, 2012, 2013 Pyravlos Team
    1.10 + * 
    1.11 + * http://www.strabon.di.uoa.gr/
    1.12 + */
    1.13 +package eu.earthobservatory.testsuite.geoSPARQL;
    1.14 +
    1.15 +import eu.earthobservatory.testsuite.utils.TemplateTest;
    1.16 +
    1.17 +
    1.18 +/**
    1.19 + * GeoSPARQL Spatial Object Class test. A Geometry is also a Spatial Object.
    1.20 + * 
    1.21 + * @author Panayiotis Smeros <psmeros@di.uoa.gr
    1.22 + */
    1.23 +public class SpatialObjectClassTest extends TemplateTest
    1.24 +{
    1.25 +	public SpatialObjectClassTest() 
    1.26 +	{
    1.27 +		super();
    1.28 +		this.inference=true;
    1.29 +	}
    1.30 +}
    1.31 \ No newline at end of file
     2.1 --- a/testsuite/src/test/java/eu/earthobservatory/testsuite/utils/TemplateTest.java	Thu Apr 25 12:53:00 2013 +0300
     2.2 +++ b/testsuite/src/test/java/eu/earthobservatory/testsuite/utils/TemplateTest.java	Thu Apr 25 14:00:09 2013 +0300
     2.3 @@ -31,15 +31,17 @@
     2.4   */
     2.5  public abstract class TemplateTest
     2.6  {	
     2.7 -	private String datasetFile;
     2.8 -	private ArrayList<String> queryFile;
     2.9 -	private ArrayList<String> resultsFile;
    2.10 +	protected String datasetFile;
    2.11 +	protected ArrayList<String> queryFile;
    2.12 +	protected ArrayList<String> resultsFile;
    2.13 +	protected Boolean inference;
    2.14  
    2.15 -	public TemplateTest(String datasetFile, ArrayList<String> queryFile, ArrayList<String> resultsFile)
    2.16 +	public TemplateTest(String datasetFile, ArrayList<String> queryFile, ArrayList<String> resultsFile, Boolean inference)
    2.17  	{
    2.18  		this.datasetFile = datasetFile;
    2.19  		this.queryFile = queryFile;
    2.20  		this.resultsFile = resultsFile;
    2.21 +		this.inference = inference;
    2.22  	}
    2.23  
    2.24  	public TemplateTest()
    2.25 @@ -68,28 +70,30 @@
    2.26  		{
    2.27  			if(file.endsWith(".nt") || file.endsWith(".nq"))
    2.28  			{
    2.29 -				this.datasetFile=File.separator+testpackage+File.separator+testname+File.separator+file;
    2.30 +				datasetFile=File.separator+testpackage+File.separator+testname+File.separator+file;
    2.31  			}
    2.32  			else if(file.endsWith(".rq"))
    2.33  			{
    2.34 -				this.queryFile.add(File.separator+testpackage+File.separator+testname+File.separator+file);
    2.35 -				this.resultsFile.add(File.separator+testpackage+File.separator+testname+File.separator+file.substring(0, file.length()-3)+".srx");
    2.36 +				queryFile.add(File.separator+testpackage+File.separator+testname+File.separator+file);
    2.37 +				resultsFile.add(File.separator+testpackage+File.separator+testname+File.separator+file.substring(0, file.length()-3)+".srx");
    2.38  			}
    2.39  		}
    2.40 +		
    2.41 +		inference=false;
    2.42  	}
    2.43  
    2.44  	@Before
    2.45  	public void before() throws Exception
    2.46  	{
    2.47  		Utils.createdb();
    2.48 -		Utils.storeDataset(datasetFile);
    2.49 +		Utils.storeDataset(datasetFile, inference);
    2.50  	}
    2.51  	
    2.52  	@Test
    2.53  	public void test() throws Exception
    2.54  	{
    2.55 -		Iterator<String> queryFileIterator = this.queryFile.iterator();
    2.56 -		Iterator<String> resultsFileIterator = this.resultsFile.iterator();
    2.57 +		Iterator<String> queryFileIterator = queryFile.iterator();
    2.58 +		Iterator<String> resultsFileIterator = resultsFile.iterator();
    2.59  		
    2.60  		while(queryFileIterator.hasNext() && resultsFileIterator.hasNext())
    2.61  		{
     3.1 --- a/testsuite/src/test/java/eu/earthobservatory/testsuite/utils/Utils.java	Thu Apr 25 12:53:00 2013 +0300
     3.2 +++ b/testsuite/src/test/java/eu/earthobservatory/testsuite/utils/Utils.java	Thu Apr 25 14:00:09 2013 +0300
     3.3 @@ -132,12 +132,12 @@
     3.4  	    strabon = new Strabon(databaseName, username, password, Integer.parseInt(port), serverName, true);
     3.5  	}
     3.6  	
     3.7 -	public static void storeDataset(String datasetFile) throws RDFParseException, RepositoryException, RDFHandlerException, IOException, InvalidDatasetFormatFault
     3.8 +	public static void storeDataset(String datasetFile, Boolean inference) throws RDFParseException, RepositoryException, RDFHandlerException, IOException, InvalidDatasetFormatFault
     3.9  	{
    3.10  	    if(datasetFile.endsWith(".nt"))
    3.11 -	    	strabon.storeInRepo(datasetFile, "NTRIPLES", false);
    3.12 +	    	strabon.storeInRepo(datasetFile, "NTRIPLES", inference);
    3.13  	    else if(datasetFile.endsWith(".nq"))
    3.14 -	    	strabon.storeInRepo(datasetFile, "NQUADS", false);
    3.15 +	    	strabon.storeInRepo(datasetFile, "NQUADS", inference);
    3.16  	}
    3.17  	
    3.18  	public static void testQuery(String queryFile, String resultsFile) throws IOException, MalformedQueryException, QueryEvaluationException, TupleQueryResultHandlerException, URISyntaxException, QueryResultParseException, UnsupportedQueryResultFormatException
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/testsuite/src/test/resources/geoSPARQL/SpatialObjectClassTest/SpatialObjectClassTest.nt	Thu Apr 25 14:00:09 2013 +0300
     4.3 @@ -0,0 +1,1 @@
     4.4 +<http://example.org#Geom> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.opengis.net/ont/geosparql#Geometry>.
     4.5 \ No newline at end of file
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/testsuite/src/test/resources/geoSPARQL/SpatialObjectClassTest/SpatialObjectClassTest.rq	Thu Apr 25 14:00:09 2013 +0300
     5.3 @@ -0,0 +1,3 @@
     5.4 +SELECT ?o
     5.5 +WHERE
     5.6 +{<http://example.org#Geom> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?o}
     5.7 \ No newline at end of file
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/testsuite/src/test/resources/geoSPARQL/SpatialObjectClassTest/SpatialObjectClassTest.srx	Thu Apr 25 14:00:09 2013 +0300
     6.3 @@ -0,0 +1,18 @@
     6.4 +<?xml version='1.0' encoding='UTF-8'?>
     6.5 +<sparql xmlns='http://www.w3.org/2005/sparql-results#'>
     6.6 +	<head>
     6.7 +		<variable name='o'/>
     6.8 +	</head>
     6.9 +	<results>
    6.10 +		<result>
    6.11 +			<binding name='o'>
    6.12 +				<uri>http://www.opengis.net/ont/geosparql#SpatialObject</uri>
    6.13 +			</binding>
    6.14 +		</result>
    6.15 +		<result>
    6.16 +			<binding name='o'>
    6.17 +				<uri>http://www.opengis.net/ont/geosparql#Geometry</uri>
    6.18 +			</binding>
    6.19 +		</result>
    6.20 +	</results>
    6.21 +</sparql>
    6.22 \ No newline at end of file