01: /*****************************************************************************
02: * Copyright (c) PicoContainer Organization. All rights reserved. *
03: * ------------------------------------------------------------------------- *
04: * The software in this package is published under the terms of the BSD *
05: * style license a copy of which has been included with this distribution in *
06: * the LICENSE.txt file. *
07: * *
08: * Idea by Rachel Davies, Original code by various *
09: *****************************************************************************/package org.nanocontainer.aop.dynaop;
10:
11: import dynaop.Invocation;
12: import org.aopalliance.intercept.MethodInterceptor;
13: import org.aopalliance.intercept.MethodInvocation;
14: import org.jmock.Mock;
15: import org.jmock.MockObjectTestCase;
16:
17: /**
18: * @author Stephen Molitor
19: */
20: public class MethodInterceptorAdapterTestCase extends
21: MockObjectTestCase {
22:
23: private Mock mockMethodInterceptor = mock(MethodInterceptor.class);
24: private Mock mockInvocation = mock(Invocation.class);
25:
26: public void testInvoke() throws Throwable {
27: mockMethodInterceptor.expects(once()).method("invoke").with(
28: isA(MethodInvocation.class))
29: .will(returnValue("result"));
30:
31: dynaop.Interceptor interceptor = new MethodInterceptorAdapter(
32: (MethodInterceptor) mockMethodInterceptor.proxy());
33: Object result = interceptor
34: .intercept((Invocation) mockInvocation.proxy());
35: assertEquals("result", result);
36: }
37:
38: }
|