1 10 package org.nanocontainer.aop.dynaop; 11 12 import dynaop.MethodPointcut; 13 import org.jmock.Mock; 14 import org.jmock.MockObjectTestCase; 15 16 import java.lang.reflect.Method ; 17 18 21 public class DynaopMethodPointcutTestCase extends MockObjectTestCase { 22 23 private Mock mockDelegate = mock(dynaop.MethodPointcut.class); 24 25 public void testPicks() throws SecurityException , NoSuchMethodException { 26 Method method1 = String .class.getMethod("length", new Class []{}); 27 Method method2 = String .class.getMethod("hashCode", new Class []{}); 28 29 mockDelegate.expects(once()).method("picks").with(eq(method1)).will(returnValue(false)); 30 mockDelegate.expects(once()).method("picks").with(eq(method2)).will(returnValue(true)); 31 32 dynaop.MethodPointcut pointcut = new DynaopMethodPointcut((MethodPointcut) mockDelegate.proxy()); 33 assertFalse(pointcut.picks(method1)); 34 assertTrue(pointcut.picks(method2)); 35 } 36 37 } 38 | Popular Tags |