01: package jimm.datavision.test;
02:
03: import jimm.datavision.*;
04: import jimm.datavision.field.*;
05: import jimm.datavision.test.mock.source.MockDataSource;
06: import junit.framework.TestCase;
07: import junit.framework.TestSuite;
08: import junit.framework.Test;
09:
10: /**
11: * Tests {@link SuppressionProc}.
12: *
13: * @author Jim Menard, <a href="mailto:jimm@io.com">jimm@io.com</a>
14: */
15: public class SuppressionProcTest extends TestCase {
16:
17: protected SuppressionProc proc;
18: protected Report report;
19:
20: public static Test suite() {
21: return new TestSuite(SuppressionProcTest.class);
22: }
23:
24: public SuppressionProcTest(String name) {
25: super (name);
26: }
27:
28: public void setUp() {
29: report = new Report();
30: proc = new SuppressionProc(report);
31: }
32:
33: public void testBasicStuff() {
34: assertTrue(!proc.isHidden());
35: assertNotNull(proc.getFormula());
36: assertTrue(!proc.suppress());
37: }
38:
39: public void testRefersTo() {
40: assertTrue(!proc.refersTo((Field) null));
41:
42: report.setDataSource(new MockDataSource(report));
43: ColumnField f = (ColumnField) Field.create(null, report, null,
44: "column", "jobs.title", true);
45: assertTrue(!proc.refersTo(f));
46:
47: proc.getFormula().setExpression("{jobs.title}");
48: assertTrue(proc.refersTo(f));
49: }
50:
51: public void testSuppress() {
52: assertTrue(!proc.isHidden());
53: assertTrue(!proc.suppress());
54:
55: proc.setHidden(true);
56: assertTrue(proc.suppress());
57:
58: proc.setHidden(false);
59: assertTrue(!proc.suppress());
60:
61: Formula f = proc.getFormula(); // Forces creation of formula object
62: assertTrue(!proc.suppress());
63:
64: f.setExpression("true");
65: assertTrue(proc.suppress());
66:
67: f.setExpression("false");
68: assertTrue(!proc.suppress());
69:
70: proc.setHidden(true);
71: assertTrue(proc.suppress());
72: }
73:
74: public static void main(String[] args) {
75: junit.textui.TestRunner.run(suite());
76: System.exit(0);
77: }
78:
79: }
|