SPRNET-1444 - revert commits on this issue to return DefaultIsolationLevel for tx advice from Unspecified back to ReadCommitted

This commit is contained in:
Steve Bohlen
2015-03-21 14:52:05 -04:00
parent 1c562f8fe6
commit 829d04f786
12 changed files with 36 additions and 39 deletions

View File

@@ -45,7 +45,7 @@ namespace Spring.Data
public class AdoPlatformTransactionManagerTests
{
private MockRepository mocks;
private IsolationLevel _defaultIsolationLevel = IsolationLevel.Unspecified;
private const IsolationLevel DefaultIsolationLevel = IsolationLevel.ReadCommitted;
[SetUp]
public void Setup()
@@ -75,7 +75,7 @@ namespace Spring.Data
Expect.Call(dbProvider.CreateConnection()).Return(connection);
connection.Open();
LastCall.On(connection).Repeat.Once();
Expect.Call(connection.BeginTransaction(_defaultIsolationLevel)).Return(transaction);
Expect.Call(connection.BeginTransaction(DefaultIsolationLevel)).Return(transaction);
//standard tx timeout.
transaction.Commit();
LastCall.On(transaction).Repeat.Once();
@@ -116,7 +116,7 @@ namespace Spring.Data
Expect.Call(dbProvider.CreateConnection()).Return(connection);
connection.Open();
LastCall.On(connection).Repeat.Once();
Expect.Call(connection.BeginTransaction(_defaultIsolationLevel)).Return(transaction);
Expect.Call(connection.BeginTransaction(DefaultIsolationLevel)).Return(transaction);
//standard tx timeout.
transaction.Rollback();
LastCall.On(transaction).Repeat.Once();
@@ -166,7 +166,7 @@ namespace Spring.Data
Expect.Call(dbProvider.CreateConnection()).Return(connection);
connection.Open();
LastCall.On(connection).Repeat.Once();
Expect.Call(connection.BeginTransaction(_defaultIsolationLevel)).Return(transaction);
Expect.Call(connection.BeginTransaction(DefaultIsolationLevel)).Return(transaction);
//standard tx timeout.
transaction.Rollback();
LastCall.On(transaction).Repeat.Once();
@@ -238,7 +238,7 @@ namespace Spring.Data
Expect.Call(dbProvider.CreateConnection()).Return(connection).Repeat.Twice();
connection.Open();
LastCall.On(connection).Repeat.Twice();
Expect.Call(connection.BeginTransaction(_defaultIsolationLevel)).Return(transaction).Repeat.Twice();
Expect.Call(connection.BeginTransaction(DefaultIsolationLevel)).Return(transaction).Repeat.Twice();
//standard tx timeout.
transaction.Rollback();
LastCall.On(transaction).Repeat.Once();
@@ -280,7 +280,7 @@ namespace Spring.Data
Expect.Call(dbProvider.CreateConnection()).Return(connection);
connection.Open();
LastCall.On(connection).Repeat.Once();
Expect.Call(connection.BeginTransaction(_defaultIsolationLevel)).Return(transaction);
Expect.Call(connection.BeginTransaction(DefaultIsolationLevel)).Return(transaction);
transaction.Commit();
LastCall.On(transaction).Repeat.Once();
connection.Dispose();
@@ -292,7 +292,7 @@ namespace Spring.Data
Expect.Call(dbProvider2.CreateConnection()).Return(connection2);
connection2.Open();
LastCall.On(connection2).Repeat.Once();
Expect.Call(connection2.BeginTransaction(_defaultIsolationLevel)).Return(transaction2);
Expect.Call(connection2.BeginTransaction(DefaultIsolationLevel)).Return(transaction2);
transaction2.Rollback();
LastCall.On(transaction2).Repeat.Once();
connection2.Dispose();
@@ -335,7 +335,7 @@ namespace Spring.Data
Expect.Call(dbProvider.CreateConnection()).Return(connection);
connection.Open();
LastCall.On(connection).Repeat.Once();
Expect.Call(connection.BeginTransaction(_defaultIsolationLevel)).Return(transaction);
Expect.Call(connection.BeginTransaction(DefaultIsolationLevel)).Return(transaction);
transaction.Rollback();
LastCall.On(transaction).Repeat.Once();
connection.Dispose();
@@ -395,7 +395,7 @@ namespace Spring.Data
Expect.Call(dbProvider.CreateConnection()).Return(connection);
connection.Open();
LastCall.On(connection).Repeat.Once();
Expect.Call(connection.BeginTransaction(_defaultIsolationLevel)).Return(transaction);
Expect.Call(connection.BeginTransaction(DefaultIsolationLevel)).Return(transaction);
//standard tx timeout.
transaction.Commit();
LastCall.On(transaction).Repeat.Once();
@@ -431,7 +431,7 @@ namespace Spring.Data
Expect.Call(dbProvider.CreateConnection()).Return(connection);
connection.Open();
LastCall.On(connection).Repeat.Once();
Expect.Call(connection.BeginTransaction(_defaultIsolationLevel)).Return(transaction);
Expect.Call(connection.BeginTransaction(DefaultIsolationLevel)).Return(transaction);
//standard tx timeout.
transaction.Rollback();
LastCall.On(transaction).Repeat.Once();
@@ -482,7 +482,7 @@ namespace Spring.Data
Expect.Call(dbProvider.CreateConnection()).Return(connection2);
connection2.Open();
LastCall.On(connection2).Repeat.Once();
Expect.Call(connection2.BeginTransaction(_defaultIsolationLevel)).Return(transaction2);
Expect.Call(connection2.BeginTransaction(DefaultIsolationLevel)).Return(transaction2);
transaction2.Commit();
LastCall.On(transaction2).Repeat.Once();
connection2.Dispose();
@@ -573,7 +573,7 @@ namespace Spring.Data
connection.Open();
LastCall.On(connection).Repeat.Once();
Expect.Call(connection.BeginTransaction(_defaultIsolationLevel)).Return(transaction);
Expect.Call(connection.BeginTransaction(DefaultIsolationLevel)).Return(transaction);
Expect.Call(connection.CreateCommand()).Return(command);
command.CommandText = "some SQL statement";
LastCall.On(command).Repeat.Once();
@@ -674,7 +674,7 @@ namespace Spring.Data
Expect.Call(dbProvider.CreateConnection()).Return(connection);
connection.Open();
LastCall.On(connection).Repeat.Once();
Expect.Call(connection.BeginTransaction(_defaultIsolationLevel)).Return(transaction);
Expect.Call(connection.BeginTransaction(DefaultIsolationLevel)).Return(transaction);
//standard tx timeout.
transaction.Commit();
LastCall.On(transaction).Throw(new TestSqlException("Cannot commit", "314"));
@@ -717,7 +717,7 @@ namespace Spring.Data
Expect.Call(dbProvider.CreateConnection()).Return(connection);
connection.Open();
LastCall.On(connection).Repeat.Once();
Expect.Call(connection.BeginTransaction(_defaultIsolationLevel)).Return(transaction);
Expect.Call(connection.BeginTransaction(DefaultIsolationLevel)).Return(transaction);
transaction.Commit();
LastCall.On(transaction).Throw(new TestSqlException("Cannot commit", "314"));
@@ -763,7 +763,7 @@ namespace Spring.Data
Expect.Call(dbProvider.CreateConnection()).Return(connection);
connection.Open();
LastCall.On(connection).Repeat.Once();
Expect.Call(connection.BeginTransaction(_defaultIsolationLevel)).Return(transaction);
Expect.Call(connection.BeginTransaction(DefaultIsolationLevel)).Return(transaction);
//standard tx timeout.
transaction.Rollback();
LastCall.On(transaction).Throw(new TestSqlException("Cannot commit", "314"));
@@ -877,7 +877,7 @@ namespace Spring.Data
Expect.Call(dbProvider.CreateConnection()).Return(connection);
connection.Open();
LastCall.On(connection).Repeat.Once();
Expect.Call(connection.BeginTransaction(_defaultIsolationLevel)).Return(transaction);
Expect.Call(connection.BeginTransaction(DefaultIsolationLevel)).Return(transaction);
transaction.Rollback();
LastCall.On(transaction).Repeat.Once();
@@ -923,7 +923,7 @@ namespace Spring.Data
Expect.Call(dbProvider.CreateConnection()).Return(connection);
connection.Open();
LastCall.On(connection).Repeat.Once();
Expect.Call(connection.BeginTransaction(_defaultIsolationLevel)).Return(transaction);
Expect.Call(connection.BeginTransaction(DefaultIsolationLevel)).Return(transaction);
//standard tx timeout.
transaction.Commit();
LastCall.On(transaction).Repeat.Once();
@@ -971,7 +971,7 @@ namespace Spring.Data
Expect.Call(dbProvider.CreateConnection()).Return(connection);
connection.Open();
LastCall.On(connection).Repeat.Once();
Expect.Call(connection.BeginTransaction(_defaultIsolationLevel)).Return(transaction);
Expect.Call(connection.BeginTransaction(DefaultIsolationLevel)).Return(transaction);
transaction.Rollback();
LastCall.On(transaction).Repeat.Once();
connection.Dispose();

View File

@@ -159,7 +159,7 @@ namespace Spring.Data.Core
// inner tx
ConfigureServiceConfig(serviceConfig, false);
serviceConfig.TransactionOption = TransactionOption.RequiresNew;
serviceConfig.IsolationLevel = TransactionIsolationLevel.Any;
serviceConfig.IsolationLevel = TransactionIsolationLevel.ReadCommitted;
txAdapter.Enter(serviceConfig);
Expect.Call(txAdapter.IsInTransaction).Return(true);
txAdapter.SetAbort();
@@ -204,7 +204,7 @@ namespace Spring.Data.Core
if (standardIsolationAndProp)
{
serviceConfig.TransactionOption = TransactionOption.Required;
serviceConfig.IsolationLevel = TransactionIsolationLevel.Any;
serviceConfig.IsolationLevel = TransactionIsolationLevel.ReadCommitted;
}
return serviceConfig;

View File

@@ -57,7 +57,7 @@ namespace Spring.Data.Core
{
Expect.Call(txAdapter.IsExistingTransaction).Return(false);
TransactionOptions txOptions = new TransactionOptions();
txOptions.IsolationLevel = IsolationLevel.Unspecified;
txOptions.IsolationLevel = IsolationLevel.ReadCommitted;
txAdapter.CreateTransactionScope(TransactionScopeOption.Required, txOptions, EnterpriseServicesInteropOption.None);
Expect.Call(txAdapter.RollbackOnly).Return(false);
@@ -94,7 +94,7 @@ namespace Spring.Data.Core
{
Expect.Call(txAdapter.IsExistingTransaction).Return(false);
TransactionOptions txOptions = new TransactionOptions();
txOptions.IsolationLevel = IsolationLevel.Unspecified;
txOptions.IsolationLevel = IsolationLevel.ReadCommitted;
txAdapter.CreateTransactionScope(TransactionScopeOption.Required, txOptions, EnterpriseServicesInteropOption.None);
txAdapter.Dispose();
}
@@ -141,7 +141,7 @@ namespace Spring.Data.Core
{
Expect.Call(txAdapter.IsExistingTransaction).Return(false);
TransactionOptions txOptions = new TransactionOptions();
txOptions.IsolationLevel = IsolationLevel.Unspecified;
txOptions.IsolationLevel = IsolationLevel.ReadCommitted;
txAdapter.CreateTransactionScope(TransactionScopeOption.RequiresNew, txOptions, EnterpriseServicesInteropOption.None);
//inner tx actions

View File

@@ -18,7 +18,7 @@ namespace Spring.Transaction.Interceptor
public void ToStringTests()
{
DefaultTransactionAttribute dta = new DefaultTransactionAttribute();
Assert.AreEqual( "PROPAGATION_Required,ISOLATION_Unspecified,-System.Exception", dta.ToString());
Assert.AreEqual( "PROPAGATION_Required,ISOLATION_ReadCommitted,-System.Exception", dta.ToString());
}
}
}

View File

@@ -34,7 +34,7 @@ namespace Spring.Transaction.Interceptor
ITransactionAttribute ta = editor.Value;
Assert.IsTrue( ta != null );
Assert.IsTrue( ta.PropagationBehavior == TransactionPropagation.Required );
Assert.IsTrue( ta.TransactionIsolationLevel == IsolationLevel.Unspecified );
Assert.IsTrue( ta.TransactionIsolationLevel == IsolationLevel.ReadCommitted );
Assert.IsFalse( ta.ReadOnly );
}

View File

@@ -59,7 +59,7 @@ namespace Spring.Transaction.Interceptor
{
ITransactionAttribute ta = tas.ReturnTransactionAttribute( method, null );
Assert.IsTrue( ta != null );
Assert.IsTrue( ta.TransactionIsolationLevel == IsolationLevel.Unspecified );
Assert.IsTrue( ta.TransactionIsolationLevel == IsolationLevel.ReadCommitted );
Assert.IsTrue( ta.PropagationBehavior == transactionPropagation);
}
}

View File

@@ -20,7 +20,7 @@ namespace Spring.Transaction.Support
Assert.IsTrue( 1000 == def.TransactionTimeout );
Assert.IsTrue( false == def.ReadOnly );
def.ReadOnly = true;
Assert.IsTrue( true == def.ReadOnly );
Assert.IsTrue( def.ReadOnly );
}
[Test]
public void PropogationBehaviorDefault()
@@ -32,7 +32,7 @@ namespace Spring.Transaction.Support
public void IsolationLevelDefault()
{
DefaultTransactionDefinition def = new DefaultTransactionDefinition();
Assert.IsTrue(def.TransactionIsolationLevel == IsolationLevel.Unspecified);
Assert.IsTrue(def.TransactionIsolationLevel == IsolationLevel.ReadCommitted);
}
[Test]
[ExpectedException(typeof(ArgumentException))]