1 /*** 2 * MethodOperatorTest.java 3 * 4 * $Author: mballesteros $ 5 * $Date: 2003/11/28 19:18:03 $ 6 * $Revision: 1.1 $ 7 */ 8 package net.sf.jec; 9 10 import java.util.HashMap; 11 12 import junit.framework.TestCase; 13 14 /*** 15 * @author Mike 16 */ 17 public class MethodOperatorTest extends TestCase { 18 19 /*** 20 * Constructor for AccessorOperatorTest. 21 * @param arg0 22 */ 23 public MethodOperatorTest(String arg0) { 24 super(arg0); 25 } 26 27 private HashMap ctx; 28 private ExtendedBook book; 29 30 /* 31 * @see TestCase#setUp() 32 */ 33 protected void setUp() throws Exception { 34 super.setUp(); 35 book = ExtendedBook.getExtendedExample(); 36 book.setValue(10.0d); 37 ctx = new HashMap(); 38 ctx.put("book", book); 39 ctx.put("intIndex", "0"); 40 ctx.put("strIndex", "1"); 41 } 42 43 public void testApply() throws EvaluationException { 44 MethodOperator op; 45 46 // Probamos un setter de Double 47 op = new MethodOperator("setValue"); 48 op.setArgumentOperators( 49 new Operator[] { new ConstantOperator(new Double(20.0d))}); 50 assertEquals(null, op.apply(ctx, book)); 51 52 // Probamos un getter de Double 53 op = new MethodOperator("getValue"); 54 assertEquals(new Double(20.0d), op.apply(ctx, book)); 55 56 // Probamos un add de Pagina 57 op = new MethodOperator("addPage"); 58 op.setArgumentOperators( 59 new Operator[] { new ConstantOperator(new Integer(1)), 60 new MethodOperator("getFirstPage")}); 61 op.apply(book, book); 62 assertEquals(book.getFirstPage(), book.getPages().get(1)); 63 } 64 }

This page was automatically generated by Maven