7374757677787980818283
ctx.putBean("bean", bean); SpringBeanLocator locator = (SpringBeanLocator)Objects.cloneObject(new SpringBeanLocator( Bean.class, ctxLocator)); assertNotNull(locator.locateProxyTarget()); } /** * tests error if bean with class is not in the context */
8485868788899091929394
public void testLookupByClassNotFound() { SpringBeanLocator locator = new SpringBeanLocator(Bean.class, ctxLocator); try { locator.locateProxyTarget(); fail(); } catch (IllegalStateException e) { // noop
105106107108109110111112113114115
ctx.putBean("somebean2", bean); SpringBeanLocator locator = new SpringBeanLocator(Bean.class, ctxLocator); try { locator.locateProxyTarget(); fail(); } catch (IllegalStateException e) { // noop
124125126127128129130131132133134
{ Bean bean = new Bean(); ctx.putBean("bean", bean); SpringBeanLocator locator = new SpringBeanLocator("bean", Bean.class, ctxLocator); assertTrue(locator.locateProxyTarget() == bean); } /** * tests lookup by name after locator has been deserialized
139140141142143144145146147148149
ctx.putBean("bean", bean); SpringBeanLocator locator = (SpringBeanLocator)Objects.cloneObject(new SpringBeanLocator( "bean", Bean.class, ctxLocator)); assertNotNull(locator.locateProxyTarget()); } /** * tests error if no bean with name found */
150151152153154155156157158159160
public void testLookupByNameNotFound() { SpringBeanLocator locator = new SpringBeanLocator("bean", Bean.class, ctxLocator); try { locator.locateProxyTarget(); fail(); } catch (IllegalStateException e) { // noop
194195196197198199200201202203204
{ SpringContextLocatorMock ctxLocator = new SpringContextLocatorMock(null); SpringBeanLocator locator = new SpringBeanLocator(Bean.class, ctxLocator); try { locator.locateProxyTarget(); } catch (IllegalStateException e) { // noop }
130131132133134135136137138139140
{ target = LazyInitProxyFactory.createProxy(field.getType(), locator); } else { target = locator.locateProxyTarget(); } // only put the proxy into the cache if the bean is a singleton if (locator.isSingletonBean()) {
132133134135136137138139140141142