use of com.adaptris.jdbc.JdbcResultRow in project interlok by adaptris.
the class StringColumnTranslatorTest method testAsFormattedDoubleTranslator.
@Test
public void testAsFormattedDoubleTranslator() throws Exception {
translator.setFormat("%f");
JdbcResultRow row = new JdbcResultRow();
row.setFieldValue("testField", new Double(111), Types.VARCHAR);
{
String translated = translator.translate(row, 0);
assertEquals("111.000000", translated);
}
{
String translated = translator.translate(row, "testField");
assertEquals("111.000000", translated);
}
}
use of com.adaptris.jdbc.JdbcResultRow in project interlok by adaptris.
the class StringColumnTranslatorTest method testStringWrite_ByName.
@Test
public void testStringWrite_ByName() throws Exception {
JdbcResultRow row = new JdbcResultRow();
row.setFieldValue("testField", "SomeData", Types.VARCHAR);
StringWriter writer = new StringWriter();
try (OutputStream out = new WriterOutputStream(writer)) {
translator.write(row, "testField", out);
}
String translated = writer.toString();
assertEquals("SomeData", translated);
}
use of com.adaptris.jdbc.JdbcResultRow in project interlok by adaptris.
the class TimestampColumnTranslatorTest method testGregorianNoFormat.
@Test
public void testGregorianNoFormat() throws Exception {
JdbcResultRow row = new JdbcResultRow();
row.setFieldValue("testField", gDate, Types.TIMESTAMP);
{
String translated = translator.translate(row, 0);
// starts with, being careful of timezone
assertTrue(translated.startsWith("2013-08-22"));
}
{
String translated = translator.translate(row, "testField");
// starts with, being careful of timezone
assertTrue(translated.startsWith("2013-08-22"));
}
}
use of com.adaptris.jdbc.JdbcResultRow in project interlok by adaptris.
the class TimestampColumnTranslatorTest method testDateFormatted.
@Test
public void testDateFormatted() throws Exception {
translator.setDateFormat("HH:mm");
JdbcResultRow row = new JdbcResultRow();
row.setFieldValue("testField", date, Types.TIMESTAMP);
{
String translated = translator.translate(row, 0);
assertEquals("12:12", translated);
}
{
String translated = translator.translate(row, "testField");
assertEquals("12:12", translated);
}
}
use of com.adaptris.jdbc.JdbcResultRow in project interlok by adaptris.
the class TimestampColumnTranslatorTest method testGregorianFormatted.
@Test
public void testGregorianFormatted() throws Exception {
translator.setDateFormat("HH:mm:ss");
JdbcResultRow row = new JdbcResultRow();
row.setFieldValue("testField", gDate, Types.TIMESTAMP);
{
String translated = translator.translate(row, 0);
assertEquals("12:12:12", translated);
}
{
String translated = translator.translate(row, "testField");
assertEquals("12:12:12", translated);
}
}
Aggregations