use of com.adaptris.jdbc.JdbcResultRow in project interlok by adaptris.
the class IntegerColumnTranslatorTest method testFormattedInteger.
@Test
public void testFormattedInteger() throws Exception {
translator.setFormat("%05d");
Integer intVal = Integer.valueOf("123");
JdbcResultRow row = new JdbcResultRow();
row.setFieldValue("testField", intVal, Types.INTEGER);
{
String translated = translator.translate(row, 0);
assertEquals(expected, translated);
}
{
String translated = translator.translate(row, "testField");
assertEquals(expected, translated);
}
}
use of com.adaptris.jdbc.JdbcResultRow in project interlok by adaptris.
the class IntegerColumnTranslatorTest method testFormattedFloat.
@Test
public void testFormattedFloat() throws Exception {
translator.setFormat("%05d");
Float intVal = Float.valueOf("123");
JdbcResultRow row = new JdbcResultRow();
row.setFieldValue("testField", intVal, Types.INTEGER);
try {
translator.translate(row, 0);
fail();
} catch (Exception ex) {
// expected
}
try {
translator.translate(row, "testField");
fail();
} catch (Exception ex) {
// expected
}
}
use of com.adaptris.jdbc.JdbcResultRow in project interlok by adaptris.
the class StringColumnTranslatorTest method testStringWrite.
@Test
public void testStringWrite() 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, 0, out);
}
String translated = writer.toString();
assertEquals("SomeData", translated);
}
use of com.adaptris.jdbc.JdbcResultRow in project interlok by adaptris.
the class StringColumnTranslatorTest method testAsByteTranslator.
@Test
public void testAsByteTranslator() throws Exception {
JdbcResultRow row = new JdbcResultRow();
row.setFieldValue("testField", "111".getBytes(), Types.VARCHAR);
{
String translated = translator.translate(row, 0);
assertEquals("111", translated);
}
{
String translated = translator.translate(row, "testField");
assertEquals("111", translated);
}
}
use of com.adaptris.jdbc.JdbcResultRow in project interlok by adaptris.
the class StringColumnTranslatorTest method testStringTranslator.
@Test
public void testStringTranslator() throws Exception {
JdbcResultRow row = new JdbcResultRow();
row.setFieldValue("testField", "111", Types.VARCHAR);
{
String translated = translator.translate(row, 0);
assertEquals("111", translated);
}
{
String translated = translator.translate(row, "testField");
assertEquals("111", translated);
}
}
Aggregations