### Question:
ConfigurerImpl extends BeanConfigurerSupport implements Configurer, ApplicationContextAware, BusExtension { protected String getBeanName(Object beanInstance) { if (beanInstance instanceof Configurable) { return ((Configurable)beanInstance).getBeanName(); } String beanName = null; Method m = null; try { m = beanInstance.getClass().getDeclaredMethod("getBeanName", (Class[])null); } catch (NoSuchMethodException ex) { try { m = beanInstance.getClass().getMethod("getBeanName", (Class[])null); } catch (NoSuchMethodException e) { } } if (m != null) { try { beanName = (String)(m.invoke(beanInstance)); } catch (Exception ex) { LogUtils.log(LOG, Level.WARNING, "ERROR_DETERMINING_BEAN_NAME_EXC", ex); } } if (null == beanName) { LogUtils.log(LOG, Level.FINE, "COULD_NOT_DETERMINE_BEAN_NAME_MSG", beanInstance.getClass().getName()); } return beanName; } ConfigurerImpl();  ConfigurerImpl(ApplicationContext ac); void setBeanFactory(BeanFactory beanFactory); void configureBean(Object beanInstance); void configureBean(String bn, Object beanInstance); synchronized void configureBean(String bn, Object beanInstance, boolean checkWildcards); final void setApplicationContext(ApplicationContext ac); final void addApplicationContext(ApplicationContext ac); void destroy(); Class<?> getRegistrationType();  }### Answer:
@Test public void testGetBeanName() { ConfigurerImpl configurer = new ConfigurerImpl(); Object beanInstance = new Configurable() { public String getBeanName() { return "a"; } }; assertEquals("a", configurer.getBeanName(beanInstance)); final class NamedBean { @SuppressWarnings("unused") public String getBeanName() { return "b"; } } beanInstance = new NamedBean(); assertEquals("b", configurer.getBeanName(beanInstance)); beanInstance = this; assertNull(configurer.getBeanName(beanInstance)); }