From af2e13e21138611e2aa8dba3fea824402a785a96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Nicoll?= Date: Fri, 5 Jan 2024 06:34:09 +0100 Subject: [PATCH] Polish --- .../aot/hint/ReflectionHintsTests.java | 3 +- .../aot/hint/ResourceHintsTests.java | 3 +- .../core/GenericTypeResolverTests.java | 8 +- .../AnnotatedElementUtilsTests.java | 14 ++-- .../core/annotation/AnnotationUtilsTests.java | 4 +- ...ComposedOnSingleAnnotatedElementTests.java | 5 +- .../annotation/MergedAnnotationsTests.java | 15 ++-- ...otationsOnSingleAnnotatedElementTests.java | 6 +- .../core/codec/ByteArrayDecoderTests.java | 8 +- .../core/codec/ByteArrayEncoderTests.java | 6 +- .../core/codec/ByteBufferDecoderTests.java | 8 +- .../core/codec/ByteBufferEncoderTests.java | 6 +- .../core/codec/CharBufferDecoderTests.java | 8 +- .../core/codec/CharSequenceEncoderTests.java | 6 +- .../core/codec/DataBufferDecoderTests.java | 8 +- .../core/codec/DataBufferEncoderTests.java | 6 +- .../core/codec/Netty5BufferDecoderTests.java | 8 +- .../core/codec/NettyByteBufDecoderTests.java | 8 +- .../core/codec/NettyByteBufEncoderTests.java | 6 +- .../core/codec/ResourceDecoderTests.java | 10 +-- .../core/codec/ResourceEncoderTests.java | 6 +- .../core/codec/StringDecoderTests.java | 8 +- .../CollectionToCollectionConverterTests.java | 6 +- .../support/MapToMapConverterTests.java | 6 +- .../convert/support/StreamConverterTests.java | 5 +- .../core/env/CustomEnvironmentTests.java | 3 +- .../core/env/PropertySourceTests.java | 23 +++--- .../core/env/StandardEnvironmentTests.java | 12 +-- .../core/io/buffer/DataBufferUtilsTests.java | 3 +- .../core/io/support/EncodedResourceTests.java | 7 +- .../type/AbstractAnnotationMetadataTests.java | 78 +++++++++---------- .../type/AbstractMethodMetadataTests.java | 42 +++++----- .../core/type/AnnotationMetadataTests.java | 4 +- .../springframework/util/ClassUtilsTests.java | 3 +- .../util/CompositeIteratorTests.java | 4 +- .../util/DigestUtilsTests.java | 5 +- .../util/ExceptionTypeFilterTests.java | 7 +- .../util/InstanceFilterTests.java | 6 +- .../util/PropertiesPersisterTests.java | 4 +- .../ResizableByteArrayOutputStreamTests.java | 6 +- .../util/SerializationUtilsTests.java | 3 +- .../util/UnmodifiableMultiValueMapTests.java | 3 +- .../comparator/ComparableComparatorTests.java | 3 +- .../comparator/NullSafeComparatorTests.java | 3 +- .../util/concurrent/FutureAdapterTests.java | 3 +- .../concurrent/ListenableFutureTaskTests.java | 4 +- .../util/xml/AbstractStaxXMLReaderTests.java | 5 +- .../codec/AbstractDecoderTests.java | 8 +- .../codec/AbstractEncoderTests.java | 6 +- 49 files changed, 205 insertions(+), 217 deletions(-) diff --git a/spring-core/src/test/java/org/springframework/aot/hint/ReflectionHintsTests.java b/spring-core/src/test/java/org/springframework/aot/hint/ReflectionHintsTests.java index 591bcf95312..2c3351c752c 100644 --- a/spring-core/src/test/java/org/springframework/aot/hint/ReflectionHintsTests.java +++ b/spring-core/src/test/java/org/springframework/aot/hint/ReflectionHintsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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. @@ -56,7 +56,6 @@ class ReflectionHintsTests { } @Test - @SuppressWarnings("unchecked") void registerTypeIfPresentIgnoresMissingClass() { Consumer hintBuilder = mock(); this.reflectionHints.registerTypeIfPresent(null, "com.example.DoesNotExist", hintBuilder); diff --git a/spring-core/src/test/java/org/springframework/aot/hint/ResourceHintsTests.java b/spring-core/src/test/java/org/springframework/aot/hint/ResourceHintsTests.java index dd24398c300..b8393dd52ba 100644 --- a/spring-core/src/test/java/org/springframework/aot/hint/ResourceHintsTests.java +++ b/spring-core/src/test/java/org/springframework/aot/hint/ResourceHintsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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. @@ -132,7 +132,6 @@ class ResourceHintsTests { } @Test - @SuppressWarnings("unchecked") void registerIfPresentIgnoreMissingLocation() { Consumer hintBuilder = mock(); this.resourceHints.registerPatternIfPresent(null, "location/does-not-exist/", hintBuilder); diff --git a/spring-core/src/test/java/org/springframework/core/GenericTypeResolverTests.java b/spring-core/src/test/java/org/springframework/core/GenericTypeResolverTests.java index 0fd9488c1b9..3290133fd2d 100644 --- a/spring-core/src/test/java/org/springframework/core/GenericTypeResolverTests.java +++ b/spring-core/src/test/java/org/springframework/core/GenericTypeResolverTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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. @@ -183,19 +183,19 @@ class GenericTypeResolverTests { } @Test - public void resolvePartiallySpecializedTypeVariables() { + void resolvePartiallySpecializedTypeVariables() { Type resolved = resolveType(BiGenericClass.class.getTypeParameters()[0], TypeFixedBiGenericClass.class); assertThat(resolved).isEqualTo(D.class); } @Test - public void resolveTransitiveTypeVariableWithDifferentName() { + void resolveTransitiveTypeVariableWithDifferentName() { Type resolved = resolveType(BiGenericClass.class.getTypeParameters()[1], TypeFixedBiGenericClass.class); assertThat(resolved).isEqualTo(E.class); } @Test - public void resolveMethodParameterWithNestedGenerics() { + void resolveMethodParameterWithNestedGenerics() { Method method = method(WithMethodParameter.class, "nestedGenerics", List.class); MethodParameter methodParameter = new MethodParameter(method, 0); Type resolvedType = resolveType(methodParameter.getGenericParameterType(), WithMethodParameter.class); diff --git a/spring-core/src/test/java/org/springframework/core/annotation/AnnotatedElementUtilsTests.java b/spring-core/src/test/java/org/springframework/core/annotation/AnnotatedElementUtilsTests.java index 1d1b75fa99f..febdebe7712 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/AnnotatedElementUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/AnnotatedElementUtilsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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. @@ -293,7 +293,7 @@ class AnnotatedElementUtilsTests { void getAllAnnotationAttributesOnClassWithLocalAnnotation() { MultiValueMap attributes = getAllAnnotationAttributes(TxConfig.class, TX_NAME); assertThat(attributes).as("Annotation attributes map for @Transactional on TxConfig").isNotNull(); - assertThat(attributes.get("value")).as("value for TxConfig").isEqualTo(asList("TxConfig")); + assertThat(attributes.get("value")).as("value for TxConfig").isEqualTo(List.of("TxConfig")); } @Test @@ -307,14 +307,14 @@ class AnnotatedElementUtilsTests { void getAllAnnotationAttributesFavorsInheritedAnnotationsOverMoreLocallyDeclaredComposedAnnotations() { MultiValueMap attributes = getAllAnnotationAttributes(SubSubClassWithInheritedAnnotation.class, TX_NAME); assertThat(attributes).as("Annotation attributes map for @Transactional on SubSubClassWithInheritedAnnotation").isNotNull(); - assertThat(attributes.get("qualifier")).isEqualTo(asList("transactionManager")); + assertThat(attributes.get("qualifier")).isEqualTo(List.of("transactionManager")); } @Test void getAllAnnotationAttributesFavorsInheritedComposedAnnotationsOverMoreLocallyDeclaredComposedAnnotations() { MultiValueMap attributes = getAllAnnotationAttributes( SubSubClassWithInheritedComposedAnnotation.class, TX_NAME); assertThat(attributes).as("Annotation attributes map for @Transactional on SubSubClassWithInheritedComposedAnnotation").isNotNull(); - assertThat(attributes.get("qualifier")).isEqualTo(asList("composed1")); + assertThat(attributes.get("qualifier")).isEqualTo(List.of("composed1")); } /** @@ -329,7 +329,7 @@ class AnnotatedElementUtilsTests { // See org.springframework.core.env.EnvironmentSystemIntegrationTests#mostSpecificDerivedClassDrivesEnvironment_withDevEnvAndDerivedDevConfigClass MultiValueMap attributes = getAllAnnotationAttributes(DerivedTxConfig.class, TX_NAME); assertThat(attributes).as("Annotation attributes map for @Transactional on DerivedTxConfig").isNotNull(); - assertThat(attributes.get("value")).as("value for DerivedTxConfig").isEqualTo(asList("DerivedTxConfig")); + assertThat(attributes.get("value")).as("value for DerivedTxConfig").isEqualTo(List.of("DerivedTxConfig")); } /** @@ -348,7 +348,7 @@ class AnnotatedElementUtilsTests { MultiValueMap attributes = getAllAnnotationAttributes( NonNullApi.class, Nonnull.class.getName()); assertThat(attributes).as("Annotation attributes map for @Nonnull on NonNullApi").isNotNull(); - assertThat(attributes.get("when")).as("value for NonNullApi").isEqualTo(asList(When.ALWAYS)); + assertThat(attributes.get("when")).as("value for NonNullApi").isEqualTo(List.of(When.ALWAYS)); } @Test @@ -356,7 +356,7 @@ class AnnotatedElementUtilsTests { MultiValueMap attributes = getAllAnnotationAttributes( ParametersAreNonnullByDefault.class, Nonnull.class.getName()); assertThat(attributes).as("Annotation attributes map for @Nonnull on NonNullApi").isNotNull(); - assertThat(attributes.get("when")).as("value for NonNullApi").isEqualTo(asList(When.ALWAYS)); + assertThat(attributes.get("when")).as("value for NonNullApi").isEqualTo(List.of(When.ALWAYS)); } @Test diff --git a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java index ce500f3b81f..05f9319994c 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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. @@ -882,7 +882,7 @@ class AnnotationUtilsTests { } @Test - void synthesizeAnnotationFromMapWithImplicitAttributeAliases() throws Exception { + void synthesizeAnnotationFromMapWithImplicitAttributeAliases() { assertAnnotationSynthesisFromMapWithImplicitAliases("value"); assertAnnotationSynthesisFromMapWithImplicitAliases("location1"); assertAnnotationSynthesisFromMapWithImplicitAliases("location2"); diff --git a/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsComposedOnSingleAnnotatedElementTests.java b/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsComposedOnSingleAnnotatedElementTests.java index 84fbd07e1b1..864a3e6302f 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsComposedOnSingleAnnotatedElementTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsComposedOnSingleAnnotatedElementTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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. @@ -161,8 +161,7 @@ class MergedAnnotationsComposedOnSingleAnnotatedElementTests { } @Test - void typeHierarchyStrategyMultipleComposedAnnotationsOnBridgeMethod() - throws Exception { + void typeHierarchyStrategyMultipleComposedAnnotationsOnBridgeMethod() { assertTypeHierarchyStrategyBehavior(getBridgeMethod()); } diff --git a/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsTests.java b/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsTests.java index 3026c64bc53..912e64d5468 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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. @@ -415,7 +415,7 @@ class MergedAnnotationsTests { MultiValueMap map = MergedAnnotations.from(TxConfig.class).stream( Transactional.class).collect( MergedAnnotationCollectors.toMultiValueMap()); - assertThat(map).contains(entry("value", Arrays.asList("TxConfig"))); + assertThat(map).contains(entry("value", List.of("TxConfig"))); } @Test @@ -434,7 +434,7 @@ class MergedAnnotationsTests { SubSubClassWithInheritedAnnotation.class, SearchStrategy.INHERITED_ANNOTATIONS).stream(Transactional.class).collect( MergedAnnotationCollectors.toMultiValueMap()); - assertThat(map).contains(entry("qualifier", Arrays.asList("transactionManager"))); + assertThat(map).contains(entry("qualifier", List.of("transactionManager"))); } @Test @@ -443,7 +443,7 @@ class MergedAnnotationsTests { SubSubClassWithInheritedComposedAnnotation.class, SearchStrategy.INHERITED_ANNOTATIONS).stream(Transactional.class).collect( MergedAnnotationCollectors.toMultiValueMap()); - assertThat(map).contains(entry("qualifier", Arrays.asList("composed1"))); + assertThat(map).contains(entry("qualifier", List.of("composed1"))); } /** @@ -458,7 +458,7 @@ class MergedAnnotationsTests { MultiValueMap map = MergedAnnotations.from(DerivedTxConfig.class, SearchStrategy.INHERITED_ANNOTATIONS).stream(Transactional.class).collect( MergedAnnotationCollectors.toMultiValueMap()); - assertThat(map).contains(entry("value", Arrays.asList("DerivedTxConfig"))); + assertThat(map).contains(entry("value", List.of("DerivedTxConfig"))); } /** @@ -855,7 +855,6 @@ class MergedAnnotationsTests { } @Test - @SuppressWarnings("deprecation") void getFromMethodWithMethodAnnotationOnLeaf() throws Exception { Method method = Leaf.class.getMethod("annotatedOnLeaf"); assertThat(method.getAnnotation(Order.class)).isNotNull(); @@ -1731,7 +1730,7 @@ class MergedAnnotationsTests { } @Test - void synthesizeWithImplicitAliases() throws Exception { + void synthesizeWithImplicitAliases() { testSynthesisWithImplicitAliases(ValueImplicitAliasesTestConfigurationClass.class, "value"); testSynthesisWithImplicitAliases(Location1ImplicitAliasesTestConfigurationClass.class, "location1"); testSynthesisWithImplicitAliases(XmlImplicitAliasesTestConfigurationClass.class, "xmlFile"); @@ -1965,7 +1964,7 @@ class MergedAnnotationsTests { } @Test - void synthesizeFromMapWithImplicitAttributeAliases() throws Exception { + void synthesizeFromMapWithImplicitAttributeAliases() { testSynthesisFromMapWithImplicitAliases("value"); testSynthesisFromMapWithImplicitAliases("location1"); testSynthesisFromMapWithImplicitAliases("location2"); diff --git a/spring-core/src/test/java/org/springframework/core/annotation/MultipleComposedAnnotationsOnSingleAnnotatedElementTests.java b/spring-core/src/test/java/org/springframework/core/annotation/MultipleComposedAnnotationsOnSingleAnnotatedElementTests.java index b9c4ec7613c..21b96c0de0b 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/MultipleComposedAnnotationsOnSingleAnnotatedElementTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/MultipleComposedAnnotationsOnSingleAnnotatedElementTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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. @@ -106,7 +106,7 @@ class MultipleComposedAnnotationsOnSingleAnnotatedElementTests { @Test @Disabled("Disabled since some Java 8 updates handle the bridge method differently") - void getMultipleComposedAnnotationsOnBridgeMethod() throws Exception { + void getMultipleComposedAnnotationsOnBridgeMethod() { Set cacheables = getAllMergedAnnotations(getBridgeMethod(), Cacheable.class); assertThat(cacheables).isNotNull(); assertThat(cacheables).isEmpty(); @@ -178,7 +178,7 @@ class MultipleComposedAnnotationsOnSingleAnnotatedElementTests { } @Test - void findMultipleComposedAnnotationsOnBridgeMethod() throws Exception { + void findMultipleComposedAnnotationsOnBridgeMethod() { assertFindAllMergedAnnotationsBehavior(getBridgeMethod()); } diff --git a/spring-core/src/test/java/org/springframework/core/codec/ByteArrayDecoderTests.java b/spring-core/src/test/java/org/springframework/core/codec/ByteArrayDecoderTests.java index 10f93f51503..f50d7a42eb4 100644 --- a/spring-core/src/test/java/org/springframework/core/codec/ByteArrayDecoderTests.java +++ b/spring-core/src/test/java/org/springframework/core/codec/ByteArrayDecoderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 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. @@ -45,7 +45,7 @@ class ByteArrayDecoderTests extends AbstractDecoderTests { @Override @Test - public void canDecode() { + protected void canDecode() { assertThat(this.decoder.canDecode(ResolvableType.forClass(byte[].class), MimeTypeUtils.TEXT_PLAIN)).isTrue(); assertThat(this.decoder.canDecode(ResolvableType.forClass(Integer.class), @@ -56,7 +56,7 @@ class ByteArrayDecoderTests extends AbstractDecoderTests { @Override @Test - public void decode() { + protected void decode() { Flux input = Flux.concat( dataBuffer(this.fooBytes), dataBuffer(this.barBytes)); @@ -70,7 +70,7 @@ class ByteArrayDecoderTests extends AbstractDecoderTests { @Override @Test - public void decodeToMono() { + protected void decodeToMono() { Flux input = Flux.concat( dataBuffer(this.fooBytes), dataBuffer(this.barBytes)); diff --git a/spring-core/src/test/java/org/springframework/core/codec/ByteArrayEncoderTests.java b/spring-core/src/test/java/org/springframework/core/codec/ByteArrayEncoderTests.java index dcb5043f297..7e2eadc3b6e 100644 --- a/spring-core/src/test/java/org/springframework/core/codec/ByteArrayEncoderTests.java +++ b/spring-core/src/test/java/org/springframework/core/codec/ByteArrayEncoderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 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. @@ -43,7 +43,7 @@ class ByteArrayEncoderTests extends AbstractEncoderTests { @Override @Test - public void canEncode() { + protected void canEncode() { assertThat(this.encoder.canEncode(ResolvableType.forClass(byte[].class), MimeTypeUtils.TEXT_PLAIN)).isTrue(); assertThat(this.encoder.canEncode(ResolvableType.forClass(Integer.class), @@ -57,7 +57,7 @@ class ByteArrayEncoderTests extends AbstractEncoderTests { @Override @Test - public void encode() { + protected void encode() { Flux input = Flux.just(this.fooBytes, this.barBytes); testEncodeAll(input, byte[].class, step -> step diff --git a/spring-core/src/test/java/org/springframework/core/codec/ByteBufferDecoderTests.java b/spring-core/src/test/java/org/springframework/core/codec/ByteBufferDecoderTests.java index d14a7543609..65c5c57dd51 100644 --- a/spring-core/src/test/java/org/springframework/core/codec/ByteBufferDecoderTests.java +++ b/spring-core/src/test/java/org/springframework/core/codec/ByteBufferDecoderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 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. @@ -46,7 +46,7 @@ class ByteBufferDecoderTests extends AbstractDecoderTests { @Override @Test - public void canDecode() { + protected void canDecode() { assertThat(this.decoder.canDecode(ResolvableType.forClass(ByteBuffer.class), MimeTypeUtils.TEXT_PLAIN)).isTrue(); assertThat(this.decoder.canDecode(ResolvableType.forClass(Integer.class), @@ -57,7 +57,7 @@ class ByteBufferDecoderTests extends AbstractDecoderTests { @Override @Test - public void decode() { + protected void decode() { Flux input = Flux.concat( dataBuffer(this.fooBytes), dataBuffer(this.barBytes)); @@ -72,7 +72,7 @@ class ByteBufferDecoderTests extends AbstractDecoderTests { @Override @Test - public void decodeToMono() { + protected void decodeToMono() { Flux input = Flux.concat( dataBuffer(this.fooBytes), dataBuffer(this.barBytes)); diff --git a/spring-core/src/test/java/org/springframework/core/codec/ByteBufferEncoderTests.java b/spring-core/src/test/java/org/springframework/core/codec/ByteBufferEncoderTests.java index 1bc0e3f665d..50b93c9f3f6 100644 --- a/spring-core/src/test/java/org/springframework/core/codec/ByteBufferEncoderTests.java +++ b/spring-core/src/test/java/org/springframework/core/codec/ByteBufferEncoderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 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. @@ -43,7 +43,7 @@ class ByteBufferEncoderTests extends AbstractEncoderTests { @Override @Test - public void canEncode() { + protected void canEncode() { assertThat(this.encoder.canEncode(ResolvableType.forClass(ByteBuffer.class), MimeTypeUtils.TEXT_PLAIN)).isTrue(); assertThat(this.encoder.canEncode(ResolvableType.forClass(Integer.class), @@ -57,7 +57,7 @@ class ByteBufferEncoderTests extends AbstractEncoderTests { @Override @Test - public void encode() { + protected void encode() { Flux input = Flux.just(this.fooBytes, this.barBytes) .map(ByteBuffer::wrap); diff --git a/spring-core/src/test/java/org/springframework/core/codec/CharBufferDecoderTests.java b/spring-core/src/test/java/org/springframework/core/codec/CharBufferDecoderTests.java index f1b7a4fe4ea..124d7e36759 100644 --- a/spring-core/src/test/java/org/springframework/core/codec/CharBufferDecoderTests.java +++ b/spring-core/src/test/java/org/springframework/core/codec/CharBufferDecoderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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. @@ -55,7 +55,7 @@ class CharBufferDecoderTests extends AbstractDecoderTests { @Override @Test - public void canDecode() { + protected void canDecode() { assertThat(this.decoder.canDecode(TYPE, MimeTypeUtils.TEXT_PLAIN)).isTrue(); assertThat(this.decoder.canDecode(TYPE, MimeTypeUtils.TEXT_HTML)).isTrue(); assertThat(this.decoder.canDecode(TYPE, MimeTypeUtils.APPLICATION_JSON)).isTrue(); @@ -66,7 +66,7 @@ class CharBufferDecoderTests extends AbstractDecoderTests { @Override @Test - public void decode() { + protected void decode() { CharBuffer u = charBuffer("ü"); CharBuffer e = charBuffer("é"); CharBuffer o = charBuffer("ø"); @@ -230,7 +230,7 @@ class CharBufferDecoderTests extends AbstractDecoderTests { @Override @Test - public void decodeToMono() { + protected void decodeToMono() { Flux input = Flux.just( stringBuffer("foo"), stringBuffer("bar"), diff --git a/spring-core/src/test/java/org/springframework/core/codec/CharSequenceEncoderTests.java b/spring-core/src/test/java/org/springframework/core/codec/CharSequenceEncoderTests.java index bb9325acece..aea1f05befe 100644 --- a/spring-core/src/test/java/org/springframework/core/codec/CharSequenceEncoderTests.java +++ b/spring-core/src/test/java/org/springframework/core/codec/CharSequenceEncoderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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. @@ -48,7 +48,7 @@ class CharSequenceEncoderTests extends AbstractEncoderTests @Override @Test - public void canEncode() { + protected void canEncode() { assertThat(this.encoder.canEncode(ResolvableType.forClass(String.class), MimeTypeUtils.TEXT_PLAIN)).isTrue(); assertThat(this.encoder.canEncode(ResolvableType.forClass(StringBuilder.class), @@ -66,7 +66,7 @@ class CharSequenceEncoderTests extends AbstractEncoderTests @Override @Test - public void encode() { + protected void encode() { Flux input = Flux.just(this.foo, this.bar); testEncodeAll(input, CharSequence.class, step -> step diff --git a/spring-core/src/test/java/org/springframework/core/codec/DataBufferDecoderTests.java b/spring-core/src/test/java/org/springframework/core/codec/DataBufferDecoderTests.java index 3b519bcdfc8..822bb200a9c 100644 --- a/spring-core/src/test/java/org/springframework/core/codec/DataBufferDecoderTests.java +++ b/spring-core/src/test/java/org/springframework/core/codec/DataBufferDecoderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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. @@ -46,7 +46,7 @@ class DataBufferDecoderTests extends AbstractDecoderTests { @Override @Test - public void canDecode() { + protected void canDecode() { assertThat(this.decoder.canDecode(ResolvableType.forClass(DataBuffer.class), MimeTypeUtils.TEXT_PLAIN)).isTrue(); assertThat(this.decoder.canDecode(ResolvableType.forClass(Integer.class), @@ -57,7 +57,7 @@ class DataBufferDecoderTests extends AbstractDecoderTests { @Override @Test - public void decode() { + protected void decode() { Flux input = Flux.just( this.bufferFactory.wrap(this.fooBytes), this.bufferFactory.wrap(this.barBytes)); @@ -70,7 +70,7 @@ class DataBufferDecoderTests extends AbstractDecoderTests { @Override @Test - public void decodeToMono() { + protected void decodeToMono() { Flux input = Flux.concat( dataBuffer(this.fooBytes), dataBuffer(this.barBytes)); diff --git a/spring-core/src/test/java/org/springframework/core/codec/DataBufferEncoderTests.java b/spring-core/src/test/java/org/springframework/core/codec/DataBufferEncoderTests.java index 6d8c0f391f9..adde58f453a 100644 --- a/spring-core/src/test/java/org/springframework/core/codec/DataBufferEncoderTests.java +++ b/spring-core/src/test/java/org/springframework/core/codec/DataBufferEncoderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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. @@ -45,7 +45,7 @@ class DataBufferEncoderTests extends AbstractEncoderTests { @Override @Test - public void canEncode() { + protected void canEncode() { assertThat(this.encoder.canEncode(ResolvableType.forClass(DataBuffer.class), MimeTypeUtils.TEXT_PLAIN)).isTrue(); assertThat(this.encoder.canEncode(ResolvableType.forClass(Integer.class), @@ -59,7 +59,7 @@ class DataBufferEncoderTests extends AbstractEncoderTests { @Override @Test - public void encode() { + protected void encode() { Flux input = Flux.just(this.fooBytes, this.barBytes) .flatMap(bytes -> Mono.defer(() -> { DataBuffer dataBuffer = this.bufferFactory.allocateBuffer(bytes.length); diff --git a/spring-core/src/test/java/org/springframework/core/codec/Netty5BufferDecoderTests.java b/spring-core/src/test/java/org/springframework/core/codec/Netty5BufferDecoderTests.java index 2260d74ecfd..a1220d099cc 100644 --- a/spring-core/src/test/java/org/springframework/core/codec/Netty5BufferDecoderTests.java +++ b/spring-core/src/test/java/org/springframework/core/codec/Netty5BufferDecoderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 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. @@ -47,7 +47,7 @@ class Netty5BufferDecoderTests extends AbstractDecoderTests @Override @Test - public void canDecode() { + protected void canDecode() { assertThat(this.decoder.canDecode(ResolvableType.forClass(Buffer.class), MimeTypeUtils.TEXT_PLAIN)).isTrue(); assertThat(this.decoder.canDecode(ResolvableType.forClass(Integer.class), @@ -58,7 +58,7 @@ class Netty5BufferDecoderTests extends AbstractDecoderTests @Override @Test - public void decode() { + protected void decode() { Flux input = Flux.concat( dataBuffer(this.fooBytes), dataBuffer(this.barBytes)); @@ -71,7 +71,7 @@ class Netty5BufferDecoderTests extends AbstractDecoderTests @Override @Test - public void decodeToMono() { + protected void decodeToMono() { Flux input = Flux.concat( dataBuffer(this.fooBytes), dataBuffer(this.barBytes)); diff --git a/spring-core/src/test/java/org/springframework/core/codec/NettyByteBufDecoderTests.java b/spring-core/src/test/java/org/springframework/core/codec/NettyByteBufDecoderTests.java index 7249fdcb750..83be79db615 100644 --- a/spring-core/src/test/java/org/springframework/core/codec/NettyByteBufDecoderTests.java +++ b/spring-core/src/test/java/org/springframework/core/codec/NettyByteBufDecoderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2024 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. @@ -47,7 +47,7 @@ class NettyByteBufDecoderTests extends AbstractDecoderTests @Override @Test - public void canDecode() { + protected void canDecode() { assertThat(this.decoder.canDecode(ResolvableType.forClass(ByteBuf.class), MimeTypeUtils.TEXT_PLAIN)).isTrue(); assertThat(this.decoder.canDecode(ResolvableType.forClass(Integer.class), @@ -58,7 +58,7 @@ class NettyByteBufDecoderTests extends AbstractDecoderTests @Override @Test - public void decode() { + protected void decode() { Flux input = Flux.concat( dataBuffer(this.fooBytes), dataBuffer(this.barBytes)); @@ -71,7 +71,7 @@ class NettyByteBufDecoderTests extends AbstractDecoderTests @Override @Test - public void decodeToMono() { + protected void decodeToMono() { Flux input = Flux.concat( dataBuffer(this.fooBytes), dataBuffer(this.barBytes)); diff --git a/spring-core/src/test/java/org/springframework/core/codec/NettyByteBufEncoderTests.java b/spring-core/src/test/java/org/springframework/core/codec/NettyByteBufEncoderTests.java index 0c6bff3792f..70bbd32a46f 100644 --- a/spring-core/src/test/java/org/springframework/core/codec/NettyByteBufEncoderTests.java +++ b/spring-core/src/test/java/org/springframework/core/codec/NettyByteBufEncoderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2024 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,7 +44,7 @@ class NettyByteBufEncoderTests extends AbstractEncoderTests @Override @Test - public void canEncode() { + protected void canEncode() { assertThat(this.encoder.canEncode(ResolvableType.forClass(ByteBuf.class), MimeTypeUtils.TEXT_PLAIN)).isTrue(); assertThat(this.encoder.canEncode(ResolvableType.forClass(Integer.class), @@ -58,7 +58,7 @@ class NettyByteBufEncoderTests extends AbstractEncoderTests @Override @Test - public void encode() { + protected void encode() { Flux input = Flux.just(this.fooBytes, this.barBytes).map(Unpooled::copiedBuffer); testEncodeAll(input, ByteBuf.class, step -> step diff --git a/spring-core/src/test/java/org/springframework/core/codec/ResourceDecoderTests.java b/spring-core/src/test/java/org/springframework/core/codec/ResourceDecoderTests.java index f060ce4f359..d66e0d8651b 100644 --- a/spring-core/src/test/java/org/springframework/core/codec/ResourceDecoderTests.java +++ b/spring-core/src/test/java/org/springframework/core/codec/ResourceDecoderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2024 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. @@ -51,7 +51,7 @@ class ResourceDecoderTests extends AbstractDecoderTests { @Override @Test - public void canDecode() { + protected void canDecode() { assertThat(this.decoder.canDecode(forClass(InputStreamResource.class), MimeTypeUtils.TEXT_PLAIN)).isTrue(); assertThat(this.decoder.canDecode(forClass(ByteArrayResource.class), MimeTypeUtils.TEXT_PLAIN)).isTrue(); assertThat(this.decoder.canDecode(forClass(Resource.class), MimeTypeUtils.TEXT_PLAIN)).isTrue(); @@ -62,7 +62,7 @@ class ResourceDecoderTests extends AbstractDecoderTests { @Override @Test - public void decode() { + protected void decode() { Flux input = Flux.concat(dataBuffer(this.fooBytes), dataBuffer(this.barBytes)); testDecodeAll(input, Resource.class, step -> step @@ -81,7 +81,7 @@ class ResourceDecoderTests extends AbstractDecoderTests { @Override @Test - public void decodeToMono() { + protected void decodeToMono() { Flux input = Flux.concat(dataBuffer(this.fooBytes), dataBuffer(this.barBytes)); testDecodeToMonoAll(input, ResolvableType.forClass(Resource.class), step -> step @@ -103,7 +103,7 @@ class ResourceDecoderTests extends AbstractDecoderTests { } @Test - public void decodeInputStreamResource() { + void decodeInputStreamResource() { Flux input = Flux.concat(dataBuffer(this.fooBytes), dataBuffer(this.barBytes)); testDecodeAll(input, InputStreamResource.class, step -> step .consumeNextWith(resource -> { diff --git a/spring-core/src/test/java/org/springframework/core/codec/ResourceEncoderTests.java b/spring-core/src/test/java/org/springframework/core/codec/ResourceEncoderTests.java index 1925415e734..957ec66214c 100644 --- a/spring-core/src/test/java/org/springframework/core/codec/ResourceEncoderTests.java +++ b/spring-core/src/test/java/org/springframework/core/codec/ResourceEncoderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 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. @@ -50,7 +50,7 @@ class ResourceEncoderTests extends AbstractEncoderTests { @Override @Test - public void canEncode() { + protected void canEncode() { assertThat(this.encoder.canEncode(ResolvableType.forClass(InputStreamResource.class), MimeTypeUtils.TEXT_PLAIN)).isTrue(); assertThat(this.encoder.canEncode(ResolvableType.forClass(ByteArrayResource.class), @@ -66,7 +66,7 @@ class ResourceEncoderTests extends AbstractEncoderTests { @Override @Test - public void encode() { + protected void encode() { Flux input = Flux.just(new ByteArrayResource(this.bytes)); testEncodeAll(input, Resource.class, step -> step diff --git a/spring-core/src/test/java/org/springframework/core/codec/StringDecoderTests.java b/spring-core/src/test/java/org/springframework/core/codec/StringDecoderTests.java index 1aeb8a7df74..60bcdd84d00 100644 --- a/spring-core/src/test/java/org/springframework/core/codec/StringDecoderTests.java +++ b/spring-core/src/test/java/org/springframework/core/codec/StringDecoderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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. @@ -58,7 +58,7 @@ class StringDecoderTests extends AbstractDecoderTests { @Override @Test - public void canDecode() { + protected void canDecode() { assertThat(this.decoder.canDecode(TYPE, MimeTypeUtils.TEXT_PLAIN)).isTrue(); assertThat(this.decoder.canDecode(TYPE, MimeTypeUtils.TEXT_HTML)).isTrue(); assertThat(this.decoder.canDecode(TYPE, MimeTypeUtils.APPLICATION_JSON)).isTrue(); @@ -69,7 +69,7 @@ class StringDecoderTests extends AbstractDecoderTests { @Override @Test - public void decode() { + protected void decode() { String u = "ü"; String e = "é"; String o = "ø"; @@ -238,7 +238,7 @@ class StringDecoderTests extends AbstractDecoderTests { @Override @Test - public void decodeToMono() { + protected void decodeToMono() { Flux input = Flux.just( stringBuffer("foo"), stringBuffer("bar"), diff --git a/spring-core/src/test/java/org/springframework/core/convert/support/CollectionToCollectionConverterTests.java b/spring-core/src/test/java/org/springframework/core/convert/support/CollectionToCollectionConverterTests.java index b7f3c31490d..55ea0f78220 100644 --- a/spring-core/src/test/java/org/springframework/core/convert/support/CollectionToCollectionConverterTests.java +++ b/spring-core/src/test/java/org/springframework/core/convert/support/CollectionToCollectionConverterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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. @@ -143,8 +143,8 @@ class CollectionToCollectionConverterTests { @SuppressWarnings("unchecked") void stringToCollection() throws Exception { List> list = new ArrayList<>(); - list.add(Arrays.asList("9,12")); - list.add(Arrays.asList("37,23")); + list.add(List.of("9,12")); + list.add(List.of("37,23")); conversionService.addConverterFactory(new StringToNumberConverterFactory()); conversionService.addConverter(new StringToCollectionConverter(conversionService)); conversionService.addConverter(new ObjectToCollectionConverter(conversionService)); diff --git a/spring-core/src/test/java/org/springframework/core/convert/support/MapToMapConverterTests.java b/spring-core/src/test/java/org/springframework/core/convert/support/MapToMapConverterTests.java index 6e3d7672907..cd4e748122e 100644 --- a/spring-core/src/test/java/org/springframework/core/convert/support/MapToMapConverterTests.java +++ b/spring-core/src/test/java/org/springframework/core/convert/support/MapToMapConverterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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. @@ -256,8 +256,8 @@ class MapToMapConverterTests { MultiValueMap converted = (MultiValueMap) conversionService.convert(source, targetType); assertThat(converted).hasSize(2); - assertThat(converted.get("a")).isEqualTo(Arrays.asList("1")); - assertThat(converted.get("b")).isEqualTo(Arrays.asList("2")); + assertThat(converted.get("a")).isEqualTo(List.of("1")); + assertThat(converted.get("b")).isEqualTo(List.of("2")); } @Test diff --git a/spring-core/src/test/java/org/springframework/core/convert/support/StreamConverterTests.java b/spring-core/src/test/java/org/springframework/core/convert/support/StreamConverterTests.java index 56ec69a2061..cf5ae5468e5 100644 --- a/spring-core/src/test/java/org/springframework/core/convert/support/StreamConverterTests.java +++ b/spring-core/src/test/java/org/springframework/core/convert/support/StreamConverterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 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. @@ -98,7 +98,6 @@ class StreamConverterTests { } @Test - @SuppressWarnings("resource") void convertFromListToStream() throws NoSuchFieldException { this.conversionService.addConverterFactory(new StringToNumberConverterFactory()); List list = Arrays.asList("1", "2", "3"); @@ -112,7 +111,6 @@ class StreamConverterTests { } @Test - @SuppressWarnings("resource") void convertFromArrayToStream() throws NoSuchFieldException { Integer[] array = new Integer[] {1, 0, 1}; this.conversionService.addConverter(Integer.class, Boolean.class, source -> source == 1); @@ -123,7 +121,6 @@ class StreamConverterTests { } @Test - @SuppressWarnings("resource") void convertFromListToRawStream() throws NoSuchFieldException { List list = Arrays.asList("1", "2", "3"); TypeDescriptor streamOfInteger = new TypeDescriptor(Types.class.getField("rawStream")); diff --git a/spring-core/src/test/java/org/springframework/core/env/CustomEnvironmentTests.java b/spring-core/src/test/java/org/springframework/core/env/CustomEnvironmentTests.java index b3294c30161..c408bce244a 100644 --- a/spring-core/src/test/java/org/springframework/core/env/CustomEnvironmentTests.java +++ b/spring-core/src/test/java/org/springframework/core/env/CustomEnvironmentTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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. @@ -75,7 +75,6 @@ class CustomEnvironmentTests { void withMultiCustomReservedDefaultProfile() { class CustomEnvironment extends AbstractEnvironment { @Override - @SuppressWarnings("serial") protected Set getReservedDefaultProfiles() { return Set.of("rd1", "rd2"); } diff --git a/spring-core/src/test/java/org/springframework/core/env/PropertySourceTests.java b/spring-core/src/test/java/org/springframework/core/env/PropertySourceTests.java index 57c56da4c24..b988d09f7c1 100644 --- a/spring-core/src/test/java/org/springframework/core/env/PropertySourceTests.java +++ b/spring-core/src/test/java/org/springframework/core/env/PropertySourceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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. @@ -48,21 +48,20 @@ class PropertySourceTests { MapPropertySource mps = new MapPropertySource("mps", map1); assertThat(mps).isEqualTo(mps); - assertThat(new MapPropertySource("x", map1).equals(new MapPropertySource("x", map1))).isTrue(); - assertThat(new MapPropertySource("x", map1).equals(new MapPropertySource("x", map2))).isTrue(); - assertThat(new MapPropertySource("x", map1).equals(new PropertiesPropertySource("x", props1))).isTrue(); - assertThat(new MapPropertySource("x", map1).equals(new PropertiesPropertySource("x", props2))).isTrue(); + assertThat(new MapPropertySource("x", map1)).isEqualTo(new MapPropertySource("x", map1)); + assertThat(new MapPropertySource("x", map1)).isEqualTo(new MapPropertySource("x", map2)); + assertThat(new MapPropertySource("x", map1)).isEqualTo(new PropertiesPropertySource("x", props1)); + assertThat(new MapPropertySource("x", map1)).isEqualTo(new PropertiesPropertySource("x", props2)); - assertThat(new MapPropertySource("x", map1).equals(new Object())).isFalse(); - assertThat(new MapPropertySource("x", map1).equals("x")).isFalse(); - assertThat(new MapPropertySource("x", map1).equals(new MapPropertySource("y", map1))).isFalse(); - assertThat(new MapPropertySource("x", map1).equals(new MapPropertySource("y", map2))).isFalse(); - assertThat(new MapPropertySource("x", map1).equals(new PropertiesPropertySource("y", props1))).isFalse(); - assertThat(new MapPropertySource("x", map1).equals(new PropertiesPropertySource("y", props2))).isFalse(); + assertThat(new MapPropertySource("x", map1)).isNotEqualTo(new Object()); + assertThat(new MapPropertySource("x", map1)).isNotEqualTo("x"); + assertThat(new MapPropertySource("x", map1)).isNotEqualTo(new MapPropertySource("y", map1)); + assertThat(new MapPropertySource("x", map1)).isNotEqualTo(new MapPropertySource("y", map2)); + assertThat(new MapPropertySource("x", map1)).isNotEqualTo(new PropertiesPropertySource("y", props1)); + assertThat(new MapPropertySource("x", map1)).isNotEqualTo(new PropertiesPropertySource("y", props2)); } @Test - @SuppressWarnings("serial") void collectionsOperations() { Map map1 = Map.of("a", "b"); Map map2 = Map.of("c", "d"); diff --git a/spring-core/src/test/java/org/springframework/core/env/StandardEnvironmentTests.java b/spring-core/src/test/java/org/springframework/core/env/StandardEnvironmentTests.java index 36c7915ac09..fc48fb013d3 100644 --- a/spring-core/src/test/java/org/springframework/core/env/StandardEnvironmentTests.java +++ b/spring-core/src/test/java/org/springframework/core/env/StandardEnvironmentTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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. @@ -454,26 +454,22 @@ class StandardEnvironmentTests { class MatchesProfilesTests { @Test - @SuppressWarnings("deprecation") void withEmptyArgumentList() { assertThatIllegalArgumentException().isThrownBy(environment::matchesProfiles); } @Test - @SuppressWarnings("deprecation") void withNullArgumentList() { assertThatIllegalArgumentException().isThrownBy(() -> environment.matchesProfiles((String[]) null)); } @Test - @SuppressWarnings("deprecation") void withNullArgument() { assertThatIllegalArgumentException().isThrownBy(() -> environment.matchesProfiles((String) null)); assertThatIllegalArgumentException().isThrownBy(() -> environment.matchesProfiles("p1", null)); } @Test - @SuppressWarnings("deprecation") void withEmptyArgument() { assertThatIllegalArgumentException().isThrownBy(() -> environment.matchesProfiles("")); assertThatIllegalArgumentException().isThrownBy(() -> environment.matchesProfiles("p1", "")); @@ -481,13 +477,11 @@ class StandardEnvironmentTests { } @Test - @SuppressWarnings("deprecation") void withInvalidNotOperator() { assertThatIllegalArgumentException().isThrownBy(() -> environment.matchesProfiles("p1", "!")); } @Test - @SuppressWarnings("deprecation") void withInvalidCompoundExpressionGrouping() { assertThatIllegalArgumentException().isThrownBy(() -> environment.matchesProfiles("p1 | p2 & p3")); assertThatIllegalArgumentException().isThrownBy(() -> environment.matchesProfiles("p1 & p2 | p3")); @@ -495,7 +489,6 @@ class StandardEnvironmentTests { } @Test - @SuppressWarnings("deprecation") void activeProfileSetProgrammatically() { assertThat(environment.matchesProfiles("p1", "p2")).isFalse(); @@ -510,7 +503,6 @@ class StandardEnvironmentTests { } @Test - @SuppressWarnings("deprecation") void activeProfileSetViaProperty() { assertThat(environment.matchesProfiles("p1")).isFalse(); @@ -519,7 +511,6 @@ class StandardEnvironmentTests { } @Test - @SuppressWarnings("deprecation") void defaultProfile() { assertThat(environment.matchesProfiles("pd")).isFalse(); @@ -532,7 +523,6 @@ class StandardEnvironmentTests { } @Test - @SuppressWarnings("deprecation") void withNotOperator() { assertThat(environment.matchesProfiles("p1")).isFalse(); assertThat(environment.matchesProfiles("!p1")).isTrue(); diff --git a/spring-core/src/test/java/org/springframework/core/io/buffer/DataBufferUtilsTests.java b/spring-core/src/test/java/org/springframework/core/io/buffer/DataBufferUtilsTests.java index d7cbcecbb83..9ea04e339c6 100644 --- a/spring-core/src/test/java/org/springframework/core/io/buffer/DataBufferUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/core/io/buffer/DataBufferUtilsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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. @@ -468,7 +468,6 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - @SuppressWarnings("unchecked") void writeAsynchronousFileChannelErrorInWrite(DataBufferFactory bufferFactory) throws Exception { super.bufferFactory = bufferFactory; diff --git a/spring-core/src/test/java/org/springframework/core/io/support/EncodedResourceTests.java b/spring-core/src/test/java/org/springframework/core/io/support/EncodedResourceTests.java index dc3e64399d1..f56b3d66e8d 100644 --- a/spring-core/src/test/java/org/springframework/core/io/support/EncodedResourceTests.java +++ b/spring-core/src/test/java/org/springframework/core/io/support/EncodedResourceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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. @@ -17,6 +17,7 @@ package org.springframework.core.io.support; import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import org.junit.jupiter.api.Test; @@ -35,8 +36,8 @@ class EncodedResourceTests { private static final String UTF8 = "UTF-8"; private static final String UTF16 = "UTF-16"; - private static final Charset UTF8_CS = Charset.forName(UTF8); - private static final Charset UTF16_CS = Charset.forName(UTF16); + private static final Charset UTF8_CS = StandardCharsets.UTF_8; + private static final Charset UTF16_CS = StandardCharsets.UTF_16; private final Resource resource = new DescriptiveResource("test"); diff --git a/spring-core/src/test/java/org/springframework/core/type/AbstractAnnotationMetadataTests.java b/spring-core/src/test/java/org/springframework/core/type/AbstractAnnotationMetadataTests.java index 98e238fbc6f..cc966f17995 100644 --- a/spring-core/src/test/java/org/springframework/core/type/AbstractAnnotationMetadataTests.java +++ b/spring-core/src/test/java/org/springframework/core/type/AbstractAnnotationMetadataTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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. @@ -38,7 +38,7 @@ import static org.assertj.core.api.Assertions.entry; public abstract class AbstractAnnotationMetadataTests { @Test - public void verifyEquals() { + void verifyEquals() { AnnotationMetadata testClass1 = get(TestClass.class); AnnotationMetadata testClass2 = get(TestClass.class); AnnotationMetadata testMemberClass1 = get(TestMemberClass.class); @@ -61,7 +61,7 @@ public abstract class AbstractAnnotationMetadataTests { } @Test - public void verifyHashCode() { + void verifyHashCode() { AnnotationMetadata testClass1 = get(TestClass.class); AnnotationMetadata testClass2 = get(TestClass.class); AnnotationMetadata testMemberClass1 = get(TestMemberClass.class); @@ -74,106 +74,106 @@ public abstract class AbstractAnnotationMetadataTests { } @Test - public void verifyToString() { + void verifyToString() { assertThat(get(TestClass.class).toString()).isEqualTo(TestClass.class.getName()); } @Test - public void getClassNameReturnsClassName() { + void getClassNameReturnsClassName() { assertThat(get(TestClass.class).getClassName()).isEqualTo(TestClass.class.getName()); } @Test - public void isInterfaceWhenInterfaceReturnsTrue() { + void isInterfaceWhenInterfaceReturnsTrue() { assertThat(get(TestInterface.class).isInterface()).isTrue(); assertThat(get(TestAnnotation.class).isInterface()).isTrue(); } @Test - public void isInterfaceWhenNotInterfaceReturnsFalse() { + void isInterfaceWhenNotInterfaceReturnsFalse() { assertThat(get(TestClass.class).isInterface()).isFalse(); } @Test - public void isAnnotationWhenAnnotationReturnsTrue() { + void isAnnotationWhenAnnotationReturnsTrue() { assertThat(get(TestAnnotation.class).isAnnotation()).isTrue(); } @Test - public void isAnnotationWhenNotAnnotationReturnsFalse() { + void isAnnotationWhenNotAnnotationReturnsFalse() { assertThat(get(TestClass.class).isAnnotation()).isFalse(); assertThat(get(TestInterface.class).isAnnotation()).isFalse(); } @Test - public void isFinalWhenFinalReturnsTrue() { + void isFinalWhenFinalReturnsTrue() { assertThat(get(TestFinalClass.class).isFinal()).isTrue(); } @Test - public void isFinalWhenNonFinalReturnsFalse() { + void isFinalWhenNonFinalReturnsFalse() { assertThat(get(TestClass.class).isFinal()).isFalse(); } @Test - public void isIndependentWhenIndependentReturnsTrue() { + void isIndependentWhenIndependentReturnsTrue() { assertThat(get(AbstractAnnotationMetadataTests.class).isIndependent()).isTrue(); assertThat(get(TestClass.class).isIndependent()).isTrue(); } @Test - public void isIndependentWhenNotIndependentReturnsFalse() { + void isIndependentWhenNotIndependentReturnsFalse() { assertThat(get(TestNonStaticInnerClass.class).isIndependent()).isFalse(); } @Test - public void getEnclosingClassNameWhenHasEnclosingClassReturnsEnclosingClass() { + void getEnclosingClassNameWhenHasEnclosingClassReturnsEnclosingClass() { assertThat(get(TestClass.class).getEnclosingClassName()).isEqualTo( AbstractAnnotationMetadataTests.class.getName()); } @Test - public void getEnclosingClassNameWhenHasNoEnclosingClassReturnsNull() { + void getEnclosingClassNameWhenHasNoEnclosingClassReturnsNull() { assertThat(get(AbstractAnnotationMetadataTests.class).getEnclosingClassName()).isNull(); } @Test - public void getSuperClassNameWhenHasSuperClassReturnsName() { + void getSuperClassNameWhenHasSuperClassReturnsName() { assertThat(get(TestSubclass.class).getSuperClassName()).isEqualTo(TestClass.class.getName()); assertThat(get(TestClass.class).getSuperClassName()).isEqualTo(Object.class.getName()); } @Test - public void getSuperClassNameWhenHasNoSuperClassReturnsNull() { + void getSuperClassNameWhenHasNoSuperClassReturnsNull() { assertThat(get(Object.class).getSuperClassName()).isNull(); assertThat(get(TestInterface.class).getSuperClassName()).isNull(); assertThat(get(TestSubInterface.class).getSuperClassName()).isNull(); } @Test - public void getInterfaceNamesWhenHasInterfacesReturnsNames() { + void getInterfaceNamesWhenHasInterfacesReturnsNames() { assertThat(get(TestSubclass.class).getInterfaceNames()).containsExactlyInAnyOrder(TestInterface.class.getName()); assertThat(get(TestSubInterface.class).getInterfaceNames()).containsExactlyInAnyOrder(TestInterface.class.getName()); } @Test - public void getInterfaceNamesWhenHasNoInterfacesReturnsEmptyArray() { + void getInterfaceNamesWhenHasNoInterfacesReturnsEmptyArray() { assertThat(get(TestClass.class).getInterfaceNames()).isEmpty(); } @Test - public void getMemberClassNamesWhenHasMemberClassesReturnsNames() { + void getMemberClassNamesWhenHasMemberClassesReturnsNames() { assertThat(get(TestMemberClass.class).getMemberClassNames()).containsExactlyInAnyOrder( TestMemberClassInnerClass.class.getName(), TestMemberClassInnerInterface.class.getName()); } @Test - public void getMemberClassNamesWhenHasNoMemberClassesReturnsEmptyArray() { + void getMemberClassNamesWhenHasNoMemberClassesReturnsEmptyArray() { assertThat(get(TestClass.class).getMemberClassNames()).isEmpty(); } @Test - public void getAnnotationsReturnsDirectAnnotations() { + void getAnnotationsReturnsDirectAnnotations() { assertThat(get(WithDirectAnnotations.class).getAnnotations().stream()) .filteredOn(MergedAnnotation::isDirectlyPresent) .extracting(a -> a.getType().getName()) @@ -181,28 +181,28 @@ public abstract class AbstractAnnotationMetadataTests { } @Test - public void isAnnotatedWhenMatchesDirectAnnotationReturnsTrue() { + void isAnnotatedWhenMatchesDirectAnnotationReturnsTrue() { assertThat(get(WithDirectAnnotations.class).isAnnotated(DirectAnnotation1.class.getName())).isTrue(); } @Test - public void isAnnotatedWhenMatchesMetaAnnotationReturnsTrue() { + void isAnnotatedWhenMatchesMetaAnnotationReturnsTrue() { assertThat(get(WithMetaAnnotations.class).isAnnotated(MetaAnnotation2.class.getName())).isTrue(); } @Test - public void isAnnotatedWhenDoesNotMatchDirectOrMetaAnnotationReturnsFalse() { + void isAnnotatedWhenDoesNotMatchDirectOrMetaAnnotationReturnsFalse() { assertThat(get(TestClass.class).isAnnotated(DirectAnnotation1.class.getName())).isFalse(); } @Test - public void getAnnotationAttributesReturnsAttributes() { + void getAnnotationAttributesReturnsAttributes() { assertThat(get(WithAnnotationAttributes.class).getAnnotationAttributes(AnnotationAttributes.class.getName())) .containsOnly(entry("name", "test"), entry("size", 1)); } @Test - public void getAllAnnotationAttributesReturnsAllAttributes() { + void getAllAnnotationAttributesReturnsAllAttributes() { MultiValueMap attributes = get(WithMetaAnnotationAttributes.class).getAllAnnotationAttributes(AnnotationAttributes.class.getName()); assertThat(attributes).containsOnlyKeys("name", "size"); @@ -211,69 +211,69 @@ public abstract class AbstractAnnotationMetadataTests { } @Test - public void getAnnotationTypesReturnsDirectAnnotations() { + void getAnnotationTypesReturnsDirectAnnotations() { AnnotationMetadata metadata = get(WithDirectAnnotations.class); assertThat(metadata.getAnnotationTypes()).containsExactlyInAnyOrder( DirectAnnotation1.class.getName(), DirectAnnotation2.class.getName()); } @Test - public void getMetaAnnotationTypesReturnsMetaAnnotations() { + void getMetaAnnotationTypesReturnsMetaAnnotations() { AnnotationMetadata metadata = get(WithMetaAnnotations.class); assertThat(metadata.getMetaAnnotationTypes(MetaAnnotationRoot.class.getName())) .containsExactlyInAnyOrder(MetaAnnotation1.class.getName(), MetaAnnotation2.class.getName()); } @Test - public void hasAnnotationWhenMatchesDirectAnnotationReturnsTrue() { + void hasAnnotationWhenMatchesDirectAnnotationReturnsTrue() { assertThat(get(WithDirectAnnotations.class).hasAnnotation(DirectAnnotation1.class.getName())).isTrue(); } @Test - public void hasAnnotationWhenMatchesMetaAnnotationReturnsFalse() { + void hasAnnotationWhenMatchesMetaAnnotationReturnsFalse() { assertThat(get(WithMetaAnnotations.class).hasAnnotation(MetaAnnotation1.class.getName())).isFalse(); assertThat(get(WithMetaAnnotations.class).hasAnnotation(MetaAnnotation2.class.getName())).isFalse(); } @Test - public void hasAnnotationWhenDoesNotMatchDirectOrMetaAnnotationReturnsFalse() { + void hasAnnotationWhenDoesNotMatchDirectOrMetaAnnotationReturnsFalse() { assertThat(get(TestClass.class).hasAnnotation(DirectAnnotation1.class.getName())).isFalse(); } @Test - public void hasMetaAnnotationWhenMatchesDirectReturnsFalse() { + void hasMetaAnnotationWhenMatchesDirectReturnsFalse() { assertThat(get(WithDirectAnnotations.class).hasMetaAnnotation(DirectAnnotation1.class.getName())).isFalse(); } @Test - public void hasMetaAnnotationWhenMatchesMetaAnnotationReturnsTrue() { + void hasMetaAnnotationWhenMatchesMetaAnnotationReturnsTrue() { assertThat(get(WithMetaAnnotations.class).hasMetaAnnotation(MetaAnnotation1.class.getName())).isTrue(); assertThat(get(WithMetaAnnotations.class).hasMetaAnnotation(MetaAnnotation2.class.getName())).isTrue(); } @Test - public void hasMetaAnnotationWhenDoesNotMatchDirectOrMetaAnnotationReturnsFalse() { + void hasMetaAnnotationWhenDoesNotMatchDirectOrMetaAnnotationReturnsFalse() { assertThat(get(TestClass.class).hasMetaAnnotation(MetaAnnotation1.class.getName())).isFalse(); } @Test - public void hasAnnotatedMethodsWhenMatchesDirectAnnotationReturnsTrue() { + void hasAnnotatedMethodsWhenMatchesDirectAnnotationReturnsTrue() { assertThat(get(WithAnnotatedMethod.class).hasAnnotatedMethods(DirectAnnotation1.class.getName())).isTrue(); } @Test - public void hasAnnotatedMethodsWhenMatchesMetaAnnotationReturnsTrue() { + void hasAnnotatedMethodsWhenMatchesMetaAnnotationReturnsTrue() { assertThat(get(WithMetaAnnotatedMethod.class).hasAnnotatedMethods(MetaAnnotation2.class.getName())).isTrue(); } @Test - public void hasAnnotatedMethodsWhenDoesNotMatchAnyAnnotationReturnsFalse() { + void hasAnnotatedMethodsWhenDoesNotMatchAnyAnnotationReturnsFalse() { assertThat(get(WithAnnotatedMethod.class).hasAnnotatedMethods(MetaAnnotation2.class.getName())).isFalse(); assertThat(get(WithNonAnnotatedMethod.class).hasAnnotatedMethods(DirectAnnotation1.class.getName())).isFalse(); } @Test - public void getAnnotatedMethodsReturnsMatchingAnnotatedAndMetaAnnotatedMethods() { + void getAnnotatedMethodsReturnsMatchingAnnotatedAndMetaAnnotatedMethods() { assertThat(get(WithDirectAndMetaAnnotatedMethods.class).getAnnotatedMethods(MetaAnnotation2.class.getName())) .extracting(MethodMetadata::getMethodName) .containsExactlyInAnyOrder("direct", "meta"); diff --git a/spring-core/src/test/java/org/springframework/core/type/AbstractMethodMetadataTests.java b/spring-core/src/test/java/org/springframework/core/type/AbstractMethodMetadataTests.java index c0bd0c2b94a..91ced1dc180 100644 --- a/spring-core/src/test/java/org/springframework/core/type/AbstractMethodMetadataTests.java +++ b/spring-core/src/test/java/org/springframework/core/type/AbstractMethodMetadataTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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. @@ -38,7 +38,7 @@ import static org.assertj.core.api.Assertions.entry; public abstract class AbstractMethodMetadataTests { @Test - public void verifyEquals() { + void verifyEquals() { MethodMetadata withMethod1 = getTagged(WithMethod.class); MethodMetadata withMethod2 = getTagged(WithMethod.class); MethodMetadata withMethodWithTwoArguments1 = getTagged(WithMethodWithTwoArguments.class); @@ -61,7 +61,7 @@ public abstract class AbstractMethodMetadataTests { } @Test - public void verifyHashCode() { + void verifyHashCode() { MethodMetadata withMethod1 = getTagged(WithMethod.class); MethodMetadata withMethod2 = getTagged(WithMethod.class); MethodMetadata withMethodWithTwoArguments1 = getTagged(WithMethodWithTwoArguments.class); @@ -74,7 +74,7 @@ public abstract class AbstractMethodMetadataTests { } @Test - public void verifyToString() { + void verifyToString() { assertThat(getTagged(WithMethod.class).toString()) .endsWith(WithMethod.class.getName() + ".test()"); @@ -86,66 +86,66 @@ public abstract class AbstractMethodMetadataTests { } @Test - public void getMethodNameReturnsMethodName() { + void getMethodNameReturnsMethodName() { assertThat(getTagged(WithMethod.class).getMethodName()).isEqualTo("test"); } @Test - public void getDeclaringClassReturnsDeclaringClass() { + void getDeclaringClassReturnsDeclaringClass() { assertThat(getTagged(WithMethod.class).getDeclaringClassName()).isEqualTo( WithMethod.class.getName()); } @Test - public void getReturnTypeReturnsReturnType() { + void getReturnTypeReturnsReturnType() { assertThat(getTagged(WithMethod.class).getReturnTypeName()).isEqualTo( String.class.getName()); } @Test - public void isAbstractWhenAbstractReturnsTrue() { + void isAbstractWhenAbstractReturnsTrue() { assertThat(getTagged(WithAbstractMethod.class).isAbstract()).isTrue(); } @Test - public void isAbstractWhenNotAbstractReturnsFalse() { + void isAbstractWhenNotAbstractReturnsFalse() { assertThat(getTagged(WithMethod.class).isAbstract()).isFalse(); } @Test - public void isStatusWhenStaticReturnsTrue() { + void isStatusWhenStaticReturnsTrue() { assertThat(getTagged(WithStaticMethod.class).isStatic()).isTrue(); } @Test - public void isStaticWhenNotStaticReturnsFalse() { + void isStaticWhenNotStaticReturnsFalse() { assertThat(getTagged(WithMethod.class).isStatic()).isFalse(); } @Test - public void isFinalWhenFinalReturnsTrue() { + void isFinalWhenFinalReturnsTrue() { assertThat(getTagged(WithFinalMethod.class).isFinal()).isTrue(); } @Test - public void isFinalWhenNonFinalReturnsFalse() { + void isFinalWhenNonFinalReturnsFalse() { assertThat(getTagged(WithMethod.class).isFinal()).isFalse(); } @Test - public void isOverridableWhenOverridableReturnsTrue() { + void isOverridableWhenOverridableReturnsTrue() { assertThat(getTagged(WithMethod.class).isOverridable()).isTrue(); } @Test - public void isOverridableWhenNonOverridableReturnsFalse() { + void isOverridableWhenNonOverridableReturnsFalse() { assertThat(getTagged(WithStaticMethod.class).isOverridable()).isFalse(); assertThat(getTagged(WithFinalMethod.class).isOverridable()).isFalse(); assertThat(getTagged(WithPrivateMethod.class).isOverridable()).isFalse(); } @Test - public void getAnnotationsReturnsDirectAnnotations() { + void getAnnotationsReturnsDirectAnnotations() { MethodMetadata metadata = getTagged(WithDirectAnnotation.class); assertThat(metadata.getAnnotations().stream().filter( MergedAnnotation::isDirectlyPresent).map( @@ -155,32 +155,32 @@ public abstract class AbstractMethodMetadataTests { } @Test - public void isAnnotatedWhenMatchesDirectAnnotationReturnsTrue() { + void isAnnotatedWhenMatchesDirectAnnotationReturnsTrue() { assertThat(getTagged(WithDirectAnnotation.class).isAnnotated( DirectAnnotation.class.getName())).isTrue(); } @Test - public void isAnnotatedWhenMatchesMetaAnnotationReturnsTrue() { + void isAnnotatedWhenMatchesMetaAnnotationReturnsTrue() { assertThat(getTagged(WithMetaAnnotation.class).isAnnotated( DirectAnnotation.class.getName())).isTrue(); } @Test - public void isAnnotatedWhenDoesNotMatchDirectOrMetaAnnotationReturnsFalse() { + void isAnnotatedWhenDoesNotMatchDirectOrMetaAnnotationReturnsFalse() { assertThat(getTagged(WithMethod.class).isAnnotated( DirectAnnotation.class.getName())).isFalse(); } @Test - public void getAnnotationAttributesReturnsAttributes() { + void getAnnotationAttributesReturnsAttributes() { assertThat(getTagged(WithAnnotationAttributes.class).getAnnotationAttributes( AnnotationAttributes.class.getName())).containsOnly(entry("name", "test"), entry("size", 1)); } @Test - public void getAllAnnotationAttributesReturnsAllAttributes() { + void getAllAnnotationAttributesReturnsAllAttributes() { MultiValueMap attributes = getTagged(WithMetaAnnotationAttributes.class) .getAllAnnotationAttributes(AnnotationAttributes.class.getName()); assertThat(attributes).containsOnlyKeys("name", "size"); diff --git a/spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java b/spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java index 5d93cb8de26..497217db8c3 100644 --- a/spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java +++ b/spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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. @@ -425,7 +425,7 @@ class AnnotationMetadataTests { List allMeta = method.getAllAnnotationAttributes(DirectAnnotation.class.getName()).get("value"); assertThat(new HashSet<>(allMeta)).isEqualTo(new HashSet(Arrays.asList("direct", "meta"))); allMeta = method.getAllAnnotationAttributes(DirectAnnotation.class.getName()).get("additional"); - assertThat(new HashSet<>(allMeta)).isEqualTo(new HashSet(Arrays.asList("direct"))); + assertThat(new HashSet<>(allMeta)).isEqualTo(new HashSet(List.of("direct"))); assertThat(metadata.isAnnotated(IsAnnotatedAnnotation.class.getName())).isTrue(); diff --git a/spring-core/src/test/java/org/springframework/util/ClassUtilsTests.java b/spring-core/src/test/java/org/springframework/util/ClassUtilsTests.java index 4a445b04cf0..a538ddc676f 100644 --- a/spring-core/src/test/java/org/springframework/util/ClassUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/util/ClassUtilsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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. @@ -450,6 +450,7 @@ class ClassUtilsTests { } @Test + @SuppressWarnings("Convert2Lambda") void isNotLambda() { assertIsNotLambda(new EnigmaSupplier()); diff --git a/spring-core/src/test/java/org/springframework/util/CompositeIteratorTests.java b/spring-core/src/test/java/org/springframework/util/CompositeIteratorTests.java index 737e062c5e2..d6f19d0a49e 100644 --- a/spring-core/src/test/java/org/springframework/util/CompositeIteratorTests.java +++ b/spring-core/src/test/java/org/springframework/util/CompositeIteratorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 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. @@ -61,7 +61,7 @@ class CompositeIteratorTests { void multipleIterators() { CompositeIterator it = new CompositeIterator<>(); it.add(Arrays.asList("0", "1").iterator()); - it.add(Arrays.asList("2").iterator()); + it.add(List.of("2").iterator()); it.add(Arrays.asList("3", "4").iterator()); for (int i = 0; i < 5; i++) { assertThat(it.hasNext()).isTrue(); diff --git a/spring-core/src/test/java/org/springframework/util/DigestUtilsTests.java b/spring-core/src/test/java/org/springframework/util/DigestUtilsTests.java index 2ba9c672401..bad71408ac0 100644 --- a/spring-core/src/test/java/org/springframework/util/DigestUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/util/DigestUtilsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 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. @@ -19,6 +19,7 @@ package org.springframework.util; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.UnsupportedEncodingException; +import java.nio.charset.StandardCharsets; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -36,7 +37,7 @@ class DigestUtilsTests { @BeforeEach void createBytes() throws UnsupportedEncodingException { - bytes = "Hello World".getBytes("UTF-8"); + bytes = "Hello World".getBytes(StandardCharsets.UTF_8); } diff --git a/spring-core/src/test/java/org/springframework/util/ExceptionTypeFilterTests.java b/spring-core/src/test/java/org/springframework/util/ExceptionTypeFilterTests.java index b4d4d414ef1..2b7a4deb15f 100644 --- a/spring-core/src/test/java/org/springframework/util/ExceptionTypeFilterTests.java +++ b/spring-core/src/test/java/org/springframework/util/ExceptionTypeFilterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 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. @@ -16,9 +16,10 @@ package org.springframework.util; +import java.util.List; + import org.junit.jupiter.api.Test; -import static java.util.Arrays.asList; import static org.assertj.core.api.Assertions.assertThat; /** @@ -28,7 +29,7 @@ class ExceptionTypeFilterTests { @Test void subClassMatch() { - ExceptionTypeFilter filter = new ExceptionTypeFilter(asList(RuntimeException.class), null, true); + ExceptionTypeFilter filter = new ExceptionTypeFilter(List.of(RuntimeException.class), null, true); assertThat(filter.match(RuntimeException.class)).isTrue(); assertThat(filter.match(IllegalStateException.class)).isTrue(); } diff --git a/spring-core/src/test/java/org/springframework/util/InstanceFilterTests.java b/spring-core/src/test/java/org/springframework/util/InstanceFilterTests.java index 8e761b36935..9c2bf39b4cd 100644 --- a/spring-core/src/test/java/org/springframework/util/InstanceFilterTests.java +++ b/spring-core/src/test/java/org/springframework/util/InstanceFilterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 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. @@ -16,6 +16,8 @@ package org.springframework.util; +import java.util.List; + import org.junit.jupiter.api.Test; import static java.util.Arrays.asList; @@ -60,7 +62,7 @@ class InstanceFilterTests { @Test void includesAndExcludesFiltersConflict() { InstanceFilter filter = new InstanceFilter<>( - asList("First"), asList("First"), true); + List.of("First"), List.of("First"), true); doNotMatch(filter, "First"); } diff --git a/spring-core/src/test/java/org/springframework/util/PropertiesPersisterTests.java b/spring-core/src/test/java/org/springframework/util/PropertiesPersisterTests.java index 0368c892a6d..7146a491108 100644 --- a/spring-core/src/test/java/org/springframework/util/PropertiesPersisterTests.java +++ b/spring-core/src/test/java/org/springframework/util/PropertiesPersisterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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. @@ -113,7 +113,7 @@ class PropertiesPersisterTests { private String storeProperties(Properties props, String header, boolean useWriter) throws IOException { DefaultPropertiesPersister persister = new DefaultPropertiesPersister(); - String propCopy = null; + String propCopy; if (useWriter) { StringWriter propWriter = new StringWriter(); persister.store(props, propWriter, header); diff --git a/spring-core/src/test/java/org/springframework/util/ResizableByteArrayOutputStreamTests.java b/spring-core/src/test/java/org/springframework/util/ResizableByteArrayOutputStreamTests.java index 8646aba648c..047edd7aa28 100644 --- a/spring-core/src/test/java/org/springframework/util/ResizableByteArrayOutputStreamTests.java +++ b/spring-core/src/test/java/org/springframework/util/ResizableByteArrayOutputStreamTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 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. @@ -16,6 +16,8 @@ package org.springframework.util; +import java.nio.charset.StandardCharsets; + import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -38,7 +40,7 @@ class ResizableByteArrayOutputStreamTests { @BeforeEach void setUp() throws Exception { this.baos = new ResizableByteArrayOutputStream(INITIAL_CAPACITY); - this.helloBytes = "Hello World".getBytes("UTF-8"); + this.helloBytes = "Hello World".getBytes(StandardCharsets.UTF_8); } diff --git a/spring-core/src/test/java/org/springframework/util/SerializationUtilsTests.java b/spring-core/src/test/java/org/springframework/util/SerializationUtilsTests.java index 12db0b1476a..b921d95e237 100644 --- a/spring-core/src/test/java/org/springframework/util/SerializationUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/util/SerializationUtilsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 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. @@ -47,7 +47,6 @@ class SerializationUtilsTests { } @Test - @SuppressWarnings("deprecation") void serializeNonSerializableRecord() { record Person(String firstName, String lastName) {} Person jane = new Person("Jane", "Doe"); diff --git a/spring-core/src/test/java/org/springframework/util/UnmodifiableMultiValueMapTests.java b/spring-core/src/test/java/org/springframework/util/UnmodifiableMultiValueMapTests.java index cc294e12469..12751088a90 100644 --- a/spring-core/src/test/java/org/springframework/util/UnmodifiableMultiValueMapTests.java +++ b/spring-core/src/test/java/org/springframework/util/UnmodifiableMultiValueMapTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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. @@ -41,7 +41,6 @@ import static org.mockito.Mockito.mock; class UnmodifiableMultiValueMapTests { @Test - @SuppressWarnings("unchecked") void delegation() { MultiValueMap mock = mock(); UnmodifiableMultiValueMap map = new UnmodifiableMultiValueMap<>(mock); diff --git a/spring-core/src/test/java/org/springframework/util/comparator/ComparableComparatorTests.java b/spring-core/src/test/java/org/springframework/util/comparator/ComparableComparatorTests.java index 4fc4a1c9795..b6becdc0fe3 100644 --- a/spring-core/src/test/java/org/springframework/util/comparator/ComparableComparatorTests.java +++ b/spring-core/src/test/java/org/springframework/util/comparator/ComparableComparatorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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. @@ -30,6 +30,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; * @author Chris Beams * @author Phillip Webb */ +@Deprecated class ComparableComparatorTests { @Test diff --git a/spring-core/src/test/java/org/springframework/util/comparator/NullSafeComparatorTests.java b/spring-core/src/test/java/org/springframework/util/comparator/NullSafeComparatorTests.java index 8b8f45a2cca..bb16188e5d1 100644 --- a/spring-core/src/test/java/org/springframework/util/comparator/NullSafeComparatorTests.java +++ b/spring-core/src/test/java/org/springframework/util/comparator/NullSafeComparatorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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. @@ -29,6 +29,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Chris Beams * @author Phillip Webb */ +@Deprecated class NullSafeComparatorTests { @Test diff --git a/spring-core/src/test/java/org/springframework/util/concurrent/FutureAdapterTests.java b/spring-core/src/test/java/org/springframework/util/concurrent/FutureAdapterTests.java index e3e8bbc18bd..e0e68859362 100644 --- a/spring-core/src/test/java/org/springframework/util/concurrent/FutureAdapterTests.java +++ b/spring-core/src/test/java/org/springframework/util/concurrent/FutureAdapterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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. @@ -31,7 +31,6 @@ import static org.mockito.Mockito.mock; @SuppressWarnings("deprecation") class FutureAdapterTests { - @SuppressWarnings("unchecked") private Future adaptee = mock(); private FutureAdapter adapter = new FutureAdapter<>(adaptee) { diff --git a/spring-core/src/test/java/org/springframework/util/concurrent/ListenableFutureTaskTests.java b/spring-core/src/test/java/org/springframework/util/concurrent/ListenableFutureTaskTests.java index db2f95e5723..01e08bc6ac4 100644 --- a/spring-core/src/test/java/org/springframework/util/concurrent/ListenableFutureTaskTests.java +++ b/spring-core/src/test/java/org/springframework/util/concurrent/ListenableFutureTaskTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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. @@ -33,7 +33,7 @@ import static org.mockito.Mockito.verifyNoInteractions; * @author Arjen Poutsma * @author Sebastien Deleuze */ -@SuppressWarnings({ "unchecked", "deprecation" }) +@SuppressWarnings({ "deprecation" }) class ListenableFutureTaskTests { @Test diff --git a/spring-core/src/test/java/org/springframework/util/xml/AbstractStaxXMLReaderTests.java b/spring-core/src/test/java/org/springframework/util/xml/AbstractStaxXMLReaderTests.java index a76d1f47de6..7f51d8af088 100644 --- a/spring-core/src/test/java/org/springframework/util/xml/AbstractStaxXMLReaderTests.java +++ b/spring-core/src/test/java/org/springframework/util/xml/AbstractStaxXMLReaderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 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. @@ -18,6 +18,7 @@ package org.springframework.util.xml; import java.io.ByteArrayInputStream; import java.io.InputStream; +import java.nio.charset.StandardCharsets; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; @@ -133,7 +134,7 @@ abstract class AbstractStaxXMLReaderTests { Transformer transformer = TransformerFactory.newInstance().newTransformer(); AbstractStaxXMLReader staxXmlReader = createStaxXmlReader( - new ByteArrayInputStream(xml.getBytes("UTF-8"))); + new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8))); SAXSource source = new SAXSource(staxXmlReader, new InputSource()); DOMResult result = new DOMResult(); diff --git a/spring-core/src/testFixtures/java/org/springframework/core/testfixture/codec/AbstractDecoderTests.java b/spring-core/src/testFixtures/java/org/springframework/core/testfixture/codec/AbstractDecoderTests.java index 97454ed162d..96145794290 100644 --- a/spring-core/src/testFixtures/java/org/springframework/core/testfixture/codec/AbstractDecoderTests.java +++ b/spring-core/src/testFixtures/java/org/springframework/core/testfixture/codec/AbstractDecoderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 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. @@ -67,21 +67,21 @@ public abstract class AbstractDecoderTests> extends Abstrac * Subclasses should implement this method to test {@link Decoder#canDecode}. */ @Test - public abstract void canDecode() throws Exception; + protected abstract void canDecode() throws Exception; /** * Subclasses should implement this method to test {@link Decoder#decode}, possibly using * {@link #testDecodeAll} or other helper methods. */ @Test - public abstract void decode() throws Exception; + protected abstract void decode() throws Exception; /** * Subclasses should implement this method to test {@link Decoder#decodeToMono}, possibly using * {@link #testDecodeToMonoAll}. */ @Test - public abstract void decodeToMono() throws Exception; + protected abstract void decodeToMono() throws Exception; // Flux diff --git a/spring-core/src/testFixtures/java/org/springframework/core/testfixture/codec/AbstractEncoderTests.java b/spring-core/src/testFixtures/java/org/springframework/core/testfixture/codec/AbstractEncoderTests.java index 2b609c9d097..8cab9edd3e2 100644 --- a/spring-core/src/testFixtures/java/org/springframework/core/testfixture/codec/AbstractEncoderTests.java +++ b/spring-core/src/testFixtures/java/org/springframework/core/testfixture/codec/AbstractEncoderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 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. @@ -67,14 +67,14 @@ public abstract class AbstractEncoderTests> extends Abstrac * Subclasses should implement this method to test {@link Encoder#canEncode}. */ @Test - public abstract void canEncode() throws Exception; + protected abstract void canEncode() throws Exception; /** * Subclasses should implement this method to test {@link Encoder#encode}, possibly using * {@link #testEncodeAll} or other helper methods. */ @Test - public abstract void encode() throws Exception; + protected abstract void encode() throws Exception; /**