KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > oddjob > arooa > PropertyProxyResolverTest


1 /*
2  * (c) Rob Gordon 2005
3  */

4 package org.oddjob.arooa;
5
6 import java.util.Properties JavaDoc;
7
8 import junit.framework.TestCase;
9
10 /**
11  *
12  */

13 public class PropertyProxyResolverTest extends TestCase {
14
15     class TestType {
16         int i;
17         public void setI(int i) {
18             this.i = i;
19         }
20     }
21     
22     public static class TestTypeProxy {
23         public Object JavaDoc valueFor(Class JavaDoc required) {
24             if (required.isAssignableFrom(String JavaDoc.class)) {
25                 return "test";
26             }
27             throw new ClassCastException JavaDoc("Can't convert!");
28         }
29     }
30     
31     PropertyProxyResolver test = new PropertyProxyResolver();
32     
33     protected void setUp() {
34         Properties JavaDoc props = new Properties JavaDoc();
35         props.put(TestType.class.getName(), TestTypeProxy.class.getName());
36         test.addProperties(props);
37     }
38         
39     public void testProxyFor() {
40         TestTypeProxy p = (TestTypeProxy) test.proxyFor(this, "fred");
41         assertNotNull("proxy for in", p);
42     }
43     
44     public void setFred(TestType tt) {}
45 }
Popular Tags