Avoid use of deprecated Character/Double constructors in tests

This commit is contained in:
Sam Brannen
2022-12-02 18:27:00 +01:00
parent b6abf45a56
commit 109b00d24d
3 changed files with 14 additions and 18 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2022 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.
@@ -502,7 +502,7 @@ class CustomEditorTests {
CharBean cb = new CharBean();
BeanWrapper bw = new BeanWrapperImpl(cb);
bw.setPropertyValue("myChar", new Character('c'));
bw.setPropertyValue("myChar", 'c');
assertThat(cb.getMyChar()).isEqualTo('c');
bw.setPropertyValue("myChar", "c");
@@ -526,16 +526,16 @@ class CustomEditorTests {
bw.registerCustomEditor(Character.class, new CharacterEditor(true));
bw.setPropertyValue("myCharacter", 'c');
assertThat(cb.getMyCharacter()).isEqualTo(Character.valueOf('c'));
assertThat(cb.getMyCharacter()).isEqualTo('c');
bw.setPropertyValue("myCharacter", "c");
assertThat(cb.getMyCharacter()).isEqualTo(Character.valueOf('c'));
assertThat(cb.getMyCharacter()).isEqualTo('c');
bw.setPropertyValue("myCharacter", "\u0041");
assertThat(cb.getMyCharacter()).isEqualTo(Character.valueOf('A'));
assertThat(cb.getMyCharacter()).isEqualTo('A');
bw.setPropertyValue("myCharacter", " ");
assertThat(cb.getMyCharacter()).isEqualTo(Character.valueOf(' '));
assertThat(cb.getMyCharacter()).isEqualTo(' ');
bw.setPropertyValue("myCharacter", "");
assertThat(cb.getMyCharacter()).isNull();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2022 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.
@@ -251,32 +251,28 @@ class ObjectUtilsTests {
@Deprecated
void hashCodeWithDouble() {
double dbl = 9830.43;
int expected = (new Double(dbl)).hashCode();
assertThat(ObjectUtils.hashCode(dbl)).isEqualTo(expected);
assertThat(ObjectUtils.hashCode(dbl)).isEqualTo(Double.hashCode(dbl));
}
@Test
@Deprecated
void hashCodeWithFloat() {
float flt = 34.8f;
int expected = (Float.valueOf(flt)).hashCode();
assertThat(ObjectUtils.hashCode(flt)).isEqualTo(expected);
assertThat(ObjectUtils.hashCode(flt)).isEqualTo(Float.hashCode(flt));
}
@Test
@Deprecated
void hashCodeWithLong() {
long lng = 883L;
int expected = (Long.valueOf(lng)).hashCode();
assertThat(ObjectUtils.hashCode(lng)).isEqualTo(expected);
assertThat(ObjectUtils.hashCode(lng)).isEqualTo(Long.hashCode(lng));
}
@Test
void identityToString() {
Object obj = new Object();
String expected = obj.getClass().getName() + "@" + ObjectUtils.getIdentityHexString(obj);
String actual = ObjectUtils.identityToString(obj);
assertThat(actual).isEqualTo(expected);
assertThat(ObjectUtils.identityToString(obj)).isEqualTo(expected);
}
@Test
@@ -732,7 +728,7 @@ class ObjectUtilsTests {
@Test
void nullSafeToStringWithObjectArray() {
Object[] array = {"Han", Long.valueOf(43)};
Object[] array = {"Han", 43};
assertThat(ObjectUtils.nullSafeToString(array)).isEqualTo("{Han, 43}");
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2022 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.
@@ -153,7 +153,7 @@ public class ServletRequestAttributesTests {
@Test
public void skipImmutableCharacter() {
doSkipImmutableValue(new Character('x'));
doSkipImmutableValue('x');
}
@Test