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 allBatchrelated tests.- Since:
- 06-Jun-2007
- Author:
- Thiyagu
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classBatchTestCase.BombFake exception to interrupt the test when we see the desired query.(package private) static classBatchTestCase.CellRequestConstraintprotected classBatchTestCase.TestCaseRuns an MDX query with a predefined resultLimit and checks the number of positions of the row axis.(package private) static classBatchTestCase.TestListenerGets 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 StringcubeNameSalesprotected StringfieldGenderprotected StringfieldProductDepartmentprotected StringfieldProductFamilyprotected String[]fieldValueProductDepartmentprotected String[]fieldValuesGenderprotected String[]fieldValuesProductFamilyprotected String[]fieldValuesYearprotected StringfieldYearprotected StringmeasureUnitSalesprotected StringtableCustomerprotected StringtableProductClassprotected StringtableTime-
Fields inherited from class mondrian.test.FoodMartTestCase
propSaver
-
-
Constructor Summary
Constructors Constructor Description BatchTestCase()BatchTestCase(String name)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidassertNative(String mdx)Convenience method for debugging; please do not delete.protected voidassertNoQuerySql(String mdxQuery, SqlPattern[] patterns)Checks that a given MDX query does not result in a particular SQL statement being generated.voidassertNotNative(String mdx)Convenience method for debugging; please do not delete.protected voidassertQuerySql(String mdxQuery, SqlPattern[] patterns)Checks that a given MDX query results in a particular SQL statement being generated.protected voidassertQuerySql(String mdxQuery, SqlPattern[] patterns, boolean clearCache)Checks that a given MDX query results in a particular SQL statement being generated.protected voidassertQuerySql(TestContext testContext, String mdxQuery, SqlPattern[] patterns)Checks that a given MDX query results in a particular SQL statement being generated.protected voidassertQuerySqlOrNot(TestContext testContext, 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 voidassertRequestSql(CellRequest[] requests, SqlPattern[] patterns)Checks that a given sequence of cell requests results in a particular SQL statement being generated.protected voidassertRequestSql(CellRequest[] requests, SqlPattern[] patterns, boolean negative)Checks that a given sequence of cell requests results in a particular SQL statement being generated.protected voidcheckNative(int resultLimit, int rowCount, String mdx)Runs a query twice, with native crossjoin optimization enabled and disabled.protected voidcheckNative(int resultLimit, int rowCount, String mdx, String expectedResult, boolean freshConnection)Runs a query twice, with native crossjoin optimization enabled and disabled.static voidcheckNative(String mdx, Result expectedResult)protected voidcheckNotNative(int rowCount, String mdx)Make sure the mdx runs correctly and not in native mode.protected voidcheckNotNative(int rowCount, String mdx, String expectedResult)Makes sure the MDX runs correctly and not in native mode.static voidcheckNotNative(String mdx, Result expectedResult)(package private) voidclearAndHardenCache(MemberCacheHelper helper)protected BatchLoader.BatchcreateBatch(BatchLoader fbcr, String[] tableNames, String[] fieldNames, String[][] fieldValues, String cubeName, String measure)protected BatchLoader.BatchcreateBatch(BatchLoader fbcr, String[] tableNames, String[] fieldNames, String[][] fieldValues, String cubeName, String measure, BatchTestCase.CellRequestConstraint constraint)protected CellRequestcreateRequest(String cube, String measureName, String[] tables, String[] columns, String[] values)protected CellRequestcreateRequest(String cube, String measureName, String[] tables, String[] columns, String[] values, BatchTestCase.CellRequestConstraint aggConstraint)protected CellRequestcreateRequest(String cube, String measure, String table, String column, String value)protected CellRequestcreateRequest(String cube, String measure, String table, String column, String value, BatchTestCase.CellRequestConstraint aggConstraint)protected Stringdialectize(Dialect.DatabaseProduct d, String sql)protected ResultexecuteQuery(String mdx, Connection connection)protected RolapCubegetCube(String cube)protected ConnectiongetFoodMartConnection()protected GroupingSetgetGroupingSet(String[] tableNames, String[] fieldNames, String[][] fieldValues, String cubeName, String measure)protected RolapStar.MeasuregetMeasure(String cube, String measureName)(package private) RolapNativeRegistrygetRegistry(Connection connection)(package private) static BatchTestCase.CellRequestConstraintmakeConstraintCountryState(List<String[]> values)(package private) static BatchTestCase.CellRequestConstraintmakeConstraintProductFamilyDepartment(List<String[]> values)(package private) static BatchTestCase.CellRequestConstraintmakeConstraintYearQuarterMonth(List<String[]> values)protected SqlPattern[]mysqlPattern(String sql)protected SqlPattern[]sqlPattern(Dialect.DatabaseProduct db, 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 String tableTime
- See Also:
- Constant Field Values
-
tableProductClass
protected final String tableProductClass
- See Also:
- Constant Field Values
-
tableCustomer
protected final String tableCustomer
- See Also:
- Constant Field Values
-
fieldYear
protected final String fieldYear
- See Also:
- Constant Field Values
-
fieldProductFamily
protected final String fieldProductFamily
- See Also:
- Constant Field Values
-
fieldProductDepartment
protected final String fieldProductDepartment
- See Also:
- Constant Field Values
-
fieldValuesYear
protected final String[] fieldValuesYear
-
fieldValuesProductFamily
protected final String[] fieldValuesProductFamily
-
fieldValueProductDepartment
protected final String[] fieldValueProductDepartment
-
fieldValuesGender
protected final String[] fieldValuesGender
-
cubeNameSales
protected final String cubeNameSales
- See Also:
- Constant Field Values
-
measureUnitSales
protected final String measureUnitSales
- See Also:
- Constant Field Values
-
fieldGender
protected String fieldGender
-
-
Constructor Detail
-
BatchTestCase
public BatchTestCase(String name)
-
BatchTestCase
public BatchTestCase()
-
-
Method Detail
-
createBatch
protected BatchLoader.Batch createBatch(BatchLoader fbcr, String[] tableNames, String[] fieldNames, String[][] fieldValues, String cubeName, String measure)
-
createBatch
protected BatchLoader.Batch createBatch(BatchLoader fbcr, String[] tableNames, String[] fieldNames, String[][] fieldValues, String cubeName, String measure, BatchTestCase.CellRequestConstraint constraint)
-
getGroupingSet
protected GroupingSet getGroupingSet(String[] tableNames, String[] fieldNames, String[][] fieldValues, String cubeName, 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(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, 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(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(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, 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, String sql)
-
mysqlPattern
protected SqlPattern[] mysqlPattern(String sql)
-
dialectize
protected String dialectize(Dialect.DatabaseProduct d, String sql)
-
createRequest
protected CellRequest createRequest(String cube, String measure, String table, String column, String value)
-
createRequest
protected CellRequest createRequest(String cube, String measureName, String[] tables, String[] columns, String[] values)
-
createRequest
protected CellRequest createRequest(String cube, String measure, String table, String column, String value, BatchTestCase.CellRequestConstraint aggConstraint)
-
createRequest
protected CellRequest createRequest(String cube, String measureName, String[] tables, String[] columns, String[] values, BatchTestCase.CellRequestConstraint aggConstraint)
-
makeConstraintYearQuarterMonth
static BatchTestCase.CellRequestConstraint makeConstraintYearQuarterMonth(List<String[]> values)
-
makeConstraintCountryState
static BatchTestCase.CellRequestConstraint makeConstraintCountryState(List<String[]> values)
-
makeConstraintProductFamilyDepartment
static BatchTestCase.CellRequestConstraint makeConstraintProductFamilyDepartment(List<String[]> values)
-
clearAndHardenCache
void clearAndHardenCache(MemberCacheHelper helper)
-
getMeasure
protected RolapStar.Measure getMeasure(String cube, String measureName)
-
getFoodMartConnection
protected Connection getFoodMartConnection()
-
checkNotNative
protected void checkNotNative(int rowCount, 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, String mdx, 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, 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, String mdx, 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
-
executeQuery
protected Result executeQuery(String mdx, Connection connection)
-
assertNotNative
public void assertNotNative(String mdx)
Convenience method for debugging; please do not delete.
-
assertNative
public void assertNative(String mdx)
Convenience method for debugging; please do not delete.
-
-