1 |
| package org.jboss.cache.factories; |
2 |
| |
3 |
| import junit.framework.TestCase; |
4 |
| import org.jboss.cache.interceptors.Interceptor; |
5 |
| |
6 |
| import java.util.List; |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| public abstract class InterceptorChainTestBase extends TestCase |
12 |
| { |
13 |
28
| protected void assertLast(Interceptor first, Interceptor last)
|
14 |
| { |
15 |
28
| assertNotNull("First interceptor in the chain cannot be null", first);
|
16 |
28
| assertNotNull("Last interceptor in the chain cannot be null", last);
|
17 |
| |
18 |
28
| Interceptor i = first;
|
19 |
28
| while (i != null)
|
20 |
| { |
21 |
214
| assertEquals("Expected last interceptor (in " + i + ") to be " + last, last, i.getLast());
|
22 |
214
| i = i.getNext();
|
23 |
| } |
24 |
| } |
25 |
| |
26 |
28
| protected void assertInterceptorLinkage(List<Interceptor> list)
|
27 |
| { |
28 |
28
| Interceptor previous = null;
|
29 |
28
| for (Interceptor i : list)
|
30 |
| { |
31 |
214
| if (previous == null)
|
32 |
| { |
33 |
28
| previous = i;
|
34 |
28
| continue;
|
35 |
| } |
36 |
| |
37 |
186
| assertEquals("Expecting the next interceptor after " + previous + " to be " + i, i, previous.getNext());
|
38 |
| |
39 |
186
| previous = i;
|
40 |
| } |
41 |
| |
42 |
28
| assertLast(list.get(0), previous);
|
43 |
| } |
44 |
| } |