01: /*
02: * Copyright 2003,2004 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;
17:
18: import junit.framework.*;
19: import net.sf.cglib.core.CodeGenerationException;
20:
21: /**
22: * @author baliuka
23: * $Id: AbstractTransformTest.java,v 1.8 2004/06/24 21:15:16 herbyderby Exp $
24: */
25: abstract public class AbstractTransformTest extends TestCase {
26:
27: /** Creates a new instance of AbstractTransformTest */
28: public AbstractTransformTest() {
29: super (null);
30: }
31:
32: /** Creates a new instance of AbstractTransformTest */
33: public AbstractTransformTest(String s) {
34: super (s);
35: }
36:
37: protected abstract ClassTransformerFactory getTransformer()
38: throws Exception;
39:
40: public Class transform() throws Exception {
41: ClassLoader loader = new TransformingClassLoader(
42: AbstractTransformTest.class.getClassLoader(),
43: new ClassFilter() {
44: public boolean accept(String name) {
45: return !(name.startsWith("java")
46: || name.startsWith("junit") || name
47: .endsWith("Exclude"));
48: }
49: }, getTransformer());
50: try {
51: return loader.loadClass(getClass().getName());
52: } catch (Exception e) {
53: e.printStackTrace(System.err);
54: throw e;
55: }
56: }
57:
58: protected void postProcess(Class c) {
59: }
60: }
|