1 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 ; 29 import java.util.List ; 30 31 32 38 public class TestXmlaDiscover extends TestCase { 39 private static Logger logger = Logger.getLogger(TestXmlaDiscover.class); 40 private XMLA_SOAP olap; 41 42 46 public TestXmlaDiscover(String arg0) { 47 super(arg0); 48 } 49 50 53 protected void setUp() throws Exception { 54 super.setUp(); 55 Util.setupLog4j(); 56 57 long start = System.currentTimeMillis(); 58 59 String 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 olapItems) { 66 Iterator 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 getFirstOlapItemLabel(List items) throws OlapException { 75 return ((OlapItem) items.iterator().next()).getLabel(); 76 } 77 78 public void testDiscoverCatalogs() throws OlapException { 79 List catalogs = this.olap.discoverCat(); 80 logger.debug("discovered catalogs: " + catalogs.size()); 81 logOlapItemList(catalogs); 82 83 87 } 88 89 public void testDiscoverCube() throws OlapException { 90 String firstCatalog = getFirstOlapItemLabel(this.olap.discoverCat()); 91 logger.debug("cubes: "); 92 logOlapItemList(olap.discoverCube(firstCatalog)); 93 } 94 95 public void testDiscoverDim() throws OlapException { 96 String firstCatalog = getFirstOlapItemLabel(this.olap.discoverCat()); 97 String 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 119 } 120 | Popular Tags |