org.springframework.tests.sample.beans.GenericBean Java Examples
The following examples show how to use
org.springframework.tests.sample.beans.GenericBean.
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 | 7 votes |
@Test public void testGenericMapResourceConstructor() throws Exception { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class); Map<String, String> input = new HashMap<>(); input.put("4", "5"); input.put("6", "7"); rbd.getConstructorArgumentValues().addGenericArgumentValue(input); rbd.getConstructorArgumentValues().addGenericArgumentValue("http://localhost:8080"); bf.registerBeanDefinition("genericBean", rbd); GenericBean<?> gb = (GenericBean<?>) bf.getBean("genericBean"); assertEquals(new Integer(5), gb.getShortMap().get(new Short("4"))); assertEquals(new Integer(7), gb.getShortMap().get(new Short("6"))); assertEquals(new UrlResource("http://localhost:8080"), gb.getResourceList().get(0)); }
Example #2
Source File: BeanFactoryGenericsTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void testGenericMapResourceFactoryMethod() throws Exception { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class); rbd.setFactoryMethodName("createInstance"); Map<String, String> input = new HashMap<>(); input.put("4", "5"); input.put("6", "7"); rbd.getConstructorArgumentValues().addGenericArgumentValue(input); rbd.getConstructorArgumentValues().addGenericArgumentValue("http://localhost:8080"); bf.registerBeanDefinition("genericBean", rbd); GenericBean<?> gb = (GenericBean<?>) bf.getBean("genericBean"); assertEquals(new Integer(5), gb.getShortMap().get(new Short("4"))); assertEquals(new Integer(7), gb.getShortMap().get(new Short("6"))); assertEquals(new UrlResource("http://localhost:8080"), gb.getResourceList().get(0)); }
Example #3
Source File: BeanFactoryGenericsTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void testGenericMapMapConstructorWithSameRefAndConversion() { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class); Map<String, String> input = new HashMap<>(); input.put("1", "0"); input.put("2", "3"); rbd.getConstructorArgumentValues().addGenericArgumentValue(input); rbd.getConstructorArgumentValues().addGenericArgumentValue(input); bf.registerBeanDefinition("genericBean", rbd); GenericBean<?> gb = (GenericBean<?>) bf.getBean("genericBean"); assertNotSame(gb.getPlainMap(), gb.getShortMap()); assertEquals(2, gb.getPlainMap().size()); assertEquals("0", gb.getPlainMap().get("1")); assertEquals("3", gb.getPlainMap().get("2")); assertEquals(2, gb.getShortMap().size()); assertEquals(new Integer(0), gb.getShortMap().get(new Short("1"))); assertEquals(new Integer(3), gb.getShortMap().get(new Short("2"))); }
Example #4
Source File: BeanFactoryGenericsTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void testGenericSetListConstructorWithAutowiring() throws MalformedURLException { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); bf.registerSingleton("integer1", new Integer(4)); bf.registerSingleton("integer2", new Integer(5)); bf.registerSingleton("resource1", new UrlResource("http://localhost:8080")); bf.registerSingleton("resource2", new UrlResource("http://localhost:9090")); RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class); rbd.setAutowireMode(RootBeanDefinition.AUTOWIRE_CONSTRUCTOR); bf.registerBeanDefinition("genericBean", rbd); GenericBean<?> gb = (GenericBean<?>) bf.getBean("genericBean"); assertTrue(gb.getIntegerSet().contains(new Integer(4))); assertTrue(gb.getIntegerSet().contains(new Integer(5))); assertEquals(new UrlResource("http://localhost:8080"), gb.getResourceList().get(0)); assertEquals(new UrlResource("http://localhost:9090"), gb.getResourceList().get(1)); }
Example #5
Source File: BeanFactoryGenericsTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void testGenericMapProperty() { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class); Map<String, String> input = new HashMap<>(); input.put("4", "5"); input.put("6", "7"); rbd.getPropertyValues().add("shortMap", input); bf.registerBeanDefinition("genericBean", rbd); GenericBean<?> gb = (GenericBean<?>) bf.getBean("genericBean"); assertEquals(new Integer(5), gb.getShortMap().get(new Short("4"))); assertEquals(new Integer(7), gb.getShortMap().get(new Short("6"))); }
Example #6
Source File: BeanFactoryGenericsTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void testGenericSetMapFactoryMethod() throws MalformedURLException { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class); rbd.setFactoryMethodName("createInstance"); Set<String> input = new HashSet<String>(); input.add("4"); input.add("5"); Map<String, String> input2 = new HashMap<String, String>(); input2.put("4", "5"); input2.put("6", "7"); rbd.getConstructorArgumentValues().addGenericArgumentValue(input); rbd.getConstructorArgumentValues().addGenericArgumentValue(input2); bf.registerBeanDefinition("genericBean", rbd); GenericBean<?> gb = (GenericBean<?>) bf.getBean("genericBean"); assertTrue(gb.getIntegerSet().contains(new Integer(4))); assertTrue(gb.getIntegerSet().contains(new Integer(5))); assertEquals(new Integer(5), gb.getShortMap().get(new Short("4"))); assertEquals(new Integer(7), gb.getShortMap().get(new Short("6"))); }
Example #7
Source File: BeanFactoryGenericsTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void testGenericSetListFactoryMethod() throws MalformedURLException { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class); rbd.setFactoryMethodName("createInstance"); Set<String> input = new HashSet<String>(); input.add("4"); input.add("5"); List<String> input2 = new ArrayList<String>(); input2.add("http://localhost:8080"); input2.add("http://localhost:9090"); rbd.getConstructorArgumentValues().addGenericArgumentValue(input); rbd.getConstructorArgumentValues().addGenericArgumentValue(input2); bf.registerBeanDefinition("genericBean", rbd); GenericBean<?> gb = (GenericBean<?>) bf.getBean("genericBean"); assertTrue(gb.getIntegerSet().contains(new Integer(4))); assertTrue(gb.getIntegerSet().contains(new Integer(5))); assertEquals(new UrlResource("http://localhost:8080"), gb.getResourceList().get(0)); assertEquals(new UrlResource("http://localhost:9090"), gb.getResourceList().get(1)); }
Example #8
Source File: BeanFactoryGenericsTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void testGenericMapWithKeyTypeConstructor() throws MalformedURLException { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class); Map<String, String> input = new HashMap<String, String>(); input.put("4", "5"); input.put("6", "7"); rbd.getConstructorArgumentValues().addGenericArgumentValue(input); bf.registerBeanDefinition("genericBean", rbd); GenericBean<?> gb = (GenericBean<?>) bf.getBean("genericBean"); assertEquals("5", gb.getLongMap().get(new Long("4"))); assertEquals("7", gb.getLongMap().get(new Long("6"))); }
Example #9
Source File: BeanFactoryGenericsTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void testGenericSetProperty() { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class); Set<String> input = new HashSet<>(); input.add("4"); input.add("5"); rbd.getPropertyValues().add("integerSet", input); bf.registerBeanDefinition("genericBean", rbd); GenericBean<?> gb = (GenericBean<?>) bf.getBean("genericBean"); assertTrue(gb.getIntegerSet().contains(new Integer(4))); assertTrue(gb.getIntegerSet().contains(new Integer(5))); }
Example #10
Source File: BeanFactoryGenericsTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void testGenericListProperty() throws Exception { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class); List<String> input = new ArrayList<>(); input.add("http://localhost:8080"); input.add("http://localhost:9090"); rbd.getPropertyValues().add("resourceList", input); bf.registerBeanDefinition("genericBean", rbd); GenericBean<?> gb = (GenericBean<?>) bf.getBean("genericBean"); assertEquals(new UrlResource("http://localhost:8080"), gb.getResourceList().get(0)); assertEquals(new UrlResource("http://localhost:9090"), gb.getResourceList().get(1)); }
Example #11
Source File: BeanFactoryGenericsTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void testGenericSetFactoryMethod() { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class); rbd.setFactoryMethodName("createInstance"); Set<String> input = new HashSet<>(); input.add("4"); input.add("5"); rbd.getConstructorArgumentValues().addGenericArgumentValue(input); bf.registerBeanDefinition("genericBean", rbd); GenericBean<?> gb = (GenericBean<?>) bf.getBean("genericBean"); assertTrue(gb.getIntegerSet().contains(new Integer(4))); assertTrue(gb.getIntegerSet().contains(new Integer(5))); }
Example #12
Source File: BeanFactoryGenericsTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void testGenericSetConstructor() { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class); Set<String> input = new HashSet<>(); input.add("4"); input.add("5"); rbd.getConstructorArgumentValues().addGenericArgumentValue(input); bf.registerBeanDefinition("genericBean", rbd); GenericBean<?> gb = (GenericBean<?>) bf.getBean("genericBean"); assertTrue(gb.getIntegerSet().contains(new Integer(4))); assertTrue(gb.getIntegerSet().contains(new Integer(5))); }
Example #13
Source File: BeanFactoryGenericsTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void testGenericSetListConstructor() throws Exception { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class); Set<String> input = new HashSet<>(); input.add("4"); input.add("5"); List<String> input2 = new ArrayList<>(); input2.add("http://localhost:8080"); input2.add("http://localhost:9090"); rbd.getConstructorArgumentValues().addGenericArgumentValue(input); rbd.getConstructorArgumentValues().addGenericArgumentValue(input2); bf.registerBeanDefinition("genericBean", rbd); GenericBean<?> gb = (GenericBean<?>) bf.getBean("genericBean"); assertTrue(gb.getIntegerSet().contains(new Integer(4))); assertTrue(gb.getIntegerSet().contains(new Integer(5))); assertEquals(new UrlResource("http://localhost:8080"), gb.getResourceList().get(0)); assertEquals(new UrlResource("http://localhost:9090"), gb.getResourceList().get(1)); }
Example #14
Source File: BeanFactoryGenericsTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void testGenericMapProperty() { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class); Map<String, String> input = new HashMap<String, String>(); input.put("4", "5"); input.put("6", "7"); rbd.getPropertyValues().add("shortMap", input); bf.registerBeanDefinition("genericBean", rbd); GenericBean<?> gb = (GenericBean<?>) bf.getBean("genericBean"); assertEquals(new Integer(5), gb.getShortMap().get(new Short("4"))); assertEquals(new Integer(7), gb.getShortMap().get(new Short("6"))); }
Example #15
Source File: BeanFactoryGenericsTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void testGenericSetListConstructor() throws Exception { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class); Set<String> input = new HashSet<>(); input.add("4"); input.add("5"); List<String> input2 = new ArrayList<>(); input2.add("http://localhost:8080"); input2.add("http://localhost:9090"); rbd.getConstructorArgumentValues().addGenericArgumentValue(input); rbd.getConstructorArgumentValues().addGenericArgumentValue(input2); bf.registerBeanDefinition("genericBean", rbd); GenericBean<?> gb = (GenericBean<?>) bf.getBean("genericBean"); assertTrue(gb.getIntegerSet().contains(new Integer(4))); assertTrue(gb.getIntegerSet().contains(new Integer(5))); assertEquals(new UrlResource("http://localhost:8080"), gb.getResourceList().get(0)); assertEquals(new UrlResource("http://localhost:9090"), gb.getResourceList().get(1)); }
Example #16
Source File: BeanFactoryGenericsTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void testGenericMapWithKeyTypeFactoryMethod() { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class); rbd.setFactoryMethodName("createInstance"); Map<String, String> input = new HashMap<>(); input.put("4", "5"); input.put("6", "7"); rbd.getConstructorArgumentValues().addGenericArgumentValue(input); bf.registerBeanDefinition("genericBean", rbd); GenericBean<?> gb = (GenericBean<?>) bf.getBean("genericBean"); assertEquals("5", gb.getLongMap().get(new Long("4"))); assertEquals("7", gb.getLongMap().get(new Long("6"))); }
Example #17
Source File: BeanFactoryGenericsTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void testGenericSetConstructor() { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class); Set<String> input = new HashSet<>(); input.add("4"); input.add("5"); rbd.getConstructorArgumentValues().addGenericArgumentValue(input); bf.registerBeanDefinition("genericBean", rbd); GenericBean<?> gb = (GenericBean<?>) bf.getBean("genericBean"); assertTrue(gb.getIntegerSet().contains(new Integer(4))); assertTrue(gb.getIntegerSet().contains(new Integer(5))); }
Example #18
Source File: BeanFactoryGenericsTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void testGenericSetMapConstructor() { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class); Set<String> input = new HashSet<>(); input.add("4"); input.add("5"); Map<String, String> input2 = new HashMap<>(); input2.put("4", "5"); input2.put("6", "7"); rbd.getConstructorArgumentValues().addGenericArgumentValue(input); rbd.getConstructorArgumentValues().addGenericArgumentValue(input2); bf.registerBeanDefinition("genericBean", rbd); GenericBean<?> gb = (GenericBean<?>) bf.getBean("genericBean"); assertTrue(gb.getIntegerSet().contains(new Integer(4))); assertTrue(gb.getIntegerSet().contains(new Integer(5))); assertEquals(new Integer(5), gb.getShortMap().get(new Short("4"))); assertEquals(new Integer(7), gb.getShortMap().get(new Short("6"))); }
Example #19
Source File: BeanFactoryGenericsTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void testGenericSetListConstructorWithAutowiring() throws Exception { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); bf.registerSingleton("integer1", new Integer(4)); bf.registerSingleton("integer2", new Integer(5)); bf.registerSingleton("resource1", new UrlResource("http://localhost:8080")); bf.registerSingleton("resource2", new UrlResource("http://localhost:9090")); RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class); rbd.setAutowireMode(RootBeanDefinition.AUTOWIRE_CONSTRUCTOR); bf.registerBeanDefinition("genericBean", rbd); GenericBean<?> gb = (GenericBean<?>) bf.getBean("genericBean"); assertTrue(gb.getIntegerSet().contains(new Integer(4))); assertTrue(gb.getIntegerSet().contains(new Integer(5))); assertEquals(new UrlResource("http://localhost:8080"), gb.getResourceList().get(0)); assertEquals(new UrlResource("http://localhost:9090"), gb.getResourceList().get(1)); }
Example #20
Source File: BeanFactoryGenericsTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void testGenericMapMapConstructor() { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class); Map<String, String> input = new HashMap<>(); input.put("1", "0"); input.put("2", "3"); Map<String, String> input2 = new HashMap<>(); input2.put("4", "5"); input2.put("6", "7"); rbd.getConstructorArgumentValues().addGenericArgumentValue(input); rbd.getConstructorArgumentValues().addGenericArgumentValue(input2); bf.registerBeanDefinition("genericBean", rbd); GenericBean<?> gb = (GenericBean<?>) bf.getBean("genericBean"); assertNotSame(gb.getPlainMap(), gb.getShortMap()); assertEquals(2, gb.getPlainMap().size()); assertEquals("0", gb.getPlainMap().get("1")); assertEquals("3", gb.getPlainMap().get("2")); assertEquals(2, gb.getShortMap().size()); assertEquals(new Integer(5), gb.getShortMap().get(new Short("4"))); assertEquals(new Integer(7), gb.getShortMap().get(new Short("6"))); }
Example #21
Source File: BeanFactoryGenericsTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void testGenericMapMapFactoryMethod() throws MalformedURLException { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class); rbd.setFactoryMethodName("createInstance"); Map<String, String> input = new HashMap<String, String>(); input.put("1", "0"); input.put("2", "3"); Map<String, String> input2 = new HashMap<String, String>(); input2.put("4", "5"); input2.put("6", "7"); rbd.getConstructorArgumentValues().addGenericArgumentValue(input); rbd.getConstructorArgumentValues().addGenericArgumentValue(input2); bf.registerBeanDefinition("genericBean", rbd); GenericBean<?> gb = (GenericBean<?>) bf.getBean("genericBean"); assertEquals("0", gb.getPlainMap().get("1")); assertEquals("3", gb.getPlainMap().get("2")); assertEquals(new Integer(5), gb.getShortMap().get(new Short("4"))); assertEquals(new Integer(7), gb.getShortMap().get(new Short("6"))); }
Example #22
Source File: BeanFactoryGenericsTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void testGenericListProperty() throws MalformedURLException { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class); List<String> input = new ArrayList<String>(); input.add("http://localhost:8080"); input.add("http://localhost:9090"); rbd.getPropertyValues().add("resourceList", input); bf.registerBeanDefinition("genericBean", rbd); GenericBean<?> gb = (GenericBean<?>) bf.getBean("genericBean"); assertEquals(new UrlResource("http://localhost:8080"), gb.getResourceList().get(0)); assertEquals(new UrlResource("http://localhost:9090"), gb.getResourceList().get(1)); }
Example #23
Source File: BeanWrapperEnumTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void testStandardEnumMapWithAutoGrowing() { GenericBean<?> gb = new GenericBean<Object>(); BeanWrapper bw = new BeanWrapperImpl(gb); bw.setAutoGrowNestedPaths(true); assertNull(gb.getStandardEnumMap()); bw.setPropertyValue("standardEnumMap[VALUE_1]", 1); assertEquals(1, gb.getStandardEnumMap().size()); assertEquals(new Integer(1), gb.getStandardEnumMap().get(CustomEnum.VALUE_1)); }
Example #24
Source File: BeanWrapperEnumTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void testCustomEnumArrayWithSingleValue() { GenericBean<?> gb = new GenericBean<>(); BeanWrapper bw = new BeanWrapperImpl(gb); bw.setPropertyValue("customEnumArray", "VALUE_1"); assertEquals(1, gb.getCustomEnumArray().length); assertEquals(CustomEnum.VALUE_1, gb.getCustomEnumArray()[0]); }
Example #25
Source File: BeanWrapperEnumTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void testCustomEnumSetWithMultipleValues() { GenericBean<?> gb = new GenericBean<Object>(); BeanWrapper bw = new BeanWrapperImpl(gb); bw.setPropertyValue("customEnumSet", new String[] {"VALUE_1", "VALUE_2"}); assertEquals(2, gb.getCustomEnumSet().size()); assertTrue(gb.getCustomEnumSet().contains(CustomEnum.VALUE_1)); assertTrue(gb.getCustomEnumSet().contains(CustomEnum.VALUE_2)); }
Example #26
Source File: BeanWrapperGenericsTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void testGenericMapElementWithKeyType() { GenericBean<?> gb = new GenericBean<>(); gb.setLongMap(new HashMap<Long, Integer>()); BeanWrapper bw = new BeanWrapperImpl(gb); bw.setPropertyValue("longMap[4]", "5"); assertEquals("5", gb.getLongMap().get(new Long("4"))); assertEquals("5", bw.getPropertyValue("longMap[4]")); }
Example #27
Source File: BeanWrapperGenericsTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void testGenericSetWithConversionFailure() { GenericBean<?> gb = new GenericBean<Object>(); BeanWrapper bw = new BeanWrapperImpl(gb); Set<TestBean> input = new HashSet<TestBean>(); input.add(new TestBean()); try { bw.setPropertyValue("integerSet", input); fail("Should have thrown TypeMismatchException"); } catch (TypeMismatchException ex) { assertTrue(ex.getMessage().indexOf("java.lang.Integer") != -1); } }
Example #28
Source File: BeanWrapperEnumTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void testCustomEnumArrayWithMultipleValuesAsCsv() { GenericBean<?> gb = new GenericBean<Object>(); BeanWrapper bw = new BeanWrapperImpl(gb); bw.setPropertyValue("customEnumArray", "VALUE_1,VALUE_2"); assertEquals(2, gb.getCustomEnumArray().length); assertEquals(CustomEnum.VALUE_1, gb.getCustomEnumArray()[0]); assertEquals(CustomEnum.VALUE_2, gb.getCustomEnumArray()[1]); }
Example #29
Source File: BeanFactoryGenericsTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void testGenericSetConstructorWithOptionalAutowiring() { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); RootBeanDefinition rbd = new RootBeanDefinition(GenericBean.class); rbd.setAutowireMode(RootBeanDefinition.AUTOWIRE_CONSTRUCTOR); bf.registerBeanDefinition("genericBean", rbd); GenericBean<?> gb = (GenericBean<?>) bf.getBean("genericBean"); assertNull(gb.getIntegerSet()); }
Example #30
Source File: BeanWrapperEnumTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void testCustomEnumWithEmptyString() { GenericBean<?> gb = new GenericBean<>(); BeanWrapper bw = new BeanWrapperImpl(gb); bw.setPropertyValue("customEnum", ""); assertEquals(null, gb.getCustomEnum()); }