package edu.ouc.chain;

import java.lang.reflect.Proxy;

public class AdvisorChainTest {
	
	public static void main(String args[]){
		
		UserService user = new UserServiceImpl();
		UserService proxy = (UserService)ProxyBuilder.buildProxy(UserService.class,user);
		proxy.insert(null);
	}
	static class ProxyBuilder{
		public static Object buildProxy(Class<?> interfaces, Object target){
			
			return Proxy.newProxyInstance(ProxyBuilder.class.getClassLoader(), 
					new Class<?>[]{interfaces},  new DefaultInvocationHandler(target));
		}
	}
}

@@ -30,273 +30,498 @@
 ort 
-java.lang.reflect.Proxy;%0D%0A%0D%0Apublic class AdvisorChainTest %7B
+static org.junit.Assert.*;%0D%0A%0D%0Aimport java.lang.reflect.Proxy;%0D%0Aimport java.util.Arrays;%0D%0Aimport java.util.HashSet;%0D%0Aimport java.util.List;%0D%0Aimport java.util.Set;
 %0D%0A
-%09
 %0D%0A
-%09public static void main(String args%5B%5D)%7B%0D%0A%09%09%0D%0A%09%09UserService user = new UserServiceImpl();%0D%0A%09%09UserService proxy = (UserService)ProxyBuilder.buildProxy(UserService.class,user);%0D%0A%09%09proxy.insert(null);%0D%0A%09%7D
+import org.junit.Test;%0D%0Aimport org.slf4j.Logger;%0D%0Aimport org.slf4j.LoggerFactory;%0D%0A%0D%0Aimport edu.ouc.base.BaseTest;%0D%0Aimport edu.ouc.chain.MethodFilterInterceptor.MethodNotAllowedException;%0D%0A%0D%0Apublic class AdvisorChainTest extends BaseTest%7B%0D%0A%09private static final Logger LOG = LoggerFactory.getLogger(AdvisorChainTest.class);%0D%0A
 %0D%0A%09s
@@ -619,15 +619,40 @@
 rget
-)%7B%0D%0A%09%09%09
+, List%3CMethodInterceptor%3E list)%7B
 %0D%0A%09%09
@@ -790,16 +790,801 @@
 r(target
+, list));%0D%0A%09%09%7D%0D%0A%09%7D%0D%0A%0D%0A%09@Test%0D%0A%09public void testAOP() %7B%0D%0A%09%09%0D%0A%09%09Set%3CString%3E exclusionMethodNames = new HashSet%3CString%3E();%0D%0A%09%09exclusionMethodNames.add(%22delete%22);//delete%0D%0A%09%09%0D%0A%09%09//%CB%B7%0D%0A%09%09MethodFilterInterceptor filter = new MethodFilterInterceptor(exclusionMethodNames);%0D%0A%09%09%0D%0A%09%09//%C2%BC%D6%B4%CA%B1%0D%0A%09%09TimeLogInterceptor time = new TimeLogInterceptor();%0D%0A%09%09%0D%0A%09%09List%3CMethodInterceptor%3E list = Arrays.asList(filter,time);%0D%0A%09%09%0D%0A%09%09UserService user = new UserServiceImpl();%0D%0A%09%09UserService proxy = (UserService)ProxyBuilder.buildProxy(UserService.class,user,list);%0D%0A%0D%0A%09%09proxy.update(null);%0D%0A%09%09assertTrue(time.msg.contains(%22update execute time:%22));%0D%0A%09%09%0D%0A%09%09try%7B%0D%0A%09%09%09proxy.delete(null);%0D%0A%09%09%09fail(%22method delete is not allowed!%22);%0D%0A%09%09%7Dcatch(Exception e)%7B%0D%0A%09%09%09assertEquals(MethodNotAllowedException.class, e.getClass(
 ));%0D%0A%09%09%7D

refactor Test case