commonsrdf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ans...@apache.org
Subject [3/3] incubator-commonsrdf git commit: Test graph without homogeneous language literals, use datatyped literals or xsd:string also
Date Sat, 28 Mar 2015 05:37:35 GMT
Test graph without homogeneous language literals, use datatyped literals
or xsd:string also

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

Branch: refs/heads/master
Commit: 18d0d366054fe997ae324a06ae0c296718d6c2bd
Parents: 601b8bc
Author: Peter Ansell <p_ansell@yahoo.com>
Authored: Sat Mar 28 16:36:56 2015 +1100
Committer: Peter Ansell <p_ansell@yahoo.com>
Committed: Sat Mar 28 16:36:56 2015 +1100

----------------------------------------------------------------------
 .../commons/rdf/simple/TestWritingGraph.java    | 30 +++++++++++++++++---
 1 file changed, 26 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/18d0d366/simple/src/test/java/org/apache/commons/rdf/simple/TestWritingGraph.java
----------------------------------------------------------------------
diff --git a/simple/src/test/java/org/apache/commons/rdf/simple/TestWritingGraph.java b/simple/src/test/java/org/apache/commons/rdf/simple/TestWritingGraph.java
index 749ee95..28bf360 100644
--- a/simple/src/test/java/org/apache/commons/rdf/simple/TestWritingGraph.java
+++ b/simple/src/test/java/org/apache/commons/rdf/simple/TestWritingGraph.java
@@ -20,12 +20,15 @@ package org.apache.commons.rdf.simple;
 import java.nio.charset.Charset;
 import java.nio.file.Files;
 import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
 import java.util.Optional;
 import java.util.stream.Stream;
 
+import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
-
 import org.apache.commons.rdf.api.BlankNode;
 import org.apache.commons.rdf.api.IRI;
 
@@ -47,16 +50,35 @@ public class TestWritingGraph {
 		graph = new GraphImpl();
 		BlankNode subject = new BlankNodeImpl(Optional.of(graph), "subj");
 		IRI predicate = new IRIImpl("pred");
+		List<IRI> types = new ArrayList<>(Types.values());
+		// Ensure we don't try to create a literal with rdf:langString but
+		// without a language tag
+		types.remove(Types.RDF_LANGSTRING);
+		Collections.shuffle(types);
 		for (int i = 0; i < TRIPLES; i++) {
-			graph.add(subject, predicate, new LiteralImpl("Example " + i, "en"));
+			if (i % 5 == 0) {
+				graph.add(subject, predicate, new LiteralImpl("Example " + i,
+						"en"));
+			} else if (i % 3 == 0) {
+				graph.add(subject, predicate, new LiteralImpl("Example " + i,
+						types.get(i % types.size())));
+			} else {
+				graph.add(subject, predicate, new LiteralImpl("Example " + i));
+			}
 		}
 	}
+	
+	@AfterClass
+	public static void tearDownClass() throws Exception {
+		graph.clear();
+		graph = null;
+	}
 
 	@Test
 	public void createGraphTiming() throws Exception {
 		createGraph();
 	}
-	
+
 	@Test
 	public void countQuery() {
 		BlankNode subject = new BlankNodeImpl(Optional.of(graph), "subj");
@@ -74,7 +96,7 @@ public class TestWritingGraph {
 		} else {
 			graphFile.toFile().deleteOnExit();
 		}
-		
+
 		Stream<CharSequence> stream = graph.getTriples().unordered()
 				.map(Object::toString);
 		Files.write(graphFile, stream::iterator, Charset.forName("UTF-8"));


Mime
View raw message