Author: rwesten
Date: Wed Apr 16 06:42:52 2014
New Revision: 1587816

URL: http://svn.apache.org/r1587816
Log:
applied patch for STANBOL-1307

Modified:
    
stanbol/trunk/commons/owl/src/main/java/org/apache/stanbol/commons/owl/RunSingleSPARQL.java
    
stanbol/trunk/commons/owl/src/test/java/org/apache/stanbol/commons/owl/RunSingleSPARQLTest.java

Modified: 
stanbol/trunk/commons/owl/src/main/java/org/apache/stanbol/commons/owl/RunSingleSPARQL.java
URL: 
http://svn.apache.org/viewvc/stanbol/trunk/commons/owl/src/main/java/org/apache/stanbol/commons/owl/RunSingleSPARQL.java?rev=1587816&r1=1587815&r2=1587816&view=diff
==============================================================================
--- 
stanbol/trunk/commons/owl/src/main/java/org/apache/stanbol/commons/owl/RunSingleSPARQL.java
 (original)
+++ 
stanbol/trunk/commons/owl/src/main/java/org/apache/stanbol/commons/owl/RunSingleSPARQL.java
 Wed Apr 16 06:42:52 2014
@@ -165,12 +165,12 @@ public class RunSingleSPARQL {
     }
 
    /**
-     * To run a SPARQL query
-     *
-     * @param query {The query string without the declaration of the prefixes.}
-     * @return {Return a Jena Result Set Object.}
-     */
-    public ResultSet runSPARQL(String query){
+    * To create a SPARQL QueryExecution Object
+    *
+    * @param query {The query string without the declaration of the prefixes.}
+    * @return {Return a QueryExecution Object.}
+    */
+   public QueryExecution createSPARQLQueryExecutionFactory(String query){
 
         if(!sparqlprefix.isEmpty()){
 
@@ -183,10 +183,7 @@ public class RunSingleSPARQL {
             query = prefix+query;
 
             try{
-                QueryExecution qexec = 
QueryExecutionFactory.create(query,jenamodel);
-                ResultSet results = qexec.execSelect();
-
-                return results;
+                return QueryExecutionFactory.create(query,jenamodel);
             }catch (Exception e){
                 e.printStackTrace();
                 return null;

Modified: 
stanbol/trunk/commons/owl/src/test/java/org/apache/stanbol/commons/owl/RunSingleSPARQLTest.java
URL: 
http://svn.apache.org/viewvc/stanbol/trunk/commons/owl/src/test/java/org/apache/stanbol/commons/owl/RunSingleSPARQLTest.java?rev=1587816&r1=1587815&r2=1587816&view=diff
==============================================================================
--- 
stanbol/trunk/commons/owl/src/test/java/org/apache/stanbol/commons/owl/RunSingleSPARQLTest.java
 (original)
+++ 
stanbol/trunk/commons/owl/src/test/java/org/apache/stanbol/commons/owl/RunSingleSPARQLTest.java
 Wed Apr 16 06:42:52 2014
@@ -27,6 +27,7 @@ import java.io.File;
 import java.util.HashMap;
 import java.util.Map;
 
+import com.hp.hpl.jena.query.QueryExecution;
 import org.apache.stanbol.commons.owl.RunSingleSPARQL;
 import org.junit.After;
 import org.junit.AfterClass;
@@ -148,10 +149,10 @@ public class RunSingleSPARQLTest {
     }
 
     /**
-     * Test of runSPARQL method, of class RunSingleSPARQL.
+     * Test of testCreateSPARQLQueryExecutionFactory() method, of class 
RunSingleSPARQL.
      */
     @Test
-    public void testRunSPARQL() {
+    public void testCreateSPARQLQueryExecutionFactory() {
         Map<String,String> map = new HashMap<String,String>();
         map.put("rdfs","<http://www.w3.org/2000/01/rdf-schema#>");
         map.put("xsd","<http://www.w3.org/2000/01/rdf-schema#>");
@@ -160,7 +161,11 @@ public class RunSingleSPARQLTest {
         
map.put("ex","<http://www.semanticweb.org/ontologies/2010/6/ProvaParent.owl#>");
         String query = "SELECT * WHERE {?p rdf:type ex:Person .}";
         RunSingleSPARQL instance = new RunSingleSPARQL(owl,map);
-        ResultSet result = instance.runSPARQL(query);
+        QueryExecution queryExecution = 
instance.createSPARQLQueryExecutionFactory(query);
+        if (queryExecution == null) {
+           fail("Some errors occurred in createSPARQLQueryExecutionFactory of 
KReSRunSPARQL");
+        }
+        ResultSet result = queryExecution.execSelect();
 
         if(result!=null){
             int m = 0;
@@ -168,10 +173,11 @@ public class RunSingleSPARQLTest {
                 result.next();
                 m++;
             }
+        queryExecution.close();
         assertEquals(3, m);
         // TODO review the generated test code and remove the default call to 
fail.
         }else{
-            fail("Some errors occur in runSPARQL of KReSRunSPARQL");
+            fail("Some errors occur in createSPARQLQueryExecutionFactory of 
KReSRunSPARQL");
         }
     }
 


Reply via email to