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