This is an automated email from the ASF dual-hosted git repository.

andy pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/jena.git

commit 5e2642b3f775aab68df99c3907fcdb34a4aee667
Author: Andy Seaborne <[email protected]>
AuthorDate: Tue Aug 26 16:00:24 2025 +0100

    Formalize configuration of RIOT tests
---
 .../apache/jena/arq/junit5/riot/RiotEvalTest.java  |   5 +-
 .../jena/arq/junit5/riot/RiotSyntaxTest.java       |   2 +-
 .../org/apache/jena/arq/junit5/riot/RiotTests.java |  66 +-------------
 .../jena/arq/junit5/riot/RiotTestsConfig.java      | 100 +++++++++++++++++++++
 4 files changed, 105 insertions(+), 68 deletions(-)

diff --git 
a/jena-arq/src/test/java/org/apache/jena/arq/junit5/riot/RiotEvalTest.java 
b/jena-arq/src/test/java/org/apache/jena/arq/junit5/riot/RiotEvalTest.java
index a9f051a556..e52cc3b893 100644
--- a/jena-arq/src/test/java/org/apache/jena/arq/junit5/riot/RiotEvalTest.java
+++ b/jena-arq/src/test/java/org/apache/jena/arq/junit5/riot/RiotEvalTest.java
@@ -18,6 +18,7 @@
 
 package org.apache.jena.arq.junit5.riot;
 
+import static org.apache.jena.arq.junit5.riot.RiotTestsConfig.fragment;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.junit.jupiter.api.Assertions.fail;
 
@@ -54,7 +55,7 @@ public class RiotEvalTest extends AbstractManifestTest {
         input = entry.getAction().getURI();
         output = positiveTest ? entry.getResult().getURI() : null;
 
-        boolean silentWarnings = RiotTests.allowWarnings(manifestEntry);
+        boolean silentWarnings = 
RiotTestsConfig.allowWarningsEvalTests(manifestEntry);
         parser = ( baseIRI != null )
             ? ParsingStepForTest.parse(input, baseIRI, lang, silentWarnings)
             : ParsingStepForTest.parse(input, lang, silentWarnings);
@@ -79,7 +80,7 @@ public class RiotEvalTest extends AbstractManifestTest {
             parser.accept(dest);
 
             if ( ! expectLegalSyntax ) {
-                String fragment = RiotTests.fragment(manifestEntry.getURI());
+                String fragment = fragment(manifestEntry.getURI());
                 if ( fragment != null )
                     fail(fragment+": Passed bad syntax eval test");
                 else
diff --git 
a/jena-arq/src/test/java/org/apache/jena/arq/junit5/riot/RiotSyntaxTest.java 
b/jena-arq/src/test/java/org/apache/jena/arq/junit5/riot/RiotSyntaxTest.java
index 3a1ec2bdef..0b936dae4d 100644
--- a/jena-arq/src/test/java/org/apache/jena/arq/junit5/riot/RiotSyntaxTest.java
+++ b/jena-arq/src/test/java/org/apache/jena/arq/junit5/riot/RiotSyntaxTest.java
@@ -52,7 +52,7 @@ public class RiotSyntaxTest extends AbstractManifestTest{
         this.baseIRI = ( baseIRI == null ) ? filename : baseIRI;
         this.expectLegalSyntax = positiveTest;
         this.lang = lang;
-        boolean silentWarnings = RiotTests.allowWarnings(manifestEntry);
+        boolean silentWarnings = 
RiotTestsConfig.allowWarningsSyntaxTests(manifestEntry);
         parser = ( baseIRI != null )
             ? ParsingStepForTest.parse(filename, baseIRI, lang, silentWarnings)
             : ParsingStepForTest.parse(filename, lang, silentWarnings);
diff --git 
a/jena-arq/src/test/java/org/apache/jena/arq/junit5/riot/RiotTests.java 
b/jena-arq/src/test/java/org/apache/jena/arq/junit5/riot/RiotTests.java
index e7bfe534b9..db980a69a5 100644
--- a/jena-arq/src/test/java/org/apache/jena/arq/junit5/riot/RiotTests.java
+++ b/jena-arq/src/test/java/org/apache/jena/arq/junit5/riot/RiotTests.java
@@ -18,9 +18,7 @@
 
 package org.apache.jena.arq.junit5.riot;
 
-import java.util.HashSet;
 import java.util.Objects;
-import java.util.Set;
 
 import org.apache.jena.arq.junit5.SkipTest;
 import org.apache.jena.arq.junit5.SurpressedTest;
@@ -170,7 +168,7 @@ public class RiotTests
         }
     }
 
-    private static boolean equalsType(Node typeNode, Resource typeResource) {
+    static boolean equalsType(Node typeNode, Resource typeResource) {
         return typeNode.equals(typeResource.asNode());
     }
 
@@ -189,67 +187,6 @@ public class RiotTests
         return baseIRI;
     }
 
-    static Set<String> allowWarningSet = new HashSet<>();
-    static {
-        // example:
-        //allowWarningSet.add("#turtle-eval-bad-01");
-    }
-
-    /**
-     * Tune tests for warnings. Normally, tests runs are warning sensitive.
-     */
-    // Some tests have U+FFFD which, in Jena, generates a helpful warning.
-    // Some tests have <http:g> which RIOT warns about but passes.
-
-    /*package*/ static boolean allowWarnings(ManifestEntry testEntry) {
-        if ( equalsType(testEntry.getTestType(), 
VocabLangRDF.TestPositiveRDFXML) ) {
-            // RDF/XML
-            // Various warnings in eval tests.
-
-            String name = testEntry.getName();
-
-            if ( name.equals("datatypes-test002") )
-                return true;
-
-            if ( name.equals("rdfms-empty-property-elements-test016") )
-                // Processing instruction warning.
-                return true;
-
-            if ( name.equals("rdfms-rdf-names-use-test-015") )
-                //rdf:_1 is being used on a typed node.
-                return true;
-
-            if ( name.startsWith("rdfms-rdf-names-use-warn-") )
-                // "is not a recognized RDF property or type."
-                // "is not a recognized RDF property."
-                return true;
-
-            if ( name.startsWith("unrecognised-xml-attributes-test00") )
-                // XML attribute: xml:foo is not known
-                return true;
-
-            return false;
-        }
-
-        String fragment = fragment(testEntry.getURI());
-        if ( fragment == null )
-            return false;
-
-        // rdf-tests-cg/sparql11-query/syntax-query/
-        // rdf-tests-cg/ntriples/manifest.ttl
-        // rdf-tests-cg/nquads/manifest.ttl
-        // rdf-tests-cg/turtle/manifest.ttl
-        // rdf-tests-cg/trig/manifest.ttl
-        // jena-shex
-        if ( fragment.endsWith("UTF8_boundaries") || 
fragment.endsWith("character_boundaries") )
-            // Boundaries of the Unicode allowed character blocks.
-            return true;
-        // rdf-tests Turtle and Trig
-        if ( fragment.contains("IRI-resolution") )
-            return true;
-        return false;
-    }
-
     /*package*/ static String fragment(String uri) {
         if ( uri == null )
             return null;
@@ -257,5 +194,4 @@ public class RiotTests
         String frag = (j >= 0) ? uri.substring(j) : uri;
         return frag;
     }
-
 }
diff --git 
a/jena-arq/src/test/java/org/apache/jena/arq/junit5/riot/RiotTestsConfig.java 
b/jena-arq/src/test/java/org/apache/jena/arq/junit5/riot/RiotTestsConfig.java
new file mode 100644
index 0000000000..d60f6a2359
--- /dev/null
+++ 
b/jena-arq/src/test/java/org/apache/jena/arq/junit5/riot/RiotTestsConfig.java
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.arq.junit5.riot;
+
+import org.apache.jena.arq.junit5.manifest.ManifestEntry;
+
+/**
+ * Tuning for RIOT tests.
+ */
+public class RiotTestsConfig {
+
+    /**
+     * Tune tests for warnings. Normally, tests runs are warning sensitive.
+     * The allowWarning rules are maintained here and used in RiotEvalTests 
and RiotSyntaxTests.
+     */
+    // Some tests have U+FFFD which, in Jena, generates a helpful warning.
+    // Some tests have <http:g> which RIOT warns about but passes.
+
+    /*package*/ static boolean allowWarningsSyntaxTests(ManifestEntry 
testEntry) {
+        return allowWarnings(testEntry);
+    }
+
+    /*package*/ static boolean allowWarningsEvalTests(ManifestEntry testEntry) 
{
+        return allowWarnings(testEntry);
+    }
+
+    private static boolean allowWarnings(ManifestEntry testEntry) {
+        if ( RiotTests.equalsType(testEntry.getTestType(), 
VocabLangRDF.TestPositiveRDFXML) ) {
+            // RDF/XML
+            // Various warnings in eval tests.
+
+            String name = testEntry.getName();
+
+            if ( name.equals("datatypes-test002") )
+                return true;
+
+            if ( name.equals("rdfms-empty-property-elements-test016") )
+                // Processing instruction warning.
+                return true;
+
+            if ( name.equals("rdfms-rdf-names-use-test-015") )
+                //rdf:_1 is being used on a typed node.
+                return true;
+
+            if ( name.startsWith("rdfms-rdf-names-use-warn-") )
+                // "is not a recognized RDF property or type."
+                // "is not a recognized RDF property."
+                return true;
+
+            if ( name.startsWith("unrecognised-xml-attributes-test00") )
+                // XML attribute: xml:foo is not known
+                return true;
+
+            return false;
+        }
+
+        String fragment = fragment(testEntry.getURI());
+        if ( fragment == null )
+            return false;
+
+        // rdf-tests-cg/sparql11-query/syntax-query/
+        // rdf-tests-cg/ntriples/manifest.ttl
+        // rdf-tests-cg/nquads/manifest.ttl
+        // rdf-tests-cg/turtle/manifest.ttl
+        // rdf-tests-cg/trig/manifest.ttl
+        // jena-shex
+        if ( fragment.endsWith("UTF8_boundaries") || 
fragment.endsWith("character_boundaries") )
+            // Boundaries of the Unicode allowed character blocks.
+            return true;
+        // rdf-tests Turtle and Trig
+        if ( fragment.contains("IRI-resolution") )
+            return true;
+        return false;
+    }
+
+    /*package*/ static String fragment(String uri) {
+        if ( uri == null )
+            return null;
+        int j = uri.lastIndexOf('#');
+        String frag = (j >= 0) ? uri.substring(j) : uri;
+        return frag;
+    }
+
+}

Reply via email to