public void testInstantiate_NonExistingGetter() throws Exception {
MockPersistenceDelegate pd = new MockPersistenceDelegate(new String[] {
"prop1", "non_existing" });
MockBean b = new MockBean();
b.setAll("bean1", 2);
Encoder enc = new Encoder();
ExceptionListener el = new ExceptionListener() {
public void exceptionThrown(Exception e) {
CallVerificationStack.getInstance().push(e);
}
};
enc.setExceptionListener(el);
Expression e = pd.instantiate(b, enc);
assertSame(b, e.getValue());
assertSame(MockBean.class, e.getTarget());
assertEquals("new", e.getMethodName());
assertEquals(2, e.getArguments().length);
assertSame(b.getProp1(), e.getArguments()[0]);
assertSame(null, e.getArguments()[1]);
assertTrue(CallVerificationStack.getInstance().pop() instanceof Exception);
enc.setExceptionListener(null);
assertNotNull(enc.getExceptionListener());
e = pd.instantiate(b, enc);
assertSame(b, e.getValue());
assertSame(MockBean.class, e.getTarget());
assertEquals("new", e.getMethodName());
assertEquals(2, e.getArguments().length);