Repository: apache/jena (java)

Issue:
Move ARP's internal use NTriples parser to the test area
### Change

ARP has its own NTriples parser. It is only used in tests.

There are two such parser - in ARP0 and in ARP1.


### Are you interested in contributing a pull request for this task?

Yes

Pull request:
GH-2997: Move ARP's NTriples code to the test area.
GitHub issue resolved #2997

Pull request Description: 
* Move ARP's NTriples code (ARP was able to run standalone) to the test area.
* Various small things.



----

 - [x] Commits have been squashed to remove intermediate development commit messages.
 - [x] Key commit messages start with the issue number (GH-xxxx)

By submitting this pull request, I acknowledge that I am making a contribution to the Apache Software Foundation under the terms and conditions of the [Contributor's Agreement](https://www.apache.org/licenses/contributor-agreements.html).


Patch:
diff --git a/jena-arq/src/main/java/org/apache/jena/riot/lang/rdfxml/rrx/ParserRRX_SAX.java b/jena-arq/src/main/java/org/apache/jena/riot/lang/rdfxml/rrx/ParserRRX_SAX.java
index 30daf48700..6225282a89 100644
--- a/jena-arq/src/main/java/org/apache/jena/riot/lang/rdfxml/rrx/ParserRRX_SAX.java
+++ b/jena-arq/src/main/java/org/apache/jena/riot/lang/rdfxml/rrx/ParserRRX_SAX.java
@@ -42,7 +42,6 @@ import org.apache.jena.irix.IRIx;
 import org.apache.jena.riot.RiotException;
 import org.apache.jena.riot.lang.rdfxml.RDFXMLParseException;
 import org.apache.jena.riot.out.NodeFmtLib;
-import org.apache.jena.riot.system.FactoryRDF;
 import org.apache.jena.riot.system.ParserProfile;
 import org.apache.jena.riot.system.StreamRDF;
 import org.apache.jena.sparql.util.Context;
@@ -382,7 +381,7 @@ class ParserRRX_SAX
 
     // ---- Parser Setup
     private final ParserProfile parserProfile;
-    private final FactoryRDF factory;
+  //  private final FactoryRDF factory;
     private final Context context;
     private final org.apache.jena.riot.system.ErrorHandler errorHandler;
     private final String initialXmlBase;
@@ -497,7 +496,6 @@ class ParserRRX_SAX
         // Debug
 
         this.parserProfile = parserProfile;
-        this.factory = parserProfile.getFactorRDF();
         this.errorHandler = parserProfile.getErrorHandler();
         this.context = context;
         this.initialXmlBase = xmlBase;
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/graph/NodeTransformLib.java b/jena-arq/src/main/java/org/apache/jena/sparql/graph/NodeTransformLib.java
index fa38705ee9..cd7435b6bd 100644
--- a/jena-arq/src/main/java/org/apache/jena/sparql/graph/NodeTransformLib.java
+++ b/jena-arq/src/main/java/org/apache/jena/sparql/graph/NodeTransformLib.java
@@ -40,8 +40,8 @@ import org.apache.jena.sparql.expr.ExprTransform;
 
 public class NodeTransformLib {
     /**
-     * Do a node{@literal ->}node conversion of an Op - return
-     * original BGP for "no change"
+     * Do a node{@literal ->}node conversion of an {@link Op} - return
+     * original {@link Op} java object for "no change"
      */
     public static Op transform(NodeTransform nodeTransform, Op op) {
         Transform opTransform = new NodeTransformOp(nodeTransform);
@@ -51,7 +51,7 @@ public class NodeTransformLib {
 
     /**
      * Do a node{@literal ->}node conversion of a BGP - return
-     * original BGP for "no change".
+     * original BGP java object for "no change".
      */
     public static BasicPattern transform(NodeTransform nodeTransform, BasicPattern pattern) {
         BasicPattern bgp2 = new BasicPattern();
diff --git a/jena-core/src/main/java/org/apache/jena/rdfxml/xmlinput0/NTriple.java b/jena-core/src/test/java/org/apache/jena/rdfxml/xmlinput0/NTripleARP0.java
similarity index 99%
rename from jena-core/src/main/java/org/apache/jena/rdfxml/xmlinput0/NTriple.java
rename to jena-core/src/test/java/org/apache/jena/rdfxml/xmlinput0/NTripleARP0.java
index 22f9a64bdc..6b3f0d7740 100644
--- a/jena-core/src/main/java/org/apache/jena/rdfxml/xmlinput0/NTriple.java
+++ b/jena-core/src/test/java/org/apache/jena/rdfxml/xmlinput0/NTripleARP0.java
@@ -85,8 +85,8 @@ import org.xml.sax.SAXParseException;
  * </dl>
  * @deprecated Legacy. To be removed.
  */
-@Deprecated
-public class NTriple implements ARPErrorNumbers {
+@Deprecated(forRemoval = true)
+public class NTripleARP0 implements ARPErrorNumbers {
 
 	private static StringBuilder line = new StringBuilder();
     private static ARP0 arp;
@@ -198,7 +198,7 @@ public class NTriple implements ARPErrorNumbers {
 	static void usage() {
 		System.err.println(
 			"java <class-path> "
-				+ NTriple.class.getName()
+				+ NTripleARP0.class.getName()
 				+ " ( [ -[xstfurR]][ -b xmlBase -[eiw] NNN[,NNN...] ] [ file ] [ url ] )... ");
 		System.err.println(
 			"    All options, files and URLs can be intemingled in any order.");
diff --git a/jena-core/src/main/java/org/apache/jena/rdfxml/xmlinput1/NTriple.java b/jena-core/src/test/java/org/apache/jena/rdfxml/xmlinput1/NTripleARP1.java
similarity index 98%
rename from jena-core/src/main/java/org/apache/jena/rdfxml/xmlinput1/NTriple.java
rename to jena-core/src/test/java/org/apache/jena/rdfxml/xmlinput1/NTripleARP1.java
index f15e283b81..3b57f89355 100644
--- a/jena-core/src/main/java/org/apache/jena/rdfxml/xmlinput1/NTriple.java
+++ b/jena-core/src/test/java/org/apache/jena/rdfxml/xmlinput1/NTripleARP1.java
@@ -83,20 +83,15 @@ import org.xml.sax.SAXParseException;
  * </dt><dd>
  * Ignores numbered error/warning conditions.
  * </dl>
+ * @deprecated Internaluse only To be removed.
  */
-@SuppressWarnings("deprecation")
-public class NTriple implements ARPErrorNumbers {
+@Deprecated(forRemoval = true)
+public class NTripleARP1 implements ARPErrorNumbers {
 
 	private static StringBuilder line = new StringBuilder();
 	private static ARP arp;
 	private static String xmlBase = null;
 	private static boolean numbers = false;
-	/** Starts an RDF/XML to NTriple converter.
-	 * @param args The command-line arguments.
-	 */
-	static public void main(String args[]) {
-		mainEh(args, null, null);
-	}
 	static StatementHandler andMeToo = null;
 	/** Starts an RDF/XML to NTriple converter,
 	 * using an error handler, and an ARPHandler.
@@ -197,7 +192,7 @@ public class NTriple implements ARPErrorNumbers {
 	static void usage() {
 		System.err.println(
 			"java <class-path> "
-				+ NTriple.class.getName()
+				+ NTripleARP1.class.getName()
 				+ " ( [ -[xstfurR]][ -b xmlBase -[eiw] NNN[,NNN...] ] [ file ] [ url ] )... ");
 		System.err.println(
 			"    All options, files and URLs can be intemingled in any order.");
diff --git a/jena-iri3986/src/main/java/org/apache/jena/rfc3986/ParseDID.java b/jena-iri3986/src/main/java/org/apache/jena/rfc3986/ParseDID.java
index adc38247e7..564677de79 100644
--- a/jena-iri3986/src/main/java/org/apache/jena/rfc3986/ParseDID.java
+++ b/jena-iri3986/src/main/java/org/apache/jena/rfc3986/ParseDID.java
@@ -43,7 +43,7 @@ public class ParseDID {
 
     April 2021: At-risk : add: empty  method-specific-id
 */
-    private static final Pattern DID_PATTERN = Pattern.compile("^did:[a-z]+:(?:(?:[A-Za-z0-9.-_]|%[0-9]A-Fa-f]{2})+)$");
+    private static final Pattern DID_PATTERN = Pattern.compile("^did:[a-z]+:(?:(?:[a-z0-9.-_]|%[0-9]A-Fa-f]{2})+)$");
     private static final int DIDStart = "did:".length();
 
     static
@@ -55,10 +55,6 @@ public class ParseDID {
         int end = string.length();
         int p = DIDStart;
 
-        // XXX if string is empty or single space.
-        // XXX if string starts "."
-        // XXX if string ends ":"
-
         int q = methodName(string, p);
         if ( q <= p+1)
             error(string, "No method name");
@@ -84,6 +80,7 @@ public class ParseDID {
                 p++;
                 return p;
             }
+            // Special upper case for better error message?
             if ( ! methodChar(ch) )
                 error(str, "Bad character: '"+Character.toString(ch)+"'");
             p++;
diff --git a/jena-iri3986/src/main/java/org/apache/jena/rfc3986/ParseDNS.java b/jena-iri3986/src/main/java/org/apache/jena/rfc3986/ParseDNS.java
index c52360d081..8d7c3da981 100644
--- a/jena-iri3986/src/main/java/org/apache/jena/rfc3986/ParseDNS.java
+++ b/jena-iri3986/src/main/java/org/apache/jena/rfc3986/ParseDNS.java
@@ -52,7 +52,7 @@ public class ParseDNS {
      *   Internationalization
      */
 
-    /* RFC952:
+    /* RFC 952:
      *
      * <hname> ::= <name>*["."<name>]
      * <name> ::=  <let>[*[<let-or-digit-or-hyphen>]<let-or-digit>]


Test patch:
diff --git a/jena-core/src/test/java/org/apache/jena/rdfxml/xmlinput0/ARPTests2.java b/jena-core/src/test/java/org/apache/jena/rdfxml/xmlinput0/ARPTests2.java
index dfb86f3ce8..9aecef2887 100644
--- a/jena-core/src/test/java/org/apache/jena/rdfxml/xmlinput0/ARPTests2.java
+++ b/jena-core/src/test/java/org/apache/jena/rdfxml/xmlinput0/ARPTests2.java
@@ -545,6 +545,7 @@ public class ARPTests2 extends TestCase implements RDFErrorHandler, ARPErrorNumb
 //        checkExpected() ;
 //    }
 
+    @SuppressWarnings("removal")
     public void testNTripleEscaping() {
     	String data[][] = {
     			{ "foo", "foo" },
@@ -555,7 +556,7 @@ public class ARPTests2 extends TestCase implements RDFErrorHandler, ARPErrorNumb
     	};
     	for (String p[] : data ) {
 //    		System.err.println(NTriple.escapeNTriple(p[0]));
-    		Assert.assertEquals("NTriple escaping", p[1],NTriple.escapeNTriple(p[0]) );
+    		Assert.assertEquals("NTriple escaping", p[1],NTripleARP0.escapeNTriple(p[0]) );
     	}
 
 
diff --git a/jena-core/src/test/java/org/apache/jena/rdfxml/xmlinput0/NTripleTestSuite.java b/jena-core/src/test/java/org/apache/jena/rdfxml/xmlinput0/NTripleTestSuite.java
index ca23ed1902..9f489d37a9 100644
--- a/jena-core/src/test/java/org/apache/jena/rdfxml/xmlinput0/NTripleTestSuite.java
+++ b/jena-core/src/test/java/org/apache/jena/rdfxml/xmlinput0/NTripleTestSuite.java
@@ -242,7 +242,7 @@ class NTripleTestSuite extends WGTestSuite {
 		return loadRDFx(in, eh, base, true, 0);
 	}
 
-    @SuppressWarnings("deprecation")
+    @SuppressWarnings("removal")
     static Model loadRDFx(
 		InFactoryX in,
 		RDFErrorHandler eh,
@@ -274,7 +274,7 @@ class NTripleTestSuite extends WGTestSuite {
 			System.setIn(in.open());
 			System.setOut(out);
 			try {
-				NTriple.mainEh(new String[] { "-b", base, "-s" }, th, th);
+				NTripleARP0.mainEh(new String[] { "-b", base, "-s" }, th, th);
 			} catch (SimulatedException e) {
 				if (wantModel)
 					throw e;
diff --git a/jena-core/src/test/java/org/apache/jena/rdfxml/xmlinput0/TaintingTests.java b/jena-core/src/test/java/org/apache/jena/rdfxml/xmlinput0/TaintingTests.java
index 20ce16401c..e8b31bd39e 100644
--- a/jena-core/src/test/java/org/apache/jena/rdfxml/xmlinput0/TaintingTests.java
+++ b/jena-core/src/test/java/org/apache/jena/rdfxml/xmlinput0/TaintingTests.java
@@ -178,7 +178,7 @@ public class TaintingTests extends TestCase implements ErrorHandler,
 	}
 
     @Override
-    @SuppressWarnings("deprecation")
+    @SuppressWarnings("removal")
     public void runTest() throws IOException {
         ByteArrayOutputStream goodBytes = new ByteArrayOutputStream();
         ByteArrayOutputStream badBytes = new ByteArrayOutputStream();
@@ -187,7 +187,7 @@ public class TaintingTests extends TestCase implements ErrorHandler,
         try (PrintStream out = new PrintStream(goodBytes); PrintStream err = new PrintStream(badBytes); ) {
             System.setOut(out);
             System.setErr(err);
-            NTriple.mainEh(new String[]{"-e","102,136,105,103,108,107,116,106,004,131",
+            NTripleARP0.mainEh(new String[]{"-e","102,136,105,103,108,107,116,106,004,131",
                 "-E","-b",base,fileName},this,null);
         }
         finally {
diff --git a/jena-core/src/test/java/org/apache/jena/rdfxml/xmlinput1/NTripleTestSuite.java b/jena-core/src/test/java/org/apache/jena/rdfxml/xmlinput1/NTripleTestSuite.java
index 7f73ba0049..1675c804e5 100644
--- a/jena-core/src/test/java/org/apache/jena/rdfxml/xmlinput1/NTripleTestSuite.java
+++ b/jena-core/src/test/java/org/apache/jena/rdfxml/xmlinput1/NTripleTestSuite.java
@@ -226,6 +226,7 @@ class NTripleTestSuite extends WGTestSuite {
 		return loadRDFx(in, eh, base, true, 0);
 	}
 
+    @SuppressWarnings("removal")
     static Model loadRDFx(
 		InputSupplier in,
 		RDFErrorHandler eh,
@@ -257,7 +258,7 @@ class NTripleTestSuite extends WGTestSuite {
 			System.setIn(in.open());
 			System.setOut(out);
 			try {
-				NTriple.mainEh(new String[] { "-b", base, "-s" }, th, th);
+				NTripleARP1.mainEh(new String[] { "-b", base, "-s" }, th, th);
 			} catch (SimulatedException e) {
 				if (wantModel)
 					throw e;
diff --git a/jena-core/src/test/java/org/apache/jena/rdfxml/xmlinput1/TestsARP.java b/jena-core/src/test/java/org/apache/jena/rdfxml/xmlinput1/TestsARP.java
index cdd10d6ff9..e99533e721 100644
--- a/jena-core/src/test/java/org/apache/jena/rdfxml/xmlinput1/TestsARP.java
+++ b/jena-core/src/test/java/org/apache/jena/rdfxml/xmlinput1/TestsARP.java
@@ -495,6 +495,7 @@ public class TestsARP extends TestCase implements RDFErrorHandler, ARPErrorNumbe
 //        checkExpected() ;
 //    }
 
+    @SuppressWarnings("removal")
     public void testNTripleEscaping() {
     	String data[][] = {
     			{ "foo", "foo" },
@@ -505,7 +506,7 @@ public class TestsARP extends TestCase implements RDFErrorHandler, ARPErrorNumbe
     	};
     	for (String p[] : data ) {
 //    		System.err.println(NTriple.escapeNTriple(p[0]));
-    		Assert.assertEquals("NTriple escaping", p[1],NTriple.escapeNTriple(p[0]) );
+    		Assert.assertEquals("NTriple escaping", p[1],NTripleARP1.escapeNTriple(p[0]) );
     	}
 
 
diff --git a/jena-core/src/test/java/org/apache/jena/rdfxml/xmlinput1/TestsTainting.java b/jena-core/src/test/java/org/apache/jena/rdfxml/xmlinput1/TestsTainting.java
index b51e4e0b86..ba472f50cb 100644
--- a/jena-core/src/test/java/org/apache/jena/rdfxml/xmlinput1/TestsTainting.java
+++ b/jena-core/src/test/java/org/apache/jena/rdfxml/xmlinput1/TestsTainting.java
@@ -183,6 +183,7 @@ public class TestsTainting extends TestCase implements ErrorHandler,
 		OntDocumentManager.getInstance().reset(true);
 	}
 
+    @SuppressWarnings("removal")
     @Override
     public void runTest() throws IOException {
         ByteArrayOutputStream goodBytes = new ByteArrayOutputStream();
@@ -192,7 +193,7 @@ public class TestsTainting extends TestCase implements ErrorHandler,
         try (PrintStream out = new PrintStream(goodBytes); PrintStream err = new PrintStream(badBytes); ) {
             System.setOut(out);
             System.setErr(err);
-            NTriple.mainEh(new String[]{"-e","102,136,105,103,108,107,116,106,004,131",
+            NTripleARP1.mainEh(new String[]{"-e","102,136,105,103,108,107,116,106,004,131",
                 "-E","-b",base,fileName},this,null);
         }
         finally {
diff --git a/jena-shex/src/test/files/spec/validation/Q.rq b/jena-shex/src/test/files/spec/validation/Q.rq
deleted file mode 100644
index 9c683906da..0000000000
--- a/jena-shex/src/test/files/spec/validation/Q.rq
+++ /dev/null
@@ -1,6 +0,0 @@
-PREFIX sht: <http://www.w3.org/ns/shacl/test-suite#>
-
-SELECT DISTINCT ?o {
-    ?s a ?o .
-    FILTER(STRSTARTS( str(?o) , str(sht:) ))
-}