List of usage examples for org.springframework.beans.factory.support GenericBeanDefinition setBeanClass
public void setBeanClass(@Nullable Class<?> beanClass)
From source file:com.urbanmania.spring.beans.factory.config.annotations.PropertyAnnotationAndPlaceholderConfigurerTest.java
@Test public void testProcessProperties() { GenericBeanDefinition beanDefinition = new GenericBeanDefinition(); beanDefinition.setBeanClass(SimplePropetyAnnotatedBean.class); beanFactory.registerBeanDefinition(TEST_BEAN_NAME, beanDefinition); properties.put(TEST_KEY, TEST_VALUE); configurer.processProperties(beanFactory, properties); assertNotNull(//from w w w .j av a 2 s . c o m beanFactory.getBeanDefinition(TEST_BEAN_NAME).getPropertyValues().getPropertyValue("property")); assertEquals(TEST_VALUE, beanFactory.getBeanDefinition(TEST_BEAN_NAME).getPropertyValues() .getPropertyValue("property").getValue()); }
From source file:com.urbanmania.spring.beans.factory.config.annotations.PropertyAnnotationAndPlaceholderConfigurerTest.java
@Test public void testProcessPropertiesWithFieldAnnotation() { GenericBeanDefinition beanDefinition = new GenericBeanDefinition(); beanDefinition.setBeanClass(AnnotatedFieldTestBean.class); beanFactory.registerBeanDefinition(TEST_BEAN_NAME, beanDefinition); properties.put(TEST_KEY, TEST_VALUE); configurer.processProperties(beanFactory, properties); assertNotNull(/*from w w w .j a va 2 s .c o m*/ beanFactory.getBeanDefinition(TEST_BEAN_NAME).getPropertyValues().getPropertyValue("property")); assertEquals(TEST_VALUE, beanFactory.getBeanDefinition(TEST_BEAN_NAME).getPropertyValues() .getPropertyValue("property").getValue()); }
From source file:com.urbanmania.spring.beans.factory.config.annotations.PropertyAnnotationAndPlaceholderConfigurerTest.java
@Test public void testProcessPropertiesWithAnnotatedGetter() { GenericBeanDefinition beanDefinition = new GenericBeanDefinition(); beanDefinition.setBeanClass(AnnotatedGetterTestBean.class); beanFactory.registerBeanDefinition(TEST_BEAN_NAME, beanDefinition); properties.put(TEST_KEY, TEST_VALUE); configurer.processProperties(beanFactory, properties); assertNotNull(// ww w . j av a2 s . c o m beanFactory.getBeanDefinition(TEST_BEAN_NAME).getPropertyValues().getPropertyValue("property")); assertEquals(TEST_VALUE, beanFactory.getBeanDefinition(TEST_BEAN_NAME).getPropertyValues() .getPropertyValue("property").getValue()); }
From source file:com.urbanmania.spring.beans.factory.config.annotations.PropertyAnnotationAndPlaceholderConfigurerTest.java
@Test public void testProcessPropertiesWithEmptyStringProperty() { GenericBeanDefinition beanDefinition = new GenericBeanDefinition(); beanDefinition.setBeanClass(SimplePropetyAnnotatedBean.class); beanFactory.registerBeanDefinition(TEST_BEAN_NAME, beanDefinition); properties.put(TEST_KEY, ""); configurer.processProperties(beanFactory, properties); assertNotNull(/*w w w . java 2 s. c o m*/ beanFactory.getBeanDefinition(TEST_BEAN_NAME).getPropertyValues().getPropertyValue("property")); assertEquals("", beanFactory.getBeanDefinition(TEST_BEAN_NAME).getPropertyValues() .getPropertyValue("property").getValue()); }
From source file:com.urbanmania.spring.beans.factory.config.annotations.PropertyAnnotationAndPlaceholderConfigurerTest.java
/** * Verify that PropertyAnnotationAndPlaceholderConfigurer is setting annotated properties for Spring factory beans. * @see http://code.google.com/p/spring-property-annotations/issues/detail?id=6 * @throws Exception//from w ww.ja va 2 s . co m */ @Test public void testPropertyAnnotationWithFactoryBean() throws Exception { GenericBeanDefinition beanDefinition = new GenericBeanDefinition(); beanDefinition.setBeanClass(PropertyAnnotatedFactoryBean.class); beanFactory.registerBeanDefinition(TEST_BEAN_NAME, beanDefinition); properties.put(TEST_KEY, TEST_VALUE); configurer.processProperties(beanFactory, properties); assertNotNull( beanFactory.getBeanDefinition(TEST_BEAN_NAME).getPropertyValues().getPropertyValue("property")); assertEquals(TEST_VALUE, beanFactory.getBeanDefinition(TEST_BEAN_NAME).getPropertyValues() .getPropertyValue("property").getValue()); }
From source file:com.urbanmania.spring.beans.factory.config.annotations.PropertyAnnotationAndPlaceholderConfigurerTest.java
/** * Verify that PropertyAnnotationAndPlaceholderConfigurer is setting annotated properties for objects created by Spring factory beans. * @see http://code.google.com/p/spring-property-annotations/issues/detail?id=6 * @throws Exception// w w w . j av a 2 s. c om */ @Test public void testPropertyAnnotationWithObjectsCreatedByFactoryBean() throws Exception { GenericBeanDefinition beanDefinition = new GenericBeanDefinition(); beanDefinition.setBeanClass(PropertyAnnotatedFactoryBean.class); beanFactory.registerBeanDefinition(TEST_BEAN_NAME, beanDefinition); properties.put(TEST_KEY, TEST_VALUE); configurer.processProperties(beanFactory, properties); String beanName = beanFactory.getBeanNamesForType(SimplePropetyAnnotatedBean.class)[0]; assertNotNull(beanName); assertEquals(TEST_VALUE, beanFactory.getBeanDefinition(beanName).getPropertyValues() .getPropertyValue("property").getValue()); }
From source file:com.urbanmania.spring.beans.factory.config.annotations.PropertyAnnotationAndPlaceholderConfigurerTest.java
@Test public void testProcessPropertiesWithinBasePackage() { configurer.setBasePackage("com.urbanmania"); GenericBeanDefinition beanDefinition = new GenericBeanDefinition(); beanDefinition.setBeanClass(SimplePropetyAnnotatedBean.class); beanFactory.registerBeanDefinition(TEST_BEAN_NAME, beanDefinition); properties.put(TEST_KEY, TEST_VALUE); configurer.processProperties(beanFactory, properties); assertNotNull(/*w w w .java 2 s . c o m*/ beanFactory.getBeanDefinition(TEST_BEAN_NAME).getPropertyValues().getPropertyValue("property")); assertEquals(TEST_VALUE, beanFactory.getBeanDefinition(TEST_BEAN_NAME).getPropertyValues() .getPropertyValue("property").getValue()); }
From source file:com.urbanmania.spring.beans.factory.config.annotations.PropertyAnnotationAndPlaceholderConfigurerTest.java
@Test public void testProcessPropertiesWithAnnotatedFieldNoSetter() { GenericBeanDefinition beanDefinition = new GenericBeanDefinition(); beanDefinition.setBeanClass(NoSetterTestBean.class); beanFactory.registerBeanDefinition(TEST_BEAN_NAME, beanDefinition); properties.put(TEST_KEY, TEST_VALUE); try {//w w w. ja va 2 s . c o m configurer.processProperties(beanFactory, properties); } catch (BeanConfigurationException e) { return; } fail("Should throw BeanConfigurationException on no property setter."); }
From source file:com.urbanmania.spring.beans.factory.config.annotations.PropertyAnnotationAndPlaceholderConfigurerTest.java
@Test public void testProcessPropertiesWithAnnotatedGetterAndNoSetter() { GenericBeanDefinition beanDefinition = new GenericBeanDefinition(); beanDefinition.setBeanClass(AnnotatedGetterWithNoSetterTestBean.class); beanFactory.registerBeanDefinition(TEST_BEAN_NAME, beanDefinition); properties.put(TEST_KEY, TEST_VALUE); try {//from w ww. ja v a2 s .com configurer.processProperties(beanFactory, properties); } catch (BeanConfigurationException e) { return; } fail("Should throw BeanConfigurationException on no property setter."); }
From source file:com.urbanmania.spring.beans.factory.config.annotations.PropertyAnnotationAndPlaceholderConfigurerTest.java
@Test public void testProcessPropertiesWithAnnotatedFieldOnly() { GenericBeanDefinition beanDefinition = new GenericBeanDefinition(); beanDefinition.setBeanClass(FieldOnlyTestBean.class); beanFactory.registerBeanDefinition(TEST_BEAN_NAME, beanDefinition); properties.put(TEST_KEY, TEST_VALUE); try {/*w ww. jav a 2s . c o m*/ configurer.processProperties(beanFactory, properties); } catch (BeanConfigurationException e) { return; } fail("Should throw BeanConfigurationException on no property setter."); }