You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@marmotta.apache.org by an...@apache.org on 2013/10/01 01:48:05 UTC
[13/51] [partial] Revert "Merge branch 'master' of
https://git-wip-us.apache.org/repos/asf/incubator-marmotta"
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/4aa87dbe/libraries/kiwi/kiwi-tripletable/src/test/java/org/apache/marmotta/kiwi/model/caching/TripleTableTest.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-tripletable/src/test/java/org/apache/marmotta/kiwi/model/caching/TripleTableTest.java b/libraries/kiwi/kiwi-tripletable/src/test/java/org/apache/marmotta/kiwi/model/caching/TripleTableTest.java
deleted file mode 100644
index 98858bc..0000000
--- a/libraries/kiwi/kiwi-tripletable/src/test/java/org/apache/marmotta/kiwi/model/caching/TripleTableTest.java
+++ /dev/null
@@ -1,127 +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.marmotta.kiwi.model.caching;
-
-import org.apache.commons.lang3.RandomStringUtils;
-import org.junit.Test;
-import org.openrdf.model.Literal;
-import org.openrdf.model.Statement;
-import org.openrdf.model.URI;
-import org.openrdf.model.impl.LiteralImpl;
-import org.openrdf.model.impl.StatementImpl;
-import org.openrdf.model.impl.URIImpl;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * Test cases for triple tables.
- *
- * @author Sebastian Schaffert (sschaffert@apache.org)
- */
-public class TripleTableTest {
-
-
-
- @Test
- public void testListTriples() {
- URI subject1 = new URIImpl("http://localhost/"+ RandomStringUtils.randomAlphanumeric(8));
- URI subject2 = new URIImpl("http://localhost/"+ RandomStringUtils.randomAlphanumeric(8));
- URI predicate1 = new URIImpl("http://localhost/"+ RandomStringUtils.randomAlphanumeric(8));
- URI predicate2 = new URIImpl("http://localhost/"+ RandomStringUtils.randomAlphanumeric(8));
- Literal object1 = new LiteralImpl("http://localhost/"+ RandomStringUtils.random(40));
- Literal object2 = new LiteralImpl("http://localhost/"+ RandomStringUtils.random(40));
-
- Statement stmt1 = new StatementImpl(subject1,predicate1,object1);
- Statement stmt2 = new StatementImpl(subject1,predicate1,object2);
- Statement stmt3 = new StatementImpl(subject1,predicate2,object1);
- Statement stmt4 = new StatementImpl(subject1,predicate2,object2);
- Statement stmt5 = new StatementImpl(subject2,predicate1,object1);
- Statement stmt6 = new StatementImpl(subject2,predicate1,object2);
- Statement stmt7 = new StatementImpl(subject2,predicate2,object1);
- Statement stmt8 = new StatementImpl(subject2,predicate2,object2);
-
- TripleTable<Statement> table = new TripleTable<>();
- table.add(stmt1);
- table.add(stmt2);
- table.add(stmt3);
- table.add(stmt4);
- table.add(stmt5);
- table.add(stmt6);
- table.add(stmt7);
- //table.add(stmt8);
-
- // tests
-
- // 1. test existence and non-existence of a triple
- assertEquals(1, table.listTriples(subject2,predicate2,object1,null, true).size());
- assertEquals(0, table.listTriples(subject2,predicate2,object2,null, true).size());
-
- // 2. test listing with wildcards
- assertEquals(7, table.listTriples(null,null,null,null, true).size());
- assertEquals(4, table.listTriples(subject1,null,null,null, true).size());
- assertEquals(3, table.listTriples(subject2,null,null,null, true).size());
- assertEquals(4, table.listTriples(null,predicate1,null,null, true).size());
- assertEquals(3, table.listTriples(null,predicate2,null,null, true).size());
- assertEquals(4, table.listTriples(null,null,object1,null, true).size());
- assertEquals(3, table.listTriples(null,null,object2,null, true).size());
- assertEquals(2, table.listTriples(subject1,predicate1,null,null, true).size());
- assertEquals(1, table.listTriples(subject2,predicate2,null,null, true).size());
- }
-
- @Test
- public void testRemoveTriples() {
- URI subject1 = new URIImpl("http://localhost/"+ RandomStringUtils.randomAlphanumeric(8));
- URI subject2 = new URIImpl("http://localhost/"+ RandomStringUtils.randomAlphanumeric(8));
- URI predicate1 = new URIImpl("http://localhost/"+ RandomStringUtils.randomAlphanumeric(8));
- URI predicate2 = new URIImpl("http://localhost/"+ RandomStringUtils.randomAlphanumeric(8));
- Literal object1 = new LiteralImpl("http://localhost/"+ RandomStringUtils.random(40));
- Literal object2 = new LiteralImpl("http://localhost/"+ RandomStringUtils.random(40));
-
- Statement stmt1 = new StatementImpl(subject1,predicate1,object1);
- Statement stmt2 = new StatementImpl(subject1,predicate1,object2);
- Statement stmt3 = new StatementImpl(subject1,predicate2,object1);
- Statement stmt4 = new StatementImpl(subject1,predicate2,object2);
- Statement stmt5 = new StatementImpl(subject2,predicate1,object1);
- Statement stmt6 = new StatementImpl(subject2,predicate1,object2);
- Statement stmt7 = new StatementImpl(subject2,predicate2,object1);
- Statement stmt8 = new StatementImpl(subject2,predicate2,object2);
-
- TripleTable<Statement> table = new TripleTable<>();
- table.add(stmt1);
- table.add(stmt2);
- table.add(stmt3);
- table.add(stmt4);
- table.add(stmt5);
- table.add(stmt6);
- table.add(stmt7);
- table.add(stmt8);
-
- // tests
-
- // 1. test existence and non-existence of a triple
- assertEquals(1, table.listTriples(subject2,predicate2,object1,null, true).size());
- assertEquals(1, table.listTriples(subject2,predicate2,object2,null, true).size());
-
-
- table.remove(stmt8);
-
- assertEquals(1, table.listTriples(subject2,predicate2,object1,null, true).size());
- assertEquals(0, table.listTriples(subject2,predicate2,object2,null, true).size());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/4aa87dbe/libraries/kiwi/kiwi-versioning/pom.xml
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-versioning/pom.xml b/libraries/kiwi/kiwi-versioning/pom.xml
index ebed513..3d37f81 100644
--- a/libraries/kiwi/kiwi-versioning/pom.xml
+++ b/libraries/kiwi/kiwi-versioning/pom.xml
@@ -21,7 +21,7 @@
<parent>
<groupId>org.apache.marmotta</groupId>
<artifactId>kiwi-parent</artifactId>
- <version>3.2.0-incubating-SNAPSHOT</version>
+ <version>3.1.0-incubating-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
@@ -74,8 +74,8 @@
<artifactId>guava</artifactId>
</dependency>
<dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-lang3</artifactId>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
</dependency>
<dependency>
<groupId>org.apache.marmotta</groupId>
@@ -129,7 +129,7 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.postgresql</groupId>
+ <groupId>org.jumpmind.symmetric.jdbc</groupId>
<artifactId>postgresql</artifactId>
<scope>test</scope>
</dependency>
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/4aa87dbe/libraries/kiwi/kiwi-versioning/src/main/java/org/apache/marmotta/kiwi/versioning/persistence/KiWiVersioningConnection.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-versioning/src/main/java/org/apache/marmotta/kiwi/versioning/persistence/KiWiVersioningConnection.java b/libraries/kiwi/kiwi-versioning/src/main/java/org/apache/marmotta/kiwi/versioning/persistence/KiWiVersioningConnection.java
index 2ef8946..054cf20 100644
--- a/libraries/kiwi/kiwi-versioning/src/main/java/org/apache/marmotta/kiwi/versioning/persistence/KiWiVersioningConnection.java
+++ b/libraries/kiwi/kiwi-versioning/src/main/java/org/apache/marmotta/kiwi/versioning/persistence/KiWiVersioningConnection.java
@@ -17,7 +17,6 @@
*/
package org.apache.marmotta.kiwi.versioning.persistence;
-import com.google.common.base.Preconditions;
import info.aduna.iteration.CloseableIteration;
import info.aduna.iteration.EmptyIteration;
import info.aduna.iteration.ExceptionConvertingIteration;
@@ -131,65 +130,6 @@ public class KiWiVersioningConnection extends KiWiConnection {
}
/**
- * Remove the version with the id passed as argument, including all references to added and removed triples. The
- * triples themselves are not deleted immediately, we let the garbage collector carry this out periodically.
- * @param id
- * @throws SQLException
- */
- public void removeVersion(Long id) throws SQLException {
- Preconditions.checkNotNull(id);
- Preconditions.checkArgument(id > 0);
-
- requireJDBCConnection();
-
- PreparedStatement removeAdded = getPreparedStatement("delete.version_added");
- removeAdded.clearParameters();
- removeAdded.setLong(1, id);
- removeAdded.executeUpdate();
-
- PreparedStatement removeRemoved = getPreparedStatement("delete.version_removed");
- removeRemoved.clearParameters();
- removeRemoved.setLong(1, id);
- removeRemoved.executeUpdate();
-
- PreparedStatement removeVersion = getPreparedStatement("delete.version");
- removeVersion.clearParameters();
- removeVersion.setLong(1, id);
- removeVersion.executeUpdate();
-
- }
-
- /**
- * Remove all versions until the date given as argument. Iterates over all versions and deletes them individually.
- * Entries in join tables (added/removed triples) are also deleted, the triples themselves not. Deleted triples
- * without version will later be cleaned up by the garbage collector
- * @param until date until when to delete versions
- * @throws SQLException
- */
- public void removeVersions(Date until) throws SQLException {
- removeVersions(new Date(0), until);
- }
-
-
- /**
- * Remove all versions in the given time interval. Iterates over all versions and deletes them individually.
- * Entries in join tables (added/removed triples) are also deleted, the triples themselves not. Deleted triples
- * without version will later be cleaned up by the garbage collector
- * @param from date after which versions will be deleted
- * @param to date before which versions will be deleted
- * @throws SQLException
- */
- public void removeVersions(Date from, Date to) throws SQLException {
- CloseableIteration<Version, SQLException> it = listVersionsInternal(from,to);
- while(it.hasNext()) {
- Version next = it.next();
- removeVersion(next.getId());
- }
- }
-
-
-
- /**
* Retrieve a version by its id. If the version does not exist, returns null
*
* @param id
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/4aa87dbe/libraries/kiwi/kiwi-versioning/src/main/java/org/apache/marmotta/kiwi/versioning/persistence/KiWiVersioningPersistence.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-versioning/src/main/java/org/apache/marmotta/kiwi/versioning/persistence/KiWiVersioningPersistence.java b/libraries/kiwi/kiwi-versioning/src/main/java/org/apache/marmotta/kiwi/versioning/persistence/KiWiVersioningPersistence.java
index a3bb6a6..797c58c 100644
--- a/libraries/kiwi/kiwi-versioning/src/main/java/org/apache/marmotta/kiwi/versioning/persistence/KiWiVersioningPersistence.java
+++ b/libraries/kiwi/kiwi-versioning/src/main/java/org/apache/marmotta/kiwi/versioning/persistence/KiWiVersioningPersistence.java
@@ -46,6 +46,10 @@ public class KiWiVersioningPersistence {
public KiWiVersioningPersistence(KiWiPersistence persistence) {
this.persistence = persistence;
+
+ persistence.addNodeTableDependency("versions", "creator");
+ persistence.addTripleTableDependency("versions_added","triple_id");
+ persistence.addTripleTableDependency("versions_removed","triple_id");
}
/**
@@ -54,10 +58,6 @@ public class KiWiVersioningPersistence {
*/
public void initDatabase() throws SQLException {
persistence.initDatabase("versioning", new String[] {"versions", "versions_added", "versions_removed"});
-
- persistence.addNodeTableDependency("versions", "creator");
- persistence.addTripleTableDependency("versions_added","triple_id");
- persistence.addTripleTableDependency("versions_removed","triple_id");
}
/**
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/4aa87dbe/libraries/kiwi/kiwi-versioning/src/main/java/org/apache/marmotta/kiwi/versioning/sail/KiWiVersioningSail.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-versioning/src/main/java/org/apache/marmotta/kiwi/versioning/sail/KiWiVersioningSail.java b/libraries/kiwi/kiwi-versioning/src/main/java/org/apache/marmotta/kiwi/versioning/sail/KiWiVersioningSail.java
index 84f448b..91de399 100644
--- a/libraries/kiwi/kiwi-versioning/src/main/java/org/apache/marmotta/kiwi/versioning/sail/KiWiVersioningSail.java
+++ b/libraries/kiwi/kiwi-versioning/src/main/java/org/apache/marmotta/kiwi/versioning/sail/KiWiVersioningSail.java
@@ -34,8 +34,6 @@ import org.openrdf.model.Statement;
import org.openrdf.model.URI;
import org.openrdf.repository.RepositoryException;
import org.openrdf.repository.RepositoryResult;
-import org.openrdf.repository.sail.SailRepositoryConnection;
-import org.openrdf.sail.SailConnection;
import org.openrdf.sail.SailException;
import org.openrdf.sail.StackableSail;
import org.slf4j.Logger;
@@ -74,33 +72,33 @@ public class KiWiVersioningSail extends TransactionalSailWrapper implements Tran
private SesameFilter<Statement> filter;
- /**
- * Build a new {@link KiWiVersioningSail} based on the provided parent
- * {@link TransactionalSail}.
- *
- * @param parent
- * the {@link TransactionalSail} to base the
- * {@link KiWiVersioningSail} on.
- */
+ /**
+ * Build a new {@link KiWiVersioningSail} based on the provided parent
+ * {@link TransactionalSail}.
+ *
+ * @param parent
+ * the {@link TransactionalSail} to base the
+ * {@link KiWiVersioningSail} on.
+ */
public KiWiVersioningSail(TransactionalSail parent) {
this(parent,new AlwaysTrueFilter<Statement>());
}
- /**
- * Build a new selective {@link KiWiVersioningSail} based on the provided
- * parent {@link TransactionalSail}. Only {@link Statement}s that are
- * accepted by the filter are included in versioning.
- *
- * @param parent
- * the {@link TransactionalSail} to base the
- * {@link KiWiVersioningSail} on.
- * @param filter
- * a {@link SesameFilter} to filter out {@link Statement}s that
- * should not be versioned. Only a {@link Statement} that is
- * accepted by this filter will be versioned.
- *
- * @see SesameFilter#accept(Object)
- */
+ /**
+ * Build a new selective {@link KiWiVersioningSail} based on the provided
+ * parent {@link TransactionalSail}. Only {@link Statement}s that are
+ * accepted by the filter are included in versioning.
+ *
+ * @param parent
+ * the {@link TransactionalSail} to base the
+ * {@link KiWiVersioningSail} on.
+ * @param filter
+ * a {@link SesameFilter} to filter out {@link Statement}s that
+ * should not be versioned. Only a {@link Statement} that is
+ * accepted by this filter will be versioned.
+ *
+ * @see SesameFilter#accept(Object)
+ */
public KiWiVersioningSail(TransactionalSail parent, SesameFilter<Statement> filter) {
super(parent);
this.persistence = new KiWiVersioningPersistence(getBaseStore().getPersistence());
@@ -318,80 +316,12 @@ public class KiWiVersioningSail extends TransactionalSailWrapper implements Tran
}
}
-
- /**
- * Remove the version with the id passed as argument, including all references to added and removed triples. The
- * triples themselves are not deleted immediately, we let the garbage collector carry this out periodically.
- * @param id the database ID of the version (see {@link Version#getId()})
- * @throws SailException
- */
- public void removeVersion(Long id) throws SailException {
- try {
- final KiWiVersioningConnection connection = persistence.getConnection();
- try {
- connection.removeVersion(id);
- connection.commit();
- } finally {
- connection.close();
- }
-
- } catch(SQLException ex) {
- throw new SailException("database error while listing versions",ex);
- }
- }
-
- /**
- * Remove all versions until the date given as argument. Iterates over all versions and deletes them individually.
- * Entries in join tables (added/removed triples) are also deleted, the triples themselves not. Deleted triples
- * without version will later be cleaned up by the garbage collector
- * @param until date until when to delete versions
- * @throws SailException
- */
- public void removeVersions(Date until) throws SailException {
- try {
- final KiWiVersioningConnection connection = persistence.getConnection();
- try {
- connection.removeVersions(until);
- connection.commit();
- } finally {
- connection.close();
- }
-
- } catch(SQLException ex) {
- throw new SailException("database error while listing versions",ex);
- }
- }
-
-
- /**
- * Remove all versions in the given time interval. Iterates over all versions and deletes them individually.
- * Entries in join tables (added/removed triples) are also deleted, the triples themselves not. Deleted triples
- * without version will later be cleaned up by the garbage collector
- * @param from date after which versions will be deleted
- * @param to date before which versions will be deleted
- * @throws SailException
- */
- public void removeVersions(Date from, Date to) throws SailException {
- try {
- final KiWiVersioningConnection connection = persistence.getConnection();
- try {
- connection.removeVersions(from, to);
- connection.commit();
- } finally {
- connection.close();
- }
-
- } catch(SQLException ex) {
- throw new SailException("database error while listing versions",ex);
- }
- }
-
/**
* Return the version that is the most recent version for a resource given a reference date. The method will either
* return the version that was current for the resource at the given date or return null in case such a version
* does not exist (e.g. before the resource was created).
*
- * @param r the resource for which to find a version
+ * @param resource the resource for which to find a version
* @param date the reference date
* @return the latest version of the resource at the given date, or null if such a version does not exist
* @throws SQLException
@@ -475,32 +405,6 @@ public class KiWiVersioningSail extends TransactionalSailWrapper implements Tran
}
}
- /**
- * Revert (undo) the version given as argument. This method creates a new transaction, adds all triples
- * that were deleted in the old version, removes all triples that were added in the old version, and commits
- * the transaction, effectively creating a new (reverted) version.
- *
- * @param version the version to revert
- * @throws SailException in case reverting the version failed
- */
- public void revertVersion(Version version) throws SailException {
- SailConnection con = getConnection();
- try {
- con.begin();
-
- for(Statement stmt : version.getAddedTriples()) {
- con.removeStatements(stmt.getSubject(), stmt.getPredicate(), stmt.getObject(), stmt.getContext());
- }
-
- for(Statement stmt : version.getRemovedTriples()) {
- con.addStatement(stmt.getSubject(), stmt.getPredicate(), stmt.getObject(), stmt.getContext());
- }
-
- con.commit();
- } finally {
- con.close();
- }
- }
@Override
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/4aa87dbe/libraries/kiwi/kiwi-versioning/src/main/resources/org/apache/marmotta/kiwi/persistence/h2/statements.properties
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-versioning/src/main/resources/org/apache/marmotta/kiwi/persistence/h2/statements.properties b/libraries/kiwi/kiwi-versioning/src/main/resources/org/apache/marmotta/kiwi/persistence/h2/statements.properties
index e5b1ae3..1001040 100644
--- a/libraries/kiwi/kiwi-versioning/src/main/resources/org/apache/marmotta/kiwi/persistence/h2/statements.properties
+++ b/libraries/kiwi/kiwi-versioning/src/main/resources/org/apache/marmotta/kiwi/persistence/h2/statements.properties
@@ -48,4 +48,4 @@ store.version_removed = INSERT INTO versions_removed (version_id,triple_id) VALU
delete.version_added = DELETE FROM versions_added WHERE version_id = ?
delete.version_removed = DELETE FROM versions_removed WHERE version_id = ?
-delete.version = DELETE FROM versions WHERE id = ?
\ No newline at end of file
+delete.version = DELETE FROM verions WHERE id = ?
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/4aa87dbe/libraries/kiwi/kiwi-versioning/src/main/resources/org/apache/marmotta/kiwi/persistence/mysql/statements.properties
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-versioning/src/main/resources/org/apache/marmotta/kiwi/persistence/mysql/statements.properties b/libraries/kiwi/kiwi-versioning/src/main/resources/org/apache/marmotta/kiwi/persistence/mysql/statements.properties
index 47d7f6a..65a39a2 100644
--- a/libraries/kiwi/kiwi-versioning/src/main/resources/org/apache/marmotta/kiwi/persistence/mysql/statements.properties
+++ b/libraries/kiwi/kiwi-versioning/src/main/resources/org/apache/marmotta/kiwi/persistence/mysql/statements.properties
@@ -19,7 +19,6 @@
# get sequence numbers
seq.versions.prep = UPDATE seq_versions SET id=LAST_INSERT_ID(id+1);
seq.versions = SELECT LAST_INSERT_ID();
-seq.versions.set = UPDATE seq_versions SET id=?;
load.version_by_id = SELECT id,creator,createdAt FROM versions WHERE id = ?
load.version_between = SELECT id,creator,createdAt FROM versions WHERE createdAt > ? AND createdAt <= ? ORDER BY createdAt ASC
@@ -50,4 +49,4 @@ store.version_removed = INSERT INTO versions_removed (version_id,triple_id) VALU
delete.version_added = DELETE FROM versions_added WHERE version_id = ?
delete.version_removed = DELETE FROM versions_removed WHERE version_id = ?
-delete.version = DELETE FROM versions WHERE id = ?
\ No newline at end of file
+delete.version = DELETE FROM verions WHERE id = ?
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/4aa87dbe/libraries/kiwi/kiwi-versioning/src/main/resources/org/apache/marmotta/kiwi/persistence/pgsql/statements.properties
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-versioning/src/main/resources/org/apache/marmotta/kiwi/persistence/pgsql/statements.properties b/libraries/kiwi/kiwi-versioning/src/main/resources/org/apache/marmotta/kiwi/persistence/pgsql/statements.properties
index 441adfc..442fb02 100644
--- a/libraries/kiwi/kiwi-versioning/src/main/resources/org/apache/marmotta/kiwi/persistence/pgsql/statements.properties
+++ b/libraries/kiwi/kiwi-versioning/src/main/resources/org/apache/marmotta/kiwi/persistence/pgsql/statements.properties
@@ -18,7 +18,6 @@
# get sequence numbers
seq.versions = SELECT nextval('seq_versions')
-seq.versions.set = SELECT setval('seq_versions',?)
load.version_by_id = SELECT id,creator,createdAt FROM versions WHERE id = ?
load.version_between = SELECT id,creator,createdAt FROM versions WHERE createdAt >= ? AND createdAt <= ? ORDER BY createdAt ASC
@@ -50,7 +49,7 @@ store.version_removed = INSERT INTO versions_removed (version_id,triple_id) VALU
delete.version_added = DELETE FROM versions_added WHERE version_id = ?
delete.version_removed = DELETE FROM versions_removed WHERE version_id = ?
-delete.version = DELETE FROM versions WHERE id = ?
+delete.version = DELETE FROM verions WHERE id = ?
query.snapshot_size = SELECT count(*) FROM triples WHERE createdAt <= ? AND (deleted = false OR deletedAt > ?)
query.snapshot_size_ctx = SELECT count(*) FROM triples WHERE context = ? AND createdAt <= ? AND (deleted = false OR deletedAt > ?)
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/4aa87dbe/libraries/kiwi/kiwi-versioning/src/test/java/org/apache/marmotta/kiwi/versioning/test/SnapshotRepositoryTest.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-versioning/src/test/java/org/apache/marmotta/kiwi/versioning/test/SnapshotRepositoryTest.java b/libraries/kiwi/kiwi-versioning/src/test/java/org/apache/marmotta/kiwi/versioning/test/SnapshotRepositoryTest.java
index 0268db5..7cc52e3 100644
--- a/libraries/kiwi/kiwi-versioning/src/test/java/org/apache/marmotta/kiwi/versioning/test/SnapshotRepositoryTest.java
+++ b/libraries/kiwi/kiwi-versioning/src/test/java/org/apache/marmotta/kiwi/versioning/test/SnapshotRepositoryTest.java
@@ -17,26 +17,24 @@
*/
package org.apache.marmotta.kiwi.versioning.test;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.junit.Assume.assumeThat;
-import info.aduna.iteration.Iterations;
-
-import java.io.InputStream;
-import java.sql.SQLException;
-import java.util.Date;
-import java.util.List;
-
-import org.apache.marmotta.kiwi.config.KiWiConfiguration;
+import org.apache.marmotta.kiwi.persistence.KiWiDialect;
+import org.apache.marmotta.kiwi.persistence.h2.H2Dialect;
+import org.apache.marmotta.kiwi.persistence.mysql.MySQLDialect;
+import org.apache.marmotta.kiwi.persistence.pgsql.PostgreSQLDialect;
import org.apache.marmotta.kiwi.sail.KiWiStore;
-import org.apache.marmotta.kiwi.test.junit.KiWiDatabaseRunner;
+import org.apache.marmotta.kiwi.test.helper.DBConnectionChecker;
import org.apache.marmotta.kiwi.transactions.sail.KiWiTransactionalSail;
import org.apache.marmotta.kiwi.versioning.repository.SnapshotRepository;
import org.apache.marmotta.kiwi.versioning.sail.KiWiVersioningSail;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.TestWatcher;
+import org.junit.runner.Description;
import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
import org.openrdf.model.Statement;
import org.openrdf.query.BooleanQuery;
import org.openrdf.query.QueryLanguage;
@@ -47,17 +45,84 @@ import org.openrdf.rio.RDFFormat;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.io.InputStream;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.junit.Assume.assumeThat;
+
/**
- * This test verifies the snapshot functionality, i.e. if the snapshot connection works properly.
- *
+ * This test verifies the snapshot functionality, i.e. if the snapshot connection works properly. It will try running
+ * over all available databases. Except for in-memory databases like
+ * H2 or Derby, database URLs must be passed as system property, or otherwise the test is skipped for this database.
+ * Available system properties:
+ * <ul>
+ * <li>PostgreSQL:
+ * <ul>
+ * <li>postgresql.url, e.g. jdbc:postgresql://localhost:5433/kiwitest?prepareThreshold=3</li>
+ * <li>postgresql.user (default: lmf)</li>
+ * <li>postgresql.pass (default: lmf)</li>
+ * </ul>
+ * </li>
+ * <li>MySQL:
+ * <ul>
+ * <li>mysql.url, e.g. jdbc:mysql://localhost:3306/kiwitest?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull</li>
+ * <li>mysql.user (default: lmf)</li>
+ * <li>mysql.pass (default: lmf</li>
+ * </ul>
+ * </li>
+ * <li>H2:
+ * <ul>
+ * <li>h2.url, e.g. jdbc:h2:mem;MVCC=true;DB_CLOSE_ON_EXIT=FALSE;DB_CLOSE_DELAY=10</li>
+ * <li>h2.user (default: lmf)</li>
+ * <li>h2.pass (default: lmf</li>
+ * </ul>
+ * </li>
+ * </ul>
+ * <p/>
* @see org.apache.marmotta.kiwi.versioning.repository.SnapshotRepositoryConnection
* @see org.apache.marmotta.kiwi.versioning.repository.SnapshotRepository
- * @author Sebastian Schaffert (sschaffert@apache.org)
+ * <p/>
+ * Author: Sebastian Schaffert
*/
-@RunWith(KiWiDatabaseRunner.class)
+@RunWith(Parameterized.class)
public class SnapshotRepositoryTest {
-
+ /**
+ * Return database configurations if the appropriate parameters have been set.
+ *
+ * @return an array (database name, url, user, password)
+ */
+ @Parameterized.Parameters(name="Database Test {index}: {0} at {1}")
+ public static Iterable<Object[]> databases() {
+ String[] databases = {"H2", "PostgreSQL", "MySQL"};
+
+ List<Object[]> result = new ArrayList<Object[]>(databases.length);
+ for(String database : databases) {
+ if(System.getProperty(database.toLowerCase()+".url") != null) {
+ result.add(new Object[] {
+ database,
+ System.getProperty(database.toLowerCase()+".url"),
+ System.getProperty(database.toLowerCase()+".user","lmf"),
+ System.getProperty(database.toLowerCase()+".pass","lmf")
+ });
+ }
+ }
+ return result;
+ }
+
+
+ private KiWiDialect dialect;
+
+ private String jdbcUrl;
+
+ private String jdbcUser;
+
+ private String jdbcPass;
+
private KiWiStore store;
private KiWiTransactionalSail tsail;
@@ -66,16 +131,26 @@ public class SnapshotRepositoryTest {
private SnapshotRepository repository;
- private final KiWiConfiguration dbConfig;
-
- public SnapshotRepositoryTest(KiWiConfiguration dbConfig) {
- this.dbConfig = dbConfig;
+ public SnapshotRepositoryTest(String database, String jdbcUrl, String jdbcUser, String jdbcPass) {
+ this.jdbcPass = jdbcPass;
+ this.jdbcUrl = jdbcUrl;
+ this.jdbcUser = jdbcUser;
+
+ if("H2".equals(database)) {
+ this.dialect = new H2Dialect();
+ } else if("MySQL".equals(database)) {
+ this.dialect = new MySQLDialect();
+ } else if("PostgreSQL".equals(database)) {
+ this.dialect = new PostgreSQLDialect();
+ }
+
+ DBConnectionChecker.checkDatabaseAvailability(jdbcUrl, jdbcUser, jdbcPass, dialect);
}
@Before
public void initDatabase() throws RepositoryException {
- store = new KiWiStore(dbConfig);
+ store = new KiWiStore("test",jdbcUrl,jdbcUser,jdbcPass,dialect, "http://localhost/context/default", "http://localhost/context/inferred");
tsail = new KiWiTransactionalSail(store);
vsail = new KiWiVersioningSail(tsail);
repository = new SnapshotRepository(vsail);
@@ -92,6 +167,17 @@ public class SnapshotRepositoryTest {
final Logger logger =
LoggerFactory.getLogger(this.getClass());
+ @Rule
+ public TestWatcher watchman = new TestWatcher() {
+ /**
+ * Invoked when a test is about to start
+ */
+ @Override
+ protected void starting(Description description) {
+ logger.info("{} being run...", description.getMethodName());
+ }
+ };
+
@Test
public void testSnapshotConnection() throws Exception {
@@ -292,6 +378,17 @@ public class SnapshotRepositoryTest {
* @return
*/
public static <E> List<E> asList(RepositoryResult<E> result) throws RepositoryException {
- return Iterations.asList(result);
+ ArrayList<E> collection = new ArrayList<E>();
+ try {
+ while (result.hasNext()) {
+ collection.add(result.next());
+ }
+
+ return collection;
+ }
+ finally {
+ result.close();
+ }
}
+
}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/4aa87dbe/libraries/kiwi/kiwi-versioning/src/test/java/org/apache/marmotta/kiwi/versioning/test/VersioningPersistenceTest.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-versioning/src/test/java/org/apache/marmotta/kiwi/versioning/test/VersioningPersistenceTest.java b/libraries/kiwi/kiwi-versioning/src/test/java/org/apache/marmotta/kiwi/versioning/test/VersioningPersistenceTest.java
index 6697704..9d723f3 100644
--- a/libraries/kiwi/kiwi-versioning/src/test/java/org/apache/marmotta/kiwi/versioning/test/VersioningPersistenceTest.java
+++ b/libraries/kiwi/kiwi-versioning/src/test/java/org/apache/marmotta/kiwi/versioning/test/VersioningPersistenceTest.java
@@ -17,27 +17,34 @@
*/
package org.apache.marmotta.kiwi.versioning.test;
-import info.aduna.iteration.Iterations;
-import org.apache.commons.lang3.RandomStringUtils;
-import org.apache.marmotta.kiwi.config.KiWiConfiguration;
+import org.apache.commons.lang.RandomStringUtils;
import org.apache.marmotta.kiwi.model.rdf.KiWiStringLiteral;
import org.apache.marmotta.kiwi.model.rdf.KiWiTriple;
import org.apache.marmotta.kiwi.model.rdf.KiWiUriResource;
import org.apache.marmotta.kiwi.persistence.KiWiConnection;
+import org.apache.marmotta.kiwi.persistence.KiWiDialect;
import org.apache.marmotta.kiwi.persistence.KiWiPersistence;
-import org.apache.marmotta.kiwi.test.junit.KiWiDatabaseRunner;
+import org.apache.marmotta.kiwi.persistence.h2.H2Dialect;
+import org.apache.marmotta.kiwi.persistence.mysql.MySQLDialect;
+import org.apache.marmotta.kiwi.persistence.pgsql.PostgreSQLDialect;
+import org.apache.marmotta.kiwi.test.helper.DBConnectionChecker;
import org.apache.marmotta.kiwi.versioning.model.Version;
import org.apache.marmotta.kiwi.versioning.persistence.KiWiVersioningConnection;
import org.apache.marmotta.kiwi.versioning.persistence.KiWiVersioningPersistence;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.TestWatcher;
+import org.junit.runner.Description;
import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.sql.SQLException;
+import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -45,25 +52,95 @@ import static org.hamcrest.Matchers.hasItems;
/**
* This test checks if the database persistence for the versioning functionality works properly.
- *
- * @author Sebastian Schaffert (sschaffert@apache.org)
+ * It will try running over all available databases. Except for in-memory databases like
+ * H2 or Derby, database URLs must be passed as system property, or otherwise the test is skipped for this database.
+ * Available system properties:
+ * <ul>
+ * <li>PostgreSQL:
+ * <ul>
+ * <li>postgresql.url, e.g. jdbc:postgresql://localhost:5433/kiwitest?prepareThreshold=3</li>
+ * <li>postgresql.user (default: lmf)</li>
+ * <li>postgresql.pass (default: lmf)</li>
+ * </ul>
+ * </li>
+ * <li>MySQL:
+ * <ul>
+ * <li>mysql.url, e.g. jdbc:mysql://localhost:3306/kiwitest?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull</li>
+ * <li>mysql.user (default: lmf)</li>
+ * <li>mysql.pass (default: lmf</li>
+ * </ul>
+ * </li>
+ * <li>H2:
+ * <ul>
+ * <li>h2.url, e.g. jdbc:h2:mem;MVCC=true;DB_CLOSE_ON_EXIT=FALSE;DB_CLOSE_DELAY=10</li>
+ * <li>h2.user (default: lmf)</li>
+ * <li>h2.pass (default: lmf</li>
+ * </ul>
+ * </li>
+ * </ul>
+ *
+ * <p/>
+ * Author: Sebastian Schaffert
*/
-@RunWith(KiWiDatabaseRunner.class)
+@RunWith(Parameterized.class)
public class VersioningPersistenceTest {
+
+ /**
+ * Return database configurations if the appropriate parameters have been set.
+ *
+ * @return an array (database name, url, user, password)
+ */
+ @Parameterized.Parameters(name="Database Test {index}: {0} at {1}")
+ public static Iterable<Object[]> databases() {
+ String[] databases = {"H2", "PostgreSQL", "MySQL"};
+
+ List<Object[]> result = new ArrayList<Object[]>(databases.length);
+ for(String database : databases) {
+ if(System.getProperty(database.toLowerCase()+".url") != null) {
+ result.add(new Object[] {
+ database,
+ System.getProperty(database.toLowerCase()+".url"),
+ System.getProperty(database.toLowerCase()+".user","lmf"),
+ System.getProperty(database.toLowerCase()+".pass","lmf")
+ });
+ }
+ }
+ return result;
+ }
+
+
+ private KiWiDialect dialect;
+
+ private String jdbcUrl;
+
+ private String jdbcUser;
+
+ private String jdbcPass;
+
private KiWiPersistence persistence;
private KiWiVersioningPersistence vpersistence;
- private final KiWiConfiguration dbConfig;
- public VersioningPersistenceTest(KiWiConfiguration dbConfig) {
- this.dbConfig = dbConfig;
+ public VersioningPersistenceTest(String database, String jdbcUrl, String jdbcUser, String jdbcPass) {
+ this.jdbcPass = jdbcPass;
+ this.jdbcUrl = jdbcUrl;
+ this.jdbcUser = jdbcUser;
+
+ if("H2".equals(database)) {
+ this.dialect = new H2Dialect();
+ } else if("MySQL".equals(database)) {
+ this.dialect = new MySQLDialect();
+ } else if("PostgreSQL".equals(database)) {
+ this.dialect = new PostgreSQLDialect();
+ }
+
+ DBConnectionChecker.checkDatabaseAvailability(jdbcUrl, jdbcUser, jdbcPass, dialect);
}
@Before
public void initDatabase() throws SQLException {
- persistence = new KiWiPersistence(dbConfig);
- persistence.initialise();
+ persistence = new KiWiPersistence("test",jdbcUrl,jdbcUser,jdbcPass,dialect);
persistence.initDatabase();
vpersistence = new KiWiVersioningPersistence(persistence);
@@ -81,13 +158,24 @@ public class VersioningPersistenceTest {
final Logger logger =
LoggerFactory.getLogger(this.getClass());
+ @Rule
+ public TestWatcher watchman = new TestWatcher() {
+ /**
+ * Invoked when a test is about to start
+ */
+ @Override
+ protected void starting(Description description) {
+ logger.info("{} being run...", description.getMethodName());
+ }
+ };
+
@Test
public void testTablesCreateDrop() throws Exception {
// test if database exists and has a version
KiWiConnection connection = vpersistence.getConnection();
try {
Assert.assertThat(connection.getDatabaseTables(), hasItems("versions", "versions_added", "versions_removed"));
- Assert.assertEquals(2, connection.getDatabaseVersion());
+ Assert.assertEquals(1, connection.getDatabaseVersion());
connection.commit();
} finally {
@@ -107,13 +195,13 @@ public class VersioningPersistenceTest {
KiWiStringLiteral object_2 = new KiWiStringLiteral(RandomStringUtils.randomAlphanumeric(32));
KiWiUriResource context = new KiWiUriResource("http://localhost/context/"+RandomStringUtils.randomAlphanumeric(8));
- connection.storeNode(subject1, false);
- connection.storeNode(subject2, false);
- connection.storeNode(pred_1, false);
- connection.storeNode(pred_2, false);
- connection.storeNode(object_1, false);
- connection.storeNode(object_2, false);
- connection.storeNode(context, false);
+ connection.storeNode(subject1);
+ connection.storeNode(subject2);
+ connection.storeNode(pred_1);
+ connection.storeNode(pred_2);
+ connection.storeNode(object_1);
+ connection.storeNode(object_2);
+ connection.storeNode(context);
KiWiTriple triple1 = new KiWiTriple(subject1,pred_1,object_1,context);
KiWiTriple triple2 = new KiWiTriple(subject2,pred_2,object_2,context);
@@ -129,14 +217,16 @@ public class VersioningPersistenceTest {
connection.commit();
// check if listVersions now gives exactly one version
- List<Version> list1 = Iterations.asList(connection.listVersions());
+ List<Version> list1 = connection.listVersions().asList();
Assert.assertEquals("there should be exactly one version",1,list1.size());
Assert.assertEquals("contents of version differ", version1, list1.get(0));
+ Assert.assertEquals("version id is not 1", 1L, (long)list1.get(0).getId());
// check if listVersions with subject1 now gives exactly one version
- List<Version> listr1 = Iterations.asList(connection.listVersions(subject1));
+ List<Version> listr1 = connection.listVersions(subject1).asList();
Assert.assertEquals("there should be exactly one version", 1, listr1.size());
Assert.assertEquals("contents of version differ", version1, listr1.get(0));
+ Assert.assertEquals("version id is not 1", 1L, (long)listr1.get(0).getId());
Version version2 = new Version();
@@ -147,15 +237,16 @@ public class VersioningPersistenceTest {
connection.commit();
// check if listVersions now gives exactly two versions
- List<Version> list2 = Iterations.asList(connection.listVersions());
+ List<Version> list2 = connection.listVersions().asList();
Assert.assertEquals("there should be exactly two version",2,list2.size());
Assert.assertEquals("contents of version differ", version2, list2.get(1));
// check if listVersions with subject1 still gives exactly one version
- List<Version> listr2 = Iterations.asList(connection.listVersions(subject1));
+ List<Version> listr2 = connection.listVersions(subject1).asList();
Assert.assertEquals("there should be exactly one version", 2, listr2.size());
Assert.assertEquals("contents of version differ", version1, listr2.get(0));
+ Assert.assertEquals("version id is not 1", 1L, (long)listr2.get(0).getId());
connection.commit();
} finally {
@@ -180,12 +271,12 @@ public class VersioningPersistenceTest {
KiWiStringLiteral object_2 = new KiWiStringLiteral(RandomStringUtils.randomAlphanumeric(32));
KiWiUriResource context = new KiWiUriResource("http://localhost/context/"+RandomStringUtils.randomAlphanumeric(8));
- connection.storeNode(subject, false);
- connection.storeNode(pred_1, false);
- connection.storeNode(pred_2, false);
- connection.storeNode(object_1, false);
- connection.storeNode(object_2, false);
- connection.storeNode(context, false);
+ connection.storeNode(subject);
+ connection.storeNode(pred_1);
+ connection.storeNode(pred_2);
+ connection.storeNode(object_1);
+ connection.storeNode(object_2);
+ connection.storeNode(context);
KiWiTriple triple1 = new KiWiTriple(subject,pred_1,object_1,context);
KiWiTriple triple2 = new KiWiTriple(subject,pred_2,object_2,context);
@@ -229,9 +320,10 @@ public class VersioningPersistenceTest {
// now we test different ways of listing versions between dates
- List<Version> list1 = Iterations.asList(connection.listVersions(date1,date2));
+ List<Version> list1 = connection.listVersions(date1,date2).asList();
Assert.assertEquals("there should be exactly one version from "+date1+" to "+date2,1,list1.size());
Assert.assertEquals("contents of version differ", version1, list1.get(0));
+ Assert.assertEquals("version id is not 1", 1L, (long)list1.get(0).getId());
// check if getLatestVersion at date2 works
Version latest2 = connection.getLatestVersion(subject,date2);
@@ -239,20 +331,21 @@ public class VersioningPersistenceTest {
Assert.assertEquals("latest version is not the expected version", version1,latest2);
// check if listVersions with subject1 now gives exactly one version
- List<Version> listr1 = Iterations.asList(connection.listVersions(subject,date1,date2));
+ List<Version> listr1 = connection.listVersions(subject,date1,date2).asList();
Assert.assertEquals("there should be exactly one version", 1, listr1.size());
Assert.assertEquals("contents of version differ", version1, listr1.get(0));
+ Assert.assertEquals("version id is not 1", 1L, (long)listr1.get(0).getId());
- List<Version> list2 = Iterations.asList(connection.listVersions(date2,date3));
+ List<Version> list2 = connection.listVersions(date2,date3).asList();
Assert.assertEquals("there should be exactly one version from "+date2+" to "+date3,1,list2.size());
Assert.assertEquals("contents of version differ", version2, list2.get(0));
- Assert.assertTrue("order of versions is not correct", version1.getId() < (long) list2.get(0).getId());
+ Assert.assertEquals("version id is not 2", 2L, (long)list2.get(0).getId());
- List<Version> list3 = Iterations.asList(connection.listVersions(date3,new Date()));
+ List<Version> list3 = connection.listVersions(date3,new Date()).asList();
Assert.assertEquals("there should be no version from "+date3+" to now",0,list3.size());
- List<Version> list4 = Iterations.asList(connection.listVersions(date1,date3));
+ List<Version> list4 = connection.listVersions(date1,date3).asList();
Assert.assertEquals("there should be exactly two versions from "+date1+" to "+date3,2,list4.size());
Assert.assertEquals("contents of version1 differ", version1, list4.get(0));
Assert.assertEquals("contents of version2 differ", version2, list4.get(1));
@@ -266,77 +359,6 @@ public class VersioningPersistenceTest {
}
-
- @Test
- public void testCreateRemoveVersions() throws Exception {
- KiWiVersioningConnection connection = vpersistence.getConnection();
- try {
- KiWiUriResource subject1 = new KiWiUriResource("http://localhost/resource/"+ RandomStringUtils.randomAlphanumeric(8));
- KiWiUriResource subject2 = new KiWiUriResource("http://localhost/resource/"+ RandomStringUtils.randomAlphanumeric(8));
- KiWiUriResource pred_1 = new KiWiUriResource("http://localhost/predicate/P1");
- KiWiUriResource pred_2 = new KiWiUriResource("http://localhost/predicate/P2");
- KiWiUriResource object_1 = new KiWiUriResource("http://localhost/resource/"+RandomStringUtils.randomAlphanumeric(8));
- KiWiStringLiteral object_2 = new KiWiStringLiteral(RandomStringUtils.randomAlphanumeric(32));
- KiWiUriResource context = new KiWiUriResource("http://localhost/context/"+RandomStringUtils.randomAlphanumeric(8));
-
- connection.storeNode(subject1, false);
- connection.storeNode(subject2, false);
- connection.storeNode(pred_1, false);
- connection.storeNode(pred_2, false);
- connection.storeNode(object_1, false);
- connection.storeNode(object_2, false);
- connection.storeNode(context, false);
-
- KiWiTriple triple1 = new KiWiTriple(subject1,pred_1,object_1,context);
- KiWiTriple triple2 = new KiWiTriple(subject2,pred_2,object_2,context);
-
- connection.storeTriple(triple1);
- connection.storeTriple(triple2);
- connection.commit();
-
- Version version1 = new Version();
- version1.setCommitTime(new Date());
- version1.addTriple(triple1);
- connection.storeVersion(version1);
- connection.commit();
-
- // check if listVersions now gives exactly one version
- List<Version> list1 = Iterations.asList(connection.listVersions());
- Assert.assertEquals("there should be exactly one version",1,list1.size());
- Assert.assertEquals("contents of version differ", version1, list1.get(0));
-
- Version version2 = new Version();
- version2.setCommitTime(new Date());
- version2.addTriple(triple2);
- version2.removeTriple(triple1);
- connection.storeVersion(version2);
- connection.commit();
-
- // check if listVersions now gives exactly two versions
- List<Version> list2 = Iterations.asList(connection.listVersions());
- Assert.assertEquals("there should be exactly two version",2,list2.size());
- Assert.assertEquals("contents of version differ", version2, list2.get(1));
-
- connection.commit();
-
- connection.removeVersion(version1.getId());
- connection.commit();
-
- // check if listVersions now gives exactly two versions
- List<Version> list3 = Iterations.asList(connection.listVersions());
- Assert.assertEquals("there should be exactly one version",1,list3.size());
- Assert.assertEquals("contents of version differ", version2, list3.get(0));
-
- connection.commit();
-
- } finally {
- connection.close();
- }
-
- }
-
-
-
/**
* MYSQL rounds timestamps to the second, so it is sometimes necessary to sleep before doing a test
*/
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/4aa87dbe/libraries/kiwi/kiwi-versioning/src/test/java/org/apache/marmotta/kiwi/versioning/test/VersioningRepositoryTest.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-versioning/src/test/java/org/apache/marmotta/kiwi/versioning/test/VersioningRepositoryTest.java b/libraries/kiwi/kiwi-versioning/src/test/java/org/apache/marmotta/kiwi/versioning/test/VersioningRepositoryTest.java
index a1830f7..f0b720a 100644
--- a/libraries/kiwi/kiwi-versioning/src/test/java/org/apache/marmotta/kiwi/versioning/test/VersioningRepositoryTest.java
+++ b/libraries/kiwi/kiwi-versioning/src/test/java/org/apache/marmotta/kiwi/versioning/test/VersioningRepositoryTest.java
@@ -17,20 +17,24 @@
*/
package org.apache.marmotta.kiwi.versioning.test;
-import info.aduna.iteration.Iterations;
-import org.apache.marmotta.kiwi.config.KiWiConfiguration;
+import org.apache.marmotta.kiwi.persistence.KiWiDialect;
+import org.apache.marmotta.kiwi.persistence.h2.H2Dialect;
import org.apache.marmotta.kiwi.persistence.mysql.MySQLDialect;
+import org.apache.marmotta.kiwi.persistence.pgsql.PostgreSQLDialect;
import org.apache.marmotta.kiwi.sail.KiWiStore;
-import org.apache.marmotta.kiwi.test.junit.KiWiDatabaseRunner;
+import org.apache.marmotta.kiwi.test.helper.DBConnectionChecker;
import org.apache.marmotta.kiwi.transactions.sail.KiWiTransactionalSail;
import org.apache.marmotta.kiwi.versioning.model.Version;
import org.apache.marmotta.kiwi.versioning.sail.KiWiVersioningSail;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.TestWatcher;
+import org.junit.runner.Description;
import org.junit.runner.RunWith;
-import org.openrdf.model.URI;
+import org.junit.runners.Parameterized;
import org.openrdf.repository.Repository;
import org.openrdf.repository.RepositoryConnection;
import org.openrdf.repository.RepositoryException;
@@ -42,6 +46,7 @@ import org.slf4j.LoggerFactory;
import java.io.InputStream;
import java.sql.SQLException;
+import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -50,13 +55,71 @@ import static org.junit.Assume.assumeThat;
/**
* This test checks if the versioning functionality itself works, i.e. the system properly creates versions on
- * transaction commits.
- *
- * @author Sebastian Schaffert (sschaffert@apache.org)
+ * transaction commits. It will try running over all available databases. Except for in-memory databases like
+ * H2 or Derby, database URLs must be passed as system property, or otherwise the test is skipped for this database.
+ * Available system properties:
+ * <ul>
+ * <li>PostgreSQL:
+ * <ul>
+ * <li>postgresql.url, e.g. jdbc:postgresql://localhost:5433/kiwitest?prepareThreshold=3</li>
+ * <li>postgresql.user (default: lmf)</li>
+ * <li>postgresql.pass (default: lmf)</li>
+ * </ul>
+ * </li>
+ * <li>MySQL:
+ * <ul>
+ * <li>mysql.url, e.g. jdbc:mysql://localhost:3306/kiwitest?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull</li>
+ * <li>mysql.user (default: lmf)</li>
+ * <li>mysql.pass (default: lmf</li>
+ * </ul>
+ * </li>
+ * <li>H2:
+ * <ul>
+ * <li>h2.url, e.g. jdbc:h2:mem;MVCC=true;DB_CLOSE_ON_EXIT=FALSE;DB_CLOSE_DELAY=10</li>
+ * <li>h2.user (default: lmf)</li>
+ * <li>h2.pass (default: lmf</li>
+ * </ul>
+ * </li>
+ * </ul>
+ *
+ * <p/>
+ * Author: Sebastian Schaffert
*/
-@RunWith(KiWiDatabaseRunner.class)
+@RunWith(Parameterized.class)
public class VersioningRepositoryTest {
+ /**
+ * Return database configurations if the appropriate parameters have been set.
+ *
+ * @return an array (database name, url, user, password)
+ */
+ @Parameterized.Parameters(name="Database Test {index}: {0} at {1}")
+ public static Iterable<Object[]> databases() {
+ String[] databases = {"H2", "PostgreSQL", "MySQL"};
+
+ List<Object[]> result = new ArrayList<Object[]>(databases.length);
+ for(String database : databases) {
+ if(System.getProperty(database.toLowerCase()+".url") != null) {
+ result.add(new Object[] {
+ database,
+ System.getProperty(database.toLowerCase()+".url"),
+ System.getProperty(database.toLowerCase()+".user","lmf"),
+ System.getProperty(database.toLowerCase()+".pass","lmf")
+ });
+ }
+ }
+ return result;
+ }
+
+
+ private KiWiDialect dialect;
+
+ private String jdbcUrl;
+
+ private String jdbcUser;
+
+ private String jdbcPass;
+
private KiWiStore store;
private KiWiTransactionalSail tsail;
@@ -65,16 +128,26 @@ public class VersioningRepositoryTest {
private Repository repository;
- private final KiWiConfiguration dbConfig;
-
- public VersioningRepositoryTest(KiWiConfiguration dbConfig) {
- this.dbConfig = dbConfig;
+ public VersioningRepositoryTest(String database, String jdbcUrl, String jdbcUser, String jdbcPass) {
+ this.jdbcPass = jdbcPass;
+ this.jdbcUrl = jdbcUrl;
+ this.jdbcUser = jdbcUser;
+
+ if("H2".equals(database)) {
+ this.dialect = new H2Dialect();
+ } else if("MySQL".equals(database)) {
+ this.dialect = new MySQLDialect();
+ } else if("PostgreSQL".equals(database)) {
+ this.dialect = new PostgreSQLDialect();
+ }
+
+ DBConnectionChecker.checkDatabaseAvailability(jdbcUrl, jdbcUser, jdbcPass, dialect);
}
@Before
public void initDatabase() throws RepositoryException {
- store = new KiWiStore(dbConfig);
+ store = new KiWiStore("test",jdbcUrl,jdbcUser,jdbcPass,dialect, "http://localhost/context/default", "http://localhost/context/inferred");
tsail = new KiWiTransactionalSail(store);
vsail = new KiWiVersioningSail(tsail);
repository = new SailRepository(vsail);
@@ -91,6 +164,18 @@ public class VersioningRepositoryTest {
final Logger logger =
LoggerFactory.getLogger(this.getClass());
+ @Rule
+ public TestWatcher watchman = new TestWatcher() {
+ /**
+ * Invoked when a test is about to start
+ */
+ @Override
+ protected void starting(Description description) {
+ logger.info("{} being run...", description.getMethodName());
+ }
+ };
+
+
/**
* This test imports three small RDF files in sequence and checks afterwards that the number of versions
* is correct and they contain the correct information
@@ -149,111 +234,25 @@ public class VersioningRepositoryTest {
// list all versions
List<Version> versions = asList(vsail.listVersions());
Assert.assertEquals("expected 3 versions!", 3, versions.size());
- Assert.assertTrue("version order is not correct", versions.get(0).getId() < versions.get(1).getId());
- Assert.assertTrue("version order is not correct", versions.get(1).getId() < versions.get(2).getId());
+ Assert.assertEquals(1, (long)versions.get(0).getId());
+ Assert.assertEquals(2, (long)versions.get(1).getId());
+ Assert.assertEquals(3, (long)versions.get(2).getId());
Assert.assertEquals(3, (long)versions.get(0).getAddedTriples().size());
Assert.assertEquals(3, (long)versions.get(1).getAddedTriples().size());
Assert.assertEquals(1, (long)versions.get(2).getAddedTriples().size());
List<Version> versions1 = asList(vsail.listVersions(date1,date2));
Assert.assertEquals("expected 1 version!", 1, versions1.size());
+ Assert.assertEquals(1, (long)versions1.get(0).getId());
Assert.assertEquals(3, (long)versions1.get(0).getAddedTriples().size());
}
/**
- * This test imports three small RDF files in sequence and checks afterwards that the number of versions
- * is correct and they contain the correct information
- * @throws Exception
- */
- @Test
- public void testRevertVersions() throws Exception {
- // import three files in sequence and check if the versions are created properly
-
- Date date1 = new Date();
-
- mysqlSleep();
-
- // base data
- InputStream baseData = this.getClass().getResourceAsStream("version-base.rdf");
- assumeThat("Could not load test-data: version-base.rdf", baseData, notNullValue(InputStream.class));
-
- RepositoryConnection connectionBase = repository.getConnection();
- try {
- connectionBase.add(baseData, "http://marmotta.incubator.apache.org/testing/ns1/", RDFFormat.RDFXML);
- connectionBase.commit();
- } finally {
- connectionBase.close();
- }
-
- mysqlSleep();
-
- Date date2 = new Date();
-
- mysqlSleep();
-
- // update 1
- InputStream update1Data = this.getClass().getResourceAsStream("version-update1.rdf");
- assumeThat("Could not load test-data: version-update1.rdf", update1Data, notNullValue(InputStream.class));
-
- RepositoryConnection connectionUpdate1 = repository.getConnection();
- try {
- connectionUpdate1.add(update1Data, "http://marmotta.incubator.apache.org/testing/ns1/", RDFFormat.RDFXML);
- connectionUpdate1.commit();
- } finally {
- connectionUpdate1.close();
- }
-
- // update 2
- InputStream update2Data = this.getClass().getResourceAsStream("version-update2.rdf");
- assumeThat("Could not load test-data: version-update2.rdf", update2Data, notNullValue(InputStream.class));
-
- RepositoryConnection connectionUpdate2 = repository.getConnection();
- try {
- connectionUpdate2.add(update2Data, "http://marmotta.incubator.apache.org/testing/ns1/", RDFFormat.RDFXML);
- connectionUpdate2.commit();
- } finally {
- connectionUpdate2.close();
- }
-
- // list all versions
- List<Version> versions = asList(vsail.listVersions());
- Assert.assertEquals("expected 3 versions!", 3, versions.size());
-
- URI subject = repository.getValueFactory().createURI("http://marmotta.incubator.apache.org/testing/ns1/R1");
- URI predicate = repository.getValueFactory().createURI("http://marmotta.incubator.apache.org/testing/ns1/P2");
-
- RepositoryConnection connectionBeforeRevert = repository.getConnection();
- try {
- Assert.assertTrue(connectionBeforeRevert.hasStatement(subject,predicate,null,true));
- } finally {
- connectionBeforeRevert.close();
- }
-
- // revert version; afterwards we expect there to be 4 versions
- vsail.revertVersion(versions.get(0));
-
- List<Version> versions2 = asList(vsail.listVersions());
- Assert.assertEquals("expected 4 versions!", 4, versions2.size());
-
- // the repository should now lo longer contain any P2 property for ns1:C
- RepositoryConnection connectionAfterRevert = repository.getConnection();
- try {
- Assert.assertFalse(connectionAfterRevert.hasStatement(subject, predicate, null, true));
- } finally {
- connectionAfterRevert.close();
- }
-
-
-
- }
-
-
- /**
* MYSQL rounds timestamps to the second, so it is sometimes necessary to sleep before doing a test
*/
private void mysqlSleep() {
- if(this.dbConfig.getDialect() instanceof MySQLDialect) {
+ if(this.dialect instanceof MySQLDialect) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
@@ -268,6 +267,16 @@ public class VersioningRepositoryTest {
* @return
*/
public static <E> List<E> asList(RepositoryResult<E> result) throws RepositoryException {
- return Iterations.asList(result);
+ ArrayList<E> collection = new ArrayList<E>();
+ try {
+ while (result.hasNext()) {
+ collection.add(result.next());
+ }
+
+ return collection;
+ }
+ finally {
+ result.close();
+ }
}
}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/4aa87dbe/libraries/kiwi/pom.xml
----------------------------------------------------------------------
diff --git a/libraries/kiwi/pom.xml b/libraries/kiwi/pom.xml
index f219e8b..39132c6 100644
--- a/libraries/kiwi/pom.xml
+++ b/libraries/kiwi/pom.xml
@@ -21,7 +21,7 @@
<parent>
<groupId>org.apache.marmotta</groupId>
<artifactId>marmotta-parent</artifactId>
- <version>3.2.0-incubating-SNAPSHOT</version>
+ <version>3.1.0-incubating-SNAPSHOT</version>
<relativePath>../../parent</relativePath>
</parent>
@@ -64,6 +64,10 @@
<version>2.13</version>
<configuration>
<systemPropertyVariables>
+ <h2.url>jdbc:h2:mem:test;MVCC=true;DB_CLOSE_ON_EXIT=TRUE</h2.url>
+ <h2.user>sa</h2.user>
+ <h2.pass />
+
<!-- enable or pass on command line for testing local PostgreSQL -->
<postgresql.url>jdbc:postgresql://localhost:5433/kiwitest?prepareThreshold=3</postgresql.url>
<postgresql.user>lmf</postgresql.user>
@@ -84,21 +88,10 @@
<plugin> <!-- generate JRebel Configuration -->
<groupId>org.zeroturnaround</groupId>
<artifactId>jrebel-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>generate-rebel-xml</id>
- <phase>process-resources</phase>
- <goals>
- <goal>generate</goal>
- </goals>
- </execution>
- </executions>
<configuration>
- <relativePath>../../../</relativePath>
- <rootPath>$${rebel.root}</rootPath>
+ <relativePath>../../</relativePath>
</configuration>
</plugin>
-
</plugins>
</pluginManagement>
<plugins>
@@ -107,6 +100,19 @@
<artifactId>maven-surefire-plugin</artifactId>
</plugin>
+ <!-- do not install / deploy reactor -->
+ <plugin>
+ <artifactId>maven-deploy-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-install-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
</plugins>
</build>
@@ -129,7 +135,6 @@
<module>kiwi-tripletable</module>
<module>kiwi-versioning</module>
<module>kiwi-reasoner</module>
- <module>kiwi-sparql</module>
</modules>
</project>
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/4aa87dbe/libraries/ldcache/ldcache-api/pom.xml
----------------------------------------------------------------------
diff --git a/libraries/ldcache/ldcache-api/pom.xml b/libraries/ldcache/ldcache-api/pom.xml
index be4cb03..8462669 100644
--- a/libraries/ldcache/ldcache-api/pom.xml
+++ b/libraries/ldcache/ldcache-api/pom.xml
@@ -21,7 +21,7 @@
<parent>
<groupId>org.apache.marmotta</groupId>
<artifactId>marmotta-parent</artifactId>
- <version>3.2.0-incubating-SNAPSHOT</version>
+ <version>3.1.0-incubating-SNAPSHOT</version>
<relativePath>../../../parent</relativePath>
</parent>
@@ -32,30 +32,6 @@
Interfaces and Data Model for the Linked Data Caching component.
</description>
- <build>
- <pluginManagement>
- <plugins>
- <plugin> <!-- generate JRebel Configuration -->
- <groupId>org.zeroturnaround</groupId>
- <artifactId>jrebel-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>generate-rebel-xml</id>
- <phase>process-resources</phase>
- <goals>
- <goal>generate</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <relativePath>../../../</relativePath>
- <rootPath>$${rebel.root}</rootPath>
- </configuration>
- </plugin>
- </plugins>
- </pluginManagement>
- </build>
-
<dependencies>
<dependency>
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/4aa87dbe/libraries/ldcache/ldcache-api/src/main/java/org/apache/marmotta/ldcache/api/LDCachingBackend.java
----------------------------------------------------------------------
diff --git a/libraries/ldcache/ldcache-api/src/main/java/org/apache/marmotta/ldcache/api/LDCachingBackend.java b/libraries/ldcache/ldcache-api/src/main/java/org/apache/marmotta/ldcache/api/LDCachingBackend.java
index a121e20..3e9bc50 100644
--- a/libraries/ldcache/ldcache-api/src/main/java/org/apache/marmotta/ldcache/api/LDCachingBackend.java
+++ b/libraries/ldcache/ldcache-api/src/main/java/org/apache/marmotta/ldcache/api/LDCachingBackend.java
@@ -60,14 +60,6 @@ public interface LDCachingBackend {
/**
- * Return true in case the resource is a cached resource.
- *
- * @param resource the URI of the resource to check
- * @return true in case the resource is a cached resource
- */
- public boolean isCached(String resource) throws RepositoryException;
-
- /**
* Carry out any initialization tasks that might be necessary
*/
public void initialize();
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/4aa87dbe/libraries/ldcache/ldcache-api/src/main/java/org/apache/marmotta/ldcache/model/CacheEntry.java
----------------------------------------------------------------------
diff --git a/libraries/ldcache/ldcache-api/src/main/java/org/apache/marmotta/ldcache/model/CacheEntry.java b/libraries/ldcache/ldcache-api/src/main/java/org/apache/marmotta/ldcache/model/CacheEntry.java
index 4c7db25..61bef7a 100644
--- a/libraries/ldcache/ldcache-api/src/main/java/org/apache/marmotta/ldcache/model/CacheEntry.java
+++ b/libraries/ldcache/ldcache-api/src/main/java/org/apache/marmotta/ldcache/model/CacheEntry.java
@@ -52,83 +52,41 @@ public class CacheEntry {
private Integer updateCount;
- /**
- * The number of triples that have been retrieved in the last cache refresh.
- */
- private Integer tripleCount;
-
public CacheEntry() {
}
- /**
- * The URI resource managed by this cache entry.
- */
public URI getResource() {
return resource;
}
- /**
- * The URI resource managed by this cache entry.
- */
public void setResource(URI resource) {
this.resource = resource;
}
- /**
- * The date when this resource has been retrieved the last time.
- */
public Date getLastRetrieved() {
return lastRetrieved;
}
- /**
- * The date when this resource has been retrieved the last time.
- */
public void setLastRetrieved(Date lastRetrieved) {
this.lastRetrieved = new Date(lastRetrieved.getTime());
}
- /**
- * The date when this resource needs to be retrieved again according to expiry configuration.
- */
public Date getExpiryDate() {
return expiryDate;
}
- /**
- * The date when this resource needs to be retrieved again according to expiry configuration.
- */
public void setExpiryDate(Date expiryDate) {
this.expiryDate = new Date(expiryDate.getTime());
}
- /**
- * The number of times this resource has already been updated.
- */
public Integer getUpdateCount() {
return updateCount;
}
- /**
- * The number of times this resource has already been updated.
- */
public void setUpdateCount(Integer updateCount) {
this.updateCount = updateCount;
}
- /**
- * The number of triples that have been retrieved in the last cache refresh.
- */
- public Integer getTripleCount() {
- return tripleCount;
- }
-
- /**
- * The number of triples that have been retrieved in the last cache refresh.
- */
- public void setTripleCount(Integer tripleCount) {
- this.tripleCount = tripleCount;
- }
}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/4aa87dbe/libraries/ldcache/ldcache-backend-ehcache/pom.xml
----------------------------------------------------------------------
diff --git a/libraries/ldcache/ldcache-backend-ehcache/pom.xml b/libraries/ldcache/ldcache-backend-ehcache/pom.xml
index e3270ac..86a9d92 100644
--- a/libraries/ldcache/ldcache-backend-ehcache/pom.xml
+++ b/libraries/ldcache/ldcache-backend-ehcache/pom.xml
@@ -21,7 +21,7 @@
<parent>
<groupId>org.apache.marmotta</groupId>
<artifactId>marmotta-parent</artifactId>
- <version>3.2.0-incubating-SNAPSHOT</version>
+ <version>3.1.0-incubating-SNAPSHOT</version>
<relativePath>../../../parent</relativePath>
</parent>
@@ -34,30 +34,6 @@
</description>
- <build>
- <pluginManagement>
- <plugins>
- <plugin> <!-- generate JRebel Configuration -->
- <groupId>org.zeroturnaround</groupId>
- <artifactId>jrebel-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>generate-rebel-xml</id>
- <phase>process-resources</phase>
- <goals>
- <goal>generate</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <relativePath>../../../</relativePath>
- <rootPath>$${rebel.root}</rootPath>
- </configuration>
- </plugin>
- </plugins>
- </pluginManagement>
- </build>
-
<dependencies>
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/4aa87dbe/libraries/ldcache/ldcache-backend-file/pom.xml
----------------------------------------------------------------------
diff --git a/libraries/ldcache/ldcache-backend-file/pom.xml b/libraries/ldcache/ldcache-backend-file/pom.xml
index 7a6cd94..c7d567b 100644
--- a/libraries/ldcache/ldcache-backend-file/pom.xml
+++ b/libraries/ldcache/ldcache-backend-file/pom.xml
@@ -21,7 +21,7 @@
<parent>
<groupId>org.apache.marmotta</groupId>
<artifactId>marmotta-parent</artifactId>
- <version>3.2.0-incubating-SNAPSHOT</version>
+ <version>3.1.0-incubating-SNAPSHOT</version>
<relativePath>../../../parent</relativePath>
</parent>
@@ -34,27 +34,8 @@
<build>
- <pluginManagement>
- <plugins>
- <plugin> <!-- generate JRebel Configuration -->
- <groupId>org.zeroturnaround</groupId>
- <artifactId>jrebel-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>generate-rebel-xml</id>
- <phase>process-resources</phase>
- <goals>
- <goal>generate</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <relativePath>../../../</relativePath>
- <rootPath>$${rebel.root}</rootPath>
- </configuration>
- </plugin>
- </plugins>
- </pluginManagement>
+ <plugins>
+ </plugins>
</build>
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/4aa87dbe/libraries/ldcache/ldcache-backend-file/src/main/java/org/apache/marmotta/ldcache/backend/file/LDCachingFileBackend.java
----------------------------------------------------------------------
diff --git a/libraries/ldcache/ldcache-backend-file/src/main/java/org/apache/marmotta/ldcache/backend/file/LDCachingFileBackend.java b/libraries/ldcache/ldcache-backend-file/src/main/java/org/apache/marmotta/ldcache/backend/file/LDCachingFileBackend.java
index bff143a..937ace5 100644
--- a/libraries/ldcache/ldcache-backend-file/src/main/java/org/apache/marmotta/ldcache/backend/file/LDCachingFileBackend.java
+++ b/libraries/ldcache/ldcache-backend-file/src/main/java/org/apache/marmotta/ldcache/backend/file/LDCachingFileBackend.java
@@ -35,11 +35,9 @@ import org.apache.marmotta.ldcache.backend.file.repository.LDCachingFileReposito
import org.apache.marmotta.ldcache.backend.file.util.FileBackendUtils;
import org.apache.marmotta.ldcache.model.CacheEntry;
import org.openrdf.model.ValueFactory;
-import org.openrdf.model.impl.ValueFactoryImpl;
import org.openrdf.repository.Repository;
import org.openrdf.repository.RepositoryException;
import org.openrdf.repository.sail.SailRepository;
-import org.openrdf.sail.SailException;
import org.openrdf.sail.nativerdf.NativeStore;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -111,26 +109,6 @@ public class LDCachingFileBackend implements LDCachingBackend {
};
}
- /**
- * Return true in case the resource is a cached resource.
- *
- * @param resource the URI of the resource to check
- * @return true in case the resource is a cached resource
- */
- @Override
- public boolean isCached(String resource) throws RepositoryException {
- try {
- final File dataFile = FileBackendUtils.getMetaFile(resource, storageDir);
- if (!(dataFile.exists())) return false;
- final CacheEntry ce = FileBackendUtils.readCacheEntry(dataFile, new ValueFactoryImpl());
- //return ce != null && !FileBackendUtils.isExpired(ce) && ce.getTripleCount() > 0;
- return ce != null && ce.getTripleCount() > 0;
- } catch (IOException e) {
- throw new RepositoryException(e);
- }
- }
-
-
/* (non-Javadoc)
* @see org.apache.marmotta.ldcache.api.LDCachingBackend#initialize()
*/
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/4aa87dbe/libraries/ldcache/ldcache-backend-file/src/main/java/org/apache/marmotta/ldcache/backend/file/util/FileBackendUtils.java
----------------------------------------------------------------------
diff --git a/libraries/ldcache/ldcache-backend-file/src/main/java/org/apache/marmotta/ldcache/backend/file/util/FileBackendUtils.java b/libraries/ldcache/ldcache-backend-file/src/main/java/org/apache/marmotta/ldcache/backend/file/util/FileBackendUtils.java
index a24902c..ea90433 100644
--- a/libraries/ldcache/ldcache-backend-file/src/main/java/org/apache/marmotta/ldcache/backend/file/util/FileBackendUtils.java
+++ b/libraries/ldcache/ldcache-backend-file/src/main/java/org/apache/marmotta/ldcache/backend/file/util/FileBackendUtils.java
@@ -101,8 +101,7 @@ public class FileBackendUtils {
ce.setLastRetrieved(new Date(Long.parseLong(br.readLine().replaceFirst("#.*$", "").trim())));
ce.setExpiryDate(new Date(Long.parseLong(br.readLine().replaceFirst("#.*$", "").trim())));
ce.setUpdateCount(Integer.parseInt(br.readLine().replaceFirst("#.*$", "").trim()));
- ce.setTripleCount(Integer.parseInt(br.readLine().replaceFirst("#.*$", "").trim()));
-
+
return ce;
} finally {
br.close();
@@ -121,8 +120,6 @@ public class FileBackendUtils {
ps.printf("%tQ # last retrieved: %<tF %<tT.%<tL%n", ce.getLastRetrieved());
ps.printf("%tQ # expires: %<tF %<tT.%<tL%n", ce.getExpiryDate());
ps.printf("%d # %<d updates%n", ce.getUpdateCount());
- ps.printf("%d # %<d triples%n", ce.getTripleCount());
- ps.flush();
} finally {
ps.close();
}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/4aa87dbe/libraries/ldcache/ldcache-backend-file/src/test/java/org/apache/marmotta/ldcache/backend/file/test/LDCacheBackendTest.java
----------------------------------------------------------------------
diff --git a/libraries/ldcache/ldcache-backend-file/src/test/java/org/apache/marmotta/ldcache/backend/file/test/LDCacheBackendTest.java b/libraries/ldcache/ldcache-backend-file/src/test/java/org/apache/marmotta/ldcache/backend/file/test/LDCacheBackendTest.java
index 0a24002..2061c9f 100644
--- a/libraries/ldcache/ldcache-backend-file/src/test/java/org/apache/marmotta/ldcache/backend/file/test/LDCacheBackendTest.java
+++ b/libraries/ldcache/ldcache-backend-file/src/test/java/org/apache/marmotta/ldcache/backend/file/test/LDCacheBackendTest.java
@@ -19,7 +19,7 @@ package org.apache.marmotta.ldcache.backend.file.test;
import com.google.common.io.Files;
import info.aduna.iteration.CloseableIteration;
import org.apache.commons.io.FileUtils;
-import org.apache.commons.lang3.RandomStringUtils;
+import org.apache.commons.lang.RandomStringUtils;
import org.apache.marmotta.ldcache.api.LDCachingConnection;
import org.apache.marmotta.ldcache.backend.file.LDCachingFileBackend;
import org.apache.marmotta.ldcache.model.CacheEntry;
@@ -160,12 +160,9 @@ public class LDCacheBackendTest {
entry1.setLastRetrieved(new Date());
entry1.setUpdateCount(1);
entry1.setResource(subject1);
- entry1.setTripleCount(1);
con.addCacheEntry(subject1, entry1);
con.commit();
- Assert.assertTrue(backend.isCached(subject1.stringValue()));
- Assert.assertFalse(backend.isCached(subject2.stringValue()));
Assert.assertEquals(1,asList(backend.listCacheEntries()).size());
Assert.assertEquals(0,asList(backend.listExpiredEntries()).size());
@@ -175,13 +172,10 @@ public class LDCacheBackendTest {
entry2.setLastRetrieved(new Date());
entry2.setUpdateCount(1);
entry2.setResource(subject2);
- entry2.setTripleCount(1);
con.addCacheEntry(subject2,entry2);
con.commit();
- Assert.assertTrue(backend.isCached(subject1.stringValue()));
- Assert.assertTrue(backend.isCached(subject2.stringValue()));
Assert.assertEquals(2,asList(backend.listCacheEntries()).size());
Assert.assertEquals(1,asList(backend.listExpiredEntries()).size());
@@ -189,8 +183,6 @@ public class LDCacheBackendTest {
con.removeCacheEntry(subject1);
con.commit();
- Assert.assertFalse(backend.isCached(subject1.stringValue()));
- Assert.assertTrue(backend.isCached(subject2.stringValue()));
Assert.assertEquals(1,asList(backend.listCacheEntries()).size());
Assert.assertEquals(1,asList(backend.listExpiredEntries()).size());
} catch(RepositoryException ex) {
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/4aa87dbe/libraries/ldcache/ldcache-backend-kiwi/pom.xml
----------------------------------------------------------------------
diff --git a/libraries/ldcache/ldcache-backend-kiwi/pom.xml b/libraries/ldcache/ldcache-backend-kiwi/pom.xml
index f638d16..356eacd 100644
--- a/libraries/ldcache/ldcache-backend-kiwi/pom.xml
+++ b/libraries/ldcache/ldcache-backend-kiwi/pom.xml
@@ -21,7 +21,7 @@
<parent>
<groupId>org.apache.marmotta</groupId>
<artifactId>marmotta-parent</artifactId>
- <version>3.2.0-incubating-SNAPSHOT</version>
+ <version>3.1.0-incubating-SNAPSHOT</version>
<relativePath>../../../parent</relativePath>
</parent>
@@ -34,27 +34,6 @@
</description>
<build>
- <pluginManagement>
- <plugins>
- <plugin> <!-- generate JRebel Configuration -->
- <groupId>org.zeroturnaround</groupId>
- <artifactId>jrebel-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>generate-rebel-xml</id>
- <phase>process-resources</phase>
- <goals>
- <goal>generate</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <relativePath>../../../</relativePath>
- <rootPath>$${rebel.root}</rootPath>
- </configuration>
- </plugin>
- </plugins>
- </pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -161,7 +140,7 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.postgresql</groupId>
+ <groupId>org.jumpmind.symmetric.jdbc</groupId>
<artifactId>postgresql</artifactId>
<scope>test</scope>
</dependency>
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/4aa87dbe/libraries/ldcache/ldcache-backend-kiwi/src/main/java/org/apache/marmotta/ldcache/backend/kiwi/LDCachingKiWiBackend.java
----------------------------------------------------------------------
diff --git a/libraries/ldcache/ldcache-backend-kiwi/src/main/java/org/apache/marmotta/ldcache/backend/kiwi/LDCachingKiWiBackend.java b/libraries/ldcache/ldcache-backend-kiwi/src/main/java/org/apache/marmotta/ldcache/backend/kiwi/LDCachingKiWiBackend.java
index 0d7870b..3e90e1e 100644
--- a/libraries/ldcache/ldcache-backend-kiwi/src/main/java/org/apache/marmotta/ldcache/backend/kiwi/LDCachingKiWiBackend.java
+++ b/libraries/ldcache/ldcache-backend-kiwi/src/main/java/org/apache/marmotta/ldcache/backend/kiwi/LDCachingKiWiBackend.java
@@ -23,7 +23,6 @@ import org.apache.marmotta.kiwi.sail.KiWiStore;
import org.apache.marmotta.ldcache.api.LDCachingBackend;
import org.apache.marmotta.ldcache.api.LDCachingConnection;
import org.apache.marmotta.ldcache.backend.kiwi.persistence.LDCachingKiWiPersistence;
-import org.apache.marmotta.ldcache.backend.kiwi.persistence.LDCachingKiWiPersistenceConnection;
import org.apache.marmotta.ldcache.backend.kiwi.repository.LDCachingSailRepositoryConnection;
import org.apache.marmotta.ldcache.backend.kiwi.sail.LDCachingKiWiSail;
import org.apache.marmotta.ldcache.backend.kiwi.sail.LDCachingKiWiSailConnection;
@@ -178,28 +177,6 @@ public class LDCachingKiWiBackend implements LDCachingBackend {
}
- /**
- * Return true in case the resource is a cached resource.
- *
- * @param resource the URI of the resource to check
- * @return true in case the resource is a cached resource
- */
- @Override
- public boolean isCached(String resource) throws RepositoryException {
- try {
- LDCachingKiWiPersistenceConnection con = persistence.getConnection();
- try {
- CacheEntry entry = con.getCacheEntry(resource);
- return entry != null && entry.getTripleCount() > 0;
- } finally {
- con.commit();
- con.close();
- }
- } catch (SQLException e) {
- throw new RepositoryException(e);
- }
- }
-
public LDCachingKiWiPersistence getPersistence() {
return persistence;
}