assertEquals(MyCache.class, e.getActualType());
}
}
public void testSealedComponent(){
final Container yan = createYanContainer();
final Component c1 = Components.ctor(java.util.ArrayList.class, new Class[]{int.class});
yan.registerComponent("list", c1.seal());
yan.registerValue(new Integer(10));
try{
yan.getInstance("list");
fail ("should have failed with IrresolveableArgumentException");
}
catch(IrresolveableArgumentException e){}
yan.registerComponent("list", c1.seal().withArgument(0, Components.value(5)));
yan.getInstance("list");
//fail ("should have failed with IrresolveableArgumentException");
yan.registerComponent("list", c1);
yan.registerComponent("target", Components.useKey("list").seal()
.withArgument(0, Components.value(12)));
//try{
yan.getInstance("target");
//fail("should have failed with IrresolveableArgumentException");
//}
//catch(IrresolveableArgumentException e){}
//assertEquals(10, result.size());
yan.registerComponent("list", c1.withArgument(0,
Components.useArgument(Functions.ctor(
ArrayList.class, new Class[]{int.class}), 0, int.class)));
yan.registerComponent("target", Components.useKey("list").seal()
.withArgument(0, Components.value(12)));
//try{
yan.getInstance("target");
//fail("should have failed with IrresolveableArgumentException");
//}
//catch(IrresolveableArgumentException e){}
yan.registerComponent("list", c1.withArgument(0, Components.useType(int.class)));
yan.registerComponent("target", Components.useKey("list").seal()
.withArgument(0, Components.value(12)));
final java.util.ArrayList result = (ArrayList)yan.getInstance("target");
final Component array = Components.ctor(String[].class);
yan.registerComponent("array", array.withArgument(0, Components.useType(int.class)));
yan.registerComponent("target", Components.useKey("array").seal()
.withArgument(0, Components.value(12)));
final String[] arr = (String[])yan.getInstance("target");
assertEquals(10, arr.length);
final Component array2 = Components.ctor(int[].class, new Class[]{int.class});
yan.registerComponent("array", array2.withArgument(0, Components.useType(int.class)));
yan.registerComponent("target", Components.useKey("array").seal()
.withArgument(0, Components.value(12)));
final int[] arr2 = (int[])yan.getInstance("target");
assertEquals(10, arr2.length);
try{