You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@marmotta.apache.org by ja...@apache.org on 2013/08/26 17:26:50 UTC
[1/8] git commit: MARMOTTA-287: Added more tests from the Sesame
Store Testsuite
Updated Branches:
refs/heads/develop a20d93573 -> 259b5d133
MARMOTTA-287: Added more tests from the Sesame Store Testsuite
Project: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/commit/a16b7f00
Tree: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/tree/a16b7f00
Diff: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/diff/a16b7f00
Branch: refs/heads/develop
Commit: a16b7f0091db300bc70ac868f1c13ce3b067cb91
Parents: a20d935
Author: Jakob Frank <ja...@apache.org>
Authored: Mon Aug 26 12:23:12 2013 +0200
Committer: Jakob Frank <ja...@apache.org>
Committed: Mon Aug 26 12:34:00 2013 +0200
----------------------------------------------------------------------
.../KiWiRepositoryConnectionTest.java | 50 +++++++++++++++++++
.../sesame/repository/KiWiRepositoryTest.java | 51 ++++++++++++++++++++
2 files changed, 101 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/a16b7f00/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/sesame/repository/KiWiRepositoryConnectionTest.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/sesame/repository/KiWiRepositoryConnectionTest.java b/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/sesame/repository/KiWiRepositoryConnectionTest.java
new file mode 100644
index 0000000..588d8ec
--- /dev/null
+++ b/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/sesame/repository/KiWiRepositoryConnectionTest.java
@@ -0,0 +1,50 @@
+/*
+ * 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.test.sesame.repository;
+
+import org.apache.marmotta.kiwi.config.KiWiConfiguration;
+import org.apache.marmotta.kiwi.sail.KiWiStore;
+import org.apache.marmotta.kiwi.test.junit.KiWiDatabaseRunner;
+import org.junit.runner.RunWith;
+import org.openrdf.repository.Repository;
+import org.openrdf.repository.RepositoryConnectionTest;
+import org.openrdf.repository.sail.SailRepository;
+
+/**
+ * Run the {@link RepositoryConnectionTest}s.
+ * @author Jakob Frank <ja...@apache.org>
+ *
+ */
+@RunWith(KiWiDatabaseRunner.class)
+public class KiWiRepositoryConnectionTest extends RepositoryConnectionTest {
+
+ private final KiWiConfiguration config;
+
+ public KiWiRepositoryConnectionTest(KiWiConfiguration config) {
+ this.config = config;
+ }
+
+ /* (non-Javadoc)
+ * @see org.openrdf.repository.RepositoryConnectionTest#createRepository()
+ */
+ @Override
+ protected Repository createRepository() throws Exception {
+ return new SailRepository(new KiWiStore(config));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/a16b7f00/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/sesame/repository/KiWiRepositoryTest.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/sesame/repository/KiWiRepositoryTest.java b/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/sesame/repository/KiWiRepositoryTest.java
new file mode 100644
index 0000000..3f02a77
--- /dev/null
+++ b/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/sesame/repository/KiWiRepositoryTest.java
@@ -0,0 +1,51 @@
+/*
+ * 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.test.sesame.repository;
+
+import org.apache.marmotta.kiwi.config.KiWiConfiguration;
+import org.apache.marmotta.kiwi.sail.KiWiStore;
+import org.apache.marmotta.kiwi.test.junit.KiWiDatabaseRunner;
+import org.junit.runner.RunWith;
+import org.openrdf.repository.Repository;
+import org.openrdf.repository.RepositoryTest;
+import org.openrdf.repository.sail.SailRepository;
+
+/**
+ * Run the {@link RepositoryTest}s.
+ * @author Jakob Frank <ja...@apache.org>
+ *
+ */
+@RunWith(KiWiDatabaseRunner.class)
+public class KiWiRepositoryTest extends RepositoryTest {
+
+ private final KiWiConfiguration config;
+
+ public KiWiRepositoryTest(KiWiConfiguration config) {
+ this.config = config;
+ }
+
+ /* (non-Javadoc)
+ * @see org.openrdf.repository.RepositoryTest#createRepository()
+ */
+ @Override
+ protected Repository createRepository() throws Exception {
+ KiWiStore store = new KiWiStore(config);
+ return new SailRepository(store);
+ }
+
+}
[8/8] git commit: Fixed @author tags
Posted by ja...@apache.org.
Fixed @author tags
Project: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/commit/259b5d13
Tree: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/tree/259b5d13
Diff: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/diff/259b5d13
Branch: refs/heads/develop
Commit: 259b5d1336647b616e0904a268f346ae9fac37b1
Parents: 64a2cc2
Author: Jakob Frank <ja...@apache.org>
Authored: Mon Aug 26 17:13:51 2013 +0200
Committer: Jakob Frank <ja...@apache.org>
Committed: Mon Aug 26 17:13:51 2013 +0200
----------------------------------------------------------------------
.../marmotta/kiwi/reasoner/test/engine/ReasoningEngineTest.java | 2 +-
.../reasoner/test/persistence/JustificationPersistenceTest.java | 2 +-
.../kiwi/reasoner/test/persistence/KWRLProgramPersistenceTest.java | 2 +-
.../marmotta/kiwi/reasoner/test/persistence/PatternQueryTest.java | 2 +-
.../apache/marmotta/kiwi/reasoner/test/sail/ReasoningSailTest.java | 2 +-
.../test/java/org/apache/marmotta/kiwi/test/TransactionTest.java | 2 +-
6 files changed, 6 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/259b5d13/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/engine/ReasoningEngineTest.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/engine/ReasoningEngineTest.java b/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/engine/ReasoningEngineTest.java
index ca427f8..a9a3dcf 100644
--- a/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/engine/ReasoningEngineTest.java
+++ b/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/engine/ReasoningEngineTest.java
@@ -68,7 +68,7 @@ import org.slf4j.LoggerFactory;
*
* @see org.apache.marmotta.kiwi.persistence.KiWiConnection
* @see org.apache.marmotta.kiwi.persistence.KiWiPersistence
- * @author Sebastian Schaffert (sebastian.schaffert@apache.org)
+ * @author Sebastian Schaffert (sschaffert@apache.org)
*/
@RunWith(KiWiDatabaseRunner.class)
public class ReasoningEngineTest {
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/259b5d13/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/persistence/JustificationPersistenceTest.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/persistence/JustificationPersistenceTest.java b/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/persistence/JustificationPersistenceTest.java
index 6525c7f..6fcbbd0 100644
--- a/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/persistence/JustificationPersistenceTest.java
+++ b/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/persistence/JustificationPersistenceTest.java
@@ -67,7 +67,7 @@ import org.slf4j.LoggerFactory;
*
* @see org.apache.marmotta.kiwi.persistence.KiWiConnection
* @see org.apache.marmotta.kiwi.persistence.KiWiPersistence
- * @author Sebastian Schaffert (sebastian.schaffert@apache.org)
+ * @author Sebastian Schaffert (sschaffert@apache.org)
*/
@RunWith(KiWiDatabaseRunner.class)
public class JustificationPersistenceTest {
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/259b5d13/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/persistence/KWRLProgramPersistenceTest.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/persistence/KWRLProgramPersistenceTest.java b/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/persistence/KWRLProgramPersistenceTest.java
index b402ba6..72524f5 100644
--- a/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/persistence/KWRLProgramPersistenceTest.java
+++ b/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/persistence/KWRLProgramPersistenceTest.java
@@ -54,7 +54,7 @@ import org.slf4j.LoggerFactory;
*
* @see org.apache.marmotta.kiwi.persistence.KiWiConnection
* @see org.apache.marmotta.kiwi.persistence.KiWiPersistence
- * @author Sebastian Schaffert (sebastian.schaffert@apache.org)
+ * @author Sebastian Schaffert (sschaffert@apache.org)
*/
@RunWith(KiWiDatabaseRunner.class)
public class KWRLProgramPersistenceTest {
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/259b5d13/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/persistence/PatternQueryTest.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/persistence/PatternQueryTest.java b/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/persistence/PatternQueryTest.java
index 242d1e0..2fab9f2 100644
--- a/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/persistence/PatternQueryTest.java
+++ b/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/persistence/PatternQueryTest.java
@@ -60,7 +60,7 @@ import com.google.common.collect.ImmutableSet;
*
* @see org.apache.marmotta.kiwi.persistence.KiWiConnection
* @see org.apache.marmotta.kiwi.persistence.KiWiPersistence
- * @author Sebastian Schaffert (sebastian.schaffert@apache.org)
+ * @author Sebastian Schaffert (sschaffert@apache.org)
*/
@RunWith(KiWiDatabaseRunner.class)
public class PatternQueryTest {
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/259b5d13/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/sail/ReasoningSailTest.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/sail/ReasoningSailTest.java b/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/sail/ReasoningSailTest.java
index d9e16f6..15f4d8f 100644
--- a/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/sail/ReasoningSailTest.java
+++ b/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/sail/ReasoningSailTest.java
@@ -54,7 +54,7 @@ import java.util.List;
*
* @see org.apache.marmotta.kiwi.persistence.KiWiConnection
* @see org.apache.marmotta.kiwi.persistence.KiWiPersistence
- * @author Sebastian Schaffert (sebastian.schaffert@apache.org)
+ * @author Sebastian Schaffert (sschaffert@apache.org)
*/
@RunWith(KiWiDatabaseRunner.class)
public class ReasoningSailTest {
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/259b5d13/libraries/kiwi/kiwi-transactions/src/test/java/org/apache/marmotta/kiwi/test/TransactionTest.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-transactions/src/test/java/org/apache/marmotta/kiwi/test/TransactionTest.java b/libraries/kiwi/kiwi-transactions/src/test/java/org/apache/marmotta/kiwi/test/TransactionTest.java
index e5aaa78..6882ddf 100644
--- a/libraries/kiwi/kiwi-transactions/src/test/java/org/apache/marmotta/kiwi/test/TransactionTest.java
+++ b/libraries/kiwi/kiwi-transactions/src/test/java/org/apache/marmotta/kiwi/test/TransactionTest.java
@@ -58,7 +58,7 @@ import com.google.common.collect.Iterables;
/**
* Test the Sesame repository functionality backed by the KiWi triple store.
*
- * @author Sebastian Schaffert (sebastian.schaffert@apache.org)
+ * @author Sebastian Schaffert (sschaffert@apache.org)
*/
@RunWith(KiWiDatabaseRunner.class)
public class TransactionTest {
[7/8] git commit: Converted test in kiwi-versioning to use the
KiWiDatabaseRunner
Posted by ja...@apache.org.
Converted test in kiwi-versioning to use the KiWiDatabaseRunner
Project: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/commit/64a2cc2c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/tree/64a2cc2c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/diff/64a2cc2c
Branch: refs/heads/develop
Commit: 64a2cc2cb61143c24b74a9623cf6c451704ce6b6
Parents: 45d130d
Author: Jakob Frank <ja...@apache.org>
Authored: Mon Aug 26 17:13:03 2013 +0200
Committer: Jakob Frank <ja...@apache.org>
Committed: Mon Aug 26 17:13:03 2013 +0200
----------------------------------------------------------------------
.../versioning/test/SnapshotRepositoryTest.java | 127 +++----------------
.../test/VersioningPersistenceTest.java | 117 +++--------------
.../test/VersioningRepositoryTest.java | 124 +++---------------
3 files changed, 55 insertions(+), 313 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/64a2cc2c/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 562da23..0268db5 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,25 +17,26 @@
*/
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 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 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.sail.KiWiStore;
-import org.apache.marmotta.kiwi.test.helper.DBConnectionChecker;
+import org.apache.marmotta.kiwi.test.junit.KiWiDatabaseRunner;
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;
@@ -46,84 +47,17 @@ 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. 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/>
+ * This test verifies the snapshot functionality, i.e. if the snapshot connection works properly.
+ *
* @see org.apache.marmotta.kiwi.versioning.repository.SnapshotRepositoryConnection
* @see org.apache.marmotta.kiwi.versioning.repository.SnapshotRepository
- * <p/>
- * Author: Sebastian Schaffert
+ * @author Sebastian Schaffert (sschaffert@apache.org)
*/
-@RunWith(Parameterized.class)
+@RunWith(KiWiDatabaseRunner.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;
@@ -132,26 +66,16 @@ public class SnapshotRepositoryTest {
private SnapshotRepository repository;
- 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);
+ private final KiWiConfiguration dbConfig;
+
+ public SnapshotRepositoryTest(KiWiConfiguration dbConfig) {
+ this.dbConfig = dbConfig;
}
@Before
public void initDatabase() throws RepositoryException {
- store = new KiWiStore("test",jdbcUrl,jdbcUser,jdbcPass,dialect, "http://localhost/context/default", "http://localhost/context/inferred");
+ store = new KiWiStore(dbConfig);
tsail = new KiWiTransactionalSail(store);
vsail = new KiWiVersioningSail(tsail);
repository = new SnapshotRepository(vsail);
@@ -168,17 +92,6 @@ 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 {
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/64a2cc2c/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 4477586..4fd354d 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,19 +17,21 @@
*/
package org.apache.marmotta.kiwi.versioning.test;
-import info.aduna.iteration.Iteration;
+import static org.hamcrest.Matchers.hasItems;
import info.aduna.iteration.Iterations;
+
+import java.sql.SQLException;
+import java.util.Date;
+import java.util.List;
+
import org.apache.commons.lang3.RandomStringUtils;
+import org.apache.marmotta.kiwi.config.KiWiConfiguration;
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.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.test.junit.KiWiDatabaseRunner;
import org.apache.marmotta.kiwi.versioning.model.Version;
import org.apache.marmotta.kiwi.versioning.persistence.KiWiVersioningConnection;
import org.apache.marmotta.kiwi.versioning.persistence.KiWiVersioningPersistence;
@@ -45,104 +47,26 @@ 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;
-
-import static org.hamcrest.Matchers.hasItems;
-
/**
* This test checks if the database persistence for the versioning functionality 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/>
- * Author: Sebastian Schaffert
+ *
+ * @author Sebastian Schaffert (sschaffert@apache.org)
*/
-@RunWith(Parameterized.class)
+@RunWith(KiWiDatabaseRunner.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(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);
+ public VersioningPersistenceTest(KiWiConfiguration dbConfig) {
+ this.dbConfig = dbConfig;
}
@Before
public void initDatabase() throws SQLException {
- persistence = new KiWiPersistence("test",jdbcUrl,jdbcUser,jdbcPass,dialect);
+ persistence = new KiWiPersistence(dbConfig);
persistence.initDatabase();
vpersistence = new KiWiVersioningPersistence(persistence);
@@ -160,17 +84,6 @@ 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
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/64a2cc2c/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 79f9415..76f8375 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,13 +17,19 @@
*/
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 org.apache.marmotta.kiwi.persistence.KiWiDialect;
-import org.apache.marmotta.kiwi.persistence.h2.H2Dialect;
+
+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.mysql.MySQLDialect;
-import org.apache.marmotta.kiwi.persistence.pgsql.PostgreSQLDialect;
import org.apache.marmotta.kiwi.sail.KiWiStore;
-import org.apache.marmotta.kiwi.test.helper.DBConnectionChecker;
+import org.apache.marmotta.kiwi.test.junit.KiWiDatabaseRunner;
import org.apache.marmotta.kiwi.transactions.sail.KiWiTransactionalSail;
import org.apache.marmotta.kiwi.versioning.model.Version;
import org.apache.marmotta.kiwi.versioning.sail.KiWiVersioningSail;
@@ -35,7 +41,6 @@ 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.URI;
import org.openrdf.repository.Repository;
import org.openrdf.repository.RepositoryConnection;
@@ -46,82 +51,15 @@ 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 checks if the versioning functionality itself works, i.e. the system properly creates versions on
- * 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
+ * transaction commits.
+ *
+ * @author Sebastian Schaffert (sschaffert@apache.org)
*/
-@RunWith(Parameterized.class)
+@RunWith(KiWiDatabaseRunner.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;
@@ -130,26 +68,16 @@ public class VersioningRepositoryTest {
private Repository repository;
- 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);
+ private final KiWiConfiguration dbConfig;
+
+ public VersioningRepositoryTest(KiWiConfiguration dbConfig) {
+ this.dbConfig = dbConfig;
}
@Before
public void initDatabase() throws RepositoryException {
- store = new KiWiStore("test",jdbcUrl,jdbcUser,jdbcPass,dialect, "http://localhost/context/default", "http://localhost/context/inferred");
+ store = new KiWiStore(dbConfig);
tsail = new KiWiTransactionalSail(store);
vsail = new KiWiVersioningSail(tsail);
repository = new SailRepository(vsail);
@@ -166,18 +94,6 @@ 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
@@ -343,7 +259,7 @@ public class VersioningRepositoryTest {
* MYSQL rounds timestamps to the second, so it is sometimes necessary to sleep before doing a test
*/
private void mysqlSleep() {
- if(this.dialect instanceof MySQLDialect) {
+ if(this.dbConfig.getDialect() instanceof MySQLDialect) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
[4/8] git commit: Converted test in kiwi-reasoner to use the
KiWiDatabaseRunner
Posted by ja...@apache.org.
Converted test in kiwi-reasoner to use the KiWiDatabaseRunner
Project: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/commit/d0f0c69b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/tree/d0f0c69b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/diff/d0f0c69b
Branch: refs/heads/develop
Commit: d0f0c69b55ae38d260a2e1d3f0f54de639c7991f
Parents: 30d5e83
Author: Jakob Frank <ja...@apache.org>
Authored: Mon Aug 26 16:26:01 2013 +0200
Committer: Jakob Frank <ja...@apache.org>
Committed: Mon Aug 26 16:26:01 2013 +0200
----------------------------------------------------------------------
.../test/engine/ReasoningEngineTest.java | 117 +++--------------
.../JustificationPersistenceTest.java | 127 ++++---------------
.../persistence/KWRLProgramPersistenceTest.java | 116 +++--------------
.../test/persistence/PatternQueryTest.java | 113 ++---------------
.../reasoner/test/sail/ReasoningSailTest.java | 96 ++------------
.../kiwi/reasoner/test/parser/test-002.kwrl | 6 +-
.../reasoner/test/persistence/test-002.kwrl | 6 +-
7 files changed, 83 insertions(+), 498 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/d0f0c69b/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/engine/ReasoningEngineTest.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/engine/ReasoningEngineTest.java b/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/engine/ReasoningEngineTest.java
index ba4dbeb..ca427f8 100644
--- a/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/engine/ReasoningEngineTest.java
+++ b/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/engine/ReasoningEngineTest.java
@@ -17,14 +17,18 @@
*/
package org.apache.marmotta.kiwi.reasoner.test.engine;
+import static org.hamcrest.Matchers.hasItem;
+import static org.junit.Assert.fail;
import info.aduna.iteration.CloseableIteration;
import info.aduna.iteration.Iterations;
+
+import java.sql.SQLException;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.marmotta.kiwi.config.KiWiConfiguration;
import org.apache.marmotta.kiwi.model.rdf.KiWiTriple;
-import org.apache.marmotta.kiwi.persistence.KiWiDialect;
import org.apache.marmotta.kiwi.persistence.KiWiPersistence;
-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.reasoner.engine.ReasoningConfiguration;
import org.apache.marmotta.kiwi.reasoner.engine.ReasoningEngine;
import org.apache.marmotta.kiwi.reasoner.model.program.Justification;
@@ -35,7 +39,7 @@ import org.apache.marmotta.kiwi.reasoner.parser.KWRLProgramParserBase;
import org.apache.marmotta.kiwi.reasoner.persistence.KiWiReasoningConnection;
import org.apache.marmotta.kiwi.reasoner.persistence.KiWiReasoningPersistence;
import org.apache.marmotta.kiwi.sail.KiWiStore;
-import org.apache.marmotta.kiwi.test.helper.DBConnectionChecker;
+import org.apache.marmotta.kiwi.test.junit.KiWiDatabaseRunner;
import org.apache.marmotta.kiwi.transactions.api.TransactionalSail;
import org.apache.marmotta.kiwi.transactions.model.TransactionData;
import org.apache.marmotta.kiwi.transactions.sail.KiWiTransactionalSail;
@@ -46,7 +50,6 @@ 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.Resource;
import org.openrdf.model.Statement;
import org.openrdf.model.URI;
@@ -58,90 +61,23 @@ import org.openrdf.rio.RDFFormat;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import static org.hamcrest.Matchers.hasItem;
-import static org.junit.Assert.fail;
-
/**
* This test verifies the functionality of the KiWi Reasonong Engine. Based on a small sample program, it will test
* both incremental reasoning (by manually adding triples) and full reasoning. After reasoning completes, it will
* check if the expected inferred triples as well as their justifications are present.
- * <p/>
- * 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>c</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>
*
* @see org.apache.marmotta.kiwi.persistence.KiWiConnection
* @see org.apache.marmotta.kiwi.persistence.KiWiPersistence
- * <p/>
- * Author: Sebastian Schaffert
+ * @author Sebastian Schaffert (sebastian.schaffert@apache.org)
*/
-@RunWith(Parameterized.class)
+@RunWith(KiWiDatabaseRunner.class)
public class ReasoningEngineTest {
private static Logger log = LoggerFactory.getLogger(ReasoningEngineTest.class);
private static final String NS = "http://localhost/resource/";
- /**
- * 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 KiWiStore store;
private TransactionalSail tsail;
private KiWiPersistence persistence;
private KiWiReasoningPersistence rpersistence;
@@ -149,28 +85,17 @@ public class ReasoningEngineTest {
private Repository repository;
+ private final KiWiConfiguration config;
- public ReasoningEngineTest(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);
+ public ReasoningEngineTest(KiWiConfiguration config) {
+ this.config = config;
}
@Before
public void initDatabase() throws Exception {
-
- store = new KiWiStore("test",jdbcUrl,jdbcUser,jdbcPass,dialect, "http://localhost/context/default", "http://localhost/context/inferred");
+ store = new KiWiStore(config);
tsail = new KiWiTransactionalSail(store);
repository = new SailRepository(tsail);
repository.initialize();
@@ -212,16 +137,6 @@ public class ReasoningEngineTest {
repository.shutDown();
}
- @org.junit.Rule
- public TestWatcher watchman = new TestWatcher() {
- /**
- * Invoked when a test is about to start
- */
- @Override
- protected void starting(Description description) {
- log.info("{} being run...", description.getMethodName());
- }
- };
/**
* Test the reasoning engine by incrementally adding and later removing triples through explicit calls to the
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/d0f0c69b/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/persistence/JustificationPersistenceTest.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/persistence/JustificationPersistenceTest.java b/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/persistence/JustificationPersistenceTest.java
index 3955d8b..6525c7f 100644
--- a/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/persistence/JustificationPersistenceTest.java
+++ b/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/persistence/JustificationPersistenceTest.java
@@ -17,14 +17,25 @@
*/
package org.apache.marmotta.kiwi.reasoner.test.persistence;
+import static org.hamcrest.Matchers.allOf;
+import static org.hamcrest.Matchers.hasItem;
+import static org.hamcrest.Matchers.hasItems;
+import static org.hamcrest.Matchers.not;
import info.aduna.iteration.CloseableIteration;
+
+import java.sql.BatchUpdateException;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
import org.apache.commons.lang3.RandomStringUtils;
+import org.apache.marmotta.kiwi.config.KiWiConfiguration;
import org.apache.marmotta.kiwi.model.rdf.KiWiTriple;
-import org.apache.marmotta.kiwi.persistence.KiWiDialect;
import org.apache.marmotta.kiwi.persistence.KiWiPersistence;
-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.reasoner.model.program.Justification;
import org.apache.marmotta.kiwi.reasoner.model.program.Program;
import org.apache.marmotta.kiwi.reasoner.parser.KWRLProgramParser;
@@ -33,8 +44,7 @@ import org.apache.marmotta.kiwi.reasoner.persistence.KiWiReasoningConnection;
import org.apache.marmotta.kiwi.reasoner.persistence.KiWiReasoningPersistence;
import org.apache.marmotta.kiwi.sail.KiWiStore;
import org.apache.marmotta.kiwi.sail.KiWiValueFactory;
-import org.apache.marmotta.kiwi.test.RepositoryTest;
-import org.apache.marmotta.kiwi.test.helper.DBConnectionChecker;
+import org.apache.marmotta.kiwi.test.junit.KiWiDatabaseRunner;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
@@ -43,7 +53,6 @@ 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.model.URI;
import org.openrdf.repository.Repository;
@@ -52,114 +61,32 @@ import org.openrdf.repository.sail.SailRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.sql.BatchUpdateException;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import static org.hamcrest.Matchers.*;
-
/**
* This test verifies the persistence functionality of the reasoning component regarding storing, loading and deleting
* reasoning programs.
*
- * 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>
- *
* @see org.apache.marmotta.kiwi.persistence.KiWiConnection
* @see org.apache.marmotta.kiwi.persistence.KiWiPersistence
- * <p/>
- * Author: Sebastian Schaffert
+ * @author Sebastian Schaffert (sebastian.schaffert@apache.org)
*/
-@RunWith(Parameterized.class)
+@RunWith(KiWiDatabaseRunner.class)
public class JustificationPersistenceTest {
- /**
- * 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 KiWiReasoningPersistence rpersistence;
private Repository repository;
+ private final KiWiConfiguration config;
- public JustificationPersistenceTest(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);
+ public JustificationPersistenceTest(KiWiConfiguration config) {
+ this.config = config;
}
@Before
public void initDatabase() throws Exception {
-
- KiWiStore store = new KiWiStore("test",jdbcUrl,jdbcUser,jdbcPass,dialect, "http://localhost/context/default", "http://localhost/context/inferred");
+ KiWiStore store = new KiWiStore(config);
repository = new SailRepository(store);
repository.initialize();
@@ -181,16 +108,6 @@ public class JustificationPersistenceTest {
final Logger logger =
LoggerFactory.getLogger(JustificationPersistenceTest.class);
- @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 1: create some triples through a repository connection (some inferred, some base), load a program, and
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/d0f0c69b/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/persistence/KWRLProgramPersistenceTest.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/persistence/KWRLProgramPersistenceTest.java b/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/persistence/KWRLProgramPersistenceTest.java
index 453af56..b402ba6 100644
--- a/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/persistence/KWRLProgramPersistenceTest.java
+++ b/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/persistence/KWRLProgramPersistenceTest.java
@@ -17,20 +17,23 @@
*/
package org.apache.marmotta.kiwi.reasoner.test.persistence;
+import static org.hamcrest.Matchers.hasItems;
import info.aduna.iteration.CloseableIteration;
+
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.marmotta.kiwi.config.KiWiConfiguration;
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.persistence.h2.H2Dialect;
-import org.apache.marmotta.kiwi.persistence.mysql.MySQLDialect;
-import org.apache.marmotta.kiwi.persistence.pgsql.PostgreSQLDialect;
import org.apache.marmotta.kiwi.reasoner.model.program.Program;
import org.apache.marmotta.kiwi.reasoner.parser.KWRLProgramParser;
import org.apache.marmotta.kiwi.reasoner.parser.KWRLProgramParserBase;
import org.apache.marmotta.kiwi.reasoner.persistence.KiWiReasoningConnection;
import org.apache.marmotta.kiwi.reasoner.persistence.KiWiReasoningPersistence;
-import org.apache.marmotta.kiwi.test.RepositoryTest;
-import org.apache.marmotta.kiwi.test.helper.DBConnectionChecker;
+import org.apache.marmotta.kiwi.test.junit.KiWiDatabaseRunner;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
@@ -39,110 +42,33 @@ 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.repository.Repository;
import org.openrdf.repository.sail.SailRepository;
import org.openrdf.sail.memory.MemoryStore;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.hamcrest.Matchers.hasItems;
-
/**
* This test verifies the persistence functionality of the reasoning component regarding storing, loading and deleting
* reasoning programs.
*
- * 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>
- *
* @see org.apache.marmotta.kiwi.persistence.KiWiConnection
* @see org.apache.marmotta.kiwi.persistence.KiWiPersistence
- * <p/>
- * Author: Sebastian Schaffert
+ * @author Sebastian Schaffert (sebastian.schaffert@apache.org)
*/
-@RunWith(Parameterized.class)
+@RunWith(KiWiDatabaseRunner.class)
public class KWRLProgramPersistenceTest {
- /**
- * 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 KiWiReasoningPersistence rpersistence;
private Repository repository;
+ private final KiWiConfiguration config;
- public KWRLProgramPersistenceTest(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);
+ public KWRLProgramPersistenceTest(KiWiConfiguration config) {
+ this.config = config;
+
}
@@ -151,7 +77,7 @@ public class KWRLProgramPersistenceTest {
repository = new SailRepository(new MemoryStore());
repository.initialize();
- persistence = new KiWiPersistence("test",jdbcUrl,jdbcUser,jdbcPass,dialect);
+ persistence = new KiWiPersistence(config);
persistence.initDatabase();
rpersistence = new KiWiReasoningPersistence(persistence, repository.getValueFactory());
@@ -172,16 +98,6 @@ public class KWRLProgramPersistenceTest {
final Logger logger =
LoggerFactory.getLogger(KWRLProgramPersistenceTest.class);
- @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
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/d0f0c69b/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/persistence/PatternQueryTest.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/persistence/PatternQueryTest.java b/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/persistence/PatternQueryTest.java
index 7bdc53e..242d1e0 100644
--- a/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/persistence/PatternQueryTest.java
+++ b/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/persistence/PatternQueryTest.java
@@ -17,14 +17,15 @@
*/
package org.apache.marmotta.kiwi.reasoner.test.persistence;
-import com.google.common.collect.ImmutableSet;
import info.aduna.iteration.CloseableIteration;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.marmotta.kiwi.config.KiWiConfiguration;
import org.apache.marmotta.kiwi.model.rdf.KiWiTriple;
-import org.apache.marmotta.kiwi.persistence.KiWiDialect;
import org.apache.marmotta.kiwi.persistence.KiWiPersistence;
-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.reasoner.model.program.LiteralField;
import org.apache.marmotta.kiwi.reasoner.model.program.Pattern;
import org.apache.marmotta.kiwi.reasoner.model.program.ResourceField;
@@ -33,7 +34,7 @@ import org.apache.marmotta.kiwi.reasoner.model.query.QueryResult;
import org.apache.marmotta.kiwi.reasoner.persistence.KiWiReasoningConnection;
import org.apache.marmotta.kiwi.reasoner.persistence.KiWiReasoningPersistence;
import org.apache.marmotta.kiwi.sail.KiWiStore;
-import org.apache.marmotta.kiwi.test.helper.DBConnectionChecker;
+import org.apache.marmotta.kiwi.test.junit.KiWiDatabaseRunner;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
@@ -42,7 +43,6 @@ 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.Literal;
import org.openrdf.model.URI;
import org.openrdf.model.ValueFactory;
@@ -52,46 +52,17 @@ import org.openrdf.repository.sail.SailRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
+import com.google.common.collect.ImmutableSet;
/**
* This test verifies the persistence functionality of the reasoning component regarding storing, loading and deleting
* reasoning programs.
*
- * 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>
- *
* @see org.apache.marmotta.kiwi.persistence.KiWiConnection
* @see org.apache.marmotta.kiwi.persistence.KiWiPersistence
- * <p/>
- * Author: Sebastian Schaffert
+ * @author Sebastian Schaffert (sebastian.schaffert@apache.org)
*/
-@RunWith(Parameterized.class)
+@RunWith(KiWiDatabaseRunner.class)
public class PatternQueryTest {
// string constants for RDF values
@@ -106,67 +77,21 @@ public class PatternQueryTest {
private static final String OBJECT4 = "Literal Value 2";
private static final String OBJECT5 = "Literal Value 3";
-
-
- /**
- * 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 KiWiReasoningPersistence rpersistence;
private Repository repository;
+ private final KiWiConfiguration config;
- public PatternQueryTest(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);
+ public PatternQueryTest(KiWiConfiguration config) {
+ this.config = config;
}
@Before
public void initDatabase() throws Exception {
-
- KiWiStore store = new KiWiStore("test",jdbcUrl,jdbcUser,jdbcPass,dialect, "http://localhost/context/default", "http://localhost/context/inferred");
+ KiWiStore store = new KiWiStore(config);
repository = new SailRepository(store);
repository.initialize();
@@ -205,16 +130,6 @@ public class PatternQueryTest {
final Logger logger =
LoggerFactory.getLogger(PatternQueryTest.class);
- @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 the method for querying patterns by:
// - evaluating a single pattern without variables (no bindings but justifications non-empty)
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/d0f0c69b/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/sail/ReasoningSailTest.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/sail/ReasoningSailTest.java b/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/sail/ReasoningSailTest.java
index 9410394..d9e16f6 100644
--- a/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/sail/ReasoningSailTest.java
+++ b/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/sail/ReasoningSailTest.java
@@ -17,6 +17,7 @@
*/
package org.apache.marmotta.kiwi.reasoner.test.sail;
+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;
@@ -26,6 +27,7 @@ import org.apache.marmotta.kiwi.reasoner.sail.KiWiReasoningSail;
import org.apache.marmotta.kiwi.sail.KiWiStore;
import org.apache.marmotta.kiwi.test.RepositoryTest;
import org.apache.marmotta.kiwi.test.helper.DBConnectionChecker;
+import org.apache.marmotta.kiwi.test.junit.KiWiDatabaseRunner;
import org.apache.marmotta.kiwi.transactions.sail.KiWiTransactionalSail;
import org.junit.After;
import org.junit.Assert;
@@ -49,104 +51,35 @@ import java.util.List;
/**
* Test the reasoning sail with small sample datasets. It will test both full and incremental reasoning.
- * <p/>
- * 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>
- *
+ *
* @see org.apache.marmotta.kiwi.persistence.KiWiConnection
* @see org.apache.marmotta.kiwi.persistence.KiWiPersistence
- * <p/>
- * Author: Sebastian Schaffert
+ * @author Sebastian Schaffert (sebastian.schaffert@apache.org)
*/
-@RunWith(Parameterized.class)
+@RunWith(KiWiDatabaseRunner.class)
public class ReasoningSailTest {
private static Logger log = LoggerFactory.getLogger(ReasoningSailTest.class);
private static final String NS = "http://localhost/resource/";
- /**
- * 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;
private KiWiReasoningSail rsail;
private Repository repository;
+ private final KiWiConfiguration config;
- public ReasoningSailTest(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);
+ public ReasoningSailTest(KiWiConfiguration config) {
+ this.config = config;
}
@Before
public void initDatabase() throws Exception {
- store = new KiWiStore("test",jdbcUrl,jdbcUser,jdbcPass,dialect, "http://localhost/context/default", "http://localhost/context/inferred");
+ store = new KiWiStore(config);
tsail = new KiWiTransactionalSail(store);
rsail = new KiWiReasoningSail(tsail, new ReasoningConfiguration());
repository = new SailRepository(rsail);
@@ -160,17 +93,6 @@ public class ReasoningSailTest {
repository.shutDown();
}
- @Rule
- public TestWatcher watchman = new TestWatcher() {
- /**
- * Invoked when a test is about to start
- */
- @Override
- protected void starting(Description description) {
- log.info("{} being run...", description.getMethodName());
- }
- };
-
/**
* Test incremental reasoning with a small sample program. This test will carry out the following steps in order:
* - load the program "simple.kwrl" into the reasoning engine
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/d0f0c69b/libraries/kiwi/kiwi-reasoner/src/test/resources/org/apache/marmotta/kiwi/reasoner/test/parser/test-002.kwrl
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-reasoner/src/test/resources/org/apache/marmotta/kiwi/reasoner/test/parser/test-002.kwrl b/libraries/kiwi/kiwi-reasoner/src/test/resources/org/apache/marmotta/kiwi/reasoner/test/parser/test-002.kwrl
index 8f1800d..4c7158e 100644
--- a/libraries/kiwi/kiwi-reasoner/src/test/resources/org/apache/marmotta/kiwi/reasoner/test/parser/test-002.kwrl
+++ b/libraries/kiwi/kiwi-reasoner/src/test/resources/org/apache/marmotta/kiwi/reasoner/test/parser/test-002.kwrl
@@ -13,6 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-($1 http://www.w3.org/2000/01/rdf-schema#subClassOf $2), ($2 http://www.w3.org/2000/01/rdf-schema#subClassOf $3) -> ($1 http://www.w3.org/2000/01/rdf-schema#subClassOf $3)
-($1 http://www.w3.org/2000/01/rdf-schema#subPropertyOf $2), ($2 http://www.w3.org/2000/01/rdf-schema#subPropertyOf $3) -> ($1 http://www.w3.org/2000/01/rdf-schema#subPropertyOf $3)
-($1 http://www.w3.org/1999/02/22-rdf-syntax-ns#type $2), ($2 http://www.w3.org/2000/01/rdf-schema#subClassOf $3) -> ($1 http://www.w3.org/1999/02/22-rdf-syntax-ns#type $3)
+($1 <http://www.w3.org/2000/01/rdf-schema#subClassOf> $2), ($2 <http://www.w3.org/2000/01/rdf-schema#subClassOf> $3) -> ($1 <http://www.w3.org/2000/01/rdf-schema#subClassOf> $3)
+($1 <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> $2), ($2 <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> $3) -> ($1 <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> $3)
+($1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> $2), ($2 <http://www.w3.org/2000/01/rdf-schema#subClassOf> $3) -> ($1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> $3)
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/d0f0c69b/libraries/kiwi/kiwi-reasoner/src/test/resources/org/apache/marmotta/kiwi/reasoner/test/persistence/test-002.kwrl
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-reasoner/src/test/resources/org/apache/marmotta/kiwi/reasoner/test/persistence/test-002.kwrl b/libraries/kiwi/kiwi-reasoner/src/test/resources/org/apache/marmotta/kiwi/reasoner/test/persistence/test-002.kwrl
index 8f1800d..4c7158e 100644
--- a/libraries/kiwi/kiwi-reasoner/src/test/resources/org/apache/marmotta/kiwi/reasoner/test/persistence/test-002.kwrl
+++ b/libraries/kiwi/kiwi-reasoner/src/test/resources/org/apache/marmotta/kiwi/reasoner/test/persistence/test-002.kwrl
@@ -13,6 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-($1 http://www.w3.org/2000/01/rdf-schema#subClassOf $2), ($2 http://www.w3.org/2000/01/rdf-schema#subClassOf $3) -> ($1 http://www.w3.org/2000/01/rdf-schema#subClassOf $3)
-($1 http://www.w3.org/2000/01/rdf-schema#subPropertyOf $2), ($2 http://www.w3.org/2000/01/rdf-schema#subPropertyOf $3) -> ($1 http://www.w3.org/2000/01/rdf-schema#subPropertyOf $3)
-($1 http://www.w3.org/1999/02/22-rdf-syntax-ns#type $2), ($2 http://www.w3.org/2000/01/rdf-schema#subClassOf $3) -> ($1 http://www.w3.org/1999/02/22-rdf-syntax-ns#type $3)
+($1 <http://www.w3.org/2000/01/rdf-schema#subClassOf> $2), ($2 <http://www.w3.org/2000/01/rdf-schema#subClassOf> $3) -> ($1 <http://www.w3.org/2000/01/rdf-schema#subClassOf> $3)
+($1 <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> $2), ($2 <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> $3) -> ($1 <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> $3)
+($1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> $2), ($2 <http://www.w3.org/2000/01/rdf-schema#subClassOf> $3) -> ($1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> $3)
[3/8] git commit: MARMOTTA-287: Added
RDFSchemaRepositoryConnectionTest for kiwi-reasoner
Posted by ja...@apache.org.
MARMOTTA-287: Added RDFSchemaRepositoryConnectionTest for kiwi-reasoner
Project: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/commit/30d5e83d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/tree/30d5e83d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/diff/30d5e83d
Branch: refs/heads/develop
Commit: 30d5e83dae4478d97a765ad056292cf9562ee6f1
Parents: 3631605
Author: Jakob Frank <ja...@apache.org>
Authored: Mon Aug 26 15:54:54 2013 +0200
Committer: Jakob Frank <ja...@apache.org>
Committed: Mon Aug 26 15:55:07 2013 +0200
----------------------------------------------------------------------
libraries/kiwi/kiwi-reasoner/pom.xml | 6 +-
.../KiWiRDFSchemaRepositoryConnectionTest.java | 126 +++++++++++++++++++
.../kiwi/reasoner/test/sesame/rdfs.skwrl | 36 ++++++
3 files changed, 167 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/30d5e83d/libraries/kiwi/kiwi-reasoner/pom.xml
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-reasoner/pom.xml b/libraries/kiwi/kiwi-reasoner/pom.xml
index 67e9a97..cdc67aa 100644
--- a/libraries/kiwi/kiwi-reasoner/pom.xml
+++ b/libraries/kiwi/kiwi-reasoner/pom.xml
@@ -56,7 +56,6 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
- <version>1.7</version>
<executions>
<execution>
<id>add-source</id>
@@ -208,6 +207,11 @@
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.openrdf.sesame</groupId>
+ <artifactId>sesame-store-testsuite</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/30d5e83d/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/sesame/KiWiRDFSchemaRepositoryConnectionTest.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/sesame/KiWiRDFSchemaRepositoryConnectionTest.java b/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/sesame/KiWiRDFSchemaRepositoryConnectionTest.java
new file mode 100644
index 0000000..494e476
--- /dev/null
+++ b/libraries/kiwi/kiwi-reasoner/src/test/java/org/apache/marmotta/kiwi/reasoner/test/sesame/KiWiRDFSchemaRepositoryConnectionTest.java
@@ -0,0 +1,126 @@
+/*
+ * 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.reasoner.test.sesame;
+
+import org.apache.marmotta.kiwi.config.KiWiConfiguration;
+import org.apache.marmotta.kiwi.reasoner.engine.ReasoningConfiguration;
+import org.apache.marmotta.kiwi.reasoner.sail.KiWiReasoningSail;
+import org.apache.marmotta.kiwi.sail.KiWiStore;
+import org.apache.marmotta.kiwi.test.junit.KiWiDatabaseRunner;
+import org.apache.marmotta.kiwi.transactions.sail.KiWiTransactionalSail;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.openrdf.model.vocabulary.RDF;
+import org.openrdf.model.vocabulary.RDFS;
+import org.openrdf.repository.RDFSchemaRepositoryConnectionTest;
+import org.openrdf.repository.Repository;
+import org.openrdf.repository.RepositoryConnection;
+import org.openrdf.repository.RepositoryException;
+import org.openrdf.repository.base.RepositoryConnectionWrapper;
+import org.openrdf.repository.base.RepositoryWrapper;
+import org.openrdf.repository.sail.SailRepository;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Run the {@link KiWiRDFSchemaRepositoryConnectionTest}s.
+ * @author Jakob Frank <ja...@apache.org>
+ *
+ */
+@RunWith(KiWiDatabaseRunner.class)
+public class KiWiRDFSchemaRepositoryConnectionTest extends RDFSchemaRepositoryConnectionTest {
+
+ public Logger log = LoggerFactory.getLogger(this.getClass());
+
+ private final KiWiConfiguration config;
+ private KiWiReasoningSail rsail;
+
+ public KiWiRDFSchemaRepositoryConnectionTest(KiWiConfiguration config) {
+ this.config = config;
+ }
+
+ /* (non-Javadoc)
+ * @see org.openrdf.repository.RepositoryConnectionTest#createRepository()
+ */
+ @Override
+ protected Repository createRepository() throws Exception {
+ KiWiStore sail = new KiWiStore(config);
+ KiWiTransactionalSail tsail = new KiWiTransactionalSail(sail);
+ rsail = new KiWiReasoningSail(tsail, new ReasoningConfiguration());
+
+
+ return new RepositoryWrapper(new SailRepository(rsail)) {
+ @Override
+ public RepositoryConnection getConnection()
+ throws RepositoryException {
+ return new RepositoryConnectionWrapper(this, super.getConnection()) {
+ @Override
+ public void commit() throws RepositoryException {
+ super.commit();
+
+ // wait for the reasoner to finish
+ try {
+ while(rsail.getEngine().isRunning()) {
+ log.info("sleeping for 100ms to let engine finish processing ... ");
+ Thread.sleep(100);
+ }
+ Thread.sleep(100);
+ log.info("sleeping for 100ms to let engine finish processing ... ");
+ } catch (InterruptedException e) {
+ throw new RepositoryException("Could not finish reasoning", e);
+ }
+ }
+ };
+ }
+ };
+ }
+
+ @Override
+ @Before
+ public void setUp() throws Exception {
+ super.setUp();
+
+ log.info("Setting up reasoning for RDFS");
+ rsail.addProgram("rdfs", this.getClass().getResourceAsStream("rdfs.skwrl"));
+ }
+
+ @Override
+ @Test
+ public void testExplicitFlag() throws Exception {
+ // We need at least _some_ data to infer...
+ testCon.begin();
+ testCon.add(bob, RDF.TYPE, RDFS.RESOURCE);
+ testCon.commit();
+
+ super.testExplicitFlag();
+ }
+
+ @Override
+ @Test
+ @Ignore("in KiWi, inferencing is triggered on commit")
+ public void testInferencerQueryDuringTransaction() throws Exception {
+ }
+
+ @Override
+ @Test
+ @Ignore("in KiWi, inferencing is triggered on commit")
+ public void testInferencerTransactionIsolation() throws Exception {
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/30d5e83d/libraries/kiwi/kiwi-reasoner/src/test/resources/org/apache/marmotta/kiwi/reasoner/test/sesame/rdfs.skwrl
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-reasoner/src/test/resources/org/apache/marmotta/kiwi/reasoner/test/sesame/rdfs.skwrl b/libraries/kiwi/kiwi-reasoner/src/test/resources/org/apache/marmotta/kiwi/reasoner/test/sesame/rdfs.skwrl
new file mode 100644
index 0000000..75294d8
--- /dev/null
+++ b/libraries/kiwi/kiwi-reasoner/src/test/resources/org/apache/marmotta/kiwi/reasoner/test/sesame/rdfs.skwrl
@@ -0,0 +1,36 @@
+/*
+ * 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.
+ */
+/* rules taken from http://www.w3.org/TR/2004/REC-rdf-mt-20040210/#RDFRules */
+@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
+@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
+@prefix xsd: <http://www.w3.org/2001/XMLSchema#>
+@prefix foaf: <http://xmlns.com/foaf/0.1/>
+
+rdf1 : ($u $a $y) -> ($a rdf:type rdf:Property)
+rdfs2 : ($a rdfs:domain $x), ($u $a $y) -> ($u rdf:type $x)
+rdfs3 : ($a rdfs:range $x), ($u $a $v) -> ($v rdf:type $x)
+rdfs4a : ($u $a $x) -> ($u rdf:type rdfs:Resource)
+rdfs5 : ($u rdfs:subPropertyOf $v), ($v rdfs:subPropertyOf $x) -> ($u rdfs:subPropertyOf $x)
+rdfs6 : ($u rdf:type rdf:Property) -> ($u rdfs:subPropertyOf $u)
+rdfs7 : ($a rdfs:subPropertyOf $b), ($u $a $y) -> ($u $b $y)
+rdfs8 : ($u rdf:type rdfs:Class) -> ($u rdfs:subClassOf rdfs:Resource)
+rdfs9 : ($u rdfs:subClassOf $x), ($v rdf:type $u) -> ($v rdf:type $x)
+rdfs10 : ($u rdf:type rdfs:Class) -> ($u rdfs:subClassOf $u)
+rdfs11 : ($u rdfs:subClassOf $v), ($v rdfs:subClassOf $x) -> ($u rdfs:subClassOf $x)
+rdfs12 : ($u rdf:type rdfs:ContainerMembershipProperty) -> ($u rdfs:subPropertyOf rdfs:member)
+rdfs13 : ($u rdf:type rdfs:Datatype) -> ($u rdfs:subClassOf rdfs:Literal)
[5/8] git commit: Converted test in kiwi-transactions to use the
KiWiDatabaseRunner
Posted by ja...@apache.org.
Converted test in kiwi-transactions to use the KiWiDatabaseRunner
Project: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/commit/bd477fed
Tree: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/tree/bd477fed
Diff: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/diff/bd477fed
Branch: refs/heads/develop
Commit: bd477fedf60ea6dee9853618a23c242ebb9f7a9c
Parents: d0f0c69
Author: Jakob Frank <ja...@apache.org>
Authored: Mon Aug 26 16:29:16 2013 +0200
Committer: Jakob Frank <ja...@apache.org>
Committed: Mon Aug 26 16:29:16 2013 +0200
----------------------------------------------------------------------
.../marmotta/kiwi/test/TransactionTest.java | 128 ++++---------------
1 file changed, 23 insertions(+), 105 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/bd477fed/libraries/kiwi/kiwi-transactions/src/test/java/org/apache/marmotta/kiwi/test/TransactionTest.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-transactions/src/test/java/org/apache/marmotta/kiwi/test/TransactionTest.java b/libraries/kiwi/kiwi-transactions/src/test/java/org/apache/marmotta/kiwi/test/TransactionTest.java
index af79558..e5aaa78 100644
--- a/libraries/kiwi/kiwi-transactions/src/test/java/org/apache/marmotta/kiwi/test/TransactionTest.java
+++ b/libraries/kiwi/kiwi-transactions/src/test/java/org/apache/marmotta/kiwi/test/TransactionTest.java
@@ -17,16 +17,19 @@
*/
package org.apache.marmotta.kiwi.test;
+import static org.hamcrest.CoreMatchers.hasItems;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.junit.Assume.assumeThat;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.sql.SQLException;
+import java.util.List;
+
import org.apache.marmotta.commons.sesame.repository.ResourceUtils;
-import com.google.common.base.Function;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
-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.config.KiWiConfiguration;
import org.apache.marmotta.kiwi.sail.KiWiStore;
-import org.apache.marmotta.kiwi.test.helper.DBConnectionChecker;
+import org.apache.marmotta.kiwi.test.junit.KiWiDatabaseRunner;
import org.apache.marmotta.kiwi.transactions.api.TransactionListener;
import org.apache.marmotta.kiwi.transactions.model.TransactionData;
import org.apache.marmotta.kiwi.transactions.sail.KiWiTransactionalSail;
@@ -38,7 +41,6 @@ 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.Resource;
import org.openrdf.repository.Repository;
import org.openrdf.repository.RepositoryConnection;
@@ -49,82 +51,19 @@ import org.openrdf.rio.RDFParseException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.IOException;
-import java.io.InputStream;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.hamcrest.CoreMatchers.hasItems;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.junit.Assume.assumeThat;
+import com.google.common.base.Function;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Iterables;
/**
- * Test the Sesame repository functionality backed by the KiWi triple store. 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
+ * Test the Sesame repository functionality backed by the KiWi triple store.
+ *
+ * @author Sebastian Schaffert (sebastian.schaffert@apache.org)
*/
-@RunWith(Parameterized.class)
+@RunWith(KiWiDatabaseRunner.class)
public class TransactionTest {
private static Logger log = LoggerFactory.getLogger(TransactionTest.class);
- /**
- * 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 Repository repository;
private KiWiStore store;
@@ -133,25 +72,15 @@ public class TransactionTest {
private MockListener listener;
- public TransactionTest(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);
+ private final KiWiConfiguration kiwiConfiguration;
+
+ public TransactionTest(KiWiConfiguration configuration) {
+ this.kiwiConfiguration = configuration;
}
@Before
public void initDatabase() throws RepositoryException {
- store = new KiWiStore("test",jdbcUrl,jdbcUser,jdbcPass,dialect, "http://localhost/context/default", "http://localhost/context/inferred");
+ store = new KiWiStore(kiwiConfiguration);
tstore = new KiWiTransactionalSail(store);
listener = new MockListener();
tstore.addTransactionListener(listener);
@@ -165,17 +94,6 @@ public class TransactionTest {
repository.shutDown();
}
- @Rule
- public TestWatcher watchman = new TestWatcher() {
- /**
- * Invoked when a test is about to start
- */
- @Override
- protected void starting(Description description) {
- log.info("{} being run...", description.getMethodName());
- }
- };
-
/**
* Test importing data; the test will load a small sample RDF file and check whether the expected resources are
[6/8] git commit: Converted test in kiwi-triplestore to use the
KiWiDatabaseRunner
Posted by ja...@apache.org.
Converted test in kiwi-triplestore to use the KiWiDatabaseRunner
Project: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/commit/45d130d5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/tree/45d130d5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/diff/45d130d5
Branch: refs/heads/develop
Commit: 45d130d503898e10a2649334f68d94f688811f98
Parents: bd477fe
Author: Jakob Frank <ja...@apache.org>
Authored: Mon Aug 26 17:07:01 2013 +0200
Committer: Jakob Frank <ja...@apache.org>
Committed: Mon Aug 26 17:07:01 2013 +0200
----------------------------------------------------------------------
.../marmotta/kiwi/test/H2ConcurrencyTest.java | 51 ++----------------
.../kiwi/test/MySQLConcurrencyTest.java | 53 +++----------------
.../kiwi/test/PostgreSQLConcurrencyTest.java | 55 +++-----------------
.../marmotta/kiwi/test/RepositoryTest.java | 31 ++---------
.../kiwi/test/junit/KiWiDatabaseRunner.java | 31 ++++++++++-
5 files changed, 51 insertions(+), 170 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/45d130d5/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/H2ConcurrencyTest.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/H2ConcurrencyTest.java b/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/H2ConcurrencyTest.java
index 3d02b1c..2b2f966 100644
--- a/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/H2ConcurrencyTest.java
+++ b/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/H2ConcurrencyTest.java
@@ -6,10 +6,10 @@ import java.sql.SQLException;
import java.util.Random;
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.sail.KiWiStore;
import org.apache.marmotta.kiwi.test.helper.DBConnectionChecker;
+import org.apache.marmotta.kiwi.test.junit.KiWiDatabaseRunner;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.openrdf.repository.RepositoryException;
@@ -20,63 +20,22 @@ import org.slf4j.LoggerFactory;
/**
* This test starts many triplestore operations in parallel to check if concurrent operations will break things,
*
- * 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
-
- *
* @author Sebastian Schaffert (sschaffert@apache.org)
*/
public class H2ConcurrencyTest extends ConcurrencyTestBase {
- private static KiWiDialect dialect;
-
- private static String jdbcUrl;
-
- private static String jdbcUser;
-
- private static String jdbcPass;
-
private static KiWiStore store;
@BeforeClass
public static void setup() throws RepositoryException {
logger = LoggerFactory.getLogger(H2ConcurrencyTest.class);
- jdbcPass = System.getProperty("h2.pass","lmf");
- jdbcUrl = System.getProperty("h2.url");
- jdbcUser = System.getProperty("h2.user","lmf");
+ KiWiConfiguration h2Config = KiWiDatabaseRunner.createKiWiConfig("H2", new H2Dialect());
+ DBConnectionChecker.checkDatabaseAvailability(h2Config);
+
rnd = new Random();
- dialect = new H2Dialect();
-
- DBConnectionChecker.checkDatabaseAvailability(jdbcUrl, jdbcUser, jdbcPass, dialect);
-
- store = new KiWiStore(new KiWiConfiguration("test",jdbcUrl,jdbcUser,jdbcPass,dialect, "http://localhost/context/default", "http://localhost/context/inferred" ));
+ store = new KiWiStore(h2Config);
repository = new SailRepository(store);
repository.initialize();
}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/45d130d5/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/MySQLConcurrencyTest.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/MySQLConcurrencyTest.java b/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/MySQLConcurrencyTest.java
index 98f69d6..ddcdf46 100644
--- a/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/MySQLConcurrencyTest.java
+++ b/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/MySQLConcurrencyTest.java
@@ -6,10 +6,10 @@ import java.sql.SQLException;
import java.util.Random;
import org.apache.marmotta.kiwi.config.KiWiConfiguration;
-import org.apache.marmotta.kiwi.persistence.KiWiDialect;
import org.apache.marmotta.kiwi.persistence.mysql.MySQLDialect;
import org.apache.marmotta.kiwi.sail.KiWiStore;
import org.apache.marmotta.kiwi.test.helper.DBConnectionChecker;
+import org.apache.marmotta.kiwi.test.junit.KiWiDatabaseRunner;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.openrdf.repository.RepositoryException;
@@ -20,63 +20,22 @@ import org.slf4j.LoggerFactory;
/**
* This test starts many triplestore operations in parallel to check if concurrent operations will break things,
*
- * 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
-
- *
* @author Sebastian Schaffert (sschaffert@apache.org)
*/
public class MySQLConcurrencyTest extends ConcurrencyTestBase {
- private static KiWiDialect dialect;
-
- private static String jdbcUrl;
-
- private static String jdbcUser;
-
- private static String jdbcPass;
-
private static KiWiStore store;
@BeforeClass
public static void setup() throws RepositoryException {
- logger = LoggerFactory.getLogger(MySQLConcurrencyTest.class);
+ logger = LoggerFactory.getLogger(H2ConcurrencyTest.class);
- jdbcPass = System.getProperty("mysql.pass","lmf");
- jdbcUrl = System.getProperty("mysql.url");
- jdbcUser = System.getProperty("mysql.user","lmf");
+ KiWiConfiguration mysqlConfig = KiWiDatabaseRunner.createKiWiConfig("MySQL", new MySQLDialect());
+ DBConnectionChecker.checkDatabaseAvailability(mysqlConfig);
+
rnd = new Random();
- dialect = new MySQLDialect();
-
- DBConnectionChecker.checkDatabaseAvailability(jdbcUrl, jdbcUser, jdbcPass, dialect);
-
- store = new KiWiStore(new KiWiConfiguration("test",jdbcUrl,jdbcUser,jdbcPass,dialect, "http://localhost/context/default", "http://localhost/context/inferred" ));
+ store = new KiWiStore(mysqlConfig);
repository = new SailRepository(store);
repository.initialize();
}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/45d130d5/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/PostgreSQLConcurrencyTest.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/PostgreSQLConcurrencyTest.java b/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/PostgreSQLConcurrencyTest.java
index ddd9b2d..8d5fb94 100644
--- a/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/PostgreSQLConcurrencyTest.java
+++ b/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/PostgreSQLConcurrencyTest.java
@@ -1,82 +1,41 @@
package org.apache.marmotta.kiwi.test;
+import static org.junit.Assert.assertTrue;
+
import java.sql.SQLException;
import java.util.Random;
import org.apache.marmotta.kiwi.config.KiWiConfiguration;
-import org.apache.marmotta.kiwi.persistence.KiWiDialect;
import org.apache.marmotta.kiwi.persistence.pgsql.PostgreSQLDialect;
import org.apache.marmotta.kiwi.sail.KiWiStore;
import org.apache.marmotta.kiwi.test.helper.DBConnectionChecker;
+import org.apache.marmotta.kiwi.test.junit.KiWiDatabaseRunner;
import org.junit.AfterClass;
import org.junit.BeforeClass;
-
import org.openrdf.repository.RepositoryException;
import org.openrdf.repository.sail.SailRepository;
import org.openrdf.sail.SailException;
-
import org.slf4j.LoggerFactory;
-import static org.junit.Assert.assertTrue;
-
/**
* This test starts many triplestore operations in parallel to check if concurrent operations will break things,
*
- * 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 (sschaffert@apache.org)
*/
public class PostgreSQLConcurrencyTest extends ConcurrencyTestBase {
- private static KiWiDialect dialect;
-
- private static String jdbcUrl;
-
- private static String jdbcUser;
-
- private static String jdbcPass;
-
private static KiWiStore store;
@BeforeClass
public static void setup() throws RepositoryException {
logger = LoggerFactory.getLogger(PostgreSQLConcurrencyTest.class);
- jdbcPass = System.getProperty("postgresql.pass","lmf");
- jdbcUrl = System.getProperty("postgresql.url");
- jdbcUser = System.getProperty("postgresql.user","lmf");
+ KiWiConfiguration psql = KiWiDatabaseRunner.createKiWiConfig("PostgreSQL", new PostgreSQLDialect());
+ DBConnectionChecker.checkDatabaseAvailability(psql);
+
rnd = new Random();
- dialect = new PostgreSQLDialect();
-
- DBConnectionChecker.checkDatabaseAvailability(jdbcUrl, jdbcUser, jdbcPass, dialect);
-
- store = new KiWiStore(new KiWiConfiguration("test",jdbcUrl,jdbcUser,jdbcPass,dialect, "http://localhost/context/default", "http://localhost/context/inferred" ));
+ store = new KiWiStore(psql);
repository = new SailRepository(store);
repository.initialize();
}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/45d130d5/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/RepositoryTest.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/RepositoryTest.java b/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/RepositoryTest.java
index 4d2e291..f8817b7 100644
--- a/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/RepositoryTest.java
+++ b/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/RepositoryTest.java
@@ -65,34 +65,9 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
/**
- * Test the Sesame repository functionality backed by the KiWi triple store. 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
+ * Test the Sesame repository functionality backed by the KiWi triple store.
+ *
+ * @author Sebastian Schaffert (sschaffert@apache.org)
*/
@RunWith(KiWiDatabaseRunner.class)
public class RepositoryTest {
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/45d130d5/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/junit/KiWiDatabaseRunner.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/junit/KiWiDatabaseRunner.java b/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/junit/KiWiDatabaseRunner.java
index 4f15c38..e7f6571 100644
--- a/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/junit/KiWiDatabaseRunner.java
+++ b/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/junit/KiWiDatabaseRunner.java
@@ -81,16 +81,42 @@ import org.slf4j.LoggerFactory;
*/
public class KiWiDatabaseRunner extends Suite {
+ /**
+ * Assign the {@link KiWiConfiguration} to all member fields with {@link KiWiConfig}-Annotation.
+ * If this annotation is used, the class must only have the default constructor.
+ */
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public static @interface KiWiConfig {
}
+ /**
+ * Only execute with {@link KiWiConfiguration}s for these {@link KiWiDialect}s.
+ */
+ @Retention(RetentionPolicy.RUNTIME)
+ @Target(ElementType.TYPE)
+ public static @interface ForDialects {
+ Class<? extends KiWiDialect>[] dialect();
+ }
+
private final ArrayList<Runner> runners = new ArrayList<Runner>();
+ private final List<Class<? extends KiWiDialect>> forDialects;
+
public KiWiDatabaseRunner(Class<?> klass) throws Throwable {
super(klass, Collections.<Runner>emptyList());
+ ForDialects d = klass.getAnnotation(ForDialects.class);
+ if (d != null) {
+ ArrayList<Class<? extends KiWiDialect>> forDialects = new ArrayList<>();
+ for (Class<? extends KiWiDialect> dialect : d.dialect()) {
+ forDialects.add(dialect);
+ }
+ this.forDialects = Collections.unmodifiableList(forDialects);
+ } else {
+ forDialects = null;
+ }
+
createRunners();
}
@@ -107,11 +133,14 @@ public class KiWiDatabaseRunner extends Suite {
}
private void createKiWiConfig(String database, KiWiDialect dialect, List<KiWiConfiguration> configs) {
+ if (forDialects != null && !forDialects.contains(dialect.getClass())) {
+ return;
+ }
KiWiConfiguration c = createKiWiConfig(database, dialect);
if (c!=null) configs.add(c);
}
- private KiWiConfiguration createKiWiConfig(String database, KiWiDialect dialect) {
+ public static KiWiConfiguration createKiWiConfig(String database, KiWiDialect dialect) {
final KiWiConfiguration config;
if(System.getProperty(database.toLowerCase()+".url") != null) {
config = new KiWiConfiguration(
[2/8] git commit: MARMOTTA-285: Switched Tests to the new
KiWiDatabaseRunner
Posted by ja...@apache.org.
MARMOTTA-285: Switched Tests to the new KiWiDatabaseRunner
Project: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/commit/36316050
Tree: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/tree/36316050
Diff: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/diff/36316050
Branch: refs/heads/develop
Commit: 363160501fbf4feeb520a01f7eadf152dd5b134e
Parents: a16b7f0
Author: Jakob Frank <ja...@apache.org>
Authored: Mon Aug 26 12:44:24 2013 +0200
Committer: Jakob Frank <ja...@apache.org>
Committed: Mon Aug 26 12:44:24 2013 +0200
----------------------------------------------------------------------
.../sparql/test/ComplexKiWiSparqlQueryTest.java | 105 ++---------------
.../kiwi/sparql/test/KiWiSparqlJoinTest.java | 114 +++++--------------
.../kiwi/sparql/test/KiWiSparqlUpdateTest.java | 108 ++----------------
3 files changed, 44 insertions(+), 283 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/36316050/libraries/kiwi/kiwi-sparql/src/test/java/org/apache/marmotta/kiwi/sparql/test/ComplexKiWiSparqlQueryTest.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-sparql/src/test/java/org/apache/marmotta/kiwi/sparql/test/ComplexKiWiSparqlQueryTest.java b/libraries/kiwi/kiwi-sparql/src/test/java/org/apache/marmotta/kiwi/sparql/test/ComplexKiWiSparqlQueryTest.java
index d58d50c..0fba8b2 100644
--- a/libraries/kiwi/kiwi-sparql/src/test/java/org/apache/marmotta/kiwi/sparql/test/ComplexKiWiSparqlQueryTest.java
+++ b/libraries/kiwi/kiwi-sparql/src/test/java/org/apache/marmotta/kiwi/sparql/test/ComplexKiWiSparqlQueryTest.java
@@ -17,23 +17,11 @@
*/
package org.apache.marmotta.kiwi.sparql.test;
-import java.util.ArrayList;
-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.sparql.sail.KiWiSparqlSail;
-import org.apache.marmotta.kiwi.test.helper.DBConnectionChecker;
-import org.junit.Assert;
-import org.junit.Rule;
-import org.junit.rules.TestWatcher;
-import org.junit.runner.Description;
+import org.apache.marmotta.kiwi.test.junit.KiWiDatabaseRunner;
import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
import org.openrdf.query.parser.sparql.ComplexSPARQLQueryTest;
import org.openrdf.repository.Repository;
import org.openrdf.repository.sail.SailRepository;
@@ -41,100 +29,23 @@ import org.openrdf.repository.sail.SailRepository;
/**
* Run the Sesame Complex SPARQL Query Test Suite.
- * <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>
+
* @author Jakob Frank <ja...@apache.org>
*
*/
-@RunWith(Parameterized.class)
+@RunWith(KiWiDatabaseRunner.class)
public class ComplexKiWiSparqlQueryTest extends ComplexSPARQLQueryTest {
- /**
- * 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 final KiWiDialect dialect;
-
- private final String jdbcUrl;
-
- private final String jdbcUser;
-
- private final String jdbcPass;
-
- @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());
- }
- };
-
- public ComplexKiWiSparqlQueryTest(String database, String jdbcUrl, String jdbcUser, String jdbcPass) {
- this.jdbcPass = jdbcPass;
- this.jdbcUrl = jdbcUrl;
- this.jdbcUser = jdbcUser;
+
+ private final KiWiConfiguration config;
- 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();
- } else {
- Assert.fail("unknown database dialect: " + database);
- throw new AssertionError();
- }
-
- DBConnectionChecker.checkDatabaseAvailability(jdbcUrl, jdbcUser, jdbcPass, dialect);
+ public ComplexKiWiSparqlQueryTest(KiWiConfiguration config) {
+ this.config = config;
}
@Override
protected Repository newRepository() throws Exception {
- KiWiStore store = new KiWiStore(new KiWiConfiguration("test",jdbcUrl,jdbcUser,jdbcPass,dialect, "http://localhost/context/default", "http://localhost/context/inferred"));
+ KiWiStore store = new KiWiStore(config);
KiWiSparqlSail ssail = new KiWiSparqlSail(store);
return new SailRepository(ssail);
}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/36316050/libraries/kiwi/kiwi-sparql/src/test/java/org/apache/marmotta/kiwi/sparql/test/KiWiSparqlJoinTest.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-sparql/src/test/java/org/apache/marmotta/kiwi/sparql/test/KiWiSparqlJoinTest.java b/libraries/kiwi/kiwi-sparql/src/test/java/org/apache/marmotta/kiwi/sparql/test/KiWiSparqlJoinTest.java
index 7165c7d..ad7d701 100644
--- a/libraries/kiwi/kiwi-sparql/src/test/java/org/apache/marmotta/kiwi/sparql/test/KiWiSparqlJoinTest.java
+++ b/libraries/kiwi/kiwi-sparql/src/test/java/org/apache/marmotta/kiwi/sparql/test/KiWiSparqlJoinTest.java
@@ -17,25 +17,34 @@
package org.apache.marmotta.kiwi.sparql.test;
-import com.google.common.base.Function;
-import com.google.common.collect.Lists;
import info.aduna.iteration.Iterations;
-import org.apache.commons.io.IOUtils;
+
+import java.io.IOException;
+import java.sql.SQLException;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.io.IOUtils;
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.sparql.sail.KiWiSparqlSail;
-import org.apache.marmotta.kiwi.test.helper.DBConnectionChecker;
-import org.junit.*;
+import org.apache.marmotta.kiwi.test.junit.KiWiDatabaseRunner;
+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.query.*;
+import org.openrdf.query.Binding;
+import org.openrdf.query.BindingSet;
+import org.openrdf.query.QueryEvaluationException;
+import org.openrdf.query.QueryLanguage;
+import org.openrdf.query.TupleQuery;
+import org.openrdf.query.TupleQueryResult;
import org.openrdf.repository.Repository;
import org.openrdf.repository.RepositoryConnection;
import org.openrdf.repository.RepositoryException;
@@ -46,75 +55,16 @@ import org.openrdf.sail.memory.MemoryStore;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.IOException;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
/**
* Test the KiWi SPARQL Join optimization.
- *
- * <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>
* @author Sebastian Schaffert (sschaffert@apache.org)
*/
-@RunWith(Parameterized.class)
+@RunWith(KiWiDatabaseRunner.class)
public class KiWiSparqlJoinTest {
- /**
- * 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;
@@ -125,26 +75,16 @@ public class KiWiSparqlJoinTest {
// reference repository for checking if the results are the same
private Repository reference;
- public KiWiSparqlJoinTest(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();
- }
+ private final KiWiConfiguration dbConfig;
- DBConnectionChecker.checkDatabaseAvailability(jdbcUrl, jdbcUser, jdbcPass, dialect);
+ public KiWiSparqlJoinTest(KiWiConfiguration dbConfig) {
+ this.dbConfig = dbConfig;
}
@Before
public void initDatabase() throws RepositoryException, IOException, RDFParseException {
- store = new KiWiStore(new KiWiConfiguration("test",jdbcUrl,jdbcUser,jdbcPass,dialect, "http://localhost/context/default", "http://localhost/context/inferred"));
+ store = new KiWiStore(dbConfig);
ssail = new KiWiSparqlSail(store);
repository = new SailRepository(ssail);
repository.initialize();
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/36316050/libraries/kiwi/kiwi-sparql/src/test/java/org/apache/marmotta/kiwi/sparql/test/KiWiSparqlUpdateTest.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-sparql/src/test/java/org/apache/marmotta/kiwi/sparql/test/KiWiSparqlUpdateTest.java b/libraries/kiwi/kiwi-sparql/src/test/java/org/apache/marmotta/kiwi/sparql/test/KiWiSparqlUpdateTest.java
index be97b12..4e3f20e 100644
--- a/libraries/kiwi/kiwi-sparql/src/test/java/org/apache/marmotta/kiwi/sparql/test/KiWiSparqlUpdateTest.java
+++ b/libraries/kiwi/kiwi-sparql/src/test/java/org/apache/marmotta/kiwi/sparql/test/KiWiSparqlUpdateTest.java
@@ -17,123 +17,33 @@
*/
package org.apache.marmotta.kiwi.sparql.test;
-import java.util.ArrayList;
-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.sparql.sail.KiWiSparqlSail;
-import org.apache.marmotta.kiwi.test.helper.DBConnectionChecker;
-import org.junit.Assert;
-import org.junit.Rule;
-import org.junit.rules.TestWatcher;
-import org.junit.runner.Description;
+import org.apache.marmotta.kiwi.test.junit.KiWiDatabaseRunner;
import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+import org.openrdf.query.parser.sparql.SPARQLUpdateTest;
import org.openrdf.repository.Repository;
import org.openrdf.repository.sail.SailRepository;
/**
* Run the Sesame SPARQL Update Test Suite.
- * <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>
* @author Jakob Frank <ja...@apache.org>
*
*/
-@RunWith(Parameterized.class)
-public class KiWiSparqlUpdateTest extends org.openrdf.query.parser.sparql.SPARQLUpdateTest {
-
- /**
- * 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 final KiWiDialect dialect;
+@RunWith(KiWiDatabaseRunner.class)
+public class KiWiSparqlUpdateTest extends SPARQLUpdateTest {
- private final String jdbcUrl;
+ private final KiWiConfiguration config;
- private final String jdbcUser;
-
- private final String jdbcPass;
-
- @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());
- }
- };
-
- public KiWiSparqlUpdateTest(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();
- } else {
- Assert.fail("unknown database dialect: " + database);
- throw new AssertionError();
- }
-
- DBConnectionChecker.checkDatabaseAvailability(jdbcUrl, jdbcUser, jdbcPass, dialect);
+ public KiWiSparqlUpdateTest(KiWiConfiguration config) {
+ this.config = config;
}
-
+
@Override
protected Repository newRepository() throws Exception {
- KiWiStore store = new KiWiStore(new KiWiConfiguration("test",jdbcUrl,jdbcUser,jdbcPass,dialect, "http://localhost/context/default", "http://localhost/context/inferred"));
+ KiWiStore store = new KiWiStore(config);
KiWiSparqlSail ssail = new KiWiSparqlSail(store);
return new SailRepository(ssail);
}