Use autoboxing instead of explicit wrapping in tests
Closes gh-24801
This commit is contained in:
@@ -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.
|
||||
@@ -140,11 +140,11 @@ public class SelectionAndProjectionTests {
|
||||
assertThat(typedValue.getTypeDescriptor().getElementTypeDescriptor().getType()).isEqualTo(Integer.class);
|
||||
Integer[] array = (Integer[]) value;
|
||||
assertThat(array.length).isEqualTo(5);
|
||||
assertThat(array[0]).isEqualTo(new Integer(0));
|
||||
assertThat(array[1]).isEqualTo(new Integer(1));
|
||||
assertThat(array[2]).isEqualTo(new Integer(2));
|
||||
assertThat(array[3]).isEqualTo(new Integer(3));
|
||||
assertThat(array[4]).isEqualTo(new Integer(4));
|
||||
assertThat(array[0]).isEqualTo(0);
|
||||
assertThat(array[1]).isEqualTo(1);
|
||||
assertThat(array[2]).isEqualTo(2);
|
||||
assertThat(array[3]).isEqualTo(3);
|
||||
assertThat(array[4]).isEqualTo(4);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -177,11 +177,11 @@ public class SelectionAndProjectionTests {
|
||||
assertThat(typedValue.getTypeDescriptor().getElementTypeDescriptor().getType()).isEqualTo(Integer.class);
|
||||
Integer[] array = (Integer[]) value;
|
||||
assertThat(array.length).isEqualTo(5);
|
||||
assertThat(array[0]).isEqualTo(new Integer(0));
|
||||
assertThat(array[1]).isEqualTo(new Integer(1));
|
||||
assertThat(array[2]).isEqualTo(new Integer(2));
|
||||
assertThat(array[3]).isEqualTo(new Integer(3));
|
||||
assertThat(array[4]).isEqualTo(new Integer(4));
|
||||
assertThat(array[0]).isEqualTo(0);
|
||||
assertThat(array[1]).isEqualTo(1);
|
||||
assertThat(array[2]).isEqualTo(2);
|
||||
assertThat(array[3]).isEqualTo(3);
|
||||
assertThat(array[4]).isEqualTo(4);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -298,9 +298,9 @@ public class SelectionAndProjectionTests {
|
||||
assertThat(typedValue.getTypeDescriptor().getElementTypeDescriptor().getType()).isEqualTo(Number.class);
|
||||
Number[] array = (Number[]) value;
|
||||
assertThat(array.length).isEqualTo(3);
|
||||
assertThat(array[0]).isEqualTo(new Integer(5));
|
||||
assertThat(array[0]).isEqualTo(5);
|
||||
assertThat(array[1]).isEqualTo(5.9f);
|
||||
assertThat(array[2]).isEqualTo(new Integer(7));
|
||||
assertThat(array[2]).isEqualTo(7);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -457,7 +457,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
expression = parser.parseExpression("T(Integer).valueOf(42)");
|
||||
expression.getValue(Integer.class);
|
||||
assertCanCompile(expression);
|
||||
assertThat(expression.getValue(Integer.class)).isEqualTo(new Integer(42));
|
||||
assertThat(expression.getValue(Integer.class)).isEqualTo(42);
|
||||
|
||||
// Code gen is different for -1 .. 6 because there are bytecode instructions specifically for those values
|
||||
|
||||
@@ -4024,7 +4024,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
assertThat(tc.s).isEqualTo("foo");
|
||||
assertCanCompile(expression);
|
||||
tc.reset();
|
||||
tc.obj=new Integer(42);
|
||||
tc.obj=42;
|
||||
assertThatExceptionOfType(SpelEvaluationException.class).isThrownBy(() ->
|
||||
expression.getValue(tc))
|
||||
.withCauseInstanceOf(ClassCastException.class);
|
||||
@@ -4035,7 +4035,7 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
assertThat(expression.getValue("abc")).isEqualTo('a');
|
||||
assertCanCompile(expression);
|
||||
assertThatExceptionOfType(SpelEvaluationException.class).isThrownBy(() ->
|
||||
expression.getValue(new Integer(42)))
|
||||
expression.getValue(42))
|
||||
.withCauseInstanceOf(ClassCastException.class);
|
||||
}
|
||||
|
||||
@@ -4072,10 +4072,10 @@ public class SpelCompilationCoverageTests extends AbstractExpressionTests {
|
||||
@Test
|
||||
public void methodReference_simpleInstanceMethodNoArgReturnPrimitive() throws Exception {
|
||||
expression = parser.parseExpression("intValue()");
|
||||
int resultI = expression.getValue(new Integer(42), Integer.TYPE);
|
||||
int resultI = expression.getValue(42, Integer.TYPE);
|
||||
assertThat(resultI).isEqualTo(42);
|
||||
assertCanCompile(expression);
|
||||
int resultC = expression.getValue(new Integer(42), Integer.TYPE);
|
||||
int resultC = expression.getValue(42, Integer.TYPE);
|
||||
assertThat(resultC).isEqualTo(42);
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -628,12 +628,12 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
}
|
||||
|
||||
final Integer INTEGER = Integer.valueOf(7);
|
||||
final Integer INTEGER = 7;
|
||||
|
||||
EvaluationContext emptyEvalContext = new StandardEvaluationContext();
|
||||
|
||||
List<TypeDescriptor> args = new ArrayList<>();
|
||||
args.add(TypeDescriptor.forObject(new Integer(42)));
|
||||
args.add(TypeDescriptor.forObject(42));
|
||||
|
||||
ConversionPriority1 target = new ConversionPriority1();
|
||||
MethodExecutor me = new ReflectiveMethodResolver(true).resolve(emptyEvalContext, target, "getX", args);
|
||||
@@ -1485,10 +1485,10 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
SpelExpressionParser parser = new SpelExpressionParser();
|
||||
Expression expression = parser.parseExpression("T(org.springframework.expression.spel.SpelReproTests.DistanceEnforcer).from(#no)");
|
||||
StandardEvaluationContext sec = new StandardEvaluationContext();
|
||||
sec.setVariable("no", new Integer(1));
|
||||
sec.setVariable("no", 1);
|
||||
assertThat(expression.getValue(sec).toString().startsWith("Integer")).isTrue();
|
||||
sec = new StandardEvaluationContext();
|
||||
sec.setVariable("no", new Float(1.0));
|
||||
sec.setVariable("no", 1.0F);
|
||||
assertThat(expression.getValue(sec).toString().startsWith("Number")).isTrue();
|
||||
sec = new StandardEvaluationContext();
|
||||
sec.setVariable("no", "1.0");
|
||||
@@ -1694,7 +1694,7 @@ public class SpelReproTests extends AbstractExpressionTests {
|
||||
}
|
||||
|
||||
public Integer tryToInvokeWithNull2(int i) {
|
||||
return new Integer(i);
|
||||
return i;
|
||||
}
|
||||
|
||||
public String tryToInvokeWithNull3(Integer value, String... strings) {
|
||||
|
||||
Reference in New Issue
Block a user