1 4 package org.oddjob.jmx; 5 6 import junit.framework.TestCase; 7 8 import org.apache.commons.beanutils.PropertyUtils; 9 import org.apache.log4j.Logger; 10 import org.oddjob.Oddjob; 11 import org.oddjob.arooa.reflect.IntrospectionHelper; 12 import org.oddjob.values.VariablesJob; 13 14 18 public class TogetherTest extends TestCase { 19 private static final Logger logger = Logger.getLogger(TogetherTest.class); 20 21 protected void setUp() { 22 logger.debug("================= " + getName() + "=================="); 23 } 24 25 public void test1() { 26 27 Oddjob oj = new Oddjob(); 28 oj.setInput(this.getClass().getResourceAsStream("together1.xml")); 29 oj.run(); 30 31 VariablesJob result = (VariablesJob) oj.lookup("result"); 32 assertNotNull(result); 33 String fruit = (String ) IntrospectionHelper.valueFor(result.get("fruit")); 34 assertNotNull(fruit); 35 assertEquals("apples", fruit); 36 } 37 38 public void test2() throws Exception { 40 Oddjob oj = new Oddjob(); 41 oj.setInput(this.getClass().getResourceAsStream("together2.xml")); 42 oj.run(); 43 44 VariablesJob result = (VariablesJob) oj.lookup("result"); 45 assertNotNull(result); 46 Object o = IntrospectionHelper.valueFor(result.get("echo")); 47 assertEquals("apples", PropertyUtils.getProperty(o, "text")); 48 } 49 50 public void test3() throws Exception { 52 Oddjob oj = new Oddjob(); 53 oj.setInput(this.getClass().getResourceAsStream("together3.xml")); 54 oj.setArgs(0, this.getClass().getResourceAsStream("together3a.xml")); 55 oj.run(); 56 57 VariablesJob result = (VariablesJob) oj.lookup("oj/result"); 58 assertNotNull(result); 59 Object o = IntrospectionHelper.valueFor(result.get("echo")); 60 assertEquals("apples", PropertyUtils.getProperty(o, "text")); 61 } 62 63 public void test4() throws Exception { 65 Oddjob oj = new Oddjob(); 66 oj.setInput(this.getClass().getResourceAsStream("together4.xml")); 67 68 73 oj.run(); 74 75 77 Object test1 = oj.lookup("test1"); 78 assertEquals("oranges", PropertyUtils.getProperty(test1, "text")); 79 80 Object test2 = oj.lookup("test2"); 81 assertEquals("apples", PropertyUtils.getProperty(test2, "text")); 82 } 83 } 84 | Popular Tags |