use of org.pentaho.platform.engine.services.audit.AuditConnection in project pentaho-platform by pentaho.
the class AuditConnectionTest method testAuditConnectionNoConfigFile.
public void testAuditConnectionNoConfigFile() {
startTest();
// We want to test what happens when the config file can't be found
SOLUTION_PATH = "";
AuditConnection auditConnection = new AuditConnection();
// make sure we get a datasource from the object factory
auditConnection.setUseNewDatasourceService(true);
auditConnection.initialize();
MockDataSourceService.setThrowExceptionOnGetConnection(false);
try {
Connection connection = auditConnection.getAuditConnection();
// $NON-NLS-1$
System.out.println("Audit Connection Is " + connection);
DataSource datasource = auditConnection.getAuditDatasource();
// $NON-NLS-1$
System.out.println("Datasource Is " + datasource);
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
} finally {
finishTest();
}
}
use of org.pentaho.platform.engine.services.audit.AuditConnection in project pentaho-platform by pentaho.
the class AuditConnectionTest method testAuditConnection_cannot_establish_connection.
public void testAuditConnection_cannot_establish_connection() {
startTest();
try {
// Load mock object factory with mock datasource service that produces null datasources
StandaloneSpringPentahoObjectFactory factory = new StandaloneSpringPentahoObjectFactory();
factory.init("src/test/resources/solution/system/pentahoObjects.datasourceservice.null.spring.xml", null);
PentahoSystem.registerObjectFactory(factory);
AuditConnection auditConnection = new AuditConnection();
// make sure we get a datasource from the object factory
auditConnection.setUseNewDatasourceService(true);
auditConnection.initialize();
MockDataSourceService.setThrowExceptionOnGetConnection(true);
auditConnection.getAuditConnection();
fail("Expected exception when no audit connection could be established");
} catch (SQLException ex) {
ex.printStackTrace();
assertTrue("Expected AUDSQLENT.ERROR_0001", ex.getMessage().contains("AUDSQLENT.ERROR_0001"));
} finally {
finishTest();
}
}
use of org.pentaho.platform.engine.services.audit.AuditConnection in project pentaho-platform by pentaho.
the class AuditConnectionTest method testAuditConnection.
public void testAuditConnection() {
startTest();
AuditConnection auditConnection = new AuditConnection();
// make sure we get a datasource from the object factory
auditConnection.setUseNewDatasourceService(true);
auditConnection.initialize();
MockDataSourceService.setThrowExceptionOnGetConnection(false);
try {
Connection connection = auditConnection.getAuditConnection();
// $NON-NLS-1$
System.out.println("Audit Connection Is " + connection);
DataSource datasource = auditConnection.getAuditDatasource();
// $NON-NLS-1$
System.out.println("Datasource Is " + datasource);
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
} finally {
finishTest();
}
}
Aggregations