You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2025/12/23 14:29:11 UTC
(jena) 01/06: GH-3664: Simplify reading of test files
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 ef0118229253fae67c852206e1054c7c3cc515c0
Author: Andy Seaborne <an...@apache.org>
AuthorDate: Sat Dec 20 14:51:24 2025 +0000
GH-3664: Simplify reading of test files
---
.../java/org/apache/jena/rdfxml/xmlinput1/ARP.java | 2 +-
.../rdfxml/libtest/InputStreamFactoryTests.java | 137 ---------------------
.../jena/rdfxml/libtest/LazyFileInputStream.java | 46 -------
.../jena/rdfxml/libtest/LazyInputStream.java | 62 ----------
.../jena/rdfxml/libtest/LazyURLInputStream.java | 50 --------
.../rdfxml/libtest/LazyZipEntryInputStream.java | 52 --------
.../org/apache/jena/rdfxml/xmlinput1/ARPTests.java | 7 --
.../rdfxml/xmlinput1/InputStreamFactoryARP.java | 80 ++++++++++++
.../jena/rdfxml/xmlinput1/NTripleTestSuite.java | 6 +-
.../jena/rdfxml/xmlinput1/TestSuiteWG_RDFXML.java | 3 +-
.../rdfxml/xmlinput1/TestSuiteWG_RDFXML_ARP.java | 3 +-
.../apache/jena/rdfxml/xmlinput1/WGTestSuite.java | 49 ++++----
.../jena/reasoner/test/WGReasonerTester.java | 4 +-
13 files changed, 110 insertions(+), 391 deletions(-)
diff --git a/jena-core/src/main/java/org/apache/jena/rdfxml/xmlinput1/ARP.java b/jena-core/src/main/java/org/apache/jena/rdfxml/xmlinput1/ARP.java
index 0bdaa16671..2564ecbcd9 100644
--- a/jena-core/src/main/java/org/apache/jena/rdfxml/xmlinput1/ARP.java
+++ b/jena-core/src/main/java/org/apache/jena/rdfxml/xmlinput1/ARP.java
@@ -203,7 +203,7 @@ public class ARP implements ARPConfig
arpf.setOptionsWith(opts);
}
- void setBadStatementHandler(StatementHandler sh) {
+ public void setBadStatementHandler(StatementHandler sh) {
arpf.setBadStatementHandler(sh);
}
diff --git a/jena-core/src/test/java/org/apache/jena/rdfxml/libtest/InputStreamFactoryTests.java b/jena-core/src/test/java/org/apache/jena/rdfxml/libtest/InputStreamFactoryTests.java
deleted file mode 100644
index 819d7b4b98..0000000000
--- a/jena-core/src/test/java/org/apache/jena/rdfxml/libtest/InputStreamFactoryTests.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * 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.rdfxml.libtest;
-
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.zip.ZipFile;
-
-import org.apache.jena.irix.IRIx;
-
-/** In support of the RDF 2004 Working Group tests.
- *
- * This class provides input streams that:
- * 1: can be from a URL or from a zip
- * 2: do not actually open until the first read
- */
-public class InputStreamFactoryTests {
-
- final String base;
- final private ZipFile zip;
- final private String property;
- private String createMe = "error";
-
- public InputStreamFactoryTests(String baseDir, String propDir) {
- createMe = "new TestInputStreamFactory(URI.create(\""+baseDir.toString()+"\"),\""+propDir+"\")";
- base = baseDir;
- this.zip = null;
- property = propDir.endsWith("/") ? propDir : propDir + "/";
- }
-
- public String getBase() {
- return base;
- }
-
- /**
- * opens the file, and really does it - not a delayed
- * lazy opening.
- * @param str the URI to open
- * @return null on some failures
- * @throws IOException
- */
- public InputStream fullyOpen(String str) throws IOException {
- InputStream in = open(str);
- if (in instanceof LazyInputStream
- && !((LazyInputStream) in).connect())
- return null;
- return in;
- }
- /**
- * A lazy open. The I/O only starts, and resources
- * are only allocated on first read.
- * @param uri to be opened.
- * @return the opened stream
- */
- public InputStream open(String uri) {
- return (InputStream) open(uri, true);
-
- }
-
- public OutputStream openOutput(String str) {
- OutputStream foo = (OutputStream) open(str, false);
- // System.out.println(foo.toString());
- return foo;
- }
-
- public String getCreationJava() {
- return createMe;
- }
- private Object open(String uri, boolean in) {
-
- IRIx base2 = IRIx.create(base);
- IRIx uri2 = IRIx.create(uri);
- IRIx relative = base2.relativize(uri2);
-
- //IRI relative = uri.isAbsolute() ? base.relativize(uri, IRIRelativize.CHILD) : uri;
-
- if (relative.isAbsolute())
- throw new IllegalArgumentException(
- "This TestInputStreamFactory only knows about '" + base + "'.");
-
- String relPath = relative.toString();
- if ( relPath.length() - relPath.lastIndexOf('.') > 5 ) {
- relPath = relPath + ".rdf";
- relative = IRIx.create(relPath);
- }
-
- if (!in)
- throw new IllegalArgumentException("Can only save to URLs");
-
-
- if (zip != null)
- return new LazyZipEntryInputStream(zip,relPath );
- else
- return InputStreamFactoryTests.getInputStream(property + relPath );
-
- }
-
- private static InputStream getInputStream(String prop) {
- // System.err.println(prop);
- ClassLoader loader = InputStreamFactoryTests.class.getClassLoader();
- if (loader == null)
- throw new SecurityException("Cannot access class loader");
- InputStream in =
- // loader.getResourceAsStream("com/hp/hpl/jena/rdf/arp/test/data/" + prop);
- loader.getResourceAsStream("testing/" + prop);
- // System.out.println(prop);
- if (in == null) {
- try {
- in = new FileInputStream("testing/" + prop);
- } catch (IOException e) {
- }
- if (in == null)
- throw new IllegalArgumentException(
- "Resource: " + prop + " not found on class path.");
- }
-
- return in;
- }
-}
diff --git a/jena-core/src/test/java/org/apache/jena/rdfxml/libtest/LazyFileInputStream.java b/jena-core/src/test/java/org/apache/jena/rdfxml/libtest/LazyFileInputStream.java
deleted file mode 100644
index f1e17da58a..0000000000
--- a/jena-core/src/test/java/org/apache/jena/rdfxml/libtest/LazyFileInputStream.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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.rdfxml.libtest;
-
-
-import java.io.*;
-
-/**
- *
- * In test cases we cannot open all the input files
- * while creating the test suite, but must defer the
- * opening until the test is actually run.
- */
-class LazyFileInputStream extends LazyInputStream {
-
- private String name;
- /** Creates new LazyZipEntryInputStream */
- LazyFileInputStream(String name) {
- // System.err.println(name);
- this.name = name;
- }
-
- @Override
- InputStream open() throws IOException {
- return new FileInputStream(name);
- }
-
-
-
-}
diff --git a/jena-core/src/test/java/org/apache/jena/rdfxml/libtest/LazyInputStream.java b/jena-core/src/test/java/org/apache/jena/rdfxml/libtest/LazyInputStream.java
deleted file mode 100644
index f50ad9b471..0000000000
--- a/jena-core/src/test/java/org/apache/jena/rdfxml/libtest/LazyInputStream.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * 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.rdfxml.libtest;
-
-
-import java.io.*;
-
-/**
- *In test cases we cannot open all the input files
- * while creating the test suite, but must defer the
- * opening until the test is actually run.
- */
-abstract class LazyInputStream extends InputStream {
-
- private InputStream underlying;
- abstract InputStream open() throws IOException;
-
- boolean connect() throws IOException {
- if ( underlying != null )
- return true;
- else {
- underlying = open();
- }
- return underlying != null;
-
- }
-
-
- @Override
- public int read() throws IOException {
- if (underlying == null)
- underlying = open();
- return underlying.read();
- }
-
- @Override
- public void close() throws IOException {
- if (underlying != null) {
- underlying.close();
- underlying = null;
- }
- }
-
-
-
-}
diff --git a/jena-core/src/test/java/org/apache/jena/rdfxml/libtest/LazyURLInputStream.java b/jena-core/src/test/java/org/apache/jena/rdfxml/libtest/LazyURLInputStream.java
deleted file mode 100644
index 5cc1a3a7e5..0000000000
--- a/jena-core/src/test/java/org/apache/jena/rdfxml/libtest/LazyURLInputStream.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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.rdfxml.libtest;
-
-
-import java.io.*;
-import java.net.*;
-
-/**
- *
- * In test cases we cannot open all the input files
- * while creating the test suite, but must defer the
- * opening until the test is actually run.
- */
-class LazyURLInputStream extends LazyInputStream {
-
- private URL url;
- /** Creates new LazyZipEntryInputStream */
- LazyURLInputStream(URL url) {
- // System.err.println(name);
- this.url = url;
- }
-
- @Override
- InputStream open() throws IOException {
- URLConnection conn = url.openConnection();
- // System.err.println(conn.getClass().getName());
-
- return conn.getInputStream();
- }
-
-
-
-}
diff --git a/jena-core/src/test/java/org/apache/jena/rdfxml/libtest/LazyZipEntryInputStream.java b/jena-core/src/test/java/org/apache/jena/rdfxml/libtest/LazyZipEntryInputStream.java
deleted file mode 100644
index 7bcb8a6032..0000000000
--- a/jena-core/src/test/java/org/apache/jena/rdfxml/libtest/LazyZipEntryInputStream.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * 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.rdfxml.libtest;
-
-
-import java.io.*;
-import java.util.zip.*;
-
-/**
- *In test cases we cannot open all the input files
- * while creating the test suite, but must defer the
- * opening until the test is actually run.
- */
-class LazyZipEntryInputStream extends LazyInputStream {
-
- private ZipEntry entry;
- private ZipFile zip;
- /** Creates new LazyZipEntryInputStream */
- LazyZipEntryInputStream(ZipFile zip,String name) {
- // System.err.println(name);
- entry = new ZipEntry(name);
- this.zip = zip;
- }
-
-
- @Override
- InputStream open() throws IOException {
- InputStream rslt = zip.getInputStream(entry);
- if ( rslt == null )
- throw new IllegalArgumentException(entry.getName()+ " cannot be opened.");
- return rslt;
- }
-
-
-
-}
diff --git a/jena-core/src/test/java/org/apache/jena/rdfxml/xmlinput1/ARPTests.java b/jena-core/src/test/java/org/apache/jena/rdfxml/xmlinput1/ARPTests.java
index dc1afbefc5..1fe85e3815 100644
--- a/jena-core/src/test/java/org/apache/jena/rdfxml/xmlinput1/ARPTests.java
+++ b/jena-core/src/test/java/org/apache/jena/rdfxml/xmlinput1/ARPTests.java
@@ -22,13 +22,6 @@ package org.apache.jena.rdfxml.xmlinput1;
* Constants for the test suite for ARP.
*/
public class ARPTests extends java.lang.Object {
- /**
- * Setting this field to true uses the tests found
- * on the W3C web site.
- * The default value false uses a cached corrected
- * copy of the tests.
- */
- static public boolean internet = false;
static String wgTestDir = "http://www.w3.org/2000/10/rdf-tests/rdfcore/";
static String arpTestDir = "http://jcarroll.hpl.hp.com/arp-tests/";
}
diff --git a/jena-core/src/test/java/org/apache/jena/rdfxml/xmlinput1/InputStreamFactoryARP.java b/jena-core/src/test/java/org/apache/jena/rdfxml/xmlinput1/InputStreamFactoryARP.java
new file mode 100644
index 0000000000..af4ea8615a
--- /dev/null
+++ b/jena-core/src/test/java/org/apache/jena/rdfxml/xmlinput1/InputStreamFactoryARP.java
@@ -0,0 +1,80 @@
+/*
+ * 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.rdfxml.xmlinput1;
+
+import java.io.*;
+
+import org.apache.jena.irix.IRIx;
+
+/** In support of the RDF 2004 Working Group tests.
+ *
+ * This class provides input streams that:
+ * 1: can be from a URL or from a zip
+ * 2: do not actually open until the first read
+ */
+public class InputStreamFactoryARP {
+
+ // Jena6 :: Now greatly simplified.
+ // URLs are remapped to load as files from testing/
+ final String rootURL;
+ final private String rootDir;
+
+ public InputStreamFactoryARP(String rootURL, String rootDir) {
+ this.rootURL = rootURL;
+ this.rootDir = rootDir.endsWith("/") ? rootDir : rootDir + "/";
+ }
+
+ public String getBase() {
+ return rootURL;
+ }
+
+ public InputStream fullyOpen(String str) throws IOException {
+ return openForInput(str);
+ }
+
+ private InputStream openForInput(String uri) {
+ // Maps URLs starting rootURL to local files as given by baseURL
+
+ IRIx base2 = IRIx.create(rootURL);
+ IRIx uri2 = IRIx.create(uri);
+ IRIx relative = base2.relativize(uri2);
+
+ //IRI relative = uri.isAbsolute() ? base.relativize(uri, IRIRelativize.CHILD) : uri;
+
+ if (relative.isAbsolute())
+ throw new IllegalArgumentException(
+ "This TestInputStreamFactory only knows about '" + rootURL + "'.");
+
+ String relPath = relative.toString();
+ if ( relPath.length() - relPath.lastIndexOf('.') > 5 ) {
+ relPath = relPath + ".rdf";
+ relative = IRIx.create(relPath);
+ }
+
+ return getInputStream(rootDir + relPath );
+ }
+
+ private static InputStream getInputStream(String prop) {
+ try {
+ return new FileInputStream("testing/" + prop);
+ } catch (FileNotFoundException e) {
+ throw new IllegalArgumentException("Resource: " + prop + " not found on class path.");
+ }
+ }
+}
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 5be1dccc03..978471e6f0 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
@@ -21,12 +21,12 @@ import java.io.*;
import java.util.HashSet;
import java.util.Set;
+import org.junit.Assert;
+
import org.apache.jena.rdf.model.Model;
import org.apache.jena.rdf.model.RDFErrorHandler;
-import org.apache.jena.rdfxml.libtest.InputStreamFactoryTests;
import org.apache.jena.rdfxml.xmlinput1.impl.ARPResource;
import org.apache.jena.rdfxml.xmlinput1.impl.ARPSaxErrorHandler;
-import org.junit.Assert;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
@@ -36,7 +36,7 @@ import org.xml.sax.SAXParseException;
* Jena N-triple writer.
*/
class NTripleTestSuite extends WGTestSuite {
- NTripleTestSuite(InputStreamFactoryTests fact, String name, boolean b) {
+ NTripleTestSuite(InputStreamFactoryARP fact, String name, boolean b) {
super(fact, name, b);
}
diff --git a/jena-core/src/test/java/org/apache/jena/rdfxml/xmlinput1/TestSuiteWG_RDFXML.java b/jena-core/src/test/java/org/apache/jena/rdfxml/xmlinput1/TestSuiteWG_RDFXML.java
index 14766cefb9..a501b97671 100644
--- a/jena-core/src/test/java/org/apache/jena/rdfxml/xmlinput1/TestSuiteWG_RDFXML.java
+++ b/jena-core/src/test/java/org/apache/jena/rdfxml/xmlinput1/TestSuiteWG_RDFXML.java
@@ -20,7 +20,6 @@ package org.apache.jena.rdfxml.xmlinput1;
import junit.framework.Test;
import junit.framework.TestSuite;
-import org.apache.jena.rdfxml.libtest.InputStreamFactoryTests;
public class TestSuiteWG_RDFXML
{
@@ -29,7 +28,7 @@ public class TestSuiteWG_RDFXML
TestSuite testSuite = new TestSuite("WG RDF/XML");
WGTestSuite testSuiteWG =
new org.apache.jena.rdfxml.xmlinput1.WGTestSuite(
- new InputStreamFactoryTests("http://www.w3.org/2000/10/rdf-tests/rdfcore/", "wg"),
+ new InputStreamFactoryARP("http://www.w3.org/2000/10/rdf-tests/rdfcore/", "wg"),
"WG Parser Tests", false);
TestSuite testSuiteApproved = new TestSuite("APPROVED");
diff --git a/jena-core/src/test/java/org/apache/jena/rdfxml/xmlinput1/TestSuiteWG_RDFXML_ARP.java b/jena-core/src/test/java/org/apache/jena/rdfxml/xmlinput1/TestSuiteWG_RDFXML_ARP.java
index 95403cc709..fc27a0d9e7 100644
--- a/jena-core/src/test/java/org/apache/jena/rdfxml/xmlinput1/TestSuiteWG_RDFXML_ARP.java
+++ b/jena-core/src/test/java/org/apache/jena/rdfxml/xmlinput1/TestSuiteWG_RDFXML_ARP.java
@@ -19,7 +19,6 @@
package org.apache.jena.rdfxml.xmlinput1;
import junit.framework.Test;
-import org.apache.jena.rdfxml.libtest.InputStreamFactoryTests;
public class TestSuiteWG_RDFXML_ARP
{
@@ -28,7 +27,7 @@ public class TestSuiteWG_RDFXML_ARP
String base = "http://jcarroll.hpl.hp.com/arp-tests/";
WGTestSuite testSuite = new org.apache.jena.rdfxml.xmlinput1.WGTestSuite
- (new InputStreamFactoryTests(base, "arp")
+ (new InputStreamFactoryARP(base, "arp")
,"ARP RDF/XML Tests"
,false);
Test test177 = testSuite.createPositiveTest("http://jcarroll.hpl.hp.com/arp-tests/xml-literals/reported3",
diff --git a/jena-core/src/test/java/org/apache/jena/rdfxml/xmlinput1/WGTestSuite.java b/jena-core/src/test/java/org/apache/jena/rdfxml/xmlinput1/WGTestSuite.java
index cf39420179..059e484ebe 100644
--- a/jena-core/src/test/java/org/apache/jena/rdfxml/xmlinput1/WGTestSuite.java
+++ b/jena-core/src/test/java/org/apache/jena/rdfxml/xmlinput1/WGTestSuite.java
@@ -30,7 +30,6 @@ import org.apache.jena.irix.IRIx;
import org.apache.jena.rdf.model.*;
import org.apache.jena.rdf.model.impl.PropertyImpl;
import org.apache.jena.rdf.model.impl.ResourceImpl;
-import org.apache.jena.rdfxml.libtest.InputStreamFactoryTests;
import org.apache.jena.rdfxml.xmloutput.impl.RDFXML_Abbrev;
import org.apache.jena.reasoner.rulesys.RDFSRuleReasonerFactory;
import org.apache.jena.reasoner.test.WGReasonerTester;
@@ -81,9 +80,9 @@ class WGTestSuite extends TestSuite implements ARPErrorNumbers {
private static boolean logging = false;
private static String BASE_RESULTS_URI = "https://jena.apache.org/data/rdf-results.rdf";
static public boolean checkMessages = false;
- static private boolean doSemanticTests() {
- return ARPTests.internet;
- }
+
+ static private boolean doSemanticTests() { return false ; }
+
static private boolean inDevelopment = false;
Model loadRDF(InputSupplier in, RDFErrorHandler eh, String base)
throws IOException {
@@ -168,11 +167,9 @@ class WGTestSuite extends TestSuite implements ARPErrorNumbers {
}
};
- InputStreamFactoryTests factory;
+ InputStreamFactoryARP inputStreamMgr;
- static private Collection<String> misc =
- Arrays.asList(
- new String[] { "http://www.w3.org/2000/10/rdf-tests/rdfcore/rdfms-uri-substructure/error001" });
+ static private Collection<String> misc = List.of("http://www.w3.org/2000/10/rdf-tests/rdfcore/rdfms-uri-substructure/error001");
private Map<ResourceImpl, Act> behaviours = new HashMap<>();
@@ -181,8 +178,6 @@ class WGTestSuite extends TestSuite implements ARPErrorNumbers {
.put(new ResourceImpl(testNS + "PositiveParserTest"), new Act() {
@Override
public void act(Resource r) {
- // if (r.getProperty(status).getString().equals(approved))
- // if (r.getURI().endsWith("rdfms-xmllang/test004"))
if (r.hasProperty(warning)) {
addTest(r, new WarningTest(r));
} else {
@@ -194,19 +189,21 @@ class WGTestSuite extends TestSuite implements ARPErrorNumbers {
.put(new ResourceImpl(testNS + "NegativeParserTest"), new Act() {
@Override
public void act(Resource r) {
- // if (r.getProperty(status).getString().equals(approved))
addTest(r, new NegativeTest(r));
}
});
- behaviours.put(new ResourceImpl(testNS + "False-Document"), noop);
+
+ behaviours.put(new ResourceImpl(testNS + "False-Document"), noop);
behaviours.put(new ResourceImpl(testNS + "RDF-XML-Document"), noop);
behaviours.put(new ResourceImpl(testNS + "NT-Document"), noop);
+
behaviours.put(
new ResourceImpl(testNS + "PositiveEntailmentTest"),
semTest);
behaviours.put(
new ResourceImpl(testNS + "NegativeEntailmentTest"),
semTest);
+
behaviours
.put(new ResourceImpl(testNS + "MiscellaneousTest"), new Act() {
@Override
@@ -219,17 +216,17 @@ class WGTestSuite extends TestSuite implements ARPErrorNumbers {
});
}
- private Model loadRDF(final InputStreamFactoryTests fact,
+ private Model loadRDF(final InputStreamFactoryARP fact,
final String file) {
Model m = null;
String base = fact.getBase().toString();
if (!base.endsWith("/"))
base = base + "/";
- try ( InputStream in = fact.fullyOpen(file) ) {
+ try ( InputStream in = openFileOrURI(fact, file) ) {
if (in == null )
return null;
- m = loadRDF(()->fact.fullyOpen(file) , null, base + file);
+ m = loadRDF(()->in , null, base + file);
} catch (JenaException e) {
// System.out.println(e.getMessage());
throw e;
@@ -243,14 +240,18 @@ class WGTestSuite extends TestSuite implements ARPErrorNumbers {
return m;
}
+ private static InputStream openFileOrURI(InputStreamFactoryARP fact, String fileOrURI) throws IOException {
+ return fact.fullyOpen(fileOrURI);
+ }
+
/** Creates new WGTestSuite
This is a private snapshot of the RDF Test Cases Working Draft's
data.
*/
- WGTestSuite(InputStreamFactoryTests fact, String name, boolean dynamic) {
+ WGTestSuite(InputStreamFactoryARP fact, String name, boolean dynamic) {
super(name);
- factory = fact;
+ inputStreamMgr = fact;
testDir = fact.getBase();
if (dynamic)
try {
@@ -286,10 +287,6 @@ class WGTestSuite extends TestSuite implements ARPErrorNumbers {
action.act(st.getSubject());
}
}
- if ( ARPTests.internet) {
- initResults();
- addTest(new DummyTest());
- }
} catch (RuntimeException re) {
re.printStackTrace();
throw re;
@@ -304,7 +301,7 @@ class WGTestSuite extends TestSuite implements ARPErrorNumbers {
static TestSuite suite(String testDir, String d, String nm) {
return new WGTestSuite(
- new InputStreamFactoryTests(testDir, d),
+ new InputStreamFactoryARP(testDir, d),
nm,
true);
}
@@ -407,9 +404,9 @@ class WGTestSuite extends TestSuite implements ARPErrorNumbers {
Resource t = file.getRequiredProperty(RDF.type).getResource();
final String uri = file.getURI();
if (ntriple.equals(t)) {
- return loadNT(factory.open(uri),uri);
+ return loadNT(openFileOrURI(inputStreamMgr, uri),uri);
} else if (rdfxml.equals(t)) {
- return loadRDF( ()->factory.open(uri), this, uri);
+ return loadRDF( ()->openFileOrURI(inputStreamMgr, uri), this, uri);
} else {
fail("Unrecognized file type: " + t);
}
@@ -679,10 +676,10 @@ class WGTestSuite extends TestSuite implements ARPErrorNumbers {
}
Model read(String file, boolean type) throws IOException {
if (!type) {
- return loadNT(factory.open(file),file);
+ return loadNT(openFileOrURI(inputStreamMgr, file),file);
}
final String uri = file;
- return loadRDF( ()->factory.open(uri) , this, uri);
+ return loadRDF(()->openFileOrURI(inputStreamMgr, uri) , this, uri);
}
@Override
diff --git a/jena-core/src/test/java/org/apache/jena/reasoner/test/WGReasonerTester.java b/jena-core/src/test/java/org/apache/jena/reasoner/test/WGReasonerTester.java
index 6bf57d6fc1..50e15d697a 100644
--- a/jena-core/src/test/java/org/apache/jena/reasoner/test/WGReasonerTester.java
+++ b/jena-core/src/test/java/org/apache/jena/reasoner/test/WGReasonerTester.java
@@ -35,7 +35,6 @@ import org.apache.jena.graph.GraphMemFactory;
import org.apache.jena.rdf.model.*;
import org.apache.jena.rdf.model.impl.PropertyImpl;
import org.apache.jena.rdf.model.impl.ResourceImpl;
-import org.apache.jena.rdfxml.xmlinput1.ARPTests;
import org.apache.jena.reasoner.InfGraph;
import org.apache.jena.reasoner.Reasoner;
import org.apache.jena.reasoner.ReasonerFactory;
@@ -326,8 +325,7 @@ public class WGReasonerTester {
// Check the results against the official conclusions
boolean correct = true;
int goodResult = PASS;
- boolean noisy = !(baseDir.equals(DEFAULT_BASE_DIR)
- || ARPTests.internet );
+ boolean noisy = ! baseDir.equals(DEFAULT_BASE_DIR);
if (testType.equals(PositiveEntailmentTest)) {
if (conclusions == null) {
// Check that the result is flagged as semantically invalid