jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r1380008 - in /jena/trunk/jena-arq/src: main/java/org/openjena/riot/Lang.java test/java/org/openjena/riot/TS_Riot.java test/java/org/openjena/riot/TestLangFileExtensions.java test/java/org/openjena/riot/lang/TestLang.java
Date Sun, 02 Sep 2012 17:15:11 GMT
Author: andy
Date: Sun Sep  2 17:15:10 2012
New Revision: 1380008

URL: http://svn.apache.org/viewvc?rev=1380008&view=rev
Log:
JENA-313

Removed:
    jena/trunk/jena-arq/src/test/java/org/openjena/riot/TestLangFileExtensions.java
Modified:
    jena/trunk/jena-arq/src/main/java/org/openjena/riot/Lang.java
    jena/trunk/jena-arq/src/test/java/org/openjena/riot/TS_Riot.java
    jena/trunk/jena-arq/src/test/java/org/openjena/riot/lang/TestLang.java

Modified: jena/trunk/jena-arq/src/main/java/org/openjena/riot/Lang.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/main/java/org/openjena/riot/Lang.java?rev=1380008&r1=1380007&r2=1380008&view=diff
==============================================================================
--- jena/trunk/jena-arq/src/main/java/org/openjena/riot/Lang.java (original)
+++ jena/trunk/jena-arq/src/main/java/org/openjena/riot/Lang.java Sun Sep  2 17:15:10 2012
@@ -117,14 +117,12 @@ public enum Lang
      */
     public static Lang get(String name, Lang dftLang)
     {
-        if ( matchesLangName(name, Lang.RDFXML) )       return RDFXML ;
-        if ( matchesLangName(name, Lang.NTRIPLES) )     return NTRIPLES ;
-        if ( matchesLangName(name, Lang.TURTLE) )       return TURTLE ;
-        if ( matchesLangName(name, Lang.NQUADS) )       return NQUADS ;
-        if ( matchesLangName(name, Lang.TRIG) )         return TRIG ;
-        if ( matchesLangName(name, Lang.RDFJSON) )		return RDFJSON ;
+        for (Lang l : Lang.values())
+            if ( matchesLangName(name, l) )
+                return l ;
         return dftLang ;
     }
+    
 
     private static boolean matchesLangName(String name, Lang lang)
     {

Modified: jena/trunk/jena-arq/src/test/java/org/openjena/riot/TS_Riot.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/test/java/org/openjena/riot/TS_Riot.java?rev=1380008&r1=1380007&r2=1380008&view=diff
==============================================================================
--- jena/trunk/jena-arq/src/test/java/org/openjena/riot/TS_Riot.java (original)
+++ jena/trunk/jena-arq/src/test/java/org/openjena/riot/TS_Riot.java Sun Sep  2 17:15:10 2012
@@ -65,7 +65,6 @@ import org.openjena.riot.tokens.TestToke
     , TestOutputRDFJSON.class
     , TestLangTag.class
     , TestNormalization.class
-    , TestLangFileExtensions.class
 })
 
 public class TS_Riot

Modified: jena/trunk/jena-arq/src/test/java/org/openjena/riot/lang/TestLang.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/test/java/org/openjena/riot/lang/TestLang.java?rev=1380008&r1=1380007&r2=1380008&view=diff
==============================================================================
--- jena/trunk/jena-arq/src/test/java/org/openjena/riot/lang/TestLang.java (original)
+++ jena/trunk/jena-arq/src/test/java/org/openjena/riot/lang/TestLang.java Sun Sep  2 17:15:10
2012
@@ -18,6 +18,11 @@
 
 package org.openjena.riot.lang;
 
+import java.util.ArrayList ;
+import java.util.Arrays ;
+import java.util.Collection ;
+
+import org.junit.Assert ;
 import org.junit.Test ;
 import org.openjena.atlas.junit.BaseTest ;
 import org.openjena.riot.Lang ;
@@ -60,4 +65,51 @@ public class TestLang extends BaseTest
     @Test public void lang_11()
     { assertEquals(Lang.RDFJSON, Lang.get(WebContent.langRdfJson)) ; }
 
+    @Test
+    public void testFileExtensionsProvided()
+    {
+        for (Lang l : Lang.values())
+        {
+            String ext = l.getDefaultFileExtension();
+            Assert.assertFalse( l+" does not have default extension defined",  ext==null||ext.isEmpty()
);
+            Assert.assertNotNull( l+" does not have file extensions defined", l.getFileExtensions());
+            Assert.assertTrue( l+" does not have file extensions defined", l.getFileExtensions().length
> 0);
+        }
+    }
+    
+    @Test
+    public void testFileExtensionUnique()
+    {
+        Collection<String> exts = new ArrayList<String>();
+        for (Lang l : Lang.values())
+        {
+            for (String ext : l.getFileExtensions())
+            {
+                Assert.assertFalse( "The "+ext+" file extensions in "+l+" was already used",
+                        exts.contains(ext));
+            }
+            exts.addAll( Arrays.asList(l.getFileExtensions()));
+        }
+        
+    }
+    
+    @Test
+    public void testDefaultInExtensions()
+    {
+        for (Lang l : Lang.values())
+        {
+            Assert.assertTrue( l+" default extension not in file extensions list", Arrays.asList(
l.getFileExtensions()).contains( l.getDefaultFileExtension())  );
+        }
+    }
+    
+    @Test
+    public void testGet()
+    {
+        for (Lang l : Lang.values())
+        {
+            Assert.assertNotNull( l+" can not be parsed by name", Lang.get( l.getName(),
null )  );
+        }
+    }
+
+    
 }



Mime
View raw message