You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@marmotta.apache.org by wi...@apache.org on 2016/05/02 11:49:58 UTC

[21/50] [abbrv] marmotta git commit: MARMOTTA-627: added some tests

MARMOTTA-627: added some tests


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

Branch: refs/heads/MARMOTTA-584
Commit: 1413bb858b24c61600cd82ba80ff1de784d3056a
Parents: cfdf9e6
Author: Sergio Fern�ndez <wi...@apache.org>
Authored: Thu Feb 11 14:32:49 2016 +0100
Committer: Sergio Fern�ndez <wi...@apache.org>
Committed: Thu Feb 11 14:32:49 2016 +0100

----------------------------------------------------------------------
 .../kiwi/sparql/test/KiWiSparqlTest.java        | 51 ++++++++++++++++++++
 1 file changed, 51 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/marmotta/blob/1413bb85/libraries/kiwi/kiwi-sparql/src/test/java/org/apache/marmotta/kiwi/sparql/test/KiWiSparqlTest.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-sparql/src/test/java/org/apache/marmotta/kiwi/sparql/test/KiWiSparqlTest.java b/libraries/kiwi/kiwi-sparql/src/test/java/org/apache/marmotta/kiwi/sparql/test/KiWiSparqlTest.java
index c3a2868..510e504 100644
--- a/libraries/kiwi/kiwi-sparql/src/test/java/org/apache/marmotta/kiwi/sparql/test/KiWiSparqlTest.java
+++ b/libraries/kiwi/kiwi-sparql/src/test/java/org/apache/marmotta/kiwi/sparql/test/KiWiSparqlTest.java
@@ -23,6 +23,7 @@ import info.aduna.iteration.Iterations;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.io.IOUtils;
 import org.apache.marmotta.kiwi.config.KiWiConfiguration;
+import org.apache.marmotta.kiwi.persistence.pgsql.PostgreSQLDialect;
 import org.apache.marmotta.kiwi.sail.KiWiStore;
 import org.apache.marmotta.kiwi.sparql.sail.KiWiSparqlSail;
 import org.apache.marmotta.kiwi.test.junit.KiWiDatabaseRunner;
@@ -54,6 +55,7 @@ import java.util.Set;
  * @author Sergio Fern�mdez
  */
 @RunWith(KiWiDatabaseRunner.class)
+@KiWiDatabaseRunner.ForDialects(PostgreSQLDialect.class)
 public class KiWiSparqlTest {
 
     final Logger log = LoggerFactory.getLogger(this.getClass());
@@ -272,4 +274,53 @@ public class KiWiSparqlTest {
         }
     }
 
+    private void testMarmotta627(String queryString, double expected) throws RepositoryException, MalformedQueryException, QueryEvaluationException {
+        RepositoryConnection conn = repository.getConnection();
+        try {
+            conn.begin();
+            final TupleQuery query = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
+            final TupleQueryResult results = query.evaluate();
+            try {
+                Assert.assertTrue(results.hasNext());
+                final BindingSet bindingSet = results.next();
+                Assert.assertNotNull(bindingSet);
+                Assert.assertTrue(bindingSet.getValue("c") instanceof Literal);
+                final Literal c = (Literal) bindingSet.getValue("c");
+                Assert.assertEquals("http://www.w3.org/2001/XMLSchema#decimal", c.getDatatype().stringValue());
+                Assert.assertEquals(expected, c.doubleValue(), 0);
+                Assert.assertFalse(results.hasNext());
+            } finally {
+                results.close();
+            }
+        } finally {
+            conn.close();
+        }
+    }
+
+    @Test
+    public void testMarmotta627_1() throws Exception {
+        testMarmotta627("SELECT ( (4.5-4.4)*0.1 as ?c )  WHERE {}", 0.01);
+    }
+
+    @Test
+    public void testMarmotta627_2() throws Exception {
+        testMarmotta627("SELECT ( 0.1*0.1 as ?c )  WHERE {}", 0.01);
+    }
+
+    @Test
+    public void testMarmotta627_3() throws Exception {
+        testMarmotta627("SELECT ( 0.10*0.01 as ?c )  WHERE {}", 0.001);
+    }
+
+    @Test
+    public void testMarmotta627_4() throws Exception {
+        testMarmotta627("SELECT ( 1.00*3.10 as ?c )  WHERE {}", 3.10);
+    }
+
+    @Test
+    public void testMarmotta627_5() throws Exception {
+        testMarmotta627("SELECT ( 2.00*4.00 as ?c )  WHERE {}", 8.00);
+    }
+
+
 }