Search in sources :

Example 41 with JdbcResultRow

use of com.adaptris.jdbc.JdbcResultRow in project interlok by adaptris.

the class ByteArrayColumnTranslatorTest method testByteToStringEncoded.

@Test
public void testByteToStringEncoded() throws Exception {
    JdbcResultRow row = new JdbcResultRow();
    row.setFieldValue("testField", "SomeData".getBytes("UTF-8"), Types.ARRAY);
    String translated = translator.translate(row, 0);
    assertEquals("SomeData", translated);
}
Also used : JdbcResultRow(com.adaptris.jdbc.JdbcResultRow) Test(org.junit.Test)

Example 42 with JdbcResultRow

use of com.adaptris.jdbc.JdbcResultRow in project interlok by adaptris.

the class ByteArrayColumnTranslatorTest method testBytesWrite.

@Test
public void testBytesWrite() throws Exception {
    JdbcResultRow row = new JdbcResultRow();
    row.setFieldValue("testField", "SomeData".getBytes(), Types.ARRAY);
    StringWriter writer = new StringWriter();
    try (OutputStream out = new WriterOutputStream(writer)) {
        translator.write(row, 0, out);
    }
    String translated = writer.toString();
    assertEquals("SomeData", translated);
}
Also used : StringWriter(java.io.StringWriter) JdbcResultRow(com.adaptris.jdbc.JdbcResultRow) OutputStream(java.io.OutputStream) WriterOutputStream(org.apache.commons.io.output.WriterOutputStream) WriterOutputStream(org.apache.commons.io.output.WriterOutputStream) Test(org.junit.Test)

Example 43 with JdbcResultRow

use of com.adaptris.jdbc.JdbcResultRow in project interlok by adaptris.

the class ByteArrayColumnTranslatorTest method testByteToStringColName.

@Test
public void testByteToStringColName() throws Exception {
    JdbcResultRow row = new JdbcResultRow();
    row.setFieldValue("testField", "SomeData".getBytes(), Types.ARRAY);
    String translated = translator.translate(row, "testField");
    assertEquals("SomeData", translated);
}
Also used : JdbcResultRow(com.adaptris.jdbc.JdbcResultRow) Test(org.junit.Test)

Example 44 with JdbcResultRow

use of com.adaptris.jdbc.JdbcResultRow in project interlok by adaptris.

the class ByteArrayColumnTranslatorTest method testBytesWrite_ByName.

@Test
public void testBytesWrite_ByName() throws Exception {
    JdbcResultRow row = new JdbcResultRow();
    row.setFieldValue("testField", "SomeData".getBytes(), Types.ARRAY);
    StringWriter writer = new StringWriter();
    try (OutputStream out = new WriterOutputStream(writer)) {
        translator.write(row, "testField", out);
    }
    String translated = writer.toString();
    assertEquals("SomeData", translated);
}
Also used : StringWriter(java.io.StringWriter) JdbcResultRow(com.adaptris.jdbc.JdbcResultRow) OutputStream(java.io.OutputStream) WriterOutputStream(org.apache.commons.io.output.WriterOutputStream) WriterOutputStream(org.apache.commons.io.output.WriterOutputStream) Test(org.junit.Test)

Example 45 with JdbcResultRow

use of com.adaptris.jdbc.JdbcResultRow in project interlok by adaptris.

the class ByteArrayColumnTranslatorTest method testByteToString.

@Test
public void testByteToString() throws Exception {
    JdbcResultRow row = new JdbcResultRow();
    row.setFieldValue("testField", "SomeData".getBytes(), Types.ARRAY);
    String translated = translator.translate(row, 0);
    assertEquals("SomeData", translated);
}
Also used : JdbcResultRow(com.adaptris.jdbc.JdbcResultRow) Test(org.junit.Test)

Aggregations

JdbcResultRow (com.adaptris.jdbc.JdbcResultRow)69 Test (org.junit.Test)65 OutputStream (java.io.OutputStream)9 StringWriter (java.io.StringWriter)9 WriterOutputStream (org.apache.commons.io.output.WriterOutputStream)9 SQLException (java.sql.SQLException)5 Clob (java.sql.Clob)4 SerialClob (javax.sql.rowset.serial.SerialClob)4 JdbcResultSet (com.adaptris.jdbc.JdbcResultSet)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 ArrayList (java.util.ArrayList)3 CoreException (com.adaptris.core.CoreException)2 MetadataElement (com.adaptris.core.MetadataElement)2 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)1 ServiceException (com.adaptris.core.ServiceException)1 NoSuchElementException (java.util.NoSuchElementException)1 Document (org.w3c.dom.Document)1 Element (org.w3c.dom.Element)1