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);
}
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"));
}
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())));
}
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())));
}
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));
}
Aggregations