1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| package org.jboss.cache.lock; |
8 |
| |
9 |
| import junit.framework.TestCase; |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| public class LockMapTest extends TestCase |
15 |
| { |
16 |
| private LockMap map_; |
17 |
| |
18 |
| |
19 |
| |
20 |
| |
21 |
| |
22 |
| |
23 |
3
| public LockMapTest(String arg0)
|
24 |
| { |
25 |
3
| super(arg0);
|
26 |
| } |
27 |
| |
28 |
0
| public static void main(String[] args)
|
29 |
| { |
30 |
0
| junit.textui.TestRunner.run(LockMapTest.class);
|
31 |
| } |
32 |
| |
33 |
| |
34 |
| |
35 |
| |
36 |
3
| protected void setUp() throws Exception
|
37 |
| { |
38 |
3
| super.setUp();
|
39 |
3
| map_ = new LockMap();
|
40 |
| } |
41 |
| |
42 |
| |
43 |
| |
44 |
| |
45 |
3
| protected void tearDown() throws Exception
|
46 |
| { |
47 |
3
| super.tearDown();
|
48 |
3
| map_.removeAll();
|
49 |
| } |
50 |
| |
51 |
1
| final public void testIsOwner()
|
52 |
| { |
53 |
1
| map_.addReader(this);
|
54 |
1
| assertTrue(map_.isOwner(this, LockMap.OWNER_READ));
|
55 |
1
| map_.setWriterIfNotNull(this);
|
56 |
1
| assertTrue(map_.isOwner(this, LockMap.OWNER_WRITE));
|
57 |
1
| assertTrue(map_.isOwner(this, LockMap.OWNER_ANY));
|
58 |
1
| map_.removeAll();
|
59 |
| } |
60 |
| |
61 |
1
| final public void testAddReader()
|
62 |
| { |
63 |
1
| map_.addReader(this);
|
64 |
1
| assertTrue(map_.isOwner(this, LockMap.OWNER_READ));
|
65 |
1
| map_.removeReader(this);
|
66 |
| } |
67 |
| |
68 |
1
| final public void testAddWriter()
|
69 |
| { |
70 |
1
| map_.setWriterIfNotNull(this);
|
71 |
1
| assertTrue(map_.writerOwner().equals(this));
|
72 |
1
| map_.removeWriter();
|
73 |
| } |
74 |
| |
75 |
| } |