drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From par...@apache.org
Subject [07/11] drill git commit: DRILL-2782: 2-Core: Decide, implement behavior for transaction-related JDBC methods.
Date Fri, 24 Apr 2015 23:22:42 GMT
DRILL-2782: 2-Core:  Decide, implement behavior for transaction-related JDBC methods.

- Added unit test.
- Added implementations of transaction-related methods:
  - setAutoCommit - reject attempt to turn auto-commit off
  - commit - reject when in auto-commit mode (which is always)
  - rollback - reject when in auto-commit mode (which is always)
  - other mode and metadata methods - roughly, report "no transactions"
- Added method declarations with doc. comments in Drill-specific interface.
- Overrode SQLLine's default transaction isolation level to Drill's
  TRANSACTION_NONE.


Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/ce9fc3af
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/ce9fc3af
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/ce9fc3af

Branch: refs/heads/master
Commit: ce9fc3af45dfa047bc05d2a009c7f09b6b501d00
Parents: 6e477e2
Author: dbarclay <dbarclay@maprtech.com>
Authored: Tue Apr 14 16:13:23 2015 -0700
Committer: Parth Chandra <pchandra@maprtech.com>
Committed: Fri Apr 24 16:21:54 2015 -0700

----------------------------------------------------------------------
 distribution/src/resources/sqlline              |   8 +
 distribution/src/resources/sqlline.bat          |   7 +
 .../org/apache/drill/jdbc/DrillConnection.java  | 116 +++++++++++++
 .../apache/drill/jdbc/DrillConnectionImpl.java  | 109 ++++++++++++
 .../jdbc/ConnectionTransactionMethodsTest.java  | 168 +++++++++++++++++++
 .../apache/drill/jdbc/DatabaseMetaDataTest.java |  86 ++++++++++
 6 files changed, 494 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/ce9fc3af/distribution/src/resources/sqlline
----------------------------------------------------------------------
diff --git a/distribution/src/resources/sqlline b/distribution/src/resources/sqlline
old mode 100755
new mode 100644
index 0852fba..48a5169
--- a/distribution/src/resources/sqlline
+++ b/distribution/src/resources/sqlline
@@ -34,8 +34,16 @@ bin=`cd "$bin">/dev/null; pwd`
 
 . "$bin"/drill-config.sh
 
+# Override SQLLine's default initial transaction isolation level.  (SQLLine
+# sets an initial level instead of leaving it at whatever the Driver's default
+# is.) 
+# Put our property specification before previous value of DRILL_SHELL_JAVA_OPTS
+# so that it can still be overridden via DRILL_SHELL_JAVA_OPTS.
+DRILL_SHELL_JAVA_OPTS="-Dsqlline.isolation=TRANSACTION_NONE $DRILL_SHELL_JAVA_OPTS"
+
 DRILL_SHELL_JAVA_OPTS="$DRILL_SHELL_JAVA_OPTS -Dlog.path=$DRILL_LOG_DIR/sqlline.log"
 
+
 if [ -n "$QUERY" ] ; then
   echo $QUERY | exec "$JAVA" $DRILL_SHELL_JAVA_OPTS $DRILL_JAVA_OPTS -cp $CP sqlline.SqlLine
-d org.apache.drill.jdbc.Driver  --maxWidth=10000 "${ARGS[@]}"
 elif [ -n "$FILE" ] ; then

http://git-wip-us.apache.org/repos/asf/drill/blob/ce9fc3af/distribution/src/resources/sqlline.bat
----------------------------------------------------------------------
diff --git a/distribution/src/resources/sqlline.bat b/distribution/src/resources/sqlline.bat
index 755526c..2564b8c 100755
--- a/distribution/src/resources/sqlline.bat
+++ b/distribution/src/resources/sqlline.bat
@@ -169,6 +169,13 @@ set DRILL_CP=%DRILL_CP%;%DRILL_HOME%\jars\3rdparty\*
 set DRILL_CP=%DRILL_CP%;%DRILL_HOME%\jars\classb\*
 if NOT "test%DRILL_CLASSPATH%"=="test" set DRILL_CP=!DRILL_CP!;%DRILL_CLASSPATH%
 
+rem Override SQLLine's default initial transaction isolation level.  (SQLLine
+rem sets an initial level instead of leaving it at whatever the Driver's default
+rem is.) 
+rem Put our property specification before previous value of DRILL_SHELL_JAVA_OPTS
+rem so that it can still be overridden via DRILL_SHELL_JAVA_OPTS.
+set DRILL_SHELL_JAVA_OPTS=-Dsqlline.isolation=TRANSACTION_NONE %DRILL_SHELL_JAVA_OPTS%
+
 set DRILL_SHELL_JAVA_OPTS=%DRILL_SHELL_JAVA_OPTS% -Dlog.path="%DRILL_LOG_DIR%\sqlline.log"
 
 SET JAVA_CMD=%JAVA_HOME%\bin\%JAVA_EXE%

http://git-wip-us.apache.org/repos/asf/drill/blob/ce9fc3af/exec/jdbc/src/main/java/org/apache/drill/jdbc/DrillConnection.java
----------------------------------------------------------------------
diff --git a/exec/jdbc/src/main/java/org/apache/drill/jdbc/DrillConnection.java b/exec/jdbc/src/main/java/org/apache/drill/jdbc/DrillConnection.java
index 6bacaad..33acb42 100644
--- a/exec/jdbc/src/main/java/org/apache/drill/jdbc/DrillConnection.java
+++ b/exec/jdbc/src/main/java/org/apache/drill/jdbc/DrillConnection.java
@@ -20,6 +20,8 @@ package org.apache.drill.jdbc;
 
 import java.sql.Connection;
 import java.sql.SQLException;
+import java.sql.SQLFeatureNotSupportedException;
+import java.sql.Savepoint;
 
 import org.apache.drill.exec.client.DrillClient;
 
@@ -30,6 +32,120 @@ import org.apache.drill.exec.client.DrillClient;
  */
 public interface DrillConnection extends Connection {
 
+
+  /**
+   * {@inheritDoc}
+   * <p>
+   *   <strong>Drill</strong>:
+   *   Drill's implementation accepts {@code DrillConnection.class}.
+   * </p>
+   */
+  @Override
+  <T> T unwrap(Class<T> iface) throws SQLException;
+
+  /**
+   * {@inheritDoc}
+   * <p>
+   *   <strong>Drill</strong>:
+   *   Drill's implementation returns true for {@code DrillConnection.class}.
+   * </p>
+   */
+  @Override
+  boolean isWrapperFor(Class<?> iface) throws SQLException;
+
+
+  /**
+   * {@inheritDoc}
+   * <p>
+   *   <strong>Drill</strong>:
+   *   Accepts only {@code true}.
+   * </p>
+   * @throws SQLFeatureNotSupportedException if called with {@code false}
+   */
+  @Override
+  void setAutoCommit(boolean autoCommit) throws SQLFeatureNotSupportedException,
+                                                SQLException;
+  /**
+   * {@inheritDoc}
+   * <p>
+   *   <strong>Drill</strong>:
+   *   Drill's implementation always returns {@code true}.
+   * </p>
+   */
+  @Override
+  boolean getAutoCommit() throws SQLException;
+
+
+  /**
+   * Not supported.  Always throws {@link SQLFeatureNotSupportedException} (or
+   * {@link AlreadyClosedSqlException})..
+   */
+  @Override
+  void commit() throws SQLException;
+
+
+  /**
+   * Not supported.  Always throws {@link SQLFeatureNotSupportedException} (or
+   * {@link AlreadyClosedSqlException}).
+   */
+  @Override
+  void rollback() throws SQLException;
+
+
+  /**
+   * {@inheritDoc}
+   * <p>
+   *   <strong>Drill</strong>:
+   *   Accepts only {@link Connection.TRANSACTION_NONE}.
+   * </p>
+   *
+   * @throws SQLFeatureNotSupportedException if {@code level} is not
+   * {@link Connection.TRANSACTION_NONE}.
+   */
+  @Override
+  void setTransactionIsolation(int level) throws SQLFeatureNotSupportedException,
+                                                 SQLException;
+
+  /**
+   * {@inheritDoc}
+   * <p>
+   *   <strong>Drill</strong>:
+   *   Drill's implementation always returns {@link Connection#TRANSACTION_NONE}.
+   * </p>
+   */
+  @Override
+  int getTransactionIsolation() throws SQLException;
+
+
+  /**
+   * Not supported.  Always throws {@link SQLFeatureNotSupportedException} (or
+   * {@link AlreadyClosedSqlException}).
+   */
+  @Override
+  Savepoint setSavepoint() throws SQLException;
+
+  /**
+   * Not supported.  Always throws {@link SQLFeatureNotSupportedException} (or
+   * {@link AlreadyClosedSqlException}).
+   */
+  @Override
+  Savepoint setSavepoint(String name) throws SQLException;
+
+  /**
+   * Not supported.  Always throws {@link SQLFeatureNotSupportedException} (or
+   * {@link AlreadyClosedSqlException}).
+   */
+  @Override
+  void rollback(Savepoint savepoint) throws SQLException;
+
+  /**
+   * Not supported.  Always throws {@link SQLFeatureNotSupportedException} (or
+   * {@link AlreadyClosedSqlException}).
+   */
+  @Override
+  void releaseSavepoint(Savepoint savepoint) throws SQLException;
+
+
   // In java.sql.Connection from JDK 1.7, but declared here to allow other JDKs.
   void setSchema(String schema) throws SQLException;
 

http://git-wip-us.apache.org/repos/asf/drill/blob/ce9fc3af/exec/jdbc/src/main/java/org/apache/drill/jdbc/DrillConnectionImpl.java
----------------------------------------------------------------------
diff --git a/exec/jdbc/src/main/java/org/apache/drill/jdbc/DrillConnectionImpl.java b/exec/jdbc/src/main/java/org/apache/drill/jdbc/DrillConnectionImpl.java
index 79852a0..7c690d8 100644
--- a/exec/jdbc/src/main/java/org/apache/drill/jdbc/DrillConnectionImpl.java
+++ b/exec/jdbc/src/main/java/org/apache/drill/jdbc/DrillConnectionImpl.java
@@ -20,6 +20,8 @@ package org.apache.drill.jdbc;
 import java.io.IOException;
 import java.sql.PreparedStatement;
 import java.sql.SQLException;
+import java.sql.SQLFeatureNotSupportedException;
+import java.sql.Savepoint;
 import java.util.Properties;
 import java.util.TimeZone;
 
@@ -61,6 +63,11 @@ public abstract class DrillConnectionImpl extends AvaticaConnection
 
   protected DrillConnectionImpl(Driver driver, AvaticaFactory factory, String url, Properties
info) throws SQLException {
     super(driver, factory, url, info);
+
+    // Initialize transaction-related settings per Drill behavior.
+    super.setTransactionIsolation( TRANSACTION_NONE );
+    super.setAutoCommit( true );
+
     this.config = new DrillConnectionConfig(info);
 
     try {
@@ -149,6 +156,108 @@ public abstract class DrillConnectionImpl extends AvaticaConnection
   }
 
   @Override
+  public void setAutoCommit( boolean autoCommit ) throws SQLException {
+    checkNotClosed();
+    if ( ! autoCommit ) {
+      throw new SQLFeatureNotSupportedException(
+          "Can't turn off auto-committing; transactions are not supported.  "
+          + "(Drill is not transactional.)" );
+    }
+    assert getAutoCommit() : "getAutoCommit() = " + getAutoCommit();
+  }
+
+  @Override
+  public void commit() throws SQLException  {
+    checkNotClosed();
+    if ( getAutoCommit()  ) {
+      throw new JdbcApiSqlException( "Can't call commit() in auto-commit mode." );
+    }
+    else {
+      // (Currently not reachable.)
+      throw new SQLFeatureNotSupportedException(
+          "Connection.commit() is not supported.  (Drill is not transactional.)" );
+    }
+  }
+
+  @Override
+  public void rollback() throws SQLException {
+    checkNotClosed();
+    if ( getAutoCommit()  ) {
+      throw new JdbcApiSqlException( "Can't call rollback() in auto-commit mode." );
+    }
+    else {
+      // (Currently not reachable.)
+      throw new SQLFeatureNotSupportedException(
+          "Connection.rollback() is not supported.  (Drill is not transactional.)" );
+    }
+  }
+
+  @Override
+  public Savepoint setSavepoint() throws SQLException {
+    checkNotClosed();
+    throw new SQLFeatureNotSupportedException(
+        "Savepoints are not supported.  (Drill is not transactional.)" );
+  }
+
+  @Override
+  public Savepoint setSavepoint(String name) throws SQLException {
+    checkNotClosed();
+    throw new SQLFeatureNotSupportedException(
+        "Savepoints are not supported.  (Drill is not transactional.)" );
+  }
+
+  @Override
+    public void rollback(Savepoint savepoint) throws SQLException {
+    checkNotClosed();
+    throw new SQLFeatureNotSupportedException(
+        "Savepoints are not supported.  (Drill is not transactional.)" );
+  }
+
+  @Override
+  public void releaseSavepoint(Savepoint savepoint) throws SQLException {
+    checkNotClosed();
+    throw new SQLFeatureNotSupportedException(
+        "Savepoints are not supported.  (Drill is not transactional.)" );
+  }
+
+
+  private String isolationValueToString( final int level ) {
+    switch ( level ) {
+      case TRANSACTION_NONE:             return "TRANSACTION_NONE";
+      case TRANSACTION_READ_UNCOMMITTED: return "TRANSACTION_READ_UNCOMMITTED";
+      case TRANSACTION_READ_COMMITTED:   return "TRANSACTION_READ_COMMITTED";
+      case TRANSACTION_REPEATABLE_READ:  return "TRANSACTION_REPEATABLE_READ";
+      case TRANSACTION_SERIALIZABLE:     return "TRANSACTION_SERIALIZABLE";
+      default:
+        return "<Unknown transaction isolation level value " + level + ">";
+    }
+  }
+
+  @Override
+  public void setTransactionIsolation(int level) throws SQLException {
+    checkNotClosed();
+    switch ( level ) {
+      case TRANSACTION_NONE:
+        // No-op.  (Is already set in constructor, and we disallow changing it.)
+        break;
+      case TRANSACTION_READ_UNCOMMITTED:
+      case TRANSACTION_READ_COMMITTED:
+      case TRANSACTION_REPEATABLE_READ:
+      case TRANSACTION_SERIALIZABLE:
+          throw new SQLFeatureNotSupportedException(
+              "Can't change transaction isolation level to Connection."
+              + isolationValueToString( level ) + " (from Connection."
+              + isolationValueToString( getTransactionIsolation() ) + ")."
+              + "  (Drill is not transactional.)" );
+      default:
+        // Invalid value (or new one unknown to code).
+        throw new JdbcApiSqlException(
+            "Invalid transaction isolation level value " + level );
+        //break;
+    }
+  }
+
+  @Override
   public DrillStatement createStatement(int resultSetType, int resultSetConcurrency,
                                         int resultSetHoldability) throws SQLException {
     checkNotClosed();

http://git-wip-us.apache.org/repos/asf/drill/blob/ce9fc3af/exec/jdbc/src/test/java/org/apache/drill/jdbc/ConnectionTransactionMethodsTest.java
----------------------------------------------------------------------
diff --git a/exec/jdbc/src/test/java/org/apache/drill/jdbc/ConnectionTransactionMethodsTest.java
b/exec/jdbc/src/test/java/org/apache/drill/jdbc/ConnectionTransactionMethodsTest.java
new file mode 100644
index 0000000..dd92c9b
--- /dev/null
+++ b/exec/jdbc/src/test/java/org/apache/drill/jdbc/ConnectionTransactionMethodsTest.java
@@ -0,0 +1,168 @@
+/**
+ * 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.drill.jdbc;
+
+import static org.junit.Assert.assertThat;
+import static org.hamcrest.CoreMatchers.*;
+import org.apache.drill.jdbc.Driver;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static java.sql.Connection.*;
+import java.sql.Connection;
+import java.sql.SQLFeatureNotSupportedException;
+import java.sql.Savepoint;
+import java.sql.SQLException;
+
+
+/**
+ * Test for Drill's implementation of Connection's main transaction-related
+ * methods.
+ */
+public class ConnectionTransactionMethodsTest {
+
+  private static Connection connection;
+
+  @BeforeClass
+  public static void setUpConnection() throws SQLException {
+    connection = new Driver().connect( "jdbc:drill:zk=local", null );
+  }
+
+  @AfterClass
+  public static void tearDownConnection() throws SQLException {
+    connection.close();
+  }
+
+
+  ////////////////////////////////////////
+  // Transaction mode methods:
+
+  //////////
+  // Transaction isolation level:
+
+  @Test
+  public void testGetTransactionIsolationSaysNone() throws SQLException {
+    assertThat( connection.getTransactionIsolation(), equalTo( TRANSACTION_NONE ) );
+  }
+
+  @Test
+  public void testSetTransactionIsolationNoneExitsNormally() throws SQLException {
+    connection.setTransactionIsolation( TRANSACTION_NONE );
+  }
+
+  // Test trying to set to unsupported isolation levels:
+
+  // (Sample message:  "Can't change transaction isolation level to
+  // Connection.TRANSACTION_REPEATABLE_READ (from Connection.TRANSACTION_NONE).
+  // (Drill is not transactional.)" (as of 2015-04-22))
+
+  @Test( expected = SQLFeatureNotSupportedException.class )
+  public void testSetTransactionIsolationReadUncommittedThrows() throws SQLException {
+    try {
+      connection.setTransactionIsolation( TRANSACTION_READ_UNCOMMITTED );
+    }
+    catch ( SQLFeatureNotSupportedException e ) {
+      // Check a few things in an error message:
+      assertThat( "Missing requested-level string",
+                  e.getMessage(), containsString( "TRANSACTION_READ_UNCOMMITTED" ) );
+      assertThat( "Missing (or reworded) expected description",
+                  e.getMessage(), containsString( "transaction isolation level" ) );
+      assertThat( "Missing current-level string",
+                  e.getMessage(), containsString( "TRANSACTION_NONE" ) );
+      throw e;
+    }
+  }
+
+  @Test( expected = SQLFeatureNotSupportedException.class )
+  public void testSetTransactionIsolationReadCommittedThrows() throws SQLException {
+    connection.setTransactionIsolation( TRANSACTION_READ_COMMITTED );
+  }
+  @Test( expected = SQLFeatureNotSupportedException.class )
+  public void testSetTransactionIsolationRepeatableReadThrows() throws SQLException {
+    connection.setTransactionIsolation( TRANSACTION_REPEATABLE_READ );
+  }
+  @Test( expected = SQLFeatureNotSupportedException.class )
+  public void testSetTransactionIsolationSerializableThrows() throws SQLException {
+    connection.setTransactionIsolation( TRANSACTION_SERIALIZABLE );
+  }
+
+  @Test( expected = JdbcApiSqlException.class )
+  public void testSetTransactionIsolationBadIntegerThrows() throws SQLException {
+    connection.setTransactionIsolation( 15 );  // not any TRANSACTION_* value
+  }
+
+
+  //////////
+  // Auto-commit mode.
+
+  @Test
+  public void testGetAutoCommitSaysAuto() throws SQLException {
+    // Auto-commit should always be true.
+    assertThat( connection.getAutoCommit(), equalTo( true ) );
+  }
+
+  @Test
+  public void testSetAutoCommitTrueExitsNormally() throws SQLException {
+    // Setting auto-commit true (redundantly) shouldn't throw exception.
+    connection.setAutoCommit( true );
+  }
+
+
+  ////////////////////////////////////////
+  // Transaction operation methods:
+
+  @Test( expected = JdbcApiSqlException.class )
+  public void testCommitThrows() throws SQLException {
+    // Should fail saying because in auto-commit mode (or maybe because not
+    // supported).
+    connection.commit();
+  }
+
+  @Test( expected = JdbcApiSqlException.class )
+  public void testRollbackThrows() throws SQLException {
+    // Should fail saying because in auto-commit mode (or maybe because not
+    // supported).
+    connection.rollback();
+  }
+
+
+  ////////////////////////////////////////
+  // Savepoint methods:
+
+  @Test( expected = SQLFeatureNotSupportedException.class )
+  public void testSetSavepointUnamed() throws SQLException {
+    connection.setSavepoint();
+  }
+
+  @Test( expected = SQLFeatureNotSupportedException.class )
+  public void testSetSavepointNamed() throws SQLException {
+    connection.setSavepoint( "savepoint name" );
+  }
+
+  @Test( expected = SQLFeatureNotSupportedException.class )
+  public void testRollbackSavepoint() throws SQLException {
+    connection.rollback( (Savepoint) null );
+  }
+
+  @Test( expected = SQLFeatureNotSupportedException.class )
+  public void testReleaseSavepoint() throws SQLException {
+    connection.releaseSavepoint( (Savepoint) null );
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/drill/blob/ce9fc3af/exec/jdbc/src/test/java/org/apache/drill/jdbc/DatabaseMetaDataTest.java
----------------------------------------------------------------------
diff --git a/exec/jdbc/src/test/java/org/apache/drill/jdbc/DatabaseMetaDataTest.java b/exec/jdbc/src/test/java/org/apache/drill/jdbc/DatabaseMetaDataTest.java
new file mode 100644
index 0000000..8b885a4
--- /dev/null
+++ b/exec/jdbc/src/test/java/org/apache/drill/jdbc/DatabaseMetaDataTest.java
@@ -0,0 +1,86 @@
+/**
+ * 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.drill.jdbc;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.fail;
+import static org.junit.Assert.assertThat;
+import static org.hamcrest.CoreMatchers.*;
+import org.apache.drill.jdbc.Driver;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+
+
+import static java.sql.Connection.*;
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.SQLFeatureNotSupportedException;
+import java.sql.Savepoint;
+import java.sql.SQLException;
+
+/**
+ * Test for Drill's implementation of DatabaseMetaData's methods (other than
+ * those tested separately, e.g., {@code getColumn(...)}, tested in
+ * {@link DatabaseMetaDataGetColumnsTest})).
+ */
+public class DatabaseMetaDataTest {
+
+  private static Connection connection;
+
+  @BeforeClass
+  public static void setUpConnection() throws SQLException {
+    connection = new Driver().connect( "jdbc:drill:zk=local", null );
+  }
+
+  @AfterClass
+  public static void tearDownConnection() throws SQLException {
+    connection.close();
+  }
+
+  @Test
+  public void testGetDefaultTransactionIsolationSaysNone() throws SQLException {
+    final DatabaseMetaData md = connection.getMetaData();
+    assertThat( md.getDefaultTransactionIsolation(), equalTo( TRANSACTION_NONE ) );
+  }
+
+  @Test
+  public void testSupportsTransactionsSaysNo() throws SQLException {
+    assertThat( connection.getMetaData().supportsTransactions(), equalTo( false ) );
+  }
+
+  @Test
+  public void testSupportsTransactionIsolationLevelNoneSaysYes()
+      throws SQLException {
+    final DatabaseMetaData md = connection.getMetaData();
+    assertTrue( md.supportsTransactionIsolationLevel( TRANSACTION_NONE ) );
+  }
+
+  @Test
+  public void testSupportsTransactionIsolationLevelOthersSayNo()
+      throws SQLException {
+    final DatabaseMetaData md = connection.getMetaData();
+    assertFalse( md.supportsTransactionIsolationLevel( TRANSACTION_READ_UNCOMMITTED ) );
+    assertFalse( md.supportsTransactionIsolationLevel( TRANSACTION_READ_COMMITTED ) );
+    assertFalse( md.supportsTransactionIsolationLevel( TRANSACTION_REPEATABLE_READ ) );
+    assertFalse( md.supportsTransactionIsolationLevel( TRANSACTION_SERIALIZABLE ) );
+  }
+
+}


Mime
View raw message