clerezza-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ha...@apache.org
Subject clerezza git commit: CLEREZZA-961: Used instance of TcManager instead of a subclass of it overriding listGraphs in SparqlPreParserTest to not affect other tests
Date Wed, 22 Apr 2015 17:56:10 GMT
Repository: clerezza
Updated Branches:
  refs/heads/master c70a78b30 -> a841717ed


CLEREZZA-961: Used instance of TcManager instead of a subclass of it overriding listGraphs
in SparqlPreParserTest to not affect other tests


Project: http://git-wip-us.apache.org/repos/asf/clerezza/repo
Commit: http://git-wip-us.apache.org/repos/asf/clerezza/commit/a841717e
Tree: http://git-wip-us.apache.org/repos/asf/clerezza/tree/a841717e
Diff: http://git-wip-us.apache.org/repos/asf/clerezza/diff/a841717e

Branch: refs/heads/master
Commit: a841717edd9c6778e494496889f1f7a5daf88e6a
Parents: c70a78b
Author: Hasan <hasan@apache.org>
Authored: Wed Apr 22 19:54:46 2015 +0200
Committer: Hasan <hasan@apache.org>
Committed: Wed Apr 22 19:54:46 2015 +0200

----------------------------------------------------------------------
 .../rdf/core/sparql/SparqlPreParserTest.java    | 38 ++++++++++++--------
 1 file changed, 23 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/clerezza/blob/a841717e/rdf/core/src/test/java/org/apache/clerezza/rdf/core/sparql/SparqlPreParserTest.java
----------------------------------------------------------------------
diff --git a/rdf/core/src/test/java/org/apache/clerezza/rdf/core/sparql/SparqlPreParserTest.java
b/rdf/core/src/test/java/org/apache/clerezza/rdf/core/sparql/SparqlPreParserTest.java
index 1ecd6e9..c56170c 100644
--- a/rdf/core/src/test/java/org/apache/clerezza/rdf/core/sparql/SparqlPreParserTest.java
+++ b/rdf/core/src/test/java/org/apache/clerezza/rdf/core/sparql/SparqlPreParserTest.java
@@ -22,7 +22,11 @@ import java.util.HashSet;
 import java.util.Set;
 import org.apache.clerezza.commons.rdf.IRI;
 import org.apache.clerezza.rdf.core.access.TcManager;
+import org.apache.clerezza.rdf.core.access.TcManagerTest;
+import org.apache.clerezza.rdf.core.access.providers.WeightedA;
+import org.junit.After;
 import org.junit.Assert;
+import org.junit.Before;
 import org.junit.Test;
 
 /**
@@ -31,18 +35,22 @@ import org.junit.Test;
  */
 public class SparqlPreParserTest {
 
-    private final static IRI DEFAULT_GRAPH = new IRI("http://example.org/default.graph");

-    private final static IRI NAMED_GRAPH = new IRI("http://example.org/dummy.graph"); 
-    private final static IRI TEST_GRAPH = new IRI("http://example.org/test.graph"); 
+    private TcManager graphAccess;
+    private final WeightedA weightedA = new WeightedA();
+    private final static IRI DEFAULT_GRAPH = new IRI("http://example.org/default.graph");
+    private final static IRI TEST_GRAPH = new IRI("http://example.org/test.graph");
 
-    class MyTcManager extends TcManager {
-        @Override
-        public Set<IRI> listGraphs() {
-            Set<IRI> result = new HashSet<>();
-            result.add(NAMED_GRAPH);
-            return result;
-        }
-    }
+    @Before
+	public void setUp() {
+		graphAccess = TcManager.getInstance();
+		graphAccess.addWeightedTcProvider(weightedA);
+	}
+
+	@After
+	public void tearDown() {
+		graphAccess = TcManager.getInstance();
+		graphAccess.removeWeightedTcProvider(weightedA);
+	}
 
     @Test
     public void testDefaultGraphInSelectQuery() throws ParseException {
@@ -147,9 +155,9 @@ public class SparqlPreParserTest {
         String queryStr = "CLEAR SILENT NAMED";
 
         SparqlPreParser parser;
-        parser = new SparqlPreParser(new MyTcManager());
+        parser = new SparqlPreParser(TcManager.getInstance());
         Set<IRI> referredGraphs = parser.getReferredGraphs(queryStr, DEFAULT_GRAPH);
-        Assert.assertTrue(referredGraphs.toArray()[0].equals(NAMED_GRAPH));
+        Assert.assertTrue(referredGraphs.contains(TcManagerTest.uriRefA));
     }
 
     @Test
@@ -180,9 +188,9 @@ public class SparqlPreParserTest {
         String queryStr = "DROP SILENT NAMED";
 
         SparqlPreParser parser;
-        parser = new SparqlPreParser(new MyTcManager());
+        parser = new SparqlPreParser(TcManager.getInstance());
         Set<IRI> referredGraphs = parser.getReferredGraphs(queryStr, DEFAULT_GRAPH);
-        Assert.assertTrue(referredGraphs.toArray()[0].equals(NAMED_GRAPH));
+        Assert.assertTrue(referredGraphs.contains(TcManagerTest.uriRefA));
     }
 
     @Test


Mime
View raw message