import com.google.common.base.Function;
import com.google.common.base.Splitter;
+import com.google.common.base.Throwables;
import com.google.common.collect.Iterables;
import java.sql.SQLException;
import java.util.Date;
}
return FileSourceDto.encodeSourceData(dataBuilder.build());
} catch (Exception e) {
- Loggers.get(FeedFileSourcesBinaryData.class).error(
- String.format("Invalid FILE_SOURCES.DATA on row with ID %s, data will be ignored: %s", fileSourceId, data), e);
+ Loggers.get(FeedFileSourcesBinaryData.class).debug(
+ "Invalid FILE_SOURCES.DATA on row with ID {}, data will be ignored. {}", fileSourceId, Throwables.getStackTraceAsString(e));
return FileSourceDto.encodeSourceData(dataBuilder.clear().build());
} finally {
IOUtils.closeQuietly(parser);
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.util.List;
import org.apache.commons.dbutils.DbUtils;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonar.api.utils.System2;
+import org.sonar.api.utils.log.LogTester;
+import org.sonar.api.utils.log.LoggerLevel;
import org.sonar.db.DbTester;
import org.sonar.db.protobuf.DbFileSources;
import org.sonar.db.source.FileSourceDto;
@Rule
public DbTester db = DbTester.createForSchema(System2.INSTANCE, FeedFileSourcesBinaryDataTest.class, "schema.sql");
+ @Rule
+ public LogTester logTester = new LogTester().setLevel(LoggerLevel.DEBUG);
+
@Test
public void convert_csv_to_protobuf() throws Exception {
db.prepareDbUnit(getClass(), "data.xml");
DbFileSources.Data data = selectData(connection, 1L);
assertThat(data.getLinesList()).isEmpty();
+ List<String> debugLogs = logTester.logs(LoggerLevel.DEBUG);
+ assertThat(debugLogs.stream()
+ .anyMatch(s -> s.startsWith("Invalid FILE_SOURCES.DATA on row with ID 1, data will be ignored"))).isTrue();
}
}