You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by rv...@apache.org on 2013/04/04 01:26:54 UTC
svn commit: r1464235 - in /jena/Experimental/jena-jdbc:
jena-jdbc-core/src/main/java/org/apache/jena/jdbc/connections/
jena-jdbc-core/src/main/java/org/apache/jena/jdbc/metadata/
jena-jdbc-core/src/main/java/org/apache/jena/jdbc/statements/ jena-jdbc-c...
Author: rvesse
Date: Wed Apr 3 23:26:53 2013
New Revision: 1464235
URL: http://svn.apache.org/r1464235
Log:
Start adding tests for transaction support, fix a bug with executeUpdate() not starting new transactions as required when used with auto-commit disabled
Added:
jena/Experimental/jena-jdbc/jena-jdbc-driver-tdb/src/test/java/org/apache/jena/jdbc/tdb/connections/
jena/Experimental/jena-jdbc/jena-jdbc-driver-tdb/src/test/java/org/apache/jena/jdbc/tdb/connections/DebugTdbConnection.java
jena/Experimental/jena-jdbc/jena-jdbc-driver-tdb/src/test/java/org/apache/jena/jdbc/tdb/connections/TestJenaJdbcTdbDiskConnection.java
jena/Experimental/jena-jdbc/jena-jdbc-driver-tdb/src/test/java/org/apache/jena/jdbc/tdb/connections/TestJenaJdbcTdbMemConnection.java
Removed:
jena/Experimental/jena-jdbc/jena-jdbc-driver-tdb/src/test/java/org/apache/jena/jdbc/tdb/DebugTdbConnection.java
jena/Experimental/jena-jdbc/jena-jdbc-driver-tdb/src/test/java/org/apache/jena/jdbc/tdb/TestJenaJdbcTdbDiskConnection.java
jena/Experimental/jena-jdbc/jena-jdbc-driver-tdb/src/test/java/org/apache/jena/jdbc/tdb/TestJenaJdbcTdbMemConnection.java
Modified:
jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/connections/DatasetConnection.java
jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/metadata/DatasetMetadata.java
jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/statements/JenaJdbcStatement.java
jena/Experimental/jena-jdbc/jena-jdbc-core/src/test/java/org/apache/jena/jdbc/connections/AbstractJenaConnectionTests.java
jena/Experimental/jena-jdbc/jena-jdbc-driver-tdb/src/main/java/org/apache/jena/jdbc/tdb/TDBDriver.java
jena/Experimental/jena-jdbc/jena-jdbc-driver-tdb/src/main/java/org/apache/jena/jdbc/tdb/metadata/TDBDatasetMetadata.java
jena/Experimental/jena-jdbc/jena-jdbc-driver-tdb/src/test/java/org/apache/jena/jdbc/tdb/results/AbstractTdbResultSetTests.java
Modified: jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/connections/DatasetConnection.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/connections/DatasetConnection.java?rev=1464235&r1=1464234&r2=1464235&view=diff
==============================================================================
--- jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/connections/DatasetConnection.java (original)
+++ jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/connections/DatasetConnection.java Wed Apr 3 23:26:53 2013
@@ -150,6 +150,7 @@ public abstract class DatasetConnection
try {
if (ds.isInTransaction()) {
ds.commit();
+ ds.end();
}
} catch (Exception e) {
throw new SQLException("Unexpected error committing the transaction", e);
@@ -161,6 +162,7 @@ public abstract class DatasetConnection
try {
if (ds.isInTransaction()) {
ds.abort();
+ ds.end();
}
} catch (Exception e) {
throw new SQLException("Unexpected error rolling back the transaction", e);
Modified: jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/metadata/DatasetMetadata.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/metadata/DatasetMetadata.java?rev=1464235&r1=1464234&r2=1464235&view=diff
==============================================================================
--- jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/metadata/DatasetMetadata.java (original)
+++ jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/metadata/DatasetMetadata.java Wed Apr 3 23:26:53 2013
@@ -18,6 +18,7 @@
package org.apache.jena.jdbc.metadata;
+import java.sql.Connection;
import java.sql.SQLException;
import org.apache.jena.jdbc.connections.DatasetConnection;
@@ -37,5 +38,22 @@ public abstract class DatasetMetadata ex
super(connection);
}
+ @Override
+ public boolean supportsTransactionIsolationLevel(int level) throws SQLException {
+ // Dataset connections can support None or Serializable transactions
+ switch (level) {
+ case Connection.TRANSACTION_NONE:
+ return true;
+ case Connection.TRANSACTION_SERIALIZABLE:
+ return this.supportsTransactions();
+ default:
+ return false;
+ }
+ }
+ @Override
+ public boolean supportsTransactions() throws SQLException {
+ // Transactions are only supported if the underlying dataset supports them
+ return ((DatasetConnection)this.getConnection()).getJenaDataset().supportsTransactions();
+ }
}
Modified: jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/statements/JenaJdbcStatement.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/statements/JenaJdbcStatement.java?rev=1464235&r1=1464234&r2=1464235&view=diff
==============================================================================
--- jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/statements/JenaJdbcStatement.java (original)
+++ jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/statements/JenaJdbcStatement.java Wed Apr 3 23:26:53 2013
@@ -270,12 +270,15 @@ public abstract class JenaJdbcStatement
throw new SQLException("The Statement is closed");
if (this.connection.isReadOnly())
throw new SQLException("The JDBC connection is currently in read-only mode, updates are not permitted");
+
+ // Do we need transactions?
+ boolean needsBegin = (!this.autoCommit && this.transactionLevel != Connection.TRANSACTION_NONE && !this.hasActiveTransaction());
+ boolean needsCommit = (this.autoCommit && this.transactionLevel != Connection.TRANSACTION_NONE);
boolean commit = false;
try {
- // TODO Handle the case where auto-commit is off but transactions
- // are on
- if (this.autoCommit && this.transactionLevel != Connection.TRANSACTION_NONE) {
+ // Start a Transaction if necessary
+ if (needsCommit || needsBegin) {
this.beginTransaction(ReadWrite.WRITE);
}
@@ -288,7 +291,7 @@ public abstract class JenaJdbcStatement
} catch (Exception e) {
throw new SQLException("Error occurred during SPARQL update evaluation", e);
} finally {
- if (this.autoCommit && this.transactionLevel != Connection.TRANSACTION_NONE) {
+ if (needsCommit) {
if (commit) {
this.commitTransaction();
} else {
@@ -508,10 +511,11 @@ public abstract class JenaJdbcStatement
protected void checkHoldability(int h) throws SQLException {
switch (h) {
case ResultSet.CLOSE_CURSORS_AT_COMMIT:
+ case ResultSet.HOLD_CURSORS_OVER_COMMIT:
return;
default:
throw new SQLException(
- "Invalid holdability, only ResultSet.CLOSE_CURSORS_AT_COMMIT is supported for Jena JDBC statements");
+ String.format("Holdability %d is supported for Jena JDBC statements", h));
}
}
Modified: jena/Experimental/jena-jdbc/jena-jdbc-core/src/test/java/org/apache/jena/jdbc/connections/AbstractJenaConnectionTests.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-jdbc/jena-jdbc-core/src/test/java/org/apache/jena/jdbc/connections/AbstractJenaConnectionTests.java?rev=1464235&r1=1464234&r2=1464235&view=diff
==============================================================================
--- jena/Experimental/jena-jdbc/jena-jdbc-core/src/test/java/org/apache/jena/jdbc/connections/AbstractJenaConnectionTests.java (original)
+++ jena/Experimental/jena-jdbc/jena-jdbc-core/src/test/java/org/apache/jena/jdbc/connections/AbstractJenaConnectionTests.java Wed Apr 3 23:26:53 2013
@@ -17,6 +17,7 @@
*/
package org.apache.jena.jdbc.connections;
+import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
@@ -30,6 +31,7 @@ import org.apache.log4j.BasicConfigurato
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.junit.Assert;
+import org.junit.Assume;
import org.junit.Test;
import com.hp.hpl.jena.graph.Node;
@@ -566,7 +568,176 @@ public abstract class AbstractJenaConnec
}
}
+ /**
+ * Does a basic read transaction
+ * @throws SQLException
+ */
+ @Test
public void connection_transactions_01() throws SQLException {
+ // Set up connection
+ JenaConnection conn = this.getConnection(DatasetFactory.createMem());
+ Assume.assumeNotNull(conn.getMetaData());
+ Assume.assumeTrue(conn.getMetaData().supportsTransactions());
+ conn.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);
+ conn.setAutoCommit(true);
+
+ // Make a read operation
+ Statement stmt = conn.createStatement();
+ ResultSet rset = stmt.executeQuery("SELECT * WHERE { ?s ?p ?o }");
+ Assert.assertNotNull(rset);
+ Assert.assertFalse(rset.isClosed());
+ Assert.assertTrue(rset.isBeforeFirst());
+
+ // Should have no rows
+ Assert.assertFalse(rset.next());
+ Assert.assertTrue(rset.isAfterLast());
+
+ // Close things
+ rset.close();
+ Assert.assertTrue(rset.isClosed());
+ stmt.close();
+ Assert.assertTrue(stmt.isClosed());
+ conn.close();
+ Assert.assertTrue(conn.isClosed());
+ }
+
+ /**
+ * Does a basic write transaction
+ * @throws SQLException
+ */
+ @Test
+ public void connection_transactions_02() throws SQLException {
+ // Set up connection
+ JenaConnection conn = this.getConnection(DatasetFactory.createMem());
+ Assume.assumeNotNull(conn.getMetaData());
+ Assume.assumeTrue(conn.getMetaData().supportsTransactions());
+ conn.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);
+ conn.setAutoCommit(true);
+ conn.setHoldability(ResultSet.HOLD_CURSORS_OVER_COMMIT);
+ // Make a write operation
+ Statement stmt = conn.createStatement();
+ stmt.executeUpdate("INSERT DATA { <http://x> <http://y> <http://z> }");
+
+ // Make a subsequent read, with auto-commit we should see some data
+ ResultSet rset = stmt.executeQuery("SELECT * WHERE { ?s ?p ?o }");
+ Assert.assertNotNull(rset);
+ Assert.assertFalse(rset.isClosed());
+ Assert.assertTrue(rset.isBeforeFirst());
+
+ // Should have one row
+ Assert.assertTrue(rset.next());
+ Assert.assertFalse(rset.next());
+
+ // Close things
+ rset.close();
+ Assert.assertTrue(rset.isClosed());
+ stmt.close();
+ Assert.assertTrue(stmt.isClosed());
+ conn.close();
+ Assert.assertTrue(conn.isClosed());
+ }
+
+ /**
+ * Does a basic write transaction without auto-commit and then commits it
+ * @throws SQLException
+ */
+ @Test
+ public void connection_transactions_03() throws SQLException {
+ // Set up connection
+ JenaConnection conn = this.getConnection(DatasetFactory.createMem());
+ Assume.assumeNotNull(conn.getMetaData());
+ Assume.assumeTrue(conn.getMetaData().supportsTransactions());
+ conn.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);
+ conn.setAutoCommit(false);
+ conn.setHoldability(ResultSet.HOLD_CURSORS_OVER_COMMIT);
+
+ // Make a write operation
+ Statement stmt = conn.createStatement();
+ stmt.executeUpdate("INSERT DATA { <http://x> <http://y> <http://z> }");
+
+ // Make a subsequent read, with auto-commit we should see some data
+ ResultSet rset = stmt.executeQuery("SELECT * WHERE { ?s ?p ?o }");
+ Assert.assertNotNull(rset);
+ Assert.assertFalse(rset.isClosed());
+ Assert.assertTrue(rset.isBeforeFirst());
+
+ // Should have one row
+ Assert.assertTrue(rset.next());
+ Assert.assertFalse(rset.next());
+ rset.close();
+ Assert.assertTrue(rset.isClosed());
+
+ // Commit the transaction
+ conn.commit();
+
+ // Check we still can read the data
+ rset = stmt.executeQuery("SELECT * WHERE { ?s ?p ?o }");
+ Assert.assertNotNull(rset);
+ Assert.assertFalse(rset.isClosed());
+ Assert.assertTrue(rset.isBeforeFirst());
+
+ // Should have one row
+ Assert.assertTrue(rset.next());
+ Assert.assertFalse(rset.next());
+ rset.close();
+ Assert.assertTrue(rset.isClosed());
+
+ // Close things
+ stmt.close();
+ Assert.assertTrue(stmt.isClosed());
+ conn.close();
+ Assert.assertTrue(conn.isClosed());
+ }
+
+ /**
+ * Does a basic write transaction without auto-commit and then rolls it back
+ * @throws SQLException
+ */
+ @Test
+ public void connection_transactions_04() throws SQLException {
+ // Set up connection
+ JenaConnection conn = this.getConnection(DatasetFactory.createMem());
+ Assume.assumeNotNull(conn.getMetaData());
+ Assume.assumeTrue(conn.getMetaData().supportsTransactions());
+ conn.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);
+ conn.setAutoCommit(false);
+ conn.setHoldability(ResultSet.HOLD_CURSORS_OVER_COMMIT);
+
+ // Make a write operation
+ Statement stmt = conn.createStatement();
+ stmt.executeUpdate("INSERT DATA { <http://x> <http://y> <http://z> }");
+
+ // Make a subsequent read, with auto-commit we should see some data
+ ResultSet rset = stmt.executeQuery("SELECT * WHERE { ?s ?p ?o }");
+ Assert.assertNotNull(rset);
+ Assert.assertFalse(rset.isClosed());
+ Assert.assertTrue(rset.isBeforeFirst());
+
+ // Should have one row
+ Assert.assertTrue(rset.next());
+ Assert.assertFalse(rset.next());
+ rset.close();
+ Assert.assertTrue(rset.isClosed());
+
+ // Rollback the transaction
+ conn.rollback();
+
+ // Check we can no longer read the data
+ rset = stmt.executeQuery("SELECT * WHERE { ?s ?p ?o }");
+ Assert.assertNotNull(rset);
+ Assert.assertFalse(rset.isClosed());
+ Assert.assertTrue(rset.isBeforeFirst());
+
+ // Should have no rows
+ Assert.assertFalse(rset.next());
+ rset.close();
+ Assert.assertTrue(rset.isClosed());
+
+ // Close things
+ stmt.close();
+ Assert.assertTrue(stmt.isClosed());
+ conn.close();
+ Assert.assertTrue(conn.isClosed());
}
}
Modified: jena/Experimental/jena-jdbc/jena-jdbc-driver-tdb/src/main/java/org/apache/jena/jdbc/tdb/TDBDriver.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-jdbc/jena-jdbc-driver-tdb/src/main/java/org/apache/jena/jdbc/tdb/TDBDriver.java?rev=1464235&r1=1464234&r2=1464235&view=diff
==============================================================================
--- jena/Experimental/jena-jdbc/jena-jdbc-driver-tdb/src/main/java/org/apache/jena/jdbc/tdb/TDBDriver.java (original)
+++ jena/Experimental/jena-jdbc/jena-jdbc-driver-tdb/src/main/java/org/apache/jena/jdbc/tdb/TDBDriver.java Wed Apr 3 23:26:53 2013
@@ -53,8 +53,8 @@ import com.hp.hpl.jena.tdb.TDBFactory;
* already exist.
* </p>
* <p>
- * Currently TDB is not used in transactional mode, this will be changed in the
- * near future
+ * Connections to TDB always support transactions and operate in auto-commit
+ * mode by default.
* </p>
*/
public class TDBDriver extends JenaDriver {
Modified: jena/Experimental/jena-jdbc/jena-jdbc-driver-tdb/src/main/java/org/apache/jena/jdbc/tdb/metadata/TDBDatasetMetadata.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-jdbc/jena-jdbc-driver-tdb/src/main/java/org/apache/jena/jdbc/tdb/metadata/TDBDatasetMetadata.java?rev=1464235&r1=1464234&r2=1464235&view=diff
==============================================================================
--- jena/Experimental/jena-jdbc/jena-jdbc-driver-tdb/src/main/java/org/apache/jena/jdbc/tdb/metadata/TDBDatasetMetadata.java (original)
+++ jena/Experimental/jena-jdbc/jena-jdbc-driver-tdb/src/main/java/org/apache/jena/jdbc/tdb/metadata/TDBDatasetMetadata.java Wed Apr 3 23:26:53 2013
@@ -18,6 +18,7 @@
package org.apache.jena.jdbc.tdb.metadata;
+import java.sql.Connection;
import java.sql.SQLException;
import org.apache.jena.jdbc.JenaJDBC;
@@ -106,4 +107,21 @@ public class TDBDatasetMetadata extends
return true;
}
+ @Override
+ public boolean supportsTransactionIsolationLevel(int level) throws SQLException {
+ // TDB supports Serializable transactions
+ switch (level) {
+ case Connection.TRANSACTION_SERIALIZABLE:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ @Override
+ public boolean supportsTransactions() throws SQLException {
+ // TDB supports transactions
+ return true;
+ }
+
}
Added: jena/Experimental/jena-jdbc/jena-jdbc-driver-tdb/src/test/java/org/apache/jena/jdbc/tdb/connections/DebugTdbConnection.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-jdbc/jena-jdbc-driver-tdb/src/test/java/org/apache/jena/jdbc/tdb/connections/DebugTdbConnection.java?rev=1464235&view=auto
==============================================================================
--- jena/Experimental/jena-jdbc/jena-jdbc-driver-tdb/src/test/java/org/apache/jena/jdbc/tdb/connections/DebugTdbConnection.java (added)
+++ jena/Experimental/jena-jdbc/jena-jdbc-driver-tdb/src/test/java/org/apache/jena/jdbc/tdb/connections/DebugTdbConnection.java Wed Apr 3 23:26:53 2013
@@ -0,0 +1,59 @@
+/**
+ * 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.jdbc.tdb.connections;
+
+import java.sql.SQLException;
+
+import org.apache.jena.jdbc.connections.JenaConnection;
+import org.apache.jena.jdbc.tdb.connections.TDBConnection;
+
+import com.hp.hpl.jena.query.Dataset;
+import com.hp.hpl.jena.query.DatasetFactory;
+
+/**
+ * A test only variant of {@link TDBConnection} which allows the dataset to be changed on the fly
+ *
+ */
+public class DebugTdbConnection extends TDBConnection {
+
+ /**
+ * Creates a debug dataset connection
+ * @throws SQLException
+ */
+ public DebugTdbConnection() throws SQLException {
+ this(DatasetFactory.createMem());
+ }
+
+ /**
+ * Creates a debug dataset connection
+ * @param ds Dataset
+ * @throws SQLException
+ */
+ public DebugTdbConnection(Dataset ds) throws SQLException {
+ super(ds, JenaConnection.DEFAULT_HOLDABILITY);
+ }
+
+ /**
+ * Sets the Jena dataset in use
+ * @param ds Dataset
+ */
+ public void setJenaDataset(Dataset ds) {
+ this.ds = ds;
+ }
+}
Added: jena/Experimental/jena-jdbc/jena-jdbc-driver-tdb/src/test/java/org/apache/jena/jdbc/tdb/connections/TestJenaJdbcTdbDiskConnection.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-jdbc/jena-jdbc-driver-tdb/src/test/java/org/apache/jena/jdbc/tdb/connections/TestJenaJdbcTdbDiskConnection.java?rev=1464235&view=auto
==============================================================================
--- jena/Experimental/jena-jdbc/jena-jdbc-driver-tdb/src/test/java/org/apache/jena/jdbc/tdb/connections/TestJenaJdbcTdbDiskConnection.java (added)
+++ jena/Experimental/jena-jdbc/jena-jdbc-driver-tdb/src/test/java/org/apache/jena/jdbc/tdb/connections/TestJenaJdbcTdbDiskConnection.java Wed Apr 3 23:26:53 2013
@@ -0,0 +1,58 @@
+/**
+ * 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.jdbc.tdb.connections;
+
+import java.sql.SQLException;
+
+import org.apache.jena.jdbc.connections.AbstractJenaConnectionTests;
+import org.apache.jena.jdbc.connections.DatasetConnection;
+import org.apache.jena.jdbc.connections.JenaConnection;
+import org.apache.jena.jdbc.tdb.connections.TDBConnection;
+import org.apache.jena.jdbc.utils.TestUtils;
+import org.junit.Rule;
+import org.junit.rules.TemporaryFolder;
+
+import com.hp.hpl.jena.query.Dataset;
+import com.hp.hpl.jena.tdb.TDBFactory;
+
+/**
+ * Tests for the {@link DatasetConnection} backed by a purely in-memory testing only TDB dataset
+ *
+ */
+public class TestJenaJdbcTdbDiskConnection extends AbstractJenaConnectionTests {
+
+ /**
+ * Temporary directory rule used to guarantee a unique temporary folder for each test method
+ */
+ @Rule
+ public TemporaryFolder tempDir = new TemporaryFolder();
+
+ @Override
+ protected JenaConnection getConnection() throws SQLException {
+ return new TDBConnection(TDBFactory.createDataset(tempDir.getRoot().getAbsolutePath()), JenaConnection.DEFAULT_HOLDABILITY);
+ }
+
+ @Override
+ protected JenaConnection getConnection(Dataset ds) throws SQLException {
+ Dataset tdb = TDBFactory.createDataset(tempDir.getRoot().getAbsolutePath());
+ TestUtils.copyDataset(ds, tdb, true);
+ return new TDBConnection(tdb, JenaConnection.DEFAULT_HOLDABILITY);
+ }
+
+}
Added: jena/Experimental/jena-jdbc/jena-jdbc-driver-tdb/src/test/java/org/apache/jena/jdbc/tdb/connections/TestJenaJdbcTdbMemConnection.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-jdbc/jena-jdbc-driver-tdb/src/test/java/org/apache/jena/jdbc/tdb/connections/TestJenaJdbcTdbMemConnection.java?rev=1464235&view=auto
==============================================================================
--- jena/Experimental/jena-jdbc/jena-jdbc-driver-tdb/src/test/java/org/apache/jena/jdbc/tdb/connections/TestJenaJdbcTdbMemConnection.java (added)
+++ jena/Experimental/jena-jdbc/jena-jdbc-driver-tdb/src/test/java/org/apache/jena/jdbc/tdb/connections/TestJenaJdbcTdbMemConnection.java Wed Apr 3 23:26:53 2013
@@ -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.jena.jdbc.tdb.connections;
+
+import java.sql.SQLException;
+
+import org.apache.jena.jdbc.connections.AbstractJenaConnectionTests;
+import org.apache.jena.jdbc.connections.DatasetConnection;
+import org.apache.jena.jdbc.connections.JenaConnection;
+import org.apache.jena.jdbc.tdb.connections.TDBConnection;
+import org.apache.jena.jdbc.utils.TestUtils;
+
+import com.hp.hpl.jena.query.Dataset;
+import com.hp.hpl.jena.tdb.TDBFactory;
+
+/**
+ * Tests for the {@link DatasetConnection} backed by a purely in-memory testing only TDB dataset
+ *
+ */
+public class TestJenaJdbcTdbMemConnection extends AbstractJenaConnectionTests {
+
+ @Override
+ protected JenaConnection getConnection() throws SQLException {
+ return new TDBConnection(TDBFactory.createDataset(), JenaConnection.DEFAULT_HOLDABILITY);
+ }
+
+ @Override
+ protected JenaConnection getConnection(Dataset ds) throws SQLException {
+ Dataset tdb = TDBFactory.createDataset();
+ TestUtils.copyDataset(ds, tdb, true);
+ return new TDBConnection(tdb, JenaConnection.DEFAULT_HOLDABILITY);
+ }
+
+}
Modified: jena/Experimental/jena-jdbc/jena-jdbc-driver-tdb/src/test/java/org/apache/jena/jdbc/tdb/results/AbstractTdbResultSetTests.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-jdbc/jena-jdbc-driver-tdb/src/test/java/org/apache/jena/jdbc/tdb/results/AbstractTdbResultSetTests.java?rev=1464235&r1=1464234&r2=1464235&view=diff
==============================================================================
--- jena/Experimental/jena-jdbc/jena-jdbc-driver-tdb/src/test/java/org/apache/jena/jdbc/tdb/results/AbstractTdbResultSetTests.java (original)
+++ jena/Experimental/jena-jdbc/jena-jdbc-driver-tdb/src/test/java/org/apache/jena/jdbc/tdb/results/AbstractTdbResultSetTests.java Wed Apr 3 23:26:53 2013
@@ -23,7 +23,7 @@ import java.sql.SQLException;
import java.sql.Statement;
import org.apache.jena.jdbc.results.AbstractResultSetTests;
-import org.apache.jena.jdbc.tdb.DebugTdbConnection;
+import org.apache.jena.jdbc.tdb.connections.DebugTdbConnection;
import org.junit.AfterClass;
import org.junit.BeforeClass;