1 |
| package org.jboss.cache.optimistic; |
2 |
| |
3 |
| import org.jboss.cache.CacheImpl; |
4 |
| import org.jboss.cache.Fqn; |
5 |
| import org.jboss.cache.NodeSPI; |
6 |
| import org.jboss.cache.config.Configuration; |
7 |
| import org.jboss.cache.misc.TestingUtil; |
8 |
| |
9 |
| import javax.transaction.TransactionManager; |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| public class RemoveBeforeCreateTest extends AbstractOptimisticTestCase |
15 |
| { |
16 |
| CacheImpl[] c = null; |
17 |
| TransactionManager t; |
18 |
| |
19 |
2
| protected void setUp() throws Exception
|
20 |
| { |
21 |
2
| c = new CacheImpl[2];
|
22 |
2
| c[0] = createReplicatedCache(Configuration.CacheMode.REPL_ASYNC);
|
23 |
2
| c[1] = createReplicatedCache(Configuration.CacheMode.REPL_ASYNC);
|
24 |
| |
25 |
2
| TestingUtil.blockUntilViewsReceived(c, 20000);
|
26 |
| |
27 |
2
| t = c[0].getTransactionManager();
|
28 |
| } |
29 |
| |
30 |
2
| protected void tearDown()
|
31 |
| { |
32 |
2
| if (c != null)
|
33 |
| { |
34 |
2
| destroyCache(c[0]);
|
35 |
2
| destroyCache(c[1]);
|
36 |
2
| c = null;
|
37 |
| } |
38 |
| } |
39 |
| |
40 |
2
| public RemoveBeforeCreateTest(String name)
|
41 |
| { |
42 |
2
| super(name);
|
43 |
| } |
44 |
| |
45 |
1
| public void testControl() throws Exception
|
46 |
| { |
47 |
1
| t.begin();
|
48 |
1
| c[0].put("/control", "key", "value");
|
49 |
1
| t.commit();
|
50 |
1
| TestingUtil.sleepThread(200);
|
51 |
| |
52 |
1
| assertEquals("value", c[0].get("/control", "key"));
|
53 |
1
| assertEquals("value", c[1].get("/control", "key"));
|
54 |
| |
55 |
1
| DefaultDataVersion v1 = (DefaultDataVersion) ((NodeSPI) c[0].get("/control")).getVersion();
|
56 |
1
| assertEquals(1, v1.getRawVersion());
|
57 |
| |
58 |
1
| DefaultDataVersion v2 = (DefaultDataVersion) ((NodeSPI) c[1].get("/control")).getVersion();
|
59 |
1
| assertEquals(1, v2.getRawVersion());
|
60 |
| |
61 |
| |
62 |
| } |
63 |
| |
64 |
1
| public void testRemoveBeforePut() throws Exception
|
65 |
| { |
66 |
1
| Fqn f = Fqn.fromString("/test");
|
67 |
1
| assertNull(c[0].get(f));
|
68 |
1
| assertNull(c[1].get(f));
|
69 |
| |
70 |
1
| t.begin();
|
71 |
1
| c[0].remove(f);
|
72 |
| |
73 |
| |
74 |
1
| t.commit();
|
75 |
1
| TestingUtil.sleepThread(200);
|
76 |
| |
77 |
1
| assertNull(c[0].get(f));
|
78 |
1
| assertNull(c[1].get(f));
|
79 |
| } |
80 |
| |
81 |
| } |