1 /***
2 * AvgOperator.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 net.sf.jec.BooleanOperator;
13 import net.sf.jec.ConstantOperator;
14 import net.sf.jec.EvaluationException;
15
16 import junit.framework.TestCase;
17
18 /***
19 * @author mballesteros
20 */
21 public class BooleanOperatorTest extends TestCase {
22
23 /***
24 * Constructor for BooleanOperatorTest.
25 * @param arg0
26 */
27 public BooleanOperatorTest(String arg0) {
28 super(arg0);
29 }
30
31 private HashMap ctx;
32 private Book book;
33
34 /*
35 * @see TestCase#setUp()
36 */
37 protected void setUp() throws Exception {
38 super.setUp();
39 book = Book.getExample();
40 ctx = new HashMap();
41 ctx.put("book", book);
42 ctx.put("intIndex", "0");
43 ctx.put("strIndex", "1");
44 }
45
46
47 public void testApply() throws EvaluationException {
48 ConstantOperator i10 = new ConstantOperator(new Integer(10));
49 ConstantOperator i10bis = new ConstantOperator(new Integer(10));
50 ConstantOperator i1 = new ConstantOperator(new Integer(1));
51 ConstantOperator aaa = new ConstantOperator("aaa");
52 ConstantOperator aaaa = new ConstantOperator("aaaa");
53 ConstantOperator aaab = new ConstantOperator("aaab");
54
55 BooleanOperator boolOp;
56
57 // Probando '=='
58 boolOp = new BooleanOperator("==", i10, i10bis, false);
59 assertEquals(boolOp.apply(ctx, ctx), Boolean.TRUE);
60 boolOp = new BooleanOperator("==", i10, i1, false);
61 assertEquals(boolOp.apply(ctx, ctx), Boolean.FALSE);
62
63 // Probando '!='
64 boolOp = new BooleanOperator("!=", i10, i1, false);
65 assertEquals(boolOp.apply(ctx, ctx), Boolean.TRUE);
66 boolOp = new BooleanOperator("!=", i10, i10bis, false);
67 assertEquals(boolOp.apply(ctx, ctx), Boolean.FALSE);
68
69 // Probando '<'
70 boolOp = new BooleanOperator("<", i1, i10, false);
71 assertEquals(boolOp.apply(ctx, ctx), Boolean.TRUE);
72 boolOp = new BooleanOperator("<", i10, i10bis, false);
73 assertEquals(boolOp.apply(ctx, ctx), Boolean.FALSE);
74 boolOp = new BooleanOperator("<", aaa, aaaa, false);
75 assertEquals(boolOp.apply(ctx, ctx), Boolean.TRUE);
76 boolOp = new BooleanOperator("<", aaab, aaa, false);
77 assertEquals(boolOp.apply(ctx, ctx), Boolean.FALSE);
78
79 // Probando '>'
80 boolOp = new BooleanOperator(">", i10, i1, false);
81 assertEquals(boolOp.apply(ctx, ctx), Boolean.TRUE);
82 boolOp = new BooleanOperator(">", i10, i10bis, false);
83 assertEquals(boolOp.apply(ctx, ctx), Boolean.FALSE);
84 }
85 }
This page was automatically generated by Maven