org.springframework.tests.sample.beans.GenericIntegerBean Java Examples
The following examples show how to use
org.springframework.tests.sample.beans.GenericIntegerBean.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BeanFactoryGenericsTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void testGenericListPropertyWithInvalidElementType() { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); RootBeanDefinition rbd = new RootBeanDefinition(GenericIntegerBean.class); List<Integer> input = new ArrayList<>(); input.add(1); rbd.getPropertyValues().add("testBeanList", input); bf.registerBeanDefinition("genericBean", rbd); try { bf.getBean("genericBean"); fail("Should have thrown BeanCreationException"); } catch (BeanCreationException ex) { assertTrue(ex.getMessage().contains("genericBean") && ex.getMessage().contains("testBeanList[0]")); assertTrue(ex.getMessage().contains(TestBean.class.getName()) && ex.getMessage().contains("Integer")); } }
Example #2
Source File: BeanFactoryGenericsTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void testGenericListPropertyWithInvalidElementType() { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); RootBeanDefinition rbd = new RootBeanDefinition(GenericIntegerBean.class); List<Integer> input = new ArrayList<>(); input.add(1); rbd.getPropertyValues().add("testBeanList", input); bf.registerBeanDefinition("genericBean", rbd); try { bf.getBean("genericBean"); fail("Should have thrown BeanCreationException"); } catch (BeanCreationException ex) { assertTrue(ex.getMessage().contains("genericBean") && ex.getMessage().contains("testBeanList[0]")); assertTrue(ex.getMessage().contains(TestBean.class.getName()) && ex.getMessage().contains("Integer")); } }
Example #3
Source File: BeanFactoryGenericsTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void testGenericListPropertyWithInvalidElementType() { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); RootBeanDefinition rbd = new RootBeanDefinition(GenericIntegerBean.class); List<Integer> input = new ArrayList<Integer>(); input.add(1); rbd.getPropertyValues().add("testBeanList", input); bf.registerBeanDefinition("genericBean", rbd); try { bf.getBean("genericBean"); fail("Should have thrown BeanCreationException"); } catch (BeanCreationException ex) { assertTrue(ex.getMessage().contains("genericBean") && ex.getMessage().contains("testBeanList[0]")); assertTrue(ex.getMessage().contains(TestBean.class.getName()) && ex.getMessage().contains("Integer")); } }
Example #4
Source File: BeanWrapperGenericsTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void testGenericallyTypedIntegerBean() throws Exception { GenericIntegerBean gb = new GenericIntegerBean(); BeanWrapper bw = new BeanWrapperImpl(gb); bw.setPropertyValue("genericProperty", "10"); bw.setPropertyValue("genericListProperty", new String[] {"20", "30"}); assertEquals(new Integer(10), gb.getGenericProperty()); assertEquals(new Integer(20), gb.getGenericListProperty().get(0)); assertEquals(new Integer(30), gb.getGenericListProperty().get(1)); }
Example #5
Source File: BeanFactoryGenericsTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void testGenericListPropertyWithAutowiring() throws Exception { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); bf.registerSingleton("resource1", new UrlResource("http://localhost:8080")); bf.registerSingleton("resource2", new UrlResource("http://localhost:9090")); RootBeanDefinition rbd = new RootBeanDefinition(GenericIntegerBean.class); rbd.setAutowireMode(RootBeanDefinition.AUTOWIRE_BY_TYPE); bf.registerBeanDefinition("genericBean", rbd); GenericIntegerBean gb = (GenericIntegerBean) bf.getBean("genericBean"); assertEquals(new UrlResource("http://localhost:8080"), gb.getResourceList().get(0)); assertEquals(new UrlResource("http://localhost:9090"), gb.getResourceList().get(1)); }
Example #6
Source File: BeanFactoryGenericsTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void testGenericallyTypedIntegerBean() { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(bf).loadBeanDefinitions( new ClassPathResource("genericBeanTests.xml", getClass())); GenericIntegerBean gb = (GenericIntegerBean) bf.getBean("integerBean"); assertEquals(new Integer(10), gb.getGenericProperty()); assertEquals(new Integer(20), gb.getGenericListProperty().get(0)); assertEquals(new Integer(30), gb.getGenericListProperty().get(1)); }
Example #7
Source File: BeanWrapperGenericsTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void testGenericallyTypedIntegerBean() throws Exception { GenericIntegerBean gb = new GenericIntegerBean(); BeanWrapper bw = new BeanWrapperImpl(gb); bw.setPropertyValue("genericProperty", "10"); bw.setPropertyValue("genericListProperty", new String[] {"20", "30"}); assertEquals(new Integer(10), gb.getGenericProperty()); assertEquals(new Integer(20), gb.getGenericListProperty().get(0)); assertEquals(new Integer(30), gb.getGenericListProperty().get(1)); }
Example #8
Source File: BeanFactoryGenericsTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void testGenericListPropertyWithAutowiring() throws Exception { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); bf.registerSingleton("resource1", new UrlResource("http://localhost:8080")); bf.registerSingleton("resource2", new UrlResource("http://localhost:9090")); RootBeanDefinition rbd = new RootBeanDefinition(GenericIntegerBean.class); rbd.setAutowireMode(RootBeanDefinition.AUTOWIRE_BY_TYPE); bf.registerBeanDefinition("genericBean", rbd); GenericIntegerBean gb = (GenericIntegerBean) bf.getBean("genericBean"); assertEquals(new UrlResource("http://localhost:8080"), gb.getResourceList().get(0)); assertEquals(new UrlResource("http://localhost:9090"), gb.getResourceList().get(1)); }
Example #9
Source File: BeanFactoryGenericsTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void testGenericallyTypedIntegerBean() { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(bf).loadBeanDefinitions( new ClassPathResource("genericBeanTests.xml", getClass())); GenericIntegerBean gb = (GenericIntegerBean) bf.getBean("integerBean"); assertEquals(new Integer(10), gb.getGenericProperty()); assertEquals(new Integer(20), gb.getGenericListProperty().get(0)); assertEquals(new Integer(30), gb.getGenericListProperty().get(1)); }
Example #10
Source File: BeanWrapperGenericsTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void testGenericallyTypedIntegerBean() throws Exception { GenericIntegerBean gb = new GenericIntegerBean(); BeanWrapper bw = new BeanWrapperImpl(gb); bw.setPropertyValue("genericProperty", "10"); bw.setPropertyValue("genericListProperty", new String[] {"20", "30"}); assertEquals(new Integer(10), gb.getGenericProperty()); assertEquals(new Integer(20), gb.getGenericListProperty().get(0)); assertEquals(new Integer(30), gb.getGenericListProperty().get(1)); }
Example #11
Source File: BeanFactoryGenericsTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void testGenericListPropertyWithAutowiring() throws MalformedURLException { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); bf.registerSingleton("resource1", new UrlResource("http://localhost:8080")); bf.registerSingleton("resource2", new UrlResource("http://localhost:9090")); RootBeanDefinition rbd = new RootBeanDefinition(GenericIntegerBean.class); rbd.setAutowireMode(RootBeanDefinition.AUTOWIRE_BY_TYPE); bf.registerBeanDefinition("genericBean", rbd); GenericIntegerBean gb = (GenericIntegerBean) bf.getBean("genericBean"); assertEquals(new UrlResource("http://localhost:8080"), gb.getResourceList().get(0)); assertEquals(new UrlResource("http://localhost:9090"), gb.getResourceList().get(1)); }
Example #12
Source File: BeanFactoryGenericsTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void testGenericallyTypedIntegerBean() throws Exception { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(bf).loadBeanDefinitions( new ClassPathResource("genericBeanTests.xml", getClass())); GenericIntegerBean gb = (GenericIntegerBean) bf.getBean("integerBean"); assertEquals(new Integer(10), gb.getGenericProperty()); assertEquals(new Integer(20), gb.getGenericListProperty().get(0)); assertEquals(new Integer(30), gb.getGenericListProperty().get(1)); }