return suite(BeanContainerStaticTestCase.class);
}
public void testStaticInjection() throws Throwable
{
StaticInjector injector = assertBean("StaticInjector", StaticInjector.class);
Class<StaticHolder> clazz = StaticHolder.class;
String string = "foobar";
Integer number = 123;
SecurityManager sm = suspendSecurity();
try
{
injector.injectToNonPublicMethod(clazz, "privMain", string, Object.class);
assertSame(string, StaticHolder.getPrivField());
injector.injectToNonPublicMethod(clazz, "protMain", string, Object.class);
assertSame(string, StaticHolder.getProtField());
injector.injectToMethod(clazz, "pubMain", string, Object.class);
assertSame(string, StaticHolder.pubField);
injector.injectToField(clazz, "privField", number);
assertSame(number, StaticHolder.getPrivField());
injector.injectToField(clazz, "protField", number);
assertSame(number, StaticHolder.getProtField());
injector.injectToField(clazz, "pubField", number);
assertSame(number, StaticHolder.pubField);
}
finally
{
resumeSecurity(sm);