message.setWarnings(warnings);
return message;
}
public void testSerialize() throws Exception {
ResultsMessage message = example();
ResultsMessage copy = UnitTestUtil.helpSerialize(message);
assertNotNull(copy.getColumnNames());
assertEquals(4, copy.getColumnNames().length);
assertEquals("A", copy.getColumnNames()[0]); //$NON-NLS-1$
assertEquals("B", copy.getColumnNames()[1]); //$NON-NLS-1$
assertEquals("C", copy.getColumnNames()[2]); //$NON-NLS-1$
assertEquals("D", copy.getColumnNames()[3]); //$NON-NLS-1$
assertNotNull(copy.getDataTypes());
assertEquals(4, copy.getDataTypes().length);
assertEquals(DataTypeManager.DefaultDataTypes.BIG_INTEGER, copy.getDataTypes()[0]);
assertEquals(DataTypeManager.DefaultDataTypes.BIG_INTEGER, copy.getDataTypes()[1]);
assertEquals(DataTypeManager.DefaultDataTypes.BIG_INTEGER, copy.getDataTypes()[2]);
assertEquals(DataTypeManager.DefaultDataTypes.BIG_INTEGER, copy.getDataTypes()[3]);
assertEquals(200, copy.getFinalRow());
assertEquals(1, copy.getFirstRow());
assertEquals(100, copy.getLastRow());
assertNotNull(copy.getParameters());
assertEquals(2, copy.getParameters().size());
ParameterInfo info1 = (ParameterInfo) copy.getParameters().get(0);
assertEquals(ParameterInfo.IN, info1.getType());
assertEquals(0, info1.getNumColumns());
ParameterInfo info2 = (ParameterInfo) copy.getParameters().get(1);
assertEquals(ParameterInfo.RESULT_SET, info2.getType());
assertEquals(5, info2.getNumColumns());
assertNotNull(copy.getPlanDescription());
assertEquals(4, copy.getPlanDescription().getProperties().size());
assertNotNull(copy.getResults());
assertEquals(1, copy.getResults().length);
assertNotNull(copy.getResults()[0]);
assertEquals(4, copy.getResults()[0].size());
assertEquals(new BigInteger("100"), copy.getResults()[0].get(0)); //$NON-NLS-1$
assertEquals(new BigInteger("200"), copy.getResults()[0].get(1)); //$NON-NLS-1$
assertEquals(new BigInteger("300"), copy.getResults()[0].get(2)); //$NON-NLS-1$
assertEquals(new BigInteger("400"), copy.getResults()[0].get(3)); //$NON-NLS-1$
assertNotNull(copy.getWarnings());
assertEquals(2, copy.getWarnings().size());
assertEquals(Exception.class, copy.getWarnings().get(0).getClass());
assertEquals("warning1", ((Exception)copy.getWarnings().get(0)).getMessage()); //$NON-NLS-1$
assertEquals(Exception.class, copy.getWarnings().get(1).getClass());
assertEquals("warning2", ((Exception)copy.getWarnings().get(1)).getMessage()); //$NON-NLS-1$
}