本文整理汇总了Java中org.olap4j.OlapWrapper类的典型用法代码示例。如果您正苦于以下问题:Java OlapWrapper类的具体用法?Java OlapWrapper怎么用?Java OlapWrapper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OlapWrapper类属于org.olap4j包,在下文中一共展示了OlapWrapper类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCannedProcedure
import org.olap4j.OlapWrapper; //导入依赖的package包/类
@Test public void testCannedProcedure() throws Exception {
String ddl = "create foreign procedure proc(arg integer, arg1 date) returns table (x string) options (\"teiid_rel:native-query\" '$2 $1 something')";
String query = "exec proc(2, {d'1970-01-01'})";
TransformationMetadata tm = RealMetadataFactory.fromDDL(ddl, "x", "phy");
CommandBuilder commandBuilder = new CommandBuilder(tm);
Command obj = commandBuilder.getCommand(query);
OlapExecutionFactory oef = new OlapExecutionFactory();
Connection mock = Mockito.mock(java.sql.Connection.class);
OlapWrapper mock2 = Mockito.mock(OlapWrapper.class);
OlapConnection mock3 = Mockito.mock(OlapConnection.class);
OlapStatement mock4 = Mockito.mock(OlapStatement.class);
Mockito.stub(mock4.executeOlapQuery(Mockito.anyString())).toThrow(new TeiidRuntimeException());
Mockito.stub(mock3.createStatement()).toReturn(mock4);
Mockito.stub(mock2.unwrap(OlapConnection.class)).toReturn(mock3);
Mockito.stub(mock.unwrap(OlapWrapper.class)).toReturn(mock2);
ProcedureExecution pe = oef.createProcedureExecution((Call)obj, Mockito.mock(ExecutionContext.class), new RuntimeMetadataImpl(tm), mock);
try {
pe.execute();
fail();
} catch (TeiidRuntimeException e) {
Mockito.verify(mock4).executeOlapQuery("'1970-01-01' 2 something");
}
}
示例2: unwrap
import org.olap4j.OlapWrapper; //导入依赖的package包/类
private OlapConnection unwrap(Connection conn) throws TranslatorException {
try {
OlapWrapper wrapper = conn.unwrap(OlapWrapper.class);
OlapConnection olapConn = wrapper.unwrap(OlapConnection.class);
return olapConn;
} catch(SQLException e) {
throw new TranslatorException(e);
}
}
示例3: getOlapConnection
import org.olap4j.OlapWrapper; //导入依赖的package包/类
/**
* Gets an olap4j connection, creating a new one if fresh is true.
*
* @return mondrian Connection.
*/
public synchronized OlapConnection getOlapConnection() throws SQLException {
if (this.connectString == null) {
makeConnectString();
}
final String olapConnectString = "jdbc:mondrian:" + connectString;
final java.sql.Connection jdbcConnection =
java.sql.DriverManager.getConnection(olapConnectString);
// Cast to OlapWrapper lets code work on JDK1.5, before java.sql.Wrapper
//noinspection RedundantCast
return ((OlapWrapper) jdbcConnection).unwrap(OlapConnection.class);
}
示例4: getConnection
import org.olap4j.OlapWrapper; //导入依赖的package包/类
OlapConnection getConnection(
CatalogInfo catalogInfo,
MondrianServer server,
String roleName,
Properties props)
throws SQLException
{
String connectString = catalogInfo.olap4jConnectString;
// Save the server for the duration of the call to 'getConnection'.
final LockBox.Entry entry =
MondrianServerRegistry.INSTANCE.lockBox.register(server);
final Properties properties = new Properties();
properties.setProperty(
RolapConnectionProperties.Instance.name(),
entry.getMoniker());
if (roleName != null) {
properties.setProperty(
RolapConnectionProperties.Role.name(),
roleName);
}
properties.putAll(props);
// Make sure we load the Mondrian driver into
// the ClassLoader.
try {
ClassResolver.INSTANCE.forName(
MondrianOlap4jDriver.class.getName(), true);
} catch (ClassNotFoundException e) {
throw new OlapException("Cannot find mondrian olap4j driver.");
}
final java.sql.Connection connection =
java.sql.DriverManager.getConnection(connectString, properties);
return ((OlapWrapper) connection).unwrap(OlapConnection.class);
}