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 11 public abstract class InterceptorChainTestBase extends TestCase 12 { 13 protected void assertLast(Interceptor first, Interceptor last) 14 { 15 assertNotNull("First interceptor in the chain cannot be null", first); 16 assertNotNull("Last interceptor in the chain cannot be null", last); 17 18 Interceptor i = first; 19 while (i != null) 20 { 21 assertEquals("Expected last interceptor (in " + i + ") to be " + last, last, i.getLast()); 22 i = i.getNext(); 23 } 24 } 25 26 protected void assertInterceptorLinkage(List <Interceptor> list) 27 { 28 Interceptor previous = null; 29 for (Interceptor i : list) 30 { 31 if (previous == null) 32 { 33 previous = i; 34 continue; 35 } 36 37 assertEquals("Expecting the next interceptor after " + previous + " to be " + i, i, previous.getNext()); 38 39 previous = i; 40 } 41 42 assertLast(list.get(0), previous); 43 } 44 } 45 | Popular Tags |