BeanDefinitionParserUtils { public static void setPropertyReference(BeanDefinitionBuilder builder, String beanReference, String propertyName) { if (StringUtils.hasText(beanReference)) { builder.addPropertyReference(propertyName, beanReference); } } private  BeanDefinitionParserUtils(); static void setPropertyValue(BeanDefinitionBuilder builder, String propertyValue, String propertyName); static void setConstructorArgValue(BeanDefinitionBuilder builder, String propertyValue); static void setPropertyReference(BeanDefinitionBuilder builder, String beanReference, String propertyName); static void addConstructorArgReference(BeanDefinitionBuilder builder, String beanReference); static void setPropertyReference(BeanDefinitionBuilder builder, String beanReference, String propertyName, String defaultValue); static BeanDefinitionHolder registerBean(String beanId, Class<?> beanClass, ParserContext parserContext, boolean shouldFireEvents); static BeanDefinitionHolder registerBean(String beanId, BeanDefinition beanDefinition, ParserContext parserContext, boolean shouldFireEvents);  }
@Test public void testSetPropertyReference() { BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(); BeanDefinitionParserUtils.setPropertyReference(builder, "beanref", "propertyname"); Assert.assertTrue(builder.getBeanDefinition().getPropertyValues().contains("propertyname")); Assert.assertEquals(builder.getBeanDefinition().getPropertyValues().getPropertyValue("propertyname").getValue().getClass(), RuntimeBeanReference.class); Assert.assertEquals(((RuntimeBeanReference)builder.getBeanDefinition().getPropertyValues().getPropertyValue("propertyname").getValue()).getBeanName(), "beanref"); }
@Test public void testSetPropertyNullReference() { BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(); BeanDefinitionParserUtils.setPropertyReference(builder, null, "propertyname"); Assert.assertFalse(builder.getBeanDefinition().getPropertyValues().contains("propertyname")); }