gh-25650 Replace remaining usage of LinkedList with ArrayList in tests
This commit is contained in:
committed by
Juergen Hoeller
parent
79cf6b4353
commit
1f3e52d932
@@ -33,7 +33,6 @@ import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
@@ -384,7 +383,7 @@ class DefaultConversionServiceTests {
|
||||
|
||||
@Test
|
||||
void convertArrayToCollectionImpl() {
|
||||
LinkedList<?> result = conversionService.convert(new String[] {"1", "2", "3"}, LinkedList.class);
|
||||
ArrayList<?> result = conversionService.convert(new String[] {"1", "2", "3"}, ArrayList.class);
|
||||
assertThat(result.get(0)).isEqualTo("1");
|
||||
assertThat(result.get(1)).isEqualTo("2");
|
||||
assertThat(result.get(2)).isEqualTo("3");
|
||||
|
||||
@@ -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.
|
||||
@@ -26,7 +26,6 @@ import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
|
||||
@@ -103,8 +102,8 @@ class CollectionToCollectionConverterTests {
|
||||
TypeDescriptor targetType = new TypeDescriptor(getClass().getField("emptyListDifferentTarget"));
|
||||
assertThat(conversionService.canConvert(sourceType, targetType)).isTrue();
|
||||
@SuppressWarnings("unchecked")
|
||||
LinkedList<Integer> result = (LinkedList<Integer>) conversionService.convert(list, sourceType, targetType);
|
||||
assertThat(result.getClass()).isEqualTo(LinkedList.class);
|
||||
ArrayList<Integer> result = (ArrayList<Integer>) conversionService.convert(list, sourceType, targetType);
|
||||
assertThat(result.getClass()).isEqualTo(ArrayList.class);
|
||||
assertThat(result.isEmpty()).isTrue();
|
||||
}
|
||||
|
||||
@@ -270,7 +269,7 @@ class CollectionToCollectionConverterTests {
|
||||
|
||||
public List<Integer> emptyListTarget;
|
||||
|
||||
public LinkedList<Integer> emptyListDifferentTarget;
|
||||
public ArrayList<Integer> emptyListDifferentTarget;
|
||||
|
||||
public List<List<List<Integer>>> objectToCollection;
|
||||
|
||||
|
||||
@@ -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.util;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -38,7 +38,7 @@ class AutoPopulatingListTests {
|
||||
|
||||
@Test
|
||||
void withClassAndUserSuppliedBackingList() throws Exception {
|
||||
doTestWithClass(new AutoPopulatingList<Object>(new LinkedList<>(), TestObject.class));
|
||||
doTestWithClass(new AutoPopulatingList<Object>(new ArrayList<>(), TestObject.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -48,7 +48,7 @@ class AutoPopulatingListTests {
|
||||
|
||||
@Test
|
||||
void withElementFactoryAndUserSuppliedBackingList() throws Exception {
|
||||
doTestWithElementFactory(new AutoPopulatingList<Object>(new LinkedList<>(), new MockElementFactory()));
|
||||
doTestWithElementFactory(new AutoPopulatingList<Object>(new ArrayList<>(), new MockElementFactory()));
|
||||
}
|
||||
|
||||
private void doTestWithClass(AutoPopulatingList<Object> list) {
|
||||
|
||||
@@ -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.
|
||||
@@ -29,7 +29,6 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -364,17 +363,17 @@ class ClassUtilsTests {
|
||||
|
||||
@Test
|
||||
void classNamesToString() {
|
||||
List<Class<?>> ifcs = new LinkedList<>();
|
||||
List<Class<?>> ifcs = new ArrayList<>();
|
||||
ifcs.add(Serializable.class);
|
||||
ifcs.add(Runnable.class);
|
||||
assertThat(ifcs.toString()).isEqualTo("[interface java.io.Serializable, interface java.lang.Runnable]");
|
||||
assertThat(ClassUtils.classNamesToString(ifcs)).isEqualTo("[java.io.Serializable, java.lang.Runnable]");
|
||||
|
||||
List<Class<?>> classes = new LinkedList<>();
|
||||
classes.add(LinkedList.class);
|
||||
List<Class<?>> classes = new ArrayList<>();
|
||||
classes.add(ArrayList.class);
|
||||
classes.add(Integer.class);
|
||||
assertThat(classes.toString()).isEqualTo("[class java.util.LinkedList, class java.lang.Integer]");
|
||||
assertThat(ClassUtils.classNamesToString(classes)).isEqualTo("[java.util.LinkedList, java.lang.Integer]");
|
||||
assertThat(classes.toString()).isEqualTo("[class java.util.ArrayList, class java.lang.Integer]");
|
||||
assertThat(ClassUtils.classNamesToString(classes)).isEqualTo("[java.util.ArrayList, java.lang.Integer]");
|
||||
|
||||
assertThat(Collections.singletonList(List.class).toString()).isEqualTo("[interface java.util.List]");
|
||||
assertThat(ClassUtils.classNamesToString(List.class)).isEqualTo("[java.util.List]");
|
||||
|
||||
@@ -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.
|
||||
@@ -22,7 +22,6 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
@@ -46,7 +45,7 @@ class CollectionUtilsTests {
|
||||
assertThat(CollectionUtils.isEmpty(new HashMap<String, String>())).isTrue();
|
||||
assertThat(CollectionUtils.isEmpty(new HashSet<>())).isTrue();
|
||||
|
||||
List<Object> list = new LinkedList<>();
|
||||
List<Object> list = new ArrayList<>();
|
||||
list.add(new Object());
|
||||
assertThat(CollectionUtils.isEmpty(list)).isFalse();
|
||||
|
||||
@@ -58,7 +57,7 @@ class CollectionUtilsTests {
|
||||
@Test
|
||||
void mergeArrayIntoCollection() {
|
||||
Object[] arr = new Object[] {"value1", "value2"};
|
||||
List<Comparable<?>> list = new LinkedList<>();
|
||||
List<Comparable<?>> list = new ArrayList<>();
|
||||
list.add("value3");
|
||||
|
||||
CollectionUtils.mergeArrayIntoCollection(arr, list);
|
||||
@@ -70,7 +69,7 @@ class CollectionUtilsTests {
|
||||
@Test
|
||||
void mergePrimitiveArrayIntoCollection() {
|
||||
int[] arr = new int[] {1, 2};
|
||||
List<Comparable<?>> list = new LinkedList<>();
|
||||
List<Comparable<?>> list = new ArrayList<>();
|
||||
list.add(Integer.valueOf(3));
|
||||
|
||||
CollectionUtils.mergeArrayIntoCollection(arr, list);
|
||||
@@ -101,10 +100,10 @@ class CollectionUtilsTests {
|
||||
void contains() {
|
||||
assertThat(CollectionUtils.contains((Iterator<String>) null, "myElement")).isFalse();
|
||||
assertThat(CollectionUtils.contains((Enumeration<String>) null, "myElement")).isFalse();
|
||||
assertThat(CollectionUtils.contains(new LinkedList<String>().iterator(), "myElement")).isFalse();
|
||||
assertThat(CollectionUtils.contains(new ArrayList<String>().iterator(), "myElement")).isFalse();
|
||||
assertThat(CollectionUtils.contains(new Hashtable<String, Object>().keys(), "myElement")).isFalse();
|
||||
|
||||
List<String> list = new LinkedList<>();
|
||||
List<String> list = new ArrayList<>();
|
||||
list.add("myElement");
|
||||
assertThat(CollectionUtils.contains(list.iterator(), "myElement")).isTrue();
|
||||
|
||||
@@ -178,35 +177,35 @@ class CollectionUtilsTests {
|
||||
|
||||
@Test
|
||||
void hasUniqueObject() {
|
||||
List<String> list = new LinkedList<>();
|
||||
List<String> list = new ArrayList<>();
|
||||
list.add("myElement");
|
||||
list.add("myOtherElement");
|
||||
assertThat(CollectionUtils.hasUniqueObject(list)).isFalse();
|
||||
|
||||
list = new LinkedList<>();
|
||||
list = new ArrayList<>();
|
||||
list.add("myElement");
|
||||
assertThat(CollectionUtils.hasUniqueObject(list)).isTrue();
|
||||
|
||||
list = new LinkedList<>();
|
||||
list = new ArrayList<>();
|
||||
list.add("myElement");
|
||||
list.add(null);
|
||||
assertThat(CollectionUtils.hasUniqueObject(list)).isFalse();
|
||||
|
||||
list = new LinkedList<>();
|
||||
list = new ArrayList<>();
|
||||
list.add(null);
|
||||
list.add("myElement");
|
||||
assertThat(CollectionUtils.hasUniqueObject(list)).isFalse();
|
||||
|
||||
list = new LinkedList<>();
|
||||
list = new ArrayList<>();
|
||||
list.add(null);
|
||||
list.add(null);
|
||||
assertThat(CollectionUtils.hasUniqueObject(list)).isTrue();
|
||||
|
||||
list = new LinkedList<>();
|
||||
list = new ArrayList<>();
|
||||
list.add(null);
|
||||
assertThat(CollectionUtils.hasUniqueObject(list)).isTrue();
|
||||
|
||||
list = new LinkedList<>();
|
||||
list = new ArrayList<>();
|
||||
assertThat(CollectionUtils.hasUniqueObject(list)).isFalse();
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.rmi.ConnectException;
|
||||
import java.rmi.RemoteException;
|
||||
import java.util.LinkedList;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
@@ -370,9 +370,9 @@ class ReflectionUtilsTests {
|
||||
|
||||
private static class ListSavingMethodCallback implements ReflectionUtils.MethodCallback {
|
||||
|
||||
private List<String> methodNames = new LinkedList<>();
|
||||
private List<String> methodNames = new ArrayList<>();
|
||||
|
||||
private List<Method> methods = new LinkedList<>();
|
||||
private List<Method> methods = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void doWith(Method m) throws IllegalArgumentException, IllegalAccessException {
|
||||
|
||||
Reference in New Issue
Block a user