KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openi > xmla > TestXmlaDiscover


1 /*********************************************************************************
2  * The contents of this file are subject to the OpenI Public License Version 1.0
3  * ("License"); You may not use this file except in compliance with the
4  * License. You may obtain a copy of the License at
5  * http://www.openi.org/docs/LICENSE.txt
6  *
7  * Software distributed under the License is distributed on an "AS IS" basis,
8  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
9  * the specific language governing rights and limitations under the License.
10  *
11  * The Original Code is: OpenI Open Source
12  *
13  * The Initial Developer of the Original Code is Loyalty Matrix, Inc.
14  * Portions created by Loyalty Matrix, Inc. are
15  * Copyright (C) 2005 Loyalty Matrix, Inc.; All Rights Reserved.
16  *
17  * Contributor(s): ______________________________________.
18  *
19  ********************************************************************************/

20 package org.openi.xmla;
21
22 import com.tonbeller.jpivot.olap.model.OlapException;
23 import com.tonbeller.jpivot.olap.model.OlapItem;
24 import com.tonbeller.jpivot.xmla.XMLA_SOAP;
25 import junit.framework.TestCase;
26 import org.apache.log4j.Logger;
27 import org.openi.test.Util;
28 import java.util.Iterator JavaDoc;
29 import java.util.List JavaDoc;
30
31
32 /**
33  * @author plucas
34  *
35  * TODO To change the template for this generated type comment go to
36  * Window - Preferences - Java - Code Style - Code Templates
37  */

38 public class TestXmlaDiscover extends TestCase {
39     private static Logger logger = Logger.getLogger(TestXmlaDiscover.class);
40     private XMLA_SOAP olap;
41
42     /**
43      * Constructor for TestXmlaDiscover.
44      * @param arg0
45      */

46     public TestXmlaDiscover(String JavaDoc arg0) {
47         super(arg0);
48     }
49
50     /*
51      * @see TestCase#setUp()
52      */

53     protected void setUp() throws Exception JavaDoc {
54         super.setUp();
55         Util.setupLog4j();
56
57         long start = System.currentTimeMillis();
58
59         // String uri = "http://olap02.intelligenceportal.colo/xmla/msxisapi.dll";
60
String JavaDoc uri = "http://moosehead/xmla/msxisapi.dll";
61         logger.debug(uri);
62         this.olap = new XMLA_SOAP(uri, null, null);
63     }
64
65     private void logOlapItemList(List JavaDoc olapItems) {
66         Iterator JavaDoc items = olapItems.iterator();
67
68         while (items.hasNext()) {
69             OlapItem item = (OlapItem) items.next();
70             logger.debug(item.getLabel());
71         }
72     }
73
74     private String JavaDoc getFirstOlapItemLabel(List JavaDoc items) throws OlapException {
75         return ((OlapItem) items.iterator().next()).getLabel();
76     }
77
78     public void testDiscoverCatalogs() throws OlapException {
79         List JavaDoc catalogs = this.olap.discoverCat();
80         logger.debug("discovered catalogs: " + catalogs.size());
81         logOlapItemList(catalogs);
82
83         /*
84            olap.discoverDS()
85            olap.discoverDSProps()
86          */

87     }
88
89     public void testDiscoverCube() throws OlapException {
90         String JavaDoc firstCatalog = getFirstOlapItemLabel(this.olap.discoverCat());
91         logger.debug("cubes: ");
92         logOlapItemList(olap.discoverCube(firstCatalog));
93     }
94
95     public void testDiscoverDim() throws OlapException {
96         String JavaDoc firstCatalog = getFirstOlapItemLabel(this.olap.discoverCat());
97         String JavaDoc firstCube = getFirstOlapItemLabel(this.olap.discoverCube(
98                     firstCatalog));
99         logger.debug("dimensions: ");
100         logOlapItemList(olap.discoverDim(firstCatalog, firstCube));
101     }
102
103     public void testDiscoverDSProps() throws OlapException {
104         logger.debug("DSProps: ");
105         logOlapItemList(this.olap.discoverDSProps());
106     }
107
108     /*
109     public void testDiscoverDS() throws OlapException {
110         logger.debug("datasources: ");
111
112         Iterator datasources = this.olap.discoverDS().iterator();
113
114         while (datasources.hasNext()) {
115             logger.debug(datasources.next());
116         }
117     }
118     */

119 }
120
Popular Tags