* @throws Exception
*/
@Test
public void testFactory() throws Exception
{
SpringBeanLocator locator;
Object proxy;
Field field = obj.getClass().getDeclaredField("nobean");
proxy = factory.getFieldValue(field, obj);
assertNull(proxy);
field = obj.getClass().getDeclaredField("beanByClass");
proxy = factory.getFieldValue(field, obj);
locator = (SpringBeanLocator)((ILazyInitProxy)proxy).getObjectLocator();
assertTrue(locator.getBeanType().equals(Bean.class));
assertTrue(locator.getSpringContextLocator() == mockCtxLocator);
assertThat(factory.getFieldValue(field, obj), instanceOf(ILazyInitProxy.class));
field = obj.getClass().getDeclaredField("beanByName");
proxy = factory.getFieldValue(field, obj);
locator = (SpringBeanLocator)((ILazyInitProxy)proxy).getObjectLocator();
assertTrue(locator.getBeanName().equals("somebean"));
assertTrue(locator.getBeanType().equals(Bean2.class));
assertTrue(locator.getSpringContextLocator() == mockCtxLocator);
assertThat(factory.getFieldValue(field, obj), instanceOf(ILazyInitProxy.class));
}