Search in sources :

Example 1 with KettleLoggingEvent

use of org.pentaho.di.core.logging.KettleLoggingEvent in project pentaho-kettle by pentaho.

the class ValueMetaBaseTest method testSetPreparedStatementStringValueLogTruncated.

@Test
public void testSetPreparedStatementStringValueLogTruncated() throws KettleDatabaseException {
    ValueMetaBase valueMetaString = new ValueMetaBase("LOG_FIELD", ValueMetaInterface.TYPE_STRING, LOG_FIELD.length(), 0);
    DatabaseMeta databaseMeta = Mockito.mock(DatabaseMeta.class);
    PreparedStatement preparedStatement = Mockito.mock(PreparedStatement.class);
    Mockito.when(databaseMeta.getMaxTextFieldLength()).thenReturn(MAX_TEXT_FIELD_LEN);
    List<KettleLoggingEvent> events = listener.getEvents();
    assertEquals(0, events.size());
    valueMetaString.setPreparedStatementValue(databaseMeta, preparedStatement, 0, LOG_FIELD);
    // check that truncated string was logged
    assertEquals(1, events.size());
}
Also used : PreparedStatement(java.sql.PreparedStatement) KettleLoggingEvent(org.pentaho.di.core.logging.KettleLoggingEvent) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) NetezzaDatabaseMeta(org.pentaho.di.core.database.NetezzaDatabaseMeta) MySQLDatabaseMeta(org.pentaho.di.core.database.MySQLDatabaseMeta) Vertica5DatabaseMeta(org.pentaho.di.core.database.Vertica5DatabaseMeta) Test(org.junit.Test)

Example 2 with KettleLoggingEvent

use of org.pentaho.di.core.logging.KettleLoggingEvent in project pentaho-kettle by pentaho.

the class Log4jLoggingTest method eventAddedDetailed.

@Test
public void eventAddedDetailed() {
    log4jPlugin.eventAdded(new KettleLoggingEvent("DETAILED_TEST_MESSAGE", 0L, LogLevel.DETAILED));
    verify(logger).log(Level.INFO, "DETAILED_TEST_MESSAGE");
}
Also used : KettleLoggingEvent(org.pentaho.di.core.logging.KettleLoggingEvent) Test(org.junit.Test)

Example 3 with KettleLoggingEvent

use of org.pentaho.di.core.logging.KettleLoggingEvent in project pentaho-kettle by pentaho.

the class Log4jLoggingTest method eventAddedBasic.

@Test
public void eventAddedBasic() {
    log4jPlugin.eventAdded(new KettleLoggingEvent("BASIC_TEST_MESSAGE", 0L, LogLevel.BASIC));
    verify(logger).log(Level.INFO, "BASIC_TEST_MESSAGE");
}
Also used : KettleLoggingEvent(org.pentaho.di.core.logging.KettleLoggingEvent) Test(org.junit.Test)

Example 4 with KettleLoggingEvent

use of org.pentaho.di.core.logging.KettleLoggingEvent in project pentaho-kettle by pentaho.

the class Log4jLoggingTest method eventAddedMinimal.

@Test
public void eventAddedMinimal() {
    log4jPlugin.eventAdded(new KettleLoggingEvent("MINIMAL_TEST_MESSAGE", 0L, LogLevel.MINIMAL));
    verify(logger).log(Level.INFO, "MINIMAL_TEST_MESSAGE");
}
Also used : KettleLoggingEvent(org.pentaho.di.core.logging.KettleLoggingEvent) Test(org.junit.Test)

Example 5 with KettleLoggingEvent

use of org.pentaho.di.core.logging.KettleLoggingEvent in project pentaho-kettle by pentaho.

the class ValueMetaBaseTest method testSetPreparedStatementStringValueDontLogTruncated.

@Test
public void testSetPreparedStatementStringValueDontLogTruncated() throws KettleDatabaseException {
    ValueMetaBase valueMetaString = new ValueMetaBase("LOG_FIELD", ValueMetaInterface.TYPE_STRING, LOG_FIELD.length(), 0);
    DatabaseMeta databaseMeta = Mockito.mock(DatabaseMeta.class);
    PreparedStatement preparedStatement = Mockito.mock(PreparedStatement.class);
    Mockito.when(databaseMeta.getMaxTextFieldLength()).thenReturn(LOG_FIELD.length());
    List<KettleLoggingEvent> events = listener.getEvents();
    assertEquals(0, events.size());
    valueMetaString.setPreparedStatementValue(databaseMeta, preparedStatement, 0, LOG_FIELD);
    // no logging occurred as max string length equals to logging text length
    assertEquals(0, events.size());
}
Also used : PreparedStatement(java.sql.PreparedStatement) KettleLoggingEvent(org.pentaho.di.core.logging.KettleLoggingEvent) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) NetezzaDatabaseMeta(org.pentaho.di.core.database.NetezzaDatabaseMeta) MySQLDatabaseMeta(org.pentaho.di.core.database.MySQLDatabaseMeta) Vertica5DatabaseMeta(org.pentaho.di.core.database.Vertica5DatabaseMeta) Test(org.junit.Test)

Aggregations

KettleLoggingEvent (org.pentaho.di.core.logging.KettleLoggingEvent)10 Test (org.junit.Test)8 PreparedStatement (java.sql.PreparedStatement)2 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)2 MySQLDatabaseMeta (org.pentaho.di.core.database.MySQLDatabaseMeta)2 NetezzaDatabaseMeta (org.pentaho.di.core.database.NetezzaDatabaseMeta)2 Vertica5DatabaseMeta (org.pentaho.di.core.database.Vertica5DatabaseMeta)2 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 List (java.util.List)1 Timer (java.util.Timer)1 TimerTask (java.util.TimerTask)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 StyleRange (org.eclipse.swt.custom.StyleRange)1 DisposeEvent (org.eclipse.swt.events.DisposeEvent)1 DisposeListener (org.eclipse.swt.events.DisposeListener)1 MouseAdapter (org.eclipse.swt.events.MouseAdapter)1 MouseEvent (org.eclipse.swt.events.MouseEvent)1