You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@jena.apache.org by GitBox <gi...@apache.org> on 2020/11/15 01:43:20 UTC

[GitHub] [jena] kinow commented on a change in pull request #864: JENA-1994: Look in datatype URI

kinow commented on a change in pull request #864:
URL: https://github.com/apache/jena/pull/864#discussion_r523589580



##########
File path: jena-core/src/test/java/org/apache/jena/util/TestPrefixMappingUtils.java
##########
@@ -141,14 +146,125 @@ static int size(PrefixMapping pmap) {
         Graph graph = create(data) ;
         PrefixMapping pmap = PrefixMappingUtils.calcInUsePrefixMapping(graph) ;
         PrefixMapping pmapExpected = new PrefixMappingImpl() ;
-     	pmapExpected.setNsPrefix("", "http://example/") ;
-		pmapExpected.setNsPrefix("ex", "http://example/ex#") ;
-		pmapExpected.setNsPrefix("indirect", "urn:foo:") ;
-		pmapExpected.setNsPrefix("ns", "http://host/ns") ;
-		pmapExpected.setNsPrefix("ns1", "http://host/ns1") ;
-		pmapExpected.setNsPrefix("indirectx", "urn:x:") ;
-		//print("Expected:", pmapExpected) ;
-		//print("Got:", pmap) ;
+        pmapExpected.setNsPrefix("", "http://example/") ;
+        pmapExpected.setNsPrefix("ex", "http://example/ex#") ;
+        pmapExpected.setNsPrefix("indirect", "urn:foo:") ;
+        pmapExpected.setNsPrefix("ns", "http://host/ns") ;
+        pmapExpected.setNsPrefix("ns1", "http://host/ns1") ;
+        pmapExpected.setNsPrefix("indirectx", "urn:x:") ;
+        //print("Expected:", pmapExpected) ;
+        //print("Got:", pmap) ;
+        Assert.assertTrue(sameMapping(pmapExpected, pmap)) ;
+        Assert.assertTrue(pmap.getNsPrefixURI("notinuse") == null) ;
+    }
+
+    @Test public void prefixesTTL1() {
+        // All prefixes used.
+        // Note: XSD as well.
+        String data1 = StrUtils.strjoinNL
+            ("@prefix : <http://example/> ." ,
+             "@prefix ex: <http://example/ex#> ." ,
+             "@prefix xsd: <"+XSD.getURI()+"> .",
+             "" ,
+             ":s1 :p :x1 ." ,
+             ":s1 ex:p :x1 .",
+             ":s1 ex:p 1 ."
+             ) ;
+        Graph graph1 = create(data1) ;
+        PrefixMapping pmap = PrefixMappingUtils.calcInUsePrefixMappingTTL(graph1) ;
+        PrefixMapping pmapExpected = graph1.getPrefixMapping() ;
+        Assert.assertEquals(3, size(pmap)) ;
+        Assert.assertEquals(pmapExpected, pmap) ; 
+    }
+    
+    @Test public void prefixesTTL2() {
+        // Some prefixes used
+        String data2 = StrUtils.strjoinNL
+            ("@prefix : <http://example/> ." ,
+             "@prefix ex: <http://example/ex#> ." ,
+             "@prefix notinuse: <http://example/whatever/> ." ,
+             "" ,
+             ":s1 :p :x1 ." ,
+             ":s1 ex:p :x1 ."
+             ) ;
+        
+        Graph graph1 = create(data2) ;
+        PrefixMapping pmap = PrefixMappingUtils.calcInUsePrefixMappingTTL(graph1) ;
+        PrefixMapping pmapExpected = new PrefixMappingImpl() ;
+        pmapExpected.setNsPrefix("", "http://example/") ;
+        pmapExpected.setNsPrefix("ex", "http://example/ex#") ;
+        Assert.assertEquals(2, size(pmap)) ;
+        Assert.assertTrue(sameMapping(pmapExpected, pmap)) ;
+        Assert.assertTrue(pmap.getNsPrefixURI("notinuse") == null) ;

Review comment:
       Tests confirming the prefixes are available after the calc methods are called :+1: 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@jena.apache.org
For additional commands, e-mail: pr-help@jena.apache.org