Skip to content

Commit

Permalink
MONDRIAN
Browse files Browse the repository at this point in the history
       Converted the test to use the TestContext.create method inorder
       to isolate the new cube definition from the other tests.

[git-p4: depot-paths = "//open/mondrian/": change = 7877]
  • Loading branch information
Richard Emberson committed Oct 9, 2006
1 parent 9ac9bc7 commit 0d21677
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
12 changes: 11 additions & 1 deletion testsrc/main/mondrian/rolap/aggmatcher/AggTableTestCase.java
Expand Up @@ -10,6 +10,7 @@
package mondrian.rolap.aggmatcher;

import mondrian.test.loader.CsvDBTestCase;
import mondrian.test.TestContext;
import mondrian.olap.Schema;
import mondrian.olap.Cube;
import mondrian.olap.MondrianProperties;
Expand All @@ -29,6 +30,7 @@ public abstract class AggTableTestCase extends CsvDBTestCase {
private static final String DIRECTORY =
"testsrc/main/mondrian/rolap/aggmatcher";

private TestContext testContext;
private boolean currentUse;
private boolean currentRead;
private boolean do_caching_orig;
Expand All @@ -44,9 +46,14 @@ protected void setUp() throws Exception {
super.setUp();


/*
Schema schema = getConnection().getSchema();
String cubeDescription = getCubeDescription();
final Cube cube = schema.createCube(cubeDescription);
*/
String cubeDescription = getCubeDescription();
this.testContext = TestContext.create(null,
cubeDescription, null, null, null);


// store current property values
MondrianProperties props = MondrianProperties.instance();
Expand Down Expand Up @@ -86,6 +93,9 @@ protected void tearDown() throws Exception {
super.tearDown();
}

protected TestContext getCubeTestContext() {
return testContext;
}
protected abstract String getCubeDescription();

protected String getDirectoryName() {
Expand Down
16 changes: 8 additions & 8 deletions testsrc/main/mondrian/rolap/aggmatcher/BUG_1541077.java
Expand Up @@ -42,12 +42,12 @@ public void testStoreCount() throws Exception {
props.UseAggregates.setString("false");

String mdx = "select {[Measures].[Store Count]} on columns from Cheques";
Result result = TestContext.instance().executeQuery(mdx);
Result result = getCubeTestContext().executeQuery(mdx);
Object v = result.getCell(new int[]{0}).getValue();

props.UseAggregates.setString("true");

Result result1 = TestContext.instance().executeQuery(mdx);
Result result1 = getCubeTestContext().executeQuery(mdx);
Object v1 = result1.getCell(new int[]{0}).getValue();

assertTrue(v.equals(v1));
Expand All @@ -59,12 +59,12 @@ public void testSalesCount() throws Exception {
props.UseAggregates.setString("false");

String mdx = "select {[Measures].[Sales Count]} on columns from Cheques";
Result result = TestContext.instance().executeQuery(mdx);
Result result = getCubeTestContext().executeQuery(mdx);
Object v = result.getCell(new int[]{0}).getValue();

props.UseAggregates.setString("true");

Result result1 = TestContext.instance().executeQuery(mdx);
Result result1 = getCubeTestContext().executeQuery(mdx);
Object v1 = result1.getCell(new int[]{0}).getValue();

assertTrue(v.equals(v1));
Expand All @@ -76,12 +76,12 @@ public void testTotalAmount() throws Exception {
props.UseAggregates.setString("false");

String mdx = "select {[Measures].[Total Amount]} on columns from Cheques";
Result result = TestContext.instance().executeQuery(mdx);
Result result = getCubeTestContext().executeQuery(mdx);
Object v = result.getCell(new int[]{0}).getValue();

props.UseAggregates.setString("true");

Result result1 = TestContext.instance().executeQuery(mdx);
Result result1 = getCubeTestContext().executeQuery(mdx);
Object v1 = result1.getCell(new int[]{0}).getValue();

assertTrue(v.equals(v1));
Expand All @@ -95,13 +95,13 @@ public void testBug1541077() throws Exception {

String mdx = "select {[Measures].[Avg Amount]} on columns from Cheques";

Result result = TestContext.instance().executeQuery(mdx);
Result result = getCubeTestContext().executeQuery(mdx);
Object v = result.getCell(new int[]{0}).getValue();

// get value with aggregates
props.UseAggregates.setString("true");

Result result1 = TestContext.instance().executeQuery(mdx);
Result result1 = getCubeTestContext().executeQuery(mdx);
Object v1 = result1.getCell(new int[]{0}).getValue();

assertTrue(v.equals(v1));
Expand Down
2 changes: 2 additions & 0 deletions testsrc/main/mondrian/test/Main.java
Expand Up @@ -30,6 +30,7 @@
import mondrian.olap.fun.SortTest;
import mondrian.olap.HierarchyBugTest;
import mondrian.rolap.*;
import mondrian.rolap.aggmatcher.*;
import mondrian.test.comp.ResultComparatorTest;
import mondrian.util.ScheduleTest;
import mondrian.util.FormatTest;
Expand Down Expand Up @@ -182,6 +183,7 @@ public static Test suite() throws Exception {
suite.addTestSuite(ParallelTest.class);
suite.addTestSuite(SchemaTest.class);
suite.addTestSuite(CmdRunnerTest.class);
suite.addTestSuite(BUG_1541077.class);

boolean testNonEmpty = isRunOnce();
if (!MondrianProperties.instance().EnableNativeNonEmpty.get())
Expand Down

0 comments on commit 0d21677

Please sign in to comment.