1 package org.sapia.regis.forms; 2 3 import java.util.HashMap ; 4 import java.util.Map ; 5 6 import org.sapia.regis.impl.NodeImpl; 7 import org.sapia.regis.type.BuiltinTypes; 8 9 import junit.framework.TestCase; 10 11 public class FieldTest extends TestCase { 12 13 Field f; 14 15 public FieldTest(String arg0) { 16 super(arg0); 17 } 18 19 protected void setUp() throws Exception { 20 f = new Field(BuiltinTypes.INT_TYPE, "test"); 21 } 22 23 public void testSetString(){ 24 NodeImpl node = new NodeImpl(); 25 f.set(node, "100"); 26 super.assertEquals(f.get(node), new Integer (100)); 27 28 try{ 29 f.set(node, "value"); 30 fail("String value should not have been set"); 31 }catch(NumberFormatException e){} 32 } 33 34 public void testSetInt(){ 35 NodeImpl node = new NodeImpl(); 36 f.set(node, new Integer (100)); 37 super.assertEquals(f.get(node), new Integer (100)); 38 } 39 40 public void testSetFromMap(){ 41 Map values = new HashMap (); 42 values.put("test", "100"); 43 NodeImpl node = new NodeImpl(); 44 f.set(node, values); 45 super.assertEquals(f.get(node), new Integer (100)); 46 } 47 48 49 50 51 52 } 53 | Popular Tags |