commonsrdf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject [21/49] incubator-commonsrdf git commit: avoid UnsupportedOperationException
Date Fri, 28 Oct 2016 13:14:43 GMT
avoid UnsupportedOperationException


Project: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/commit/3ed42722
Tree: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/tree/3ed42722
Diff: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/diff/3ed42722

Branch: refs/heads/master
Commit: 3ed4272245535ed2fdb4b29ca074964734ea24ce
Parents: 417963f
Author: Stian Soiland-Reyes <stain@apache.org>
Authored: Sun Oct 23 01:32:24 2016 +0100
Committer: Stian Soiland-Reyes <stain@apache.org>
Committed: Sun Oct 23 01:32:24 2016 +0100

----------------------------------------------------------------------
 .../java/org/apache/commons/rdf/api/RDF.java    | 74 +++++---------------
 .../rdf/api/DefaultRDFTermFactoryTest.java      | 33 ---------
 .../commons/rdf/rdf4j/NativeStoreGraphTest.java | 14 ++++
 .../commons/rdf/simple/DefaultGraphTest.java    | 51 --------------
 4 files changed, 30 insertions(+), 142 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/3ed42722/api/src/main/java/org/apache/commons/rdf/api/RDF.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/commons/rdf/api/RDF.java b/api/src/main/java/org/apache/commons/rdf/api/RDF.java
index bd405d0..0565ba4 100644
--- a/api/src/main/java/org/apache/commons/rdf/api/RDF.java
+++ b/api/src/main/java/org/apache/commons/rdf/api/RDF.java
@@ -60,10 +60,7 @@ public interface RDF {
      * @throws UnsupportedOperationException
      *             If the operation is not supported.
      */
-    default BlankNode createBlankNode() throws UnsupportedOperationException {
-        throw new UnsupportedOperationException(
-                "createBlankNode() not supported");
-    }
+	 public BlankNode createBlankNode();
 
     /**
      * Create a blank node based on the given name.
@@ -87,14 +84,8 @@ public interface RDF {
      *            A non-empty, non-null, String that is unique to this blank
      *            node in the context of this {@link RDF}.
      * @return A BlankNode for the given name
-     * @throws UnsupportedOperationException
-     *             If the operation is not supported.
      */
-    default BlankNode createBlankNode(String name)
-            throws UnsupportedOperationException {
-        throw new UnsupportedOperationException(
-                "createBlankNode(String) not supported");
-    }
+	public BlankNode createBlankNode(String name);
 
     /**
      * Create a new graph.
@@ -103,11 +94,8 @@ public interface RDF {
      * mechanism.
      *
      * @return A new Graph
-     * @throws UnsupportedOperationException If the operation is not supported.
      */
-    default Graph createGraph() throws UnsupportedOperationException {
-        throw new UnsupportedOperationException("createGraph() not supported");
-    }
+	 public Graph createGraph();
 
     /**
      * Create a new dataset.
@@ -116,11 +104,8 @@ public interface RDF {
      * mechanism.
      *
      * @return A new Dataset
-     * @throws UnsupportedOperationException If the operation is not supported.
      */
-    default Dataset createDataset() throws UnsupportedOperationException {
-        throw new UnsupportedOperationException("createDataset() not supported");
-    }
+	public Dataset createDataset();
 
     /**
      * Create an IRI from a (possibly escaped) String.
@@ -133,13 +118,8 @@ public interface RDF {
      * @return A new IRI
      * @throws IllegalArgumentException      If the provided string is not acceptable, e.g.
does not
      *                                       conform to the RFC3987 syntax.
-     * @throws UnsupportedOperationException If the operation is not supported.
      */
-    default IRI createIRI(String iri) throws IllegalArgumentException,
-            UnsupportedOperationException {
-        throw new UnsupportedOperationException(
-                "createIRI(String) not supported");
-    }
+	public IRI createIRI(String iri) throws IllegalArgumentException;
 
     /**
      * Create a simple literal.
@@ -157,13 +137,9 @@ public interface RDF {
      * @return The created Literal
      * @throws IllegalArgumentException      If the provided lexicalForm is not acceptable,
e.g. because
      *                                       it is too large for an underlying storage.
-     * @throws UnsupportedOperationException If the operation is not supported.
      */
-    default Literal createLiteral(String lexicalForm)
-            throws IllegalArgumentException, UnsupportedOperationException {
-        throw new UnsupportedOperationException(
-                "createLiteral(String) not supported");
-    }
+    public Literal createLiteral(String lexicalForm)
+            throws IllegalArgumentException;
 
     /**
      * Create a literal with the specified data type.
@@ -191,13 +167,9 @@ public interface RDF {
      * @return The created Literal
      * @throws IllegalArgumentException      If any of the provided arguments are not acceptable,
e.g.
      *                                       because the provided dataType is not permitted.
-     * @throws UnsupportedOperationException If the operation is not supported.
      */
-    default Literal createLiteral(String lexicalForm, IRI dataType)
-            throws IllegalArgumentException, UnsupportedOperationException {
-        throw new UnsupportedOperationException(
-                "createLiteral(String) not supported");
-    }
+    public Literal createLiteral(String lexicalForm, IRI dataType)
+            throws IllegalArgumentException;
 
     /**
      * Create a language-tagged literal.
@@ -226,13 +198,9 @@ public interface RDF {
      * @return The created Literal
      * @throws IllegalArgumentException      If the provided values are not acceptable, e.g.
because the
      *                                       languageTag was syntactically invalid.
-     * @throws UnsupportedOperationException If the operation is not supported.
      */
-    default Literal createLiteral(String lexicalForm, String languageTag)
-            throws IllegalArgumentException, UnsupportedOperationException {
-        throw new UnsupportedOperationException(
-                "createLiteral(String,String) not supported");
-    }
+    public Literal createLiteral(String lexicalForm, String languageTag)
+            throws IllegalArgumentException;
 
     /**
      * Create a triple.
@@ -249,14 +217,9 @@ public interface RDF {
      * @throws IllegalArgumentException      If any of the provided arguments are not acceptable,
e.g.
      *                                       because a Literal has a lexicalForm that is
too large for an
      *                                       underlying storage.
-     * @throws UnsupportedOperationException If the operation is not supported.
      */
-    default Triple createTriple(BlankNodeOrIRI subject, IRI predicate,
-                                RDFTerm object) throws IllegalArgumentException,
-            UnsupportedOperationException {
-        throw new UnsupportedOperationException(
-                "createTriple(BlankNodeOrIRI,IRI,RDFTerm) not supported");
-    }
+    public Triple createTriple(BlankNodeOrIRI subject, IRI predicate,
+                                RDFTerm object) throws IllegalArgumentException;
 
     /**
      * Create a quad.
@@ -268,7 +231,7 @@ public interface RDF {
      * equal to the provided predicate, and a {@link Quad#getObject()} that is
      * equal to the provided object.
      *
-     * @param graphName The IRI or BlankNode that this quad belongs to, or <code>null</code>
for the default graph
+     * @param graphName The IRI or BlankNode that this quad belongs to, or <code>null</code>
for the public graph
      * @param subject   The IRI or BlankNode that is the subject of the quad
      * @param predicate The IRI that is the predicate of the quad
      * @param object    The IRI, BlankNode or Literal that is the object of the quad
@@ -276,13 +239,8 @@ public interface RDF {
      * @throws IllegalArgumentException      If any of the provided arguments are not acceptable,
e.g.
      *                                       because a Literal has a lexicalForm that is
too large for an
      *                                       underlying storage.
-     * @throws UnsupportedOperationException If the operation is not supported.
      */
-    default Quad createQuad(BlankNodeOrIRI graphName, BlankNodeOrIRI subject, IRI predicate,
-                                RDFTerm object) throws IllegalArgumentException,
-            UnsupportedOperationException {
-        throw new UnsupportedOperationException(
-                "createQuad(BlankNodeOrIRI,BlankNodeOrIRI,IRI,RDFTerm) not supported");
-    }
+    public Quad createQuad(BlankNodeOrIRI graphName, BlankNodeOrIRI subject, IRI predicate,
+                                RDFTerm object) throws IllegalArgumentException;
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/3ed42722/api/src/test/java/org/apache/commons/rdf/api/DefaultRDFTermFactoryTest.java
----------------------------------------------------------------------
diff --git a/api/src/test/java/org/apache/commons/rdf/api/DefaultRDFTermFactoryTest.java b/api/src/test/java/org/apache/commons/rdf/api/DefaultRDFTermFactoryTest.java
deleted file mode 100644
index a800191..0000000
--- a/api/src/test/java/org/apache/commons/rdf/api/DefaultRDFTermFactoryTest.java
+++ /dev/null
@@ -1,33 +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.commons.rdf.api;
-
-/**
- * The default RDF might be useless (every method throws
- * UnsupportedOperationException), but this test ensures that
- * AbstractRDFTermFactoryTest does not fall over on unsupported operations.
- */
-public class DefaultRDFTermFactoryTest extends AbstractRDFTermFactoryTest {
-
-    @Override
-    public RDF createFactory() {
-        return new RDF() {
-        };
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/3ed42722/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/NativeStoreGraphTest.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/NativeStoreGraphTest.java b/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/NativeStoreGraphTest.java
index bedea22..e5a9772 100644
--- a/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/NativeStoreGraphTest.java
+++ b/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/NativeStoreGraphTest.java
@@ -24,8 +24,10 @@ import java.util.Set;
 
 import org.apache.commons.rdf.api.AbstractGraphTest;
 import org.apache.commons.rdf.api.BlankNodeOrIRI;
+import org.apache.commons.rdf.api.Dataset;
 import org.apache.commons.rdf.api.IRI;
 import org.apache.commons.rdf.api.Literal;
+import org.apache.commons.rdf.api.Quad;
 import org.apache.commons.rdf.api.RDFTerm;
 import org.apache.commons.rdf.api.RDF;
 import org.eclipse.rdf4j.repository.RepositoryConnection;
@@ -59,7 +61,14 @@ public class NativeStoreGraphTest extends AbstractGraphTest {
 			Set<RDF4JBlankNode> context = Collections.singleton(rdf4jFactory.createBlankNode());
 			return rdf4jFactory.asRDFTermGraph(getRepository(), context);
 		}
+		@Override
+		public Dataset createDataset() {
+			throw new UnsupportedOperationException("Can't create more than one Dataset in this test");
+			// ...as the below would re-use the same repository:
+			//return rdf4jFactory.asRDFTermDataset(getRepository()); 
+		}
 
+		
 		// Delegate methods 
 		public RDF4JBlankNode createBlankNode() {
 			return rdf4jFactory.createBlankNode();
@@ -82,6 +91,11 @@ public class NativeStoreGraphTest extends AbstractGraphTest {
 		public RDF4JTriple createTriple(BlankNodeOrIRI subject, IRI predicate, RDFTerm object)
{
 			return rdf4jFactory.createTriple(subject, predicate, object);
 		}
+		@Override
+		public Quad createQuad(BlankNodeOrIRI graphName, BlankNodeOrIRI subject, IRI predicate,
RDFTerm object)
+				throws IllegalArgumentException {
+			return rdf4jFactory.createQuad(graphName, subject, predicate, object);
+		}
 	}
 
 

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/3ed42722/simple/src/test/java/org/apache/commons/rdf/simple/DefaultGraphTest.java
----------------------------------------------------------------------
diff --git a/simple/src/test/java/org/apache/commons/rdf/simple/DefaultGraphTest.java b/simple/src/test/java/org/apache/commons/rdf/simple/DefaultGraphTest.java
deleted file mode 100644
index 3d3aad1..0000000
--- a/simple/src/test/java/org/apache/commons/rdf/simple/DefaultGraphTest.java
+++ /dev/null
@@ -1,51 +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.commons.rdf.simple;
-
-import org.apache.commons.rdf.api.AbstractGraphTest;
-import org.apache.commons.rdf.api.Graph;
-import org.apache.commons.rdf.api.IRI;
-import org.apache.commons.rdf.api.RDF;
-
-/**
- * Ensure AbstractGraphTest does not crash if the RDF throws
- * UnsupportedOperationException
- */
-
-public class DefaultGraphTest extends AbstractGraphTest {
-
-    @Override
-    public RDF createFactory() {
-        // The most minimal RDF that would still
-        // make sense with a Graph
-        return new RDF() {
-            @Override
-            public Graph createGraph() throws UnsupportedOperationException {
-                return new GraphImpl(new SimpleRDF());
-            }
-
-            @Override
-            public IRI createIRI(String iri)
-                    throws UnsupportedOperationException,
-                    IllegalArgumentException {
-                return new IRIImpl(iri);
-            }
-        };
-    }
-
-}


Mime
View raw message