Skip to content

Commit

Permalink
MONDRIAN: Enable XML/A test. Make the "mondrian.catalogURL" property …
Browse files Browse the repository at this point in the history
…(used by both CmdRunner and XmlaTest) behave a little more like other properties.

[git-p4: depot-paths = "//open/mondrian/": change = 3384]
  • Loading branch information
julianhyde committed Mar 18, 2005
1 parent 5608288 commit 7e7c8a1
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 105 deletions.
77 changes: 40 additions & 37 deletions src/main/mondrian/olap/MondrianProperties.java
Expand Up @@ -80,15 +80,15 @@ public void populate(ServletContext servletContext) {
load(url);
}
} catch (MalformedURLException e) {
LOGGER.error("Mondrian: file '"
+ file.getAbsolutePath()
+ "' could not be loaded ("
+ e
LOGGER.error("Mondrian: file '"
+ file.getAbsolutePath()
+ "' could not be loaded ("
+ e
+ ")");
}
} else if (populateCount == 0 && false) {
LOGGER.warn("Mondrian: Warning: file '"
+ file.getAbsolutePath()
LOGGER.warn("Mondrian: Warning: file '"
+ file.getAbsolutePath()
+ "' not found");
}

Expand All @@ -102,14 +102,14 @@ public void populate(ServletContext servletContext) {
load(resourceUrl);
}
else if (populateCount == 0 && false) {
LOGGER.warn("Mondrian: Warning: servlet resource '"
+ mondrianDotProperties
LOGGER.warn("Mondrian: Warning: servlet resource '"
+ mondrianDotProperties
+ "' not found");
}
} catch (MalformedURLException e) {
LOGGER.error("Mondrian: '" + mondrianDotProperties
+ "' could not be loaded from servlet context ("
+ e
LOGGER.error("Mondrian: '" + mondrianDotProperties
+ "' could not be loaded from servlet context ("
+ e
+ ")");
}
}
Expand All @@ -125,8 +125,8 @@ else if (populateCount == 0 && false) {
}
}
if (populateCount++ == 0) {
LOGGER.info("Mondrian: loaded "
+ count
LOGGER.info("Mondrian: loaded "
+ count
+ " system properties");
}
}
Expand All @@ -137,16 +137,16 @@ private void load(final URL url) {
try {
load(url.openStream());
if (populateCount == 0) {
LOGGER.info("Mondrian: properties loaded from '"
+ url
LOGGER.info("Mondrian: properties loaded from '"
+ url
+ "'");
}
} catch (IOException e) {
LOGGER.error("Mondrian: error while loading properties "
+ "from '"
+ url
+ "' ("
+ e
LOGGER.error("Mondrian: error while loading properties "
+ "from '"
+ url
+ "' ("
+ e
+ ")");
}
}
Expand Down Expand Up @@ -179,10 +179,10 @@ public String getJdbcDrivers() {
/** Property {@value}. */
public static final String JdbcDrivers = "mondrian.jdbcDrivers";
/** Values is {@value}. */
public static final String JdbcDrivers_Default =
"sun.jdbc.odbc.JdbcOdbcDriver,"
+ "org.hsqldb.jdbcDriver,"
+ "oracle.jdbc.OracleDriver,"
public static final String JdbcDrivers_Default =
"sun.jdbc.odbc.JdbcOdbcDriver,"
+ "org.hsqldb.jdbcDriver,"
+ "oracle.jdbc.OracleDriver,"
+ "com.mysql.jdbc.Driver";

/** Retrieves the value of the {@link #ResultLimit} property. */
Expand All @@ -209,15 +209,15 @@ public boolean getPrintCacheablesAfterQuery() {
return getBooleanProperty(PrintCacheablesAfterQuery);
}
/** Property {@value}. */
public static final String PrintCacheablesAfterQuery =
public static final String PrintCacheablesAfterQuery =
"mondrian.rolap.RolapResult.printCacheables";

/** Retrieves the value of the {@link #FlushAfterQuery} property. */
public boolean getFlushAfterQuery() {
return getBooleanProperty(FlushAfterQuery);
}
/** Property {@value}. */
public static final String FlushAfterQuery =
public static final String FlushAfterQuery =
"mondrian.rolap.RolapResult.flushAfterEachQuery";

// mondrian.test properties
Expand Down Expand Up @@ -255,7 +255,7 @@ public String getTestConnectString() {
return getProperty(TestConnectString);
}
/** Property {@value} */
public static final String TestConnectString =
public static final String TestConnectString =
"mondrian.test.connectString";


Expand Down Expand Up @@ -284,7 +284,7 @@ public int getLargeDimensionThreshold() {
return getIntProperty(LargeDimensionThreshold, LargeDimensionThreshold_Default);
}
/** Property {@value}. */
public static final String LargeDimensionThreshold =
public static final String LargeDimensionThreshold =
"mondrian.rolap.LargeDimensionThreshold";
/** Value is {@value}. */
public static final int LargeDimensionThreshold_Default = 100;
Expand Down Expand Up @@ -316,7 +316,7 @@ public int getSparseSegmentCountThreshold() {
return getIntProperty(SparseSegmentCountThreshold, SparseSegmentCountThreshold_Default);
}
/** Property {@value}. */
public static final String SparseSegmentCountThreshold =
public static final String SparseSegmentCountThreshold =
"mondrian.rolap.SparseSegmentValueThreshold";
/** Value is {@value}. */
public static final int SparseSegmentCountThreshold_Default = 1000;
Expand All @@ -327,18 +327,18 @@ public double getSparseSegmentDensityThreshold() {
return getDoubleProperty(SparseSegmentDensityThreshold, SparseSegmentDensityThreshold_Default);
}
/** Property {@value}. */
public static final String SparseSegmentDensityThreshold =
public static final String SparseSegmentDensityThreshold =
"mondrian.rolap.SparseSegmentDensityThreshold";
/** Value is {@value}. */
public static final double SparseSegmentDensityThreshold_Default = 0.5;

public static final String QueryFilePattern =
public static final String QueryFilePattern =
"mondrian.test.QueryFilePattern";
public String getQueryFilePattern() {
return getProperty(QueryFilePattern);
}

public static final String QueryFileDirectory =
public static final String QueryFileDirectory =
"mondrian.test.QueryFileDirectory";
public String getQueryFileDirectory() {
return getProperty(QueryFileDirectory);
Expand Down Expand Up @@ -370,13 +370,16 @@ public boolean getWarmup() {
}

/**
* Retrieves the URL of the catalog to be used by CmdRunner.
*
* <p>The value always comes from {@link System#props}, but the property is
* declared in the {@link MondrianProperties} class for uniformity.
* Retrieves the URL of the catalog to be used by CmdRunner and XML/A Test.
*/
public String getCatalogURL() {
return System.getProperty(CatalogUrl);
return getProperty("mondrian.catalogURL");
}
/**
* Sets the catalog URL. Writes to {@link System#getProperties()}.
*/
public void setCatalogURL() {

}
/** Property {@value}. */
public static final String CatalogUrl = "mondrian.catalogURL";
Expand Down
13 changes: 2 additions & 11 deletions src/main/mondrian/tui/CmdRunner.java
Expand Up @@ -111,11 +111,7 @@ public static void listPropertiesAll(StringBuffer buf) {
}

private static String getPropertyValue(String propertyName) {
if (propertyName.equals(MondrianProperties.CatalogUrl)) {
return System.getProperty(MondrianProperties.CatalogUrl);
} else {
return MondrianProperties.instance().getProperty(propertyName);
}
return MondrianProperties.instance().getProperty(propertyName);
}

public static void listProperty(String propertyName, StringBuffer buf) {
Expand All @@ -134,11 +130,7 @@ public static boolean isProperty(String propertyName) {
public static boolean setProperty(String name, String value) {
String oldValue = getPropertyValue(name);
if (! Util.equals(oldValue, value)) {
if (name.equals(MondrianProperties.CatalogUrl)) {
System.setProperty(MondrianProperties.CatalogUrl, value);
} else {
MondrianProperties.instance().setProperty(name, value);
}
MondrianProperties.instance().setProperty(name, value);
return true;
} else {
return false;
Expand Down Expand Up @@ -1037,7 +1029,6 @@ protected String executeFunc(String mdxCmd) {
} else if (tokens.length == 2) {
String funcname = tokens[1];
List funInfoList = FunTable.instance().getFunInfoList();
Category cat = Category.instance();
List matches = new ArrayList();

Iterator it = funInfoList.iterator();
Expand Down
2 changes: 1 addition & 1 deletion testsrc/main/mondrian/test/Main.java
Expand Up @@ -127,7 +127,7 @@ public static Test suite() throws Exception {
suite.addTestSuite(AccessControlTest.class);
suite.addTestSuite(ParserTest.class);
suite.addTestSuite(ParentChildHierarchyTest.class);
if (false) suite.addTestSuite(XmlaTest.class);
suite.addTestSuite(XmlaTest.class);
if (isRunOnce()) suite.addTestSuite(TestCalculatedMembers.class);
suite.addTestSuite(RaggedHierarchyTest.class);
}
Expand Down
80 changes: 24 additions & 56 deletions testsrc/main/mondrian/xmla/XmlaTest.java
Expand Up @@ -14,10 +14,15 @@
import junit.framework.TestCase;

import java.io.StringWriter;
import java.io.File;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.regex.Pattern;
import java.net.URL;

import mondrian.olap.MondrianProperties;
import mondrian.olap.Util;

/**
* Unit test for Mondrian's XML for Analysis API (package
Expand All @@ -29,8 +34,6 @@
**/
public class XmlaTest extends TestCase {
private static final String nl = System.getProperty("line.separator");
//private static final String dataSource = "Provider=MSOLAP;Data Source=local;";
private static final String FOODMART_CATALOG_URL = "mondrian.test.foodmart.catalogURL";
private static String catalogName;
private static String dataSource;

Expand All @@ -42,12 +45,23 @@ public class XmlaTest extends TestCase {

public XmlaTest(String s) {
super(s);
if( System.getProperty(FOODMART_CATALOG_URL) != null )
catalogName = System.getProperty(FOODMART_CATALOG_URL);
else
catalogName = "file:/E:/mondrian/demo/FoodMart.xml";
dataSource = "Provider=Mondrian;Jdbc=jdbc:odbc:MondrianFoodMart;Catalog=" + catalogName + ";JdbcDrivers=sun.jdbc.odbc.JdbcOdbcDriver;";
}

protected void setUp() throws Exception {
super.setUp();

catalogName = MondrianProperties.instance().getCatalogURL();
if (catalogName == null) {
final File file = new File("demo/FoodMart.xml");
if (!file.exists()) {
throw new RuntimeException("CatalogURL must be specified");
}
final URL url = Util.toURL(file);
catalogName = url.toString();
}
dataSource =
"Provider=Mondrian;Jdbc=jdbc:odbc:MondrianFoodMart;Catalog=" +
catalogName + ";JdbcDrivers=sun.jdbc.odbc.JdbcOdbcDriver;";
}

/**
Expand Down Expand Up @@ -204,7 +218,7 @@ public void testDiscoverCatalogs() {
}

public void testDiscoverCubes() {
assertRequestYields(wrap(
assertRequestMatches(wrap(
"<Discover xmlns=\"urn:schemas-microsoft-com:xml-analysis\"" + nl +
" SOAP-ENV:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">" + nl +
" <RequestType>MDSCHEMA_CUBES</RequestType>" + nl +
Expand All @@ -222,13 +236,7 @@ public void testDiscoverCubes() {
" </Properties>" + nl +
"</Discover>"),

"<?xml version=\"1.0\"?>" + nl +
"<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" SOAP-ENV:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">" + nl +
" <SOAP-ENV:Body>" + nl +
" <DiscoverResponse xmlns=\"urn:schemas-microsoft-com:xml-analysis\">" + nl +
" <return>" + nl +
" <root xmlns=\"urn:schemas-microsoft-com:xml-analysis:rowset\">" + nl +
" <xsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"/>" + nl +
"(?s).*" + nl +
" <row>" + nl +
" <CATALOG_NAME>" + catalogName + "</CATALOG_NAME>" + nl +
" <SCHEMA_NAME>FoodMart</SCHEMA_NAME>" + nl +
Expand All @@ -238,47 +246,7 @@ public void testDiscoverCubes() {
" <IS_LINKABLE>false</IS_LINKABLE>" + nl +
" <IS_SQL_ALLOWED>false</IS_SQL_ALLOWED>" + nl +
" </row>" + nl +
" <row>" + nl +
" <CATALOG_NAME>" + catalogName + "</CATALOG_NAME>" + nl +
" <SCHEMA_NAME>FoodMart</SCHEMA_NAME>" + nl +
" <CUBE_NAME>Warehouse and Sales</CUBE_NAME>" + nl +
" <IS_DRILLTHROUGH_ENABLED>true</IS_DRILLTHROUGH_ENABLED>" + nl +
" <IS_WRITE_ENABLED>false</IS_WRITE_ENABLED>" + nl +
" <IS_LINKABLE>false</IS_LINKABLE>" + nl +
" <IS_SQL_ALLOWED>false</IS_SQL_ALLOWED>" + nl +
" </row>" + nl +
" <row>" + nl +
" <CATALOG_NAME>" + catalogName + "</CATALOG_NAME>" + nl +
" <SCHEMA_NAME>FoodMart</SCHEMA_NAME>" + nl +
" <CUBE_NAME>Sales</CUBE_NAME>" + nl +
" <IS_DRILLTHROUGH_ENABLED>true</IS_DRILLTHROUGH_ENABLED>" + nl +
" <IS_WRITE_ENABLED>false</IS_WRITE_ENABLED>" + nl +
" <IS_LINKABLE>false</IS_LINKABLE>" + nl +
" <IS_SQL_ALLOWED>false</IS_SQL_ALLOWED>" + nl +
" </row>" + nl +
" <row>" + nl +
" <CATALOG_NAME>" + catalogName + "</CATALOG_NAME>" + nl +
" <SCHEMA_NAME>FoodMart</SCHEMA_NAME>" + nl +
" <CUBE_NAME>HR</CUBE_NAME>" + nl +
" <IS_DRILLTHROUGH_ENABLED>true</IS_DRILLTHROUGH_ENABLED>" + nl +
" <IS_WRITE_ENABLED>false</IS_WRITE_ENABLED>" + nl +
" <IS_LINKABLE>false</IS_LINKABLE>" + nl +
" <IS_SQL_ALLOWED>false</IS_SQL_ALLOWED>" + nl +
" </row>" + nl +
" <row>" + nl +
" <CATALOG_NAME>" + catalogName + "</CATALOG_NAME>" + nl +
" <SCHEMA_NAME>FoodMart</SCHEMA_NAME>" + nl +
" <CUBE_NAME>Warehouse</CUBE_NAME>" + nl +
" <IS_DRILLTHROUGH_ENABLED>true</IS_DRILLTHROUGH_ENABLED>" + nl +
" <IS_WRITE_ENABLED>false</IS_WRITE_ENABLED>" + nl +
" <IS_LINKABLE>false</IS_LINKABLE>" + nl +
" <IS_SQL_ALLOWED>false</IS_SQL_ALLOWED>" + nl +
" </row>" + nl +
" </root>" + nl +
" </return>" + nl +
" </DiscoverResponse>" + nl +
" </SOAP-ENV:Body>" + nl +
"</SOAP-ENV:Envelope>");
".*");
}

public void testDiscoverCubesRestricted() {
Expand Down

0 comments on commit 7e7c8a1

Please sign in to comment.