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:
17: package net.sf.cglib.transform.impl;
18:
19: import net.sf.cglib.transform.*;
20: import junit.framework.*;
21:
22: /**
23: *
24: * @author baliuka
25: */
26: public class TestProvideFields extends AbstractTransformTest {
27:
28: String field = "test";
29:
30: /** Creates a new instance of TestProvideFields */
31: public TestProvideFields() {
32: }
33:
34: /** Creates a new instance of TestProvideFields */
35: public TestProvideFields(String name) {
36: super (name);
37: }
38:
39: public void test() {
40:
41: FieldProvider provider = (FieldProvider) this ;
42: assertEquals(field, provider.getField("field"));
43: String value = "tst2";
44: provider.setField("field", value);
45: assertEquals(field, value);
46:
47: }
48:
49: protected ClassTransformerFactory getTransformer() throws Exception {
50:
51: return new ClassTransformerFactory() {
52:
53: public ClassTransformer newInstance() {
54:
55: return new FieldProviderTransformer();
56: }
57: };
58: }
59:
60: public static void main(String[] args) throws Exception {
61: junit.textui.TestRunner.run(suite());
62: }
63:
64: public static Test suite() throws Exception {
65: return new TestSuite(new TestProvideFields().transform());
66: }
67:
68: }
|