|
|
|
|
@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
|
|
|
|
|
/* |
|
|
|
|
* Copyright 2002-2020 the original author or authors. |
|
|
|
|
* Copyright 2002-2021 the original author or authors. |
|
|
|
|
* |
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
|
@ -16,7 +16,6 @@
@@ -16,7 +16,6 @@
|
|
|
|
|
|
|
|
|
|
package org.springframework.beans; |
|
|
|
|
|
|
|
|
|
import java.net.MalformedURLException; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.Arrays; |
|
|
|
|
import java.util.Collection; |
|
|
|
|
@ -86,7 +85,7 @@ public class BeanWrapperGenericsTests {
@@ -86,7 +85,7 @@ public class BeanWrapperGenericsTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testGenericList() throws MalformedURLException { |
|
|
|
|
public void testGenericList() throws Exception { |
|
|
|
|
GenericBean<?> gb = new GenericBean<>(); |
|
|
|
|
BeanWrapper bw = new BeanWrapperImpl(gb); |
|
|
|
|
List<String> input = new ArrayList<>(); |
|
|
|
|
@ -98,7 +97,7 @@ public class BeanWrapperGenericsTests {
@@ -98,7 +97,7 @@ public class BeanWrapperGenericsTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testGenericListElement() throws MalformedURLException { |
|
|
|
|
public void testGenericListElement() throws Exception { |
|
|
|
|
GenericBean<?> gb = new GenericBean<>(); |
|
|
|
|
gb.setResourceList(new ArrayList<>()); |
|
|
|
|
BeanWrapper bw = new BeanWrapperImpl(gb); |
|
|
|
|
@ -195,7 +194,7 @@ public class BeanWrapperGenericsTests {
@@ -195,7 +194,7 @@ public class BeanWrapperGenericsTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testGenericListOfLists() throws MalformedURLException { |
|
|
|
|
public void testGenericListOfLists() { |
|
|
|
|
GenericBean<String> gb = new GenericBean<>(); |
|
|
|
|
List<List<Integer>> list = new LinkedList<>(); |
|
|
|
|
list.add(new LinkedList<>()); |
|
|
|
|
@ -207,7 +206,7 @@ public class BeanWrapperGenericsTests {
@@ -207,7 +206,7 @@ public class BeanWrapperGenericsTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testGenericListOfListsWithElementConversion() throws MalformedURLException { |
|
|
|
|
public void testGenericListOfListsWithElementConversion() { |
|
|
|
|
GenericBean<String> gb = new GenericBean<>(); |
|
|
|
|
List<List<Integer>> list = new LinkedList<>(); |
|
|
|
|
list.add(new LinkedList<>()); |
|
|
|
|
@ -219,7 +218,7 @@ public class BeanWrapperGenericsTests {
@@ -219,7 +218,7 @@ public class BeanWrapperGenericsTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testGenericListOfArrays() throws MalformedURLException { |
|
|
|
|
public void testGenericListOfArrays() { |
|
|
|
|
GenericBean<String> gb = new GenericBean<>(); |
|
|
|
|
ArrayList<String[]> list = new ArrayList<>(); |
|
|
|
|
list.add(new String[] {"str1", "str2"}); |
|
|
|
|
@ -231,7 +230,7 @@ public class BeanWrapperGenericsTests {
@@ -231,7 +230,7 @@ public class BeanWrapperGenericsTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testGenericListOfArraysWithElementConversion() throws MalformedURLException { |
|
|
|
|
public void testGenericListOfArraysWithElementConversion() { |
|
|
|
|
GenericBean<String> gb = new GenericBean<>(); |
|
|
|
|
ArrayList<String[]> list = new ArrayList<>(); |
|
|
|
|
list.add(new String[] {"str1", "str2"}); |
|
|
|
|
@ -244,7 +243,7 @@ public class BeanWrapperGenericsTests {
@@ -244,7 +243,7 @@ public class BeanWrapperGenericsTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testGenericListOfMaps() throws MalformedURLException { |
|
|
|
|
public void testGenericListOfMaps() { |
|
|
|
|
GenericBean<String> gb = new GenericBean<>(); |
|
|
|
|
List<Map<Integer, Long>> list = new LinkedList<>(); |
|
|
|
|
list.add(new HashMap<>()); |
|
|
|
|
@ -256,7 +255,7 @@ public class BeanWrapperGenericsTests {
@@ -256,7 +255,7 @@ public class BeanWrapperGenericsTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testGenericListOfMapsWithElementConversion() throws MalformedURLException { |
|
|
|
|
public void testGenericListOfMapsWithElementConversion() { |
|
|
|
|
GenericBean<String> gb = new GenericBean<>(); |
|
|
|
|
List<Map<Integer, Long>> list = new LinkedList<>(); |
|
|
|
|
list.add(new HashMap<>()); |
|
|
|
|
@ -268,7 +267,7 @@ public class BeanWrapperGenericsTests {
@@ -268,7 +267,7 @@ public class BeanWrapperGenericsTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testGenericMapOfMaps() throws MalformedURLException { |
|
|
|
|
public void testGenericMapOfMaps() { |
|
|
|
|
GenericBean<String> gb = new GenericBean<>(); |
|
|
|
|
Map<String, Map<Integer, Long>> map = new HashMap<>(); |
|
|
|
|
map.put("mykey", new HashMap<>()); |
|
|
|
|
@ -280,7 +279,7 @@ public class BeanWrapperGenericsTests {
@@ -280,7 +279,7 @@ public class BeanWrapperGenericsTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testGenericMapOfMapsWithElementConversion() throws MalformedURLException { |
|
|
|
|
public void testGenericMapOfMapsWithElementConversion() { |
|
|
|
|
GenericBean<String> gb = new GenericBean<>(); |
|
|
|
|
Map<String, Map<Integer, Long>> map = new HashMap<>(); |
|
|
|
|
map.put("mykey", new HashMap<>()); |
|
|
|
|
@ -292,7 +291,7 @@ public class BeanWrapperGenericsTests {
@@ -292,7 +291,7 @@ public class BeanWrapperGenericsTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testGenericMapOfLists() throws MalformedURLException { |
|
|
|
|
public void testGenericMapOfLists() { |
|
|
|
|
GenericBean<String> gb = new GenericBean<>(); |
|
|
|
|
Map<Integer, List<Integer>> map = new HashMap<>(); |
|
|
|
|
map.put(1, new LinkedList<>()); |
|
|
|
|
@ -304,7 +303,7 @@ public class BeanWrapperGenericsTests {
@@ -304,7 +303,7 @@ public class BeanWrapperGenericsTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testGenericMapOfListsWithElementConversion() throws MalformedURLException { |
|
|
|
|
public void testGenericMapOfListsWithElementConversion() { |
|
|
|
|
GenericBean<String> gb = new GenericBean<>(); |
|
|
|
|
Map<Integer, List<Integer>> map = new HashMap<>(); |
|
|
|
|
map.put(1, new LinkedList<>()); |
|
|
|
|
@ -316,7 +315,7 @@ public class BeanWrapperGenericsTests {
@@ -316,7 +315,7 @@ public class BeanWrapperGenericsTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testGenericTypeNestingMapOfInteger() throws Exception { |
|
|
|
|
public void testGenericTypeNestingMapOfInteger() { |
|
|
|
|
Map<String, String> map = new HashMap<>(); |
|
|
|
|
map.put("testKey", "100"); |
|
|
|
|
|
|
|
|
|
@ -330,7 +329,7 @@ public class BeanWrapperGenericsTests {
@@ -330,7 +329,7 @@ public class BeanWrapperGenericsTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testGenericTypeNestingMapOfListOfInteger() throws Exception { |
|
|
|
|
public void testGenericTypeNestingMapOfListOfInteger() { |
|
|
|
|
Map<String, List<String>> map = new HashMap<>(); |
|
|
|
|
List<String> list = Arrays.asList(new String[] {"1", "2", "3"}); |
|
|
|
|
map.put("testKey", list); |
|
|
|
|
@ -340,13 +339,12 @@ public class BeanWrapperGenericsTests {
@@ -340,13 +339,12 @@ public class BeanWrapperGenericsTests {
|
|
|
|
|
bw.setPropertyValue("mapOfListOfInteger", map); |
|
|
|
|
|
|
|
|
|
Object obj = gb.getMapOfListOfInteger().get("testKey").get(0); |
|
|
|
|
boolean condition = obj instanceof Integer; |
|
|
|
|
assertThat(condition).isTrue(); |
|
|
|
|
assertThat(obj instanceof Integer).isTrue(); |
|
|
|
|
assertThat(((Integer) obj).intValue()).isEqualTo(1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testGenericTypeNestingListOfMapOfInteger() throws Exception { |
|
|
|
|
public void testGenericTypeNestingListOfMapOfInteger() { |
|
|
|
|
List<Map<String, String>> list = new LinkedList<>(); |
|
|
|
|
Map<String, String> map = new HashMap<>(); |
|
|
|
|
map.put("testKey", "5"); |
|
|
|
|
@ -357,13 +355,12 @@ public class BeanWrapperGenericsTests {
@@ -357,13 +355,12 @@ public class BeanWrapperGenericsTests {
|
|
|
|
|
bw.setPropertyValue("listOfMapOfInteger", list); |
|
|
|
|
|
|
|
|
|
Object obj = gb.getListOfMapOfInteger().get(0).get("testKey"); |
|
|
|
|
boolean condition = obj instanceof Integer; |
|
|
|
|
assertThat(condition).isTrue(); |
|
|
|
|
assertThat(obj instanceof Integer).isTrue(); |
|
|
|
|
assertThat(((Integer) obj).intValue()).isEqualTo(5); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testGenericTypeNestingMapOfListOfListOfInteger() throws Exception { |
|
|
|
|
public void testGenericTypeNestingMapOfListOfListOfInteger() { |
|
|
|
|
Map<String, List<List<String>>> map = new HashMap<>(); |
|
|
|
|
List<String> list = Arrays.asList(new String[] {"1", "2", "3"}); |
|
|
|
|
map.put("testKey", Collections.singletonList(list)); |
|
|
|
|
@ -373,8 +370,7 @@ public class BeanWrapperGenericsTests {
@@ -373,8 +370,7 @@ public class BeanWrapperGenericsTests {
|
|
|
|
|
bw.setPropertyValue("mapOfListOfListOfInteger", map); |
|
|
|
|
|
|
|
|
|
Object obj = gb.getMapOfListOfListOfInteger().get("testKey").get(0).get(0); |
|
|
|
|
boolean condition = obj instanceof Integer; |
|
|
|
|
assertThat(condition).isTrue(); |
|
|
|
|
assertThat(obj instanceof Integer).isTrue(); |
|
|
|
|
assertThat(((Integer) obj).intValue()).isEqualTo(1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -465,7 +461,7 @@ public class BeanWrapperGenericsTests {
@@ -465,7 +461,7 @@ public class BeanWrapperGenericsTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testGenericallyTypedIntegerBean() throws Exception { |
|
|
|
|
public void testGenericallyTypedIntegerBean() { |
|
|
|
|
GenericIntegerBean gb = new GenericIntegerBean(); |
|
|
|
|
BeanWrapper bw = new BeanWrapperImpl(gb); |
|
|
|
|
bw.setPropertyValue("genericProperty", "10"); |
|
|
|
|
@ -476,7 +472,7 @@ public class BeanWrapperGenericsTests {
@@ -476,7 +472,7 @@ public class BeanWrapperGenericsTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testGenericallyTypedSetOfIntegerBean() throws Exception { |
|
|
|
|
public void testGenericallyTypedSetOfIntegerBean() { |
|
|
|
|
GenericSetOfIntegerBean gb = new GenericSetOfIntegerBean(); |
|
|
|
|
BeanWrapper bw = new BeanWrapperImpl(gb); |
|
|
|
|
bw.setPropertyValue("genericProperty", "10"); |
|
|
|
|
|