@Test
public void createConstructorArg_BeanFactory() throws Exception {
BeanFactory context = createMock(BeanFactory.class);
// not ApplicationContext or ConfigurableBeanFactory, required
ConstructorArg arg = new ConstructorArg(MyClass.class.getConstructors()[0], HttpServletRequest.class, 0, true);
arg.setBeanFactory(context);
try {
arg.getObject();
fail();
} catch (IllegalArgumentException e) {
assertThat(e, exception("could not get object of " + HttpServletRequest.class.getName()
+ ": no Application Context"));
}
// not ApplicationContext or ConfigurableBeanFactory, optional
arg = new ConstructorArg(MyClass.class.getConstructors()[0], HttpServletRequest.class, 0, false);
arg.setBeanFactory(context);
assertNull(arg.getObject());
}