mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
ACS-9259 Improve stability of HazelcastLockStoreTxTest test (#3248)
This commit is contained in:
@@ -25,29 +25,30 @@
|
||||
*/
|
||||
package org.alfresco.repo.lock.mem;
|
||||
|
||||
import java.util.Date;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.util.Date;
|
||||
import jakarta.transaction.NotSupportedException;
|
||||
import jakarta.transaction.SystemException;
|
||||
import jakarta.transaction.UserTransaction;
|
||||
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.service.cmr.lock.LockType;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
import org.alfresco.util.ApplicationContextHelper;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.dao.ConcurrencyFailureException;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.fail;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.service.cmr.lock.LockType;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
import org.alfresco.util.ApplicationContextHelper;
|
||||
|
||||
/**
|
||||
* Integration tests that check transaction related functionality of {@link LockStore} implementations.
|
||||
*
|
||||
* @author Matt Ward
|
||||
*/
|
||||
public abstract class AbstractLockStoreTxTest<T extends LockStore>
|
||||
@@ -108,9 +109,7 @@ public abstract class AbstractLockStoreTxTest<T extends LockStore>
|
||||
final LockState lockState1 = LockState.createLock(nodeRef, LockType.WRITE_LOCK,
|
||||
"jbloggs", expires, Lifetime.EPHEMERAL, null);
|
||||
|
||||
|
||||
Thread txB = new Thread("TxB")
|
||||
{
|
||||
Thread txB = new Thread("TxB") {
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
@@ -166,6 +165,9 @@ public abstract class AbstractLockStoreTxTest<T extends LockStore>
|
||||
// txA set lock state 1
|
||||
lockStore.set(nodeRef, lockState1);
|
||||
|
||||
// Perform a read, that we know will retrieve a null value (and null will be cached for this transaction)
|
||||
assertNull("nodeRef2 LockState", lockStore.get(nodeRef2));
|
||||
|
||||
// Wait while txB reads and checks the LockState
|
||||
txB.setDaemon(true);
|
||||
txB.start();
|
||||
@@ -186,13 +188,10 @@ public abstract class AbstractLockStoreTxTest<T extends LockStore>
|
||||
// Check we can see the update.
|
||||
assertEquals("bsmith", lockStore.get(nodeRef).getOwner());
|
||||
|
||||
// Perform a read, that we know will retrieve a null value
|
||||
assertNull("nodeRef2 LockState", lockStore.get(nodeRef2));
|
||||
|
||||
// Wait while txB populates the store with a value for nodeRef2
|
||||
passControl(this, txB);
|
||||
|
||||
// Perform the read again - update should not be visible in this transaction
|
||||
// Perform the read again - update should not be visible in this transaction (was already cached)
|
||||
assertNull("nodeRef2 LockState", lockStore.get(nodeRef2));
|
||||
}
|
||||
finally
|
||||
@@ -233,9 +232,7 @@ public abstract class AbstractLockStoreTxTest<T extends LockStore>
|
||||
final LockState lockState1 = LockState.createLock(nodeRef, LockType.WRITE_LOCK,
|
||||
"jbloggs", expires, Lifetime.EPHEMERAL, null);
|
||||
|
||||
|
||||
Thread txB = new Thread("TxB")
|
||||
{
|
||||
Thread txB = new Thread("TxB") {
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
@@ -329,8 +326,7 @@ public abstract class AbstractLockStoreTxTest<T extends LockStore>
|
||||
|
||||
final LockState lockState2 = LockState.createWithOwner(lockState1, "another");
|
||||
|
||||
Thread txB = new Thread("TxB")
|
||||
{
|
||||
Thread txB = new Thread("TxB") {
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
@@ -404,7 +400,6 @@ public abstract class AbstractLockStoreTxTest<T extends LockStore>
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testNotOnlyCurrentLockOwnerCanChangeInfo() throws NotSupportedException, SystemException
|
||||
{
|
||||
|
Reference in New Issue
Block a user