use of org.pentaho.platform.api.engine.IPentahoSession in project pentaho-platform by pentaho.
the class DefaultPluginManagerIT method test17_getPluginIdForType.
@Test
public void test17_getPluginIdForType() throws PlatformInitializationException, PluginBeanException {
IPluginProvider provider = new IPluginProvider() {
public List<IPlatformPlugin> getPlugins(IPentahoSession session) throws PlatformPluginRegistrationException {
PlatformPlugin p = new PlatformPlugin(new DefaultListableBeanFactory());
p.setId("testPlugin");
ContentGeneratorInfo cg1 = new ContentGeneratorInfo();
cg1.setDescription("test 9 plugin description");
cg1.setId("oldworldCGid");
cg1.setType("oldworldCGtype");
cg1.setTitle("test");
cg1.setClassname("org.pentaho.test.platform.plugin.pluginmgr.ContentGenerator1");
// cg1.setFileInfoGeneratorClassname("org.pentaho.test.platform.plugin.pluginmgr.FileInfoGenerator");
p.addContentGenerator(cg1);
BeanDefinition beanDef = BeanDefinitionBuilder.rootBeanDefinition("org.pentaho.test.platform.plugin.pluginmgr.ContentGenerator1").setScope(BeanDefinition.SCOPE_PROTOTYPE).getBeanDefinition();
p.getBeanFactory().registerBeanDefinition("springDefinedCGid", beanDef);
p.getBeanFactory().registerAlias("springDefinedCGid", "springDefinedCGtype");
return Arrays.asList((IPlatformPlugin) p);
}
};
microPlatform.defineInstance(IPluginProvider.class, provider).start();
pluginManager.reload();
assertEquals("testPlugin", pluginManager.getPluginIdForType("oldworldCGtype"));
assertEquals("testPlugin", pluginManager.getPluginIdForType("springDefinedCGtype"));
}
use of org.pentaho.platform.api.engine.IPentahoSession in project pentaho-platform by pentaho.
the class PluginManagerNotConfiguredIT method testPluginAdapterViaSystemListenerAPI.
@SuppressWarnings("cast")
public void testPluginAdapterViaSystemListenerAPI() throws Exception {
startTest();
// $NON-NLS-1$
IPentahoSession session = new StandaloneSession("test user");
PluginAdapter mgr = new PluginAdapter();
assertTrue(mgr instanceof IPentahoSystemListener);
IPentahoSystemListener listener = (IPentahoSystemListener) mgr;
assertFalse(listener.startup(session));
// this does not do anything but it shouldn't error
listener.shutdown();
finishTest();
}
use of org.pentaho.platform.api.engine.IPentahoSession 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.platform.api.engine.IPentahoSession 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.platform.api.engine.IPentahoSession in project pentaho-platform by pentaho.
the class FilterDefinitionIT method getSession.
private IPentahoSession getSession() {
IPentahoResultSet rs = getFakeResultSet();
// $NON-NLS-1$
IPentahoSession session = new StandaloneSession("REPOSTEST.JUNIT_TEST_SESSION");
// $NON-NLS-1$
session.setAttribute("customerNamesList", rs);
return session;
}
Aggregations