1 16 17 package org.apache.commons.betwixt.expression; 18 19 import java.lang.reflect.Method ; 20 21 import junit.framework.Test; 22 import junit.framework.TestSuite; 23 24 import org.apache.commons.betwixt.AbstractTestCase; 25 26 31 public class TestUpdaters extends AbstractTestCase { 32 33 public static Test suite() { 34 return new TestSuite(TestUpdaters.class); 35 } 36 37 public TestUpdaters(String testName) { 38 super(testName); 39 } 40 41 public void testMapUpdate() throws Exception { 42 Class [] params = { String .class, String .class } ; 43 Method method = AdderBean.class.getMethod("add", params); 44 MapEntryAdder adder = new MapEntryAdder(method); 45 46 AdderBean bean = new AdderBean(); 47 bean.add("UNSET", "UNSET"); 48 49 Updater keyUpdater = adder.getKeyUpdater(); 50 Updater valueUpdater = adder.getValueUpdater(); 51 52 Context context = new Context(); 53 context.setBean(bean); 54 55 keyUpdater.update(context, "key"); 56 valueUpdater.update(context, "value"); 57 58 assertEquals("AdderBean not updated (1)", "key", bean.getKey()); 59 assertEquals("AdderBean not updated (2)", "value", bean.getValue()); 60 61 keyUpdater.update(context, "new-key"); 62 valueUpdater.update(context, "new-value"); 63 64 assertEquals("AdderBean not updated (1)", "new-key", bean.getKey()); 65 assertEquals("AdderBean not updated (2)", "new-value", bean.getValue()); 66 67 } 68 } 69 70 | Popular Tags |