Package mondrian.test

Examples of mondrian.test.TestContext$HighCardDynamicSchemaProcessor


        if (properties.TestExpDependencies.get() > 0) {
            // Dependency testing produces side-effects in the cache.
            return;
        }
        // got to clean out the cache
        final TestContext testContext = getTestContext();
        final mondrian.olap.CacheControl cacheControl =
            testContext.getConnection().getCacheControl(null);

        // Flush the entire cache.
        final Connection connection = testContext.getConnection();
        final mondrian.olap.Cube salesCube =
            connection.getSchema().lookupCube("Sales", true);
        final mondrian.olap.CacheControl.CellRegion measuresRegion =
            cacheControl.createMeasuresRegion(salesCube);
        cacheControl.flush(measuresRegion);
View Full Code Here


            + "{}\n"
            + "Axis #1:\n"
            + "{[Store].[USA].[CA].[San Francisco]}\n"
            + "Row #0: 2,117\n"
        };
        final TestContext testContext =
            TestContext.instance().create(
                null, null,
                "<Cube name=\"Warehouse No Cache\" cache=\"false\">\n"
                + "  <Table name=\"inventory_fact_1997\"/>\n"
                + "\n"
                + "  <DimensionUsage name=\"Time\" source=\"Time\" foreignKey=\"time_id\"/>\n"
                + "  <DimensionUsage name=\"Store\" source=\"Store\" foreignKey=\"store_id\"/>\n"
                + "  <Measure name=\"Units Shipped\" column=\"units_shipped\" aggregator=\"sum\" formatString=\"#.0\"/>\n"
                + "</Cube>\n"
                + "<VirtualCube name=\"Warehouse and Sales Format Expression Cube No Cache\">\n"
                + "  <VirtualCubeDimension name=\"Store\"/>\n"
                + "  <VirtualCubeDimension name=\"Time\"/>\n"
                + "  <VirtualCubeMeasure cubeName=\"Sales\" name=\"[Measures].[Store Cost]\"/>\n"
                + "  <VirtualCubeMeasure cubeName=\"Sales\" name=\"[Measures].[Store Sales]\"/>\n"
                + "  <VirtualCubeMeasure cubeName=\"Warehouse No Cache\" name=\"[Measures].[Units Shipped]\"/>\n"
                + "  <CalculatedMember name=\"Profit\" dimension=\"Measures\">\n"
                + "    <Formula>[Measures].[Store Sales] - [Measures].[Store Cost]</Formula>\n"
                + "  </CalculatedMember>\n"
                + "  <CalculatedMember name=\"Profit Per Unit Shipped\" dimension=\"Measures\">\n"
                + "    <Formula>[Measures].[Profit] / [Measures].[Units Shipped]</Formula>\n"
                + "    <CalculatedMemberProperty name=\"FORMAT_STRING\" expression=\"IIf(([Measures].[Profit Per Unit Shipped] > 2.0), '|0.#|style=green', '|0.#|style=red')\"/>\n"
                + "  </CalculatedMember>\n"
                + "</VirtualCube>",
                null, null, null);

        SmartMemberReader smrStore =
            getSmartMemberReader(testContext.getConnection(), "Store");
        MemberCacheHelper smrStoreCacheHelper =
            (MemberCacheHelper) smrStore.getMemberCache();
        SmartMemberReader smrProduct =
            getSmartMemberReader(testContext.getConnection(), "Product");
        MemberCacheHelper smrProductCacheHelper =
            (MemberCacheHelper) smrProduct.getMemberCache();

        // 1/500 of the time, the hierarchies are flushed
        // 1/50 of the time, the aggregates are flushed
        smrStoreCacheHelper.changeListener =
            new DataSourceChangeListenerImpl4(500, 50);
        smrProductCacheHelper.changeListener =
            smrStoreCacheHelper.changeListener;

        RolapStar star = getStar(testContext.getConnection(), "Sales");
        star.setChangeListener(smrStoreCacheHelper.changeListener);

        star = getStar(testContext.getConnection(), "Warehouse No Cache");
        star.setChangeListener(smrStoreCacheHelper.changeListener);


        for (int i = 0; i < workerCount; i++) {
            workers[i] = new Worker() {
                public void runSafe() {
                    for (int i = 0; i < cycleCount; ++i) {
                        cycle();
                        try {
                            // Sleep up to 100ms.
                            Thread.sleep(random.nextInt(100));
                        } catch (InterruptedException e) {
                            throw Util.newInternal(e, "interrupted");
                        }
                    }
                }

                private void cycle() {
                    int idx = random.nextInt(4);
                    String query = queries[idx];
                    String result = results[idx];
                    testContext.assertQueryReturns(query, result);
                }
            };
            threads[i] = new Thread(workers[i]);
        }
        for (int i = 0; i < workerCount; i++) {
View Full Code Here

    }

    public void testA() {
        // Schema has two cubes sharing a dimension.
        // Query from the first cube.
        TestContext testContext = getTestContextForSharedDimCubeACubeB();

        testContext.assertQueryReturns(queryCubeA, resultCubeA);
    }
View Full Code Here

    }

    public void testB() {
        // Schema has two cubes sharing a dimension.
        // Query from the second cube.
        TestContext testContext = getTestContextForSharedDimCubeACubeB();

        testContext.assertQueryReturns(queryCubeB, resultCubeB);
    }
View Full Code Here

    public void testVirtualCube() {
        // Schema has two cubes sharing a dimension, and a virtual cube built
        // over these two cubes.
        // Query from the virtual cube.

        TestContext testContext =
            TestContext.instance().create(
                sharedDimension,
                cubeA + "\n" + cubeB,
                virtualCube,
                null,
                null,
                null);

        testContext.assertQueryReturns(queryVirtualCube, resultVirtualCube);
    }
View Full Code Here

    }

    public void testNECJMemberList() {
        // Schema has two cubes sharing a dimension.
        // Query from the second cube.
        TestContext testContext = getTestContextForSharedDimCubeACubeB();

        testContext.assertQueryReturns(
            queryNECJMemberList,
            resultNECJMemberList);
    }
View Full Code Here

    public void testNECJMultiLevelMemberList() {
        // Schema has two cubes sharing a dimension.
        // Query from the first cube.
        // This is a case where not using alias not only affects performance,
        // but also produces incorrect result.
        TestContext testContext = getTestContextForSharedDimCubeACubeB();

        testContext.assertQueryReturns(
            queryNECJMultiLevelMemberList,
            resultNECJMultiLevelMemberList);
    }
View Full Code Here

                + ") } on 0 from sales");
        }
    }

    public void testBugCantRestrictSlicerToCalcMember() throws Exception {
        TestContext ctx = getTestContext();
        ctx.assertQueryReturns(
            "WITH Member [Time].[Time].[Aggr] AS 'Aggregate({[Time].[1998].[Q1], [Time].[1998].[Q2]})' "
            + "SELECT {[Measures].[Store Sales]} ON COLUMNS, "
            + "NON EMPTY Order(TopCount([Customers].[Name].Members,3,[Measures].[Store Sales]),[Measures].[Store Sales],BASC) ON ROWS "
            + "FROM [Sales] "
            + "WHERE ([Time].[Aggr])",
View Full Code Here

            + "Row #8: 43,479.86\n");
    }

    public void testTopCountWithCalcMemberInSlicer() {
        // Internal error: can not restrict SQL to calculated Members
        TestContext ctx = getTestContext();
        ctx.assertQueryReturns(
            "with member [Time].[Time].[First Term] as 'Aggregate({[Time].[1997].[Q1], [Time].[1997].[Q2]})' "
            + "select {[Measures].[Unit Sales]} ON COLUMNS, "
            + "TopCount([Product].[Product Subcategory].Members, 3, [Measures].[Unit Sales]) ON ROWS "
            + "from [Sales] "
            + "where ([Time].[First Term]) ",
View Full Code Here

    public void testTopCountCacheKeyMustIncludeCount() {
        /**
         * When caching topcount results, the number of elements must
         * be part of the cache key
         */
        TestContext ctx = getTestContext();
        // fill cache
        ctx.assertQueryReturns(
            "select {[Measures].[Unit Sales]} ON COLUMNS, "
            + "TopCount([Product].[Product Subcategory].Members, 2, [Measures].[Unit Sales]) ON ROWS "
            + "from [Sales]",
            "Axis #0:\n"
            + "{}\n"
            + "Axis #1:\n"
            + "{[Measures].[Unit Sales]}\n"
            + "Axis #2:\n"
            + "{[Product].[Food].[Produce].[Vegetables].[Fresh Vegetables]}\n"
            + "{[Product].[Food].[Produce].[Fruit].[Fresh Fruit]}\n"
            + "Row #0: 20,739\n"
            + "Row #1: 11,767\n");
        // run again with different count
        ctx.assertQueryReturns(
            "select {[Measures].[Unit Sales]} ON COLUMNS, "
            + "TopCount([Product].[Product Subcategory].Members, 3, [Measures].[Unit Sales]) ON ROWS "
            + "from [Sales]",
            "Axis #0:\n"
            + "{}\n"
View Full Code Here

TOP

Related Classes of mondrian.test.TestContext$HighCardDynamicSchemaProcessor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.