use of com.adaptris.jdbc.JdbcResultRow in project interlok by adaptris.
the class BlobColumnTranslatorTest method testBlobWrite_WithEncoding.
@Test
public void testBlobWrite_WithEncoding() throws Exception {
BlobColumnTranslator translator = new BlobColumnTranslator("UTF-8");
TestBlob blob = new TestBlob();
String myData = new String("SomeData");
blob.setBytes(0, myData.getBytes("UTF-8"));
JdbcResultRow row = new JdbcResultRow();
row.setFieldValue("testField", blob, Types.BLOB);
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 BlobColumnTranslatorTest method testBlobWrite_ColumnName.
@Test
public void testBlobWrite_ColumnName() throws Exception {
BlobColumnTranslator translator = new BlobColumnTranslator();
TestBlob blob = new TestBlob();
String myData = new String("SomeData");
blob.setBytes(0, myData.getBytes());
JdbcResultRow row = new JdbcResultRow();
row.setFieldValue("testField", blob, Types.BLOB);
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 BooleanColumnTranslatorTest method testTrueBool.
@Test
public void testTrueBool() throws Exception {
JdbcResultRow row = new JdbcResultRow();
boolean val = true;
row.setFieldValue("testField", val, Types.BOOLEAN);
String translated = translator.translate(row, 0);
assertEquals("true", translated);
}
use of com.adaptris.jdbc.JdbcResultRow in project interlok by adaptris.
the class BooleanColumnTranslatorTest method testTrueString.
@Test
public void testTrueString() throws Exception {
JdbcResultRow row = new JdbcResultRow();
row.setFieldValue("testField", "true", Types.BOOLEAN);
String translated = translator.translate(row, 0);
assertEquals("true", translated);
}
use of com.adaptris.jdbc.JdbcResultRow in project interlok by adaptris.
the class ByteArrayColumnTranslatorTest method testByteIncorrectObject.
@Test
public void testByteIncorrectObject() throws Exception {
JdbcResultRow row = new JdbcResultRow();
row.setFieldValue("testField", new Integer(10), Types.ARRAY);
try {
translator.translate(row, "testField");
fail();
} catch (Exception ex) {
// pass, expected
}
}
Aggregations