Update of /cvsroot/springnet/Spring.Net/src/Spring/Spring.Data/Transaction/Support
In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv29799
Modified Files:
AbstractPlatformTransactionManager.cs
Log Message:
SPRNET-761 - Add unit tests for TxScopePlatformTransactionManager
Introduce ITransactionScopeAdapter to make it testable with Mocks
added TypeMock based unit test that is not used but nice to have for future reference
Index: AbstractPlatformTransactionManager.cs
===================================================================
RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Data/Transaction/Support/AbstractPlatformTransactionManager.cs,v
retrieving revision 1.25
retrieving revision 1.26
diff -C2 -d -r1.25 -r1.26
*** AbstractPlatformTransactionManager.cs 12 Nov 2007 19:58:06 -0000 1.25
--- AbstractPlatformTransactionManager.cs 30 Nov 2007 18:38:54 -0000 1.26
***************
*** 125,128 ****
--- 125,129 ----
private bool _nestedTransactionsAllowed;
private bool _rollbackOnCommitFailure;
+ private bool _failEarlyOnGlobalRollbackOnly;
private int _defaultTimeout = DefaultTransactionDefinition.TIMEOUT_DEFAULT;
***************
*** 189,192 ****
--- 190,212 ----
/// <summary>
+ /// Gets or sets a value indicating whether to fail early in case of the transaction being
+ /// globally marked as rollback-only.
+ /// </summary>
+ /// <remarks>
+ /// Default is "false", only causing an UnexpectedRollbackException at the
+ /// outermost transaction boundary. Switch this flag on to cause an
+ /// UnexpectedRollbackException as early as the global rollback-only marker
+ /// has been first detected, even from within an inner transaction boundary.
+ /// </remarks>
+ /// <value>
+ /// <c>true</c> if fail early on global rollback; otherwise, <c>false</c>.
+ /// </value>
+ public bool FailEarlyOnGlobalRollbackOnly
+ {
+ get { return _failEarlyOnGlobalRollbackOnly; }
+ set { _failEarlyOnGlobalRollbackOnly = value; }
+ }
+
+ /// <summary>
/// Gets or sets the default timeout that this transaction manager should apply if there
/// is no timeout specified at the transaction level, in seconds.
***************
*** 641,645 ****
return;
}
! if (defaultStatus.GlobalRollbackOnly)
{
if (defaultStatus.Debug)
--- 661,665 ----
return;
}
! if ( !ShouldCommitOnGlobalRollbackOnly && defaultStatus.GlobalRollbackOnly)
{
if (defaultStatus.Debug)
***************
*** 650,654 ****
// Throw UnexpectedRollbackException only at outermost transaction boundary
// or if explicitly asked to.
! if (defaultStatus.IsNewTransaction)
{
throw new UnexpectedRollbackException(
--- 670,674 ----
// Throw UnexpectedRollbackException only at outermost transaction boundary
// or if explicitly asked to.
! if (defaultStatus.IsNewTransaction || FailEarlyOnGlobalRollbackOnly)
{
throw new UnexpectedRollbackException(
***************
*** 661,664 ****
--- 681,689 ----
}
+ protected virtual bool ShouldCommitOnGlobalRollbackOnly
+ {
+ get { return false; }
+ }
+
private void ProcessCommit(DefaultTransactionStatus status)
{
***************
*** 672,676 ****
beforeCompletionInvoked = true;
bool globalRollbackOnly = false;
! if (status.IsNewTransaction)
{
globalRollbackOnly = status.GlobalRollbackOnly;
--- 697,701 ----
beforeCompletionInvoked = true;
bool globalRollbackOnly = false;
! if (status.IsNewTransaction || FailEarlyOnGlobalRollbackOnly)
{
globalRollbackOnly = status.GlobalRollbackOnly;
|