commonsrdf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject [3/3] incubator-commonsrdf git commit: added NativeStoreGraphTest
Date Fri, 03 Jun 2016 13:56:33 GMT
added NativeStoreGraphTest


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

Branch: refs/heads/rdf4j
Commit: 6c5988d8047d2c414441661eb8e8791db6c79460
Parents: 1b3924c
Author: Stian Soiland-Reyes <stain@apache.org>
Authored: Fri Jun 3 14:56:18 2016 +0100
Committer: Stian Soiland-Reyes <stain@apache.org>
Committed: Fri Jun 3 14:56:18 2016 +0100

----------------------------------------------------------------------
 .../commons/rdf/rdf4j/NativeStoreGraphTest.java | 66 ++++++++++++++++++++
 1 file changed, 66 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/6c5988d8/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
new file mode 100644
index 0000000..1042f26
--- /dev/null
+++ b/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/NativeStoreGraphTest.java
@@ -0,0 +1,66 @@
+/**
+ * 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.rdf4j;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+
+import org.apache.commons.rdf.api.AbstractGraphTest;
+import org.apache.commons.rdf.api.RDFTermFactory;
+import org.eclipse.rdf4j.model.ValueFactory;
+import org.eclipse.rdf4j.repository.Repository;
+import org.eclipse.rdf4j.repository.sail.SailRepository;
+import org.eclipse.rdf4j.sail.Sail;
+import org.eclipse.rdf4j.sail.memory.model.MemValueFactory;
+import org.eclipse.rdf4j.sail.nativerdf.NativeStore;
+
+
+public class NativeStoreGraphTest extends AbstractGraphTest {
+
+	public static final class NativeStoreFactory extends RDF4JTermFactory {
+		NativeStoreFactory() {
+			super(new MemValueFactory());
+		}
+		@Override
+		public RDF4JGraph createGraph() {
+			return asRDFTermGraph(createRepository());
+		}
+	}
+
+	public static Repository createRepository() {
+		Path tempDir;
+		try {
+			tempDir = Files.createTempDirectory("test-commonsrdf-rdf4j");
+		} catch (IOException e) {
+			throw new RuntimeException(e);
+		}
+		Sail sail = new NativeStore(tempDir.toFile());
+		SailRepository repository = new SailRepository(sail);
+		repository.initialize();
+		return repository;
+	}
+	
+	@Override
+	public RDFTermFactory createFactory() {
+		// FIXME: This valueFactory will be backed by the wrong temporary folder!
+		ValueFactory valueFactory = createRepository().getValueFactory();
+		return new RDF4JTermFactory(valueFactory);
+	}
+
+}


Mime
View raw message