KickJava   Java API By Example, From Geeks To Geeks.

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


1 package com.tonbeller.jpivot.xmla;
2
3 import java.net.URL JavaDoc;
4 import java.util.List JavaDoc;
5
6 import junit.framework.TestCase;
7
8 import com.tonbeller.jpivot.core.ModelFactory;
9 import com.tonbeller.jpivot.olap.model.Axis;
10 import com.tonbeller.jpivot.olap.model.Result;
11 import com.tonbeller.jpivot.olap.query.ResultBase;
12
13 public class EmptyResultTest extends TestCase {
14
15   /**
16    * Constructor
17    * @param arg0
18    */

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

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