| 1 4 package org.oddjob.arooa; 5 6 import java.util.Properties ; 7 8 import junit.framework.TestCase; 9 10 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 valueFor(Class required) { 24 if (required.isAssignableFrom(String .class)) { 25 return "test"; 26 } 27 throw new ClassCastException ("Can't convert!"); 28 } 29 } 30 31 PropertyProxyResolver test = new PropertyProxyResolver(); 32 33 protected void setUp() { 34 Properties props = new Properties (); 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 |