use of mondrian.rolap.RolapConnection in project mondrian by pentaho.
the class AggGenTest method testCallingLoadColumnsInAddCollapsedColumnOrAddzSpecialCollapsedColumn.
public void testCallingLoadColumnsInAddCollapsedColumnOrAddzSpecialCollapsedColumn() throws Exception {
Logger logger = LogManager.getLogger(AggGen.class);
StringWriter writer = new StringWriter();
final Appender appender = Util.makeAppender("testMdcContext", writer, null);
Util.addAppender(appender, logger, org.apache.logging.log4j.Level.DEBUG);
MondrianProperties props = MondrianProperties.instance();
// If run in Ant and with mondrian.jar, please comment out this line:
propSaver.set(props.AggregateRules, "DefaultRules.xml");
propSaver.set(props.UseAggregates, true);
propSaver.set(props.ReadAggregates, true);
propSaver.set(props.GenerateAggregateSql, true);
final RolapConnection rolapConn = (RolapConnection) getConnection();
Query query = rolapConn.parseQuery("select {[Measures].[Count]} on columns from [HR]");
rolapConn.execute(query);
Util.removeAppender(appender, logger);
final DataSource dataSource = rolapConn.getDataSource();
Connection sqlConnection = null;
try {
sqlConnection = dataSource.getConnection();
DatabaseMetaData dbmeta = sqlConnection.getMetaData();
JdbcSchema jdbcSchema = JdbcSchema.makeDB(dataSource);
final String catalogName = jdbcSchema.getCatalogName();
final String schemaName = jdbcSchema.getSchemaName();
String log = writer.toString();
Pattern p = Pattern.compile("DEBUG - Init: Column: [^:]+: `(\\w+)`.`(\\w+)`" + Util.nl + "WARN - Can not find column: \\2");
Matcher m = p.matcher(log);
while (m.find()) {
ResultSet rs = dbmeta.getColumns(catalogName, schemaName, m.group(1), m.group(2));
assertTrue(!rs.next());
}
} finally {
if (sqlConnection != null) {
try {
sqlConnection.close();
} catch (SQLException e) {
// ignore
}
}
}
}
use of mondrian.rolap.RolapConnection in project mondrian by pentaho.
the class SchemaTest method testMondrian1275.
public void testMondrian1275() throws Exception {
final TestContext tc = getTestContext().withSchema("<?xml version=\"1.0\"?>\n" + "<Schema name=\"FoodMart\">\n" + " <Dimension name=\"Store Type\">\n" + " <Annotations>\n" + " <Annotation name=\"foo\">bar</Annotation>\n" + " </Annotations>\n" + " <Hierarchy hasAll=\"true\" primaryKey=\"store_id\">\n" + " <Table name=\"store\"/>\n" + " <Level name=\"Store Type\" column=\"store_type\" uniqueMembers=\"true\"/>\n" + " </Hierarchy>\n" + " </Dimension>\n" + "<Cube name=\"Sales\" defaultMeasure=\"Unit Sales\">\n" + " <Table name=\"sales_fact_1997\">\n" + " <AggExclude name=\"agg_c_special_sales_fact_1997\" />\n" + " <AggExclude name=\"agg_lc_100_sales_fact_1997\" />\n" + " <AggExclude name=\"agg_lc_10_sales_fact_1997\" />\n" + " <AggExclude name=\"agg_pc_10_sales_fact_1997\" />\n" + " </Table>\n" + " <DimensionUsage name=\"Store Type\" source=\"Store Type\" foreignKey=\"store_id\"/>\n" + " <Measure name=\"Unit Sales\" column=\"unit_sales\" aggregator=\"sum\"\n" + " formatString=\"Standard\"/>\n" + "</Cube>\n" + "</Schema>\n");
final RolapConnection rolapConn = tc.getOlap4jConnection().unwrap(RolapConnection.class);
final SchemaReader schemaReader = rolapConn.getSchemaReader();
final RolapSchema schema = schemaReader.getSchema();
for (RolapCube cube : schema.getCubeList()) {
Dimension dim = cube.getDimensions()[1];
final Map<String, Annotation> annotations = dim.getAnnotationMap();
Assert.assertEquals(1, annotations.size());
Assert.assertEquals("bar", annotations.get("foo").getValue());
}
}
use of mondrian.rolap.RolapConnection in project mondrian by pentaho.
the class Execution method fireExecutionEndEvent.
private void fireExecutionEndEvent() {
final RolapConnection connection = statement.getMondrianConnection();
final MondrianServer server = connection.getServer();
server.getMonitor().sendEvent(new ExecutionEndEvent(this.startTimeMillis, server.getId(), connection.getId(), this.statement.getId(), this.id, this.phase, this.state, this.cellCacheHitCount, this.cellCacheMissCount, this.cellCachePendingCount, expCacheHitCount, expCacheMissCount));
}
use of mondrian.rolap.RolapConnection in project pentaho-platform by pentaho.
the class OlapServiceImplTest method flushSingleSchemaCache.
@Test
public void flushSingleSchemaCache() throws Exception {
OlapConnection connection = mock(OlapConnection.class);
doReturn(connection).when(olapService).getConnection("schemaX", session);
RolapConnection rc = mock(RolapConnection.class);
doReturn(rc).when(connection).unwrap(RolapConnection.class);
doReturn(cacheControl).when(rc).getCacheControl(any(PrintWriter.class));
RolapSchema schema = mock(RolapSchema.class);
doReturn(schema).when(rc).getSchema();
olapService.flush(session, "schemaX");
verify(cacheControl, times(1)).flushSchema(schema);
}
use of mondrian.rolap.RolapConnection in project pentaho-platform by pentaho.
the class OlapServiceImplTest method testFlushProceedsOnException.
@Test
public void testFlushProceedsOnException() throws Exception {
stubHostedServer();
final Properties properties = new Properties();
properties.put(RolapConnectionProperties.Locale.name(), getLocale().toString());
OlapConnection conn = mock(OlapConnection.class);
when(server.getConnection("Pentaho", "myHostedServer", null, properties)).thenReturn(conn);
when(conn.isWrapperFor(any(Class.class))).thenReturn(true);
final RolapConnection rolapConn = mock(RolapConnection.class);
when(conn.unwrap(any(Class.class))).thenReturn(rolapConn);
when(rolapConn.getCacheControl(any(PrintWriter.class))).thenThrow(new RuntimeException("something happend"));
try {
olapService.flushAll(session);
} catch (IOlapServiceException e) {
fail("Exception shouldn't have made it this far.");
}
}
Aggregations