public void testSerialize() throws Exception { ServiceInvocationStruct struct = new ServiceInvocationStruct(new Object[] {new Integer(1), "hello"}, "doSomething", TestServiceInvocationStruct.class); Object serialized = UnitTestUtil.helpSerialize(struct); assertNotNull(serialized); assertTrue(serialized instanceof ServiceInvocationStruct); ServiceInvocationStruct copy = (ServiceInvocationStruct)serialized; assertTrue(Arrays.equals(struct.args, copy.args)); assertEquals(struct.methodName, copy.methodName); assertEquals(struct.targetClass, copy.targetClass); } }
public void testSerialization() throws Exception { String testString = "This is test string for testing ByteLobChunk"; //$NON-NLS-1$ LobChunk chunk = new LobChunk(testString.getBytes(), true); LobChunk result = UnitTestUtil.helpSerialize(chunk); assertTrue(Arrays.equals(chunk.getBytes(), result.getBytes())); assertTrue(result.isLast()); }
@Test public void testSerialize() throws Exception { ArrayImpl a1 = new ArrayImpl((Object[])new Integer[] {1, 2, 3}); a1 = UnitTestUtil.helpSerialize(a1); assertEquals(1, a1.getValues()[0]); } }
@Test public void testReferencePersistence() throws Exception { String testString = "this is test clob"; //$NON-NLS-1$ 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()))); }
@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())); }
public void testBlobValuePersistence() throws Exception { String testString = "this is test clob"; //$NON-NLS-1$ SerialBlob blob = new SerialBlob(testString.getBytes()); BlobType bv = new BlobType(blob); String key = bv.getReferenceStreamId(); // now force to serialize BlobType read = UnitTestUtil.helpSerialize(bv); // make sure we have kept the reference stream id assertEquals(key, read.getReferenceStreamId()); // and lost the original object assertNull(read.getReference()); }
@Test public void testReferencePersistence() throws Exception { String testString = "<foo>this is an xml value test</foo>"; //$NON-NLS-1$ SQLXMLImpl xml = new SQLXMLImpl(testString); XMLType xv = new XMLType(xml); xv.setReferenceStreamId(null); // now force to serialize XMLType read = UnitTestUtil.helpSerialize(xv); assertEquals(testString, read.getString()); }
public void testDelayedDeserialization() throws Exception { ResultsMessage message = example(); message.setDelayDeserialization(true); ResultsMessage copy = UnitTestUtil.helpSerialize(message); assertNull(copy.getResultsList()); copy.processResults(); assertNotNull(copy.getResultsList()); }
public void testSerialize1() throws Exception { RequestID copy = UnitTestUtil.helpSerialize(new RequestID("1", 100)); //$NON-NLS-1$ assertEquals("1", copy.getConnectionID()); //$NON-NLS-1$ assertEquals(100, copy.getExecutionID()); assertEquals("1.100", copy.toString()); //$NON-NLS-1$ }
public void testSerialize2() throws Exception { RequestID copy = UnitTestUtil.helpSerialize(new RequestID(100)); assertEquals(null, copy.getConnectionID()); assertEquals(100, copy.getExecutionID()); assertEquals("C.100", copy.toString()); //$NON-NLS-1$ }
@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()); }
@Test public void testXMLValuePersistence() throws Exception { String testString = "<foo>this is an xml value test</foo>"; //$NON-NLS-1$ SQLXMLImpl xml = new SQLXMLImpl(testString); XMLType xv = new XMLType(xml); String key = xv.getReferenceStreamId(); // now force to serialize XMLType read = UnitTestUtil.helpSerialize(xv); // make sure we have kept the reference stream id assertEquals(key, read.getReferenceStreamId()); // and lost the original object assertNull(read.getReference()); }
@Test public void testSerialize() throws Exception { RequestMessage copy = UnitTestUtil.helpSerialize(example()); assertTrue(copy.isCallableStatement()); assertEquals(100, copy.getFetchSize()); assertNotNull(copy.getParameterValues()); assertEquals(4, copy.getParameterValues().size()); assertEquals(new Integer(100), copy.getParameterValues().get(0)); assertEquals(new Integer(200), copy.getParameterValues().get(1)); assertEquals(new Integer(300), copy.getParameterValues().get(2)); assertEquals(new Integer(400), copy.getParameterValues().get(3)); assertFalse(copy.isPreparedStatement()); assertEquals("myStyleSheet", copy.getStyleSheet()); //$NON-NLS-1$ assertEquals("myExecutionPayload", copy.getExecutionPayload()); //$NON-NLS-1$ assertEquals(RequestMessage.TXN_WRAP_ON, copy.getTxnAutoWrapMode()); assertEquals(ShowPlan.ON, copy.getShowPlan()); assertEquals(1313, copy.getRowLimit()); assertTrue(copy.isReturnAutoGeneratedKeys()); assertTrue(copy.isDelaySerialization()); assertEquals("foo", copy.getSpanContext()); }
public void testSerialize() throws Exception { ResultsMessage message = example(); ResultsMessage copy = UnitTestUtil.helpSerialize(message);
@Test public void testTypeCorrection() throws Exception { MetadataFactory mf = new MetadataFactory(null, 1, "x", SystemMetadata.getInstance().getRuntimeTypeMap(), new Properties(), null); //$NON-NLS-1$ Table t = mf.addTable("y"); //$NON-NLS-1$ mf.addColumn("test", "string", t); mf.addColumn("array", "string[]", t); Datatype unknown = new Datatype(); unknown.setName("unknown"); Column col = mf.addColumn("arg", "string", t); col.setDatatype(unknown, false, 0); MetadataFactory mf1 = UnitTestUtil.helpSerialize(mf); Column column = mf1.getSchema().getTable("y").getColumns().get(0); Datatype dt = column.getDatatype(); assertNotSame(mf.getDataTypes().get(dt.getName()), column.getDatatype()); assertEquals(1, mf1.getSchema().getTable("y").getColumns().get(1).getArrayDimensions()); mf1.correctDatatypes(mf.getDataTypes()); assertSame(mf.getDataTypes().get(dt.getName()), column.getDatatype()); assertEquals(1, mf1.getSchema().getTable("y").getColumns().get(1).getArrayDimensions()); }
@Test public void testSerialize() throws Exception { DQPWorkContext copy = UnitTestUtil.helpSerialize(example()); assertEquals("5", copy.getSessionId()); //$NON-NLS-1$ assertEquals("userName", copy.getUserName()); //$NON-NLS-1$ assertEquals("vdbName", copy.getVdbName()); //$NON-NLS-1$ assertEquals("1", copy.getVdbVersion()); //$NON-NLS-1$ assertEquals("querybuilder", copy.getAppName()); //$NON-NLS-1$ }
CachedResults cachedResults = UnitTestUtil.helpSerialize(results);