Author: manik.surtani(a)jboss.com
Date: 2008-06-27 07:05:39 -0400 (Fri, 27 Jun 2008)
New Revision: 6084
Modified:
core/trunk/src/test/java/org/jboss/cache/util/concurrent/locks/OwnableReentrantLockTest.java
Log:
Fixed broken setup
Modified:
core/trunk/src/test/java/org/jboss/cache/util/concurrent/locks/OwnableReentrantLockTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/util/concurrent/locks/OwnableReentrantLockTest.java 2008-06-27
07:49:41 UTC (rev 6083)
+++
core/trunk/src/test/java/org/jboss/cache/util/concurrent/locks/OwnableReentrantLockTest.java 2008-06-27
11:05:39 UTC (rev 6084)
@@ -1,5 +1,6 @@
package org.jboss.cache.util.concurrent.locks;
+import org.jboss.cache.factories.context.MVCCContextFactory;
import org.jboss.cache.invocation.InvocationContextContainer;
import org.jboss.cache.transaction.GlobalTransaction;
import org.testng.annotations.Test;
@@ -15,9 +16,16 @@
@Test(groups = "unit")
public class OwnableReentrantLockTest
{
+ private InvocationContextContainer getInvocationContextContainer()
+ {
+ InvocationContextContainer icc = new InvocationContextContainer();
+ icc.injectContextFactory(new MVCCContextFactory());
+ return icc;
+ }
+
public void testReentrancyThread()
{
- InvocationContextContainer icc = new InvocationContextContainer();
+ InvocationContextContainer icc = getInvocationContextContainer();
OwnableReentrantLock lock = new OwnableReentrantLock(icc);
lock.lock(); // locked by current thread
@@ -39,7 +47,7 @@
public void testReentrancyGtx()
{
- InvocationContextContainer icc = new InvocationContextContainer();
+ InvocationContextContainer icc = getInvocationContextContainer();
OwnableReentrantLock lock = new OwnableReentrantLock(icc);
// create and set a gtx
@@ -66,7 +74,7 @@
public void testReentrancyNotSameGtx()
{
- InvocationContextContainer icc = new InvocationContextContainer();
+ InvocationContextContainer icc = getInvocationContextContainer();
OwnableReentrantLock lock = new OwnableReentrantLock(icc);
// create and set a gtx
@@ -100,7 +108,7 @@
public void testThreadLockedByThread() throws InterruptedException
{
- InvocationContextContainer icc = new InvocationContextContainer();
+ InvocationContextContainer icc = getInvocationContextContainer();
final OwnableReentrantLock lock = new OwnableReentrantLock(icc);
final AtomicBoolean acquired = new AtomicBoolean(false);
final AtomicBoolean threwExceptionOnRelease = new AtomicBoolean(false);
@@ -147,7 +155,7 @@
public void testThreadLockedByGtx() throws InterruptedException
{
- InvocationContextContainer icc = new InvocationContextContainer();
+ InvocationContextContainer icc = getInvocationContextContainer();
final OwnableReentrantLock lock = new OwnableReentrantLock(icc);
GlobalTransaction gtx = new GlobalTransaction();
gtx.setId(10);
@@ -196,7 +204,7 @@
public void testGtxLockedByThread() throws InterruptedException
{
- final InvocationContextContainer icc = new InvocationContextContainer();
+ final InvocationContextContainer icc = getInvocationContextContainer();
final OwnableReentrantLock lock = new OwnableReentrantLock(icc);
final AtomicBoolean acquired = new AtomicBoolean(false);
final AtomicBoolean threwExceptionOnRelease = new AtomicBoolean(false);
@@ -245,7 +253,7 @@
public void testGtxLockedByGtxFail() throws InterruptedException
{
- final InvocationContextContainer icc = new InvocationContextContainer();
+ final InvocationContextContainer icc = getInvocationContextContainer();
final OwnableReentrantLock lock = new OwnableReentrantLock(icc);
final AtomicBoolean acquired = new AtomicBoolean(false);
final AtomicBoolean threwExceptionOnRelease = new AtomicBoolean(false);
@@ -297,7 +305,7 @@
public void testGtxLockedByGtxSuccess() throws InterruptedException
{
- final InvocationContextContainer icc = new InvocationContextContainer();
+ final InvocationContextContainer icc = getInvocationContextContainer();
final OwnableReentrantLock lock = new OwnableReentrantLock(icc);
final AtomicBoolean acquired = new AtomicBoolean(false);
GlobalTransaction gtx = new GlobalTransaction();
@@ -338,7 +346,7 @@
public void satisfyCodeCoverage() throws InterruptedException
{
- final InvocationContextContainer icc = new InvocationContextContainer();
+ final InvocationContextContainer icc = getInvocationContextContainer();
final OwnableReentrantLock lock = new OwnableReentrantLock(icc);
System.out.println(lock.toString());
lock.lockInterruptibly();
@@ -347,12 +355,12 @@
assert lock.newCondition() != null;
assert lock.isHeldExclusively();
lock.unlock();
- assert lock.isHeldExclusively();
+ assert !lock.isHeldExclusively();
}
public void testSerialization() throws IOException, ClassNotFoundException
{
- final InvocationContextContainer icc = new InvocationContextContainer();
+ final InvocationContextContainer icc = getInvocationContextContainer();
final OwnableReentrantLock lock = new OwnableReentrantLock(icc);
lock.lock();
assert lock.isLocked();
Show replies by date