Skip to content

Commit 109b00d

Browse files
committed
Avoid use of deprecated Character/Double constructors in tests
1 parent b6abf45 commit 109b00d

File tree

3 files changed

+14
-18
lines changed

3 files changed

+14
-18
lines changed

spring-beans/src/test/java/org/springframework/beans/propertyeditors/CustomEditorTests.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2021 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -502,7 +502,7 @@ void testCharacterEditor() {
502502
CharBean cb = new CharBean();
503503
BeanWrapper bw = new BeanWrapperImpl(cb);
504504

505-
bw.setPropertyValue("myChar", new Character('c'));
505+
bw.setPropertyValue("myChar", 'c');
506506
assertThat(cb.getMyChar()).isEqualTo('c');
507507

508508
bw.setPropertyValue("myChar", "c");
@@ -526,16 +526,16 @@ void testCharacterEditorWithAllowEmpty() {
526526
bw.registerCustomEditor(Character.class, new CharacterEditor(true));
527527

528528
bw.setPropertyValue("myCharacter", 'c');
529-
assertThat(cb.getMyCharacter()).isEqualTo(Character.valueOf('c'));
529+
assertThat(cb.getMyCharacter()).isEqualTo('c');
530530

531531
bw.setPropertyValue("myCharacter", "c");
532-
assertThat(cb.getMyCharacter()).isEqualTo(Character.valueOf('c'));
532+
assertThat(cb.getMyCharacter()).isEqualTo('c');
533533

534534
bw.setPropertyValue("myCharacter", "\u0041");
535-
assertThat(cb.getMyCharacter()).isEqualTo(Character.valueOf('A'));
535+
assertThat(cb.getMyCharacter()).isEqualTo('A');
536536

537537
bw.setPropertyValue("myCharacter", " ");
538-
assertThat(cb.getMyCharacter()).isEqualTo(Character.valueOf(' '));
538+
assertThat(cb.getMyCharacter()).isEqualTo(' ');
539539

540540
bw.setPropertyValue("myCharacter", "");
541541
assertThat(cb.getMyCharacter()).isNull();

spring-core/src/test/java/org/springframework/util/ObjectUtilsTests.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2021 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -251,32 +251,28 @@ void hashCodeWithBooleanTrue() {
251251
@Deprecated
252252
void hashCodeWithDouble() {
253253
double dbl = 9830.43;
254-
int expected = (new Double(dbl)).hashCode();
255-
assertThat(ObjectUtils.hashCode(dbl)).isEqualTo(expected);
254+
assertThat(ObjectUtils.hashCode(dbl)).isEqualTo(Double.hashCode(dbl));
256255
}
257256

258257
@Test
259258
@Deprecated
260259
void hashCodeWithFloat() {
261260
float flt = 34.8f;
262-
int expected = (Float.valueOf(flt)).hashCode();
263-
assertThat(ObjectUtils.hashCode(flt)).isEqualTo(expected);
261+
assertThat(ObjectUtils.hashCode(flt)).isEqualTo(Float.hashCode(flt));
264262
}
265263

266264
@Test
267265
@Deprecated
268266
void hashCodeWithLong() {
269267
long lng = 883L;
270-
int expected = (Long.valueOf(lng)).hashCode();
271-
assertThat(ObjectUtils.hashCode(lng)).isEqualTo(expected);
268+
assertThat(ObjectUtils.hashCode(lng)).isEqualTo(Long.hashCode(lng));
272269
}
273270

274271
@Test
275272
void identityToString() {
276273
Object obj = new Object();
277274
String expected = obj.getClass().getName() + "@" + ObjectUtils.getIdentityHexString(obj);
278-
String actual = ObjectUtils.identityToString(obj);
279-
assertThat(actual).isEqualTo(expected);
275+
assertThat(ObjectUtils.identityToString(obj)).isEqualTo(expected);
280276
}
281277

282278
@Test
@@ -732,7 +728,7 @@ void nullSafeToStringWithPlainOldString() {
732728

733729
@Test
734730
void nullSafeToStringWithObjectArray() {
735-
Object[] array = {"Han", Long.valueOf(43)};
731+
Object[] array = {"Han", 43};
736732
assertThat(ObjectUtils.nullSafeToString(array)).isEqualTo("{Han, 43}");
737733
}
738734

spring-web/src/test/java/org/springframework/web/context/request/ServletRequestAttributesTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -153,7 +153,7 @@ public void skipImmutableString() {
153153

154154
@Test
155155
public void skipImmutableCharacter() {
156-
doSkipImmutableValue(new Character('x'));
156+
doSkipImmutableValue('x');
157157
}
158158

159159
@Test

0 commit comments

Comments
 (0)