KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > cglib > transform > AbstractTransformTest


1 /*
2  * Copyright 2003,2004 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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     
28      /** Creates a new instance of AbstractTransformTest */
29     public AbstractTransformTest() {
30         super(null);
31     }
32    
33     /** Creates a new instance of AbstractTransformTest */
34     public AbstractTransformTest(String JavaDoc s) {
35        super(s);
36     }
37     
38     protected abstract ClassTransformerFactory getTransformer() throws Exception JavaDoc;
39     
40     public Class JavaDoc transform() throws Exception JavaDoc {
41         ClassLoader JavaDoc loader =
42             new TransformingClassLoader(AbstractTransformTest.class.getClassLoader(),
43                                         new ClassFilter(){
44                                             public boolean accept(String JavaDoc name){
45                                                 return !(name.startsWith("java")
46                                                          || name.startsWith("junit")
47                                                          || name.endsWith("Exclude"));
48                                             }
49                                         },
50                                         getTransformer());
51         try {
52             return loader.loadClass(getClass().getName());
53         } catch (Exception JavaDoc e) {
54             e.printStackTrace(System.err);
55             throw e;
56         }
57     }
58
59     protected void postProcess(Class JavaDoc c) {
60     }
61 }
62
Popular Tags