mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged V3.0 to HEAD
11829: Updated javadocs for RuntimeExec class 11830: Updated and wired in Spring source 11831: Fixed ETHREEOH-382: Can't run Lucene search via Node Browser 11832: Added unit test for V3.0 rev 11535 11834: Removed redundant TODO item 11835: ETHREEOH-798 Double clicking OK on most pop-up dialogs in Share causing multiple requests to be sent - and errors generated for the user 11836: Fix for a number of session based authentication and webscript authentication issues with NTLM from Share. Fixes ETHREEOH-806 and ETHREEOH-834 and first part of fix for ETHREEOH-789. 11838: Sharepoint Protocol Support 11843: Build fix 11846: Refactor of the SSO web filters (NTLM and Kerberos) for web-client and WebDAV. 11848: Added commented out entries for web-client and WebDAV Kerberos filter debugging. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@12483 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -24,11 +24,15 @@
|
||||
*/
|
||||
package org.alfresco.repo.transaction;
|
||||
|
||||
import javax.transaction.Status;
|
||||
import javax.transaction.UserTransaction;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.alfresco.error.ExceptionStackUtil;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
||||
import org.alfresco.repo.transaction.AlfrescoTransactionSupport.TxnReadState;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
|
||||
@@ -164,6 +168,61 @@ public class RetryingTransactionHelperTest extends TestCase
|
||||
assertEquals("The txn value must be the same as the value after", afterValue, txnValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that the transaction state can be fetched in and around the transaction.
|
||||
* This also checks that any mischievous attempts to manipulate the transaction
|
||||
* (other than setRollback) are detected.
|
||||
*/
|
||||
public void testUserTransactionStatus()
|
||||
{
|
||||
UserTransaction txnBefore = RetryingTransactionHelper.getActiveUserTransaction();
|
||||
assertNull("Did not expect to get an active UserTransaction", txnBefore);
|
||||
|
||||
RetryingTransactionCallback<Long> callbackOuter = new RetryingTransactionCallback<Long>()
|
||||
{
|
||||
public Long execute() throws Throwable
|
||||
{
|
||||
final UserTransaction txnOuter = RetryingTransactionHelper.getActiveUserTransaction();
|
||||
assertNotNull("Expected an active UserTransaction", txnOuter);
|
||||
assertEquals(
|
||||
"Should be read-write txn",
|
||||
TxnReadState.TXN_READ_WRITE, AlfrescoTransactionSupport.getTransactionReadState());
|
||||
assertEquals("Expected state is active", Status.STATUS_ACTIVE, txnOuter.getStatus());
|
||||
RetryingTransactionCallback<Long> callbackInner = new RetryingTransactionCallback<Long>()
|
||||
{
|
||||
public Long execute() throws Throwable
|
||||
{
|
||||
UserTransaction txnInner = RetryingTransactionHelper.getActiveUserTransaction();
|
||||
assertNotNull("Expected an active UserTransaction", txnInner);
|
||||
assertEquals(
|
||||
"Should be read-only txn",
|
||||
TxnReadState.TXN_READ_ONLY, AlfrescoTransactionSupport.getTransactionReadState());
|
||||
assertEquals("Expected state is active", Status.STATUS_ACTIVE, txnInner.getStatus());
|
||||
// Check blow up
|
||||
try
|
||||
{
|
||||
txnInner.commit();
|
||||
fail("Should not be able to commit the UserTransaction. It is for info only.");
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
// Expected
|
||||
}
|
||||
// Force a rollback
|
||||
txnInner.setRollbackOnly();
|
||||
// Done
|
||||
return null;
|
||||
}
|
||||
};
|
||||
return txnHelper.doInTransaction(callbackInner, true, true);
|
||||
}
|
||||
};
|
||||
txnHelper.doInTransaction(callbackOuter);
|
||||
|
||||
UserTransaction txnAfter = RetryingTransactionHelper.getActiveUserTransaction();
|
||||
assertNull("Did not expect to get an active UserTransaction", txnAfter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that the retries happening for simple concurrency exceptions
|
||||
*/
|
||||
|
Reference in New Issue
Block a user