KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > avalon > excalibur > component > test > ComponentProxyGeneratorTestCase


1 /*
2  * Copyright 2002-2004 The Apache Software Foundation
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12  * implied.
13  *
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17 package org.apache.avalon.excalibur.component.test;
18
19 import junit.framework.TestCase;
20
21 import org.apache.avalon.excalibur.component.ComponentProxyGenerator;
22 import org.apache.avalon.framework.component.Component;
23
24 /**
25  * Create a Component proxy. Requires JDK 1.3+
26  *
27  * @deprecated ECM is no longer supported
28  *
29  * @author <a HREF="mailto:dev@avalon.apache.org">Avalon Development Team</a>
30  */

31 public final class ComponentProxyGeneratorTestCase
32     extends TestCase
33 {
34     public ComponentProxyGeneratorTestCase( String JavaDoc name )
35     {
36         super( name );
37     }
38
39     public void testGenerateComponent()
40         throws Exception JavaDoc
41     {
42         Integer JavaDoc testInt = new Integer JavaDoc( 7 );
43         ComponentProxyGenerator proxyGen = new ComponentProxyGenerator();
44
45         final Component component =
46             proxyGen.getProxy( "java.lang.Comparable", testInt );
47         assertTrue( component != null );
48         assertTrue( component instanceof Comparable JavaDoc );
49
50         Comparable JavaDoc comp = (Comparable JavaDoc)component;
51         assertEquals( 0, comp.compareTo( testInt ) );
52
53         /* Please note one important limitation of using the Proxy on final
54          * classes like Integer. I cannot create a proxy on Integer, but I
55          * can on interfaces it implements like Comparable. I can safely
56          * compare the proxied class against the original Integer, but I
57          * cannot compare the original Integer against the proxied class.
58          * there ends up a class cast exception within the Integer.compareTo
59          * method.
60          */

61     }
62 }
63
Popular Tags