1 |
| package org.jboss.cache.optimistic; |
2 |
| |
3 |
| import org.jboss.cache.CacheSPI; |
4 |
| import org.jboss.cache.InvocationContext; |
5 |
| import org.jboss.cache.interceptors.Interceptor; |
6 |
| import org.jboss.cache.marshall.MethodCall; |
7 |
| |
8 |
| import java.util.ArrayList; |
9 |
| import java.util.List; |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| |
16 |
| |
17 |
| |
18 |
| |
19 |
| public class MockFailureInterceptor extends Interceptor |
20 |
| { |
21 |
| |
22 |
| |
23 |
2
| public void setCache(CacheSPI cache)
|
24 |
| { |
25 |
2
| super.setCache(cache);
|
26 |
| } |
27 |
| |
28 |
| |
29 |
| private List allCalled = new ArrayList(); |
30 |
| private List failurelist = new ArrayList(); |
31 |
| |
32 |
4
| public Object invoke(InvocationContext ctx) throws Throwable
|
33 |
| { |
34 |
4
| MethodCall m = ctx.getMethodCall();
|
35 |
4
| if (failurelist.contains(m.getMethod()))
|
36 |
| { |
37 |
2
| throw new Exception("Failure in method" + m);
|
38 |
| } |
39 |
| |
40 |
2
| allCalled.add(m.getMethod());
|
41 |
| |
42 |
2
| return null;
|
43 |
| } |
44 |
| |
45 |
| |
46 |
| |
47 |
| |
48 |
| |
49 |
0
| public List getFailurelist()
|
50 |
| { |
51 |
0
| return failurelist;
|
52 |
| } |
53 |
| |
54 |
| |
55 |
| |
56 |
| |
57 |
2
| public void setFailurelist(List failurelist)
|
58 |
| { |
59 |
2
| this.failurelist = failurelist;
|
60 |
| } |
61 |
| |
62 |
| |
63 |
| |
64 |
| |
65 |
2
| public List getAllCalled()
|
66 |
| { |
67 |
2
| return allCalled;
|
68 |
| } |
69 |
| |
70 |
| |
71 |
| |
72 |
| |
73 |
0
| public void setAllCalled(List called)
|
74 |
| { |
75 |
0
| this.allCalled = called;
|
76 |
| } |
77 |
| } |