diff --git a/spring-beans/src/test/java/org/springframework/beans/propertyeditors/CustomEditorTests.java b/spring-beans/src/test/java/org/springframework/beans/propertyeditors/CustomEditorTests.java index 696e3088583..02d6eacfdf8 100644 --- a/spring-beans/src/test/java/org/springframework/beans/propertyeditors/CustomEditorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/propertyeditors/CustomEditorTests.java @@ -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(); diff --git a/spring-core/src/test/java/org/springframework/util/ObjectUtilsTests.java b/spring-core/src/test/java/org/springframework/util/ObjectUtilsTests.java index b18710a1bfd..206b8633d0f 100644 --- a/spring-core/src/test/java/org/springframework/util/ObjectUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/util/ObjectUtilsTests.java @@ -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}"); } diff --git a/spring-web/src/test/java/org/springframework/web/context/request/ServletRequestAttributesTests.java b/spring-web/src/test/java/org/springframework/web/context/request/ServletRequestAttributesTests.java index b24979a9548..d37c21668f6 100644 --- a/spring-web/src/test/java/org/springframework/web/context/request/ServletRequestAttributesTests.java +++ b/spring-web/src/test/java/org/springframework/web/context/request/ServletRequestAttributesTests.java @@ -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