Class BatchTestCase

    • Field Detail

      • 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
      • fieldGender

        protected java.lang.String fieldGender
    • Constructor Detail

      • BatchTestCase

        public BatchTestCase​(java.lang.String name)
      • BatchTestCase

        public BatchTestCase()
    • 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)
      • 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 requests
        patterns - 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 requests
        patterns - Set of patterns
        negative - 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 query
        patterns - 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 required
        mdxQuery - MDX query
        patterns - 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 query
        patterns - 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 query
        patterns - 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 required
        mdxQuery - MDX query
        patterns - Set of patterns
        negative - false to assert if SQL is generated; true to assert if SQL is NOT generated
        bypassSchemaCache - whether to grab a new connection and bypass the schema cache before parsing the MDX query
        clearCache - whether to clear cache before executing the MDX query
      • mysqlPattern

        protected SqlPattern[] mysqlPattern​(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)
      • 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 returned
        mdx - 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 returned
        mdx - Query
        expectedResult - Expected result string
      • 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 returned
        mdx - 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 - Query
        expectedResult - Expected result string
        freshConnection - 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.