gh-25650 Replace remaining usage of LinkedList with ArrayList in tests

This commit is contained in:
Сергей Цыпанов
2020-08-31 12:35:00 +03:00
committed by Juergen Hoeller
parent 79cf6b4353
commit 1f3e52d932
28 changed files with 126 additions and 140 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 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.
@@ -25,7 +25,6 @@ import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -1072,7 +1071,7 @@ public abstract class AbstractPropertyAccessorTests {
public void setGenericArrayProperty() {
SkipReaderStub target = new SkipReaderStub();
AbstractPropertyAccessor accessor = createAccessor(target);
List<String> values = new LinkedList<>();
List<String> values = new ArrayList<>();
values.add("1");
values.add("2");
values.add("3");
@@ -1113,7 +1112,7 @@ public abstract class AbstractPropertyAccessorTests {
SortedSet<String> sortedSet = new TreeSet<>();
sortedSet.add("sortedSet1");
accessor.setPropertyValue("sortedSet", sortedSet);
List<String> list = new LinkedList<>();
List<String> list = new ArrayList<>();
list.add("list1");
accessor.setPropertyValue("list", list);
assertThat(target.getCollection()).isSameAs(coll);
@@ -1130,7 +1129,7 @@ public abstract class AbstractPropertyAccessorTests {
Collection<String> coll = new ArrayList<>();
coll.add("coll1");
accessor.setPropertyValue("collection", coll);
List<String> set = new LinkedList<>();
List<String> set = new ArrayList<>();
set.add("set1");
accessor.setPropertyValue("set", set);
List<String> sortedSet = new ArrayList<>();
@@ -1157,7 +1156,7 @@ public abstract class AbstractPropertyAccessorTests {
Collection<String> coll = new HashSet<>();
coll.add("coll1");
accessor.setPropertyValue("collection", coll.toArray());
List<String> set = new LinkedList<>();
List<String> set = new ArrayList<>();
set.add("set1");
accessor.setPropertyValue("set", set.toArray());
List<String> sortedSet = new ArrayList<>();
@@ -1184,7 +1183,7 @@ public abstract class AbstractPropertyAccessorTests {
Collection<Integer> coll = new HashSet<>();
coll.add(0);
accessor.setPropertyValue("collection", new int[] {0});
List<Integer> set = new LinkedList<>();
List<Integer> set = new ArrayList<>();
set.add(1);
accessor.setPropertyValue("set", new int[] {1});
List<Integer> sortedSet = new ArrayList<>();
@@ -1211,7 +1210,7 @@ public abstract class AbstractPropertyAccessorTests {
Collection<Integer> coll = new HashSet<>();
coll.add(0);
accessor.setPropertyValue("collection", 0);
List<Integer> set = new LinkedList<>();
List<Integer> set = new ArrayList<>();
set.add(1);
accessor.setPropertyValue("set", 1);
List<Integer> sortedSet = new ArrayList<>();
@@ -1235,7 +1234,7 @@ public abstract class AbstractPropertyAccessorTests {
public void setCollectionPropertyWithStringValue() {
IndexedTestBean target = new IndexedTestBean();
AbstractPropertyAccessor accessor = createAccessor(target);
List<String> set = new LinkedList<>();
List<String> set = new ArrayList<>();
set.add("set1");
accessor.setPropertyValue("set", "set1");
List<String> sortedSet = new ArrayList<>();

View File

@@ -23,7 +23,6 @@ import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -197,8 +196,8 @@ public class BeanWrapperGenericsTests {
@Test
public void testGenericListOfLists() throws MalformedURLException {
GenericBean<String> gb = new GenericBean<>();
List<List<Integer>> list = new LinkedList<>();
list.add(new LinkedList<>());
List<List<Integer>> list = new ArrayList<>();
list.add(new ArrayList<>());
gb.setListOfLists(list);
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.setPropertyValue("listOfLists[0][0]", 5);
@@ -209,8 +208,8 @@ public class BeanWrapperGenericsTests {
@Test
public void testGenericListOfListsWithElementConversion() throws MalformedURLException {
GenericBean<String> gb = new GenericBean<>();
List<List<Integer>> list = new LinkedList<>();
list.add(new LinkedList<>());
List<List<Integer>> list = new ArrayList<>();
list.add(new ArrayList<>());
gb.setListOfLists(list);
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.setPropertyValue("listOfLists[0][0]", "5");
@@ -246,7 +245,7 @@ public class BeanWrapperGenericsTests {
@Test
public void testGenericListOfMaps() throws MalformedURLException {
GenericBean<String> gb = new GenericBean<>();
List<Map<Integer, Long>> list = new LinkedList<>();
List<Map<Integer, Long>> list = new ArrayList<>();
list.add(new HashMap<>());
gb.setListOfMaps(list);
BeanWrapper bw = new BeanWrapperImpl(gb);
@@ -258,7 +257,7 @@ public class BeanWrapperGenericsTests {
@Test
public void testGenericListOfMapsWithElementConversion() throws MalformedURLException {
GenericBean<String> gb = new GenericBean<>();
List<Map<Integer, Long>> list = new LinkedList<>();
List<Map<Integer, Long>> list = new ArrayList<>();
list.add(new HashMap<>());
gb.setListOfMaps(list);
BeanWrapper bw = new BeanWrapperImpl(gb);
@@ -295,7 +294,7 @@ public class BeanWrapperGenericsTests {
public void testGenericMapOfLists() throws MalformedURLException {
GenericBean<String> gb = new GenericBean<>();
Map<Integer, List<Integer>> map = new HashMap<>();
map.put(1, new LinkedList<>());
map.put(1, new ArrayList<>());
gb.setMapOfLists(map);
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.setPropertyValue("mapOfLists[1][0]", 5);
@@ -307,7 +306,7 @@ public class BeanWrapperGenericsTests {
public void testGenericMapOfListsWithElementConversion() throws MalformedURLException {
GenericBean<String> gb = new GenericBean<>();
Map<Integer, List<Integer>> map = new HashMap<>();
map.put(1, new LinkedList<>());
map.put(1, new ArrayList<>());
gb.setMapOfLists(map);
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.setPropertyValue("mapOfLists[1][0]", "5");
@@ -347,7 +346,7 @@ public class BeanWrapperGenericsTests {
@Test
public void testGenericTypeNestingListOfMapOfInteger() throws Exception {
List<Map<String, String>> list = new LinkedList<>();
List<Map<String, String>> list = new ArrayList<>();
Map<String, String> map = new HashMap<>();
map.put("testKey", "5");
list.add(map);
@@ -381,9 +380,9 @@ public class BeanWrapperGenericsTests {
@Test
public void testComplexGenericMap() {
Map<List<String>, List<String>> inputMap = new HashMap<>();
List<String> inputKey = new LinkedList<>();
List<String> inputKey = new ArrayList<>();
inputKey.add("1");
List<String> inputValue = new LinkedList<>();
List<String> inputValue = new ArrayList<>();
inputValue.add("10");
inputMap.put(inputKey, inputValue);
@@ -414,7 +413,7 @@ public class BeanWrapperGenericsTests {
@Test
public void testComplexGenericIndexedMapEntry() {
List<String> inputValue = new LinkedList<>();
List<String> inputValue = new ArrayList<>();
inputValue.add("10");
ComplexMapHolder holder = new ComplexMapHolder();
@@ -440,7 +439,7 @@ public class BeanWrapperGenericsTests {
@Test
public void testComplexDerivedIndexedMapEntry() {
List<String> inputValue = new LinkedList<>();
List<String> inputValue = new ArrayList<>();
inputValue.add("10");
ComplexMapHolder holder = new ComplexMapHolder();

View File

@@ -24,13 +24,13 @@ import java.lang.annotation.Target;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -2709,7 +2709,7 @@ public class AutowiredAnnotationBeanPostProcessorTests {
@SuppressWarnings("serial")
public static class SelfInjectionCollectionBean extends LinkedList<SelfInjectionCollectionBean> {
public static class SelfInjectionCollectionBean extends ArrayList<SelfInjectionCollectionBean> {
@Autowired
public SelfInjectionCollectionBean reference;
@@ -2833,7 +2833,7 @@ public class AutowiredAnnotationBeanPostProcessorTests {
}
public List<TestBean> iterateTestBeans() {
List<TestBean> resolved = new LinkedList<>();
List<TestBean> resolved = new ArrayList<>();
for (TestBean tb : this.testBeanProvider) {
resolved.add(tb);
}
@@ -2841,7 +2841,7 @@ public class AutowiredAnnotationBeanPostProcessorTests {
}
public List<TestBean> forEachTestBeans() {
List<TestBean> resolved = new LinkedList<>();
List<TestBean> resolved = new ArrayList<>();
this.testBeanProvider.forEach(resolved::add);
return resolved;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 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,7 @@
package org.springframework.beans.factory.config;
import java.util.LinkedList;
import java.util.ArrayList;
import java.util.List;
import org.junit.jupiter.api.BeforeEach;
@@ -47,7 +47,7 @@ public class SimpleScopeTests {
beanFactory = new DefaultListableBeanFactory();
Scope scope = new NoOpScope() {
private int index;
private List<TestBean> objects = new LinkedList<>(); {
private List<TestBean> objects = new ArrayList<>(); {
objects.add(new TestBean());
objects.add(new TestBean());
}

View File

@@ -26,7 +26,6 @@ import java.util.AbstractCollection;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -960,7 +959,7 @@ public class BeanFactoryGenericsTests {
@SuppressWarnings("serial")
public static class NamedUrlList extends LinkedList<URL> {
public static class NamedUrlList extends ArrayList<URL> {
}