+ "{}\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++) {