Search in sources :

Example 16 with JdbcResultRow

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

the class ClobColumnTranslatorTest method testClobWrite_ByName.

@Test
public void testClobWrite_ByName() throws Exception {
    Clob clob = new TestClob("SomeData");
    JdbcResultRow row = new JdbcResultRow();
    row.setFieldValue("testField", clob, Types.CLOB);
    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) SerialClob(javax.sql.rowset.serial.SerialClob) Clob(java.sql.Clob) WriterOutputStream(org.apache.commons.io.output.WriterOutputStream) Test(org.junit.Test)

Example 17 with JdbcResultRow

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

the class ClobColumnTranslatorTest method testClobIncorrectType.

@Test
public void testClobIncorrectType() throws Exception {
    JdbcResultRow row = new JdbcResultRow();
    row.setFieldValue("testField", new Integer(999), Types.CLOB);
    try {
        translator.translate(row, 0);
        fail();
    } catch (Exception ex) {
    // pass, expected
    }
}
Also used : JdbcResultRow(com.adaptris.jdbc.JdbcResultRow) SQLException(java.sql.SQLException) Test(org.junit.Test)

Example 18 with JdbcResultRow

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

the class ClobColumnTranslatorTest method testClobToString.

@Test
public void testClobToString() throws Exception {
    Clob clob = new SerialClob("SomeData".toCharArray());
    JdbcResultRow row = new JdbcResultRow();
    row.setFieldValue("testField", clob, Types.CLOB);
    String translated = translator.translate(row, 0);
    assertEquals("SomeData", translated);
}
Also used : JdbcResultRow(com.adaptris.jdbc.JdbcResultRow) SerialClob(javax.sql.rowset.serial.SerialClob) SerialClob(javax.sql.rowset.serial.SerialClob) Clob(java.sql.Clob) Test(org.junit.Test)

Example 19 with JdbcResultRow

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

the class ClobColumnTranslatorTest method testClobToStringColumnName.

@Test
public void testClobToStringColumnName() throws Exception {
    Clob clob = new SerialClob("SomeData".toCharArray());
    JdbcResultRow row = new JdbcResultRow();
    row.setFieldValue("testField", clob, Types.CLOB);
    String translated = translator.translate(row, "testField");
    assertEquals("SomeData", translated);
}
Also used : JdbcResultRow(com.adaptris.jdbc.JdbcResultRow) SerialClob(javax.sql.rowset.serial.SerialClob) SerialClob(javax.sql.rowset.serial.SerialClob) Clob(java.sql.Clob) Test(org.junit.Test)

Example 20 with JdbcResultRow

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

the class ClobColumnTranslatorTest method testClobIncorrectTypeColumnName.

@Test
public void testClobIncorrectTypeColumnName() throws Exception {
    JdbcResultRow row = new JdbcResultRow();
    row.setFieldValue("testField", new Integer(999), Types.CLOB);
    try {
        translator.translate(row, "testField");
        fail();
    } catch (Exception ex) {
    // pass, expected
    }
}
Also used : JdbcResultRow(com.adaptris.jdbc.JdbcResultRow) SQLException(java.sql.SQLException) 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