Skip to content

Commit

Permalink
MONDRIAN: Disable some olap4j TCK tests; they use too much memory.
Browse files Browse the repository at this point in the history
[git-p4: depot-paths = "//open/mondrian-release/3.2/": change = 13971]
  • Loading branch information
julianhyde committed Dec 11, 2010
1 parent ec74fd0 commit 6879c90
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 6 deletions.
35 changes: 31 additions & 4 deletions testsrc/main/mondrian/test/Olap4jTckTest.java
Expand Up @@ -9,8 +9,8 @@
*/
package mondrian.test;

import junit.framework.TestCase;
import junit.framework.TestSuite;
import junit.framework.*;

import mondrian.olap.Util;
import org.olap4j.test.TestContext;

Expand All @@ -25,6 +25,21 @@
* @version $Id$
*/
public class Olap4jTckTest extends TestCase {
private static final Util.Functor1<Boolean, Test> CONDITION =
new Util.Functor1<Boolean, Test>() {
public Boolean apply(Test test) {
if (!(test instanceof TestCase)) {
return true;
}
final TestCase testCase = (TestCase) test;
final String testCaseName = testCase.getName();
return !testCaseName.equals("testStatementTimeout")
&& !testCaseName.equals("testStatementCancel")
&& !testCaseName.equals("testDatabaseMetaDataGetCatalogs")
&& !testCaseName.equals("testCellSetBug");
}
};

public static TestSuite suite() {
final Util.PropertyList list =
mondrian.test.TestContext.instance()
Expand All @@ -33,6 +48,10 @@ public static TestSuite suite() {
final String catalog = list.get("Catalog");

final TestSuite suite = new TestSuite();
if (Util.PreJdk15) {
// olap4j doesn't run on JDK1.4. (Not without effort.)
return suite;
}
suite.setName("olap4j TCK");
suite.addTest(createMondrianSuite(connStr, false));
suite.addTest(createMondrianSuite(connStr, true));
Expand All @@ -58,7 +77,11 @@ private static TestSuite createXmlaSuite(
if (wrapper) {
name += " (DBCP wrapper)";
}
return TestContext.createTckSuite(properties, name);
final TestSuite suite = TestContext.createTckSuite(properties, name);
if (CONDITION == null) {
return suite;
}
return mondrian.test.TestContext.copySuite(suite, CONDITION);
}

private static TestSuite createMondrianSuite(
Expand All @@ -75,7 +98,11 @@ private static TestSuite createMondrianSuite(
final String name =
"mondrian olap4j driver"
+ (wrapper ? " (DBCP wrapper)" : "");
return TestContext.createTckSuite(properties, name);
final TestSuite suite = TestContext.createTckSuite(properties, name);
if (CONDITION == null) {
return suite;
}
return mondrian.test.TestContext.copySuite(suite, CONDITION);
}
}

Expand Down
36 changes: 34 additions & 2 deletions testsrc/main/mondrian/test/TestContext.java
Expand Up @@ -12,9 +12,9 @@
*/
package mondrian.test;

import junit.framework.Assert;
import junit.framework.ComparisonFailure;
import junit.framework.*;

import junit.framework.Test;
import mondrian.calc.*;
import mondrian.olap.*;
import mondrian.olap.Connection;
Expand Down Expand Up @@ -1332,6 +1332,38 @@ public static String toString(List<Position> positions) {
return buf.toString();
}

/**
* Makes a copy of a suite, filtering certain tests.
*
* @param suite Test suite
* @param testPattern Regular expression of name of tests to include
* @return copy of test suite
*/
public static TestSuite copySuite(
TestSuite suite,
Util.Functor1<Boolean, Test> testPattern)
{
TestSuite newSuite = new TestSuite(suite.getName());
//noinspection unchecked
for (Test test : Collections.list((Enumeration<Test>) suite.tests())) {
if (!testPattern.apply(test)) {
continue;
}
if (test instanceof TestCase) {
newSuite.addTest(test);
} else if (test instanceof TestSuite) {
TestSuite subSuite = copySuite((TestSuite) test, testPattern);
if (subSuite.countTestCases() > 0) {
newSuite.addTest(subSuite);
}
} else {
// some other kind of test
newSuite.addTest(test);
}
}
return newSuite;
}

/**
* Wrapper around a string that indicates that all line endings have been
* converted to platform-specific line endings.
Expand Down

0 comments on commit 6879c90

Please sign in to comment.