1 4 package org.oddjob.arooa.handlers; 5 6 import java.util.Date ; 7 import java.util.Properties ; 8 9 import junit.framework.TestCase; 10 11 import org.oddjob.arooa.ArooaContext; 12 import org.oddjob.arooa.ArooaConstants; 13 import org.oddjob.arooa.ArooaRuntime; 14 import org.oddjob.arooa.PropertyProxyResolver; 15 import org.oddjob.arooa.SimpleObjectFactory; 16 import org.oddjob.values.types.DateType; 17 import org.xml.sax.SAXParseException ; 18 import org.xml.sax.helpers.AttributesImpl ; 19 20 24 public class NestedPropertyHandlerTest extends TestCase { 25 26 boolean called = false; 27 28 public void testPropertyAdded() throws SAXParseException { 31 ArooaContext context = new ArooaContext(); 32 33 SimpleObjectFactory oFactory = new SimpleObjectFactory(); 34 Properties defs = new Properties (); 35 defs.setProperty("date", DateType.class.getName()); 36 oFactory.addProperties(defs); 37 context.set(ArooaConstants.VALUE_FACTORY, oFactory); 38 39 PropertyProxyResolver vr = new PropertyProxyResolver(); 40 Properties proxies = new Properties (); 41 proxies.setProperty(Date .class.getName(), DateType.class.getName()); 42 vr.addProperties(proxies); 43 44 context.set(ArooaConstants.PROPERTY_PROXY_RESOLVER, vr); 45 46 ArooaRuntime rtc = new ArooaRuntime(this, "test", context); 47 NestedPropertyHandler typeHandler = new NestedPropertyHandler(); 48 context.set(ArooaConstants.CURRENTLY_CONFIGURING, rtc); 49 context.set(ArooaConstants.ELEMENT_NAME, "date"); 50 context = new ArooaContext(context); 51 52 AttributesImpl atts = new AttributesImpl (); 53 atts.addAttribute("", "date", "date", "java.lang.String", "25-dec-05"); 54 atts.addAttribute("", "timeZone", "timeZone", "java.lang.String", "Europe/London"); 55 56 typeHandler.onStartElement("", "date", "date", atts, context); 57 58 rtc.configure(); 59 assertTrue("addValue method called.", called); 60 } 61 62 public void setDate(Date d) { 63 called = true; 64 System.out.println(d); 65 } 66 } 67 | Popular Tags |