KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > aop > callerargs > NotAdvisedPOJOCaller


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22 package org.jboss.test.aop.callerargs;
23
24 /**
25  *
26  * @author <a HREF="kabir.khan@jboss.com">Kabir Khan</a>
27  * @version $Revision$
28  */

29 public class NotAdvisedPOJOCaller
30 {
31    public NotAdvisedPOJOCaller()
32    {
33       CallerInterceptor.intercepted = false;
34       NotAdvisedPOJO.voidStaticNoArgsMethod();
35       if (!CallerInterceptor.intercepted) throw new RuntimeException JavaDoc("Did not intercept");
36       if (CallerInterceptor.argsLength != 0) throw new RuntimeException JavaDoc("Args length should have been 0");
37       
38       CallerInterceptor.intercepted = false;
39       int ret = NotAdvisedPOJO.intStaticArgsMethod(3);
40       if (ret != 6) throw new RuntimeException JavaDoc("Expected 6 as return value");
41       if (!CallerInterceptor.intercepted) throw new RuntimeException JavaDoc("Did not intercept");
42       if (CallerInterceptor.argsLength != 1) throw new RuntimeException JavaDoc("Args length should have been 1");
43       if (((Integer JavaDoc)CallerInterceptor.args[0]).intValue() != 3) throw new RuntimeException JavaDoc("Args[0] should have been 3");
44
45       CallerInterceptor.intercepted = false;
46       NotAdvisedPOJO pojo = new NotAdvisedPOJO();
47       if (!CallerInterceptor.intercepted) throw new RuntimeException JavaDoc("Did not intercept");
48       if (CallerInterceptor.argsLength != 0) throw new RuntimeException JavaDoc("Args length should have been 0");
49       
50       CallerInterceptor.intercepted = false;
51       pojo.voidNoArgsMethod();
52       if (!CallerInterceptor.intercepted) throw new RuntimeException JavaDoc("Did not intercept");
53       if (CallerInterceptor.argsLength != 0) throw new RuntimeException JavaDoc("Args length should have been 0");
54       
55       CallerInterceptor.intercepted = false;
56       NotAdvisedPOJO pojo2 = new NotAdvisedPOJO(10, 100);
57       if (!CallerInterceptor.intercepted) throw new RuntimeException JavaDoc("Did not intercept");
58       if(pojo2.i != 10) throw new RuntimeException JavaDoc("Expected pojo.i to be 10");
59       if(pojo2.j != 100) throw new RuntimeException JavaDoc("Expected pojo.i to be 100");
60       if (CallerInterceptor.argsLength != 2) throw new RuntimeException JavaDoc("Args length should have been 2");
61       if (((Integer JavaDoc)CallerInterceptor.args[0]).intValue() != 10) throw new RuntimeException JavaDoc("Args[0] should have been 10");
62       if (((Integer JavaDoc)CallerInterceptor.args[1]).intValue() != 100) throw new RuntimeException JavaDoc("Args[1] should have been 100");
63       
64       CallerInterceptor.intercepted = false;
65       ret = pojo2.intArgsMethod(20, 100);
66       if (!CallerInterceptor.intercepted) throw new RuntimeException JavaDoc("Did not intercept");
67       if (ret != 2000)throw new RuntimeException JavaDoc("Expected 2000 as return value");
68       if (((Integer JavaDoc)CallerInterceptor.args[0]).intValue() != 20) throw new RuntimeException JavaDoc("Args[0] should have been 20");
69       if (((Integer JavaDoc)CallerInterceptor.args[1]).intValue() != 100) throw new RuntimeException JavaDoc("Args[1] should have been 100");
70    }
71    
72    public void method()
73    {
74       CallerInterceptor.intercepted = false;
75       NotAdvisedPOJO.voidStaticNoArgsMethod();
76       if (!CallerInterceptor.intercepted) throw new RuntimeException JavaDoc("Did not intercept");
77       if (CallerInterceptor.argsLength != 0) throw new RuntimeException JavaDoc("Args length should have been 0");
78       
79       CallerInterceptor.intercepted = false;
80       int ret = NotAdvisedPOJO.intStaticArgsMethod(3);
81       if (ret != 6) throw new RuntimeException JavaDoc("Expected 6 as return value");
82       if (!CallerInterceptor.intercepted) throw new RuntimeException JavaDoc("Did not intercept");
83       if (CallerInterceptor.argsLength != 1) throw new RuntimeException JavaDoc("Args length should have been 1");
84       if (((Integer JavaDoc)CallerInterceptor.args[0]).intValue() != 3) throw new RuntimeException JavaDoc("Args[0] should have been 3");
85
86       CallerInterceptor.intercepted = false;
87       NotAdvisedPOJO pojo = new NotAdvisedPOJO();
88       if (!CallerInterceptor.intercepted) throw new RuntimeException JavaDoc("Did not intercept");
89       if (CallerInterceptor.argsLength != 0) throw new RuntimeException JavaDoc("Args length should have been 0");
90       
91       CallerInterceptor.intercepted = false;
92       pojo.voidNoArgsMethod();
93       if (!CallerInterceptor.intercepted) throw new RuntimeException JavaDoc("Did not intercept");
94       if (CallerInterceptor.argsLength != 0) throw new RuntimeException JavaDoc("Args length should have been 0");
95       
96       CallerInterceptor.intercepted = false;
97       NotAdvisedPOJO pojo2 = new NotAdvisedPOJO(10, 100);
98       if (!CallerInterceptor.intercepted) throw new RuntimeException JavaDoc("Did not intercept");
99       if(pojo2.i != 10) throw new RuntimeException JavaDoc("Expected pojo.i to be 10");
100       if(pojo2.j != 100) throw new RuntimeException JavaDoc("Expected pojo.i to be 100");
101       if (CallerInterceptor.argsLength != 2) throw new RuntimeException JavaDoc("Args length should have been 2");
102       if (((Integer JavaDoc)CallerInterceptor.args[0]).intValue() != 10) throw new RuntimeException JavaDoc("Args[0] should have been 10");
103       if (((Integer JavaDoc)CallerInterceptor.args[1]).intValue() != 100) throw new RuntimeException JavaDoc("Args[1] should have been 100");
104       
105       CallerInterceptor.intercepted = false;
106       ret = pojo2.intArgsMethod(20, 100);
107       if (!CallerInterceptor.intercepted) throw new RuntimeException JavaDoc("Did not intercept");
108       if (ret != 2000)throw new RuntimeException JavaDoc("Expected 2000 as return value");
109       if (((Integer JavaDoc)CallerInterceptor.args[0]).intValue() != 20) throw new RuntimeException JavaDoc("Args[0] should have been 20");
110       if (((Integer JavaDoc)CallerInterceptor.args[1]).intValue() != 100) throw new RuntimeException JavaDoc("Args[1] should have been 100");
111    }
112    
113    public static void staticMethod()
114    {
115       CallerInterceptor.intercepted = false;
116       NotAdvisedPOJO.voidStaticNoArgsMethod();
117       if (!CallerInterceptor.intercepted) throw new RuntimeException JavaDoc("Did not intercept");
118       if (CallerInterceptor.argsLength != 0) throw new RuntimeException JavaDoc("Args length should have been 0");
119       
120       CallerInterceptor.intercepted = false;
121       int ret = NotAdvisedPOJO.intStaticArgsMethod(3);
122       if (ret != 6) throw new RuntimeException JavaDoc("Expected 6 as return value");
123       if (!CallerInterceptor.intercepted) throw new RuntimeException JavaDoc("Did not intercept");
124       if (CallerInterceptor.argsLength != 1) throw new RuntimeException JavaDoc("Args length should have been 1");
125       if (((Integer JavaDoc)CallerInterceptor.args[0]).intValue() != 3) throw new RuntimeException JavaDoc("Args[0] should have been 3");
126
127       CallerInterceptor.intercepted = false;
128       NotAdvisedPOJO pojo = new NotAdvisedPOJO();
129       if (!CallerInterceptor.intercepted) throw new RuntimeException JavaDoc("Did not intercept");
130       if (CallerInterceptor.argsLength != 0) throw new RuntimeException JavaDoc("Args length should have been 0");
131       
132       CallerInterceptor.intercepted = false;
133       pojo.voidNoArgsMethod();
134       if (!CallerInterceptor.intercepted) throw new RuntimeException JavaDoc("Did not intercept");
135       if (CallerInterceptor.argsLength != 0) throw new RuntimeException JavaDoc("Args length should have been 0");
136       
137       CallerInterceptor.intercepted = false;
138       NotAdvisedPOJO pojo2 = new NotAdvisedPOJO(10, 100);
139       if (!CallerInterceptor.intercepted) throw new RuntimeException JavaDoc("Did not intercept");
140       if(pojo2.i != 10) throw new RuntimeException JavaDoc("Expected pojo.i to be 10");
141       if(pojo2.j != 100) throw new RuntimeException JavaDoc("Expected pojo.i to be 100");
142       if (CallerInterceptor.argsLength != 2) throw new RuntimeException JavaDoc("Args length should have been 2");
143       if (((Integer JavaDoc)CallerInterceptor.args[0]).intValue() != 10) throw new RuntimeException JavaDoc("Args[0] should have been 10");
144       if (((Integer JavaDoc)CallerInterceptor.args[1]).intValue() != 100) throw new RuntimeException JavaDoc("Args[1] should have been 100");
145       
146       CallerInterceptor.intercepted = false;
147       ret = pojo2.intArgsMethod(20, 100);
148       if (!CallerInterceptor.intercepted) throw new RuntimeException JavaDoc("Did not intercept");
149       if (ret != 2000)throw new RuntimeException JavaDoc("Expected 2000 as return value");
150       if (((Integer JavaDoc)CallerInterceptor.args[0]).intValue() != 20) throw new RuntimeException JavaDoc("Args[0] should have been 20");
151       if (((Integer JavaDoc)CallerInterceptor.args[1]).intValue() != 100) throw new RuntimeException JavaDoc("Args[1] should have been 100");
152    }
153 }
154
Popular Tags