}
public void testBooleanBit() throws Exception {
// populate (testing insert as well)
BitTestEntity trueObject = (BitTestEntity) context.newObject("BitTestEntity");
trueObject.setBitColumn(Boolean.TRUE);
BitTestEntity falseObject = (BitTestEntity) context.newObject("BitTestEntity");
falseObject.setBitColumn(Boolean.FALSE);
context.commitChanges();
// this will clear cache as a side effect
context = createDataContext();
// fetch true...
Expression trueQ = ExpressionFactory.matchExp("bitColumn", Boolean.TRUE);
List trueResult = context
.performQuery(new SelectQuery(BitTestEntity.class, trueQ));
assertEquals(1, trueResult.size());
BitTestEntity trueRefetched = (BitTestEntity) trueResult.get(0);
assertEquals(Boolean.TRUE, trueRefetched.getBitColumn());
// CAY-320. Simplifying the use of booleans to allow identity comparison.
assertNotSame(trueRefetched, trueObject);
assertSame(Boolean.TRUE, trueRefetched.getBitColumn());
// fetch false
Expression falseQ = ExpressionFactory.matchExp("bitColumn", Boolean.FALSE);
List falseResult = context.performQuery(new SelectQuery(
BitTestEntity.class,
falseQ));
assertEquals(1, falseResult.size());
BitTestEntity falseRefetched = (BitTestEntity) falseResult.get(0);
assertEquals(Boolean.FALSE, falseRefetched.getBitColumn());
// CAY-320. Simplifying the use of booleans to allow identity comparison.
assertNotSame(falseRefetched, falseObject);
assertSame(Boolean.FALSE, falseRefetched.getBitColumn());
}