1
2
3
4
5 package org.neo.swarm.interceptor.appContext;
6
7 import java.lang.reflect.Method;
8
9 import junit.framework.TestCase;
10
11 import org.neo.swarm.ApplicationContext;
12 import org.neo.swarm.core.aop.silc.comp.Invocation;
13 import org.neo.swarm.interceptor.appContext.GetMethodInterceptor;
14
15 import com.mockobjects.dynamic.C;
16 import com.mockobjects.dynamic.Mock;
17
18 /***
19 * This filters remote calls from AC->get(blah) => AC->getInterceptor(blah);
20 * @author navery
21 */
22 public class GetMethodInterceptorTest extends TestCase {
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38 public void testConversionOfRetrieveComponent() throws Throwable {
39 Method method = ApplicationContext.class.getMethod("retrieveComponent", new Class[] { Object.class });
40
41 Mock invocation = new Mock(Invocation.class);
42
43 invocation.expectAndReturn("getMethod", method);
44 invocation.expectAndReturn("getArguments", new Object[] { "objectKey"});
45
46 invocation.expectAndReturn("getArguments", new Object[] { "objectKey"});
47 invocation.expect("setMethod", C.ANY_ARGS);
48 invocation.expect("setArguments", C.ANY_ARGS);
49 invocation.expect("proceed", C.ANY_ARGS);
50
51 GetMethodInterceptor getInterceptor = new GetMethodInterceptor();
52 getInterceptor.invoke((Invocation) invocation.proxy());
53
54 invocation.verify();
55 }
56
57 public void testConversionOfRetrieveComponentsOfType() throws Throwable {
58 Method method = ApplicationContext.class.getMethod("retrieveComponentsOfType", new Class[] { Class.class });
59
60 Mock invocation = new Mock(Invocation.class);
61
62 invocation.expectAndReturn("getMethod", method);
63 invocation.expectAndReturn("getArguments", new Object[] { "objectKey"});
64 invocation.expectAndReturn("getArguments", new Object[] { "objectKey"});
65 invocation.expect("setMethod", C.ANY_ARGS);
66 invocation.expect("setArguments", C.ANY_ARGS);
67 invocation.expect("proceed", C.ANY_ARGS);
68
69 GetMethodInterceptor getInterceptor = new GetMethodInterceptor();
70 getInterceptor.invoke((Invocation) invocation.proxy());
71
72 invocation.verify();
73 }
74 }