Переглянути джерело

Added extra test case

Added extra test case to make sure datatypes were working with
functions, which they did.
Christophe Debruyne 11 місяців тому
батько
коміт
766ac5186e

+ 0 - 2
test/resources/13.output/default.ttl

@@ -1,4 +1,2 @@
1 1
 <http://data.example.com/employee/7369>
2 2
         a       <http://example.com/ns#Employee> .
3
-<http://data.example.com/employee/7369>
4
-        a       <http://example.com/ns#Employee> .

+ 0 - 2
test/resources/13.output/http_foo_bar_bar_.ttl

@@ -1,4 +1,2 @@
1 1
 <http://data.example.com/employee/7369>
2 2
         <http://example.com/ns#name>  "SMITH" .
3
-<http://data.example.com/employee/7369>
4
-        <http://example.com/ns#name>  "SMITH" .

+ 40 - 0
test/resources/F03.mapping.ttl

@@ -0,0 +1,40 @@
1
+@prefix rr: <http://www.w3.org/ns/r2rml#> .
2
+@prefix rrf: <http://kdeg.scss.tcd.ie/ns/rrf#> .
3
+@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
4
+@prefix ex: <http://example.com/ns#> .
5
+
6
+<#TriplesMap1>
7
+    rr:logicalTable [ rr:tableName "EMP" ];
8
+    rr:subjectMap [
9
+        rr:template "http://data.example.com/employee/{EMPNO}";
10
+        rr:class ex:Employee;
11
+    ];
12
+    rr:predicateObjectMap [
13
+        rr:predicate ex:name;
14
+        rr:objectMap [ rr:column "ENAME" ];
15
+    ];
16
+    rr:predicateObjectMap [
17
+        rr:predicate ex:test;
18
+        rr:objectMap [
19
+	 		rr:datatype xsd:integer ;
20
+	        rrf:functionCall [
21
+	 			rrf:function <#foo> ;
22
+	 			rrf:parameterBindings (
23
+	 				[ rr:column "EMPNO" ]
24
+	 			) ;
25
+	 		] ; 
26
+	 	]
27
+    ]    
28
+    .
29
+    
30
+<#foo>
31
+	rrf:functionName "foo" ;
32
+	rrf:functionBody """
33
+	function foo(var1) {
34
+		return var1 ;
35
+	}
36
+	""" ;
37
+.
38
+	
39
+<#a> rr:objectMap <#b> .
40
+<#b> rr:column "ENAME" .

+ 6 - 0
test/resources/F03.output.ttl

@@ -0,0 +1,6 @@
1
+@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
2
+@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
3
+@prefix ex: <http://example.com/ns#> .
4
+<http://data.example.com/employee/7369> rdf:type ex:Employee.
5
+<http://data.example.com/employee/7369> ex:name "SMITH".
6
+<http://data.example.com/employee/7369> ex:test "7369"^^xsd:integer.

+ 16 - 0
test/test/TestR2RMLF.java

@@ -14,6 +14,7 @@ import org.junit.BeforeClass;
14 14
 import junit.framework.TestCase;
15 15
 import r2rml.engine.Configuration;
16 16
 import r2rml.engine.R2RMLProcessor;
17
+import r2rml.function.JSEnv;
17 18
 
18 19
 /**
19 20
  * Unit test for testing the functionality of this implementation using an
@@ -102,6 +103,21 @@ public class TestR2RMLF extends TestCase {
102 103
 		target.read("./test/resources/F01.output.ttl");
103 104
 		assertEquals(true, model.difference(target).isEmpty());
104 105
 		assertEquals(true, target.difference(model).isEmpty());	
106
+		
107
+		JSEnv.reset();
108
+	}
109
+	
110
+	public void testExampleF03() {
111
+		Configuration configuration = new Configuration();
112
+		configuration.setMappingFile("./test/resources/F03.mapping.ttl");
113
+		configuration.setConnectionURL(connectionURL);
114
+		R2RMLProcessor engine = new R2RMLProcessor(configuration);
115
+		engine.execute();
116
+		Model model = engine.getDataset().getDefaultModel();
117
+		Model target = ModelFactory.createDefaultModel();
118
+		target.read("./test/resources/F03.output.ttl");
119
+		assertEquals(true, model.difference(target).isEmpty());
120
+		assertEquals(true, target.difference(model).isEmpty());	
105 121
 	}
106 122
 
107 123
 }