提交 eaf9deed 编写于 作者: S Syuziko 提交者: Stephane Nicoll

Polish tests

See gh-27248
上级 ce6217be
/*
* 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.
......@@ -46,10 +46,10 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
* @author Chris Beams
* @since 18.01.2006
*/
public class BeanWrapperGenericsTests {
class BeanWrapperGenericsTests {
@Test
public void testGenericSet() {
void testGenericSet() {
GenericBean<?> gb = new GenericBean<>();
BeanWrapper bw = new BeanWrapperImpl(gb);
Set<String> input = new HashSet<>();
......@@ -61,7 +61,7 @@ public class BeanWrapperGenericsTests {
}
@Test
public void testGenericLowerBoundedSet() {
void testGenericLowerBoundedSet() {
GenericBean<?> gb = new GenericBean<>();
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.registerCustomEditor(Number.class, new CustomNumberEditor(Integer.class, true));
......@@ -74,7 +74,7 @@ public class BeanWrapperGenericsTests {
}
@Test
public void testGenericSetWithConversionFailure() {
void testGenericSetWithConversionFailure() {
GenericBean<?> gb = new GenericBean<>();
BeanWrapper bw = new BeanWrapperImpl(gb);
Set<TestBean> input = new HashSet<>();
......@@ -85,7 +85,7 @@ public class BeanWrapperGenericsTests {
}
@Test
public void testGenericList() throws MalformedURLException {
void testGenericList() throws MalformedURLException {
GenericBean<?> gb = new GenericBean<>();
BeanWrapper bw = new BeanWrapperImpl(gb);
List<String> input = new ArrayList<>();
......@@ -97,7 +97,7 @@ public class BeanWrapperGenericsTests {
}
@Test
public void testGenericListElement() throws MalformedURLException {
void testGenericListElement() throws MalformedURLException {
GenericBean<?> gb = new GenericBean<>();
gb.setResourceList(new ArrayList<>());
BeanWrapper bw = new BeanWrapperImpl(gb);
......@@ -106,29 +106,29 @@ public class BeanWrapperGenericsTests {
}
@Test
public void testGenericMap() {
void testGenericMap() {
GenericBean<?> gb = new GenericBean<>();
BeanWrapper bw = new BeanWrapperImpl(gb);
Map<String, String> input = new HashMap<>();
input.put("4", "5");
input.put("6", "7");
bw.setPropertyValue("shortMap", input);
assertThat(gb.getShortMap().get(new Short("4"))).isEqualTo(5);
assertThat(gb.getShortMap().get(new Short("6"))).isEqualTo(7);
assertThat(gb.getShortMap().get(Short.valueOf("4"))).isEqualTo(5);
assertThat(gb.getShortMap().get(Short.valueOf("6"))).isEqualTo(7);
}
@Test
public void testGenericMapElement() {
void testGenericMapElement() {
GenericBean<?> gb = new GenericBean<>();
gb.setShortMap(new HashMap<>());
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.setPropertyValue("shortMap[4]", "5");
assertThat(bw.getPropertyValue("shortMap[4]")).isEqualTo(5);
assertThat(gb.getShortMap().get(new Short("4"))).isEqualTo(5);
assertThat(gb.getShortMap().get(Short.valueOf("4"))).isEqualTo(5);
}
@Test
public void testGenericMapWithKeyType() {
void testGenericMapWithKeyType() {
GenericBean<?> gb = new GenericBean<>();
BeanWrapper bw = new BeanWrapperImpl(gb);
Map<String, String> input = new HashMap<>();
......@@ -140,17 +140,17 @@ public class BeanWrapperGenericsTests {
}
@Test
public void testGenericMapElementWithKeyType() {
void testGenericMapElementWithKeyType() {
GenericBean<?> gb = new GenericBean<>();
gb.setLongMap(new HashMap<Long, Integer>());
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.setPropertyValue("longMap[4]", "5");
assertThat(gb.getLongMap().get(new Long("4"))).isEqualTo("5");
assertThat(gb.getLongMap().get(Long.valueOf("4"))).isEqualTo("5");
assertThat(bw.getPropertyValue("longMap[4]")).isEqualTo("5");
}
@Test
public void testGenericMapWithCollectionValue() {
void testGenericMapWithCollectionValue() {
GenericBean<?> gb = new GenericBean<>();
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.registerCustomEditor(Number.class, new CustomNumberEditor(Integer.class, false));
......@@ -169,7 +169,7 @@ public class BeanWrapperGenericsTests {
}
@Test
public void testGenericMapElementWithCollectionValue() {
void testGenericMapElementWithCollectionValue() {
GenericBean<?> gb = new GenericBean<>();
gb.setCollectionMap(new HashMap<>());
BeanWrapper bw = new BeanWrapperImpl(gb);
......@@ -182,19 +182,19 @@ public class BeanWrapperGenericsTests {
}
@Test
public void testGenericMapFromProperties() {
void testGenericMapFromProperties() {
GenericBean<?> gb = new GenericBean<>();
BeanWrapper bw = new BeanWrapperImpl(gb);
Properties input = new Properties();
input.setProperty("4", "5");
input.setProperty("6", "7");
bw.setPropertyValue("shortMap", input);
assertThat(gb.getShortMap().get(new Short("4"))).isEqualTo(5);
assertThat(gb.getShortMap().get(new Short("6"))).isEqualTo(7);
assertThat(gb.getShortMap().get(Short.valueOf("4"))).isEqualTo(5);
assertThat(gb.getShortMap().get(Short.valueOf("6"))).isEqualTo(7);
}
@Test
public void testGenericListOfLists() throws MalformedURLException {
void testGenericListOfLists() throws MalformedURLException {
GenericBean<String> gb = new GenericBean<>();
List<List<Integer>> list = new ArrayList<>();
list.add(new ArrayList<>());
......@@ -206,7 +206,7 @@ public class BeanWrapperGenericsTests {
}
@Test
public void testGenericListOfListsWithElementConversion() throws MalformedURLException {
void testGenericListOfListsWithElementConversion() throws MalformedURLException {
GenericBean<String> gb = new GenericBean<>();
List<List<Integer>> list = new ArrayList<>();
list.add(new ArrayList<>());
......@@ -218,7 +218,7 @@ public class BeanWrapperGenericsTests {
}
@Test
public void testGenericListOfArrays() throws MalformedURLException {
void testGenericListOfArrays() throws MalformedURLException {
GenericBean<String> gb = new GenericBean<>();
ArrayList<String[]> list = new ArrayList<>();
list.add(new String[] {"str1", "str2"});
......@@ -230,7 +230,7 @@ public class BeanWrapperGenericsTests {
}
@Test
public void testGenericListOfArraysWithElementConversion() throws MalformedURLException {
void testGenericListOfArraysWithElementConversion() throws MalformedURLException {
GenericBean<String> gb = new GenericBean<>();
ArrayList<String[]> list = new ArrayList<>();
list.add(new String[] {"str1", "str2"});
......@@ -243,55 +243,55 @@ public class BeanWrapperGenericsTests {
}
@Test
public void testGenericListOfMaps() throws MalformedURLException {
void testGenericListOfMaps() throws MalformedURLException {
GenericBean<String> gb = new GenericBean<>();
List<Map<Integer, Long>> list = new ArrayList<>();
list.add(new HashMap<>());
gb.setListOfMaps(list);
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.setPropertyValue("listOfMaps[0][10]", new Long(5));
assertThat(bw.getPropertyValue("listOfMaps[0][10]")).isEqualTo(new Long(5));
assertThat(gb.getListOfMaps().get(0).get(10)).isEqualTo(new Long(5));
bw.setPropertyValue("listOfMaps[0][10]", 5L);
assertThat(bw.getPropertyValue("listOfMaps[0][10]")).isEqualTo(5L);
assertThat(gb.getListOfMaps().get(0).get(10)).isEqualTo(Long.valueOf(5));
}
@Test
public void testGenericListOfMapsWithElementConversion() throws MalformedURLException {
void testGenericListOfMapsWithElementConversion() {
GenericBean<String> gb = new GenericBean<>();
List<Map<Integer, Long>> list = new ArrayList<>();
list.add(new HashMap<>());
gb.setListOfMaps(list);
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.setPropertyValue("listOfMaps[0][10]", "5");
assertThat(bw.getPropertyValue("listOfMaps[0][10]")).isEqualTo(new Long(5));
assertThat(gb.getListOfMaps().get(0).get(10)).isEqualTo(new Long(5));
assertThat(bw.getPropertyValue("listOfMaps[0][10]")).isEqualTo(5L);
assertThat(gb.getListOfMaps().get(0).get(10)).isEqualTo(Long.valueOf(5));
}
@Test
public void testGenericMapOfMaps() throws MalformedURLException {
void testGenericMapOfMaps() throws MalformedURLException {
GenericBean<String> gb = new GenericBean<>();
Map<String, Map<Integer, Long>> map = new HashMap<>();
map.put("mykey", new HashMap<>());
gb.setMapOfMaps(map);
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.setPropertyValue("mapOfMaps[mykey][10]", new Long(5));
assertThat(bw.getPropertyValue("mapOfMaps[mykey][10]")).isEqualTo(new Long(5));
assertThat(gb.getMapOfMaps().get("mykey").get(10)).isEqualTo(new Long(5));
bw.setPropertyValue("mapOfMaps[mykey][10]", 5L);
assertThat(bw.getPropertyValue("mapOfMaps[mykey][10]")).isEqualTo(5L);
assertThat(gb.getMapOfMaps().get("mykey").get(10)).isEqualTo(Long.valueOf(5));
}
@Test
public void testGenericMapOfMapsWithElementConversion() throws MalformedURLException {
void testGenericMapOfMapsWithElementConversion() throws MalformedURLException {
GenericBean<String> gb = new GenericBean<>();
Map<String, Map<Integer, Long>> map = new HashMap<>();
map.put("mykey", new HashMap<>());
gb.setMapOfMaps(map);
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.setPropertyValue("mapOfMaps[mykey][10]", "5");
assertThat(bw.getPropertyValue("mapOfMaps[mykey][10]")).isEqualTo(new Long(5));
assertThat(gb.getMapOfMaps().get("mykey").get(10)).isEqualTo(new Long(5));
assertThat(bw.getPropertyValue("mapOfMaps[mykey][10]")).isEqualTo(Long.valueOf(5));
assertThat(gb.getMapOfMaps().get("mykey").get(10)).isEqualTo(Long.valueOf(5));
}
@Test
public void testGenericMapOfLists() throws MalformedURLException {
void testGenericMapOfLists() throws MalformedURLException {
GenericBean<String> gb = new GenericBean<>();
Map<Integer, List<Integer>> map = new HashMap<>();
map.put(1, new ArrayList<>());
......@@ -303,7 +303,7 @@ public class BeanWrapperGenericsTests {
}
@Test
public void testGenericMapOfListsWithElementConversion() throws MalformedURLException {
void testGenericMapOfListsWithElementConversion() throws MalformedURLException {
GenericBean<String> gb = new GenericBean<>();
Map<Integer, List<Integer>> map = new HashMap<>();
map.put(1, new ArrayList<>());
......@@ -315,7 +315,7 @@ public class BeanWrapperGenericsTests {
}
@Test
public void testGenericTypeNestingMapOfInteger() throws Exception {
void testGenericTypeNestingMapOfInteger() throws Exception {
Map<String, String> map = new HashMap<>();
map.put("testKey", "100");
......@@ -329,9 +329,9 @@ public class BeanWrapperGenericsTests {
}
@Test
public void testGenericTypeNestingMapOfListOfInteger() throws Exception {
void testGenericTypeNestingMapOfListOfInteger() throws Exception {
Map<String, List<String>> map = new HashMap<>();
List<String> list = Arrays.asList(new String[] {"1", "2", "3"});
List<String> list = Arrays.asList("1", "2", "3");
map.put("testKey", list);
NestedGenericCollectionBean gb = new NestedGenericCollectionBean();
......@@ -345,7 +345,7 @@ public class BeanWrapperGenericsTests {
}
@Test
public void testGenericTypeNestingListOfMapOfInteger() throws Exception {
void testGenericTypeNestingListOfMapOfInteger() throws Exception {
List<Map<String, String>> list = new ArrayList<>();
Map<String, String> map = new HashMap<>();
map.put("testKey", "5");
......@@ -362,9 +362,9 @@ public class BeanWrapperGenericsTests {
}
@Test
public void testGenericTypeNestingMapOfListOfListOfInteger() throws Exception {
void testGenericTypeNestingMapOfListOfListOfInteger() throws Exception {
Map<String, List<List<String>>> map = new HashMap<>();
List<String> list = Arrays.asList(new String[] {"1", "2", "3"});
List<String> list = Arrays.asList("1", "2", "3");
map.put("testKey", Collections.singletonList(list));
NestedGenericCollectionBean gb = new NestedGenericCollectionBean();
......@@ -378,7 +378,7 @@ public class BeanWrapperGenericsTests {
}
@Test
public void testComplexGenericMap() {
void testComplexGenericMap() {
Map<List<String>, List<String>> inputMap = new HashMap<>();
List<String> inputKey = new ArrayList<>();
inputKey.add("1");
......@@ -391,11 +391,11 @@ public class BeanWrapperGenericsTests {
bw.setPropertyValue("genericMap", inputMap);
assertThat(holder.getGenericMap().keySet().iterator().next().get(0)).isEqualTo(1);
assertThat(holder.getGenericMap().values().iterator().next().get(0)).isEqualTo(new Long(10));
assertThat(holder.getGenericMap().values().iterator().next().get(0)).isEqualTo(Long.valueOf(10));
}
@Test
public void testComplexGenericMapWithCollectionConversion() {
void testComplexGenericMapWithCollectionConversion() {
Map<Set<String>, Set<String>> inputMap = new HashMap<>();
Set<String> inputKey = new HashSet<>();
inputKey.add("1");
......@@ -408,11 +408,11 @@ public class BeanWrapperGenericsTests {
bw.setPropertyValue("genericMap", inputMap);
assertThat(holder.getGenericMap().keySet().iterator().next().get(0)).isEqualTo(1);
assertThat(holder.getGenericMap().values().iterator().next().get(0)).isEqualTo(new Long(10));
assertThat(holder.getGenericMap().values().iterator().next().get(0)).isEqualTo(Long.valueOf(10));
}
@Test
public void testComplexGenericIndexedMapEntry() {
void testComplexGenericIndexedMapEntry() {
List<String> inputValue = new ArrayList<>();
inputValue.add("10");
......@@ -421,11 +421,11 @@ public class BeanWrapperGenericsTests {
bw.setPropertyValue("genericIndexedMap[1]", inputValue);
assertThat(holder.getGenericIndexedMap().keySet().iterator().next()).isEqualTo(1);
assertThat(holder.getGenericIndexedMap().values().iterator().next().get(0)).isEqualTo(new Long(10));
assertThat(holder.getGenericIndexedMap().values().iterator().next().get(0)).isEqualTo(Long.valueOf(10));
}
@Test
public void testComplexGenericIndexedMapEntryWithCollectionConversion() {
void testComplexGenericIndexedMapEntryWithCollectionConversion() {
Set<String> inputValue = new HashSet<>();
inputValue.add("10");
......@@ -434,11 +434,11 @@ public class BeanWrapperGenericsTests {
bw.setPropertyValue("genericIndexedMap[1]", inputValue);
assertThat(holder.getGenericIndexedMap().keySet().iterator().next()).isEqualTo(1);
assertThat(holder.getGenericIndexedMap().values().iterator().next().get(0)).isEqualTo(new Long(10));
assertThat(holder.getGenericIndexedMap().values().iterator().next().get(0)).isEqualTo(Long.valueOf(10));
}
@Test
public void testComplexDerivedIndexedMapEntry() {
void testComplexDerivedIndexedMapEntry() {
List<String> inputValue = new ArrayList<>();
inputValue.add("10");
......@@ -447,11 +447,11 @@ public class BeanWrapperGenericsTests {
bw.setPropertyValue("derivedIndexedMap[1]", inputValue);
assertThat(holder.getDerivedIndexedMap().keySet().iterator().next()).isEqualTo(1);
assertThat(holder.getDerivedIndexedMap().values().iterator().next().get(0)).isEqualTo(new Long(10));
assertThat(holder.getDerivedIndexedMap().values().iterator().next().get(0)).isEqualTo(Long.valueOf(10));
}
@Test
public void testComplexDerivedIndexedMapEntryWithCollectionConversion() {
void testComplexDerivedIndexedMapEntryWithCollectionConversion() {
Set<String> inputValue = new HashSet<>();
inputValue.add("10");
......@@ -460,11 +460,11 @@ public class BeanWrapperGenericsTests {
bw.setPropertyValue("derivedIndexedMap[1]", inputValue);
assertThat(holder.getDerivedIndexedMap().keySet().iterator().next()).isEqualTo(1);
assertThat(holder.getDerivedIndexedMap().values().iterator().next().get(0)).isEqualTo(new Long(10));
assertThat(holder.getDerivedIndexedMap().values().iterator().next().get(0)).isEqualTo(Long.valueOf(10));
}
@Test
public void testGenericallyTypedIntegerBean() throws Exception {
void testGenericallyTypedIntegerBean() {
GenericIntegerBean gb = new GenericIntegerBean();
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.setPropertyValue("genericProperty", "10");
......@@ -475,7 +475,7 @@ public class BeanWrapperGenericsTests {
}
@Test
public void testGenericallyTypedSetOfIntegerBean() throws Exception {
void testGenericallyTypedSetOfIntegerBean() {
GenericSetOfIntegerBean gb = new GenericSetOfIntegerBean();
BeanWrapper bw = new BeanWrapperImpl(gb);
bw.setPropertyValue("genericProperty", "10");
......@@ -486,23 +486,23 @@ public class BeanWrapperGenericsTests {
}
@Test
public void testSettingGenericPropertyWithReadOnlyInterface() {
void testSettingGenericPropertyWithReadOnlyInterface() {
Bar bar = new Bar();
BeanWrapper bw = new BeanWrapperImpl(bar);
bw.setPropertyValue("version", "10");
assertThat(bar.getVersion()).isEqualTo(new Double(10.0));
assertThat(bar.getVersion()).isEqualTo(Double.valueOf(10.0));
}
@Test
public void testSettingLongPropertyWithGenericInterface() {
void testSettingLongPropertyWithGenericInterface() {
Promotion bean = new Promotion();
BeanWrapper bw = new BeanWrapperImpl(bean);
bw.setPropertyValue("id", "10");
assertThat(bean.getId()).isEqualTo(new Long(10));
assertThat(bean.getId()).isEqualTo(Long.valueOf(10));
}
@Test
public void testUntypedPropertyWithMapAtRuntime() {
void testUntypedPropertyWithMapAtRuntime() {
class Holder<D> {
private final D data;
public Holder(D data) {
......
/*
* 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.
......@@ -182,9 +182,9 @@ class DefaultListableBeanFactoryTests {
assertThat(!DummyFactory.wasPrototypeCreated()).as("prototype not instantiated").isTrue();
String[] beanNames = lbf.getBeanNamesForType(TestBean.class, true, false);
assertThat(beanNames.length).isEqualTo(0);
assertThat(beanNames).hasSize(0);
beanNames = lbf.getBeanNamesForAnnotation(SuppressWarnings.class);
assertThat(beanNames.length).isEqualTo(0);
assertThat(beanNames).hasSize(0);
assertThat(lbf.containsSingleton("x1")).isFalse();
assertThat(lbf.containsBean("x1")).isTrue();
......@@ -216,9 +216,9 @@ class DefaultListableBeanFactoryTests {
assertThat(!DummyFactory.wasPrototypeCreated()).as("prototype not instantiated").isTrue();
String[] beanNames = lbf.getBeanNamesForType(TestBean.class, true, false);
assertThat(beanNames.length).isEqualTo(0);
assertThat(beanNames).hasSize(0);
beanNames = lbf.getBeanNamesForAnnotation(SuppressWarnings.class);
assertThat(beanNames.length).isEqualTo(0);
assertThat(beanNames).hasSize(0);
assertThat(lbf.containsSingleton("x1")).isFalse();
assertThat(lbf.containsBean("x1")).isTrue();
......@@ -249,9 +249,9 @@ class DefaultListableBeanFactoryTests {
assertThat(!DummyFactory.wasPrototypeCreated()).as("prototype not instantiated").isTrue();
String[] beanNames = lbf.getBeanNamesForType(TestBean.class, true, false);
assertThat(beanNames.length).isEqualTo(0);
assertThat(beanNames).hasSize(0);
beanNames = lbf.getBeanNamesForAnnotation(SuppressWarnings.class);
assertThat(beanNames.length).isEqualTo(0);
assertThat(beanNames).hasSize(0);
assertThat(lbf.containsSingleton("x1")).isFalse();
assertThat(lbf.containsBean("x1")).isTrue();
......@@ -283,7 +283,7 @@ class DefaultListableBeanFactoryTests {
assertThat(!DummyFactory.wasPrototypeCreated()).as("prototype not instantiated").isTrue();
String[] beanNames = lbf.getBeanNamesForType(TestBean.class, true, false);
assertThat(beanNames.length).isEqualTo(1);
assertThat(beanNames).hasSize(1);
assertThat(beanNames[0]).isEqualTo("x1");
assertThat(lbf.containsSingleton("x1")).isTrue();
assertThat(lbf.containsBean("x1")).isTrue();
......@@ -337,7 +337,7 @@ class DefaultListableBeanFactoryTests {
TestBeanFactory.initialized = false;
String[] beanNames = lbf.getBeanNamesForType(TestBean.class, true, false);
assertThat(beanNames.length).isEqualTo(1);
assertThat(beanNames).hasSize(1);
assertThat(beanNames[0]).isEqualTo("x1");
assertThat(lbf.containsSingleton("x1")).isFalse();
assertThat(lbf.containsBean("x1")).isTrue();
......@@ -349,7 +349,7 @@ class DefaultListableBeanFactoryTests {
assertThat(lbf.isTypeMatch("x1", TestBean.class)).isTrue();
assertThat(lbf.isTypeMatch("&x1", TestBean.class)).isFalse();
assertThat(lbf.getType("x1")).isEqualTo(TestBean.class);
assertThat(lbf.getType("&x1")).isEqualTo(null);
assertThat(lbf.getType("&x1")).isNull();
assertThat(TestBeanFactory.initialized).isFalse();
}
......@@ -362,7 +362,7 @@ class DefaultListableBeanFactoryTests {
TestBeanFactory.initialized = false;
String[] beanNames = lbf.getBeanNamesForType(TestBean.class, true, false);
assertThat(beanNames.length).isEqualTo(1);
assertThat(beanNames).hasSize(1);
assertThat(beanNames[0]).isEqualTo("x1");
assertThat(lbf.containsSingleton("x1")).isFalse();
assertThat(lbf.containsBean("x1")).isTrue();
......@@ -374,7 +374,7 @@ class DefaultListableBeanFactoryTests {
assertThat(lbf.isTypeMatch("x1", TestBean.class)).isTrue();
assertThat(lbf.isTypeMatch("&x1", TestBean.class)).isFalse();
assertThat(lbf.getType("x1")).isEqualTo(TestBean.class);
assertThat(lbf.getType("&x1")).isEqualTo(null);
assertThat(lbf.getType("&x1")).isNull();
assertThat(TestBeanFactory.initialized).isFalse();
}
......@@ -389,7 +389,7 @@ class DefaultListableBeanFactoryTests {
TestBeanFactory.initialized = false;
String[] beanNames = lbf.getBeanNamesForType(TestBean.class, true, false);
assertThat(beanNames.length).isEqualTo(1);
assertThat(beanNames).hasSize(1);
assertThat(beanNames[0]).isEqualTo("x1");
assertThat(lbf.containsSingleton("x1")).isFalse();
assertThat(lbf.containsBean("x1")).isTrue();
......@@ -401,7 +401,7 @@ class DefaultListableBeanFactoryTests {
assertThat(lbf.isTypeMatch("x1", TestBean.class)).isTrue();
assertThat(lbf.isTypeMatch("&x1", TestBean.class)).isFalse();
assertThat(lbf.getType("x1")).isEqualTo(TestBean.class);
assertThat(lbf.getType("&x1")).isEqualTo(null);
assertThat(lbf.getType("&x1")).isNull();
assertThat(TestBeanFactory.initialized).isFalse();
}
......@@ -417,7 +417,7 @@ class DefaultListableBeanFactoryTests {
TestBeanFactory.initialized = false;
String[] beanNames = lbf.getBeanNamesForType(TestBean.class, true, false);
assertThat(beanNames.length).isEqualTo(1);
assertThat(beanNames).hasSize(1);
assertThat(beanNames[0]).isEqualTo("x1");
assertThat(lbf.containsSingleton("x1")).isFalse();
assertThat(lbf.containsBean("x1")).isTrue();
......@@ -450,7 +450,7 @@ class DefaultListableBeanFactoryTests {
assertThat(lbf.isTypeMatch("x2", Object.class)).isTrue();
assertThat(lbf.isTypeMatch("&x2", Object.class)).isFalse();
assertThat(lbf.getType("x2")).isEqualTo(TestBean.class);
assertThat(lbf.getType("&x2")).isEqualTo(null);
assertThat(lbf.getType("&x2")).isNull();
assertThat(lbf.getAliases("x1").length).isEqualTo(1);
assertThat(lbf.getAliases("x1")[0]).isEqualTo("x2");
assertThat(lbf.getAliases("&x1").length).isEqualTo(1);
......@@ -3030,7 +3030,7 @@ class DefaultListableBeanFactoryTests {
public Object convertIfNecessary(Object value, @Nullable Class requiredType) {
if (value instanceof String && Float.class.isAssignableFrom(requiredType)) {
try {
return new Float(this.numberFormat.parse((String) value).floatValue());
return this.numberFormat.parse((String) value).floatValue();
}
catch (ParseException ex) {
throw new TypeMismatchException(value, requiredType, ex);
......
/*
* Copyright 2002-2019 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.
......@@ -26,18 +26,18 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
*
* @author Rick Evans
*/
public class ClassNameBeanWiringInfoResolverTests {
class ClassNameBeanWiringInfoResolverTests {
@Test
public void resolveWiringInfoWithNullBeanInstance() throws Exception {
void resolveWiringInfoWithNullBeanInstance() throws Exception {
assertThatIllegalArgumentException().isThrownBy(() ->
new ClassNameBeanWiringInfoResolver().resolveWiringInfo(null));
}
@Test
public void resolveWiringInfo() {
void resolveWiringInfo() {
ClassNameBeanWiringInfoResolver resolver = new ClassNameBeanWiringInfoResolver();
Long beanInstance = new Long(1);
Long beanInstance = 1L;
BeanWiringInfo info = resolver.resolveWiringInfo(beanInstance);
assertThat(info).isNotNull();
assertThat(info.getBeanName()).as("Not resolving bean name to the class name of the supplied bean instance as per class contract.").isEqualTo(beanInstance.getClass().getName());
......
......@@ -162,13 +162,13 @@ class ProceedTestingAspect implements Ordered {
public Object doubleOrQuits(ProceedingJoinPoint pjp) throws Throwable {
int value = ((Integer) pjp.getArgs()[0]).intValue();
pjp.getArgs()[0] = new Integer(value * 2);
pjp.getArgs()[0] = Integer.valueOf(value * 2);
return pjp.proceed();
}
public Object addOne(ProceedingJoinPoint pjp, Float value) throws Throwable {
float fv = value.floatValue();
return pjp.proceed(new Object[] {new Float(fv + 1.0F)});
return pjp.proceed(new Object[] {Float.valueOf(fv + 1.0F)});
}
public void captureStringArgument(JoinPoint tjp, String arg) {
......
......@@ -79,7 +79,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
* @author Stephane Nicoll
* @author Juergen Hoeller
*/
public class AnnotationDrivenEventListenerTests {
class AnnotationDrivenEventListenerTests {
private ConfigurableApplicationContext context;
......@@ -97,7 +97,7 @@ public class AnnotationDrivenEventListenerTests {
@Test
public void simpleEventJavaConfig() {
void simpleEventJavaConfig() {
load(TestEventListener.class);
TestEvent event = new TestEvent(this, "test");
TestEventListener listener = this.context.getBean(TestEventListener.class);
......@@ -120,7 +120,7 @@ public class AnnotationDrivenEventListenerTests {
}
@Test
public void simpleEventXmlConfig() {
void simpleEventXmlConfig() {
this.context = new ClassPathXmlApplicationContext(
"org/springframework/context/event/simple-event-configuration.xml");
......@@ -141,7 +141,7 @@ public class AnnotationDrivenEventListenerTests {
}
@Test
public void metaAnnotationIsDiscovered() {
void metaAnnotationIsDiscovered() {
load(MetaAnnotationListenerTestBean.class);
MetaAnnotationListenerTestBean bean = this.context.getBean(MetaAnnotationListenerTestBean.class);
this.eventCollector.assertNoEventReceived(bean);
......@@ -159,7 +159,7 @@ public class AnnotationDrivenEventListenerTests {
}
@Test
public void contextEventsAreReceived() {
void contextEventsAreReceived() {
load(ContextEventListener.class);
ContextEventListener listener = this.context.getBean(ContextEventListener.class);
......@@ -175,7 +175,7 @@ public class AnnotationDrivenEventListenerTests {
}
@Test
public void methodSignatureNoEvent() {
void methodSignatureNoEvent() {
@SuppressWarnings("resource")
AnnotationConfigApplicationContext failingContext =
new AnnotationConfigApplicationContext();
......@@ -189,7 +189,7 @@ public class AnnotationDrivenEventListenerTests {
}
@Test
public void simpleReply() {
void simpleReply() {
load(TestEventListener.class, ReplyEventListener.class);
AnotherTestEvent event = new AnotherTestEvent(this, "dummy");
ReplyEventListener replyEventListener = this.context.getBean(ReplyEventListener.class);
......@@ -204,7 +204,7 @@ public class AnnotationDrivenEventListenerTests {
}
@Test
public void nullReplyIgnored() {
void nullReplyIgnored() {
load(TestEventListener.class, ReplyEventListener.class);
AnotherTestEvent event = new AnotherTestEvent(this, null); // No response
ReplyEventListener replyEventListener = this.context.getBean(ReplyEventListener.class);
......@@ -219,7 +219,7 @@ public class AnnotationDrivenEventListenerTests {
}
@Test
public void arrayReply() {
void arrayReply() {
load(TestEventListener.class, ReplyEventListener.class);
AnotherTestEvent event = new AnotherTestEvent(this, new String[]{"first", "second"});
ReplyEventListener replyEventListener = this.context.getBean(ReplyEventListener.class);
......@@ -234,7 +234,7 @@ public class AnnotationDrivenEventListenerTests {
}
@Test
public void collectionReply() {
void collectionReply() {
load(TestEventListener.class, ReplyEventListener.class);
Set<Object> replies = new LinkedHashSet<>();
replies.add("first");
......@@ -253,7 +253,7 @@ public class AnnotationDrivenEventListenerTests {
}
@Test
public void collectionReplyNullValue() {
void collectionReplyNullValue() {
load(TestEventListener.class, ReplyEventListener.class);
AnotherTestEvent event = new AnotherTestEvent(this, Arrays.asList(null, "test"));
ReplyEventListener replyEventListener = this.context.getBean(ReplyEventListener.class);
......@@ -268,7 +268,7 @@ public class AnnotationDrivenEventListenerTests {
}
@Test
public void listenableFutureReply() {
void listenableFutureReply() {
load(TestEventListener.class, ReplyEventListener.class);
SettableListenableFuture<String> future = new SettableListenableFuture<>();
future.set("dummy");
......@@ -285,7 +285,7 @@ public class AnnotationDrivenEventListenerTests {
}
@Test
public void completableFutureReply() {
void completableFutureReply() {
load(TestEventListener.class, ReplyEventListener.class);
AnotherTestEvent event = new AnotherTestEvent(this, CompletableFuture.completedFuture("dummy"));
ReplyEventListener replyEventListener = this.context.getBean(ReplyEventListener.class);
......@@ -300,7 +300,7 @@ public class AnnotationDrivenEventListenerTests {
}
@Test
public void monoReply() {
void monoReply() {
load(TestEventListener.class, ReplyEventListener.class);
AnotherTestEvent event = new AnotherTestEvent(this, Mono.just("dummy"));
ReplyEventListener replyEventListener = this.context.getBean(ReplyEventListener.class);
......@@ -315,7 +315,7 @@ public class AnnotationDrivenEventListenerTests {
}
@Test
public void fluxReply() {
void fluxReply() {
load(TestEventListener.class, ReplyEventListener.class);
AnotherTestEvent event = new AnotherTestEvent(this, Flux.just("dummy1", "dummy2"));
ReplyEventListener replyEventListener = this.context.getBean(ReplyEventListener.class);
......@@ -330,7 +330,7 @@ public class AnnotationDrivenEventListenerTests {
}
@Test
public void eventListenerWorksWithSimpleInterfaceProxy() {
void eventListenerWorksWithSimpleInterfaceProxy() {
load(ScopedProxyTestBean.class);
SimpleService proxy = this.context.getBean(SimpleService.class);
......@@ -347,7 +347,7 @@ public class AnnotationDrivenEventListenerTests {
}
@Test
public void eventListenerWorksWithAnnotatedInterfaceProxy() {
void eventListenerWorksWithAnnotatedInterfaceProxy() {
load(AnnotatedProxyTestBean.class);
AnnotatedSimpleService proxy = this.context.getBean(AnnotatedSimpleService.class);
......@@ -364,7 +364,7 @@ public class AnnotationDrivenEventListenerTests {
}
@Test
public void eventListenerWorksWithCglibProxy() {
void eventListenerWorksWithCglibProxy() {
load(CglibProxyTestBean.class);
CglibProxyTestBean proxy = this.context.getBean(CglibProxyTestBean.class);
......@@ -381,14 +381,14 @@ public class AnnotationDrivenEventListenerTests {
}
@Test
public void privateMethodOnCglibProxyFails() {
void privateMethodOnCglibProxyFails() {
assertThatExceptionOfType(BeanInitializationException.class).isThrownBy(() ->
load(CglibProxyWithPrivateMethod.class))
.withCauseInstanceOf(IllegalStateException.class);
}
@Test
public void eventListenerWorksWithCustomScope() {
void eventListenerWorksWithCustomScope() {
load(CustomScopeTestBean.class);
CustomScope customScope = new CustomScope();
this.context.getBeanFactory().registerScope("custom", customScope);
......@@ -417,7 +417,7 @@ public class AnnotationDrivenEventListenerTests {
}
@Test
public void asyncProcessingApplied() throws InterruptedException {
void asyncProcessingApplied() throws InterruptedException {
loadAsync(AsyncEventListener.class);
String threadName = Thread.currentThread().getName();
......@@ -432,7 +432,7 @@ public class AnnotationDrivenEventListenerTests {
}
@Test
public void asyncProcessingAppliedWithInterfaceProxy() throws InterruptedException {
void asyncProcessingAppliedWithInterfaceProxy() throws InterruptedException {
doLoad(AsyncConfigurationWithInterfaces.class, SimpleProxyTestBean.class);
String threadName = Thread.currentThread().getName();
......@@ -447,7 +447,7 @@ public class AnnotationDrivenEventListenerTests {
}
@Test
public void asyncProcessingAppliedWithScopedProxy() throws InterruptedException {
void asyncProcessingAppliedWithScopedProxy() throws InterruptedException {
doLoad(AsyncConfigurationWithInterfaces.class, ScopedProxyTestBean.class);
String threadName = Thread.currentThread().getName();
......@@ -462,7 +462,7 @@ public class AnnotationDrivenEventListenerTests {
}
@Test
public void exceptionPropagated() {
void exceptionPropagated() {
load(ExceptionEventListener.class);
TestEvent event = new TestEvent(this, "fail");
ExceptionEventListener listener = this.context.getBean(ExceptionEventListener.class);
......@@ -475,7 +475,7 @@ public class AnnotationDrivenEventListenerTests {
}
@Test
public void exceptionNotPropagatedWithAsync() throws InterruptedException {
void exceptionNotPropagatedWithAsync() throws InterruptedException {
loadAsync(ExceptionEventListener.class);
AnotherTestEvent event = new AnotherTestEvent(this, "fail");
ExceptionEventListener listener = this.context.getBean(ExceptionEventListener.class);
......@@ -489,7 +489,7 @@ public class AnnotationDrivenEventListenerTests {
}
@Test
public void listenerWithSimplePayload() {
void listenerWithSimplePayload() {
load(TestEventListener.class);
TestEventListener listener = this.context.getBean(TestEventListener.class);
......@@ -500,7 +500,7 @@ public class AnnotationDrivenEventListenerTests {
}
@Test
public void listenerWithNonMatchingPayload() {
void listenerWithNonMatchingPayload() {
load(TestEventListener.class);
TestEventListener listener = this.context.getBean(TestEventListener.class);
......@@ -511,7 +511,7 @@ public class AnnotationDrivenEventListenerTests {
}
@Test
public void replyWithPayload() {
void replyWithPayload() {
load(TestEventListener.class, ReplyEventListener.class);
AnotherTestEvent event = new AnotherTestEvent(this, "String");
ReplyEventListener replyEventListener = this.context.getBean(ReplyEventListener.class);
......@@ -527,7 +527,7 @@ public class AnnotationDrivenEventListenerTests {
}
@Test
public void listenerWithGenericApplicationEvent() {
void listenerWithGenericApplicationEvent() {
load(GenericEventListener.class);
GenericEventListener listener = this.context.getBean(GenericEventListener.class);
......@@ -538,7 +538,7 @@ public class AnnotationDrivenEventListenerTests {
}
@Test
public void listenerWithResolvableTypeEvent() {
void listenerWithResolvableTypeEvent() {
load(ResolvableTypeEventListener.class);
ResolvableTypeEventListener listener = this.context.getBean(ResolvableTypeEventListener.class);
......@@ -550,7 +550,7 @@ public class AnnotationDrivenEventListenerTests {
}
@Test
public void listenerWithResolvableTypeEventWrongGeneric() {
void listenerWithResolvableTypeEventWrongGeneric() {
load(ResolvableTypeEventListener.class);
ResolvableTypeEventListener listener = this.context.getBean(ResolvableTypeEventListener.class);
......@@ -562,12 +562,12 @@ public class AnnotationDrivenEventListenerTests {
}
@Test
public void conditionMatch() {
void conditionMatch() {
validateConditionMatch(ConditionalEventListener.class);
}
@Test
public void conditionMatchWithProxy() {
void conditionMatchWithProxy() {
validateConditionMatch(ConditionalEventListener.class, MethodValidationPostProcessor.class);
}
......@@ -600,7 +600,7 @@ public class AnnotationDrivenEventListenerTests {
}
@Test
public void conditionDoesNotMatch() {
void conditionDoesNotMatch() {
long maxLong = Long.MAX_VALUE;
load(ConditionalEventListener.class);
TestEvent event = new TestEvent(this, "KO");
......@@ -625,7 +625,7 @@ public class AnnotationDrivenEventListenerTests {
}
@Test
public void orderedListeners() {
void orderedListeners() {
load(OrderedTestListener.class);
OrderedTestListener listener = this.context.getBean(OrderedTestListener.class);
......@@ -635,7 +635,7 @@ public class AnnotationDrivenEventListenerTests {
}
@Test @Disabled // SPR-15122
public void listenersReceiveEarlyEvents() {
void listenersReceiveEarlyEvents() {
load(EventOnPostConstruct.class, OrderedTestListener.class);
OrderedTestListener listener = this.context.getBean(OrderedTestListener.class);
......@@ -643,7 +643,7 @@ public class AnnotationDrivenEventListenerTests {
}
@Test
public void missingListenerBeanIgnored() {
void missingListenerBeanIgnored() {
load(MissingEventListener.class);
context.getBean(UseMissingEventListener.class);
context.getBean(ApplicationEventMulticaster.class).multicastEvent(new TestEvent(this));
......@@ -697,7 +697,7 @@ public class AnnotationDrivenEventListenerTests {
static class TestConditionEvaluator {
public boolean valid(Double ratio) {
return new Double(42).equals(ratio);
return Double.valueOf(42).equals(ratio);
}
}
}
......
/*
* 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.
......@@ -341,10 +341,10 @@ public class MBeanExporterTests extends AbstractMBeanServerTests {
assertIsRegistered("Bean instance not registered", objectName);
Object result = server.invoke(objectName, "add", new Object[] {new Integer(2), new Integer(3)}, new String[] {
Object result = server.invoke(objectName, "add", new Object[] {2, 3}, new String[] {
int.class.getName(), int.class.getName()});
assertThat(new Integer(5)).as("Incorrect result return from add").isEqualTo(result);
assertThat(Integer.valueOf(5)).as("Incorrect result return from add").isEqualTo(result);
assertThat(server.getAttribute(objectName, "Name")).as("Incorrect attribute value").isEqualTo(name);
server.setAttribute(objectName, new Attribute("Name", otherName));
......@@ -352,7 +352,7 @@ public class MBeanExporterTests extends AbstractMBeanServerTests {
}
@Test
void testBonaFideMBeanIsNotExportedWhenAutodetectIsTotallyTurnedOff() throws Exception {
void testBonaFideMBeanIsNotExportedWhenAutodetectIsTotallyTurnedOff() {
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(Person.class);
DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
factory.registerBeanDefinition("^&_invalidObjectName_(*", builder.getBeanDefinition());
......
/*
* Copyright 2002-2019 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.
......@@ -60,7 +60,7 @@ public abstract class AbstractJmxAssemblerTests extends AbstractJmxTests {
IJmxTestBean bean = getBean();
assertThat(bean).isNotNull();
MBeanInfo inf = getMBeanInfo();
assertThat(inf.getOperations().length).as("Incorrect number of operations registered").isEqualTo(getExpectedOperationCount());
assertThat(inf.getOperations()).as("Incorrect number of operations registered").hasSize(getExpectedOperationCount());
}
@Test
......@@ -68,7 +68,7 @@ public abstract class AbstractJmxAssemblerTests extends AbstractJmxTests {
IJmxTestBean bean = getBean();
assertThat(bean).isNotNull();
MBeanInfo inf = getMBeanInfo();
assertThat(inf.getAttributes().length).as("Incorrect number of attributes registered").isEqualTo(getExpectedAttributeCount());
assertThat(inf.getAttributes()).as("Incorrect number of attributes registered").hasSize(getExpectedAttributeCount());
}
@Test
......@@ -81,7 +81,7 @@ public abstract class AbstractJmxAssemblerTests extends AbstractJmxTests {
public void testGetMBeanAttributeInfo() throws Exception {
ModelMBeanInfo info = getMBeanInfoFromAssembler();
MBeanAttributeInfo[] inf = info.getAttributes();
assertThat(inf.length).as("Invalid number of Attributes returned").isEqualTo(getExpectedAttributeCount());
assertThat(inf).as("Invalid number of Attributes returned").hasSize(getExpectedAttributeCount());
for (int x = 0; x < inf.length; x++) {
assertThat(inf[x]).as("MBeanAttributeInfo should not be null").isNotNull();
......@@ -93,7 +93,7 @@ public abstract class AbstractJmxAssemblerTests extends AbstractJmxTests {
public void testGetMBeanOperationInfo() throws Exception {
ModelMBeanInfo info = getMBeanInfoFromAssembler();
MBeanOperationInfo[] inf = info.getOperations();
assertThat(inf.length).as("Invalid number of Operations returned").isEqualTo(getExpectedOperationCount());
assertThat(inf).as("Invalid number of Operations returned").hasSize(getExpectedOperationCount());
for (int x = 0; x < inf.length; x++) {
assertThat(inf[x]).as("MBeanOperationInfo should not be null").isNotNull();
......@@ -128,8 +128,8 @@ public abstract class AbstractJmxAssemblerTests extends AbstractJmxTests {
public void testOperationInvocation() throws Exception{
ObjectName objectName = ObjectNameManager.getInstance(getObjectName());
Object result = getServer().invoke(objectName, "add",
new Object[] {new Integer(20), new Integer(30)}, new String[] {"int", "int"});
assertThat(result).as("Incorrect result").isEqualTo(new Integer(50));
new Object[] {20, 30}, new String[] {"int", "int"});
assertThat(result).as("Incorrect result").isEqualTo(50);
}
@Test
......@@ -150,12 +150,12 @@ public abstract class AbstractJmxAssemblerTests extends AbstractJmxTests {
ModelMBeanOperationInfo get = info.getOperation("getName");
assertThat(get).as("get operation should not be null").isNotNull();
assertThat(new Integer(4)).as("get operation should have visibility of four").isEqualTo(get.getDescriptor().getFieldValue("visibility"));
assertThat(Integer.valueOf(4)).as("get operation should have visibility of four").isEqualTo(get.getDescriptor().getFieldValue("visibility"));
assertThat(get.getDescriptor().getFieldValue("role")).as("get operation should have role \"getter\"").isEqualTo("getter");
ModelMBeanOperationInfo set = info.getOperation("setName");
assertThat(set).as("set operation should not be null").isNotNull();
assertThat(new Integer(4)).as("set operation should have visibility of four").isEqualTo(set.getDescriptor().getFieldValue("visibility"));
assertThat(Integer.valueOf(4)).as("set operation should have visibility of four").isEqualTo(set.getDescriptor().getFieldValue("visibility"));
assertThat(set.getDescriptor().getFieldValue("role")).as("set operation should have role \"setter\"").isEqualTo("setter");
}
......@@ -163,12 +163,12 @@ public abstract class AbstractJmxAssemblerTests extends AbstractJmxTests {
public void testNotificationMetadata() throws Exception {
ModelMBeanInfo info = (ModelMBeanInfo) getMBeanInfo();
MBeanNotificationInfo[] notifications = info.getNotifications();
assertThat(notifications.length).as("Incorrect number of notifications").isEqualTo(1);
assertThat(notifications).as("Incorrect number of notifications").hasSize(1);
assertThat(notifications[0].getName()).as("Incorrect notification name").isEqualTo("My Notification");
String[] notifTypes = notifications[0].getNotifTypes();
assertThat(notifTypes.length).as("Incorrect number of notification types").isEqualTo(2);
assertThat(notifTypes).as("Incorrect number of notification types").hasSize(2);
assertThat(notifTypes[0]).as("Notification type.foo not found").isEqualTo("type.foo");
assertThat(notifTypes[1]).as("Notification type.bar not found").isEqualTo("type.bar");
}
......
/*
* Copyright 2002-2019 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.
......@@ -41,7 +41,7 @@ import static org.springframework.core.testfixture.TestGroup.LONG_RUNNING;
* @author Chris Beams
*/
@EnabledForTestGroups(LONG_RUNNING)
public class ScriptFactoryPostProcessorTests {
class ScriptFactoryPostProcessorTests {
private static final String MESSAGE_TEXT = "Bingo";
......@@ -79,18 +79,18 @@ public class ScriptFactoryPostProcessorTests {
@Test
public void testDoesNothingWhenPostProcessingNonScriptFactoryTypeBeforeInstantiation() throws Exception {
void testDoesNothingWhenPostProcessingNonScriptFactoryTypeBeforeInstantiation() {
assertThat(new ScriptFactoryPostProcessor().postProcessBeforeInstantiation(getClass(), "a.bean")).isNull();
}
@Test
public void testThrowsExceptionIfGivenNonAbstractBeanFactoryImplementation() throws Exception {
void testThrowsExceptionIfGivenNonAbstractBeanFactoryImplementation() {
assertThatIllegalStateException().isThrownBy(() ->
new ScriptFactoryPostProcessor().setBeanFactory(mock(BeanFactory.class)));
}
@Test
public void testChangeScriptWithRefreshableBeanFunctionality() throws Exception {
void testChangeScriptWithRefreshableBeanFunctionality() throws Exception {
BeanDefinition processorBeanDefinition = createScriptFactoryPostProcessor(true);
BeanDefinition scriptedBeanDefinition = createScriptedGroovyBean();
......@@ -111,7 +111,7 @@ public class ScriptFactoryPostProcessorTests {
}
@Test
public void testChangeScriptWithNoRefreshableBeanFunctionality() throws Exception {
void testChangeScriptWithNoRefreshableBeanFunctionality() throws Exception {
BeanDefinition processorBeanDefinition = createScriptFactoryPostProcessor(false);
BeanDefinition scriptedBeanDefinition = createScriptedGroovyBean();
......@@ -131,7 +131,7 @@ public class ScriptFactoryPostProcessorTests {
}
@Test
public void testRefreshedScriptReferencePropagatesToCollaborators() throws Exception {
void testRefreshedScriptReferencePropagatesToCollaborators() throws Exception {
BeanDefinition processorBeanDefinition = createScriptFactoryPostProcessor(true);
BeanDefinition scriptedBeanDefinition = createScriptedGroovyBean();
BeanDefinitionBuilder collaboratorBuilder = BeanDefinitionBuilder.rootBeanDefinition(DefaultMessengerService.class);
......@@ -159,7 +159,7 @@ public class ScriptFactoryPostProcessorTests {
}
@Test
public void testReferencesAcrossAContainerHierarchy() throws Exception {
void testReferencesAcrossAContainerHierarchy() throws Exception {
GenericApplicationContext businessContext = new GenericApplicationContext();
businessContext.registerBeanDefinition("messenger", BeanDefinitionBuilder.rootBeanDefinition(StubMessenger.class).getBeanDefinition());
businessContext.refresh();
......@@ -175,13 +175,13 @@ public class ScriptFactoryPostProcessorTests {
}
@Test
public void testScriptHavingAReferenceToAnotherBean() throws Exception {
void testScriptHavingAReferenceToAnotherBean() throws Exception {
// just tests that the (singleton) script-backed bean is able to be instantiated with references to its collaborators
new ClassPathXmlApplicationContext("org/springframework/scripting/support/groovyReferences.xml");
}
@Test
public void testForRefreshedScriptHavingErrorPickedUpOnFirstCall() throws Exception {
void testForRefreshedScriptHavingErrorPickedUpOnFirstCall() throws Exception {
BeanDefinition processorBeanDefinition = createScriptFactoryPostProcessor(true);
BeanDefinition scriptedBeanDefinition = createScriptedGroovyBean();
BeanDefinitionBuilder collaboratorBuilder = BeanDefinitionBuilder.rootBeanDefinition(DefaultMessengerService.class);
......@@ -202,13 +202,12 @@ public class ScriptFactoryPostProcessorTests {
// needs The Sundays compiler; must NOT throw any exception here...
source.setScript("I keep hoping you are the same as me, and I'll send you letters and come to your house for tea");
Messenger refreshedMessenger = (Messenger) ctx.getBean(MESSENGER_BEAN_NAME);
assertThatExceptionOfType(FatalBeanException.class).isThrownBy(() ->
refreshedMessenger.getMessage())
assertThatExceptionOfType(FatalBeanException.class).isThrownBy(refreshedMessenger::getMessage)
.matches(ex -> ex.contains(ScriptCompilationException.class));
}
@Test
public void testPrototypeScriptedBean() throws Exception {
void testPrototypeScriptedBean() throws Exception {
GenericApplicationContext ctx = new GenericApplicationContext();
ctx.registerBeanDefinition("messenger", BeanDefinitionBuilder.rootBeanDefinition(StubMessenger.class).getBeanDefinition());
......@@ -236,7 +235,7 @@ public class ScriptFactoryPostProcessorTests {
private static BeanDefinition createScriptFactoryPostProcessor(boolean isRefreshable) {
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(ScriptFactoryPostProcessor.class);
if (isRefreshable) {
builder.addPropertyValue("defaultRefreshCheckDelay", new Long(1));
builder.addPropertyValue("defaultRefreshCheckDelay", 1L);
}
return builder.getBeanDefinition();
}
......
/*
* Copyright 2002-2019 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.
......@@ -36,17 +36,17 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
* @author Stephane Nicoll
* @since 07.03.2006
*/
public class DataBinderFieldAccessTests {
class DataBinderFieldAccessTests {
@Test
public void bindingNoErrors() throws Exception {
void bindingNoErrors() throws Exception {
FieldAccessBean rod = new FieldAccessBean();
DataBinder binder = new DataBinder(rod, "person");
assertThat(binder.isIgnoreUnknownFields()).isTrue();
binder.initDirectFieldAccess();
MutablePropertyValues pvs = new MutablePropertyValues();
pvs.addPropertyValue(new PropertyValue("name", "Rod"));
pvs.addPropertyValue(new PropertyValue("age", new Integer(32)));
pvs.addPropertyValue(new PropertyValue("age", 32));
pvs.addPropertyValue(new PropertyValue("nonExisting", "someValue"));
binder.bind(pvs);
......@@ -62,21 +62,21 @@ public class DataBinderFieldAccessTests {
}
@Test
public void bindingNoErrorsNotIgnoreUnknown() throws Exception {
void bindingNoErrorsNotIgnoreUnknown() throws Exception {
FieldAccessBean rod = new FieldAccessBean();
DataBinder binder = new DataBinder(rod, "person");
binder.initDirectFieldAccess();
binder.setIgnoreUnknownFields(false);
MutablePropertyValues pvs = new MutablePropertyValues();
pvs.addPropertyValue(new PropertyValue("name", "Rod"));
pvs.addPropertyValue(new PropertyValue("age", new Integer(32)));
pvs.addPropertyValue(new PropertyValue("age", 32));
pvs.addPropertyValue(new PropertyValue("nonExisting", "someValue"));
assertThatExceptionOfType(NotWritablePropertyException.class).isThrownBy(() ->
binder.bind(pvs));
}
@Test
public void bindingWithErrors() throws Exception {
void bindingWithErrors() throws Exception {
FieldAccessBean rod = new FieldAccessBean();
DataBinder binder = new DataBinder(rod, "person");
binder.initDirectFieldAccess();
......@@ -105,7 +105,7 @@ public class DataBinderFieldAccessTests {
}
@Test
public void nestedBindingWithDefaultConversionNoErrors() throws Exception {
void nestedBindingWithDefaultConversionNoErrors() throws Exception {
FieldAccessBean rod = new FieldAccessBean();
DataBinder binder = new DataBinder(rod, "person");
assertThat(binder.isIgnoreUnknownFields()).isTrue();
......@@ -122,7 +122,7 @@ public class DataBinderFieldAccessTests {
}
@Test
public void nestedBindingWithDisabledAutoGrow() throws Exception {
void nestedBindingWithDisabledAutoGrow() throws Exception {
FieldAccessBean rod = new FieldAccessBean();
DataBinder binder = new DataBinder(rod, "person");
binder.setAutoGrowNestedPaths(false);
......@@ -135,7 +135,7 @@ public class DataBinderFieldAccessTests {
}
@Test
public void bindingWithErrorsAndCustomEditors() throws Exception {
void bindingWithErrorsAndCustomEditors() throws Exception {
FieldAccessBean rod = new FieldAccessBean();
DataBinder binder = new DataBinder(rod, "person");
binder.initDirectFieldAccess();
......
/*
* 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.
......@@ -109,7 +109,7 @@ class ObjectUtilsTests {
Set<String> set = new HashSet<>();
set.add("foo");
assertThat(isEmpty(set)).isFalse();
assertThat(isEmpty(Arrays.asList("foo"))).isFalse();
assertThat(isEmpty(Collections.singletonList("foo"))).isFalse();
}
@Test
......@@ -159,7 +159,7 @@ class ObjectUtilsTests {
void toObjectArrayWithEmptyPrimitiveArray() {
Object[] objects = ObjectUtils.toObjectArray(new byte[] {});
assertThat(objects).isNotNull();
assertThat(objects.length).isEqualTo(0);
assertThat(objects).hasSize(0);
}
@Test
......@@ -179,7 +179,7 @@ class ObjectUtilsTests {
String[] array = new String[] {"foo", "bar"};
String newElement = "baz";
Object[] newArray = ObjectUtils.addObjectToArray(array, newElement);
assertThat(newArray.length).isEqualTo(3);
assertThat(newArray).hasSize(3);
assertThat(newArray[2]).isEqualTo(newElement);
}
......@@ -188,7 +188,7 @@ class ObjectUtilsTests {
String[] array = new String[0];
String newElement = "foo";
String[] newArray = ObjectUtils.addObjectToArray(array, newElement);
assertThat(newArray.length).isEqualTo(1);
assertThat(newArray).hasSize(1);
assertThat(newArray[0]).isEqualTo(newElement);
}
......@@ -198,7 +198,7 @@ class ObjectUtilsTests {
String[] array = new String[] {existingElement};
String newElement = "bar";
String[] newArray = ObjectUtils.addObjectToArray(array, newElement);
assertThat(newArray.length).isEqualTo(2);
assertThat(newArray).hasSize(2);
assertThat(newArray[0]).isEqualTo(existingElement);
assertThat(newArray[1]).isEqualTo(newElement);
}
......@@ -208,8 +208,8 @@ class ObjectUtilsTests {
String[] array = new String[] {null};
String newElement = "bar";
String[] newArray = ObjectUtils.addObjectToArray(array, newElement);
assertThat(newArray.length).isEqualTo(2);
assertThat(newArray[0]).isEqualTo(null);
assertThat(newArray).hasSize(2);
assertThat(newArray[0]).isNull();
assertThat(newArray[1]).isEqualTo(newElement);
}
......@@ -217,15 +217,15 @@ class ObjectUtilsTests {
void addObjectToNullArray() throws Exception {
String newElement = "foo";
String[] newArray = ObjectUtils.addObjectToArray(null, newElement);
assertThat(newArray.length).isEqualTo(1);
assertThat(newArray).hasSize(1);
assertThat(newArray[0]).isEqualTo(newElement);
}
@Test
void addNullObjectToNullArray() throws Exception {
Object[] newArray = ObjectUtils.addObjectToArray(null, null);
assertThat(newArray.length).isEqualTo(1);
assertThat(newArray[0]).isEqualTo(null);
assertThat(newArray).hasSize(1);
assertThat(newArray[0]).isNull();
}
@Test
......@@ -260,7 +260,7 @@ class ObjectUtilsTests {
@Deprecated
void hashCodeWithFloat() {
float flt = 34.8f;
int expected = (new Float(flt)).hashCode();
int expected = (Float.valueOf(flt)).hashCode();
assertThat(ObjectUtils.hashCode(flt)).isEqualTo(expected);
}
......@@ -268,7 +268,7 @@ class ObjectUtilsTests {
@Deprecated
void hashCodeWithLong() {
long lng = 883L;
int expected = (new Long(lng)).hashCode();
int expected = (Long.valueOf(lng)).hashCode();
assertThat(ObjectUtils.hashCode(lng)).isEqualTo(expected);
}
......@@ -282,7 +282,7 @@ class ObjectUtilsTests {
@Test
void identityToStringWithNullObject() {
assertThat(ObjectUtils.identityToString(null)).isEqualTo("");
assertThat(ObjectUtils.identityToString(null)).isEmpty();
}
@Test
......
/*
* 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.
......@@ -41,11 +41,11 @@ import org.springframework.expression.spel.support.StandardEvaluationContext;
import static org.assertj.core.api.Assertions.assertThat;
@SuppressWarnings("rawtypes")
public class IndexingTests {
class IndexingTests {
@Test
@SuppressWarnings("unchecked")
public void indexIntoGenericPropertyContainingMap() {
void indexIntoGenericPropertyContainingMap() {
Map<String, String> property = new HashMap<>();
property.put("foo", "bar");
this.property = property;
......@@ -63,7 +63,7 @@ public class IndexingTests {
@Test
@SuppressWarnings("unchecked")
public void indexIntoGenericPropertyContainingMapObject() {
void indexIntoGenericPropertyContainingMapObject() {
Map<String, Map<String, String>> property = new HashMap<>();
Map<String, String> map = new HashMap<>();
map.put("foo", "bar");
......@@ -112,7 +112,7 @@ public class IndexingTests {
}
@Test
public void setGenericPropertyContainingMap() {
void setGenericPropertyContainingMap() {
Map<String, String> property = new HashMap<>();
property.put("foo", "bar");
this.property = property;
......@@ -127,7 +127,7 @@ public class IndexingTests {
}
@Test
public void setPropertyContainingMap() {
void setPropertyContainingMap() {
Map<Integer, Integer> property = new HashMap<>();
property.put(9, 3);
this.parameterizedMap = property;
......@@ -144,7 +144,7 @@ public class IndexingTests {
public Map<Integer, Integer> parameterizedMap;
@Test
public void setPropertyContainingMapAutoGrow() {
void setPropertyContainingMapAutoGrow() {
SpelExpressionParser parser = new SpelExpressionParser(new SpelParserConfiguration(true, false));
Expression expression = parser.parseExpression("parameterizedMap");
assertThat(expression.getValueTypeDescriptor(this).toString()).isEqualTo("java.util.Map<java.lang.Integer, java.lang.Integer>");
......@@ -156,7 +156,7 @@ public class IndexingTests {
}
@Test
public void indexIntoGenericPropertyContainingList() {
void indexIntoGenericPropertyContainingList() {
List<String> property = new ArrayList<>();
property.add("bar");
this.property = property;
......@@ -169,7 +169,7 @@ public class IndexingTests {
}
@Test
public void setGenericPropertyContainingList() {
void setGenericPropertyContainingList() {
List<Integer> property = new ArrayList<>();
property.add(3);
this.property = property;
......@@ -184,7 +184,7 @@ public class IndexingTests {
}
@Test
public void setGenericPropertyContainingListAutogrow() {
void setGenericPropertyContainingListAutogrow() {
List<Integer> property = new ArrayList<>();
this.property = property;
SpelExpressionParser parser = new SpelExpressionParser(new SpelParserConfiguration(true, true));
......@@ -203,7 +203,7 @@ public class IndexingTests {
public List<BigDecimal> decimals;
@Test
public void autoGrowListOfElementsWithoutDefaultConstructor() {
void autoGrowListOfElementsWithoutDefaultConstructor() {
this.decimals = new ArrayList<>();
SpelExpressionParser parser = new SpelExpressionParser(new SpelParserConfiguration(true, true));
parser.parseExpression("decimals[0]").setValue(this, "123.4");
......@@ -211,7 +211,7 @@ public class IndexingTests {
}
@Test
public void indexIntoPropertyContainingListContainingNullElement() {
void indexIntoPropertyContainingListContainingNullElement() {
this.decimals = new ArrayList<>();
this.decimals.add(null);
this.decimals.add(BigDecimal.ONE);
......@@ -221,7 +221,7 @@ public class IndexingTests {
}
@Test
public void indexIntoPropertyContainingList() {
void indexIntoPropertyContainingList() {
List<Integer> property = new ArrayList<>();
property.add(3);
this.parameterizedList = property;
......@@ -236,7 +236,7 @@ public class IndexingTests {
public List<Integer> parameterizedList;
@Test
public void indexIntoPropertyContainingListOfList() {
void indexIntoPropertyContainingListOfList() {
List<List<Integer>> property = new ArrayList<>();
property.add(Arrays.asList(3));
this.parameterizedListOfList = property;
......@@ -251,7 +251,7 @@ public class IndexingTests {
public List<List<Integer>> parameterizedListOfList;
@Test
public void setPropertyContainingList() {
void setPropertyContainingList() {
List<Integer> property = new ArrayList<>();
property.add(3);
this.parameterizedList = property;
......@@ -266,7 +266,7 @@ public class IndexingTests {
}
@Test
public void indexIntoGenericPropertyContainingNullList() {
void indexIntoGenericPropertyContainingNullList() {
SpelParserConfiguration configuration = new SpelParserConfiguration(true, true);
SpelExpressionParser parser = new SpelExpressionParser(configuration);
Expression expression = parser.parseExpression("property");
......@@ -282,7 +282,7 @@ public class IndexingTests {
}
@Test
public void indexIntoGenericPropertyContainingGrowingList() {
void indexIntoGenericPropertyContainingGrowingList() {
List<String> property = new ArrayList<>();
this.property = property;
SpelParserConfiguration configuration = new SpelParserConfiguration(true, true);
......@@ -300,7 +300,7 @@ public class IndexingTests {
}
@Test
public void indexIntoGenericPropertyContainingGrowingList2() {
void indexIntoGenericPropertyContainingGrowingList2() {
List<String> property2 = new ArrayList<>();
this.property2 = property2;
SpelParserConfiguration configuration = new SpelParserConfiguration(true, true);
......@@ -320,7 +320,7 @@ public class IndexingTests {
public List property2;
@Test
public void indexIntoGenericPropertyContainingArray() {
void indexIntoGenericPropertyContainingArray() {
String[] property = new String[] { "bar" };
this.property = property;
SpelExpressionParser parser = new SpelExpressionParser();
......@@ -332,7 +332,7 @@ public class IndexingTests {
}
@Test
public void emptyList() {
void emptyList() {
listOfScalarNotGeneric = new ArrayList();
SpelExpressionParser parser = new SpelExpressionParser();
Expression expression = parser.parseExpression("listOfScalarNotGeneric");
......@@ -342,7 +342,7 @@ public class IndexingTests {
@SuppressWarnings("unchecked")
@Test
public void resolveCollectionElementType() {
void resolveCollectionElementType() {
listNotGeneric = new ArrayList(2);
listNotGeneric.add(5);
listNotGeneric.add(6);
......@@ -353,7 +353,7 @@ public class IndexingTests {
}
@Test
public void resolveCollectionElementTypeNull() {
void resolveCollectionElementTypeNull() {
SpelExpressionParser parser = new SpelExpressionParser();
Expression expression = parser.parseExpression("listNotGeneric");
assertThat(expression.getValueTypeDescriptor(this).toString()).isEqualTo("@org.springframework.expression.spel.IndexingTests$FieldAnnotation java.util.List<?>");
......@@ -370,7 +370,7 @@ public class IndexingTests {
@SuppressWarnings("unchecked")
@Test
public void resolveMapKeyValueTypes() {
void resolveMapKeyValueTypes() {
mapNotGeneric = new HashMap();
mapNotGeneric.put("baseAmount", 3.11);
mapNotGeneric.put("bonusAmount", 7.17);
......@@ -384,12 +384,12 @@ public class IndexingTests {
@SuppressWarnings("unchecked")
@Test
public void testListOfScalar() {
void testListOfScalar() {
listOfScalarNotGeneric = new ArrayList(1);
listOfScalarNotGeneric.add("5");
SpelExpressionParser parser = new SpelExpressionParser();
Expression expression = parser.parseExpression("listOfScalarNotGeneric[0]");
assertThat(expression.getValue(this, Integer.class)).isEqualTo(new Integer(5));
assertThat(expression.getValue(this, Integer.class)).isEqualTo(Integer.valueOf(5));
}
public List listOfScalarNotGeneric;
......@@ -397,7 +397,7 @@ public class IndexingTests {
@SuppressWarnings("unchecked")
@Test
public void testListsOfMap() {
void testListsOfMap() {
listOfMapsNotGeneric = new ArrayList();
Map map = new HashMap();
map.put("fruit", "apple");
......
/*
* Copyright 2002-2019 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.
......@@ -33,10 +33,10 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Juergen Hoeller
* @author Giovanni Dall'Oglio Risso
*/
public class OperatorTests extends AbstractExpressionTests {
class OperatorTests extends AbstractExpressionTests {
@Test
public void testEqual() {
void testEqual() {
evaluate("3 == 5", false, Boolean.class);
evaluate("5 == 3", false, Boolean.class);
evaluate("6 == 6", true, Boolean.class);
......@@ -85,7 +85,7 @@ public class OperatorTests extends AbstractExpressionTests {
}
@Test
public void testNotEqual() {
void testNotEqual() {
evaluate("3 != 5", true, Boolean.class);
evaluate("5 != 3", true, Boolean.class);
evaluate("6 != 6", false, Boolean.class);
......@@ -134,7 +134,7 @@ public class OperatorTests extends AbstractExpressionTests {
}
@Test
public void testLessThan() {
void testLessThan() {
evaluate("5 < 5", false, Boolean.class);
evaluate("3 < 5", true, Boolean.class);
evaluate("5 < 3", false, Boolean.class);
......@@ -176,7 +176,7 @@ public class OperatorTests extends AbstractExpressionTests {
}
@Test
public void testLessThanOrEqual() {
void testLessThanOrEqual() {
evaluate("3 <= 5", true, Boolean.class);
evaluate("5 <= 3", false, Boolean.class);
evaluate("6 <= 6", true, Boolean.class);
......@@ -225,7 +225,7 @@ public class OperatorTests extends AbstractExpressionTests {
}
@Test
public void testGreaterThan() {
void testGreaterThan() {
evaluate("3 > 5", false, Boolean.class);
evaluate("5 > 3", true, Boolean.class);
evaluate("3L > 5L", false, Boolean.class);
......@@ -266,7 +266,7 @@ public class OperatorTests extends AbstractExpressionTests {
}
@Test
public void testGreaterThanOrEqual() {
void testGreaterThanOrEqual() {
evaluate("3 >= 5", false, Boolean.class);
evaluate("5 >= 3", true, Boolean.class);
evaluate("6 >= 6", true, Boolean.class);
......@@ -315,27 +315,27 @@ public class OperatorTests extends AbstractExpressionTests {
}
@Test
public void testIntegerLiteral() {
void testIntegerLiteral() {
evaluate("3", 3, Integer.class);
}
@Test
public void testRealLiteral() {
void testRealLiteral() {
evaluate("3.5", 3.5d, Double.class);
}
@Test
public void testMultiplyStringInt() {
void testMultiplyStringInt() {
evaluate("'a' * 5", "aaaaa", String.class);
}
@Test
public void testMultiplyDoubleDoubleGivesDouble() {
void testMultiplyDoubleDoubleGivesDouble() {
evaluate("3.0d * 5.0d", 15.0d, Double.class);
}
@Test
public void testMixedOperandsBigDecimal() {
void testMixedOperandsBigDecimal() {
evaluate("3 * new java.math.BigDecimal('5')", new BigDecimal("15"), BigDecimal.class);
evaluate("3L * new java.math.BigDecimal('5')", new BigDecimal("15"), BigDecimal.class);
evaluate("3.0d * new java.math.BigDecimal('5')", new BigDecimal("15.0"), BigDecimal.class);
......@@ -361,19 +361,19 @@ public class OperatorTests extends AbstractExpressionTests {
}
@Test
public void testMathOperatorAdd02() {
void testMathOperatorAdd02() {
evaluate("'hello' + ' ' + 'world'", "hello world", String.class);
}
@Test
public void testMathOperatorsInChains() {
void testMathOperatorsInChains() {
evaluate("1+2+3",6,Integer.class);
evaluate("2*3*4",24,Integer.class);
evaluate("12-1-2",9,Integer.class);
}
@Test
public void testIntegerArithmetic() {
void testIntegerArithmetic() {
evaluate("2 + 4", "6", Integer.class);
evaluate("5 - 4", "1", Integer.class);
evaluate("3 * 5", 15, Integer.class);
......@@ -388,7 +388,7 @@ public class OperatorTests extends AbstractExpressionTests {
}
@Test
public void testPlus() throws Exception {
void testPlus() {
evaluate("7 + 2", "9", Integer.class);
evaluate("3.0f + 5.0f", 8.0f, Float.class);
evaluate("3.0d + 5.0d", 8.0d, Double.class);
......@@ -419,7 +419,7 @@ public class OperatorTests extends AbstractExpressionTests {
}
@Test
public void testMinus() throws Exception {
void testMinus() {
evaluate("'c' - 2", "a", String.class);
evaluate("3.0f - 5.0f", -2.0f, Float.class);
evaluateAndCheckError("'ab' - 2", SpelMessage.OPERATOR_NOT_SUPPORTED_BETWEEN_TYPES);
......@@ -437,7 +437,7 @@ public class OperatorTests extends AbstractExpressionTests {
}
@Test
public void testModulus() {
void testModulus() {
evaluate("3%2",1,Integer.class);
evaluate("3L%2L",1L,Long.class);
evaluate("3.0f%2.0f",1f,Float.class);
......@@ -448,7 +448,7 @@ public class OperatorTests extends AbstractExpressionTests {
}
@Test
public void testDivide() {
void testDivide() {
evaluate("3.0f / 5.0f", 0.6f, Float.class);
evaluate("4L/2L",2L,Long.class);
evaluate("3.0f div 5.0f", 0.6f, Float.class);
......@@ -461,17 +461,17 @@ public class OperatorTests extends AbstractExpressionTests {
}
@Test
public void testMathOperatorDivide_ConvertToDouble() {
evaluateAndAskForReturnType("8/4", new Double(2.0), Double.class);
void testMathOperatorDivide_ConvertToDouble() {
evaluateAndAskForReturnType("8/4", 2.0, Double.class);
}
@Test
public void testMathOperatorDivide04_ConvertToFloat() {
evaluateAndAskForReturnType("8/4", new Float(2.0), Float.class);
void testMathOperatorDivide04_ConvertToFloat() {
evaluateAndAskForReturnType("8/4", 2.0F, Float.class);
}
@Test
public void testDoubles() {
void testDoubles() {
evaluate("3.0d == 5.0d", false, Boolean.class);
evaluate("3.0d == 3.0d", true, Boolean.class);
evaluate("3.0d != 5.0d", true, Boolean.class);
......@@ -484,7 +484,7 @@ public class OperatorTests extends AbstractExpressionTests {
}
@Test
public void testBigDecimals() {
void testBigDecimals() {
evaluate("3 + new java.math.BigDecimal('5')", new BigDecimal("8"), BigDecimal.class);
evaluate("3 - new java.math.BigDecimal('5')", new BigDecimal("-2"), BigDecimal.class);
evaluate("3 * new java.math.BigDecimal('5')", new BigDecimal("15"), BigDecimal.class);
......@@ -495,7 +495,7 @@ public class OperatorTests extends AbstractExpressionTests {
}
@Test
public void testOperatorNames() throws Exception {
void testOperatorNames() {
Operator node = getOperatorNode((SpelExpression)parser.parseExpression("1==3"));
assertThat(node.getOperatorName()).isEqualTo("==");
......@@ -534,13 +534,13 @@ public class OperatorTests extends AbstractExpressionTests {
}
@Test
public void testOperatorOverloading() {
void testOperatorOverloading() {
evaluateAndCheckError("'a' * '2'", SpelMessage.OPERATOR_NOT_SUPPORTED_BETWEEN_TYPES);
evaluateAndCheckError("'a' ^ '2'", SpelMessage.OPERATOR_NOT_SUPPORTED_BETWEEN_TYPES);
}
@Test
public void testPower() {
void testPower() {
evaluate("3^2",9,Integer.class);
evaluate("3.0d^2.0d",9.0d,Double.class);
evaluate("3L^2L",9L,Long.class);
......@@ -549,7 +549,7 @@ public class OperatorTests extends AbstractExpressionTests {
}
@Test
public void testMixedOperands_FloatsAndDoubles() {
void testMixedOperands_FloatsAndDoubles() {
evaluate("3.0d + 5.0f", 8.0d, Double.class);
evaluate("3.0D - 5.0f", -2.0d, Double.class);
evaluate("3.0f * 5.0d", 15.0d, Double.class);
......@@ -558,7 +558,7 @@ public class OperatorTests extends AbstractExpressionTests {
}
@Test
public void testMixedOperands_DoublesAndInts() {
void testMixedOperands_DoublesAndInts() {
evaluate("3.0d + 5", 8.0d, Double.class);
evaluate("3.0D - 5", -2.0d, Double.class);
evaluate("3.0f * 5", 15.0f, Float.class);
......@@ -569,7 +569,7 @@ public class OperatorTests extends AbstractExpressionTests {
}
@Test
public void testStrings() {
void testStrings() {
evaluate("'abc' == 'abc'", true, Boolean.class);
evaluate("'abc' == 'def'", false, Boolean.class);
evaluate("'abc' != 'abc'", false, Boolean.class);
......@@ -577,7 +577,7 @@ public class OperatorTests extends AbstractExpressionTests {
}
@Test
public void testLongs() {
void testLongs() {
evaluate("3L == 4L", false, Boolean.class);
evaluate("3L == 3L", true, Boolean.class);
evaluate("3L != 4L", true, Boolean.class);
......@@ -588,7 +588,7 @@ public class OperatorTests extends AbstractExpressionTests {
}
@Test
public void testBigIntegers() {
void testBigIntegers() {
evaluate("3 + new java.math.BigInteger('5')", new BigInteger("8"), BigInteger.class);
evaluate("3 - new java.math.BigInteger('5')", new BigInteger("-2"), BigInteger.class);
evaluate("3 * new java.math.BigInteger('5')", new BigInteger("15"), BigInteger.class);
......
/*
* 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.
......@@ -51,7 +51,7 @@ import static org.mockito.Mockito.verify;
* @author Juergen Hoeller
* @author Chris Beams
*/
public class MessageListenerAdapterTests {
class MessageListenerAdapterTests {
private static final String TEXT = "I fancy a good cuppa right now";
......@@ -65,7 +65,7 @@ public class MessageListenerAdapterTests {
@Test
public void testWithMessageContentsDelegateForTextMessage() throws Exception {
void testWithMessageContentsDelegateForTextMessage() throws Exception {
TextMessage textMessage = mock(TextMessage.class);
// TextMessage contents must be unwrapped...
given(textMessage.getText()).willReturn(TEXT);
......@@ -79,17 +79,14 @@ public class MessageListenerAdapterTests {
}
@Test
public void testWithMessageContentsDelegateForBytesMessage() throws Exception {
void testWithMessageContentsDelegateForBytesMessage() throws Exception {
BytesMessage bytesMessage = mock(BytesMessage.class);
// BytesMessage contents must be unwrapped...
given(bytesMessage.getBodyLength()).willReturn(new Long(TEXT.getBytes().length));
given(bytesMessage.readBytes(any(byte[].class))).willAnswer(new Answer<Integer>() {
@Override
public Integer answer(InvocationOnMock invocation) throws Throwable {
byte[] bytes = (byte[]) invocation.getArguments()[0];
ByteArrayInputStream inputStream = new ByteArrayInputStream(TEXT.getBytes());
return inputStream.read(bytes);
}
given(bytesMessage.getBodyLength()).willReturn(Long.valueOf(TEXT.getBytes().length));
given(bytesMessage.readBytes(any(byte[].class))).willAnswer((Answer<Integer>) invocation -> {
byte[] bytes = (byte[]) invocation.getArguments()[0];
ByteArrayInputStream inputStream = new ByteArrayInputStream(TEXT.getBytes());
return inputStream.read(bytes);
});
MessageContentsDelegate delegate = mock(MessageContentsDelegate.class);
......@@ -101,7 +98,7 @@ public class MessageListenerAdapterTests {
}
@Test
public void testWithMessageContentsDelegateForObjectMessage() throws Exception {
void testWithMessageContentsDelegateForObjectMessage() throws Exception {
ObjectMessage objectMessage = mock(ObjectMessage.class);
given(objectMessage.getObject()).willReturn(NUMBER);
......@@ -114,7 +111,7 @@ public class MessageListenerAdapterTests {
}
@Test
public void testWithMessageContentsDelegateForObjectMessageWithPlainObject() throws Exception {
void testWithMessageContentsDelegateForObjectMessageWithPlainObject() throws Exception {
ObjectMessage objectMessage = mock(ObjectMessage.class);
given(objectMessage.getObject()).willReturn(OBJECT);
......@@ -127,7 +124,7 @@ public class MessageListenerAdapterTests {
}
@Test
public void testWithMessageDelegate() throws Exception {
void testWithMessageDelegate() throws Exception {
TextMessage textMessage = mock(TextMessage.class);
MessageDelegate delegate = mock(MessageDelegate.class);
......@@ -141,7 +138,7 @@ public class MessageListenerAdapterTests {
}
@Test
public void testWhenTheAdapterItselfIsTheDelegate() throws Exception {
void testWhenTheAdapterItselfIsTheDelegate() throws Exception {
TextMessage textMessage = mock(TextMessage.class);
// TextMessage contents must be unwrapped...
given(textMessage.getText()).willReturn(TEXT);
......@@ -152,7 +149,7 @@ public class MessageListenerAdapterTests {
}
@Test
public void testRainyDayWithNoApplicableHandlingMethods() throws Exception {
void testRainyDayWithNoApplicableHandlingMethods() throws Exception {
TextMessage textMessage = mock(TextMessage.class);
// TextMessage contents must be unwrapped...
given(textMessage.getText()).willReturn(TEXT);
......@@ -164,7 +161,7 @@ public class MessageListenerAdapterTests {
}
@Test
public void testThatAnExceptionThrownFromTheHandlingMethodIsSimplySwallowedByDefault() throws Exception {
void testThatAnExceptionThrownFromTheHandlingMethodIsSimplySwallowedByDefault() throws Exception {
final IllegalArgumentException exception = new IllegalArgumentException();
TextMessage textMessage = mock(TextMessage.class);
......@@ -189,7 +186,7 @@ public class MessageListenerAdapterTests {
}
@Test
public void testThatTheDefaultMessageConverterisIndeedTheSimpleMessageConverter() throws Exception {
void testThatTheDefaultMessageConverterisIndeedTheSimpleMessageConverter() throws Exception {
MessageListenerAdapter adapter = new MessageListenerAdapter();
assertThat(adapter.getMessageConverter()).as("The default [MessageConverter] must never be null.").isNotNull();
boolean condition = adapter.getMessageConverter() instanceof SimpleMessageConverter;
......@@ -197,19 +194,19 @@ public class MessageListenerAdapterTests {
}
@Test
public void testThatWhenNoDelegateIsSuppliedTheDelegateIsAssumedToBeTheMessageListenerAdapterItself() throws Exception {
void testThatWhenNoDelegateIsSuppliedTheDelegateIsAssumedToBeTheMessageListenerAdapterItself() throws Exception {
MessageListenerAdapter adapter = new MessageListenerAdapter();
assertThat(adapter.getDelegate()).isSameAs(adapter);
}
@Test
public void testThatTheDefaultMessageHandlingMethodNameIsTheConstantDefault() throws Exception {
void testThatTheDefaultMessageHandlingMethodNameIsTheConstantDefault() throws Exception {
MessageListenerAdapter adapter = new MessageListenerAdapter();
assertThat(adapter.getDefaultListenerMethod()).isEqualTo(MessageListenerAdapter.ORIGINAL_DEFAULT_LISTENER_METHOD);
}
@Test
public void testWithResponsiveMessageDelegate_DoesNotSendReturnTextMessageIfNoSessionSupplied() throws Exception {
void testWithResponsiveMessageDelegate_DoesNotSendReturnTextMessageIfNoSessionSupplied() throws Exception {
TextMessage textMessage = mock(TextMessage.class);
ResponsiveMessageDelegate delegate = mock(ResponsiveMessageDelegate.class);
given(delegate.handleMessage(textMessage)).willReturn(TEXT);
......@@ -221,7 +218,7 @@ public class MessageListenerAdapterTests {
}
@Test
public void testWithResponsiveMessageDelegateWithDefaultDestination_SendsReturnTextMessageWhenSessionSupplied() throws Exception {
void testWithResponsiveMessageDelegateWithDefaultDestination_SendsReturnTextMessageWhenSessionSupplied() throws Exception {
Queue destination = mock(Queue.class);
TextMessage sentTextMessage = mock(TextMessage.class);
// correlation ID is queried when response is being created...
......@@ -256,7 +253,7 @@ public class MessageListenerAdapterTests {
}
@Test
public void testWithResponsiveMessageDelegateNoDefaultDestination_SendsReturnTextMessageWhenSessionSupplied() throws Exception {
void testWithResponsiveMessageDelegateNoDefaultDestination_SendsReturnTextMessageWhenSessionSupplied() throws Exception {
Queue destination = mock(Queue.class);
TextMessage sentTextMessage = mock(TextMessage.class);
// correlation ID is queried when response is being created...
......@@ -289,7 +286,7 @@ public class MessageListenerAdapterTests {
}
@Test
public void testWithResponsiveMessageDelegateNoDefaultDestinationAndNoReplyToDestination_SendsReturnTextMessageWhenSessionSupplied() throws Exception {
void testWithResponsiveMessageDelegateNoDefaultDestinationAndNoReplyToDestination_SendsReturnTextMessageWhenSessionSupplied() throws Exception {
final TextMessage sentTextMessage = mock(TextMessage.class);
// correlation ID is queried when response is being created...
given(sentTextMessage.getJMSCorrelationID()).willReturn(CORRELATION_ID);
......@@ -318,7 +315,7 @@ public class MessageListenerAdapterTests {
}
@Test
public void testWithResponsiveMessageDelegateNoDefaultDestination_SendsReturnTextMessageWhenSessionSupplied_AndSendingThrowsJMSException() throws Exception {
void testWithResponsiveMessageDelegateNoDefaultDestination_SendsReturnTextMessageWhenSessionSupplied_AndSendingThrowsJMSException() throws Exception {
Queue destination = mock(Queue.class);
final TextMessage sentTextMessage = mock(TextMessage.class);
......@@ -354,7 +351,7 @@ public class MessageListenerAdapterTests {
}
@Test
public void testWithResponsiveMessageDelegateDoesNotSendReturnTextMessageWhenSessionSupplied_AndListenerMethodThrowsException() throws Exception {
void testWithResponsiveMessageDelegateDoesNotSendReturnTextMessageWhenSessionSupplied_AndListenerMethodThrowsException() throws Exception {
final TextMessage message = mock(TextMessage.class);
final QueueSession session = mock(QueueSession.class);
......@@ -372,7 +369,7 @@ public class MessageListenerAdapterTests {
}
@Test
public void testWithResponsiveMessageDelegateWhenReturnTypeIsNotAJMSMessageAndNoMessageConverterIsSupplied() throws Exception {
void testWithResponsiveMessageDelegateWhenReturnTypeIsNotAJMSMessageAndNoMessageConverterIsSupplied() throws Exception {
final TextMessage sentTextMessage = mock(TextMessage.class);
final Session session = mock(Session.class);
ResponsiveMessageDelegate delegate = mock(ResponsiveMessageDelegate.class);
......@@ -391,7 +388,7 @@ public class MessageListenerAdapterTests {
}
@Test
public void testWithResponsiveMessageDelegateWhenReturnTypeIsAJMSMessageAndNoMessageConverterIsSupplied() throws Exception {
void testWithResponsiveMessageDelegateWhenReturnTypeIsAJMSMessageAndNoMessageConverterIsSupplied() throws Exception {
Queue destination = mock(Queue.class);
final TextMessage sentTextMessage = mock(TextMessage.class);
// correlation ID is queried when response is being created...
......
......@@ -83,7 +83,7 @@ public class EscapedErrorsTests {
FieldError ageError = errors.getFieldError("age");
assertThat("message: &lt;tag&gt;".equals(ageError.getDefaultMessage())).as("Age error message escaped").isTrue();
assertThat("AGE_NOT_SET <tag>".equals(ageError.getCode())).as("Age error code not escaped").isTrue();
assertThat((new Integer(0)).equals(errors.getFieldValue("age"))).as("Age value not escaped").isTrue();
assertThat((Integer.valueOf(0)).equals(errors.getFieldValue("age"))).as("Age value not escaped").isTrue();
FieldError ageErrorInList = errors.getFieldErrors("age").get(0);
assertThat(ageError.getDefaultMessage().equals(ageErrorInList.getDefaultMessage())).as("Same name error in list").isTrue();
FieldError ageError2 = errors.getFieldErrors("age").get(1);
......
......@@ -159,7 +159,7 @@ class CrossOriginTests {
assertThat(config.getAllowCredentials()).isNull();
assertThat(config.getAllowedHeaders()).containsExactly("*");
assertThat(CollectionUtils.isEmpty(config.getExposedHeaders())).isTrue();
assertThat(config.getMaxAge()).isEqualTo(new Long(1800));
assertThat(config.getMaxAge()).isEqualTo(Long.valueOf(1800));
}
@PathPatternsParameterizedTest
......@@ -173,7 +173,7 @@ class CrossOriginTests {
assertThat(config.getAllowedOrigins()).containsExactly("https://site1.com", "https://site2.com");
assertThat(config.getAllowedHeaders()).containsExactly("header1", "header2");
assertThat(config.getExposedHeaders()).containsExactly("header3", "header4");
assertThat(config.getMaxAge()).isEqualTo(new Long(123));
assertThat(config.getMaxAge()).isEqualTo(Long.valueOf(123));
assertThat(config.getAllowCredentials()).isFalse();
}
......@@ -315,7 +315,7 @@ class CrossOriginTests {
assertThat(config.getAllowCredentials()).isNull();
assertThat(config.getAllowedHeaders()).containsExactly("*");
assertThat(CollectionUtils.isEmpty(config.getExposedHeaders())).isTrue();
assertThat(config.getMaxAge()).isEqualTo(new Long(1800));
assertThat(config.getMaxAge()).isEqualTo(Long.valueOf(1800));
}
@PathPatternsParameterizedTest
......@@ -389,7 +389,7 @@ class CrossOriginTests {
assertThat(chain).isNotNull();
if (isPreFlightRequest) {
Object handler = chain.getHandler();
assertThat(handler.getClass().getSimpleName().equals("PreFlightHandler")).isTrue();
assertThat(handler.getClass().getSimpleName()).isEqualTo("PreFlightHandler");
DirectFieldAccessor accessor = new DirectFieldAccessor(handler);
return (CorsConfiguration)accessor.getPropertyValue("config");
}
......
......@@ -56,7 +56,7 @@ public class InputTagTests extends AbstractFormTagTests {
// set up test data
this.rob = new TestBean();
this.rob.setName("Rob");
this.rob.setMyFloat(new Float(12.34));
this.rob.setMyFloat(Float.valueOf(12.34f));
TestBean sally = new TestBean();
sally.setName("Sally");
......
......@@ -429,9 +429,9 @@ public class SelectTagTests extends AbstractFormTagTests {
this.tag.setPath("myFloat");
Float[] array = new Float[] {
new Float("12.30"), new Float("12.32"), new Float("12.34"), new Float("12.36"),
new Float("12.38"), new Float("12.40"), new Float("12.42"), new Float("12.44"),
new Float("12.46"), new Float("12.48")
Float.valueOf("12.30"), Float.valueOf("12.32"), Float.valueOf("12.34"), Float.valueOf("12.36"),
Float.valueOf("12.38"), Float.valueOf("12.40"), Float.valueOf("12.42"), Float.valueOf("12.44"),
Float.valueOf("12.46"), Float.valueOf("12.48")
};
this.tag.setItems(array);
......@@ -1010,7 +1010,7 @@ public class SelectTagTests extends AbstractFormTagTests {
this.bean.setName("Rob");
this.bean.setCountry("UK");
this.bean.setSex("M");
this.bean.setMyFloat(new Float("12.34"));
this.bean.setMyFloat(Float.valueOf("12.34"));
this.bean.setSomeIntegerArray(new Integer[]{12, 34});
return this.bean;
}
......
/*
* Copyright 2002-2012 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.
......@@ -26,7 +26,7 @@ class SimpleFloatEditor extends PropertyEditorSupport {
@Override
public void setAsText(String text) throws IllegalArgumentException {
setValue(new Float(text));
setValue(Float.valueOf(text));
}
@Override
......
......@@ -136,7 +136,7 @@ public class TextareaTagTests extends AbstractFormTagTests {
// set up test data
this.rob = new TestBean();
rob.setName("Rob");
rob.setMyFloat(new Float(12.34));
rob.setMyFloat(12.34f);
TestBean sally = new TestBean();
sally.setName("Sally");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册