KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > aop > implementz > ImplementsTester


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.implementz;
23
24 import org.jboss.test.aop.AOPTestWithSetup;
25
26 /**
27  *
28  * @author <a HREF="kabir.khan@jboss.com">Kabir Khan</a>
29  * @version $Revision: 45977 $
30  */

31 public class ImplementsTester extends AOPTestWithSetup
32 {
33
34    /**
35     * Constructor for ImplementsTester.
36     * @param arg0
37     */

38    public ImplementsTester(String JavaDoc arg0)
39    {
40       super(arg0);
41    }
42
43    public void testImplements() throws Exception JavaDoc
44    {
45       System.out.println("RUNNING TEST $IMPLEMENTS");
46       
47       ImplementsPOJO pojo = new ImplementsPOJO();
48
49       CallerInterceptor.called = false;
50       pojo.method2();
51       assertFalse(CallerInterceptor.called);
52
53       CallerInterceptor.called = false;
54       pojo.method3();
55       assertFalse(CallerInterceptor.called);
56       
57       CallerInterceptor.called = false;
58       pojo.method3("x");
59       assertTrue(CallerInterceptor.called);
60       
61       CallerInterceptor.called = false;
62       pojo.method4();
63       assertFalse(CallerInterceptor.called);
64
65       CallerInterceptor.called = false;
66       pojo.pojoMethod();
67       assertFalse(CallerInterceptor.called);
68       
69       ImplementsPOJOChild child = new ImplementsPOJOChild();
70       CallerInterceptor.called = false;
71       child.method1();
72       assertTrue(CallerInterceptor.called);
73
74       CallerInterceptor.called = false;
75       child.method1("s");
76       assertTrue(CallerInterceptor.called);
77
78       CallerInterceptor.called = false;
79       child.method2();
80       assertFalse(CallerInterceptor.called);
81
82       CallerInterceptor.called = false;
83       child.method3();
84       assertFalse(CallerInterceptor.called);
85
86       CallerInterceptor.called = false;
87       child.method3("c");
88       assertTrue(CallerInterceptor.called);
89
90       CallerInterceptor.called = false;
91       child.method4();
92       assertFalse(CallerInterceptor.called);
93
94       CallerInterceptor.called = false;
95       child.method4("x");
96       assertFalse(CallerInterceptor.called);
97
98       CallerInterceptor.called = false;
99       child.notImplemented();
100       assertFalse(CallerInterceptor.called);
101       
102       CallerInterceptor.called = false;
103       child.matchedUsingHas();
104       assertTrue(CallerInterceptor.called);
105
106       CallerInterceptor.called = false;
107       child.pojoMethod();
108       assertFalse(CallerInterceptor.called);
109
110       CallerInterceptor.called = false;
111       child.pojoChildMethod();
112       assertFalse(CallerInterceptor.called);
113       
114       CallerInterceptor.called = false;
115       child.methodAnnotated();
116       assertTrue(CallerInterceptor.called);
117
118       ImplementsPOJOGrandChild grandChild = new ImplementsPOJOGrandChild();
119       CallerInterceptor.called = false;
120       grandChild.pojoMethod();
121       assertFalse(CallerInterceptor.called);
122
123       CallerInterceptor.called = false;
124       grandChild.pojoChildMethod();
125       assertTrue(CallerInterceptor.called);
126       
127    }
128
129    public void testImplementing() throws Exception JavaDoc
130    {
131       System.out.println("RUNNING TEST $IMPLEMENTING");
132       
133       ImplementingPOJO pojo = new ImplementingPOJO();
134
135       CallerInterceptor.called = false;
136       pojo.method2();
137       assertFalse(CallerInterceptor.called);
138
139       CallerInterceptor.called = false;
140       pojo.method3();
141       assertFalse(CallerInterceptor.called);
142       
143       CallerInterceptor.called = false;
144       pojo.method3("x");
145       assertTrue(CallerInterceptor.called);
146       
147       CallerInterceptor.called = false;
148       pojo.method4();
149       assertFalse(CallerInterceptor.called);
150
151       CallerInterceptor.called = false;
152       pojo.method4("x");
153       assertTrue(CallerInterceptor.called);
154
155       CallerInterceptor.called = false;
156       pojo.pojoMethod();
157       assertFalse(CallerInterceptor.called);
158       
159       ImplementingPOJOChild child = new ImplementingPOJOChild();
160       CallerInterceptor.called = false;
161       child.method1();
162       assertTrue(CallerInterceptor.called);
163
164       CallerInterceptor.called = false;
165       child.method1("s");
166       assertTrue(CallerInterceptor.called);
167
168       CallerInterceptor.called = false;
169       child.method2();
170       assertFalse(CallerInterceptor.called);
171
172       CallerInterceptor.called = false;
173       child.method3();
174       assertFalse(CallerInterceptor.called);
175
176       CallerInterceptor.called = false;
177       child.method3("c");
178       assertTrue(CallerInterceptor.called);
179
180       CallerInterceptor.called = false;
181       child.method4();
182       assertFalse(CallerInterceptor.called);
183
184       CallerInterceptor.called = false;
185       child.method4("x");
186       assertTrue(CallerInterceptor.called);
187
188       CallerInterceptor.called = false;
189       child.notImplemented();
190       assertFalse(CallerInterceptor.called);
191       
192       CallerInterceptor.called = false;
193       child.pojoMethod();
194       assertFalse(CallerInterceptor.called);
195
196       CallerInterceptor.called = false;
197       child.pojoChildMethod();
198       assertFalse(CallerInterceptor.called);
199       
200       CallerInterceptor.called = false;
201       child.methodAnnotated();
202       assertTrue(CallerInterceptor.called);
203
204       ImplementingPOJOGrandChild grandChild = new ImplementingPOJOGrandChild();
205       CallerInterceptor.called = false;
206       grandChild.pojoMethod();
207       assertTrue(CallerInterceptor.called);
208
209       CallerInterceptor.called = false;
210       grandChild.pojoChildMethod();
211       assertTrue(CallerInterceptor.called);
212       
213    }
214
215 }
216
Popular Tags