1 16 17 package org.springframework.beans; 18 19 import java.util.HashMap ; 20 import java.util.Map ; 21 22 import junit.framework.TestCase; 23 24 27 public abstract class AbstractPropertyValuesTests extends TestCase { 28 29 32 protected void doTestTony(PropertyValues pvs) throws Exception { 33 assertTrue("Contains 3", pvs.getPropertyValues().length == 3); 34 assertTrue("Contains forname", pvs.contains("forname")); 35 assertTrue("Contains surname", pvs.contains("surname")); 36 assertTrue("Contains age", pvs.contains("age")); 37 assertTrue("Doesn't contain tory", !pvs.contains("tory")); 38 39 PropertyValue[] ps = pvs.getPropertyValues(); 40 Map m = new HashMap (); 41 m.put("forname", "Tony"); 42 m.put("surname", "Blair"); 43 m.put("age", "50"); 44 for (int i = 0; i < ps.length; i++) { 45 Object val = m.get(ps[i].getName()); 46 assertTrue("Can't have unexpected value", val != null); 47 assertTrue("Val i string", val instanceof String ); 48 assertTrue("val matches expected", val.equals(ps[i].getValue())); 49 m.remove(ps[i].getName()); 50 } 51 assertTrue("Map size is 0", m.size() == 0); 52 } 53 54 } 55 | Popular Tags |