}
@Test
public void testNullValues() {
IPredicate predicate = new OperatorPredicate(PERSON_LAST_NAME, OperatorPredicate.Operator.EQ, "Jones");
IResultSet resultSet = storageSource.executeQuery(PERSON_TABLE_NAME, null, predicate, new RowOrdering(PERSON_SSN));
while (resultSet.next()) {
resultSet.setNull(PERSON_FIRST_NAME);
resultSet.setIntegerObject(PERSON_AGE, null);
}
resultSet.save();
resultSet.close();
resultSet = storageSource.executeQuery(PERSON_TABLE_NAME, null, predicate, new RowOrdering(PERSON_SSN));
int count = 0;
while (resultSet.next()) {
boolean checkNull = resultSet.isNull(PERSON_FIRST_NAME);
assertTrue(checkNull);
String s = resultSet.getString(PERSON_FIRST_NAME);
assertEquals(s, null);
checkNull = resultSet.isNull(PERSON_AGE);
assertTrue(checkNull);
Integer intObj = resultSet.getIntegerObject(PERSON_AGE);
assertEquals(intObj, null);
Short shortObj = resultSet.getShortObject(PERSON_AGE);
assertEquals(shortObj, null);
boolean excThrown = false;
try {
resultSet.getInt(PERSON_AGE);
}
catch (NullValueStorageException exc) {
excThrown = true;
}
assertTrue(excThrown);
count++;
}
resultSet.close();
assertEquals(count, 2);
predicate = new OperatorPredicate(PERSON_FIRST_NAME, OperatorPredicate.Operator.EQ, null);
resultSet = storageSource.executeQuery(PERSON_TABLE_NAME, null, predicate, new RowOrdering(PERSON_SSN));
count = 0;
while (resultSet.next()) {
boolean checkNull = resultSet.isNull(PERSON_FIRST_NAME);
assertTrue(checkNull);