1 package org.oddjob.arooa; 2 3 import org.oddjob.arooa.reflect.IntrospectionHelper; 4 5 import junit.framework.TestCase; 6 7 8 11 public class ArooaFactoryTest extends TestCase { 12 13 public void test1() { 14 assertNotNull(new ArooaFactory().build("<foo class='java.lang.Object'/>")); 15 } 16 17 public void testFullLoad() throws ArooaException { 18 SimpleObjectFactory factory = new SimpleObjectFactory(); 19 factory.set("fred", FredComp.class.getName()); 20 PropertyProxyResolver dtm = new PropertyProxyResolver(); 21 dtm.setProxy(TextThing.class.getName(), TextThing.class.getName()); 22 23 ArooaFactory af = new ArooaFactory(); 24 af.setComponentFactory(factory); 25 af.setPropertProxyResolver(dtm); 26 27 IntrospectionHelper.getHelper(FredComp.class).dump(System.out); 28 FredComp f = (FredComp) af.build( 29 getClass().getResourceAsStream("arooa-factory-test.xml")); 30 31 assertNotNull(f); 32 assertEquals("some text", f.te.getText()); 33 assertEquals("more text", f.ip.getText()); 34 } 35 36 public static class TextThing { 37 StringBuffer text = new StringBuffer (); 38 public void addText(String text) { 39 this.text.append(text); 40 } 41 String getText() { 42 return text.toString().trim(); 43 } 44 } 45 46 public static class FredComp { 47 TextThing te; 48 TextThing ip; 49 FredComp f; 50 public void addTextElement(TextThing t) { 51 te = t; 52 } 53 54 public void setInlineProp(TextThing t) { 55 ip = t; 56 } 57 public void addComponentChild(FredComp f) { 58 this.f = f; 59 } 60 } 61 } 62 | Popular Tags |