use of org.pentaho.commons.connection.IPentahoResultSet in project pentaho-platform by pentaho.
the class ConnectionIT method testMDX_VFS_zipped_Schema.
/**
* This test currently fails, due to Mondrian not understanding the catalog URL. I'm guessing we're not using the
* latest mondrian libs that support mondrian
*/
@SuppressWarnings("deprecation")
public void testMDX_VFS_zipped_Schema() {
startTest();
// StandaloneSession session = new StandaloneSession(Messages.getString("BaseTest.DEBUG_JUNIT_SESSION")); //$NON-NLS-1$
// SolutionRepositoryVfs.setSolutionRepository( PentahoSystem.getSolutionRepository( session ) );
IPentahoSession session = new StandaloneSession("Admin");
// $NON-NLS-1$ //$NON-NLS-2$
OutputStream outputStream = this.getOutputStream("ConnectionTest.testSQLConnection", ".csv");
File file = // $NON-NLS-1$
new File(PentahoSystem.getApplicationContext().getSolutionPath("test/datasources/SampleDataSchema.zip"));
// $NON-NLS-1$ //$NON-NLS-2$
String catalog = "zip:" + file.toURI().toString() + "!/SampleData.mondrian.xml";
// $NON-NLS-1$
catalog = "solution:/test/datasources/SampleData.mondrian.xml;vfs=true";
IPentahoConnection connection = PentahoConnectionFactory.getConnection(IPentahoConnection.MDX_DATASOURCE, "jdbc:hsqldb:hsql://localhost:9001/sampledata; Catalog=" + catalog, "mondrian", "sa", "", session, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
null);
String query = // $NON-NLS-1$
"select {[Measures].[Actual], [Measures].[Budget]} on rows, {[Region].[All Regions]} ON columns from [Quadrant Analysis] WHERE ([Positions].[All Positions])";
try {
IPentahoResultSet results = connection.executeQuery(query);
Object[][] columnHeaders = results.getMetaData().getColumnHeaders();
for (int row = columnHeaders.length - 1; row >= 0; row--) {
for (int col = 0; col < columnHeaders[row].length; col++) {
// $NON-NLS-1$
outputStream.write((columnHeaders[row][col] + "\t").getBytes());
}
outputStream.write('\n');
}
Object[][] rowHeaders = results.getMetaData().getRowHeaders();
int rowIdx = 0;
Object[] row = results.next();
while (row != null) {
for (int colIdx = rowHeaders[rowIdx].length - 1; colIdx >= 0; colIdx--) {
// $NON-NLS-1$
outputStream.write((rowHeaders[rowIdx][colIdx].toString() + "\t").getBytes());
}
for (int colIdx = 0; colIdx < row.length; colIdx++) {
// $NON-NLS-1$
outputStream.write((row[colIdx] + "\t").getBytes());
}
outputStream.write('\n');
row = results.next();
rowIdx++;
}
results.close();
} catch (Exception e) {
e.printStackTrace();
}
connection.close();
finishTest();
}
use of org.pentaho.commons.connection.IPentahoResultSet in project pentaho-platform by pentaho.
the class ConnectionIT method testSQLConnectionWithAllInfo.
public void testSQLConnectionWithAllInfo() {
startTest();
IPentahoSession session = new StandaloneSession("Admin");
// $NON-NLS-1$ //$NON-NLS-2$
OutputStream outputStream = this.getOutputStream("ConnectionTest.testConnectionWithPropertyName", ".csv");
File file = // $NON-NLS-1$
new File(PentahoSystem.getApplicationContext().getSolutionPath("test/datasources/SampleData.mondrian.xml"));
IPentahoConnection connection = PentahoConnectionFactory.getConnection(IPentahoConnection.MDX_DATASOURCE, "jdbc:hsqldb:hsql://localhost:9001/sampledata; Catalog=" + file.toURI().toString(), "mondrian", "sa", "", session, // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
this);
try {
// $NON-NLS-1$
IPentahoResultSet results = connection.executeQuery("select * from DEPARTMENT_MANAGERS");
Object[][] columnHeaders = results.getMetaData().getColumnHeaders();
for (int row = 0; row < columnHeaders.length; row++) {
for (int col = 0; col < columnHeaders[0].length; col++) {
outputStream.write(columnHeaders[row][col].toString().getBytes());
// $NON-NLS-1$
outputStream.write(",".getBytes());
}
// $NON-NLS-1$
outputStream.write("\n".getBytes());
}
Object[] row = results.next();
while (row != null) {
for (int i = 0; i < row.length; i++) {
outputStream.write(row[i].toString().getBytes());
// $NON-NLS-1$
outputStream.write(",".getBytes());
}
// $NON-NLS-1$
outputStream.write("\n".getBytes());
row = results.next();
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
connection.close();
finishTest();
}
use of org.pentaho.commons.connection.IPentahoResultSet in project pentaho-platform by pentaho.
the class MultipleComponentIT method testDataUtility4.
public void testDataUtility4() {
startTest();
IPentahoResultSet rs4 = getResultSet3();
String xmlString4 = DataUtilities.getXMLString(rs4);
// $NON-NLS-1$
assertTrue(xmlString4.indexOf("DATA2") > 0);
finishTest();
}
use of org.pentaho.commons.connection.IPentahoResultSet in project pentaho-platform by pentaho.
the class MultipleComponentIT method testDataUtility.
public void testDataUtility() {
startTest();
IPentahoResultSet rs = getResultSet();
String xmlString = DataUtilities.getXMLString(rs);
// $NON-NLS-1$
assertTrue(xmlString.indexOf("DATA2") > 0);
finishTest();
}
use of org.pentaho.commons.connection.IPentahoResultSet in project pentaho-platform by pentaho.
the class FilterDefinitionIT method setGlobalParams.
private void setGlobalParams() {
IPentahoResultSet rs = getFakeResultSet();
SimpleParameterProvider spp = (SimpleParameterProvider) PentahoSystem.getGlobalParameters();
// $NON-NLS-1$
spp.setParameter("customerNamesList", rs);
}
Aggregations