KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > nanocontainer > aop > dynaop > DynaopMethodPointcutTestCase


1 /*****************************************************************************
2  * Copyright (c) PicoContainer Organization. All rights reserved. *
3  * ------------------------------------------------------------------------- *
4  * The software in this package is published under the terms of the BSD *
5  * style license a copy of which has been included with this distribution in *
6  * the LICENSE.txt file. *
7  * *
8  * Idea by Rachel Davies, Original code by various *
9  *****************************************************************************/

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 JavaDoc;
17
18 /**
19  * @author Stephen Molitor
20  */

21 public class DynaopMethodPointcutTestCase extends MockObjectTestCase {
22
23     private Mock mockDelegate = mock(dynaop.MethodPointcut.class);
24
25     public void testPicks() throws SecurityException JavaDoc, NoSuchMethodException JavaDoc {
26         Method JavaDoc method1 = String JavaDoc.class.getMethod("length", new Class JavaDoc[]{});
27         Method JavaDoc method2 = String JavaDoc.class.getMethod("hashCode", new Class JavaDoc[]{});
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