commonsrdf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wik...@apache.org
Subject [34/50] [abbrv] incubator-commonsrdf git commit: Add test and reword contract for RDFTermFactory.createBlankNode(String)
Date Fri, 27 Mar 2015 18:15:32 GMT
Add test and reword contract for RDFTermFactory.createBlankNode(String)

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

Branch: refs/heads/master
Commit: f8ad580c81bf3fd7e1aefa257da90ee73ac3762a
Parents: 5bb67d3
Author: Peter Ansell <p_ansell@yahoo.com>
Authored: Tue Jan 27 14:36:01 2015 +1100
Committer: Peter Ansell <p_ansell@yahoo.com>
Committed: Tue Jan 27 14:36:01 2015 +1100

----------------------------------------------------------------------
 .../github/commonsrdf/api/RDFTermFactory.java   |  6 ++--
 .../api/AbstractRDFTermFactoryTest.java         | 33 +++++++++++++-------
 2 files changed, 26 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/f8ad580c/api/src/main/java/com/github/commonsrdf/api/RDFTermFactory.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/com/github/commonsrdf/api/RDFTermFactory.java b/api/src/main/java/com/github/commonsrdf/api/RDFTermFactory.java
index 0643ba4..90592c6 100644
--- a/api/src/main/java/com/github/commonsrdf/api/RDFTermFactory.java
+++ b/api/src/main/java/com/github/commonsrdf/api/RDFTermFactory.java
@@ -61,10 +61,12 @@ public interface RDFTermFactory {
 	 * the equals contract for {@link BlankNode} for more information.
 	 * <p>
 	 * If supported, the {@link BlankNode#internalIdentifier()} of the returned
-	 * blank node SHOULD be equal to the provided identifier.
+	 * blank node MAY be equal to the provided identifier.
 	 * 
 	 * @param identifier
-	 *            An internal identifier for the blank node.
+	 *            A non-empty String that is unique to this blank node in this
+	 *            scope, and which may be used as the internal identifier for
+	 *            the blank node.
 	 * @return A BlankNode for the given identifier
 	 * @throws IllegalArgumentException
 	 *             if the identifier is not acceptable, e.g. was empty or

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/f8ad580c/api/src/test/java/com/github/commonsrdf/api/AbstractRDFTermFactoryTest.java
----------------------------------------------------------------------
diff --git a/api/src/test/java/com/github/commonsrdf/api/AbstractRDFTermFactoryTest.java b/api/src/test/java/com/github/commonsrdf/api/AbstractRDFTermFactoryTest.java
index 091571b..36b2cb8 100644
--- a/api/src/test/java/com/github/commonsrdf/api/AbstractRDFTermFactoryTest.java
+++ b/api/src/test/java/com/github/commonsrdf/api/AbstractRDFTermFactoryTest.java
@@ -49,7 +49,18 @@ public abstract class AbstractRDFTermFactoryTest {
 		BlankNode bnode2 = factory.createBlankNode();
 		assertNotEquals(
 				"Second blank node has not got a unique internal identifier",
-				bnode.internalIdentifier(), bnode2.internalIdentifier());		
+				bnode.internalIdentifier(), bnode2.internalIdentifier());
+	}
+
+	@Test
+	public void createBlankNodeIdentifierEmpty() throws Exception {
+		try {
+			factory.createBlankNode("");
+		} catch (UnsupportedOperationException e) {
+			Assume.assumeNoException(e);
+		} catch (IllegalArgumentException e) {
+			// Expected exception
+		}
 	}
 
 	@Test
@@ -64,7 +75,7 @@ public abstract class AbstractRDFTermFactoryTest {
 		assertEquals("example1", bnode.internalIdentifier());
 		// .. but we can't assume the internal identifier leaks into
 		// ntriplesString
-		//assertEquals("_:example1", bnode.ntriplesString());
+		// assertEquals("_:example1", bnode.ntriplesString());
 	}
 
 	@Test
@@ -85,7 +96,6 @@ public abstract class AbstractRDFTermFactoryTest {
 		assertNotEquals(bnode1.ntriplesString(), bnode3.ntriplesString());
 	}
 
-	
 	public abstract RDFTermFactory createFactory();
 
 	@Test
@@ -193,7 +203,8 @@ public abstract class AbstractRDFTermFactoryTest {
 	public void createLiteralDateTime() throws Exception {
 		Literal dateTime;
 		try {
-			dateTime = factory.createLiteral(
+			dateTime = factory
+					.createLiteral(
 							"2014-12-27T00:50:00T-0600",
 							factory.createIRI("http://www.w3.org/2001/XMLSchema#dateTime"));
 		} catch (UnsupportedOperationException ex) {
@@ -280,7 +291,7 @@ public abstract class AbstractRDFTermFactoryTest {
 
 		// bnode equivalence should be OK as we used the same
 		// factory and have not yet inserted Triple into a Graph
-		assertEquals(subject, triple.getSubject());		
+		assertEquals(subject, triple.getSubject());
 		assertEquals(predicate, triple.getPredicate());
 		assertEquals(object, triple.getObject());
 	}
@@ -303,7 +314,7 @@ public abstract class AbstractRDFTermFactoryTest {
 
 		// bnode equivalence should be OK as we used the same
 		// factory and have not yet inserted Triple into a Graph
-		assertEquals(subject, triple.getSubject());		
+		assertEquals(subject, triple.getSubject());
 		assertEquals(predicate, triple.getPredicate());
 		assertEquals(object, triple.getObject());
 	}
@@ -326,7 +337,7 @@ public abstract class AbstractRDFTermFactoryTest {
 
 		// bnode equivalence should be OK as we used the same
 		// factory and have not yet inserted Triple into a Graph
-		assertEquals(subject, triple.getSubject());		
+		assertEquals(subject, triple.getSubject());
 		assertEquals(predicate, triple.getPredicate());
 		assertEquals(object, triple.getObject());
 	}
@@ -337,7 +348,7 @@ public abstract class AbstractRDFTermFactoryTest {
 	}
 
 	@Test
-	public void possiblyInvalidBlankNode() throws Exception {		
+	public void possiblyInvalidBlankNode() throws Exception {
 		BlankNode withColon;
 		try {
 			withColon = factory.createBlankNode("with:colon");
@@ -345,15 +356,15 @@ public abstract class AbstractRDFTermFactoryTest {
 			Assume.assumeNoException("createBlankNode(String) not supported",
 					ex);
 			return;
-		} catch (IllegalArgumentException ex){			
+		} catch (IllegalArgumentException ex) {
 			// Good!
 			return;
 		}
 		// Factory allows :colon, which is OK as long as it's not causing an
 		// invalid ntriplesString
 		assertFalse(withColon.ntriplesString().contains("with:colon"));
-		
-		// and creating it twice gets the same ntriplesString		
+
+		// and creating it twice gets the same ntriplesString
 		assertEquals(withColon.ntriplesString(),
 				factory.createBlankNode("with:colon").ntriplesString());
 	}


Mime
View raw message