1 /***
2 * AccessorOperatorTest.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 import java.util.Map;
12
13
14 import junit.framework.TestCase;
15
16 /***
17 * @author mballesteros
18 */
19 public class AccessorOperatorTest extends TestCase {
20
21 /***
22 * Constructor for AccessorOperatorTest.
23 * @param arg0
24 */
25 public AccessorOperatorTest(String arg0) {
26 super(arg0);
27 }
28
29 private Map ctx;
30 private Book book;
31
32 /*
33 * @see TestCase#setUp()
34 */
35 protected void setUp() throws Exception {
36 super.setUp();
37 book = Book.getExample();
38 ctx = new HashMap();
39 ctx.put("book", book);
40 ctx.put("intIndex", "0");
41 ctx.put("strIndex", "1");
42 }
43
44 public void testApplyInverse() {
45 }
46
47 public void testMapAccessor() throws EvaluationException {
48 AccessorOperator op = new AccessorOperator("book", false);
49 assertEquals(book, op.apply(ctx, ctx));
50
51 op = new AccessorOperator("newProperty", false);
52 op.applyInverse(ctx, ctx, "newValue");
53 assertEquals("newValue", op.apply(ctx, ctx));
54 }
55
56 public void testBeanAccessor() throws EvaluationException {
57 // Test accessor chaining...
58 AccessorOperator bookAccessor = new AccessorOperator("book", false);
59 AccessorOperator pagesAccessor = new AccessorOperator("pages", bookAccessor, false);
60 assertEquals(book.getPages(), pagesAccessor.apply(ctx, ctx));
61 }
62 }
This page was automatically generated by Maven