@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()); }
@Test public void testLobHandling() throws Exception { ElementSymbol x = new ElementSymbol("x"); //$NON-NLS-1$ x.setType(DataTypeManager.DefaultDataClasses.CLOB); List<ElementSymbol> schema = Arrays.asList(x); TupleBuffer tb = BufferManagerFactory.getStandaloneBufferManager().createTupleBuffer(schema, "x", TupleSourceType.PROCESSOR); //$NON-NLS-1$ tb.setInlineLobs(false); ClobType c = new ClobType(new SerialClob(new char[0])); TupleBatch batch = new TupleBatch(1, new List[] {Arrays.asList(c)}); tb.addTupleBatch(batch, false); assertNotNull(tb.getLobReference(c.getReferenceStreamId())); }
@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()); }
Streamable<?>lob = lobManager.getLobReference(clob.getReferenceStreamId()); assertTrue(lob.getClass().isAssignableFrom(ClobType.class)); ClobType clobRead = (ClobType)lob;