use of com.adaptris.jdbc.JdbcResultRow in project interlok by adaptris.
the class BlobColumnTranslatorTest method testBlobToString.
@Test
public void testBlobToString() 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);
String translated = translator.translate(row, 0);
assertEquals("SomeData", translated);
}
use of com.adaptris.jdbc.JdbcResultRow in project interlok by adaptris.
the class BlobColumnTranslatorTest method testBlobToStringWrongType.
@Test
public void testBlobToStringWrongType() throws Exception {
BlobColumnTranslator translator = new BlobColumnTranslator();
JdbcResultRow row = new JdbcResultRow();
row.setFieldValue("testField", "SomeData", Types.BLOB);
try {
translator.translate(row, "testField");
fail();
} catch (Exception ex) {
// pass, expected
}
}
use of com.adaptris.jdbc.JdbcResultRow in project interlok by adaptris.
the class BlobColumnTranslatorTest method testBlobToString_WithEncoding.
@Test
public void testBlobToString_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);
String translated = translator.translate(row, 0);
assertEquals("SomeData", translated);
}
use of com.adaptris.jdbc.JdbcResultRow in project interlok by adaptris.
the class BlobColumnTranslatorTest method testBlobWrite.
@Test
public void testBlobWrite() 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, 0, out);
}
String translated = writer.toString();
assertEquals("SomeData", translated);
}
use of com.adaptris.jdbc.JdbcResultRow in project interlok by adaptris.
the class BlobColumnTranslatorTest method testBlobToStringWithColumnName.
@Test
public void testBlobToStringWithColumnName() 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);
String translated = translator.translate(row, "testField");
assertEquals("SomeData", translated);
}
Aggregations