1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| package org.jboss.cache.optimistic; |
8 |
| |
9 |
| import org.jboss.cache.CacheImpl; |
10 |
| import org.jboss.cache.Fqn; |
11 |
| import org.jboss.cache.GlobalTransaction; |
12 |
| import org.jboss.cache.NodeSPI; |
13 |
| import org.jboss.cache.OptimisticTransactionEntry; |
14 |
| import org.jboss.cache.TransactionTable; |
15 |
| import org.jboss.cache.interceptors.Interceptor; |
16 |
| import org.jboss.cache.interceptors.OptimisticCreateIfNotExistsInterceptor; |
17 |
| import org.jboss.cache.interceptors.OptimisticNodeInterceptor; |
18 |
| import org.jboss.cache.interceptors.OptimisticValidatorInterceptor; |
19 |
| import org.jboss.cache.loader.SamplePojo; |
20 |
| import org.jboss.cache.marshall.MethodCall; |
21 |
| import org.jboss.cache.marshall.MethodCallFactory; |
22 |
| import org.jboss.cache.marshall.MethodDeclarations; |
23 |
| import org.jboss.cache.transaction.DummyTransactionManager; |
24 |
| |
25 |
| import javax.transaction.Transaction; |
26 |
| import java.util.HashMap; |
27 |
| import java.util.Map; |
28 |
| |
29 |
| |
30 |
| |
31 |
| |
32 |
| public class ValidatorInterceptorTest extends AbstractOptimisticTestCase |
33 |
| { |
34 |
| |
35 |
| |
36 |
| |
37 |
| |
38 |
| |
39 |
5
| public ValidatorInterceptorTest(String name)
|
40 |
| { |
41 |
5
| super(name);
|
42 |
| } |
43 |
| |
44 |
1
| public void testTransactionvalidateMethod() throws Exception
|
45 |
| { |
46 |
1
| CacheImpl cache = createCacheWithListener();
|
47 |
| |
48 |
1
| Interceptor validateInterceptor = new OptimisticValidatorInterceptor();
|
49 |
1
| validateInterceptor.setCache(cache);
|
50 |
1
| Interceptor interceptor = new OptimisticCreateIfNotExistsInterceptor();
|
51 |
1
| interceptor.setCache(cache);
|
52 |
1
| Interceptor nodeInterceptor = new OptimisticNodeInterceptor();
|
53 |
1
| nodeInterceptor.setCache(cache);
|
54 |
1
| MockInterceptor dummy = new MockInterceptor();
|
55 |
1
| dummy.setCache(cache);
|
56 |
1
| validateInterceptor.setNext(interceptor);
|
57 |
1
| interceptor.setNext(nodeInterceptor);
|
58 |
1
| nodeInterceptor.setNext(dummy);
|
59 |
| |
60 |
1
| cache.setInterceptorChain(validateInterceptor);
|
61 |
| |
62 |
| |
63 |
1
| DummyTransactionManager mgr = DummyTransactionManager.getInstance();
|
64 |
1
| mgr.begin();
|
65 |
1
| Transaction tx = mgr.getTransaction();
|
66 |
| |
67 |
| |
68 |
1
| cache.getInvocationContext().setTransaction(tx);
|
69 |
1
| cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx));
|
70 |
| |
71 |
1
| SamplePojo pojo = new SamplePojo(21, "test");
|
72 |
1
| Map temp = new HashMap();
|
73 |
1
| temp.put("key1", pojo);
|
74 |
1
| cache.put("/one/two", temp);
|
75 |
| |
76 |
1
| assertEquals(null, dummy.getCalled());
|
77 |
1
| TransactionTable table = cache.getTransactionTable();
|
78 |
| |
79 |
1
| GlobalTransaction gtx = table.get(tx);
|
80 |
| |
81 |
1
| OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
|
82 |
| |
83 |
1
| TransactionWorkspace workspace = entry.getTransactionWorkSpace();
|
84 |
| |
85 |
| |
86 |
| |
87 |
| |
88 |
| |
89 |
| |
90 |
1
| assertEquals(3, workspace.getNodes().size());
|
91 |
1
| assertNotNull(workspace.getNode(Fqn.fromString("/one/two")));
|
92 |
1
| assertEquals(pojo, workspace.getNode(Fqn.fromString("/one/two")).get("key1"));
|
93 |
1
| assertEquals(1, workspace.getNode(Fqn.fromString("/one/two")).getMergedData().size());
|
94 |
1
| assertTrue(entry.getLocks().isEmpty());
|
95 |
1
| assertEquals(1, entry.getModifications().size());
|
96 |
1
| assertTrue(!cache.exists("/one/two"));
|
97 |
1
| assertEquals(null, dummy.getCalled());
|
98 |
| |
99 |
| |
100 |
1
| MethodCall prepareMethod = MethodCallFactory.create(MethodDeclarations.optimisticPrepareMethod, new Object[]{gtx, entry.getModifications(), gtx.getAddress(), Boolean.FALSE});
|
101 |
1
| try
|
102 |
| { |
103 |
1
| cache._replicate(prepareMethod);
|
104 |
| } |
105 |
| catch (Throwable t) |
106 |
| { |
107 |
| |
108 |
| } |
109 |
| |
110 |
| |
111 |
1
| assertEquals(3, workspace.getNodes().size());
|
112 |
1
| assertNotNull(workspace.getNode(Fqn.fromString("/one/two")));
|
113 |
1
| assertEquals(pojo, workspace.getNode(Fqn.fromString("/one/two")).get("key1"));
|
114 |
1
| assertEquals(1, workspace.getNode(Fqn.fromString("/one/two")).getMergedData().size());
|
115 |
1
| assertTrue(entry.getLocks().isEmpty());
|
116 |
1
| assertEquals(1, entry.getModifications().size());
|
117 |
1
| assertTrue(!cache.exists("/one/two"));
|
118 |
1
| assertEquals(null, dummy.getCalled());
|
119 |
| |
120 |
| |
121 |
1
| mgr.commit();
|
122 |
| |
123 |
1
| destroyCache(cache);
|
124 |
| } |
125 |
| |
126 |
1
| public void testTransactionValidateFailureMethod() throws Exception
|
127 |
| { |
128 |
| |
129 |
1
| CacheImpl cache = createCacheWithListener();
|
130 |
| |
131 |
1
| Interceptor validateInterceptor = new OptimisticValidatorInterceptor();
|
132 |
1
| validateInterceptor.setCache(cache);
|
133 |
1
| Interceptor interceptor = new OptimisticCreateIfNotExistsInterceptor();
|
134 |
1
| interceptor.setCache(cache);
|
135 |
1
| Interceptor nodeInterceptor = new OptimisticNodeInterceptor();
|
136 |
1
| nodeInterceptor.setCache(cache);
|
137 |
1
| MockInterceptor dummy = new MockInterceptor();
|
138 |
1
| dummy.setCache(cache);
|
139 |
1
| validateInterceptor.setNext(interceptor);
|
140 |
1
| interceptor.setNext(nodeInterceptor);
|
141 |
1
| nodeInterceptor.setNext(dummy);
|
142 |
| |
143 |
1
| cache.setInterceptorChain(validateInterceptor);
|
144 |
| |
145 |
| |
146 |
1
| DummyTransactionManager mgr = DummyTransactionManager.getInstance();
|
147 |
1
| mgr.begin();
|
148 |
1
| Transaction tx = mgr.getTransaction();
|
149 |
| |
150 |
| |
151 |
1
| cache.getInvocationContext().setTransaction(tx);
|
152 |
1
| cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx));
|
153 |
| |
154 |
1
| SamplePojo pojo = new SamplePojo(21, "test");
|
155 |
1
| Map temp = new HashMap();
|
156 |
1
| temp.put("key1", pojo);
|
157 |
1
| cache.put("/one/two", temp);
|
158 |
| |
159 |
1
| assertEquals(null, dummy.getCalled());
|
160 |
1
| TransactionTable table = cache.getTransactionTable();
|
161 |
| |
162 |
1
| GlobalTransaction gtx = table.get(tx);
|
163 |
| |
164 |
1
| OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
|
165 |
| |
166 |
1
| TransactionWorkspace workspace = entry.getTransactionWorkSpace();
|
167 |
| |
168 |
| |
169 |
| |
170 |
| |
171 |
| |
172 |
| |
173 |
1
| assertEquals(3, workspace.getNodes().size());
|
174 |
1
| assertNotNull(workspace.getNode(Fqn.fromString("/one/two")));
|
175 |
1
| assertEquals(pojo, workspace.getNode(Fqn.fromString("/one/two")).get("key1"));
|
176 |
1
| assertEquals(1, workspace.getNode(Fqn.fromString("/one/two")).getMergedData().size());
|
177 |
1
| assertTrue(entry.getLocks().isEmpty());
|
178 |
1
| assertEquals(1, entry.getModifications().size());
|
179 |
1
| assertTrue(!cache.exists("/one/two"));
|
180 |
1
| assertEquals(null, dummy.getCalled());
|
181 |
| |
182 |
| |
183 |
1
| workspace.getNode(Fqn.fromString("/one/two")).getNode().setVersion(new DefaultDataVersion(2));
|
184 |
| |
185 |
1
| MethodCall prepareMethod = MethodCallFactory.create(MethodDeclarations.optimisticPrepareMethod, gtx, entry.getModifications(), gtx.getAddress(), Boolean.FALSE);
|
186 |
1
| try
|
187 |
| { |
188 |
1
| cache._replicate(prepareMethod);
|
189 |
1
| fail();
|
190 |
| } |
191 |
| catch (Throwable t) |
192 |
| { |
193 |
1
| assertTrue(true);
|
194 |
| } |
195 |
| |
196 |
| |
197 |
1
| mgr.commit();
|
198 |
| |
199 |
1
| destroyCache(cache);
|
200 |
| } |
201 |
| |
202 |
1
| public void testTransactionValidateCommitMethod() throws Exception
|
203 |
| { |
204 |
| |
205 |
1
| CacheImpl cache = createCacheWithListener();
|
206 |
| |
207 |
1
| Interceptor validateInterceptor = new OptimisticValidatorInterceptor();
|
208 |
1
| validateInterceptor.setCache(cache);
|
209 |
1
| Interceptor interceptor = new OptimisticCreateIfNotExistsInterceptor();
|
210 |
1
| interceptor.setCache(cache);
|
211 |
1
| Interceptor nodeInterceptor = new OptimisticNodeInterceptor();
|
212 |
1
| nodeInterceptor.setCache(cache);
|
213 |
1
| MockInterceptor dummy = new MockInterceptor();
|
214 |
1
| dummy.setCache(cache);
|
215 |
1
| validateInterceptor.setNext(interceptor);
|
216 |
1
| interceptor.setNext(nodeInterceptor);
|
217 |
1
| nodeInterceptor.setNext(dummy);
|
218 |
| |
219 |
1
| cache.setInterceptorChain(validateInterceptor);
|
220 |
| |
221 |
| |
222 |
1
| DummyTransactionManager mgr = DummyTransactionManager.getInstance();
|
223 |
1
| mgr.begin();
|
224 |
1
| Transaction tx = mgr.getTransaction();
|
225 |
| |
226 |
| |
227 |
1
| cache.getInvocationContext().setTransaction(tx);
|
228 |
1
| cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx));
|
229 |
| |
230 |
1
| SamplePojo pojo = new SamplePojo(21, "test");
|
231 |
1
| Map temp = new HashMap();
|
232 |
1
| temp.put("key1", pojo);
|
233 |
1
| cache.put("/one/two", temp);
|
234 |
| |
235 |
1
| assertEquals(null, dummy.getCalled());
|
236 |
1
| TransactionTable table = cache.getTransactionTable();
|
237 |
| |
238 |
1
| GlobalTransaction gtx = table.get(tx);
|
239 |
| |
240 |
1
| OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
|
241 |
| |
242 |
1
| TransactionWorkspace workspace = entry.getTransactionWorkSpace();
|
243 |
| |
244 |
| |
245 |
| |
246 |
| |
247 |
| |
248 |
| |
249 |
1
| assertEquals(3, workspace.getNodes().size());
|
250 |
1
| assertNotNull(workspace.getNode(Fqn.fromString("/one/two")));
|
251 |
1
| assertEquals(pojo, workspace.getNode(Fqn.fromString("/one/two")).get("key1"));
|
252 |
1
| assertEquals(1, workspace.getNode(Fqn.fromString("/one/two")).getMergedData().size());
|
253 |
1
| assertTrue(entry.getLocks().isEmpty());
|
254 |
1
| assertEquals(1, entry.getModifications().size());
|
255 |
1
| assertTrue(!cache.exists("/one/two"));
|
256 |
1
| assertEquals(null, dummy.getCalled());
|
257 |
| |
258 |
| |
259 |
| |
260 |
1
| MethodCall prepareMethod = MethodCallFactory.create(MethodDeclarations.optimisticPrepareMethod, new Object[]{gtx, entry.getModifications(), gtx.getAddress(), Boolean.FALSE});
|
261 |
1
| try
|
262 |
| { |
263 |
1
| cache._replicate(prepareMethod);
|
264 |
1
| fail();
|
265 |
| } |
266 |
| catch (Throwable t) |
267 |
| { |
268 |
1
| assertTrue(true);
|
269 |
| } |
270 |
| |
271 |
1
| MethodCall commitMethod = MethodCallFactory.create(MethodDeclarations.commitMethod, new Object[]{gtx});
|
272 |
1
| try
|
273 |
| { |
274 |
1
| cache._replicate(commitMethod);
|
275 |
| } |
276 |
| catch (Throwable t) |
277 |
| { |
278 |
0
| fail();
|
279 |
| } |
280 |
| |
281 |
| |
282 |
1
| assertEquals(3, workspace.getNodes().size());
|
283 |
1
| assertNotNull(workspace.getNode(Fqn.fromString("/one/two")));
|
284 |
1
| assertEquals(pojo, workspace.getNode(Fqn.fromString("/one/two")).get("key1"));
|
285 |
1
| assertEquals(1, workspace.getNode(Fqn.fromString("/one/two")).getMergedData().size());
|
286 |
1
| assertTrue(entry.getLocks().isEmpty());
|
287 |
1
| assertEquals(1, entry.getModifications().size());
|
288 |
| |
289 |
| |
290 |
1
| assertEquals(null, dummy.getCalled());
|
291 |
1
| NodeSPI node = workspace.getNode(Fqn.fromString("/")).getNode();
|
292 |
| |
293 |
| |
294 |
1
| assertNotNull(node);
|
295 |
1
| node = (NodeSPI) node.getChild("one");
|
296 |
1
| assertEquals(new DefaultDataVersion(1), node.getVersion());
|
297 |
1
| assertNotNull(node);
|
298 |
1
| assertTrue(cache.exists(node.getFqn()));
|
299 |
1
| assertEquals(new DefaultDataVersion(1), node.getVersion());
|
300 |
1
| node = (NodeSPI) node.getChild("two");
|
301 |
1
| assertNotNull(node);
|
302 |
1
| assertTrue(cache.exists(node.getFqn()));
|
303 |
1
| assertEquals(new DefaultDataVersion(1), node.getVersion());
|
304 |
| |
305 |
1
| assertEquals(pojo, node.get("key1"));
|
306 |
| |
307 |
1
| mgr.commit();
|
308 |
| |
309 |
1
| destroyCache(cache);
|
310 |
| } |
311 |
| |
312 |
| |
313 |
1
| public void testTransactionValidateFailRemoteCommitMethod() throws Exception
|
314 |
| { |
315 |
| |
316 |
1
| CacheImpl cache = createCacheWithListener();
|
317 |
| |
318 |
1
| Interceptor validateInterceptor = new OptimisticValidatorInterceptor();
|
319 |
1
| validateInterceptor.setCache(cache);
|
320 |
1
| Interceptor interceptor = new OptimisticCreateIfNotExistsInterceptor();
|
321 |
1
| interceptor.setCache(cache);
|
322 |
1
| Interceptor nodeInterceptor = new OptimisticNodeInterceptor();
|
323 |
1
| nodeInterceptor.setCache(cache);
|
324 |
1
| MockInterceptor dummy = new MockInterceptor();
|
325 |
1
| dummy.setCache(cache);
|
326 |
1
| validateInterceptor.setNext(interceptor);
|
327 |
1
| interceptor.setNext(nodeInterceptor);
|
328 |
1
| nodeInterceptor.setNext(dummy);
|
329 |
| |
330 |
1
| cache.setInterceptorChain(validateInterceptor);
|
331 |
| |
332 |
| |
333 |
1
| DummyTransactionManager mgr = DummyTransactionManager.getInstance();
|
334 |
1
| mgr.begin();
|
335 |
1
| Transaction tx = mgr.getTransaction();
|
336 |
| |
337 |
| |
338 |
1
| cache.getInvocationContext().setTransaction(tx);
|
339 |
1
| cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx));
|
340 |
| |
341 |
1
| SamplePojo pojo = new SamplePojo(21, "test");
|
342 |
1
| Map temp = new HashMap();
|
343 |
1
| temp.put("key1", pojo);
|
344 |
1
| cache.put("/one/two", temp);
|
345 |
| |
346 |
1
| assertEquals(null, dummy.getCalled());
|
347 |
1
| TransactionTable table = cache.getTransactionTable();
|
348 |
| |
349 |
1
| GlobalTransaction gtx = table.get(tx);
|
350 |
| |
351 |
1
| OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
|
352 |
| |
353 |
1
| TransactionWorkspace workspace = entry.getTransactionWorkSpace();
|
354 |
| |
355 |
1
| assertEquals(3, workspace.getNodes().size());
|
356 |
1
| assertNotNull(workspace.getNode(Fqn.fromString("/one/two")));
|
357 |
1
| assertEquals(pojo, workspace.getNode(Fqn.fromString("/one/two")).get("key1"));
|
358 |
1
| assertEquals(1, workspace.getNode(Fqn.fromString("/one/two")).getMergedData().size());
|
359 |
1
| assertTrue(entry.getLocks().isEmpty());
|
360 |
1
| assertEquals(1, entry.getModifications().size());
|
361 |
1
| assertTrue(!cache.exists("/one/two"));
|
362 |
1
| assertEquals(null, dummy.getCalled());
|
363 |
| |
364 |
| |
365 |
| |
366 |
1
| MethodCall prepareMethod = MethodCallFactory.create(MethodDeclarations.optimisticPrepareMethod, new Object[]{gtx, entry.getModifications(), gtx.getAddress(), Boolean.FALSE});
|
367 |
1
| try
|
368 |
| { |
369 |
1
| cache._replicate(prepareMethod);
|
370 |
1
| fail();
|
371 |
| } |
372 |
| catch (Throwable t) |
373 |
| { |
374 |
1
| assertTrue(true);
|
375 |
| } |
376 |
| |
377 |
| |
378 |
1
| MethodCall commitMethod = MethodCallFactory.create(MethodDeclarations.commitMethod, new Object[]{gtx});
|
379 |
1
| try
|
380 |
| { |
381 |
1
| cache._replicate(commitMethod);
|
382 |
| } |
383 |
| catch (Throwable t) |
384 |
| { |
385 |
0
| fail();
|
386 |
| } |
387 |
| |
388 |
| |
389 |
1
| assertEquals(3, workspace.getNodes().size());
|
390 |
1
| assertNotNull(workspace.getNode(Fqn.fromString("/one/two")));
|
391 |
1
| assertEquals(pojo, workspace.getNode(Fqn.fromString("/one/two")).get("key1"));
|
392 |
1
| assertEquals(1, workspace.getNode(Fqn.fromString("/one/two")).getMergedData().size());
|
393 |
1
| assertTrue(entry.getLocks().isEmpty());
|
394 |
1
| assertEquals(1, entry.getModifications().size());
|
395 |
| |
396 |
| |
397 |
1
| assertEquals(null, dummy.getCalled());
|
398 |
1
| NodeSPI node = workspace.getNode(Fqn.fromString("/")).getNode();
|
399 |
| |
400 |
| |
401 |
1
| assertNotNull(node);
|
402 |
1
| node = (NodeSPI) node.getChild("one");
|
403 |
1
| assertEquals(new DefaultDataVersion(1), node.getVersion());
|
404 |
1
| assertNotNull(node);
|
405 |
1
| assertTrue(cache.exists(node.getFqn()));
|
406 |
1
| assertEquals(new DefaultDataVersion(1), node.getVersion());
|
407 |
1
| node = (NodeSPI) node.getChild("two");
|
408 |
1
| assertNotNull(node);
|
409 |
1
| assertTrue(cache.exists(node.getFqn()));
|
410 |
1
| assertEquals(new DefaultDataVersion(1), node.getVersion());
|
411 |
| |
412 |
1
| assertEquals(pojo, node.get("key1"));
|
413 |
| |
414 |
1
| mgr.commit();
|
415 |
| |
416 |
1
| destroyCache(cache);
|
417 |
| } |
418 |
| |
419 |
1
| public void testTransactionValidateRollbackMethod() throws Exception
|
420 |
| { |
421 |
| |
422 |
1
| CacheImpl cache = createCacheWithListener();
|
423 |
1
| Interceptor validateInterceptor = new OptimisticValidatorInterceptor();
|
424 |
1
| validateInterceptor.setCache(cache);
|
425 |
1
| Interceptor interceptor = new OptimisticCreateIfNotExistsInterceptor();
|
426 |
1
| interceptor.setCache(cache);
|
427 |
1
| Interceptor nodeInterceptor = new OptimisticNodeInterceptor();
|
428 |
1
| nodeInterceptor.setCache(cache);
|
429 |
1
| MockInterceptor dummy = new MockInterceptor();
|
430 |
1
| dummy.setCache(cache);
|
431 |
1
| validateInterceptor.setNext(interceptor);
|
432 |
1
| interceptor.setNext(nodeInterceptor);
|
433 |
1
| nodeInterceptor.setNext(dummy);
|
434 |
| |
435 |
1
| cache.setInterceptorChain(validateInterceptor);
|
436 |
| |
437 |
| |
438 |
1
| DummyTransactionManager mgr = DummyTransactionManager.getInstance();
|
439 |
1
| mgr.begin();
|
440 |
1
| Transaction tx = mgr.getTransaction();
|
441 |
| |
442 |
| |
443 |
1
| cache.getInvocationContext().setTransaction(tx);
|
444 |
1
| cache.getInvocationContext().setGlobalTransaction(cache.getCurrentTransaction(tx));
|
445 |
| |
446 |
1
| SamplePojo pojo = new SamplePojo(21, "test");
|
447 |
1
| Map temp = new HashMap();
|
448 |
1
| temp.put("key1", pojo);
|
449 |
1
| cache.put("/one/two", temp);
|
450 |
| |
451 |
1
| assertEquals(null, dummy.getCalled());
|
452 |
1
| TransactionTable table = cache.getTransactionTable();
|
453 |
| |
454 |
1
| GlobalTransaction gtx = table.get(tx);
|
455 |
| |
456 |
1
| OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
|
457 |
| |
458 |
1
| TransactionWorkspace workspace = entry.getTransactionWorkSpace();
|
459 |
| |
460 |
| |
461 |
| |
462 |
| |
463 |
| |
464 |
| |
465 |
1
| assertEquals(3, workspace.getNodes().size());
|
466 |
1
| assertNotNull(workspace.getNode(Fqn.fromString("/one/two")));
|
467 |
1
| assertEquals(pojo, workspace.getNode(Fqn.fromString("/one/two")).get("key1"));
|
468 |
1
| assertEquals(1, workspace.getNode(Fqn.fromString("/one/two")).getMergedData().size());
|
469 |
1
| assertTrue(entry.getLocks().isEmpty());
|
470 |
1
| assertEquals(1, entry.getModifications().size());
|
471 |
1
| assertTrue(!cache.exists("/one/two"));
|
472 |
1
| assertEquals(null, dummy.getCalled());
|
473 |
| |
474 |
| |
475 |
| |
476 |
1
| MethodCall prepareMethod = MethodCallFactory.create(MethodDeclarations.optimisticPrepareMethod, new Object[]{gtx, entry.getModifications(), gtx.getAddress(), Boolean.FALSE});
|
477 |
1
| try
|
478 |
| { |
479 |
1
| cache._replicate(prepareMethod);
|
480 |
1
| fail();
|
481 |
| } |
482 |
| catch (Throwable t) |
483 |
| { |
484 |
1
| assertTrue(true);
|
485 |
| } |
486 |
| |
487 |
1
| MethodCall rollbackMethod = MethodCallFactory.create(MethodDeclarations.rollbackMethod, new Object[]{gtx});
|
488 |
1
| try
|
489 |
| { |
490 |
1
| cache._replicate(rollbackMethod);
|
491 |
| } |
492 |
| catch (Throwable t) |
493 |
| { |
494 |
0
| fail();
|
495 |
| } |
496 |
| |
497 |
| |
498 |
1
| assertEquals(0, workspace.getNodes().size());
|
499 |
1
| assertNull(workspace.getNode(Fqn.fromString("/one/two")));
|
500 |
1
| assertNull(workspace.getNode(Fqn.fromString("/one")));
|
501 |
1
| assertTrue(entry.getLocks().isEmpty());
|
502 |
1
| assertEquals(1, entry.getModifications().size());
|
503 |
| |
504 |
1
| mgr.commit();
|
505 |
| |
506 |
1
| destroyCache(cache);
|
507 |
| } |
508 |
| |
509 |
| } |