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());
}
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");
}
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");
}
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");
}
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());
}
Aggregations