KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > cache > test > generic > LockMapUnitTestCase


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7 package org.jboss.test.cache.test.generic;
8
9 import junit.framework.TestCase;
10 import org.jboss.cache.lock.LockMap;
11
12 /**
13  * @author Ben Wang
14  */

15 public class LockMapUnitTestCase extends TestCase
16 {
17    private LockMap map_;
18
19    /**
20     * Constructor for LockMapTest.
21     *
22     * @param arg0
23     */

24    public LockMapUnitTestCase(String JavaDoc arg0)
25    {
26       super(arg0);
27    }
28
29    public static void main(String JavaDoc[] args)
30    {
31       junit.textui.TestRunner.run(LockMapUnitTestCase.class);
32    }
33
34    /*
35     * @see TestCase#setUp()
36     */

37    protected void setUp() throws Exception JavaDoc
38    {
39       super.setUp();
40       map_ = new LockMap();
41    }
42
43    /*
44     * @see TestCase#tearDown()
45     */

46    protected void tearDown() throws Exception JavaDoc
47    {
48       super.tearDown();
49       map_.removeAll();
50    }
51
52    final public void testIsOwner()
53    {
54       map_.addReader(this);
55       assertTrue(map_.isOwner(this, LockMap.OWNER_READ));
56       map_.addWriter(this);
57       assertTrue(map_.isOwner(this, LockMap.OWNER_WRITE));
58       assertTrue(map_.isOwner(this, LockMap.OWNER_ANY));
59       map_.removeAll();
60    }
61
62    final public void testAddReader()
63    {
64       map_.addReader(this);
65       assertTrue(map_.readerOwners().contains(this));
66       map_.removeReader(this);
67    }
68
69    final public void testAddWriter()
70    {
71       map_.addWriter(this);
72       assertTrue(map_.writerOwner().equals(this));
73       map_.removeWriter(this);
74    }
75
76 }
77
Popular Tags