use of org.pentaho.platform.api.engine.ILogger in project pentaho-platform by pentaho.
the class FilterDefinitionIT method testFilterCreation.
public void testFilterCreation() {
try {
// $NON-NLS-1$
Class.forName("net.sf.cglib.transform.ClassFilter");
} catch (ClassNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
ILogger l = new SimpleLogger(this);
IPentahoSession session = getSession();
setGlobalParams();
this.sessionStartup(session);
Document doc = null;
try {
// $NON-NLS-1$
doc = XmlDom4JHelper.getDocFromFile(new File(SOLUTION_PATH + "/test/filterPanel/test.filterpanel.xml"), null);
} catch (Exception ee) {
ee.printStackTrace();
// $NON-NLS-1$
assertTrue("Failed to get the document from a file.", false);
}
FilterPanel fp = null;
try {
fp = new FilterPanel(session, doc, l);
} catch (FilterPanelException e) {
e.printStackTrace();
// $NON-NLS-1$
assertTrue("Failed to create stream from document.", false);
}
Map parameterProviders = getParameterProviders();
boolean success = false;
List filters = fp.getFilters();
FilterDefinition fd = null;
fd = (FilterDefinition) filters.get(0);
// $NON-NLS-1$
success = fd.populate(parameterProviders, new String[] { "huh" });
// $NON-NLS-1$
assertTrue("Populate on filter session-attribute failed", success);
fd = (FilterDefinition) filters.get(1);
// $NON-NLS-1$
success = fd.populate(parameterProviders, new String[] { "huh" });
// $NON-NLS-1$
assertTrue("Populate on filter global-attribute failed", success);
fd = (FilterDefinition) filters.get(2);
// $NON-NLS-1$
success = fd.populate(parameterProviders, new String[] { "huh" });
// $NON-NLS-1$
assertTrue("Populate on filter static-lov failed", success);
fd = (FilterDefinition) filters.get(3);
// $NON-NLS-1$
success = fd.populate(parameterProviders, new String[] { "huh" });
// $NON-NLS-1$
assertTrue("Populate on filter action sequence failed", success);
}
use of org.pentaho.platform.api.engine.ILogger in project pentaho-platform by pentaho.
the class XQueryIT method testXQConnectionConnect.
public void testXQConnectionConnect() {
try {
XQConnection connection = new XQConnection();
ILogger mockLogger = mock(ILogger.class);
connection.setLogger(mockLogger);
Properties properties = null;
boolean isConnected = connection.connect(properties);
assertTrue(isConnected);
properties = new Properties();
isConnected = connection.connect(properties);
assertTrue(isConnected);
properties.setProperty(IPentahoConnection.QUERY_KEY, StringUtils.EMPTY);
isConnected = connection.connect(properties);
assertTrue(isConnected);
properties.setProperty(IPentahoConnection.QUERY_KEY, TEST_QUERY);
isConnected = connection.connect(properties);
assertTrue(isConnected);
StaticQueryContext mockContext = mock(StaticQueryContext.class);
when(mockContext.compileQuery(TEST_QUERY)).thenThrow(new XPathException("Test XPathException"));
connection.sqc = mockContext;
isConnected = connection.connect(properties);
assertFalse(isConnected);
} catch (Exception e) {
e.printStackTrace();
fail("Should not throw Exception");
}
}
use of org.pentaho.platform.api.engine.ILogger in project pentaho-platform by pentaho.
the class PentahoConnectionFactoryTest method testGetConnection.
@Test
public void testGetConnection() {
// Test constructor.
PentahoConnectionFactory factory = new PentahoConnectionFactory();
assertNotNull(factory);
String dsType = "connection-test";
IPentahoSession session = mock(IPentahoSession.class);
ILogger logger = mock(ILogger.class);
IPentahoConnection connection = PentahoConnectionFactory.getConnection(dsType, session, logger);
assertNull(connection);
String connectStr = "connect-str";
connection = PentahoConnectionFactory.getConnection(dsType, connectStr, session, logger);
assertNull(connection);
String driver = "ds-driver";
String location = "location";
String userName = "username";
String password = "password";
connection = PentahoConnectionFactory.getConnection(dsType, driver, location, userName, password, session, logger);
assertNull(connection);
connection = PentahoConnectionFactory.getConnection(dsType, null, null, null, null, session, logger);
assertNull(connection);
}
use of org.pentaho.platform.api.engine.ILogger in project pentaho-platform by pentaho.
the class MicroPlatform method start.
@Override
public boolean start() throws PlatformInitializationException {
PentahoSystem.setSystemSettingsService(new PathBasedSystemSettings());
// initialize log4j to write to the console
BasicConfigurator.configure();
boolean ret = super.start();
// and other errors, not to mention it's inefficient
try {
Object o = PentahoSystem.get(ISolutionEngine.class);
if (o != null && o instanceof ILogger) {
((ILogger) o).setLoggingLevel(ILogger.DEBUG);
}
} catch (Throwable e) {
logger.error("Failed to set DEBUG log level due to ISolutionEngine not being available in MicroPlatform");
}
return ret;
}
Aggregations