@Test public void testClobValue() throws Exception { String testString = "this is test clob"; //$NON-NLS-1$ SerialClob clob = new SerialClob(testString.toCharArray()); ClobType cv = new ClobType(clob); assertEquals(testString, cv.getSubString(1L, (int)cv.length())); }
@Test public void testReferencePersistence() throws Exception { String testString = "this is test clob"; //$NON-NLS-1$ SerialClob clob = new SerialClob(testString.toCharArray()); ClobType cv = new ClobType(clob); cv.setReferenceStreamId(null); // now force to serialize ClobType read = UnitTestUtil.helpSerialize(cv); assertTrue(read.length() > 0); assertEquals(testString, read.getSubString(1, testString.length())); }
@Test public void testClobValuePersistence() throws Exception { String testString = "this is test clob"; //$NON-NLS-1$ SerialClob clob = new SerialClob(testString.toCharArray()); ClobType cv = new ClobType(clob); String key = cv.getReferenceStreamId(); // now force to serialize ClobType read = UnitTestUtil.helpSerialize(cv); assertTrue(read.length() > 0); // make sure we have kept the reference stream id assertEquals(key, read.getReferenceStreamId()); // and lost the original object assertNull(read.getReference()); }
@SuppressWarnings("serial") @Test public void testReferencePersistenceError() throws Exception { String testString = "this is test clob"; //$NON-NLS-1$ SerialClob clob = new SerialClob(testString.toCharArray()) { @Override public Reader getCharacterStream() throws SerialException { throw new SerialException(); } }; ClobType cv = new ClobType(clob); cv.setReferenceStreamId(null); // now force to serialize ClobType read = UnitTestUtil.helpSerialize(cv); assertTrue(read.length() > 0); assertNotNull(read.getReferenceStreamId()); assertNull(read.getReference()); }
ClobType clobRead = (ClobType)lob; assertEquals(ClobType.getString(clob), ClobType.getString(clobRead)); assertTrue(clobRead.length() != -1);
((ClobType)lob).setReference(new ClobImpl(isf, ((ClobType)lob).length()));