Search in sources :

Example 1 with ILogger

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);
}
Also used : IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession) FilterPanelException(org.pentaho.platform.uifoundation.component.xml.FilterPanelException) Document(org.dom4j.Document) SimpleLogger(org.pentaho.platform.util.logging.SimpleLogger) FilterPanelException(org.pentaho.platform.uifoundation.component.xml.FilterPanelException) FilterPanel(org.pentaho.platform.uifoundation.component.xml.FilterPanel) FilterDefinition(org.pentaho.platform.uifoundation.component.FilterDefinition) ILogger(org.pentaho.platform.api.engine.ILogger) List(java.util.List) LinkedList(java.util.LinkedList) File(java.io.File) HashMap(java.util.HashMap) Map(java.util.Map)

Example 2 with ILogger

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");
    }
}
Also used : StaticQueryContext(net.sf.saxon.query.StaticQueryContext) XQConnection(org.pentaho.platform.plugin.services.connections.xquery.XQConnection) XPathException(net.sf.saxon.trans.XPathException) ILogger(org.pentaho.platform.api.engine.ILogger) Properties(java.util.Properties) XPathException(net.sf.saxon.trans.XPathException)

Example 3 with ILogger

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);
}
Also used : IPentahoConnection(org.pentaho.commons.connection.IPentahoConnection) IPentahoSession(org.pentaho.platform.api.engine.IPentahoSession) ILogger(org.pentaho.platform.api.engine.ILogger) Test(org.junit.Test)

Example 4 with ILogger

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;
}
Also used : ILogger(org.pentaho.platform.api.engine.ILogger) PathBasedSystemSettings(org.pentaho.platform.engine.core.system.PathBasedSystemSettings)

Aggregations

ILogger (org.pentaho.platform.api.engine.ILogger)4 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)2 File (java.io.File)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Map (java.util.Map)1 Properties (java.util.Properties)1 StaticQueryContext (net.sf.saxon.query.StaticQueryContext)1 XPathException (net.sf.saxon.trans.XPathException)1 Document (org.dom4j.Document)1 Test (org.junit.Test)1 IPentahoConnection (org.pentaho.commons.connection.IPentahoConnection)1 PathBasedSystemSettings (org.pentaho.platform.engine.core.system.PathBasedSystemSettings)1 XQConnection (org.pentaho.platform.plugin.services.connections.xquery.XQConnection)1 FilterDefinition (org.pentaho.platform.uifoundation.component.FilterDefinition)1 FilterPanel (org.pentaho.platform.uifoundation.component.xml.FilterPanel)1 FilterPanelException (org.pentaho.platform.uifoundation.component.xml.FilterPanelException)1 SimpleLogger (org.pentaho.platform.util.logging.SimpleLogger)1