this.name = name;
}
}
public void testTypeMismatchForPropertyAndParameter()
throws Exception{
final Container yan = createYanContainer();
yan.registerComponent(
Components.ctor(PersonBean.class, new Class[]{String.class})
.withArgument(0, Components.value(new int[0])));
try{
yan.verify();
fail("should have type failed");
}
catch(ParameterTypeMismatchException e){
assertEquals(2, e.getResolutionTrace().size());
assertParameter(e, 0, Functions.ctor(PersonBean.class, new Class[]{String.class}),
0);
assertEquals(PersonBean.class, e.getComponentKey());
assertEquals(0, e.getOrdinalPosition());
assertEquals(String.class, e.getExpectedType());
assertEquals(int[].class, e.getActualType());
}
//yan.verify();
final HashMap props = new HashMap();
props.put("name", Components.ctor(ArrayList.class, null));
yan.registerComponent(Components.bean(PersonBean.class)
.withProperties(props));
try{
yan.verify();
fail("should have type failed");
}
catch(PropertyTypeMismatchException e){
//e.printResolutionTrace(System.err);
assertEquals(3, e.getResolutionTrace().size());