You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2016/09/27 20:11:45 UTC
[3/6] jena git commit: JENA-1237: Tests (TDB and TIM)
JENA-1237: Tests (TDB and TIM)
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/51175d27
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/51175d27
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/51175d27
Branch: refs/heads/master
Commit: 51175d27768955ed1918b79ea7f046723e5c3173
Parents: f9f2870
Author: Andy Seaborne <an...@apache.org>
Authored: Sat Sep 17 17:03:31 2016 +0100
Committer: Andy Seaborne <an...@apache.org>
Committed: Sat Sep 17 17:11:31 2016 +0100
----------------------------------------------------------------------
.../jena/sparql/core/mem/TS_DatasetTxnMem.java | 3 +-
.../mem/TestDatasetGraphInMemoryIsolation.java | 30 +++++++++++
.../AbstractTestTransactionIsolation.java | 55 ++++++++++++++++++++
.../AbstractTestTransactionLifecycle.java | 2 -
.../tdb/transaction/TransactionManager.java | 2 +-
.../jena/tdb/transaction/TS_TransactionTDB.java | 1 +
.../tdb/transaction/TestTransIsolation.java | 32 ++++++++++++
.../jena/tdb/transaction/TestTransPromote.java | 5 +-
8 files changed, 122 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/51175d27/jena-arq/src/test/java/org/apache/jena/sparql/core/mem/TS_DatasetTxnMem.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/test/java/org/apache/jena/sparql/core/mem/TS_DatasetTxnMem.java b/jena-arq/src/test/java/org/apache/jena/sparql/core/mem/TS_DatasetTxnMem.java
index 815c8e5..f3d795b 100644
--- a/jena-arq/src/test/java/org/apache/jena/sparql/core/mem/TS_DatasetTxnMem.java
+++ b/jena-arq/src/test/java/org/apache/jena/sparql/core/mem/TS_DatasetTxnMem.java
@@ -39,6 +39,7 @@ import org.junit.runners.Suite.SuiteClasses;
TestDatasetGraphInMemoryTransactions.class,
TestDatasetGraphInMemoryFind.class,
- TestDatasetGraphInMemoryFindPattern.class
+ TestDatasetGraphInMemoryFindPattern.class,
+ TestDatasetGraphInMemoryIsolation.class
})
public class TS_DatasetTxnMem {}
http://git-wip-us.apache.org/repos/asf/jena/blob/51175d27/jena-arq/src/test/java/org/apache/jena/sparql/core/mem/TestDatasetGraphInMemoryIsolation.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/test/java/org/apache/jena/sparql/core/mem/TestDatasetGraphInMemoryIsolation.java b/jena-arq/src/test/java/org/apache/jena/sparql/core/mem/TestDatasetGraphInMemoryIsolation.java
new file mode 100644
index 0000000..12b0173
--- /dev/null
+++ b/jena-arq/src/test/java/org/apache/jena/sparql/core/mem/TestDatasetGraphInMemoryIsolation.java
@@ -0,0 +1,30 @@
+/*
+ * 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.jena.sparql.core.mem;
+
+import org.apache.jena.sparql.core.DatasetGraph ;
+import org.apache.jena.sparql.transaction.AbstractTestTransactionIsolation ;
+
+public class TestDatasetGraphInMemoryIsolation extends AbstractTestTransactionIsolation {
+
+ @Override
+ protected DatasetGraph create() {
+ return new DatasetGraphInMemory() ;
+ }
+}
http://git-wip-us.apache.org/repos/asf/jena/blob/51175d27/jena-arq/src/test/java/org/apache/jena/sparql/transaction/AbstractTestTransactionIsolation.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/test/java/org/apache/jena/sparql/transaction/AbstractTestTransactionIsolation.java b/jena-arq/src/test/java/org/apache/jena/sparql/transaction/AbstractTestTransactionIsolation.java
new file mode 100644
index 0000000..85a574f
--- /dev/null
+++ b/jena-arq/src/test/java/org/apache/jena/sparql/transaction/AbstractTestTransactionIsolation.java
@@ -0,0 +1,55 @@
+/*
+ * 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.jena.sparql.transaction;
+
+import static org.apache.jena.query.ReadWrite.* ;
+
+import org.apache.jena.atlas.iterator.Iter ;
+import org.apache.jena.sparql.core.DatasetGraph ;
+import org.apache.jena.sparql.core.Quad ;
+import org.apache.jena.sparql.sse.SSE ;
+import org.apache.jena.system.ThreadAction ;
+import org.apache.jena.system.ThreadTxn ;
+import org.junit.Assert ;
+import org.junit.Test ;
+
+/** Isolation tests */
+public abstract class AbstractTestTransactionIsolation {
+
+ protected abstract DatasetGraph create() ;
+ static Quad q1 = SSE.parseQuad("(_ :s :p 111)") ;
+
+ @Test
+ public void isolation_01() {
+ // Start a read transaction on another thread.
+ // The transaction has begin() by the time threadTxnRead
+ // returns but the action of the ThreadTxn is not triggered
+ // until other.run() is called.
+ DatasetGraph dsg = create() ;
+ ThreadAction other = ThreadTxn.threadTxnRead(dsg, ()-> {
+ long x = Iter.count(dsg.find()) ;
+ Assert.assertEquals(0, x) ;
+ }) ;
+ dsg.begin(WRITE) ;
+ dsg.add(q1) ;
+ dsg.commit() ;
+ dsg.end() ;
+ other.run() ;
+ }
+}
http://git-wip-us.apache.org/repos/asf/jena/blob/51175d27/jena-arq/src/test/java/org/apache/jena/sparql/transaction/AbstractTestTransactionLifecycle.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/test/java/org/apache/jena/sparql/transaction/AbstractTestTransactionLifecycle.java b/jena-arq/src/test/java/org/apache/jena/sparql/transaction/AbstractTestTransactionLifecycle.java
index d8b8567..32b8ca3 100644
--- a/jena-arq/src/test/java/org/apache/jena/sparql/transaction/AbstractTestTransactionLifecycle.java
+++ b/jena-arq/src/test/java/org/apache/jena/sparql/transaction/AbstractTestTransactionLifecycle.java
@@ -252,8 +252,6 @@ public abstract class AbstractTestTransactionLifecycle extends BaseTest
@Test
public void transaction_err_12() { testAbortCommit(WRITE) ; }
-
-
private void read1(Dataset ds) {
ds.begin(ReadWrite.READ) ;
assertTrue(ds.isInTransaction()) ;
http://git-wip-us.apache.org/repos/asf/jena/blob/51175d27/jena-tdb/src/main/java/org/apache/jena/tdb/transaction/TransactionManager.java
----------------------------------------------------------------------
diff --git a/jena-tdb/src/main/java/org/apache/jena/tdb/transaction/TransactionManager.java b/jena-tdb/src/main/java/org/apache/jena/tdb/transaction/TransactionManager.java
index 60c4d88..235f3b9 100644
--- a/jena-tdb/src/main/java/org/apache/jena/tdb/transaction/TransactionManager.java
+++ b/jena-tdb/src/main/java/org/apache/jena/tdb/transaction/TransactionManager.java
@@ -380,7 +380,7 @@ public class TransactionManager
synchronized
private DatasetGraphTxn promote2$(DatasetGraphTxn dsgtxn, boolean readCommited) {
Transaction txn = dsgtxn.getTransaction() ;
- // Writers may have happened between the first check of of the active writers may have committed.
+ // Writers may have happened between the first check of the active writers may have committed.
if ( txn.getVersion() != version.get() ) {
releaseWriterLock();
throw new TDBTransactionException("Active writer changed the dataset - can't promote") ;
http://git-wip-us.apache.org/repos/asf/jena/blob/51175d27/jena-tdb/src/test/java/org/apache/jena/tdb/transaction/TS_TransactionTDB.java
----------------------------------------------------------------------
diff --git a/jena-tdb/src/test/java/org/apache/jena/tdb/transaction/TS_TransactionTDB.java b/jena-tdb/src/test/java/org/apache/jena/tdb/transaction/TS_TransactionTDB.java
index 7a9d288..e1f8af4 100644
--- a/jena-tdb/src/test/java/org/apache/jena/tdb/transaction/TS_TransactionTDB.java
+++ b/jena-tdb/src/test/java/org/apache/jena/tdb/transaction/TS_TransactionTDB.java
@@ -43,6 +43,7 @@ import org.junit.runners.Suite ;
, TestTDBInternal.class
, TestTransPromote.class
, TestTransControl.class
+ , TestTransIsolation.class
})
public class TS_TransactionTDB
{
http://git-wip-us.apache.org/repos/asf/jena/blob/51175d27/jena-tdb/src/test/java/org/apache/jena/tdb/transaction/TestTransIsolation.java
----------------------------------------------------------------------
diff --git a/jena-tdb/src/test/java/org/apache/jena/tdb/transaction/TestTransIsolation.java b/jena-tdb/src/test/java/org/apache/jena/tdb/transaction/TestTransIsolation.java
new file mode 100644
index 0000000..ba2ff10
--- /dev/null
+++ b/jena-tdb/src/test/java/org/apache/jena/tdb/transaction/TestTransIsolation.java
@@ -0,0 +1,32 @@
+/*
+ * 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.jena.tdb.transaction;
+
+import org.apache.jena.sparql.core.DatasetGraph ;
+import org.apache.jena.sparql.transaction.AbstractTestTransactionIsolation ;
+import org.apache.jena.tdb.TDBFactory ;
+
+public class TestTransIsolation extends AbstractTestTransactionIsolation {
+
+ @Override
+ protected DatasetGraph create() {
+ return TDBFactory.createDatasetGraph() ;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/jena/blob/51175d27/jena-tdb/src/test/java/org/apache/jena/tdb/transaction/TestTransPromote.java
----------------------------------------------------------------------
diff --git a/jena-tdb/src/test/java/org/apache/jena/tdb/transaction/TestTransPromote.java b/jena-tdb/src/test/java/org/apache/jena/tdb/transaction/TestTransPromote.java
index 1d1d686..5e62924 100644
--- a/jena-tdb/src/test/java/org/apache/jena/tdb/transaction/TestTransPromote.java
+++ b/jena-tdb/src/test/java/org/apache/jena/tdb/transaction/TestTransPromote.java
@@ -45,7 +45,7 @@ public class TestTransPromote {
// Currently,
// this feature is off and needs enabling via DatasetGraphTransaction.promotion
- // promotiion is implicit whe a write happens.
+ // promotion is implicit when a write happens.
// See beforeClass / afterClass.
@@ -62,9 +62,6 @@ public class TestTransPromote {
stdReadCommitted = DatasetGraphTransaction.readCommittedPromotion ;
level1 = logger1.getLevel() ;
level2 = logger2.getLevel() ;
-
- // logger1.setLevel(Level.ERROR) ;
- // logger2.setLevel(Level.ERROR) ;
}
@AfterClass