From: <ke...@us...> - 2003-03-30 00:09:52
|
Update of /cvsroot/webmacro/webmacro/test/unit/org/webmacro/template In directory sc8-pr-cvs1:/tmp/cvs-serv6584 Modified Files: TestGetSet.java Log Message: Added testBinaryMutator() to test the various binary accessor/mutator combinations. Index: TestGetSet.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/test/unit/org/webmacro/template/TestGetSet.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TestGetSet.java 23 Mar 2003 02:00:40 -0000 1.3 --- TestGetSet.java 30 Mar 2003 00:09:45 -0000 1.4 *************** *** 44,47 **** --- 44,62 ---- return objArray; } + + private java.util.HashMap myProps = new java.util.HashMap(); + + public Object getMyProp(String name){ + return myProps.get(name); + } + + public void setMyProp(String name, Object val){ + myProps.put(name, val); + } + + public java.util.Map getProps(){ + return myProps; + } + } *************** *** 117,120 **** --- 132,148 ---- assertStringTemplateEquals("$TestObject2.setObjectValue($foo)", ""); assertTrue(to2.obj == null); + } + + /** test the binary accessor/mutator syntax */ + public void testBinaryMutator() throws Exception { + String tmpl = "#set $TestObject.ObjectValue='foo'"; + assertStringTemplateEquals(tmpl, ""); + assertTrue(to.obj.equals("foo")); + + tmpl = "#set $TestObject.MyProp.Foo='Bar'\n$TestObject.MyProp.Foo"; + assertStringTemplateEquals(tmpl, "Bar"); + + tmpl = "#set $TestObject.Props.MyProp=123\n$TestObject.Props.MyProp"; + assertStringTemplateEquals(tmpl, "123"); } |