KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tonbeller > jpivot > mondrian > EmptyResultTest


1 package com.tonbeller.jpivot.mondrian;
2
3 import java.util.List JavaDoc;
4
5 import junit.framework.TestCase;
6
7 import com.tonbeller.jpivot.olap.model.Axis;
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 public class EmptyResultTest extends TestCase {
13
14   /**
15    * Constructor
16    * @param arg0
17    */

18   public EmptyResultTest(String JavaDoc arg0) {
19     super(arg0);
20   }
21
22   public void testEmptyResult() throws Exception JavaDoc {
23
24     /*
25      select {[Measures].[Unit Sales], [Measures].[Store Cost]} ON columns,
26      Filter([Product].[Brand Name].Members, ([Measures].[Unit Sales] > 100000.0)) ON rows
27      from [Sales] where [Time].[1997]
28      */

29     String JavaDoc mdxQuery = "select NON EMPTY {[Measures].[Unit Sales], [Measures].[Store Cost]} ON columns, "
30         + "NON EMPTY Filter([Product].[Brand Name].Members, ([Measures].[Unit Sales] > 100000.0)) ON rows "
31         + "from [Sales] where [Time].[1997]";
32
33     String JavaDoc renderFile = null; //"c:\\x\\testEmptyResult";
34
int renderNum = 0;
35
36     Result result;
37
38     MondrianModel model = MondrianModelFactory.instance();
39     model.setMdxQuery(mdxQuery);
40     TestConnection.initModel(model);
41
42     // first step
43
result = model.getResult();
44     if (renderFile != null)
45       ResultBase.renderHtml(result, model.getCurrentMdx(), renderFile + renderNum++ + ".html");
46     Axis[] axes = result.getAxes();
47     List JavaDoc positions = axes[0].getPositions();
48     assertEquals(positions.size(), 0);
49     positions = axes[1].getPositions();
50     assertEquals(positions.size(), 0);
51   }
52
53 } // EmptyResult
54
Popular Tags