use of mondrian.olap.Connection in project mondrian by pentaho.
the class SchemaVersionTest method testSchema4withVersion.
public void testSchema4withVersion() {
TestContext testContext = TestContext.instance().withSchema(SCHEMA_4_HEADER + SCHEMA_4_BODY);
Util.PropertyList connectInfo = testContext.getConnectionProperties();
try {
Connection conn = DriverManager.getConnection(connectInfo, null);
conn.close();
Assert.fail("No exception thrown for version 4 schema.");
} catch (MondrianException e) {
assertTrue(e.getMessage().contains("Schema version"));
}
}
use of mondrian.olap.Connection in project mondrian by pentaho.
the class SchemaVersionTest method testSchema3withVersion.
public void testSchema3withVersion() {
TestContext testContext = TestContext.instance().withSchema(SCHEMA_3_VHEADER + SCHEMA_3_BODY);
Util.PropertyList connectInfo = testContext.getConnectionProperties();
Connection conn = DriverManager.getConnection(connectInfo, null);
assertNotNull(conn);
conn.close();
}
use of mondrian.olap.Connection in project mondrian by pentaho.
the class TestContext method assertAxisThrows.
/**
* Executes a query with a given expression on an axis, and asserts that it
* throws an error which matches a particular pattern. The expression is
* evaulated against the default cube.
*/
public void assertAxisThrows(String expression, String pattern) {
Throwable throwable = null;
Connection connection = getConnection();
try {
final String cubeName = getDefaultCubeName();
final String queryString = "select {" + expression + "} on columns from " + cubeName;
Query query = connection.parseQuery(queryString);
connection.execute(query);
} catch (Throwable e) {
throwable = e;
}
checkThrowable(throwable, pattern);
}
use of mondrian.olap.Connection in project mondrian by pentaho.
the class TestContext method assertExprDependsOn.
/**
* Asserts that an MDX expression depends upon a given list of dimensions.
*/
public void assertExprDependsOn(String expr, String hierList) {
// Construct a query, and mine it for a parsed expression.
// Use a fresh connection, because some tests define their own dims.
final Connection connection = getConnection();
final String queryString = "WITH MEMBER [Measures].[Foo] AS " + Util.singleQuoteString(expr) + " SELECT FROM [Sales]";
final Query query = connection.parseQuery(queryString);
query.resolve();
final Formula formula = query.getFormulas()[0];
final Exp expression = formula.getExpression();
// Build a list of the dimensions which the expression depends upon,
// and check that it is as expected.
checkDependsOn(query, expression, hierList, true);
}
use of mondrian.olap.Connection in project mondrian by pentaho.
the class TestContext method assertParameterizedExprReturns.
/**
* Asserts that an expression, with a given set of parameter bindings,
* returns a given result.
*
* @param expr Scalar MDX expression
* @param expected Expected result
* @param paramValues Array of parameter names and values
*/
public void assertParameterizedExprReturns(String expr, String expected, Object... paramValues) {
Connection connection = getConnection();
String queryString = generateExpression(expr);
Query query = connection.parseQuery(queryString);
assert paramValues.length % 2 == 0;
for (int i = 0; i < paramValues.length; ) {
final String paramName = (String) paramValues[i++];
final Object value = paramValues[i++];
query.setParameter(paramName, value);
}
final Result result = connection.execute(query);
final Cell cell = result.getCell(new int[] { 0 });
if (expected == null) {
// null values are formatted as empty string
expected = "";
}
assertEqualsVerbose(expected, cell.getFormattedValue());
}
Aggregations