KickJava   Java API By Example, From Geeks To Geeks.

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


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.Invocation;
13 import org.aopalliance.intercept.MethodInterceptor;
14 import org.aopalliance.intercept.MethodInvocation;
15 import org.jmock.Mock;
16 import org.jmock.MockObjectTestCase;
17
18 /**
19  * @author Stephen Molitor
20  */

21 public class MethodInterceptorAdapterTestCase extends MockObjectTestCase {
22
23     private Mock mockMethodInterceptor = mock(MethodInterceptor.class);
24     private Mock mockInvocation = mock(Invocation.class);
25
26     public void testInvoke() throws Throwable JavaDoc {
27         mockMethodInterceptor.expects(once()).method("invoke").with(isA(MethodInvocation.class)).will(returnValue("result"));
28
29         dynaop.Interceptor interceptor = new MethodInterceptorAdapter((MethodInterceptor) mockMethodInterceptor.proxy());
30         Object JavaDoc result = interceptor.intercept((Invocation) mockInvocation.proxy());
31         assertEquals("result", result);
32     }
33
34 }
Popular Tags