mirror of https://github.com/apache/openjpa.git
OPENJPA-1753 a) remove unneeded import, b) close and clean up em using add Act.CloseEm, c) add better diagnostic info in SequenceActionsTest and d) clean up and update find/lock permutation tests for more consistent testing.
git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@984147 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a2d3c9f57a
commit
c9f58ec243
|
@ -81,6 +81,7 @@ public abstract class SequencedActionsTest extends SQLListenerTestCase {
|
||||||
private String empTableName;
|
private String empTableName;
|
||||||
private List<TestThread> threads = null;
|
private List<TestThread> threads = null;
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
protected void commonSetUp() {
|
protected void commonSetUp() {
|
||||||
empTableName = getMapping(LockEmployee.class).getTable().getFullName();
|
empTableName = getMapping(LockEmployee.class).getTable().getFullName();
|
||||||
|
|
||||||
|
@ -326,10 +327,12 @@ public abstract class SequencedActionsTest extends SQLListenerTestCase {
|
||||||
LockEmployee employee = null;
|
LockEmployee employee = null;
|
||||||
LockModeType lockMode = null;
|
LockModeType lockMode = null;
|
||||||
Act curAction = null;
|
Act curAction = null;
|
||||||
|
int actIndex = 0;
|
||||||
Object[][] threadSequence = actions[threadToRun];
|
Object[][] threadSequence = actions[threadToRun];
|
||||||
for (Object[] args : threadSequence) {
|
for (Object[] args : threadSequence) {
|
||||||
curAction = (Act) args[0];
|
curAction = (Act) args[0];
|
||||||
log.trace("** Act=" + Arrays.toString(args));
|
String curAct = "Act[t" + threadToRun + ":" + (++actIndex) +"]=" + Arrays.toString(args);
|
||||||
|
log.trace("** " + curAct);
|
||||||
try {
|
try {
|
||||||
switch (curAction) {
|
switch (curAction) {
|
||||||
case CreateEm:
|
case CreateEm:
|
||||||
|
@ -591,7 +594,7 @@ public abstract class SequencedActionsTest extends SQLListenerTestCase {
|
||||||
id = (Integer)args[1];
|
id = (Integer)args[1];
|
||||||
}
|
}
|
||||||
employee = employees.get(id);
|
employee = employees.get(id);
|
||||||
assertNotNull(employee);
|
assertNotNull(curAct, employee);
|
||||||
break;
|
break;
|
||||||
case TestEmployee:
|
case TestEmployee:
|
||||||
id = 1;
|
id = 1;
|
||||||
|
@ -602,22 +605,22 @@ public abstract class SequencedActionsTest extends SQLListenerTestCase {
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 4:
|
case 4:
|
||||||
if (args[3] != null) {
|
if (args[3] != null) {
|
||||||
assertEquals("", saveVersion
|
assertEquals(curAct, saveVersion
|
||||||
+ (Integer) args[3], employee.getVersion());
|
+ (Integer) args[3], employee.getVersion());
|
||||||
}
|
}
|
||||||
case 3:
|
case 3:
|
||||||
if (args[2] != null) {
|
if (args[2] != null) {
|
||||||
assertEquals("", (String) args[2], employee
|
assertEquals(curAct, (String) args[2], employee
|
||||||
.getFirstName());
|
.getFirstName());
|
||||||
}
|
}
|
||||||
case 2:
|
case 2:
|
||||||
if (args[1] != null) {
|
if (args[1] != null) {
|
||||||
assertEquals("", id.intValue(),
|
assertEquals(curAct, id.intValue(),
|
||||||
employee.getId());
|
employee.getId());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
assertNull(employee);
|
assertNull(curAct, employee);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SaveVersion:
|
case SaveVersion:
|
||||||
|
@ -640,7 +643,7 @@ public abstract class SequencedActionsTest extends SQLListenerTestCase {
|
||||||
+ (saveVersion + increment) + ", testing="
|
+ (saveVersion + increment) + ", testing="
|
||||||
+ employee.getVersion());
|
+ employee.getVersion());
|
||||||
|
|
||||||
assertEquals("", saveVersion + increment, employee
|
assertEquals(curAct, saveVersion + increment, employee
|
||||||
.getVersion());
|
.getVersion());
|
||||||
break;
|
break;
|
||||||
case TestLockMode:
|
case TestLockMode:
|
||||||
|
@ -654,7 +657,7 @@ public abstract class SequencedActionsTest extends SQLListenerTestCase {
|
||||||
log.trace("test version: expected=" + expectedlockMode
|
log.trace("test version: expected=" + expectedlockMode
|
||||||
+ ", testing=" + testinglockMode);
|
+ ", testing=" + testinglockMode);
|
||||||
|
|
||||||
assertEquals("", getCanonical(expectedlockMode),
|
assertEquals(curAct, getCanonical(expectedlockMode),
|
||||||
getCanonical(testinglockMode));
|
getCanonical(testinglockMode));
|
||||||
break;
|
break;
|
||||||
case ResetException:
|
case ResetException:
|
||||||
|
@ -696,7 +699,7 @@ public abstract class SequencedActionsTest extends SQLListenerTestCase {
|
||||||
&& expectedExceptions.size() > 0) {
|
&& expectedExceptions.size() > 0) {
|
||||||
for (Class<?> expectedException :
|
for (Class<?> expectedException :
|
||||||
expectedExceptions) {
|
expectedExceptions) {
|
||||||
if (matchExpectedException(expectedException,
|
if (matchExpectedException(curAct, expectedException,
|
||||||
curThrowable)) {
|
curThrowable)) {
|
||||||
exMatched = true;
|
exMatched = true;
|
||||||
break;
|
break;
|
||||||
|
@ -713,7 +716,7 @@ public abstract class SequencedActionsTest extends SQLListenerTestCase {
|
||||||
logStack(curThrowable);
|
logStack(curThrowable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assertTrue("Expecting=" + expectedExceptions
|
assertTrue(curAct + ":Expecting=" + expectedExceptions
|
||||||
+ ", Testing=" + testExClass, exMatched);
|
+ ", Testing=" + testExClass, exMatched);
|
||||||
exThread.throwable = null;
|
exThread.throwable = null;
|
||||||
break;
|
break;
|
||||||
|
@ -908,9 +911,9 @@ public abstract class SequencedActionsTest extends SQLListenerTestCase {
|
||||||
return props;
|
return props;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean matchExpectedException(Class<?> expected,
|
private boolean matchExpectedException(String curAct, Class<?> expected,
|
||||||
Throwable tested) {
|
Throwable tested) {
|
||||||
assertNotNull(expected);
|
assertNotNull(curAct, expected);
|
||||||
Class<?> testExClass = null;
|
Class<?> testExClass = null;
|
||||||
boolean exMatched = true;
|
boolean exMatched = true;
|
||||||
if (tested != null) {
|
if (tested != null) {
|
||||||
|
|
|
@ -20,7 +20,6 @@ package org.apache.openjpa.persistence.lockmgr;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
import javax.persistence.LockModeType;
|
import javax.persistence.LockModeType;
|
||||||
|
|
|
@ -121,7 +121,8 @@ public class TestMixedLockManagerDeadlock extends SequencedActionsTest {
|
||||||
{Act.WaitAllChildren},
|
{Act.WaitAllChildren},
|
||||||
{Act.TestException, 1, t1Exceptions},
|
{Act.TestException, 1, t1Exceptions},
|
||||||
|
|
||||||
{Act.RollbackTx}
|
{Act.RollbackTx},
|
||||||
|
{Act.CloseEm}
|
||||||
};
|
};
|
||||||
Object[][] thread1 = {
|
Object[][] thread1 = {
|
||||||
{Act.CreateEm},
|
{Act.CreateEm},
|
||||||
|
@ -134,6 +135,7 @@ public class TestMixedLockManagerDeadlock extends SequencedActionsTest {
|
||||||
{Act.NamedQueryWithLock, "findEmployeeById", 1, t1Lock, "openjpa.hint.IgnorePreparedQuery", true},
|
{Act.NamedQueryWithLock, "findEmployeeById", 1, t1Lock, "openjpa.hint.IgnorePreparedQuery", true},
|
||||||
|
|
||||||
{Act.RollbackTx},
|
{Act.RollbackTx},
|
||||||
|
{Act.CloseEm}
|
||||||
};
|
};
|
||||||
launchActionSequence(testName, parameters, threadMain, thread1);
|
launchActionSequence(testName, parameters, threadMain, thread1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,6 +111,7 @@ public class TestMixedLockManagerFindBasic extends SequencedActionsTest {
|
||||||
{ Act.Clear },
|
{ Act.Clear },
|
||||||
{ Act.Find, 1 },
|
{ Act.Find, 1 },
|
||||||
{ Act.TestEmployee, 1, lockMode.toString(), 0 },
|
{ Act.TestEmployee, 1, lockMode.toString(), 0 },
|
||||||
|
{ Act.CloseEm }
|
||||||
};
|
};
|
||||||
|
|
||||||
launchActionSequence(testName, "LockMode=" + lockMode, threadMain);
|
launchActionSequence(testName, "LockMode=" + lockMode, threadMain);
|
||||||
|
|
|
@ -67,6 +67,7 @@ public class TestMixedLockManagerFindException extends SequencedActionsTest {
|
||||||
|
|
||||||
{Act.FindWithLock, 1, LockModeType.PESSIMISTIC_FORCE_INCREMENT },
|
{Act.FindWithLock, 1, LockModeType.PESSIMISTIC_FORCE_INCREMENT },
|
||||||
{Act.TestException, 0, TransactionRequiredException.class },
|
{Act.TestException, 0, TransactionRequiredException.class },
|
||||||
|
{Act.CloseEm},
|
||||||
};
|
};
|
||||||
launchActionSequence("testLockTxReqExceptions()",
|
launchActionSequence("testLockTxReqExceptions()",
|
||||||
null, threadMainTxReqTest);
|
null, threadMainTxReqTest);
|
||||||
|
@ -182,6 +183,7 @@ public class TestMixedLockManagerFindException extends SequencedActionsTest {
|
||||||
{Act.FindObject, LockEmployee.class, Boolean.TRUE,
|
{Act.FindObject, LockEmployee.class, Boolean.TRUE,
|
||||||
LockModeType.PESSIMISTIC_FORCE_INCREMENT },
|
LockModeType.PESSIMISTIC_FORCE_INCREMENT },
|
||||||
{Act.TestException, 0, IllegalArgumentException.class },
|
{Act.TestException, 0, IllegalArgumentException.class },
|
||||||
|
{Act.CloseEm}
|
||||||
};
|
};
|
||||||
launchActionSequence("testLockIllegalArgrumentExceptions()",
|
launchActionSequence("testLockIllegalArgrumentExceptions()",
|
||||||
"Test invalid entity.", threadMainInvEntityIllegalArgTest);
|
"Test invalid entity.", threadMainInvEntityIllegalArgTest);
|
||||||
|
@ -239,6 +241,7 @@ public class TestMixedLockManagerFindException extends SequencedActionsTest {
|
||||||
? OptimisticLockException.class : null},
|
? OptimisticLockException.class : null},
|
||||||
{Act.TestException, 1, expectingOptLockException2
|
{Act.TestException, 1, expectingOptLockException2
|
||||||
? OptimisticLockException.class : null},
|
? OptimisticLockException.class : null},
|
||||||
|
{Act.CloseEm}
|
||||||
};
|
};
|
||||||
Object[][] thread1OptLockExTest = {
|
Object[][] thread1OptLockExTest = {
|
||||||
{Act.CreateEm},
|
{Act.CreateEm},
|
||||||
|
@ -252,6 +255,7 @@ public class TestMixedLockManagerFindException extends SequencedActionsTest {
|
||||||
|
|
||||||
{Act.CommitTx},
|
{Act.CommitTx},
|
||||||
{Act.Notify, 0},
|
{Act.Notify, 0},
|
||||||
|
{Act.CloseEm}
|
||||||
};
|
};
|
||||||
launchActionSequence("testLockOptimisticLockExceptions()", null,
|
launchActionSequence("testLockOptimisticLockExceptions()", null,
|
||||||
threadMainOptLockExTest, thread1OptLockExTest);
|
threadMainOptLockExTest, thread1OptLockExTest);
|
||||||
|
|
|
@ -59,8 +59,8 @@ public class TestMixedLockManagerFindPermutation extends SequencedActionsTest {
|
||||||
public void testFindReadPessimisticRead() {
|
public void testFindReadPessimisticRead() {
|
||||||
commonFindTest(
|
commonFindTest(
|
||||||
"testFind(Read,Commit/PessimisticRead,Commit)",
|
"testFind(Read,Commit/PessimisticRead,Commit)",
|
||||||
LockModeType.READ, Act.CommitTx, 1, null,
|
LockModeType.READ, Act.CommitTx, 1, ExpectingOptimisticLockExClass,
|
||||||
LockModeType.PESSIMISTIC_READ, Act.CommitTx, 0, null);
|
LockModeType.PESSIMISTIC_READ, Act.CommitTx, 1, null);
|
||||||
commonFindTest(
|
commonFindTest(
|
||||||
"testFind(Read,Commit/PessimisticRead,Rollback)",
|
"testFind(Read,Commit/PessimisticRead,Rollback)",
|
||||||
LockModeType.READ, Act.CommitTx, 1, null,
|
LockModeType.READ, Act.CommitTx, 1, null,
|
||||||
|
@ -70,8 +70,8 @@ public class TestMixedLockManagerFindPermutation extends SequencedActionsTest {
|
||||||
public void testFindReadPessimisticWrite() {
|
public void testFindReadPessimisticWrite() {
|
||||||
commonFindTest(
|
commonFindTest(
|
||||||
"testFind(Read,Commit/PessimisticWrite,Commit)",
|
"testFind(Read,Commit/PessimisticWrite,Commit)",
|
||||||
LockModeType.READ, Act.CommitTx, 1, null,
|
LockModeType.READ, Act.CommitTx, 1, ExpectingOptimisticLockExClass,
|
||||||
LockModeType.PESSIMISTIC_WRITE, Act.CommitTx, 0, null);
|
LockModeType.PESSIMISTIC_WRITE, Act.CommitTx, 1, null);
|
||||||
commonFindTest(
|
commonFindTest(
|
||||||
"testFind(Read,Commit/PessimisticWrite,Rollback)",
|
"testFind(Read,Commit/PessimisticWrite,Rollback)",
|
||||||
LockModeType.READ, Act.CommitTx, 1, null,
|
LockModeType.READ, Act.CommitTx, 1, null,
|
||||||
|
@ -115,8 +115,8 @@ public class TestMixedLockManagerFindPermutation extends SequencedActionsTest {
|
||||||
public void testFindWritePessimisticRead() {
|
public void testFindWritePessimisticRead() {
|
||||||
commonFindTest(
|
commonFindTest(
|
||||||
"testFind(Write,Commit/PessimisticRead,Commit)",
|
"testFind(Write,Commit/PessimisticRead,Commit)",
|
||||||
LockModeType.WRITE, Act.CommitTx, 1, null,
|
LockModeType.WRITE, Act.CommitTx, 1, ExpectingOptimisticLockExClass,
|
||||||
LockModeType.PESSIMISTIC_READ, Act.CommitTx, 0, null);
|
LockModeType.PESSIMISTIC_READ, Act.CommitTx, 1, null);
|
||||||
commonFindTest(
|
commonFindTest(
|
||||||
"testFind(Write,Commit/PessimisticRead,Rollback)",
|
"testFind(Write,Commit/PessimisticRead,Rollback)",
|
||||||
LockModeType.WRITE, Act.CommitTx, 1, null,
|
LockModeType.WRITE, Act.CommitTx, 1, null,
|
||||||
|
@ -126,8 +126,8 @@ public class TestMixedLockManagerFindPermutation extends SequencedActionsTest {
|
||||||
public void testFindWritePessimisticWrite() {
|
public void testFindWritePessimisticWrite() {
|
||||||
commonFindTest(
|
commonFindTest(
|
||||||
"testFind(Write,Commit/PessimisticWrite,Commit)",
|
"testFind(Write,Commit/PessimisticWrite,Commit)",
|
||||||
LockModeType.WRITE, Act.CommitTx, 1, null,
|
LockModeType.WRITE, Act.CommitTx, 1, ExpectingOptimisticLockExClass,
|
||||||
LockModeType.PESSIMISTIC_WRITE, Act.CommitTx, 0, null);
|
LockModeType.PESSIMISTIC_WRITE, Act.CommitTx, 1, null);
|
||||||
commonFindTest(
|
commonFindTest(
|
||||||
"testFind(Write,Commit/PessimisticWrite,Rollback)",
|
"testFind(Write,Commit/PessimisticWrite,Rollback)",
|
||||||
LockModeType.WRITE, Act.CommitTx, 1, null,
|
LockModeType.WRITE, Act.CommitTx, 1, null,
|
||||||
|
@ -172,7 +172,7 @@ public class TestMixedLockManagerFindPermutation extends SequencedActionsTest {
|
||||||
commonFindTest(
|
commonFindTest(
|
||||||
"testFind(PessimisticRead,Commit/PessimisticRead,Commit)",
|
"testFind(PessimisticRead,Commit/PessimisticRead,Commit)",
|
||||||
LockModeType.PESSIMISTIC_READ, Act.CommitTx, 1, null,
|
LockModeType.PESSIMISTIC_READ, Act.CommitTx, 1, null,
|
||||||
LockModeType.PESSIMISTIC_READ, Act.CommitTx, 0, null);
|
LockModeType.PESSIMISTIC_READ, Act.CommitTx, 1, null);
|
||||||
commonFindTest(
|
commonFindTest(
|
||||||
"testFind(PessimisticRead,Commit/PessimisticRead,Rollback)",
|
"testFind(PessimisticRead,Commit/PessimisticRead,Rollback)",
|
||||||
LockModeType.PESSIMISTIC_READ, Act.CommitTx, 1, null,
|
LockModeType.PESSIMISTIC_READ, Act.CommitTx, 1, null,
|
||||||
|
@ -183,7 +183,7 @@ public class TestMixedLockManagerFindPermutation extends SequencedActionsTest {
|
||||||
commonFindTest(
|
commonFindTest(
|
||||||
"testFind(PessimisticRead,Commit/PessimisticWrite,Commit)",
|
"testFind(PessimisticRead,Commit/PessimisticWrite,Commit)",
|
||||||
LockModeType.PESSIMISTIC_READ, Act.CommitTx, 1, null,
|
LockModeType.PESSIMISTIC_READ, Act.CommitTx, 1, null,
|
||||||
LockModeType.PESSIMISTIC_WRITE, Act.CommitTx, 0, null);
|
LockModeType.PESSIMISTIC_WRITE, Act.CommitTx, 1, null);
|
||||||
commonFindTest(
|
commonFindTest(
|
||||||
"testFind(PessimisticRead,Commit/PessimisticWrite,Rollback)",
|
"testFind(PessimisticRead,Commit/PessimisticWrite,Rollback)",
|
||||||
LockModeType.PESSIMISTIC_READ, Act.CommitTx, 1, null,
|
LockModeType.PESSIMISTIC_READ, Act.CommitTx, 1, null,
|
||||||
|
@ -228,7 +228,7 @@ public class TestMixedLockManagerFindPermutation extends SequencedActionsTest {
|
||||||
commonFindTest(
|
commonFindTest(
|
||||||
"testFind(PessimsiticWrite,Commit/PessimisticRead,Commit)",
|
"testFind(PessimsiticWrite,Commit/PessimisticRead,Commit)",
|
||||||
LockModeType.PESSIMISTIC_WRITE, Act.CommitTx, 1, null,
|
LockModeType.PESSIMISTIC_WRITE, Act.CommitTx, 1, null,
|
||||||
LockModeType.PESSIMISTIC_READ, Act.CommitTx, 0, null);
|
LockModeType.PESSIMISTIC_READ, Act.CommitTx, 1, null);
|
||||||
commonFindTest(
|
commonFindTest(
|
||||||
"testFind(PessimsiticWrite,Commit/PessimisticRead,Rollback)",
|
"testFind(PessimsiticWrite,Commit/PessimisticRead,Rollback)",
|
||||||
LockModeType.PESSIMISTIC_WRITE, Act.CommitTx, 1, null,
|
LockModeType.PESSIMISTIC_WRITE, Act.CommitTx, 1, null,
|
||||||
|
@ -239,7 +239,7 @@ public class TestMixedLockManagerFindPermutation extends SequencedActionsTest {
|
||||||
commonFindTest(
|
commonFindTest(
|
||||||
"testFind(PessimsiticWrite,Commit/PessimisticWrite,Commit)",
|
"testFind(PessimsiticWrite,Commit/PessimisticWrite,Commit)",
|
||||||
LockModeType.PESSIMISTIC_WRITE, Act.CommitTx, 1, null,
|
LockModeType.PESSIMISTIC_WRITE, Act.CommitTx, 1, null,
|
||||||
LockModeType.PESSIMISTIC_WRITE, Act.CommitTx, 0, null);
|
LockModeType.PESSIMISTIC_WRITE, Act.CommitTx, 1, null);
|
||||||
commonFindTest(
|
commonFindTest(
|
||||||
"testFind(PessimsiticWrite,Commit/PessimisticWrite,Rollback)",
|
"testFind(PessimsiticWrite,Commit/PessimisticWrite,Rollback)",
|
||||||
LockModeType.PESSIMISTIC_WRITE, Act.CommitTx, 1, null,
|
LockModeType.PESSIMISTIC_WRITE, Act.CommitTx, 1, null,
|
||||||
|
@ -284,7 +284,7 @@ public class TestMixedLockManagerFindPermutation extends SequencedActionsTest {
|
||||||
commonFindTest(
|
commonFindTest(
|
||||||
"testFind(PessimsiticForceInc,Commit/PessimisticRead,Commit)",
|
"testFind(PessimsiticForceInc,Commit/PessimisticRead,Commit)",
|
||||||
LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.CommitTx, 1, null,
|
LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.CommitTx, 1, null,
|
||||||
LockModeType.PESSIMISTIC_READ, Act.CommitTx, 0, null);
|
LockModeType.PESSIMISTIC_READ, Act.CommitTx, 1, null);
|
||||||
commonFindTest(
|
commonFindTest(
|
||||||
"testFind(PessimsiticForceInc,Commit/PessimisticRead,Rollback)",
|
"testFind(PessimsiticForceInc,Commit/PessimisticRead,Rollback)",
|
||||||
LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.CommitTx, 1, null,
|
LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.CommitTx, 1, null,
|
||||||
|
@ -295,7 +295,7 @@ public class TestMixedLockManagerFindPermutation extends SequencedActionsTest {
|
||||||
commonFindTest(
|
commonFindTest(
|
||||||
"testFind(PessimsiticForceInc,Commit/PessimisticWrite,Commit)",
|
"testFind(PessimsiticForceInc,Commit/PessimisticWrite,Commit)",
|
||||||
LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.CommitTx, 1, null,
|
LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.CommitTx, 1, null,
|
||||||
LockModeType.PESSIMISTIC_WRITE, Act.CommitTx, 0, null);
|
LockModeType.PESSIMISTIC_WRITE, Act.CommitTx, 1, null);
|
||||||
commonFindTest(
|
commonFindTest(
|
||||||
"testFind(PessimsiticForceInc,Commit/PessimisticWrite,Rollback)",
|
"testFind(PessimsiticForceInc,Commit/PessimisticWrite,Rollback)",
|
||||||
LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.CommitTx, 1, null,
|
LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.CommitTx, 1, null,
|
||||||
|
@ -327,51 +327,57 @@ public class TestMixedLockManagerFindPermutation extends SequencedActionsTest {
|
||||||
", expectedEx= " + Arrays.toString(t2Exceptions)};
|
", expectedEx= " + Arrays.toString(t2Exceptions)};
|
||||||
|
|
||||||
Object[][] threadMain = {
|
Object[][] threadMain = {
|
||||||
{Act.CreateEm},
|
{Act.CreateEm},
|
||||||
{Act.Find},
|
{Act.Find},
|
||||||
{Act.SaveVersion},
|
{Act.SaveVersion},
|
||||||
{Act.TestEmployee, 1, Default_FirstName},
|
{Act.TestEmployee, 1, Default_FirstName},
|
||||||
|
{Act.CloseEm},
|
||||||
{Act.NewThread, 1 },
|
{Act.Sleep, 100},
|
||||||
{Act.NewThread, 2 },
|
|
||||||
{Act.StartThread, 1 },
|
{Act.CreateEm},
|
||||||
{Act.Wait},
|
{Act.StartTx},
|
||||||
{Act.StartThread, 2 },
|
{Act.FindWithLock, 1, t1Lock},
|
||||||
{Act.Notify, 1, 1000 },
|
{Act.SaveVersion},
|
||||||
{Act.Notify, 2, 1000 },
|
{Act.TestException},
|
||||||
{Act.WaitAllChildren},
|
|
||||||
{Act.Find},
|
{Act.NewThread, 1 },
|
||||||
{Act.TestEmployee, 1},
|
{Act.StartThread, 1 },
|
||||||
{Act.TestException, 1, t1Exceptions },
|
|
||||||
{Act.TestException, 2, t2Exceptions },
|
{Act.Wait},
|
||||||
};
|
{Act.UpdateEmployee},
|
||||||
Object[][] thread1 = {
|
{t1IsCommit},
|
||||||
{Act.CreateEm},
|
|
||||||
{Act.StartTx},
|
{Act.Notify, 1},
|
||||||
{Act.FindWithLock, 1, t1Lock},
|
|
||||||
{Act.SaveVersion},
|
{Act.Find},
|
||||||
{Act.TestException},
|
|
||||||
{Act.Notify, 0},
|
{Act.WaitAllChildren},
|
||||||
{Act.Wait},
|
{Act.Find},
|
||||||
{Act.UpdateEmployee},
|
{Act.TestEmployee, 1, null, t1VersionInc},
|
||||||
|
{Act.TestException, 0, t1Exceptions },
|
||||||
{t1IsCommit},
|
{Act.TestException, 1, t2Exceptions },
|
||||||
{Act.Find},
|
{Act.CloseEm}
|
||||||
{Act.TestEmployee, 1, null, t1VersionInc}
|
};
|
||||||
};
|
|
||||||
Object[][] thread2 = {
|
Object[][] thread1 = {
|
||||||
{Act.CreateEm},
|
{Act.CreateEm},
|
||||||
{Act.StartTx},
|
{Act.StartTx},
|
||||||
{Act.FindWithLock, 1, t2Lock},
|
{Act.FindWithLock, 1, t2Lock},
|
||||||
{Act.SaveVersion},
|
{Act.SaveVersion},
|
||||||
{Act.Notify, 0},
|
{Act.TestException},
|
||||||
{Act.Wait},
|
{Act.Notify, 0},
|
||||||
|
|
||||||
{t2IsCommit},
|
{Act.Wait},
|
||||||
{Act.Find},
|
{Act.Sleep, 2000}, // sleep for at least 2 sec so that the entity name updated with timestamp
|
||||||
{Act.TestEmployee, 1, null, t2VersionInc}
|
// in each of the 2 threads are different.
|
||||||
};
|
{Act.UpdateEmployee},
|
||||||
launchActionSequence(testName, parameters, threadMain, thread1,
|
|
||||||
thread2);
|
{t2IsCommit},
|
||||||
|
{Act.Sleep, 1000},
|
||||||
|
{Act.Find},
|
||||||
|
{Act.TestEmployee, 1, null, t2VersionInc},
|
||||||
|
{Act.CloseEm}
|
||||||
|
};
|
||||||
|
launchActionSequence(testName, parameters, threadMain, thread1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,6 +109,7 @@ public class TestMixedLockManagerLockBasic extends SequencedActionsTest {
|
||||||
{ Act.Clear },
|
{ Act.Clear },
|
||||||
{ Act.Find, 1 },
|
{ Act.Find, 1 },
|
||||||
{ Act.TestEmployee, 1, lockMode.toString(), 0 },
|
{ Act.TestEmployee, 1, lockMode.toString(), 0 },
|
||||||
|
{ Act.CloseEm }
|
||||||
};
|
};
|
||||||
launchActionSequence(testName, "LockMode=" + lockMode, threadMain);
|
launchActionSequence(testName, "LockMode=" + lockMode, threadMain);
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,6 +66,7 @@ public class TestMixedLockManagerLockException extends SequencedActionsTest {
|
||||||
|
|
||||||
{Act.Lock, 1, LockModeType.PESSIMISTIC_FORCE_INCREMENT },
|
{Act.Lock, 1, LockModeType.PESSIMISTIC_FORCE_INCREMENT },
|
||||||
{Act.TestException, 0, TransactionRequiredException.class },
|
{Act.TestException, 0, TransactionRequiredException.class },
|
||||||
|
{Act.CloseEm}
|
||||||
};
|
};
|
||||||
|
|
||||||
launchActionSequence("testLockTxReqExceptions()",
|
launchActionSequence("testLockTxReqExceptions()",
|
||||||
|
@ -124,7 +125,8 @@ public class TestMixedLockManagerLockException extends SequencedActionsTest {
|
||||||
{Act.TestException, 0, IllegalArgumentException.class },
|
{Act.TestException, 0, IllegalArgumentException.class },
|
||||||
{Act.LockObject, "null", LockModeType.PESSIMISTIC_FORCE_INCREMENT },
|
{Act.LockObject, "null", LockModeType.PESSIMISTIC_FORCE_INCREMENT },
|
||||||
{Act.TestException, 0, IllegalArgumentException.class },
|
{Act.TestException, 0, IllegalArgumentException.class },
|
||||||
};
|
{Act.CloseEm}
|
||||||
|
};
|
||||||
launchActionSequence("testLockIllegalArgrumentExceptions()",
|
launchActionSequence("testLockIllegalArgrumentExceptions()",
|
||||||
"Test invalid entity.", threadMainInvEntityIllegalArgTest);
|
"Test invalid entity.", threadMainInvEntityIllegalArgTest);
|
||||||
|
|
||||||
|
@ -163,6 +165,7 @@ public class TestMixedLockManagerLockException extends SequencedActionsTest {
|
||||||
|
|
||||||
{Act.Lock, 2, LockModeType.PESSIMISTIC_FORCE_INCREMENT },
|
{Act.Lock, 2, LockModeType.PESSIMISTIC_FORCE_INCREMENT },
|
||||||
{Act.TestException, 0, IllegalArgumentException.class },
|
{Act.TestException, 0, IllegalArgumentException.class },
|
||||||
|
{Act.CloseEm}
|
||||||
};
|
};
|
||||||
launchActionSequence("testLockIllegalArgrumentExceptions()",
|
launchActionSequence("testLockIllegalArgrumentExceptions()",
|
||||||
"Test detached entity.", threadMainDetachEntityIllegalArgTest);
|
"Test detached entity.", threadMainDetachEntityIllegalArgTest);
|
||||||
|
@ -200,6 +203,7 @@ public class TestMixedLockManagerLockException extends SequencedActionsTest {
|
||||||
|
|
||||||
{Act.Lock, 2, LockModeType.PESSIMISTIC_FORCE_INCREMENT },
|
{Act.Lock, 2, LockModeType.PESSIMISTIC_FORCE_INCREMENT },
|
||||||
{Act.TestException, 0, IllegalArgumentException.class },
|
{Act.TestException, 0, IllegalArgumentException.class },
|
||||||
|
{Act.CloseEm}
|
||||||
};
|
};
|
||||||
launchActionSequence("testLockIllegalArgrumentExceptions()",
|
launchActionSequence("testLockIllegalArgrumentExceptions()",
|
||||||
"Test detached entity using serialization.",
|
"Test detached entity using serialization.",
|
||||||
|
@ -238,6 +242,7 @@ public class TestMixedLockManagerLockException extends SequencedActionsTest {
|
||||||
{Act.TestException},
|
{Act.TestException},
|
||||||
|
|
||||||
{Act.RollbackTx},
|
{Act.RollbackTx},
|
||||||
|
{Act.CloseEm}
|
||||||
};
|
};
|
||||||
launchActionSequence(
|
launchActionSequence(
|
||||||
"testLockIllegalArgrumentExceptions()",
|
"testLockIllegalArgrumentExceptions()",
|
||||||
|
@ -296,6 +301,7 @@ public class TestMixedLockManagerLockException extends SequencedActionsTest {
|
||||||
? OptimisticLockException.class : null},
|
? OptimisticLockException.class : null},
|
||||||
|
|
||||||
{Act.RollbackTx},
|
{Act.RollbackTx},
|
||||||
|
{Act.CloseEm}
|
||||||
};
|
};
|
||||||
Object[][] thread1OptLockExTest = {
|
Object[][] thread1OptLockExTest = {
|
||||||
{Act.CreateEm},
|
{Act.CreateEm},
|
||||||
|
@ -309,6 +315,7 @@ public class TestMixedLockManagerLockException extends SequencedActionsTest {
|
||||||
|
|
||||||
{Act.CommitTx},
|
{Act.CommitTx},
|
||||||
{Act.Notify, 0},
|
{Act.Notify, 0},
|
||||||
|
{Act.CloseEm}
|
||||||
};
|
};
|
||||||
launchActionSequence("testLockOptimisticLockExceptions()", null,
|
launchActionSequence("testLockOptimisticLockExceptions()", null,
|
||||||
threadMainOptLockExTest, thread1OptLockExTest);
|
threadMainOptLockExTest, thread1OptLockExTest);
|
||||||
|
|
|
@ -38,55 +38,55 @@ public class TestMixedLockManagerLockPermutation extends SequencedActionsTest {
|
||||||
commonLockTest(
|
commonLockTest(
|
||||||
"testLock(Read,Commit/Read,Commit)",
|
"testLock(Read,Commit/Read,Commit)",
|
||||||
LockModeType.READ, Act.CommitTx, 1, null,
|
LockModeType.READ, Act.CommitTx, 1, null,
|
||||||
LockModeType.READ, Act.CommitTx, 1, ExpectingOptimisticLockExClass);
|
LockModeType.READ, Act.CommitTx, 1, null, ExpectingOptimisticLockExClass);
|
||||||
commonLockTest(
|
commonLockTest(
|
||||||
"testLock(Read,Commit/Read,Rollback)",
|
"testLock(Read,Commit/Read,Rollback)",
|
||||||
LockModeType.READ, Act.CommitTx, 1, null,
|
LockModeType.READ, Act.CommitTx, 1, null,
|
||||||
LockModeType.READ, Act.RollbackTx, 1, null);
|
LockModeType.READ, Act.RollbackTx, 1, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testLockReadWrite() {
|
public void testLockReadWrite() {
|
||||||
commonLockTest(
|
commonLockTest(
|
||||||
"testLock(Read,Commit/Write,Commit)",
|
"testLock(Read,Commit/Write,Commit)",
|
||||||
LockModeType.READ, Act.CommitTx, 1, null,
|
LockModeType.READ, Act.CommitTx, 1, null,
|
||||||
LockModeType.WRITE, Act.CommitTx, 1, ExpectingOptimisticLockExClass);
|
LockModeType.WRITE, Act.CommitTx, 1, null, ExpectingOptimisticLockExClass);
|
||||||
commonLockTest(
|
commonLockTest(
|
||||||
"testLock(Read,Commit/Write,Rollback)",
|
"testLock(Read,Commit/Write,Rollback)",
|
||||||
LockModeType.READ, Act.CommitTx, 1, null,
|
LockModeType.READ, Act.CommitTx, 1, null,
|
||||||
LockModeType.WRITE, Act.RollbackTx, 1, null);
|
LockModeType.WRITE, Act.RollbackTx, 1, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testLockReadPessimisticRead() {
|
public void testLockReadPessimisticRead() {
|
||||||
commonLockTest(
|
commonLockTest(
|
||||||
"testLock(Read,Commit/PessimisticRead,Commit)",
|
"testLock(Read,Commit/PessimisticRead,Commit)",
|
||||||
LockModeType.READ, Act.CommitTx, 1, null,
|
LockModeType.READ, Act.CommitTx, 1, ExpectingOptimisticLockExClass,
|
||||||
LockModeType.PESSIMISTIC_READ, Act.CommitTx, 0, null);
|
LockModeType.PESSIMISTIC_READ, Act.CommitTx, 1, null, null);
|
||||||
commonLockTest(
|
commonLockTest(
|
||||||
"testLock(Read,Commit/PessimisticRead,Rollback)",
|
"testLock(Read,Commit/PessimisticRead,Rollback)",
|
||||||
LockModeType.READ, Act.CommitTx, 1, null,
|
LockModeType.READ, Act.CommitTx, 1, null,
|
||||||
LockModeType.PESSIMISTIC_READ, Act.RollbackTx, 1, null);
|
LockModeType.PESSIMISTIC_READ, Act.RollbackTx, 1, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testLockReadPessimisticWrite() {
|
public void testLockReadPessimisticWrite() {
|
||||||
commonLockTest(
|
commonLockTest(
|
||||||
"testLock(Read,Commit/PessimisticWrite,Commit)",
|
"testLock(Read,Commit/PessimisticWrite,Commit)",
|
||||||
LockModeType.READ, Act.CommitTx, 1, null,
|
LockModeType.READ, Act.CommitTx, 1, ExpectingOptimisticLockExClass,
|
||||||
LockModeType.PESSIMISTIC_WRITE, Act.CommitTx, 0, null);
|
LockModeType.PESSIMISTIC_WRITE, Act.CommitTx, 1, null, null);
|
||||||
commonLockTest(
|
commonLockTest(
|
||||||
"testLock(Read,Commit/PessimisticWrite,Rollback)",
|
"testLock(Read,Commit/PessimisticWrite,Rollback)",
|
||||||
LockModeType.READ, Act.CommitTx, 1, null,
|
LockModeType.READ, Act.CommitTx, 1, null,
|
||||||
LockModeType.PESSIMISTIC_WRITE, Act.RollbackTx, 1, null);
|
LockModeType.PESSIMISTIC_WRITE, Act.RollbackTx, 1, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testLockReadPessimisticForceInc() {
|
public void testLockReadPessimisticForceInc() {
|
||||||
commonLockTest(
|
commonLockTest(
|
||||||
"testLock(Read,Commit/PessimisticForceInc,Commit)",
|
"testLock(Read,Commit/PessimisticForceInc,Commit)",
|
||||||
LockModeType.READ, Act.CommitTx, 1, ExpectingOptimisticLockExClass,
|
LockModeType.READ, Act.CommitTx, 1, ExpectingOptimisticLockExClass,
|
||||||
LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.CommitTx, 1, null);
|
LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.CommitTx, 1, null, null);
|
||||||
commonLockTest(
|
commonLockTest(
|
||||||
"testLock(Read,Commit/PessimisticForceInc,Rollback)",
|
"testLock(Read,Commit/PessimisticForceInc,Rollback)",
|
||||||
LockModeType.READ, Act.CommitTx, 1, null,
|
LockModeType.READ, Act.CommitTx, 1, null,
|
||||||
LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.RollbackTx, 1, null);
|
LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.RollbackTx, 1, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ======== Thread 1 : Write Lock ============*/
|
/* ======== Thread 1 : Write Lock ============*/
|
||||||
|
@ -94,55 +94,55 @@ public class TestMixedLockManagerLockPermutation extends SequencedActionsTest {
|
||||||
commonLockTest(
|
commonLockTest(
|
||||||
"testLock(Write,Commit/Read,Commit)",
|
"testLock(Write,Commit/Read,Commit)",
|
||||||
LockModeType.WRITE, Act.CommitTx, 1, null,
|
LockModeType.WRITE, Act.CommitTx, 1, null,
|
||||||
LockModeType.READ, Act.CommitTx, 1, ExpectingOptimisticLockExClass);
|
LockModeType.READ, Act.CommitTx, 1, null, ExpectingOptimisticLockExClass);
|
||||||
commonLockTest(
|
commonLockTest(
|
||||||
"testLock(Write,Commit/Read,Rollback)",
|
"testLock(Write,Commit/Read,Rollback)",
|
||||||
LockModeType.WRITE, Act.CommitTx, 1, null,
|
LockModeType.WRITE, Act.CommitTx, 1, null,
|
||||||
LockModeType.READ, Act.RollbackTx, 1, null);
|
LockModeType.READ, Act.RollbackTx, 1, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testLockWriteWrite() {
|
public void testLockWriteWrite() {
|
||||||
commonLockTest(
|
commonLockTest(
|
||||||
"testLock(Write,Commit/Write,Commit)",
|
"testLock(Write,Commit/Write,Commit)",
|
||||||
LockModeType.WRITE, Act.CommitTx, 1, null,
|
LockModeType.WRITE, Act.CommitTx, 1, null,
|
||||||
LockModeType.WRITE, Act.CommitTx, 1, ExpectingOptimisticLockExClass);
|
LockModeType.WRITE, Act.CommitTx, 1, null, ExpectingOptimisticLockExClass);
|
||||||
commonLockTest(
|
commonLockTest(
|
||||||
"testLock(Write,Commit/Write,Rollback)",
|
"testLock(Write,Commit/Write,Rollback)",
|
||||||
LockModeType.WRITE, Act.CommitTx, 1, null,
|
LockModeType.WRITE, Act.CommitTx, 1, null,
|
||||||
LockModeType.WRITE, Act.RollbackTx, 1, null);
|
LockModeType.WRITE, Act.RollbackTx, 1, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testLockWritePessimisticRead() {
|
public void testLockWritePessimisticRead() {
|
||||||
commonLockTest(
|
commonLockTest(
|
||||||
"testLock(Write,Commit/PessimisticRead,Commit)",
|
"testLock(Write,Commit/PessimisticRead,Commit)",
|
||||||
LockModeType.WRITE, Act.CommitTx, 1, null,
|
LockModeType.WRITE, Act.CommitTx, 1, ExpectingOptimisticLockExClass,
|
||||||
LockModeType.PESSIMISTIC_READ, Act.CommitTx, 0, null);
|
LockModeType.PESSIMISTIC_READ, Act.CommitTx, 1, null, null);
|
||||||
commonLockTest(
|
commonLockTest(
|
||||||
"testLock(Write,Commit/PessimisticRead,Rollback)",
|
"testLock(Write,Commit/PessimisticRead,Rollback)",
|
||||||
LockModeType.WRITE, Act.CommitTx, 1, null,
|
LockModeType.WRITE, Act.CommitTx, 1, null,
|
||||||
LockModeType.PESSIMISTIC_READ, Act.RollbackTx, 1, null);
|
LockModeType.PESSIMISTIC_READ, Act.RollbackTx, 1, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testLockWritePessimisticWrite() {
|
public void testLockWritePessimisticWrite() {
|
||||||
commonLockTest(
|
commonLockTest(
|
||||||
"testLock(Write,Commit/PessimisticWrite,Commit)",
|
"testLock(Write,Commit/PessimisticWrite,Commit)",
|
||||||
LockModeType.WRITE, Act.CommitTx, 1, null,
|
LockModeType.WRITE, Act.CommitTx, 1, ExpectingOptimisticLockExClass,
|
||||||
LockModeType.PESSIMISTIC_WRITE, Act.CommitTx, 0, null);
|
LockModeType.PESSIMISTIC_WRITE, Act.CommitTx, 1, null, null);
|
||||||
commonLockTest(
|
commonLockTest(
|
||||||
"testLock(Write,Commit/PessimisticWrite,Rollback)",
|
"testLock(Write,Commit/PessimisticWrite,Rollback)",
|
||||||
LockModeType.WRITE, Act.CommitTx, 1, null,
|
LockModeType.WRITE, Act.CommitTx, 1, null,
|
||||||
LockModeType.PESSIMISTIC_WRITE, Act.RollbackTx, 1, null);
|
LockModeType.PESSIMISTIC_WRITE, Act.RollbackTx, 1, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testLockWritePessimisticForceInc() {
|
public void testLockWritePessimisticForceInc() {
|
||||||
commonLockTest(
|
commonLockTest(
|
||||||
"testLock(Write,Commit/PessimisticForceInc,Commit)",
|
"testLock(Write,Commit/PessimisticForceInc,Commit)",
|
||||||
LockModeType.WRITE, Act.CommitTx, 1, ExpectingOptimisticLockExClass,
|
LockModeType.WRITE, Act.CommitTx, 1, ExpectingOptimisticLockExClass,
|
||||||
LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.CommitTx, 1, null);
|
LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.CommitTx, 1, null, null);
|
||||||
commonLockTest(
|
commonLockTest(
|
||||||
"testLock(Write,Commit/PessimisticForceInc,Rollback)",
|
"testLock(Write,Commit/PessimisticForceInc,Rollback)",
|
||||||
LockModeType.WRITE, Act.CommitTx, 1, null,
|
LockModeType.WRITE, Act.CommitTx, 1, null,
|
||||||
LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.RollbackTx, 1, null);
|
LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.RollbackTx, 1, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ======== Thread 1 : PessimisticRead Lock ============*/
|
/* ======== Thread 1 : PessimisticRead Lock ============*/
|
||||||
|
@ -150,55 +150,58 @@ public class TestMixedLockManagerLockPermutation extends SequencedActionsTest {
|
||||||
commonLockTest(
|
commonLockTest(
|
||||||
"testLock(PessimisticRead,Commit/Read,Commit)",
|
"testLock(PessimisticRead,Commit/Read,Commit)",
|
||||||
LockModeType.PESSIMISTIC_READ, Act.CommitTx, 1, null,
|
LockModeType.PESSIMISTIC_READ, Act.CommitTx, 1, null,
|
||||||
LockModeType.READ, Act.CommitTx, 1, ExpectingOptimisticLockExClass);
|
LockModeType.READ, Act.CommitTx, 1, null, ExpectingOptimisticLockExClass);
|
||||||
commonLockTest(
|
commonLockTest(
|
||||||
"testLock(PessimisticRead,Commit/Read,Rollback)",
|
"testLock(PessimisticRead,Commit/Read,Rollback)",
|
||||||
LockModeType.PESSIMISTIC_READ, Act.CommitTx, 1, null,
|
LockModeType.PESSIMISTIC_READ, Act.CommitTx, 1, null,
|
||||||
LockModeType.READ, Act.RollbackTx, 1, null);
|
LockModeType.READ, Act.RollbackTx, 1, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testLockPessimisticReadWrite() {
|
public void testLockPessimisticReadWrite() {
|
||||||
commonLockTest(
|
commonLockTest(
|
||||||
"testLock(PessimisticRead,Commit/Write,Commit)",
|
"testLock(PessimisticRead,Commit/Write,Commit)",
|
||||||
LockModeType.PESSIMISTIC_READ, Act.CommitTx, 1, null,
|
LockModeType.PESSIMISTIC_READ, Act.CommitTx, 1, null,
|
||||||
LockModeType.WRITE, Act.CommitTx, 1, ExpectingOptimisticLockExClass);
|
LockModeType.WRITE, Act.CommitTx, 1, null, ExpectingOptimisticLockExClass);
|
||||||
commonLockTest(
|
commonLockTest(
|
||||||
"testLock(PessimisticRead,Commit/Write,Rollback)",
|
"testLock(PessimisticRead,Commit/Write,Rollback)",
|
||||||
LockModeType.PESSIMISTIC_READ, Act.CommitTx, 1, null,
|
LockModeType.PESSIMISTIC_READ, Act.CommitTx, 1, null,
|
||||||
LockModeType.WRITE, Act.RollbackTx, 1, null);
|
LockModeType.WRITE, Act.RollbackTx, 1, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testLockPessimisticReadPessimisticRead() {
|
public void testLockPessimisticReadPessimisticRead() {
|
||||||
commonLockTest(
|
commonLockTest(
|
||||||
"testLock(PessimisticRead,Commit/PessimisticRead,Commit)",
|
"testLock(PessimisticRead,Commit/PessimisticRead,Commit)",
|
||||||
LockModeType.PESSIMISTIC_READ, Act.CommitTx, 1, null,
|
LockModeType.PESSIMISTIC_READ, Act.CommitTx, 1, null,
|
||||||
LockModeType.PESSIMISTIC_READ, Act.CommitTx, 1, ExpectingOptimisticLockExClass);
|
LockModeType.PESSIMISTIC_READ, Act.CommitTx, 1, ExpectingOptimisticLockExClass,
|
||||||
|
ExpectingOptimisticLockExClass);
|
||||||
commonLockTest(
|
commonLockTest(
|
||||||
"testLock(PessimisticRead,Commit/PessimisticRead,Rollback)",
|
"testLock(PessimisticRead,Commit/PessimisticRead,Rollback)",
|
||||||
LockModeType.PESSIMISTIC_READ, Act.CommitTx, 1, null,
|
LockModeType.PESSIMISTIC_READ, Act.CommitTx, 1, null,
|
||||||
LockModeType.PESSIMISTIC_READ, Act.RollbackTx, 1, ExpectingOptimisticLockExClass);
|
LockModeType.PESSIMISTIC_READ, Act.RollbackTx, 1, ExpectingOptimisticLockExClass, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testLockPessimisticReadPessimisticWrite() {
|
public void testLockPessimisticReadPessimisticWrite() {
|
||||||
commonLockTest(
|
commonLockTest(
|
||||||
"testLock(PessimisticRead,Commit/PessimisticWrite,Commit)",
|
"testLock(PessimisticRead,Commit/PessimisticWrite,Commit)",
|
||||||
LockModeType.PESSIMISTIC_READ, Act.CommitTx, 1, null,
|
LockModeType.PESSIMISTIC_READ, Act.CommitTx, 1, null,
|
||||||
LockModeType.PESSIMISTIC_WRITE, Act.CommitTx, 1, ExpectingOptimisticLockExClass);
|
LockModeType.PESSIMISTIC_WRITE, Act.CommitTx, 1, ExpectingOptimisticLockExClass,
|
||||||
|
ExpectingOptimisticLockExClass);
|
||||||
commonLockTest(
|
commonLockTest(
|
||||||
"testLock(PessimisticRead,Commit/PessimisticWrite,Rollback)",
|
"testLock(PessimisticRead,Commit/PessimisticWrite,Rollback)",
|
||||||
LockModeType.PESSIMISTIC_READ, Act.CommitTx, 1, null,
|
LockModeType.PESSIMISTIC_READ, Act.CommitTx, 1, null,
|
||||||
LockModeType.PESSIMISTIC_WRITE, Act.RollbackTx, 1, ExpectingOptimisticLockExClass);
|
LockModeType.PESSIMISTIC_WRITE, Act.RollbackTx, 1, ExpectingOptimisticLockExClass, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testLockPessimisticReadPessimisticForceInc() {
|
public void testLockPessimisticReadPessimisticForceInc() {
|
||||||
commonLockTest(
|
commonLockTest(
|
||||||
"testLock(PessimisticRead,Commit/PessimisticForceInc,Commit)",
|
"testLock(PessimisticRead,Commit/PessimisticForceInc,Commit)",
|
||||||
LockModeType.PESSIMISTIC_READ, Act.CommitTx, 1, null,
|
LockModeType.PESSIMISTIC_READ, Act.CommitTx, 1, null,
|
||||||
LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.CommitTx, 1, ExpectingOptimisticLockExClass);
|
LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.CommitTx, 1, ExpectingOptimisticLockExClass,
|
||||||
|
ExpectingOptimisticLockExClass);
|
||||||
commonLockTest(
|
commonLockTest(
|
||||||
"testLock(PessimisticRead,Commit/PessimisticForceInc,Rollback)",
|
"testLock(PessimisticRead,Commit/PessimisticForceInc,Rollback)",
|
||||||
LockModeType.PESSIMISTIC_READ, Act.CommitTx, 1, null,
|
LockModeType.PESSIMISTIC_READ, Act.CommitTx, 1, null,
|
||||||
LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.RollbackTx, 1, ExpectingOptimisticLockExClass);
|
LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.RollbackTx, 1, ExpectingOptimisticLockExClass, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ======== Thread 1 : Pessimsitic Write Lock ============*/
|
/* ======== Thread 1 : Pessimsitic Write Lock ============*/
|
||||||
|
@ -206,55 +209,58 @@ public class TestMixedLockManagerLockPermutation extends SequencedActionsTest {
|
||||||
commonLockTest(
|
commonLockTest(
|
||||||
"testLock(PessimsiticWrite,Commit/Read,Commit)",
|
"testLock(PessimsiticWrite,Commit/Read,Commit)",
|
||||||
LockModeType.PESSIMISTIC_WRITE, Act.CommitTx, 1, null,
|
LockModeType.PESSIMISTIC_WRITE, Act.CommitTx, 1, null,
|
||||||
LockModeType.READ, Act.CommitTx, 1, ExpectingOptimisticLockExClass);
|
LockModeType.READ, Act.CommitTx, 1, null, ExpectingOptimisticLockExClass);
|
||||||
commonLockTest(
|
commonLockTest(
|
||||||
"testLock(PessimsiticWrite,Commit/Read,Rollback)",
|
"testLock(PessimsiticWrite,Commit/Read,Rollback)",
|
||||||
LockModeType.PESSIMISTIC_WRITE, Act.CommitTx, 1, null,
|
LockModeType.PESSIMISTIC_WRITE, Act.CommitTx, 1, null,
|
||||||
LockModeType.READ, Act.RollbackTx, 1, null);
|
LockModeType.READ, Act.RollbackTx, 1, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testLockPessimsiticWriteWrite() {
|
public void testLockPessimsiticWriteWrite() {
|
||||||
commonLockTest(
|
commonLockTest(
|
||||||
"testLock(PessimsiticWrite,Commit/Write,Commit)",
|
"testLock(PessimsiticWrite,Commit/Write,Commit)",
|
||||||
LockModeType.PESSIMISTIC_WRITE, Act.CommitTx, 1, null,
|
LockModeType.PESSIMISTIC_WRITE, Act.CommitTx, 1, null,
|
||||||
LockModeType.WRITE, Act.CommitTx, 1, ExpectingOptimisticLockExClass);
|
LockModeType.WRITE, Act.CommitTx, 1, null, ExpectingOptimisticLockExClass);
|
||||||
commonLockTest(
|
commonLockTest(
|
||||||
"testLock(PessimsiticWrite,Commit/Write,Rollback)",
|
"testLock(PessimsiticWrite,Commit/Write,Rollback)",
|
||||||
LockModeType.PESSIMISTIC_WRITE, Act.CommitTx, 1, null,
|
LockModeType.PESSIMISTIC_WRITE, Act.CommitTx, 1, null,
|
||||||
LockModeType.WRITE, Act.RollbackTx, 1, null);
|
LockModeType.WRITE, Act.RollbackTx, 1, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testLockPessimsiticWritePessimisticRead() {
|
public void testLockPessimsiticWritePessimisticRead() {
|
||||||
commonLockTest(
|
commonLockTest(
|
||||||
"testLock(PessimsiticWrite,Commit/PessimisticRead,Commit)",
|
"testLock(PessimsiticWrite,Commit/PessimisticRead,Commit)",
|
||||||
LockModeType.PESSIMISTIC_WRITE, Act.CommitTx, 1, null,
|
LockModeType.PESSIMISTIC_WRITE, Act.CommitTx, 1, null,
|
||||||
LockModeType.PESSIMISTIC_READ, Act.CommitTx, 1, ExpectingOptimisticLockExClass);
|
LockModeType.PESSIMISTIC_READ, Act.CommitTx, 1, ExpectingOptimisticLockExClass,
|
||||||
|
ExpectingOptimisticLockExClass);
|
||||||
commonLockTest(
|
commonLockTest(
|
||||||
"testLock(PessimsiticWrite,Commit/PessimisticRead,Rollback)",
|
"testLock(PessimsiticWrite,Commit/PessimisticRead,Rollback)",
|
||||||
LockModeType.PESSIMISTIC_WRITE, Act.CommitTx, 1, null,
|
LockModeType.PESSIMISTIC_WRITE, Act.CommitTx, 1, null,
|
||||||
LockModeType.PESSIMISTIC_READ, Act.RollbackTx, 1, ExpectingOptimisticLockExClass);
|
LockModeType.PESSIMISTIC_READ, Act.RollbackTx, 1, ExpectingOptimisticLockExClass, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testLockPessimsiticWritePessimisticWrite() {
|
public void testLockPessimsiticWritePessimisticWrite() {
|
||||||
commonLockTest(
|
commonLockTest(
|
||||||
"testLock(PessimsiticWrite,Commit/PessimisticWrite,Commit)",
|
"testLock(PessimsiticWrite,Commit/PessimisticWrite,Commit)",
|
||||||
LockModeType.PESSIMISTIC_WRITE, Act.CommitTx, 1, null,
|
LockModeType.PESSIMISTIC_WRITE, Act.CommitTx, 1, null,
|
||||||
LockModeType.PESSIMISTIC_WRITE, Act.CommitTx, 1, ExpectingOptimisticLockExClass);
|
LockModeType.PESSIMISTIC_WRITE, Act.CommitTx, 1, ExpectingOptimisticLockExClass,
|
||||||
|
ExpectingOptimisticLockExClass);
|
||||||
commonLockTest(
|
commonLockTest(
|
||||||
"testLock(PessimsiticWrite,Commit/PessimisticWrite,Rollback)",
|
"testLock(PessimsiticWrite,Commit/PessimisticWrite,Rollback)",
|
||||||
LockModeType.PESSIMISTIC_WRITE, Act.CommitTx, 1, null,
|
LockModeType.PESSIMISTIC_WRITE, Act.CommitTx, 1, null,
|
||||||
LockModeType.PESSIMISTIC_WRITE, Act.RollbackTx, 1, ExpectingOptimisticLockExClass);
|
LockModeType.PESSIMISTIC_WRITE, Act.RollbackTx, 1, ExpectingOptimisticLockExClass, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testLockPessimsiticWritePessimisticForceInc() {
|
public void testLockPessimsiticWritePessimisticForceInc() {
|
||||||
commonLockTest(
|
commonLockTest(
|
||||||
"testLock(PessimsiticWrite,Commit/PessimisticForceInc,Commit)",
|
"testLock(PessimsiticWrite,Commit/PessimisticForceInc,Commit)",
|
||||||
LockModeType.PESSIMISTIC_WRITE, Act.CommitTx, 1, null,
|
LockModeType.PESSIMISTIC_WRITE, Act.CommitTx, 1, null,
|
||||||
LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.CommitTx, 1, ExpectingOptimisticLockExClass);
|
LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.CommitTx, 1, ExpectingOptimisticLockExClass,
|
||||||
|
ExpectingOptimisticLockExClass);
|
||||||
commonLockTest(
|
commonLockTest(
|
||||||
"testLock(PessimsiticWrite,Commit/PessimisticForceInc,Rollback)",
|
"testLock(PessimsiticWrite,Commit/PessimisticForceInc,Rollback)",
|
||||||
LockModeType.PESSIMISTIC_WRITE, Act.CommitTx, 1, null,
|
LockModeType.PESSIMISTIC_WRITE, Act.CommitTx, 1, null,
|
||||||
LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.RollbackTx, 1, ExpectingOptimisticLockExClass);
|
LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.RollbackTx, 1, ExpectingOptimisticLockExClass, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ======== Thread 1 : Pessimsitic Force Increment Lock ============*/
|
/* ======== Thread 1 : Pessimsitic Force Increment Lock ============*/
|
||||||
|
@ -262,62 +268,65 @@ public class TestMixedLockManagerLockPermutation extends SequencedActionsTest {
|
||||||
commonLockTest(
|
commonLockTest(
|
||||||
"testLock(PessimsiticForceInc,Commit/Read,Commit)",
|
"testLock(PessimsiticForceInc,Commit/Read,Commit)",
|
||||||
LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.CommitTx, 1, null,
|
LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.CommitTx, 1, null,
|
||||||
LockModeType.READ, Act.CommitTx, 1, ExpectingOptimisticLockExClass);
|
LockModeType.READ, Act.CommitTx, 1, null, ExpectingOptimisticLockExClass);
|
||||||
commonLockTest(
|
commonLockTest(
|
||||||
"testLock(PessimsiticForceInc,Commit/Read,Rollback)",
|
"testLock(PessimsiticForceInc,Commit/Read,Rollback)",
|
||||||
LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.CommitTx, 1, null,
|
LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.CommitTx, 1, null,
|
||||||
LockModeType.READ, Act.RollbackTx, 1, null);
|
LockModeType.READ, Act.RollbackTx, 1, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testLockPessimsiticForceIncWrite() {
|
public void testLockPessimsiticForceIncWrite() {
|
||||||
commonLockTest(
|
commonLockTest(
|
||||||
"testLock(PessimsiticForceInc,Commit/Write,Commit)",
|
"testLock(PessimsiticForceInc,Commit/Write,Commit)",
|
||||||
LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.CommitTx, 1, null,
|
LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.CommitTx, 1, null,
|
||||||
LockModeType.WRITE, Act.CommitTx, 1, ExpectingOptimisticLockExClass);
|
LockModeType.WRITE, Act.CommitTx, 1, null, ExpectingOptimisticLockExClass);
|
||||||
commonLockTest(
|
commonLockTest(
|
||||||
"testLock(PessimsiticForceInc,Commit/Write,Rollback)",
|
"testLock(PessimsiticForceInc,Commit/Write,Rollback)",
|
||||||
LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.CommitTx, 1, null,
|
LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.CommitTx, 1, null,
|
||||||
LockModeType.WRITE, Act.RollbackTx, 1, null);
|
LockModeType.WRITE, Act.RollbackTx, 1, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testLockPessimsiticForceIncPessimisticRead() {
|
public void testLockPessimsiticForceIncPessimisticRead() {
|
||||||
commonLockTest(
|
commonLockTest(
|
||||||
"testLock(PessimsiticForceInc,Commit/PessimisticRead,Commit)",
|
"testLock(PessimsiticForceInc,Commit/PessimisticRead,Commit)",
|
||||||
LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.CommitTx, 1, null,
|
LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.CommitTx, 1, null,
|
||||||
LockModeType.PESSIMISTIC_READ, Act.CommitTx, 1, ExpectingOptimisticLockExClass);
|
LockModeType.PESSIMISTIC_READ, Act.CommitTx, 1, ExpectingOptimisticLockExClass,
|
||||||
|
ExpectingOptimisticLockExClass);
|
||||||
commonLockTest(
|
commonLockTest(
|
||||||
"testLock(PessimsiticForceInc,Commit/PessimisticRead,Rollback)",
|
"testLock(PessimsiticForceInc,Commit/PessimisticRead,Rollback)",
|
||||||
LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.CommitTx, 1, null,
|
LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.CommitTx, 1, null,
|
||||||
LockModeType.PESSIMISTIC_READ, Act.RollbackTx, 1, ExpectingOptimisticLockExClass);
|
LockModeType.PESSIMISTIC_READ, Act.RollbackTx, 1, ExpectingOptimisticLockExClass, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testLockPessimsiticForceIncPessimisticWrite() {
|
public void testLockPessimsiticForceIncPessimisticWrite() {
|
||||||
commonLockTest(
|
commonLockTest(
|
||||||
"testLock(PessimsiticForceInc,Commit/PessimisticWrite,Commit)",
|
"testLock(PessimsiticForceInc,Commit/PessimisticWrite,Commit)",
|
||||||
LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.CommitTx, 1, null,
|
LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.CommitTx, 1, null,
|
||||||
LockModeType.PESSIMISTIC_WRITE, Act.CommitTx, 1, ExpectingOptimisticLockExClass);
|
LockModeType.PESSIMISTIC_WRITE, Act.CommitTx, 1, ExpectingOptimisticLockExClass,
|
||||||
|
ExpectingOptimisticLockExClass);
|
||||||
commonLockTest(
|
commonLockTest(
|
||||||
"testLock(PessimsiticForceInc,Commit/PessimisticWrite,Rollback)",
|
"testLock(PessimsiticForceInc,Commit/PessimisticWrite,Rollback)",
|
||||||
LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.CommitTx, 1, null,
|
LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.CommitTx, 1, null,
|
||||||
LockModeType.PESSIMISTIC_WRITE, Act.RollbackTx, 1, ExpectingOptimisticLockExClass);
|
LockModeType.PESSIMISTIC_WRITE, Act.RollbackTx, 1, ExpectingOptimisticLockExClass, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testLockPessimsiticForceIncPessimisticForceInc() {
|
public void testLockPessimsiticForceIncPessimisticForceInc() {
|
||||||
commonLockTest(
|
commonLockTest(
|
||||||
"testLock(PessimsiticForceInc,Commit/PessimisticForceInc,Commit)",
|
"testLock(PessimsiticForceInc,Commit/PessimisticForceInc,Commit)",
|
||||||
LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.CommitTx, 1, null,
|
LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.CommitTx, 1, null,
|
||||||
LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.CommitTx, 1, ExpectingOptimisticLockExClass);
|
LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.CommitTx, 1, ExpectingOptimisticLockExClass,
|
||||||
|
ExpectingOptimisticLockExClass);
|
||||||
commonLockTest(
|
commonLockTest(
|
||||||
"testLock(PessimsiticForceInc,Commit/PessimisticForceInc,Rollback)",
|
"testLock(PessimsiticForceInc,Commit/PessimisticForceInc,Rollback)",
|
||||||
LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.CommitTx, 1, null,
|
LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.CommitTx, 1, null,
|
||||||
LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.RollbackTx, 1, ExpectingOptimisticLockExClass);
|
LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.RollbackTx, 1, ExpectingOptimisticLockExClass, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void commonLockTest( String testName,
|
private void commonLockTest( String testName,
|
||||||
LockModeType t1Lock, Act t1IsCommit, int t1VersionInc,
|
LockModeType t1Lock, Act t1IsCommit, int t1VersionInc,
|
||||||
Class<?>[] t1Exceptions,
|
Class<?>[] t1Exceptions,
|
||||||
LockModeType t2Lock, Act t2IsCommit, int t2VersionInc,
|
LockModeType t2Lock, Act t2IsCommit, int t2VersionInc,
|
||||||
Class<?>[] t2Exceptions ) {
|
Class<?>[] t2Exceptions, Class<?>[] t3Exceptions ) {
|
||||||
String[] parameters = new String[] {
|
String[] parameters = new String[] {
|
||||||
"Thread 1: lock= " + t1Lock + ", isCommit= " + t1IsCommit +
|
"Thread 1: lock= " + t1Lock + ", isCommit= " + t1IsCommit +
|
||||||
", versionInc= +" + t1VersionInc +
|
", versionInc= +" + t1VersionInc +
|
||||||
|
@ -327,53 +336,109 @@ public class TestMixedLockManagerLockPermutation extends SequencedActionsTest {
|
||||||
", expectedEx= " + Arrays.toString(t2Exceptions)};
|
", expectedEx= " + Arrays.toString(t2Exceptions)};
|
||||||
|
|
||||||
Object[][] threadMain = {
|
Object[][] threadMain = {
|
||||||
{Act.CreateEm},
|
{Act.CreateEm},
|
||||||
{Act.Find},
|
{Act.Find},
|
||||||
{Act.SaveVersion},
|
{Act.SaveVersion},
|
||||||
{Act.TestEmployee, 1, Default_FirstName},
|
{Act.TestEmployee, 1, Default_FirstName},
|
||||||
|
{Act.CloseEm},
|
||||||
{Act.NewThread, 1 },
|
{Act.Sleep, 100},
|
||||||
{Act.NewThread, 2 },
|
|
||||||
{Act.StartThread, 1 },
|
{Act.CreateEm},
|
||||||
{Act.Wait},
|
{Act.StartTx},
|
||||||
{Act.StartThread, 2 },
|
{Act.Find},
|
||||||
{Act.Notify, 1, 1000 },
|
{Act.SaveVersion},
|
||||||
{Act.Notify, 2, 1000 },
|
{Act.Lock, 1, t1Lock},
|
||||||
{Act.WaitAllChildren},
|
{Act.TestException},
|
||||||
{Act.Find},
|
|
||||||
{Act.TestEmployee, 1},
|
{Act.NewThread, 1 },
|
||||||
{Act.TestException, 1, t1Exceptions },
|
{Act.StartThread, 1 },
|
||||||
{Act.TestException, 2, t2Exceptions },
|
|
||||||
};
|
{Act.Wait},
|
||||||
Object[][] thread1 = {
|
{Act.UpdateEmployee},
|
||||||
{Act.CreateEm},
|
{t1IsCommit},
|
||||||
{Act.StartTx},
|
|
||||||
{Act.Find},
|
{Act.Notify, 1},
|
||||||
{Act.SaveVersion},
|
|
||||||
{Act.Lock, 1, t1Lock },
|
{Act.Find},
|
||||||
{Act.TestException},
|
|
||||||
{Act.Notify, 0},
|
{Act.WaitAllChildren},
|
||||||
{Act.Wait},
|
{Act.Find},
|
||||||
{Act.UpdateEmployee},
|
{Act.TestEmployee, 1, null, t1VersionInc},
|
||||||
|
{Act.TestException, 0, t1Exceptions },
|
||||||
{t1IsCommit},
|
{Act.TestException, 1, t3Exceptions },
|
||||||
{Act.Find},
|
{Act.CloseEm}
|
||||||
{Act.TestEmployee, 1, null, t1VersionInc}
|
};
|
||||||
};
|
|
||||||
Object[][] thread2 = {
|
Object[][] thread1 = {
|
||||||
{Act.CreateEm},
|
{Act.CreateEm},
|
||||||
{Act.StartTx},
|
{Act.StartTx},
|
||||||
{Act.Find},
|
{Act.Find},
|
||||||
{Act.SaveVersion},
|
{Act.SaveVersion},
|
||||||
{Act.Lock, 1, t2Lock },
|
{Act.Lock, 1, t2Lock},
|
||||||
{Act.Notify, 0},
|
{Act.TestException, 1, t2Exceptions},
|
||||||
{Act.Wait},
|
{Act.Notify, 0},
|
||||||
|
|
||||||
{t2IsCommit},
|
{Act.Wait},
|
||||||
{Act.Find},
|
{Act.Sleep, 2000}, // sleep for at least 2 sec so that the entity name updated with timestamp
|
||||||
{Act.TestEmployee, 1, null, t2VersionInc}
|
// in each of the 2 threads are different.
|
||||||
};
|
{Act.UpdateEmployee},
|
||||||
launchActionSequence(testName, parameters, threadMain, thread1,
|
|
||||||
thread2);
|
{t2IsCommit},
|
||||||
|
{Act.Sleep, 1000},
|
||||||
|
{Act.Find},
|
||||||
|
{Act.TestEmployee, 1, null, t2VersionInc},
|
||||||
|
{Act.CloseEm}
|
||||||
|
};
|
||||||
|
launchActionSequence(testName, parameters, threadMain, thread1);
|
||||||
|
|
||||||
|
// Object[][] threadMain = {
|
||||||
|
// {Act.CreateEm},
|
||||||
|
// {Act.Find},
|
||||||
|
// {Act.SaveVersion},
|
||||||
|
// {Act.TestEmployee, 1, Default_FirstName},
|
||||||
|
//
|
||||||
|
// {Act.NewThread, 1 },
|
||||||
|
// {Act.NewThread, 2 },
|
||||||
|
// {Act.StartThread, 1 },
|
||||||
|
// {Act.Wait},
|
||||||
|
// {Act.StartThread, 2 },
|
||||||
|
// {Act.Notify, 1, 1000 },
|
||||||
|
// {Act.Notify, 2, 1000 },
|
||||||
|
// {Act.WaitAllChildren},
|
||||||
|
// {Act.Find},
|
||||||
|
// {Act.TestEmployee, 1},
|
||||||
|
// {Act.TestException, 1, t1Exceptions },
|
||||||
|
// {Act.TestException, 2, t2Exceptions },
|
||||||
|
// };
|
||||||
|
// Object[][] thread1 = {
|
||||||
|
// {Act.CreateEm},
|
||||||
|
// {Act.StartTx},
|
||||||
|
// {Act.Find},
|
||||||
|
// {Act.SaveVersion},
|
||||||
|
// {Act.Lock, 1, t1Lock },
|
||||||
|
// {Act.TestException},
|
||||||
|
// {Act.Notify, 0},
|
||||||
|
// {Act.Wait},
|
||||||
|
// {Act.UpdateEmployee},
|
||||||
|
//
|
||||||
|
// {t1IsCommit},
|
||||||
|
// {Act.Find},
|
||||||
|
// {Act.TestEmployee, 1, null, t1VersionInc}
|
||||||
|
// };
|
||||||
|
// Object[][] thread2 = {
|
||||||
|
// {Act.CreateEm},
|
||||||
|
// {Act.StartTx},
|
||||||
|
// {Act.Find},
|
||||||
|
// {Act.SaveVersion},
|
||||||
|
// {Act.Lock, 1, t2Lock },
|
||||||
|
// {Act.Notify, 0},
|
||||||
|
// {Act.Wait},
|
||||||
|
//
|
||||||
|
// {t2IsCommit},
|
||||||
|
// {Act.Find},
|
||||||
|
// {Act.TestEmployee, 1, null, t2VersionInc}
|
||||||
|
// };
|
||||||
|
// launchActionSequence(testName, parameters, threadMain, thread1,
|
||||||
|
// thread2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,6 +116,7 @@ public class TestMixedLockManagerRefreshBasic extends SequencedActionsTest {
|
||||||
{ Act.Clear },
|
{ Act.Clear },
|
||||||
{ Act.Find, 1 },
|
{ Act.Find, 1 },
|
||||||
{ Act.TestEmployee, 1, lockMode.toString(), 0 },
|
{ Act.TestEmployee, 1, lockMode.toString(), 0 },
|
||||||
|
{ Act.CloseEm }
|
||||||
};
|
};
|
||||||
launchActionSequence(testName, "LockMode=" + lockMode, threadMain);
|
launchActionSequence(testName, "LockMode=" + lockMode, threadMain);
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,6 +66,7 @@ public class TestMixedLockManagerRefreshException extends SequencedActionsTest {
|
||||||
|
|
||||||
{Act.Refresh, 1, LockModeType.PESSIMISTIC_FORCE_INCREMENT },
|
{Act.Refresh, 1, LockModeType.PESSIMISTIC_FORCE_INCREMENT },
|
||||||
{Act.TestException, 0, null },
|
{Act.TestException, 0, null },
|
||||||
|
{Act.CloseEm}
|
||||||
};
|
};
|
||||||
launchActionSequence("testLockTxReqExceptions()",
|
launchActionSequence("testLockTxReqExceptions()",
|
||||||
null, threadMainTxReqTest);
|
null, threadMainTxReqTest);
|
||||||
|
@ -104,6 +105,7 @@ public class TestMixedLockManagerRefreshException extends SequencedActionsTest {
|
||||||
|
|
||||||
{Act.RefreshWithLock, 1, LockModeType.PESSIMISTIC_FORCE_INCREMENT },
|
{Act.RefreshWithLock, 1, LockModeType.PESSIMISTIC_FORCE_INCREMENT },
|
||||||
{Act.TestException, 0, TransactionRequiredException.class },
|
{Act.TestException, 0, TransactionRequiredException.class },
|
||||||
|
{Act.CloseEm}
|
||||||
};
|
};
|
||||||
launchActionSequence("testLockTxReqExceptions()",
|
launchActionSequence("testLockTxReqExceptions()",
|
||||||
null, threadMainTxReqTest);
|
null, threadMainTxReqTest);
|
||||||
|
@ -165,6 +167,7 @@ public class TestMixedLockManagerRefreshException extends SequencedActionsTest {
|
||||||
{Act.RefreshObject, "null",
|
{Act.RefreshObject, "null",
|
||||||
LockModeType.PESSIMISTIC_FORCE_INCREMENT },
|
LockModeType.PESSIMISTIC_FORCE_INCREMENT },
|
||||||
{Act.TestException, 0, IllegalArgumentException.class },
|
{Act.TestException, 0, IllegalArgumentException.class },
|
||||||
|
{Act.CloseEm}
|
||||||
};
|
};
|
||||||
launchActionSequence("testLockIllegalArgrumentExceptions()",
|
launchActionSequence("testLockIllegalArgrumentExceptions()",
|
||||||
"Test invalid entity.", threadMainInvEntityIllegalArgTest);
|
"Test invalid entity.", threadMainInvEntityIllegalArgTest);
|
||||||
|
@ -204,6 +207,7 @@ public class TestMixedLockManagerRefreshException extends SequencedActionsTest {
|
||||||
|
|
||||||
{Act.Refresh, 2, LockModeType.PESSIMISTIC_FORCE_INCREMENT },
|
{Act.Refresh, 2, LockModeType.PESSIMISTIC_FORCE_INCREMENT },
|
||||||
{Act.TestException, 0, IllegalArgumentException.class },
|
{Act.TestException, 0, IllegalArgumentException.class },
|
||||||
|
{Act.CloseEm}
|
||||||
};
|
};
|
||||||
launchActionSequence("testLockIllegalArgrumentExceptions()",
|
launchActionSequence("testLockIllegalArgrumentExceptions()",
|
||||||
"Test detached entity.", threadMainDetachEntityIllegalArgTest);
|
"Test detached entity.", threadMainDetachEntityIllegalArgTest);
|
||||||
|
@ -241,7 +245,8 @@ public class TestMixedLockManagerRefreshException extends SequencedActionsTest {
|
||||||
|
|
||||||
{Act.Refresh, 2, LockModeType.PESSIMISTIC_FORCE_INCREMENT },
|
{Act.Refresh, 2, LockModeType.PESSIMISTIC_FORCE_INCREMENT },
|
||||||
{Act.TestException, 0, IllegalArgumentException.class },
|
{Act.TestException, 0, IllegalArgumentException.class },
|
||||||
};
|
{Act.CloseEm}
|
||||||
|
};
|
||||||
launchActionSequence("testLockIllegalArgrumentExceptions()",
|
launchActionSequence("testLockIllegalArgrumentExceptions()",
|
||||||
"Test detached entity using serialization.",
|
"Test detached entity using serialization.",
|
||||||
threadMainDetachSerializeIllegalArgTest);
|
threadMainDetachSerializeIllegalArgTest);
|
||||||
|
@ -279,6 +284,7 @@ public class TestMixedLockManagerRefreshException extends SequencedActionsTest {
|
||||||
{Act.TestException, 1, IllegalArgumentException.class },
|
{Act.TestException, 1, IllegalArgumentException.class },
|
||||||
|
|
||||||
{Act.RollbackTx},
|
{Act.RollbackTx},
|
||||||
|
{Act.CloseEm}
|
||||||
};
|
};
|
||||||
launchActionSequence(
|
launchActionSequence(
|
||||||
"testLockIllegalArgrumentExceptions()",
|
"testLockIllegalArgrumentExceptions()",
|
||||||
|
|
|
@ -332,6 +332,61 @@ public class TestMixedLockManagerRefreshPermutation
|
||||||
String t1Message2 = "Refresh in Thread 1 Again";
|
String t1Message2 = "Refresh in Thread 1 Again";
|
||||||
String t2Message1 = "Refresh in Thread 2";
|
String t2Message1 = "Refresh in Thread 2";
|
||||||
|
|
||||||
|
// Object[][] threadMain = {
|
||||||
|
// {Act.CreateEm},
|
||||||
|
// {Act.Find},
|
||||||
|
// {Act.SaveVersion},
|
||||||
|
// {Act.TestEmployee, 1, Default_FirstName},
|
||||||
|
//
|
||||||
|
// {Act.CloseEm},
|
||||||
|
// {Act.Sleep, 100},
|
||||||
|
//
|
||||||
|
// {Act.CreateEm},
|
||||||
|
// {Act.StartTx},
|
||||||
|
// {Act.RefreshWithLock, 1, t1Lock},
|
||||||
|
// {Act.SaveVersion},
|
||||||
|
// {Act.TestException},
|
||||||
|
//
|
||||||
|
// {Act.NewThread, 1 },
|
||||||
|
// {Act.StartThread, 1 },
|
||||||
|
//
|
||||||
|
// {Act.Wait},
|
||||||
|
// {Act.UpdateEmployee},
|
||||||
|
// {t1IsCommit},
|
||||||
|
//
|
||||||
|
// {Act.Notify, 1},
|
||||||
|
//
|
||||||
|
// {Act.Find},
|
||||||
|
//
|
||||||
|
// {Act.WaitAllChildren},
|
||||||
|
// {Act.Find},
|
||||||
|
// {Act.TestEmployee, 1, null, t1VersionInc},
|
||||||
|
// {Act.TestException, 0, t1Exceptions },
|
||||||
|
// {Act.TestException, 1, t2Exceptions },
|
||||||
|
// {Act.CloseEm}
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// Object[][] thread1 = {
|
||||||
|
// {Act.CreateEm},
|
||||||
|
// {Act.StartTx},
|
||||||
|
// {Act.FindWithLock, 1, t2Lock},
|
||||||
|
// {Act.SaveVersion},
|
||||||
|
// {Act.TestException},
|
||||||
|
// {Act.Notify, 0},
|
||||||
|
//
|
||||||
|
// {Act.Wait},
|
||||||
|
// {Act.Sleep, 2000}, // sleep for at least 2 sec so that the entity name updated with timestamp
|
||||||
|
// // in each of the 2 threads are different.
|
||||||
|
// {Act.UpdateEmployee},
|
||||||
|
//
|
||||||
|
// {t2IsCommit},
|
||||||
|
// {Act.Sleep, 1000},
|
||||||
|
// {Act.Find},
|
||||||
|
// {Act.TestEmployee, 1, null, t2VersionInc},
|
||||||
|
// {Act.CloseEm}
|
||||||
|
// };
|
||||||
|
// launchActionSequence(testName, parameters, threadMain, thread1);
|
||||||
|
|
||||||
Object[][] threadMain = {
|
Object[][] threadMain = {
|
||||||
{Act.CreateEm},
|
{Act.CreateEm},
|
||||||
{Act.Find},
|
{Act.Find},
|
||||||
|
@ -351,6 +406,7 @@ public class TestMixedLockManagerRefreshPermutation
|
||||||
{Act.TestEmployee, 1},
|
{Act.TestEmployee, 1},
|
||||||
{Act.TestException, 1, t1Exceptions },
|
{Act.TestException, 1, t1Exceptions },
|
||||||
{Act.TestException, 2, t2Exceptions },
|
{Act.TestException, 2, t2Exceptions },
|
||||||
|
{Act.CloseEm}
|
||||||
};
|
};
|
||||||
Object[][] thread1 = {
|
Object[][] thread1 = {
|
||||||
{Act.CreateEm},
|
{Act.CreateEm},
|
||||||
|
@ -381,7 +437,8 @@ public class TestMixedLockManagerRefreshPermutation
|
||||||
|
|
||||||
{Act.Clear},
|
{Act.Clear},
|
||||||
{Act.Find},
|
{Act.Find},
|
||||||
{Act.TestEmployee, 1, null, t1VersionInc}
|
{Act.TestEmployee, 1, null, t1VersionInc},
|
||||||
|
{Act.CloseEm}
|
||||||
};
|
};
|
||||||
Object[][] thread2 = {
|
Object[][] thread2 = {
|
||||||
{Act.CreateEm},
|
{Act.CreateEm},
|
||||||
|
@ -406,7 +463,8 @@ public class TestMixedLockManagerRefreshPermutation
|
||||||
{Act.Clear},
|
{Act.Clear},
|
||||||
{Act.Find},
|
{Act.Find},
|
||||||
{Act.TestEmployee, 1, null, t2VersionInc},
|
{Act.TestEmployee, 1, null, t2VersionInc},
|
||||||
};
|
{Act.CloseEm}
|
||||||
|
};
|
||||||
|
|
||||||
launchActionSequence(testName, parameters, threadMain, thread1,
|
launchActionSequence(testName, parameters, threadMain, thread1,
|
||||||
thread2);
|
thread2);
|
||||||
|
|
|
@ -22,8 +22,6 @@ import javax.persistence.EntityManager;
|
||||||
import javax.persistence.LockModeType;
|
import javax.persistence.LockModeType;
|
||||||
import javax.persistence.Query;
|
import javax.persistence.Query;
|
||||||
|
|
||||||
import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
|
|
||||||
import org.apache.openjpa.jdbc.sql.DBDictionary;
|
|
||||||
import org.apache.openjpa.persistence.FetchPlan;
|
import org.apache.openjpa.persistence.FetchPlan;
|
||||||
import org.apache.openjpa.persistence.OpenJPAEntityManager;
|
import org.apache.openjpa.persistence.OpenJPAEntityManager;
|
||||||
import org.apache.openjpa.persistence.OpenJPAEntityManagerSPI;
|
import org.apache.openjpa.persistence.OpenJPAEntityManagerSPI;
|
||||||
|
|
Loading…
Reference in New Issue