1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.shiro.guice.aop;
20
21 import org.aopalliance.intercept.MethodInvocation;
22 import org.junit.Test;
23
24 import java.lang.reflect.Method;
25
26 import static org.easymock.EasyMock.*;
27 import static org.junit.Assert.assertSame;
28
29
30
31
32
33
34
35
36 public class AopAllianceMethodInvocationAdapterTest {
37 @Test
38 public void testGetMethod() throws Exception {
39 MethodInvocation mock = createMock(MethodInvocation.class);
40 Method method = AopAllianceMethodInvocationAdapterTest.class.getMethod("testGetMethod");
41 expect(mock.getMethod()).andReturn(method);
42 AopAllianceMethodInvocationAdapter underTest = new AopAllianceMethodInvocationAdapter(mock);
43
44 replay(mock);
45
46 assertSame(method, underTest.getMethod());
47
48 verify(mock);
49 }
50
51 @Test
52 public void testGetArguments() throws Exception {
53 MethodInvocation mock = createMock(MethodInvocation.class);
54 Object[] args = new Object[0];
55 expect(mock.getArguments()).andReturn(args);
56 AopAllianceMethodInvocationAdapter underTest = new AopAllianceMethodInvocationAdapter(mock);
57
58 replay(mock);
59
60 assertSame(args, underTest.getArguments());
61
62 verify(mock);
63 }
64
65 @Test
66 public void testProceed() throws Throwable {
67 MethodInvocation mock = createMock(MethodInvocation.class);
68 Object value = new Object();
69 expect(mock.proceed()).andReturn(value);
70 AopAllianceMethodInvocationAdapter underTest = new AopAllianceMethodInvocationAdapter(mock);
71
72 replay(mock);
73
74 assertSame(value, underTest.proceed());
75
76 verify(mock);
77 }
78
79 @Test
80 public void testGetThis() throws Exception {
81 MethodInvocation mock = createMock(MethodInvocation.class);
82 Object value = new Object();
83 expect(mock.getThis()).andReturn(value);
84 AopAllianceMethodInvocationAdapter underTest = new AopAllianceMethodInvocationAdapter(mock);
85
86 replay(mock);
87
88 assertSame(value, underTest.getThis());
89
90 verify(mock);
91 }
92 }