KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tonbeller > jpivot > table > span > SpanConfigSupportTest


1 package com.tonbeller.jpivot.table.span;
2
3 import junit.framework.TestCase;
4
5 import com.tonbeller.jpivot.olap.model.Displayable;
6 import com.tonbeller.jpivot.olap.model.Level;
7 import com.tonbeller.jpivot.olap.model.Member;
8 import com.tonbeller.jpivot.olap.model.Visitor;
9 import com.tonbeller.jpivot.test.olap.TestLevel;
10 import com.tonbeller.jpivot.test.olap.TestMember;
11
12 /**
13  * Created on 29.10.2002
14  *
15  * @author av
16  */

17 public class SpanConfigSupportTest extends TestCase {
18
19   /**
20    * Constructor for SpanConfigSupportTest.
21    * @param arg0
22    */

23   public SpanConfigSupportTest(String JavaDoc arg0) {
24     super(arg0);
25   }
26
27   public static void main(String JavaDoc[] args) {
28     junit.textui.TestRunner.run(SpanConfigSupportTest.class);
29   }
30
31   static class X implements Displayable {
32     public String JavaDoc getLabel() { return this.toString(); }
33     public void accept(Visitor visitor) {
34       throw new UnsupportedOperationException JavaDoc();
35     }
36   }
37   
38   public void testChooseSpanDirection() {
39     SpanConfigSupport scs = new SpanConfigSupport();
40     scs.setDefaultDirection(100);
41     scs.setDirection(Member.class, 200);
42     scs.setDirection(Level.class, 300);
43     
44     check(scs, 100, new X());
45     check(scs, 200, new TestMember());
46     check(scs, 300, new TestLevel());
47     
48   }
49
50   public void testOrder() {
51     SpanConfigSupport scs = new SpanConfigSupport();
52     scs.setDefaultDirection(100);
53     scs.setDirection(Member.class, 200);
54     scs.setDirection(Displayable.class, 300);
55     // level is invisible, because Displayable will match
56
scs.setDirection(Level.class, 400);
57     
58     check(scs, 200, new TestMember());
59     check(scs, 300, new TestLevel());
60     
61   }
62   
63   void check(SpanConfig sc, int dir, Displayable o) {
64     Span s = new Span(null, null, o);
65     assertEquals(dir, sc.chooseSpanDirection(s));
66   }
67
68 }
69
Popular Tags