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 17 public class SpanConfigSupportTest extends TestCase { 18 19 23 public SpanConfigSupportTest(String arg0) { 24 super(arg0); 25 } 26 27 public static void main(String [] args) { 28 junit.textui.TestRunner.run(SpanConfigSupportTest.class); 29 } 30 31 static class X implements Displayable { 32 public String getLabel() { return this.toString(); } 33 public void accept(Visitor visitor) { 34 throw new UnsupportedOperationException (); 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 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 |