Search in sources :

Example 46 with SerialBlob

use of javax.sql.rowset.serial.SerialBlob in project teiid by teiid.

the class TestFunctionLibrary method testToChars2.

@Test
public void testToChars2() throws Exception {
    // $NON-NLS-1$
    Clob result = (Clob) helpInvokeMethod("to_chars", new Class<?>[] { DefaultDataClasses.BLOB, DefaultDataClasses.STRING }, new Object[] { new BlobType(new SerialBlob("hello world".getBytes("ASCII"))), "HEX" }, null);
    String string = result.getSubString(1, (int) result.length());
    assertEquals("68656C6C6F20776F726C64", string);
}
Also used : BlobType(org.teiid.core.types.BlobType) SerialBlob(javax.sql.rowset.serial.SerialBlob) Clob(java.sql.Clob) SerialClob(javax.sql.rowset.serial.SerialClob) Test(org.junit.Test)

Example 47 with SerialBlob

use of javax.sql.rowset.serial.SerialBlob in project teiid by teiid.

the class TestFunctionLibrary method testToChars1.

@Test
public void testToChars1() throws Exception {
    // $NON-NLS-1$
    Clob result = (Clob) helpInvokeMethod("to_chars", new Class<?>[] { DefaultDataClasses.BLOB, DefaultDataClasses.STRING }, new Object[] { new BlobType(new SerialBlob("hello world".getBytes("ASCII"))), "BASE64" }, null);
    String string = result.getSubString(1, (int) result.length());
    assertEquals("hello world", new String(Base64.decode(string), "ASCII"));
}
Also used : BlobType(org.teiid.core.types.BlobType) SerialBlob(javax.sql.rowset.serial.SerialBlob) Clob(java.sql.Clob) SerialClob(javax.sql.rowset.serial.SerialClob) Test(org.junit.Test)

Example 48 with SerialBlob

use of javax.sql.rowset.serial.SerialBlob in project teiid by teiid.

the class TestBlobValue method testBlobValue.

public void testBlobValue() throws Exception {
    // $NON-NLS-1$
    String testString = "this is test blob";
    SerialBlob blob = new SerialBlob(testString.getBytes());
    BlobType bv = new BlobType(blob);
    assertEquals(testString, new String(bv.getBytes(1L, (int) bv.length())));
}
Also used : SerialBlob(javax.sql.rowset.serial.SerialBlob)

Example 49 with SerialBlob

use of javax.sql.rowset.serial.SerialBlob in project teiid by teiid.

the class TestBlobValue method testReferencePersistence.

@Test
public void testReferencePersistence() throws Exception {
    // $NON-NLS-1$
    String testString = "this is test clob";
    SerialBlob blob = new SerialBlob(testString.getBytes());
    BlobType bv = new BlobType(blob);
    bv.setReferenceStreamId(null);
    // now force to serialize
    BlobType read = UnitTestUtil.helpSerialize(bv);
    assertNull(read.getReferenceStreamId());
    assertEquals(testString, new String(read.getBytes(1, (int) blob.length())));
}
Also used : SerialBlob(javax.sql.rowset.serial.SerialBlob) Test(org.junit.Test)

Example 50 with SerialBlob

use of javax.sql.rowset.serial.SerialBlob in project teiid by teiid.

the class TestDataTypeManager method testRuntimeTypeConversion.

@Test
public void testRuntimeTypeConversion() throws Exception {
    assertNull(DataTypeManager.convertToRuntimeType(null, true));
    assertTrue(DataTypeManager.convertToRuntimeType(new SerialBlob(new byte[0]), true) instanceof BlobType);
    // unknown type should return as same
    Object foo = new Object();
    assertEquals(foo, DataTypeManager.convertToRuntimeType(foo, true));
    // known type should return as same
    Integer bar = new Integer(1);
    assertEquals(bar, DataTypeManager.convertToRuntimeType(bar, true));
}
Also used : SerialBlob(javax.sql.rowset.serial.SerialBlob) Test(org.junit.Test)

Aggregations

SerialBlob (javax.sql.rowset.serial.SerialBlob)52 Test (org.testng.annotations.Test)32 BaseTest (util.BaseTest)32 StubBlob (util.StubBlob)16 InputStream (java.io.InputStream)11 SerialClob (javax.sql.rowset.serial.SerialClob)8 Test (org.junit.Test)8 BlobType (org.teiid.core.types.BlobType)7 Clob (java.sql.Clob)6 SQLException (java.sql.SQLException)6 IOException (java.io.IOException)5 Blob (java.sql.Blob)5 BigDecimal (java.math.BigDecimal)3 BlobImpl (org.teiid.core.types.BlobImpl)3 OutputStream (java.io.OutputStream)2 Reader (java.io.Reader)2 SQLXML (java.sql.SQLXML)2 Time (java.sql.Time)2 Timestamp (java.sql.Timestamp)2 SerialArray (javax.sql.rowset.serial.SerialArray)2