1 /*
2 Copyright (c) 2003, Laurent Caillette.
3 All rights reserved.
4
5 Redistribution and use in source and binary forms, with or without modifica-
6 tion, are permitted provided that the following conditions are met:
7
8 1. Redistributions of source code must retain the above copyright notice,
9 this list of conditions and the following disclaimer.
10
11 2. Redistributions in binary form must reproduce the above copyright notice,
12 this list of conditions and the following disclaimer in the documentation
13 and/or other materials provided with the distribution.
14
15 3. The end-user documentation included with the redistribution, if any, must
16 include the following acknowledgment: "This product includes software
17 written by Laurent Caillette."
18 Alternately, this acknowledgment may appear in the software itself, if
19 and wherever such third-party acknowledgments normally appear.
20
21 4. The name "Laurent Caillette" must not be used to endorse or
22 promote products derived from this software without
23 prior written permission. For written permission, please contact
24 laurent.caillette@laposte.net
25
26 5. Products derived from this software may not be called
27 "Laurent Caillette", nor may "Laurent Caillette" appear
28 in their name, without prior written permission of the
29 author.
30
31 THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
32 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
33 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
34 AUTHOR (LAURENT CAILLETTE) BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
35 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
36 TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
37 OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
38 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
40 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41 */
42 package tweed.system.interceptor;
43 import java.lang.reflect.Method;
44 import junit.framework.Test;
45 import junit.framework.TestSuite;
46 import junit.textui.TestRunner;
47
48
49 /***
50 * Tests the test with an hard-coded version of an intercepted bean.
51 *
52 * @author Laurent Caillette
53 * @version $Id$
54 */
55 public class HardCodedInterceptionTest extends AbstractInterceptionTest {
56
57 protected MyBean createInterceptor(
58 MyBean subject,
59 InterceptionHandler handler
60 ) {
61 MyBeanInterceptor interceptor = new MyBeanInterceptor(
62 subject, handler ) ;
63
64 try {
65 interceptor.methodDescriptors[ 0 ] =
66 new MethodDescriptor( MyBean.class.getMethod(
67 "getMyObject",
68 new Class[ 0 ]
69 ) ) ;
70 interceptor.methodDescriptors[ 2 ] =
71 new MethodDescriptor( MyBean.class.getMethod(
72 "getMyIntProperty",
73 new Class[ 0 ]
74 ) ) ;
75 interceptor.methodDescriptors[ 4 ] =
76 new MethodDescriptor( MyBean.class.getMethod(
77 "getMyStringProperty",
78 new Class[ 0 ]
79 ) ) ;
80 interceptor.methodDescriptors[ 6 ] =
81 new MethodDescriptor( MyBean.class.getMethod(
82 "isMyBooleanProperty",
83 new Class[ 0 ]
84 ) ) ;
85 } catch( NoSuchMethodException ex ) {
86 throw new RuntimeException( ex ) ;
87 } catch( SecurityException ex ) {
88 throw new RuntimeException( ex ) ;
89 }
90
91 return interceptor ;
92
93 }
94
95
96 // =====
97 // JUnit
98 // =====
99
100 public HardCodedInterceptionTest( final String name ) {
101 super( name );
102 }
103
104 public static Test suite() {
105 TestSuite suite = new TestSuite();
106 suite.addTestSuite( HardCodedInterceptionTest.class );
107 return suite;
108 }
109
110 public static void main( String[] args ) {
111 TestRunner.run( HardCodedInterceptionTest.suite() );
112 }
113
114 }
This page was automatically generated by Maven