Class BatchTestCase
- java.lang.Object
-
- TestCase
-
- mondrian.test.FoodMartTestCase
-
- mondrian.rolap.BatchTestCase
-
- Direct Known Subclasses:
AggregationOnDistinctCountMeasuresTest
,ClearViewBase
,CsvDBTestCase
,DataSourceChangeListenerTest
,DefaultRecognizerTest
,EffectiveMemberCacheTest
,FastBatchingCellReaderTest
,FilterTest
,GroupingSetQueryTest
,IdBatchResolverTest
,MultipleHierarchyTest
,NativeFilterAgainstAggTableTest
,NativeFilterMatchingTest
,NativeSetEvaluationTest
,NativizeSetFunDefTest
,NonEmptyTest
,RolapNativeTopCountTest
,RolapNativeTopCountVersusNonNativeTest
,SegmentBuilderTest
,SegmentLoaderTest
,SelectNotInGroupByTest
,SqlQueryTest
,TestAggregationManager
,TestCalculatedMembers
,TopCountWithTwoParamsVersusHeadTest
,VirtualCubeTest
public class BatchTestCase extends FoodMartTestCase
To support allBatch
related tests.- Since:
- 06-Jun-2007
- Author:
- Thiyagu
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
BatchTestCase.Bomb
Fake exception to interrupt the test when we see the desired query.(package private) static class
BatchTestCase.CellRequestConstraint
protected class
BatchTestCase.TestCase
Runs an MDX query with a predefined resultLimit and checks the number of positions of the row axis.(package private) static class
BatchTestCase.TestListener
Gets notified on various test events: when a matching native evaluator was found when SQL is executed when result is found in the cache
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String
cubeNameSales
protected java.lang.String
fieldGender
protected java.lang.String
fieldProductDepartment
protected java.lang.String
fieldProductFamily
protected java.lang.String[]
fieldValueProductDepartment
protected java.lang.String[]
fieldValuesGender
protected java.lang.String[]
fieldValuesProductFamily
protected java.lang.String[]
fieldValuesYear
protected java.lang.String
fieldYear
protected java.lang.String
measureUnitSales
protected java.lang.String
tableCustomer
protected java.lang.String
tableProductClass
protected java.lang.String
tableTime
-
Fields inherited from class mondrian.test.FoodMartTestCase
propSaver
-
-
Constructor Summary
Constructors Constructor Description BatchTestCase()
BatchTestCase(java.lang.String name)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
assertNative(java.lang.String mdx)
Convenience method for debugging; please do not delete.protected void
assertNoQuerySql(java.lang.String mdxQuery, SqlPattern[] patterns)
Checks that a given MDX query does not result in a particular SQL statement being generated.void
assertNotNative(java.lang.String mdx)
Convenience method for debugging; please do not delete.protected void
assertQuerySql(java.lang.String mdxQuery, SqlPattern[] patterns)
Checks that a given MDX query results in a particular SQL statement being generated.protected void
assertQuerySql(java.lang.String mdxQuery, SqlPattern[] patterns, boolean clearCache)
Checks that a given MDX query results in a particular SQL statement being generated.protected void
assertQuerySql(TestContext testContext, java.lang.String mdxQuery, SqlPattern[] patterns)
Checks that a given MDX query results in a particular SQL statement being generated.protected void
assertQuerySqlOrNot(TestContext testContext, java.lang.String mdxQuery, SqlPattern[] patterns, boolean negative, boolean bypassSchemaCache, boolean clearCache)
During MDX query parse and execution, checks that the query results (or does not result) in a particular SQL statement being generated.protected void
assertRequestSql(CellRequest[] requests, SqlPattern[] patterns)
Checks that a given sequence of cell requests results in a particular SQL statement being generated.protected void
assertRequestSql(CellRequest[] requests, SqlPattern[] patterns, boolean negative)
Checks that a given sequence of cell requests results in a particular SQL statement being generated.protected void
checkNative(int resultLimit, int rowCount, java.lang.String mdx)
Runs a query twice, with native crossjoin optimization enabled and disabled.protected void
checkNative(int resultLimit, int rowCount, java.lang.String mdx, java.lang.String expectedResult, boolean freshConnection)
Runs a query twice, with native crossjoin optimization enabled and disabled.static void
checkNative(java.lang.String mdx, Result expectedResult)
protected void
checkNotNative(int rowCount, java.lang.String mdx)
Make sure the mdx runs correctly and not in native mode.protected void
checkNotNative(int rowCount, java.lang.String mdx, java.lang.String expectedResult)
Makes sure the MDX runs correctly and not in native mode.static void
checkNotNative(java.lang.String mdx, Result expectedResult)
(package private) void
clearAndHardenCache(MemberCacheHelper helper)
protected BatchLoader.Batch
createBatch(BatchLoader fbcr, java.lang.String[] tableNames, java.lang.String[] fieldNames, java.lang.String[][] fieldValues, java.lang.String cubeName, java.lang.String measure)
protected BatchLoader.Batch
createBatch(BatchLoader fbcr, java.lang.String[] tableNames, java.lang.String[] fieldNames, java.lang.String[][] fieldValues, java.lang.String cubeName, java.lang.String measure, BatchTestCase.CellRequestConstraint constraint)
protected CellRequest
createRequest(java.lang.String cube, java.lang.String measureName, java.lang.String[] tables, java.lang.String[] columns, java.lang.String[] values)
protected CellRequest
createRequest(java.lang.String cube, java.lang.String measureName, java.lang.String[] tables, java.lang.String[] columns, java.lang.String[] values, BatchTestCase.CellRequestConstraint aggConstraint)
protected CellRequest
createRequest(java.lang.String cube, java.lang.String measure, java.lang.String table, java.lang.String column, java.lang.String value)
protected CellRequest
createRequest(java.lang.String cube, java.lang.String measure, java.lang.String table, java.lang.String column, java.lang.String value, BatchTestCase.CellRequestConstraint aggConstraint)
protected java.lang.String
dialectize(Dialect.DatabaseProduct d, java.lang.String sql)
protected Result
executeQuery(java.lang.String mdx, Connection connection)
protected RolapCube
getCube(java.lang.String cube)
protected Connection
getFoodMartConnection()
protected GroupingSet
getGroupingSet(java.lang.String[] tableNames, java.lang.String[] fieldNames, java.lang.String[][] fieldValues, java.lang.String cubeName, java.lang.String measure)
protected RolapStar.Measure
getMeasure(java.lang.String cube, java.lang.String measureName)
(package private) RolapNativeRegistry
getRegistry(Connection connection)
(package private) static BatchTestCase.CellRequestConstraint
makeConstraintCountryState(java.util.List<java.lang.String[]> values)
(package private) static BatchTestCase.CellRequestConstraint
makeConstraintProductFamilyDepartment(java.util.List<java.lang.String[]> values)
(package private) static BatchTestCase.CellRequestConstraint
makeConstraintYearQuarterMonth(java.util.List<java.lang.String[]> values)
protected SqlPattern[]
mysqlPattern(java.lang.String sql)
protected SqlPattern[]
sqlPattern(Dialect.DatabaseProduct db, java.lang.String sql)
-
Methods inherited from class mondrian.test.FoodMartTestCase
allMember, assertAxisReturns, assertAxisThrows, assertBooleanExprReturns, assertExprReturns, assertExprThrows, assertQueriesReturnSimilarResults, assertQueryReturns, assertQueryThrows, assertSize, cubeByName, execute, executeExpr, executeQuery, executeSingletonAxis, genderMembersIncludingAll, getConnection, getDimensionWithName, getTestContext, isDefaultNullMemberRepresentation, isGroupingSetsSupported, member, productMembersPotScrubbersPotsAndPans, storeMembersCAAndOR, storeMembersUsaAndCanada, tearDown, verifySameNativeAndNot, warehouseMembersCanadaMexicoUsa
-
-
-
-
Field Detail
-
tableTime
protected final java.lang.String tableTime
- See Also:
- Constant Field Values
-
tableProductClass
protected final java.lang.String tableProductClass
- See Also:
- Constant Field Values
-
tableCustomer
protected final java.lang.String tableCustomer
- See Also:
- Constant Field Values
-
fieldYear
protected final java.lang.String fieldYear
- See Also:
- Constant Field Values
-
fieldProductFamily
protected final java.lang.String fieldProductFamily
- See Also:
- Constant Field Values
-
fieldProductDepartment
protected final java.lang.String fieldProductDepartment
- See Also:
- Constant Field Values
-
fieldValuesYear
protected final java.lang.String[] fieldValuesYear
-
fieldValuesProductFamily
protected final java.lang.String[] fieldValuesProductFamily
-
fieldValueProductDepartment
protected final java.lang.String[] fieldValueProductDepartment
-
fieldValuesGender
protected final java.lang.String[] fieldValuesGender
-
cubeNameSales
protected final java.lang.String cubeNameSales
- See Also:
- Constant Field Values
-
measureUnitSales
protected final java.lang.String measureUnitSales
- See Also:
- Constant Field Values
-
fieldGender
protected java.lang.String fieldGender
-
-
Method Detail
-
createBatch
protected BatchLoader.Batch createBatch(BatchLoader fbcr, java.lang.String[] tableNames, java.lang.String[] fieldNames, java.lang.String[][] fieldValues, java.lang.String cubeName, java.lang.String measure)
-
createBatch
protected BatchLoader.Batch createBatch(BatchLoader fbcr, java.lang.String[] tableNames, java.lang.String[] fieldNames, java.lang.String[][] fieldValues, java.lang.String cubeName, java.lang.String measure, BatchTestCase.CellRequestConstraint constraint)
-
getGroupingSet
protected GroupingSet getGroupingSet(java.lang.String[] tableNames, java.lang.String[] fieldNames, java.lang.String[][] fieldValues, java.lang.String cubeName, java.lang.String measure)
-
assertRequestSql
protected void assertRequestSql(CellRequest[] requests, SqlPattern[] patterns)
Checks that a given sequence of cell requests results in a particular SQL statement being generated.Always clears the cache before running the requests.
Runs the requests once for each SQL pattern in the current dialect. If there are multiple patterns, runs the MDX query multiple times, and expects to see each SQL statement appear. If there are no patterns in this dialect, the test trivially succeeds.
- Parameters:
requests
- Sequence of cell requestspatterns
- Set of patterns
-
assertRequestSql
protected void assertRequestSql(CellRequest[] requests, SqlPattern[] patterns, boolean negative)
Checks that a given sequence of cell requests results in a particular SQL statement being generated.Always clears the cache before running the requests.
Runs the requests once for each SQL pattern in the current dialect. If there are multiple patterns, runs the MDX query multiple times, and expects to see each SQL statement appear. If there are no patterns in this dialect, the test trivially succeeds.
- Parameters:
requests
- Sequence of cell requestspatterns
- Set of patternsnegative
- Set to false in order to 'expect' a query or true to 'forbid' a query.
-
assertQuerySql
protected void assertQuerySql(java.lang.String mdxQuery, SqlPattern[] patterns)
Checks that a given MDX query results in a particular SQL statement being generated.- Parameters:
mdxQuery
- MDX querypatterns
- Set of patterns for expected SQL statements
-
assertQuerySql
protected void assertQuerySql(TestContext testContext, java.lang.String mdxQuery, SqlPattern[] patterns)
Checks that a given MDX query results in a particular SQL statement being generated.- Parameters:
testContext
- non-default test context if requiredmdxQuery
- MDX querypatterns
- Set of patterns for expected SQL statements
-
assertNoQuerySql
protected void assertNoQuerySql(java.lang.String mdxQuery, SqlPattern[] patterns)
Checks that a given MDX query does not result in a particular SQL statement being generated.- Parameters:
mdxQuery
- MDX querypatterns
- Set of patterns for expected SQL statements
-
assertQuerySql
protected void assertQuerySql(java.lang.String mdxQuery, SqlPattern[] patterns, boolean clearCache)
Checks that a given MDX query results in a particular SQL statement being generated.- Parameters:
mdxQuery
- MDX querypatterns
- Set of patterns, one for each dialect.clearCache
- whether to clear cache before running the query
-
assertQuerySqlOrNot
protected void assertQuerySqlOrNot(TestContext testContext, java.lang.String mdxQuery, SqlPattern[] patterns, boolean negative, boolean bypassSchemaCache, boolean clearCache)
During MDX query parse and execution, checks that the query results (or does not result) in a particular SQL statement being generated.Parses and executes the MDX query once for each SQL pattern in the current dialect. If there are multiple patterns, runs the MDX query multiple times, and expects to see each SQL statement appear. If there are no patterns in this dialect, the test trivially succeeds.
- Parameters:
testContext
- non-default test context if requiredmdxQuery
- MDX querypatterns
- Set of patternsnegative
- false to assert if SQL is generated; true to assert if SQL is NOT generatedbypassSchemaCache
- whether to grab a new connection and bypass the schema cache before parsing the MDX queryclearCache
- whether to clear cache before executing the MDX query
-
sqlPattern
protected SqlPattern[] sqlPattern(Dialect.DatabaseProduct db, java.lang.String sql)
-
mysqlPattern
protected SqlPattern[] mysqlPattern(java.lang.String sql)
-
dialectize
protected java.lang.String dialectize(Dialect.DatabaseProduct d, java.lang.String sql)
-
createRequest
protected CellRequest createRequest(java.lang.String cube, java.lang.String measure, java.lang.String table, java.lang.String column, java.lang.String value)
-
createRequest
protected CellRequest createRequest(java.lang.String cube, java.lang.String measureName, java.lang.String[] tables, java.lang.String[] columns, java.lang.String[] values)
-
createRequest
protected CellRequest createRequest(java.lang.String cube, java.lang.String measure, java.lang.String table, java.lang.String column, java.lang.String value, BatchTestCase.CellRequestConstraint aggConstraint)
-
createRequest
protected CellRequest createRequest(java.lang.String cube, java.lang.String measureName, java.lang.String[] tables, java.lang.String[] columns, java.lang.String[] values, BatchTestCase.CellRequestConstraint aggConstraint)
-
makeConstraintYearQuarterMonth
static BatchTestCase.CellRequestConstraint makeConstraintYearQuarterMonth(java.util.List<java.lang.String[]> values)
-
makeConstraintCountryState
static BatchTestCase.CellRequestConstraint makeConstraintCountryState(java.util.List<java.lang.String[]> values)
-
makeConstraintProductFamilyDepartment
static BatchTestCase.CellRequestConstraint makeConstraintProductFamilyDepartment(java.util.List<java.lang.String[]> values)
-
clearAndHardenCache
void clearAndHardenCache(MemberCacheHelper helper)
-
getMeasure
protected RolapStar.Measure getMeasure(java.lang.String cube, java.lang.String measureName)
-
getFoodMartConnection
protected Connection getFoodMartConnection()
-
getCube
protected RolapCube getCube(java.lang.String cube)
-
checkNotNative
protected void checkNotNative(int rowCount, java.lang.String mdx)
Make sure the mdx runs correctly and not in native mode.- Parameters:
rowCount
- number of rows returnedmdx
- query
-
checkNotNative
protected void checkNotNative(int rowCount, java.lang.String mdx, java.lang.String expectedResult)
Makes sure the MDX runs correctly and not in native mode.- Parameters:
rowCount
- Number of rows returnedmdx
- QueryexpectedResult
- Expected result string
-
getRegistry
RolapNativeRegistry getRegistry(Connection connection)
-
checkNative
protected void checkNative(int resultLimit, int rowCount, java.lang.String mdx)
Runs a query twice, with native crossjoin optimization enabled and disabled. If both results are equal, its considered correct.- Parameters:
resultLimit
- Maximum result size of all the MDX operations in this query. This might be hard to estimate as it is usually larger than the rowCount of the final result. Setting it to 0 will cause this limit to be ignored.rowCount
- Number of rows returnedmdx
- Query
-
checkNative
protected void checkNative(int resultLimit, int rowCount, java.lang.String mdx, java.lang.String expectedResult, boolean freshConnection)
Runs a query twice, with native crossjoin optimization enabled and disabled. If both results are equal,and both aggree with the expected result, it is considered correct.Optionally the query can be run with fresh connection. This is useful if the test case sets its certain mondrian properties, e.g. native properties like: mondrian.native.filter.enable
- Parameters:
resultLimit
- Maximum result size of all the MDX operations in this query. This might be hard to estimate as it is usually larger than the rowCount of the final result. Setting it to 0 will cause this limit to be ignored.rowCount
- Number of rows returned. (That is, the number of positions on the last axis of the query.)mdx
- QueryexpectedResult
- Expected result stringfreshConnection
- Whether fresh connection is required
-
checkNotNative
public static void checkNotNative(java.lang.String mdx, Result expectedResult)
-
checkNative
public static void checkNative(java.lang.String mdx, Result expectedResult)
-
executeQuery
protected Result executeQuery(java.lang.String mdx, Connection connection)
-
assertNotNative
public void assertNotNative(java.lang.String mdx)
Convenience method for debugging; please do not delete.
-
assertNative
public void assertNative(java.lang.String mdx)
Convenience method for debugging; please do not delete.
-
-