}
@Test
public void question_dot_operator_for_object_type()
{
InternalPropertyConduit normal = (InternalPropertyConduit) source.create(CompositeBean.class,
"simple.firstName");
InternalPropertyConduit smart = (InternalPropertyConduit) source.create(CompositeBean.class,
"simple?.firstName");
CompositeBean bean = new CompositeBean();
bean.setSimple(null);
assertEquals(normal.getPropertyName(), "firstName");
assertEquals(smart.getPropertyName(), "firstName");
try
{
normal.get(bean);
unreachable();
} catch (NullPointerException ex)
{
// Expected.
}
assertNull(smart.get(bean));
try
{
normal.set(bean, "Howard");
unreachable();
} catch (NullPointerException ex)
{
// Expected.
}
// This will be a no-op due to the null property in the expression
smart.set(bean, "Howard");
}