1 package com.tonbeller.jpivot.mondrian; 2 3 import java.net.URL ; 4 5 import junit.framework.TestCase; 6 7 import com.tonbeller.jpivot.olap.model.Position; 8 import com.tonbeller.jpivot.olap.model.Result; 9 import com.tonbeller.jpivot.olap.query.ResultBase; 10 import com.tonbeller.jpivot.tags.MondrianModelFactory; 11 12 15 public class TimeSchemaTest extends TestCase { 16 17 22 public TimeSchemaTest(String arg0) { 23 super(arg0); 24 } 25 26 31 public void testTimeDimNonTimeLev() throws Exception { 32 33 String mdxQuery = "select {[Measures].[Unit Sales], [Measures].[Store Cost], [Measures].[Store Sales]} on columns, " 34 + "Crossjoin([Time].[Quartale].members, [Customers].[All Customers].[USA].children) on rows " 35 + "from Sales"; 36 37 String renderFile = null; int renderNum = 0; 39 40 Result result; 41 42 MondrianModel model = MondrianModelFactory.instance(); 43 model.setMdxQuery(mdxQuery); 44 45 49 URL url = this.getClass().getResource("TestSchema.xml"); 50 String connectString = TestConnection.getConnectString(url.toExternalForm()); 51 model.setConnectString(connectString); 52 String jdbcDriver = TestConnection.getJdbcDriver(); 53 model.setJdbcDriver(jdbcDriver); 54 model.initialize(); 55 56 result = model.getResult(); 57 if (renderFile != null) 58 ResultBase.renderHtml(result, model.getCurrentMdx(), renderFile + renderNum++ + ".html"); 59 60 } 62 63 66 private void assertPosition(Result result, int iPos, String firstMember, String secondMember) { 67 Position pos = (Position) result.getAxes()[1].getPositions().get(iPos); 68 String s = pos.getMembers()[0].getLabel(); 69 assertEquals(s, firstMember); 70 if (secondMember != null) { 71 s = pos.getMembers()[1].getLabel(); 72 assertEquals(s, secondMember); 73 } 74 } 75 76 } | Popular Tags |