01: /*
02: * Copyright 2003 The Apache Software Foundation
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package net.sf.cglib.transform.impl;
17:
18: import net.sf.cglib.transform.*;
19: import junit.framework.*;
20:
21: /**
22: *
23: * @author baliuka
24: */
25: public class TestAddDelegate extends AbstractTransformTest {
26:
27: /** Creates a new instance of TestAddDelegate */
28: public TestAddDelegate(String name) {
29: super (name);
30: }
31:
32: public interface Interface {
33:
34: Object getDelegte();
35:
36: Object getTarget();
37:
38: }
39:
40: public void test() {
41:
42: Interface i = (Interface) this ;
43: assertEquals(i.getTarget(), this );
44:
45: }
46:
47: public static class ImplExclude implements Interface {
48:
49: private Object target;
50:
51: public ImplExclude(Object target) {
52: this .target = target;
53: }
54:
55: public Object getDelegte() {
56: return this ;
57: }
58:
59: public Object getTarget() {
60: return target;
61: }
62: }
63:
64: public TestAddDelegate() {
65: super (null);
66: }
67:
68: protected ClassTransformerFactory getTransformer() throws Exception {
69:
70: return new ClassTransformerFactory() {
71:
72: public ClassTransformer newInstance() {
73:
74: return new AddDelegateTransformer(
75: new Class[] { Interface.class },
76: ImplExclude.class);
77:
78: }
79:
80: };
81:
82: }
83:
84: public static void main(String[] args) throws Exception {
85: junit.textui.TestRunner.run(suite());
86: }
87:
88: public static Test suite() throws Exception {
89:
90: return new TestSuite(new TestAddDelegate().transform());
91:
92: }
93:
94: }
|