|
From: <svn...@os...> - 2012-01-16 15:40:37
|
Author: aaime
Date: 2012-01-16 07:40:31 -0800 (Mon, 16 Jan 2012)
New Revision: 38490
Modified:
trunk/modules/plugin/jdbc/jdbc-sqlserver/src/test/java/org/geotools/data/sqlserver/SQLServerFeatureStoreTest.java
Log:
[GEOT-4015] SQLServerFeatureStore locks up on testExternalConnection since SQLServer does not support MVCC by default
Modified: trunk/modules/plugin/jdbc/jdbc-sqlserver/src/test/java/org/geotools/data/sqlserver/SQLServerFeatureStoreTest.java
===================================================================
--- trunk/modules/plugin/jdbc/jdbc-sqlserver/src/test/java/org/geotools/data/sqlserver/SQLServerFeatureStoreTest.java 2012-01-16 15:40:15 UTC (rev 38489)
+++ trunk/modules/plugin/jdbc/jdbc-sqlserver/src/test/java/org/geotools/data/sqlserver/SQLServerFeatureStoreTest.java 2012-01-16 15:40:31 UTC (rev 38490)
@@ -17,7 +17,12 @@
package org.geotools.data.sqlserver;
import java.io.IOException;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import org.geotools.data.Transaction;
import org.geotools.jdbc.JDBCFeatureStoreTest;
import org.geotools.jdbc.JDBCTestSetup;
@@ -45,5 +50,36 @@
// - however if IDENTITY_INSERT is setup, then the column stops generating values and
// requires one to insert values manually, which breaks other tests
}
+
+ @Override
+ public void testExternalConnection() throws IOException, SQLException {
+ // MVCC is not enabled by default in SQL Server, to do that one has to
+ // use something like:
+ // ALTER DATABASE ' + DB_NAME() + ' SET SINGLE_USER WITH ROLLBACK IMMEDIATE ;
+ // ALTER DATABASE ' + DB_NAME() + ' SET READ_COMMITTED_SNAPSHOT ON;
+ // ALTER DATABASE ' + DB_NAME() + ' SET MULTI_USER;'
+ // However this requires having admin access to the database, so we cannot
+ // assume we can run it, thus we just check if it's possible at all
+ // When the above is set the test passes, verified against SQL Server 2008
+
+ Connection cx = null;
+ Statement st = null;
+ ResultSet rs = null;
+ try {
+ cx = dataStore.getConnection(Transaction.AUTO_COMMIT);
+ st = cx.createStatement();
+ rs = st.executeQuery("SELECT is_read_committed_snapshot_on FROM sys.databases WHERE name= db_name()");
+ if(rs.next()) {
+ if(rs.getBoolean(1)) {
+ super.testExternalConnection();
+ }
+ }
+ } finally {
+ dataStore.closeSafe(rs);
+ dataStore.closeSafe(st);
+ dataStore.closeSafe(cx);
+ }
+
+ }
}
|