Use autoboxing instead of explicit wrapping in tests

Closes gh-24801
This commit is contained in:
陈其苗
2020-03-27 23:39:52 +08:00
committed by Sam Brannen
parent d8567749b8
commit 13970ae528
45 changed files with 308 additions and 308 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -709,7 +709,7 @@ public class ProxyFactoryBeanTests {
@Override
public Object invoke(MethodInvocation mi) throws Throwable {
if (mi.getMethod().getDeclaringClass().equals(AddedGlobalInterface.class)) {
return new Integer(-1);
return -1;
}
return mi.proceed();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -64,7 +64,7 @@ public class ReflectionUtilsIntegrationTests {
@Override
@Bean
public Integer m1() {
return new Integer(42);
return 42;
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -92,7 +92,7 @@ public class StaticMessageSourceTests extends AbstractApplicationContextTests {
@Test
public void getMessageWithMessageAlreadyLookedFor() {
Object[] arguments = {
new Integer(7), new Date(System.currentTimeMillis()),
7, new Date(System.currentTimeMillis()),
"a disturbance in the Force"
};
@@ -105,7 +105,7 @@ public class StaticMessageSourceTests extends AbstractApplicationContextTests {
contains("there was \"a disturbance in the Force\" on planet 7.")).as("2nd search within MsgFormat cache returned expected message for Locale.US").isTrue();
Object[] newArguments = {
new Integer(8), new Date(System.currentTimeMillis()),
8, new Date(System.currentTimeMillis()),
"a disturbance in the Force"
};
@@ -120,7 +120,7 @@ public class StaticMessageSourceTests extends AbstractApplicationContextTests {
@Test
public void getMessageWithNoDefaultPassedInAndFoundInMsgCatalog() {
Object[] arguments = {
new Integer(7), new Date(System.currentTimeMillis()),
7, new Date(System.currentTimeMillis()),
"a disturbance in the Force"
};

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -87,7 +87,7 @@ public class FormattingConversionServiceTests {
String formatted = formattingService.convert(3, String.class);
assertThat(formatted).isEqualTo("3");
Integer i = formattingService.convert("3", Integer.class);
assertThat(i).isEqualTo(new Integer(3));
assertThat(i).isEqualTo(3);
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -192,7 +192,7 @@ public class NotificationListenerTests extends AbstractMBeanServerTests {
String ageAttribute = "Age";
server.setAttribute(objectName, new Attribute(nameAttribute, "Rob Harrop"));
server.setAttribute(objectName, new Attribute(ageAttribute, new Integer(90)));
server.setAttribute(objectName, new Attribute(ageAttribute, 90));
assertThat(listener.getCount(nameAttribute)).as("Listener not notified for Name").isEqualTo(1);
assertThat(listener.getCount(ageAttribute)).as("Listener incorrectly notified for Age").isEqualTo(0);
@@ -231,7 +231,7 @@ public class NotificationListenerTests extends AbstractMBeanServerTests {
start(exporter);
assertIsRegistered("Should have registered MBean", objectName);
server.setAttribute(objectName, new Attribute("Age", new Integer(77)));
server.setAttribute(objectName, new Attribute("Age", 77));
assertThat(listener.getCount("Age")).as("Listener not notified").isEqualTo(1);
}
@@ -262,7 +262,7 @@ public class NotificationListenerTests extends AbstractMBeanServerTests {
start(exporter);
assertIsRegistered("Should have registered MBean", objectName);
server.setAttribute(objectName, new Attribute("Age", new Integer(77)));
server.setAttribute(objectName, new Attribute("Age", 77));
assertThat(listener.getCount("Age")).as("Listener not notified").isEqualTo(1);
}
@@ -294,7 +294,7 @@ public class NotificationListenerTests extends AbstractMBeanServerTests {
start(exporter);
assertIsRegistered("Should have registered MBean", objectName);
server.setAttribute(objectName, new Attribute("Age", new Integer(77)));
server.setAttribute(objectName, new Attribute("Age", 77));
assertThat(listener.getCount("Age")).as("Listener should have been notified exactly once").isEqualTo(1);
}
@@ -326,7 +326,7 @@ public class NotificationListenerTests extends AbstractMBeanServerTests {
start(exporter);
assertIsRegistered("Should have registered MBean", objectName);
server.setAttribute(objectName, new Attribute("Age", new Integer(77)));
server.setAttribute(objectName, new Attribute("Age", 77));
assertThat(listener.getCount("Age")).as("Listener should have been notified exactly once").isEqualTo(1);
}
@@ -367,10 +367,10 @@ public class NotificationListenerTests extends AbstractMBeanServerTests {
assertIsRegistered("Should have registered MBean", objectName1);
assertIsRegistered("Should have registered MBean", objectName2);
server.setAttribute(ObjectNameManager.getInstance(objectName1), new Attribute("Age", new Integer(77)));
server.setAttribute(ObjectNameManager.getInstance(objectName1), new Attribute("Age", 77));
assertThat(listener.getCount("Age")).as("Listener not notified for testBean1").isEqualTo(1);
server.setAttribute(ObjectNameManager.getInstance(objectName2), new Attribute("Age", new Integer(33)));
server.setAttribute(ObjectNameManager.getInstance(objectName2), new Attribute("Age", 33));
assertThat(listener.getCount("Age")).as("Listener not notified for testBean2").isEqualTo(2);
}
@@ -462,10 +462,10 @@ public class NotificationListenerTests extends AbstractMBeanServerTests {
if (currentCount != null) {
int count = currentCount.intValue() + 1;
this.attributeCounts.put(attributeName, new Integer(count));
this.attributeCounts.put(attributeName, count);
}
else {
this.attributeCounts.put(attributeName, new Integer(1));
this.attributeCounts.put(attributeName, 1);
}
this.attributeHandbacks.put(attributeName, handback);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -177,7 +177,7 @@ public class JndiObjectFactoryBeanTests {
jof.setExpectedType(Integer.class);
jof.setDefaultObject("5");
jof.afterPropertiesSet();
assertThat(jof.getObject()).isEqualTo(new Integer(5));
assertThat(jof.getObject()).isEqualTo(5);
}
@Test
@@ -189,7 +189,7 @@ public class JndiObjectFactoryBeanTests {
jof.setDefaultObject("5");
jof.setBeanFactory(new DefaultListableBeanFactory());
jof.afterPropertiesSet();
assertThat(jof.getObject()).isEqualTo(new Integer(5));
assertThat(jof.getObject()).isEqualTo(5);
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -44,14 +44,14 @@ public class SchedulerBeanDefinitionParserTests {
public void defaultScheduler() {
ThreadPoolTaskScheduler scheduler = (ThreadPoolTaskScheduler) this.context.getBean("defaultScheduler");
Integer size = (Integer) new DirectFieldAccessor(scheduler).getPropertyValue("poolSize");
assertThat(size).isEqualTo(new Integer(1));
assertThat(size).isEqualTo(1);
}
@Test
public void customScheduler() {
ThreadPoolTaskScheduler scheduler = (ThreadPoolTaskScheduler) this.context.getBean("customScheduler");
Integer size = (Integer) new DirectFieldAccessor(scheduler).getPropertyValue("poolSize");
assertThat(size).isEqualTo(new Integer(42));
assertThat(size).isEqualTo(42);
}
@Test

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -332,7 +332,7 @@ public class DataBinderTests {
MutablePropertyValues pvs = new MutablePropertyValues();
pvs.add("object", "1");
binder.bind(pvs);
assertThat(tb.getObject()).isEqualTo(new Integer(1));
assertThat(tb.getObject()).isEqualTo(1);
}
@Test
@@ -460,7 +460,7 @@ public class DataBinderTests {
LocaleContextHolder.setLocale(Locale.GERMAN);
try {
binder.bind(pvs);
assertThat(tb.getIntegerList().get(0)).isEqualTo(new Integer(1));
assertThat(tb.getIntegerList().get(0)).isEqualTo(1);
assertThat(binder.getBindingResult().getFieldValue("integerList[0]")).isEqualTo("1");
}
finally {
@@ -932,7 +932,7 @@ public class DataBinderTests {
binder.registerCustomEditor(int.class, "age", new PropertyEditorSupport() {
@Override
public void setAsText(String text) throws IllegalArgumentException {
setValue(new Integer(99));
setValue(99);
}
@Override
public String getAsText() {
@@ -1231,7 +1231,7 @@ public class DataBinderTests {
assertThat((errors.getFieldErrors("age").get(0)).getCode()).isEqualTo("TOO_YOUNG");
assertThat((errors.getFieldErrors("age").get(0)).getObjectName()).isEqualTo("tb");
assertThat((errors.getFieldErrors("age").get(0)).getField()).isEqualTo("age");
assertThat((errors.getFieldErrors("age").get(0)).getRejectedValue()).isEqualTo(new Integer(0));
assertThat((errors.getFieldErrors("age").get(0)).getRejectedValue()).isEqualTo(0);
assertThat((errors.getFieldErrors("age").get(1)).getCode()).isEqualTo("AGE_NOT_ODD");
assertThat(errors.hasFieldErrors("name")).isTrue();
@@ -1248,7 +1248,7 @@ public class DataBinderTests {
assertThat(errors.getFieldErrorCount("spouse.age")).isEqualTo(1);
assertThat(errors.getFieldError("spouse.age").getCode()).isEqualTo("TOO_YOUNG");
assertThat((errors.getFieldErrors("spouse.age").get(0)).getObjectName()).isEqualTo("tb");
assertThat((errors.getFieldErrors("spouse.age").get(0)).getRejectedValue()).isEqualTo(new Integer(0));
assertThat((errors.getFieldErrors("spouse.age").get(0)).getRejectedValue()).isEqualTo(0);
}
@Test
@@ -1303,7 +1303,7 @@ public class DataBinderTests {
assertThat((errors.getFieldErrors("age").get(0)).getCode()).isEqualTo("validation.TOO_YOUNG");
assertThat((errors.getFieldErrors("age").get(0)).getObjectName()).isEqualTo("tb");
assertThat((errors.getFieldErrors("age").get(0)).getField()).isEqualTo("age");
assertThat((errors.getFieldErrors("age").get(0)).getRejectedValue()).isEqualTo(new Integer(0));
assertThat((errors.getFieldErrors("age").get(0)).getRejectedValue()).isEqualTo(0);
assertThat((errors.getFieldErrors("age").get(1)).getCode()).isEqualTo("validation.AGE_NOT_ODD");
assertThat(errors.hasFieldErrors("name")).isTrue();
@@ -1320,7 +1320,7 @@ public class DataBinderTests {
assertThat(errors.getFieldErrorCount("spouse.age")).isEqualTo(1);
assertThat(errors.getFieldError("spouse.age").getCode()).isEqualTo("validation.TOO_YOUNG");
assertThat((errors.getFieldErrors("spouse.age").get(0)).getObjectName()).isEqualTo("tb");
assertThat((errors.getFieldErrors("spouse.age").get(0)).getRejectedValue()).isEqualTo(new Integer(0));
assertThat((errors.getFieldErrors("spouse.age").get(0)).getRejectedValue()).isEqualTo(0);
}
@Test
@@ -1374,9 +1374,9 @@ public class DataBinderTests {
boolean condition = tb.getSet() instanceof TreeSet;
assertThat(condition).isTrue();
assertThat(tb.getSet().size()).isEqualTo(3);
assertThat(tb.getSet().contains(new Integer(10))).isTrue();
assertThat(tb.getSet().contains(new Integer(20))).isTrue();
assertThat(tb.getSet().contains(new Integer(30))).isTrue();
assertThat(tb.getSet().contains(10)).isTrue();
assertThat(tb.getSet().contains(20)).isTrue();
assertThat(tb.getSet().contains(30)).isTrue();
pvs = new MutablePropertyValues();
pvs.add("set", null);
@@ -1840,7 +1840,7 @@ public class DataBinderTests {
assertThat(ex2.getGlobalError().getCode()).isEqualTo("invalid");
assertThat(ex2.hasFieldErrors("age")).isTrue();
assertThat(ex2.getFieldError("age").getCode()).isEqualTo("invalidField");
assertThat(ex2.getFieldValue("age")).isEqualTo(new Integer(99));
assertThat(ex2.getFieldValue("age")).isEqualTo(99);
ex2.rejectValue("name", "invalidField", "someMessage");
assertThat(ex2.hasFieldErrors("name")).isTrue();