1 4 package org.oddjob.monitor.action; 5 6 import junit.framework.TestCase; 7 8 import org.apache.commons.beanutils.BeanUtilsBean; 9 import org.oddjob.arooa.ArooaConstants; 10 import org.oddjob.arooa.ArooaContext; 11 import org.oddjob.arooa.SimpleObjectFactory; 12 import org.oddjob.designer.model.DesignDefinition; 13 import org.oddjob.designer.view.DummyView; 14 import org.oddjob.designer.view.DummyViewFactory; 15 import org.oddjob.monitor.model.ExplorerContext; 16 import org.oddjob.monitor.model.ExplorerModel; 17 18 public class SetPropertyActionTest extends TestCase { 19 21 public static class Component { 22 String fruit; 23 public void setFruit(String fruit) { 24 this.fruit = fruit; 25 } 26 } 27 28 public void testSetProperty() throws Exception { 29 Component component = new Component(); 30 31 SimpleObjectFactory factory = new SimpleObjectFactory(); 32 factory.addResource("/org/oddjob/values/types.properties"); 33 34 ArooaContext arooaContext = new ArooaContext(); 35 arooaContext.set(ArooaConstants.VALUE_FACTORY, factory); 36 arooaContext.set(ArooaConstants.BEAN_UTILS_BEAN, BeanUtilsBean.getInstance()); 37 ExplorerModel explorerModel = new ExplorerModel(); 38 explorerModel.setRoot(component); 39 explorerModel.setArooaContext(arooaContext); 40 ExplorerContext ec = new ExplorerContext(explorerModel); 41 42 SetPropertyAction test = new SetPropertyAction(); 43 assertFalse(test.enabled()); 44 45 test.select(component, ec); 46 47 assertTrue(test.enabled()); 48 49 DesignDefinition dd = test.form(); 50 51 DummyView dv = DummyViewFactory.create(dd); 52 53 dv.get("Name").attribute("fruit"); 54 dv.get("Name").attribute("fruit"); 55 dv.get("Type").create("value"); 56 dv.get("Type").get("Text").attribute("apples"); 57 58 test.action(); 59 60 assertEquals("apples", component.fruit); 61 } 62 63 } 64 | Popular Tags |