From 22bf4df290a2f44f0ca9550e7331c17f77125d8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Nicoll?= Date: Sat, 16 Dec 2023 10:25:18 +0100 Subject: [PATCH] Polish --- .../BindingReflectionHintsRegistrarTests.java | 6 +- ...terReflectionForBindingProcessorTests.java | 4 +- .../core/BridgeMethodResolverTests.java | 12 +-- .../core/CollectionFactoryTests.java | 2 +- .../springframework/core/ConstantsTests.java | 10 +- .../core/ExceptionDepthComparatorTests.java | 20 ++-- .../core/ResolvableTypeTests.java | 100 +++++++++--------- .../AnnotatedElementUtilsTests.java | 8 +- .../annotation/AnnotationAttributesTests.java | 10 +- .../core/annotation/AnnotationUtilsTests.java | 38 +++---- ...ComposedOnSingleAnnotatedElementTests.java | 4 +- .../annotation/MergedAnnotationsTests.java | 75 ++++++------- ...otationsOnSingleAnnotatedElementTests.java | 4 +- .../core/codec/CharSequenceEncoderTests.java | 2 +- .../core/codec/DataBufferDecoderTests.java | 4 +- .../core/codec/DataBufferEncoderTests.java | 4 +- .../core/convert/TypeDescriptorTests.java | 8 +- .../converter/ConvertingComparatorTests.java | 14 +-- .../CollectionToCollectionConverterTests.java | 21 ++-- .../GenericConversionServiceTests.java | 2 +- .../support/MapToMapConverterTests.java | 10 +- .../core/io/PathResourceTests.java | 12 +-- .../core/io/ResourceTests.java | 4 +- .../core/io/buffer/DataBufferTests.java | 3 +- .../core/io/buffer/DataBufferUtilsTests.java | 10 +- .../support/PropertySourceProcessorTests.java | 2 +- .../core/style/SimpleValueStylerTests.java | 4 +- .../core/testfixture/TestGroupTests.java | 10 +- .../type/AbstractAnnotationMetadataTests.java | 6 +- .../type/AbstractMethodMetadataTests.java | 6 +- .../core/type/AnnotationMetadataTests.java | 4 +- .../util/AntPathMatcherTests.java | 6 +- .../util/AutoPopulatingListTests.java | 10 +- .../util/CollectionUtilsTests.java | 12 +-- .../util/FileSystemUtilsTests.java | 2 +- .../util/MethodInvokerTests.java | 2 +- .../util/NumberUtilsTests.java | 6 +- .../util/ReflectionUtilsTests.java | 4 +- .../util/ResourceUtilsTests.java | 5 +- .../util/UnmodifiableMultiValueMapTests.java | 6 +- .../comparator/InstanceComparatorTests.java | 8 +- .../util/concurrent/FutureAdapterTests.java | 3 +- .../concurrent/ListenableFutureTaskTests.java | 10 +- .../SettableListenableFutureTests.java | 26 +++-- .../function/ThrowingBiFunctionTests.java | 4 +- .../util/function/ThrowingConsumerTests.java | 4 +- .../util/function/ThrowingFunctionTests.java | 4 +- .../util/function/ThrowingSupplierTests.java | 8 +- .../util/xml/AbstractStaxXMLReaderTests.java | 2 +- .../util/xml/SimpleNamespaceContextTests.java | 8 +- .../util/xml/StaxUtilsTests.java | 6 +- .../util/xml/TransformerUtilsTests.java | 16 +-- 52 files changed, 281 insertions(+), 290 deletions(-) diff --git a/spring-core/src/test/java/org/springframework/aot/hint/BindingReflectionHintsRegistrarTests.java b/spring-core/src/test/java/org/springframework/aot/hint/BindingReflectionHintsRegistrarTests.java index c3906146260..1ca33d1bf0b 100644 --- a/spring-core/src/test/java/org/springframework/aot/hint/BindingReflectionHintsRegistrarTests.java +++ b/spring-core/src/test/java/org/springframework/aot/hint/BindingReflectionHintsRegistrarTests.java @@ -16,14 +16,12 @@ package org.springframework.aot.hint; -import java.io.IOException; import java.lang.reflect.Type; import java.time.LocalDate; import java.util.List; import java.util.Set; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.core.JacksonException; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.PropertyNamingStrategies; @@ -443,7 +441,7 @@ class BindingReflectionHintsRegistrarTests { } @Override - public LocalDate deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JacksonException { + public LocalDate deserialize(JsonParser p, DeserializationContext ctxt) { return null; } } @@ -456,7 +454,7 @@ class BindingReflectionHintsRegistrarTests { } @Override - public LocalDate deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JacksonException { + public LocalDate deserialize(JsonParser p, DeserializationContext ctxt) { return null; } } diff --git a/spring-core/src/test/java/org/springframework/aot/hint/annotation/RegisterReflectionForBindingProcessorTests.java b/spring-core/src/test/java/org/springframework/aot/hint/annotation/RegisterReflectionForBindingProcessorTests.java index 37e65ce6ac3..48ba76d4f8e 100644 --- a/spring-core/src/test/java/org/springframework/aot/hint/annotation/RegisterReflectionForBindingProcessorTests.java +++ b/spring-core/src/test/java/org/springframework/aot/hint/annotation/RegisterReflectionForBindingProcessorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 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. @@ -59,7 +59,7 @@ public class RegisterReflectionForBindingProcessorTests { } @Test - void throwExceptionWithoutAnnotationAttributeOnMethod() throws NoSuchMethodException { + void throwExceptionWithoutAnnotationAttributeOnMethod() { assertThatThrownBy(() -> processor.registerReflectionHints(hints.reflection(), SampleClassWithoutMethodLevelAnnotationAttribute.class.getMethod("method"))) .isInstanceOf(IllegalStateException.class); diff --git a/spring-core/src/test/java/org/springframework/core/BridgeMethodResolverTests.java b/spring-core/src/test/java/org/springframework/core/BridgeMethodResolverTests.java index b28e69c0aaf..d5fb2f1f63d 100644 --- a/spring-core/src/test/java/org/springframework/core/BridgeMethodResolverTests.java +++ b/spring-core/src/test/java/org/springframework/core/BridgeMethodResolverTests.java @@ -152,7 +152,7 @@ class BridgeMethodResolverTests { } @Test - void withGenericParameter() throws Exception { + void withGenericParameter() { Method[] methods = StringGenericParameter.class.getMethods(); Method bridgeMethod = null; Method bridgedMethod = null; @@ -173,7 +173,7 @@ class BridgeMethodResolverTests { } @Test - void onAllMethods() throws Exception { + void onAllMethods() { Method[] methods = StringList.class.getMethods(); for (Method method : methods) { assertThat(BridgeMethodResolver.findBridgedMethod(method)).isNotNull(); @@ -206,7 +206,7 @@ class BridgeMethodResolverTests { } @Test - void spr2648() throws Exception { + void spr2648() { Method bridgeMethod = ReflectionUtils.findMethod(GenericSqlMapIntegerDao.class, "saveOrUpdate", Object.class); assertThat(bridgeMethod != null && bridgeMethod.isBridge()).isTrue(); Method bridgedMethod = BridgeMethodResolver.findBridgedMethod(bridgeMethod); @@ -296,7 +296,7 @@ class BridgeMethodResolverTests { } @Test - void spr3534() throws Exception { + void spr3534() { Method bridgeMethod = ReflectionUtils.findMethod(TestEmailProvider.class, "findBy", Object.class); assertThat(bridgeMethod != null && bridgeMethod.isBridge()).isTrue(); Method bridgedMethod = BridgeMethodResolver.findBridgedMethod(bridgeMethod); @@ -843,7 +843,7 @@ class BridgeMethodResolverTests { public interface SimpleGenericRepository { - public Class getPersistentClass(); + Class getPersistentClass(); List findByQuery(); @@ -884,7 +884,7 @@ class BridgeMethodResolverTests { return null; } - public void afterPropertiesSet() throws Exception { + public void afterPropertiesSet() { } } diff --git a/spring-core/src/test/java/org/springframework/core/CollectionFactoryTests.java b/spring-core/src/test/java/org/springframework/core/CollectionFactoryTests.java index 8f418f052f7..789b5339dd7 100644 --- a/spring-core/src/test/java/org/springframework/core/CollectionFactoryTests.java +++ b/spring-core/src/test/java/org/springframework/core/CollectionFactoryTests.java @@ -306,7 +306,7 @@ class CollectionFactoryTests { enum Color { - RED, BLUE; + RED, BLUE } } diff --git a/spring-core/src/test/java/org/springframework/core/ConstantsTests.java b/spring-core/src/test/java/org/springframework/core/ConstantsTests.java index 8bb2618e593..b39e353565d 100644 --- a/spring-core/src/test/java/org/springframework/core/ConstantsTests.java +++ b/spring-core/src/test/java/org/springframework/core/ConstantsTests.java @@ -192,28 +192,28 @@ class ConstantsTests { } @Test - void getValuesWithNullPrefix() throws Exception { + void getValuesWithNullPrefix() { Constants c = new Constants(A.class); Set values = c.getValues(null); assertThat(values).as("Must have returned *all* public static final values").hasSize(7); } @Test - void getValuesWithEmptyStringPrefix() throws Exception { + void getValuesWithEmptyStringPrefix() { Constants c = new Constants(A.class); Set values = c.getValues(""); assertThat(values).as("Must have returned *all* public static final values").hasSize(7); } @Test - void getValuesWithWhitespacedStringPrefix() throws Exception { + void getValuesWithWhitespacedStringPrefix() { Constants c = new Constants(A.class); Set values = c.getValues(" "); assertThat(values).as("Must have returned *all* public static final values").hasSize(7); } @Test - void withClassThatExposesNoConstants() throws Exception { + void withClassThatExposesNoConstants() { Constants c = new Constants(NoConstants.class); assertThat(c.getSize()).isEqualTo(0); final Set values = c.getValues(""); @@ -222,7 +222,7 @@ class ConstantsTests { } @Test - void ctorWithNullClass() throws Exception { + void ctorWithNullClass() { assertThatIllegalArgumentException().isThrownBy(() -> new Constants(null)); } diff --git a/spring-core/src/test/java/org/springframework/core/ExceptionDepthComparatorTests.java b/spring-core/src/test/java/org/springframework/core/ExceptionDepthComparatorTests.java index f30f04bf787..3d243ea0882 100644 --- a/spring-core/src/test/java/org/springframework/core/ExceptionDepthComparatorTests.java +++ b/spring-core/src/test/java/org/springframework/core/ExceptionDepthComparatorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2023 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,55 +30,55 @@ import static org.assertj.core.api.Assertions.assertThat; class ExceptionDepthComparatorTests { @Test - void targetBeforeSameDepth() throws Exception { + void targetBeforeSameDepth() { Class foundClass = findClosestMatch(TargetException.class, SameDepthException.class); assertThat(foundClass).isEqualTo(TargetException.class); } @Test - void sameDepthBeforeTarget() throws Exception { + void sameDepthBeforeTarget() { Class foundClass = findClosestMatch(SameDepthException.class, TargetException.class); assertThat(foundClass).isEqualTo(TargetException.class); } @Test - void lowestDepthBeforeTarget() throws Exception { + void lowestDepthBeforeTarget() { Class foundClass = findClosestMatch(LowestDepthException.class, TargetException.class); assertThat(foundClass).isEqualTo(TargetException.class); } @Test - void targetBeforeLowestDepth() throws Exception { + void targetBeforeLowestDepth() { Class foundClass = findClosestMatch(TargetException.class, LowestDepthException.class); assertThat(foundClass).isEqualTo(TargetException.class); } @Test - void noDepthBeforeTarget() throws Exception { + void noDepthBeforeTarget() { Class foundClass = findClosestMatch(NoDepthException.class, TargetException.class); assertThat(foundClass).isEqualTo(TargetException.class); } @Test - void noDepthBeforeHighestDepth() throws Exception { + void noDepthBeforeHighestDepth() { Class foundClass = findClosestMatch(NoDepthException.class, HighestDepthException.class); assertThat(foundClass).isEqualTo(HighestDepthException.class); } @Test - void highestDepthBeforeNoDepth() throws Exception { + void highestDepthBeforeNoDepth() { Class foundClass = findClosestMatch(HighestDepthException.class, NoDepthException.class); assertThat(foundClass).isEqualTo(HighestDepthException.class); } @Test - void highestDepthBeforeLowestDepth() throws Exception { + void highestDepthBeforeLowestDepth() { Class foundClass = findClosestMatch(HighestDepthException.class, LowestDepthException.class); assertThat(foundClass).isEqualTo(LowestDepthException.class); } @Test - void lowestDepthBeforeHighestDepth() throws Exception { + void lowestDepthBeforeHighestDepth() { Class foundClass = findClosestMatch(LowestDepthException.class, HighestDepthException.class); assertThat(foundClass).isEqualTo(LowestDepthException.class); } diff --git a/spring-core/src/test/java/org/springframework/core/ResolvableTypeTests.java b/spring-core/src/test/java/org/springframework/core/ResolvableTypeTests.java index a1388be50d9..7880ca35d3b 100644 --- a/spring-core/src/test/java/org/springframework/core/ResolvableTypeTests.java +++ b/spring-core/src/test/java/org/springframework/core/ResolvableTypeTests.java @@ -76,7 +76,7 @@ class ResolvableTypeTests { @Test - void noneReturnValues() throws Exception { + void noneReturnValues() { ResolvableType none = ResolvableType.NONE; assertThat(none.as(Object.class)).isEqualTo(ResolvableType.NONE); assertThat(none.asCollection()).isEqualTo(ResolvableType.NONE); @@ -99,7 +99,7 @@ class ResolvableTypeTests { } @Test - void forClass() throws Exception { + void forClass() { ResolvableType type = ResolvableType.forClass(ExtendsList.class); assertThat(type.getType()).isEqualTo(ExtendsList.class); assertThat(type.getRawClass()).isEqualTo(ExtendsList.class); @@ -108,7 +108,7 @@ class ResolvableTypeTests { } @Test - void forClassWithNull() throws Exception { + void forClassWithNull() { ResolvableType type = ResolvableType.forClass(null); assertThat(type.getType()).isEqualTo(Object.class); assertThat(type.getRawClass()).isEqualTo(Object.class); @@ -117,7 +117,7 @@ class ResolvableTypeTests { } @Test - void forRawClass() throws Exception { + void forRawClass() { ResolvableType type = ResolvableType.forRawClass(ExtendsList.class); assertThat(type.getType()).isEqualTo(ExtendsList.class); assertThat(type.getRawClass()).isEqualTo(ExtendsList.class); @@ -127,7 +127,7 @@ class ResolvableTypeTests { } @Test - void forRawClassWithNull() throws Exception { + void forRawClassWithNull() { ResolvableType type = ResolvableType.forRawClass(null); assertThat(type.getType()).isEqualTo(Object.class); assertThat(type.getRawClass()).isEqualTo(Object.class); @@ -137,7 +137,7 @@ class ResolvableTypeTests { } @Test // gh-23321 - void forRawClassAssignableFromTypeVariable() throws Exception { + void forRawClassAssignableFromTypeVariable() { ResolvableType typeVariable = ResolvableType.forClass(ExtendsList.class).as(List.class).getGeneric(); ResolvableType raw = ResolvableType.forRawClass(CharSequence.class); assertThat(raw.resolve()).isEqualTo(CharSequence.class); @@ -149,26 +149,26 @@ class ResolvableTypeTests { } @Test // gh-28776 - void forInstanceNull() throws Exception { + void forInstanceNull() { assertThat(ResolvableType.forInstance(null)).isEqualTo(ResolvableType.NONE); } @Test - void forInstanceNoProvider() throws Exception { + void forInstanceNoProvider() { ResolvableType type = ResolvableType.forInstance(new Object()); assertThat(type.getType()).isEqualTo(Object.class); assertThat(type.resolve()).isEqualTo(Object.class); } @Test - void forInstanceProvider() throws Exception { + void forInstanceProvider() { ResolvableType type = ResolvableType.forInstance(new MyGenericInterfaceType<>(String.class)); assertThat(type.getRawClass()).isEqualTo(MyGenericInterfaceType.class); assertThat(type.getGeneric().resolve()).isEqualTo(String.class); } @Test - void forInstanceProviderNull() throws Exception { + void forInstanceProviderNull() { ResolvableType type = ResolvableType.forInstance(new MyGenericInterfaceType(null)); assertThat(type.getType()).isEqualTo(MyGenericInterfaceType.class); assertThat(type.resolve()).isEqualTo(MyGenericInterfaceType.class); @@ -200,7 +200,7 @@ class ResolvableTypeTests { } @Test - void forFieldMustNotBeNull() throws Exception { + void forFieldMustNotBeNull() { assertThatIllegalArgumentException() .isThrownBy(() -> ResolvableType.forField(null)) .withMessage("Field must not be null"); @@ -214,7 +214,7 @@ class ResolvableTypeTests { } @Test - void forConstructorParameterMustNotBeNull() throws Exception { + void forConstructorParameterMustNotBeNull() { assertThatIllegalArgumentException() .isThrownBy(() -> ResolvableType.forConstructorParameter(null, 0)) .withMessage("Constructor must not be null"); @@ -228,7 +228,7 @@ class ResolvableTypeTests { } @Test - void forMethodParameterByIndexMustNotBeNull() throws Exception { + void forMethodParameterByIndexMustNotBeNull() { assertThatIllegalArgumentException() .isThrownBy(() -> ResolvableType.forMethodParameter(null, 0)) .withMessage("Method must not be null"); @@ -268,7 +268,7 @@ class ResolvableTypeTests { } @Test - void forMethodParameterMustNotBeNull() throws Exception { + void forMethodParameterMustNotBeNull() { assertThatIllegalArgumentException() .isThrownBy(() -> ResolvableType.forMethodParameter(null)) .withMessage("MethodParameter must not be null"); @@ -295,7 +295,7 @@ class ResolvableTypeTests { } @Test - void forMethodReturnMustNotBeNull() throws Exception { + void forMethodReturnMustNotBeNull() { assertThatIllegalArgumentException() .isThrownBy(() -> ResolvableType.forMethodReturnType(null)) .withMessage("Method must not be null"); @@ -372,7 +372,7 @@ class ResolvableTypeTests { } @Test - void getComponentTypeForVariableThatResolvesToGenericArray() throws Exception { + void getComponentTypeForVariableThatResolvesToGenericArray() { ResolvableType type = ResolvableType.forClass(ListOfGenericArray.class).asCollection().getGeneric(); assertThat(type.isArray()).isTrue(); assertThat(type.getType()).isInstanceOf(TypeVariable.class); @@ -381,21 +381,21 @@ class ResolvableTypeTests { } @Test - void getComponentTypeForNonArray() throws Exception { + void getComponentTypeForNonArray() { ResolvableType type = ResolvableType.forClass(String.class); assertThat(type.isArray()).isFalse(); assertThat(type.getComponentType()).isEqualTo(ResolvableType.NONE); } @Test - void asCollection() throws Exception { + void asCollection() { ResolvableType type = ResolvableType.forClass(ExtendsList.class).asCollection(); assertThat(type.resolve()).isEqualTo(Collection.class); assertThat(type.resolveGeneric()).isEqualTo(CharSequence.class); } @Test - void asMap() throws Exception { + void asMap() { ResolvableType type = ResolvableType.forClass(ExtendsMap.class).asMap(); assertThat(type.resolve()).isEqualTo(Map.class); assertThat(type.resolveGeneric(0)).isEqualTo(String.class); @@ -403,43 +403,43 @@ class ResolvableTypeTests { } @Test - void asFromInterface() throws Exception { + void asFromInterface() { ResolvableType type = ResolvableType.forClass(ExtendsList.class).as(List.class); assertThat(type.getType().toString()).isEqualTo("java.util.List"); } @Test - void asFromInheritedInterface() throws Exception { + void asFromInheritedInterface() { ResolvableType type = ResolvableType.forClass(ExtendsList.class).as(Collection.class); assertThat(type.getType().toString()).isEqualTo("java.util.Collection"); } @Test - void asFromSuperType() throws Exception { + void asFromSuperType() { ResolvableType type = ResolvableType.forClass(ExtendsList.class).as(ArrayList.class); assertThat(type.getType().toString()).isEqualTo("java.util.ArrayList"); } @Test - void asFromInheritedSuperType() throws Exception { + void asFromInheritedSuperType() { ResolvableType type = ResolvableType.forClass(ExtendsList.class).as(List.class); assertThat(type.getType().toString()).isEqualTo("java.util.List"); } @Test - void asNotFound() throws Exception { + void asNotFound() { ResolvableType type = ResolvableType.forClass(ExtendsList.class).as(Map.class); assertThat(type).isSameAs(ResolvableType.NONE); } @Test - void asSelf() throws Exception { + void asSelf() { ResolvableType type = ResolvableType.forClass(ExtendsList.class); assertThat(type.as(ExtendsList.class)).isEqualTo(type); } @Test - void getSuperType() throws Exception { + void getSuperType() { ResolvableType type = ResolvableType.forClass(ExtendsList.class).getSuperType(); assertThat(type.resolve()).isEqualTo(ArrayList.class); type = type.getSuperType(); @@ -451,7 +451,7 @@ class ResolvableTypeTests { } @Test - void getInterfaces() throws Exception { + void getInterfaces() { ResolvableType type = ResolvableType.forClass(ExtendsList.class); assertThat(type.getInterfaces()).isEmpty(); SortedSet interfaces = new TreeSet<>(); @@ -464,13 +464,13 @@ class ResolvableTypeTests { } @Test - void noSuperType() throws Exception { + void noSuperType() { assertThat(ResolvableType.forClass(Object.class).getSuperType()) .isEqualTo(ResolvableType.NONE); } @Test - void noInterfaces() throws Exception { + void noInterfaces() { assertThat(ResolvableType.forClass(Object.class).getInterfaces()).isEmpty(); } @@ -534,7 +534,7 @@ class ResolvableTypeTests { } @Test - void getGenericOutOfBounds() throws Exception { + void getGenericOutOfBounds() { ResolvableType type = ResolvableType.forClass(List.class, ExtendsList.class); assertThat(type.getGeneric(0)).isNotEqualTo(ResolvableType.NONE); assertThat(type.getGeneric(1)).isEqualTo(ResolvableType.NONE); @@ -542,14 +542,14 @@ class ResolvableTypeTests { } @Test - void hasGenerics() throws Exception { + void hasGenerics() { ResolvableType type = ResolvableType.forClass(ExtendsList.class); assertThat(type.hasGenerics()).isFalse(); assertThat(type.asCollection().hasGenerics()).isTrue(); } @Test - void getGenericsFromParameterizedType() throws Exception { + void getGenericsFromParameterizedType() { ResolvableType type = ResolvableType.forClass(List.class, ExtendsList.class); ResolvableType[] generics = type.getGenerics(); assertThat(generics).hasSize(1); @@ -557,7 +557,7 @@ class ResolvableTypeTests { } @Test - void getGenericsFromClass() throws Exception { + void getGenericsFromClass() { ResolvableType type = ResolvableType.forClass(List.class); ResolvableType[] generics = type.getGenerics(); assertThat(generics).hasSize(1); @@ -565,14 +565,14 @@ class ResolvableTypeTests { } @Test - void noGetGenerics() throws Exception { + void noGetGenerics() { ResolvableType type = ResolvableType.forClass(ExtendsList.class); ResolvableType[] generics = type.getGenerics(); assertThat(generics).isEmpty(); } @Test - void getResolvedGenerics() throws Exception { + void getResolvedGenerics() { ResolvableType type = ResolvableType.forClass(List.class, ExtendsList.class); Class[] generics = type.resolveGenerics(); assertThat(generics).hasSize(1); @@ -768,14 +768,14 @@ class ResolvableTypeTests { } @Test - void resolveTypeVariableFromSuperType() throws Exception { + void resolveTypeVariableFromSuperType() { ResolvableType type = ResolvableType.forClass(ExtendsList.class); assertThat(type.resolve()).isEqualTo(ExtendsList.class); assertThat(type.asCollection().resolveGeneric()).isEqualTo(CharSequence.class); } @Test - void resolveTypeVariableFromClassWithImplementsClass() throws Exception { + void resolveTypeVariableFromClassWithImplementsClass() { ResolvableType type = ResolvableType.forClass( MySuperclassType.class, MyCollectionSuperclassType.class); assertThat(type.resolveGeneric()).isEqualTo(Collection.class); @@ -971,7 +971,7 @@ class ResolvableTypeTests { } @Test - void resolveFromClassWithGenerics() throws Exception { + void resolveFromClassWithGenerics() { ResolvableType type = ResolvableType.forClassWithGenerics(List.class, ResolvableType.forClassWithGenerics(List.class, String.class)); assertThat(type.asCollection().toString()).isEqualTo("java.util.Collection>"); assertThat(type.asCollection().getGeneric().toString()).isEqualTo("java.util.List"); @@ -981,21 +981,21 @@ class ResolvableTypeTests { } @Test - void isAssignableFromMustNotBeNull() throws Exception { + void isAssignableFromMustNotBeNull() { assertThatIllegalArgumentException() .isThrownBy(() -> ResolvableType.forClass(Object.class).isAssignableFrom((ResolvableType) null)) .withMessage("ResolvableType must not be null"); } @Test - void isAssignableFromForNone() throws Exception { + void isAssignableFromForNone() { ResolvableType objectType = ResolvableType.forClass(Object.class); assertThat(objectType.isAssignableFrom(ResolvableType.NONE)).isFalse(); assertThat(ResolvableType.NONE.isAssignableFrom(objectType)).isFalse(); } @Test - void isAssignableFromForClassAndClass() throws Exception { + void isAssignableFromForClassAndClass() { ResolvableType objectType = ResolvableType.forClass(Object.class); ResolvableType charSequenceType = ResolvableType.forClass(CharSequence.class); ResolvableType stringType = ResolvableType.forClass(String.class); @@ -1223,7 +1223,7 @@ class ResolvableTypeTests { } @Test - void forClassWithGenerics() throws Exception { + void forClassWithGenerics() { ResolvableType elementType = ResolvableType.forClassWithGenerics(Map.class, Integer.class, String.class); ResolvableType listType = ResolvableType.forClassWithGenerics(List.class, elementType); assertThat(listType.toString()).isEqualTo("java.util.List>"); @@ -1232,13 +1232,13 @@ class ResolvableTypeTests { } @Test - void classWithGenericsAs() throws Exception { + void classWithGenericsAs() { ResolvableType type = ResolvableType.forClassWithGenerics(MultiValueMap.class, Integer.class, String.class); assertThat(type.asMap().toString()).isEqualTo("java.util.Map>"); } @Test - void forClassWithMismatchedGenerics() throws Exception { + void forClassWithMismatchedGenerics() { assertThatIllegalArgumentException() .isThrownBy(() -> ResolvableType.forClassWithGenerics(Map.class, Integer.class)) .withMessageContaining("Mismatched number of generics specified for") @@ -1266,7 +1266,7 @@ class ResolvableTypeTests { } @Test - void canResolveVoid() throws Exception { + void canResolveVoid() { ResolvableType type = ResolvableType.forClass(void.class); assertThat(type.resolve()).isEqualTo(void.class); } @@ -1285,19 +1285,19 @@ class ResolvableTypeTests { } @Test - void hasUnresolvableGenericsBasedOnOwnGenerics() throws Exception { + void hasUnresolvableGenericsBasedOnOwnGenerics() { ResolvableType type = ResolvableType.forClass(List.class); assertThat(type.hasUnresolvableGenerics()).isTrue(); } @Test - void hasUnresolvableGenericsWhenSelfNotResolvable() throws Exception { + void hasUnresolvableGenericsWhenSelfNotResolvable() { ResolvableType type = ResolvableType.forClass(List.class).getGeneric(); assertThat(type.hasUnresolvableGenerics()).isFalse(); } @Test - void hasUnresolvableGenericsWhenImplementingRawInterface() throws Exception { + void hasUnresolvableGenericsWhenImplementingRawInterface() { ResolvableType type = ResolvableType.forClass(MySimpleInterfaceTypeWithImplementsRaw.class); for (ResolvableType generic : type.getGenerics()) { assertThat(generic.resolve()).isNotNull(); @@ -1306,7 +1306,7 @@ class ResolvableTypeTests { } @Test - void hasUnresolvableGenericsWhenExtends() throws Exception { + void hasUnresolvableGenericsWhenExtends() { ResolvableType type = ResolvableType.forClass(ExtendsMySimpleInterfaceTypeWithImplementsRaw.class); for (ResolvableType generic : type.getGenerics()) { assertThat(generic.resolve()).isNotNull(); @@ -1322,7 +1322,7 @@ class ResolvableTypeTests { } @Test - void spr12701() throws Exception { + void spr12701() { ResolvableType resolvableType = ResolvableType.forClassWithGenerics(Callable.class, String.class); Type type = resolvableType.getType(); assertThat(type).isInstanceOf(ParameterizedType.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 56e052b4168..1d1b75fa99f 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 @@ -752,7 +752,7 @@ class AnnotatedElementUtilsTests { * @see #23767 */ @Test - void findMergedAnnotationAttributesOnClassWithComposedMetaTransactionalAnnotation() throws Exception { + void findMergedAnnotationAttributesOnClassWithComposedMetaTransactionalAnnotation() { Class clazz = ComposedTransactionalClass.class; AnnotationAttributes attributes = findMergedAnnotationAttributes(clazz, AliasedTransactional.class); @@ -766,7 +766,7 @@ class AnnotatedElementUtilsTests { * @see #23767 */ @Test - void findMergedAnnotationOnClassWithComposedMetaTransactionalAnnotation() throws Exception { + void findMergedAnnotationOnClassWithComposedMetaTransactionalAnnotation() { Class clazz = ComposedTransactionalClass.class; AliasedTransactional annotation = findMergedAnnotation(clazz, AliasedTransactional.class); @@ -848,13 +848,13 @@ class AnnotatedElementUtilsTests { } @Test - void javaxAnnotationTypeViaFindMergedAnnotation() throws Exception { + void javaxAnnotationTypeViaFindMergedAnnotation() { assertThat(findMergedAnnotation(ResourceHolder.class, Resource.class)).isEqualTo(ResourceHolder.class.getAnnotation(Resource.class)); assertThat(findMergedAnnotation(SpringAppConfigClass.class, Resource.class)).isEqualTo(SpringAppConfigClass.class.getAnnotation(Resource.class)); } @Test - void javaxMetaAnnotationTypeViaFindMergedAnnotation() throws Exception { + void javaxMetaAnnotationTypeViaFindMergedAnnotation() { assertThat(findMergedAnnotation(ParametersAreNonnullByDefault.class, Nonnull.class)).isEqualTo(ParametersAreNonnullByDefault.class.getAnnotation(Nonnull.class)); assertThat(findMergedAnnotation(ResourceHolder.class, Nonnull.class)).isEqualTo(ParametersAreNonnullByDefault.class.getAnnotation(Nonnull.class)); } diff --git a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationAttributesTests.java b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationAttributesTests.java index 49ea67b0b29..b24ace18917 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationAttributesTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationAttributesTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 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. @@ -72,7 +72,7 @@ class AnnotationAttributesTests { } @Test - void unresolvableClassWithClassNotFoundException() throws Exception { + void unresolvableClassWithClassNotFoundException() { attributes.put("unresolvableClass", new ClassNotFoundException("myclass")); assertThatIllegalArgumentException() .isThrownBy(() -> attributes.getClass("unresolvableClass")) @@ -81,7 +81,7 @@ class AnnotationAttributesTests { } @Test - void unresolvableClassWithLinkageError() throws Exception { + void unresolvableClassWithLinkageError() { attributes.put("unresolvableClass", new LinkageError("myclass")); assertThatIllegalArgumentException() .isThrownBy(() -> attributes.getClass("unresolvableClass")) @@ -90,7 +90,7 @@ class AnnotationAttributesTests { } @Test - void singleElementToSingleElementArrayConversionSupport() throws Exception { + void singleElementToSingleElementArrayConversionSupport() { Filter filter = FilteredClass.class.getAnnotation(Filter.class); AnnotationAttributes nestedAttributes = new AnnotationAttributes(); @@ -118,7 +118,7 @@ class AnnotationAttributesTests { } @Test - void nestedAnnotations() throws Exception { + void nestedAnnotations() { Filter filter = FilteredClass.class.getAnnotation(Filter.class); attributes.put("filter", filter); 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 feab26dad54..ce500f3b81f 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 @@ -503,7 +503,7 @@ class AnnotationUtilsTests { } @Test - void getValueFromNonPublicAnnotation() throws Exception { + void getValueFromNonPublicAnnotation() { Annotation[] declaredAnnotations = NonPublicAnnotatedClass.class.getDeclaredAnnotations(); assertThat(declaredAnnotations).hasSize(1); Annotation annotation = declaredAnnotations[0]; @@ -718,7 +718,7 @@ class AnnotationUtilsTests { } @Test - void synthesizeAnnotationWithImplicitAliasesWithMissingDefaultValues() throws Exception { + void synthesizeAnnotationWithImplicitAliasesWithMissingDefaultValues() { Class clazz = ImplicitAliasesWithMissingDefaultValuesContextConfigClass.class; Class annotationType = ImplicitAliasesWithMissingDefaultValuesContextConfig.class; @@ -734,7 +734,7 @@ class AnnotationUtilsTests { } @Test - void synthesizeAnnotationWithImplicitAliasesWithDifferentDefaultValues() throws Exception { + void synthesizeAnnotationWithImplicitAliasesWithDifferentDefaultValues() { Class clazz = ImplicitAliasesWithDifferentDefaultValuesContextConfigClass.class; Class annotationType = ImplicitAliasesWithDifferentDefaultValuesContextConfig.class; @@ -749,7 +749,7 @@ class AnnotationUtilsTests { } @Test - void synthesizeAnnotationWithImplicitAliasesWithDuplicateValues() throws Exception { + void synthesizeAnnotationWithImplicitAliasesWithDuplicateValues() { Class clazz = ImplicitAliasesWithDuplicateValuesContextConfigClass.class; Class annotationType = ImplicitAliasesWithDuplicateValuesContextConfig.class; @@ -767,7 +767,7 @@ class AnnotationUtilsTests { } @Test - void synthesizeAnnotationFromMapWithoutAttributeAliases() throws Exception { + void synthesizeAnnotationFromMapWithoutAttributeAliases() { Component component = WebController.class.getAnnotation(Component.class); assertThat(component).isNotNull(); @@ -782,7 +782,7 @@ class AnnotationUtilsTests { @Test @SuppressWarnings("unchecked") - void synthesizeAnnotationFromMapWithNestedMap() throws Exception { + void synthesizeAnnotationFromMapWithNestedMap() { ComponentScanSingleFilter componentScan = ComponentScanSingleFilterClass.class.getAnnotation(ComponentScanSingleFilter.class); assertThat(componentScan).isNotNull(); @@ -811,7 +811,7 @@ class AnnotationUtilsTests { @Test @SuppressWarnings("unchecked") - void synthesizeAnnotationFromMapWithNestedArrayOfMaps() throws Exception { + void synthesizeAnnotationFromMapWithNestedArrayOfMaps() { ComponentScan componentScan = ComponentScanClass.class.getAnnotation(ComponentScan.class); assertThat(componentScan).isNotNull(); @@ -841,7 +841,7 @@ class AnnotationUtilsTests { } @Test - void synthesizeAnnotationFromDefaultsWithoutAttributeAliases() throws Exception { + void synthesizeAnnotationFromDefaultsWithoutAttributeAliases() { AnnotationWithDefaults annotationWithDefaults = synthesizeAnnotation(AnnotationWithDefaults.class); assertThat(annotationWithDefaults).isNotNull(); assertThat(annotationWithDefaults.text()).as("text: ").isEqualTo("enigma"); @@ -850,7 +850,7 @@ class AnnotationUtilsTests { } @Test - void synthesizeAnnotationFromDefaultsWithAttributeAliases() throws Exception { + void synthesizeAnnotationFromDefaultsWithAttributeAliases() { ContextConfig contextConfig = synthesizeAnnotation(ContextConfig.class); assertThat(contextConfig).isNotNull(); assertThat(contextConfig.value()).as("value: ").isEmpty(); @@ -858,7 +858,7 @@ class AnnotationUtilsTests { } @Test - void synthesizeAnnotationFromMapWithMinimalAttributesWithAttributeAliases() throws Exception { + void synthesizeAnnotationFromMapWithMinimalAttributesWithAttributeAliases() { Map map = Collections.singletonMap("location", "test.xml"); ContextConfig contextConfig = synthesizeAnnotation(map, ContextConfig.class, null); assertThat(contextConfig).isNotNull(); @@ -867,7 +867,7 @@ class AnnotationUtilsTests { } @Test - void synthesizeAnnotationFromMapWithAttributeAliasesThatOverrideArraysWithSingleElements() throws Exception { + void synthesizeAnnotationFromMapWithAttributeAliasesThatOverrideArraysWithSingleElements() { Map map = Collections.singletonMap("value", "/foo"); Get get = synthesizeAnnotation(map, Get.class, null); assertThat(get).isNotNull(); @@ -891,7 +891,7 @@ class AnnotationUtilsTests { assertAnnotationSynthesisFromMapWithImplicitAliases("groovyScript"); } - private void assertAnnotationSynthesisFromMapWithImplicitAliases(String attributeNameAndValue) throws Exception { + private void assertAnnotationSynthesisFromMapWithImplicitAliases(String attributeNameAndValue) { Map map = Collections.singletonMap(attributeNameAndValue, attributeNameAndValue); ImplicitAliasesContextConfig config = synthesizeAnnotation(map, ImplicitAliasesContextConfig.class, null); assertThat(config).isNotNull(); @@ -904,12 +904,12 @@ class AnnotationUtilsTests { } @Test - void synthesizeAnnotationFromMapWithMissingAttributeValue() throws Exception { + void synthesizeAnnotationFromMapWithMissingAttributeValue() { assertMissingTextAttribute(Collections.emptyMap()); } @Test - void synthesizeAnnotationFromMapWithNullAttributeValue() throws Exception { + void synthesizeAnnotationFromMapWithNullAttributeValue() { Map map = Collections.singletonMap("text", null); assertThat(map.containsKey("text")).isTrue(); assertMissingTextAttribute(map); @@ -922,7 +922,7 @@ class AnnotationUtilsTests { } @Test - void synthesizeAnnotationFromMapWithAttributeOfIncorrectType() throws Exception { + void synthesizeAnnotationFromMapWithAttributeOfIncorrectType() { Map map = Collections.singletonMap(VALUE, 42L); assertThatIllegalStateException().isThrownBy(() -> synthesizeAnnotation(map, Component.class, null).value()) @@ -931,7 +931,7 @@ class AnnotationUtilsTests { } @Test - void synthesizeAnnotationFromAnnotationAttributesWithoutAttributeAliases() throws Exception { + void synthesizeAnnotationFromAnnotationAttributesWithoutAttributeAliases() { // 1) Get an annotation Component component = WebController.class.getAnnotation(Component.class); assertThat(component).isNotNull(); @@ -952,7 +952,7 @@ class AnnotationUtilsTests { } @Test // gh-22702 - void findAnnotationWithRepeatablesElements() throws Exception { + void findAnnotationWithRepeatablesElements() { assertThat(AnnotationUtils.findAnnotation(TestRepeatablesClass.class, TestRepeatable.class)).isNull(); assertThat(AnnotationUtils.findAnnotation(TestRepeatablesClass.class, @@ -960,7 +960,7 @@ class AnnotationUtilsTests { } @Test // gh-23856 - void findAnnotationFindsRepeatableContainerOnComposedAnnotationMetaAnnotatedWithRepeatableAnnotations() throws Exception { + void findAnnotationFindsRepeatableContainerOnComposedAnnotationMetaAnnotatedWithRepeatableAnnotations() { MyRepeatableContainer annotation = AnnotationUtils.findAnnotation(MyRepeatableMeta1And2.class, MyRepeatableContainer.class); assertThat(annotation).isNotNull(); @@ -977,7 +977,7 @@ class AnnotationUtilsTests { } @Test // gh-23929 - void findDeprecatedAnnotation() throws Exception { + void findDeprecatedAnnotation() { assertThat(getAnnotation(DeprecatedClass.class, Deprecated.class)).isNotNull(); assertThat(getAnnotation(SubclassOfDeprecatedClass.class, Deprecated.class)).isNull(); assertThat(findAnnotation(DeprecatedClass.class, Deprecated.class)).isNotNull(); 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 154c9d9f4fa..84fbd07e1b1 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-2022 the original author or authors. + * Copyright 2002-2023 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. @@ -173,7 +173,7 @@ class MergedAnnotationsComposedOnSingleAnnotatedElementTests { assertThat(stream(annotations, "value")).containsExactly("fooCache", "barCache"); } - Method getBridgeMethod() throws NoSuchMethodException { + Method getBridgeMethod() { List methods = new ArrayList<>(); ReflectionUtils.doWithLocalMethods(StringGenericParameter.class, method -> { if ("getFor".equals(method.getName())) { 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 0a2371fa4b1..3026c64bc53 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 @@ -835,7 +835,7 @@ class MergedAnnotationsTests { } @Test - void getDirectWithJavaxAnnotationType() throws Exception { + void getDirectWithJavaxAnnotationType() { assertThat(MergedAnnotations.from(ResourceHolder.class).get( Resource.class).getString("name")).isEqualTo("x"); } @@ -1214,7 +1214,7 @@ class MergedAnnotationsTests { } @Test - void isDirectlyPresentForAllScenarios() throws Exception { + void isDirectlyPresentForAllScenarios() { // no class-level annotation assertThat(MergedAnnotations.from(NonAnnotatedInterface.class).get( Transactional.class).isDirectlyPresent()).isFalse(); @@ -1357,7 +1357,7 @@ class MergedAnnotationsTests { } @Test - void getValueFromNonPublicAnnotation() throws Exception { + void getValueFromNonPublicAnnotation() { Annotation[] declaredAnnotations = NonPublicAnnotatedClass.class.getDeclaredAnnotations(); assertThat(declaredAnnotations).hasSize(1); Annotation annotation = declaredAnnotations[0]; @@ -1499,7 +1499,7 @@ class MergedAnnotationsTests { } @Test - void synthesizeWithoutAttributeAliases() throws Exception { + void synthesizeWithoutAttributeAliases() { Component component = WebController.class.getAnnotation(Component.class); assertThat(component).isNotNull(); Component synthesizedComponent = MergedAnnotation.from(component).synthesize(); @@ -1631,7 +1631,7 @@ class MergedAnnotationsTests { } @Test - void synthesizeWhenAliasForIsMissingAttributeDeclaration() throws Exception { + void synthesizeWhenAliasForIsMissingAttributeDeclaration() { AliasForWithMissingAttributeDeclaration annotation = AliasForWithMissingAttributeDeclarationClass.class.getAnnotation( AliasForWithMissingAttributeDeclaration.class); @@ -1643,7 +1643,7 @@ class MergedAnnotationsTests { } @Test - void synthesizeWhenAliasForHasDuplicateAttributeDeclaration() throws Exception { + void synthesizeWhenAliasForHasDuplicateAttributeDeclaration() { AliasForWithDuplicateAttributeDeclaration annotation = AliasForWithDuplicateAttributeDeclarationClass.class.getAnnotation( AliasForWithDuplicateAttributeDeclaration.class); assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> @@ -1654,7 +1654,7 @@ class MergedAnnotationsTests { } @Test - void synthesizeWhenAttributeAliasForNonexistentAttribute() throws Exception { + void synthesizeWhenAttributeAliasForNonexistentAttribute() { AliasForNonexistentAttribute annotation = AliasForNonexistentAttributeClass.class.getAnnotation( AliasForNonexistentAttribute.class); assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> @@ -1665,7 +1665,7 @@ class MergedAnnotationsTests { } @Test - void synthesizeWhenAttributeAliasWithMirroredAliasForWrongAttribute() throws Exception { + void synthesizeWhenAttributeAliasWithMirroredAliasForWrongAttribute() { AliasForWithMirroredAliasForWrongAttribute annotation = AliasForWithMirroredAliasForWrongAttributeClass.class.getAnnotation( AliasForWithMirroredAliasForWrongAttribute.class); @@ -1677,7 +1677,7 @@ class MergedAnnotationsTests { } @Test - void synthesizeWhenAttributeAliasForAttributeOfDifferentType() throws Exception { + void synthesizeWhenAttributeAliasForAttributeOfDifferentType() { AliasForAttributeOfDifferentType annotation = AliasForAttributeOfDifferentTypeClass.class.getAnnotation( AliasForAttributeOfDifferentType.class); assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> @@ -1690,7 +1690,7 @@ class MergedAnnotationsTests { } @Test - void synthesizeWhenAttributeAliasForWithMissingDefaultValues() throws Exception { + void synthesizeWhenAttributeAliasForWithMissingDefaultValues() { AliasForWithMissingDefaultValues annotation = AliasForWithMissingDefaultValuesClass.class.getAnnotation( AliasForWithMissingDefaultValues.class); assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> @@ -1703,7 +1703,7 @@ class MergedAnnotationsTests { } @Test - void synthesizeWhenAttributeAliasForAttributeWithDifferentDefaultValue() throws Exception { + void synthesizeWhenAttributeAliasForAttributeWithDifferentDefaultValue() { AliasForAttributeWithDifferentDefaultValue annotation = AliasForAttributeWithDifferentDefaultValueClass.class.getAnnotation( AliasForAttributeWithDifferentDefaultValue.class); @@ -1717,7 +1717,7 @@ class MergedAnnotationsTests { } @Test - void synthesizeWhenAttributeAliasForMetaAnnotationThatIsNotMetaPresent() throws Exception { + void synthesizeWhenAttributeAliasForMetaAnnotationThatIsNotMetaPresent() { AliasedComposedTestConfigurationNotMetaPresent annotation = AliasedComposedTestConfigurationNotMetaPresentClass.class.getAnnotation( AliasedComposedTestConfigurationNotMetaPresent.class); @@ -1738,7 +1738,7 @@ class MergedAnnotationsTests { testSynthesisWithImplicitAliases(GroovyImplicitAliasesSimpleTestConfigurationClass.class, "groovyScript"); } - private void testSynthesisWithImplicitAliases(Class clazz, String expected) throws Exception { + private void testSynthesisWithImplicitAliases(Class clazz, String expected) { ImplicitAliasesTestConfiguration config = clazz.getAnnotation(ImplicitAliasesTestConfiguration.class); assertThat(config).isNotNull(); ImplicitAliasesTestConfiguration synthesized = MergedAnnotation.from(config).synthesize(); @@ -1750,8 +1750,7 @@ class MergedAnnotationsTests { } @Test - void synthesizeWithImplicitAliasesWithImpliedAliasNamesOmitted() - throws Exception { + void synthesizeWithImplicitAliasesWithImpliedAliasNamesOmitted() { testSynthesisWithImplicitAliasesWithImpliedAliasNamesOmitted( ValueImplicitAliasesWithImpliedAliasNamesOmittedTestConfigurationClass.class, "value"); @@ -1777,7 +1776,7 @@ class MergedAnnotationsTests { } @Test - void synthesizeWithImplicitAliasesForAliasPair() throws Exception { + void synthesizeWithImplicitAliasesForAliasPair() { ImplicitAliasesForAliasPairTestConfiguration config = ImplicitAliasesForAliasPairTestConfigurationClass.class.getAnnotation( ImplicitAliasesForAliasPairTestConfiguration.class); @@ -1788,7 +1787,7 @@ class MergedAnnotationsTests { } @Test - void synthesizeWithTransitiveImplicitAliases() throws Exception { + void synthesizeWithTransitiveImplicitAliases() { TransitiveImplicitAliasesTestConfiguration config = TransitiveImplicitAliasesTestConfigurationClass.class.getAnnotation( TransitiveImplicitAliasesTestConfiguration.class); @@ -1799,7 +1798,7 @@ class MergedAnnotationsTests { } @Test - void synthesizeWithTransitiveImplicitAliasesForAliasPair() throws Exception { + void synthesizeWithTransitiveImplicitAliasesForAliasPair() { TransitiveImplicitAliasesForAliasPairTestConfiguration config = TransitiveImplicitAliasesForAliasPairTestConfigurationClass.class.getAnnotation( TransitiveImplicitAliasesForAliasPairTestConfiguration.class); @@ -1811,7 +1810,7 @@ class MergedAnnotationsTests { } @Test - void synthesizeWithImplicitAliasesWithMissingDefaultValues() throws Exception { + void synthesizeWithImplicitAliasesWithMissingDefaultValues() { Class clazz = ImplicitAliasesWithMissingDefaultValuesTestConfigurationClass.class; Class annotationType = ImplicitAliasesWithMissingDefaultValuesTestConfiguration.class; @@ -1826,8 +1825,7 @@ class MergedAnnotationsTests { } @Test - void synthesizeWithImplicitAliasesWithDifferentDefaultValues() - throws Exception { + void synthesizeWithImplicitAliasesWithDifferentDefaultValues() { Class clazz = ImplicitAliasesWithDifferentDefaultValuesTestConfigurationClass.class; Class annotationType = ImplicitAliasesWithDifferentDefaultValuesTestConfiguration.class; @@ -1842,7 +1840,7 @@ class MergedAnnotationsTests { } @Test - void synthesizeWithImplicitAliasesWithDuplicateValues() throws Exception { + void synthesizeWithImplicitAliasesWithDuplicateValues() { Class clazz = ImplicitAliasesWithDuplicateValuesTestConfigurationClass.class; Class annotationType = ImplicitAliasesWithDuplicateValuesTestConfiguration.class; @@ -1858,7 +1856,7 @@ class MergedAnnotationsTests { } @Test - void synthesizeFromMapWithoutAttributeAliases() throws Exception { + void synthesizeFromMapWithoutAttributeAliases() { Component component = WebController.class.getAnnotation(Component.class); assertThat(component).isNotNull(); Map map = Collections.singletonMap("value", "webController"); @@ -1870,7 +1868,7 @@ class MergedAnnotationsTests { @Test @SuppressWarnings("unchecked") - void synthesizeFromMapWithNestedMap() throws Exception { + void synthesizeFromMapWithNestedMap() { ComponentScanSingleFilter componentScan = ComponentScanSingleFilterClass.class.getAnnotation( ComponentScanSingleFilter.class); assertThat(componentScan).isNotNull(); @@ -1891,7 +1889,7 @@ class MergedAnnotationsTests { @Test @SuppressWarnings("unchecked") - void synthesizeFromMapWithNestedArrayOfMaps() throws Exception { + void synthesizeFromMapWithNestedArrayOfMaps() { ComponentScan componentScan = ComponentScanClass.class.getAnnotation( ComponentScan.class); assertThat(componentScan).isNotNull(); @@ -1915,7 +1913,7 @@ class MergedAnnotationsTests { } @Test - void synthesizeFromDefaultsWithoutAttributeAliases() throws Exception { + void synthesizeFromDefaultsWithoutAttributeAliases() { MergedAnnotation annotation = MergedAnnotation.of( AnnotationWithDefaults.class); AnnotationWithDefaults synthesized = annotation.synthesize(); @@ -1925,7 +1923,7 @@ class MergedAnnotationsTests { } @Test - void synthesizeFromDefaultsWithAttributeAliases() throws Exception { + void synthesizeFromDefaultsWithAttributeAliases() { MergedAnnotation annotation = MergedAnnotation.of( TestConfiguration.class); TestConfiguration synthesized = annotation.synthesize(); @@ -1934,14 +1932,13 @@ class MergedAnnotationsTests { } @Test - void synthesizeWhenAttributeAliasesWithDifferentValues() throws Exception { + void synthesizeWhenAttributeAliasesWithDifferentValues() { assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> MergedAnnotation.from(TestConfigurationMismatch.class.getAnnotation(TestConfiguration.class)).synthesize()); } @Test - void synthesizeFromMapWithMinimalAttributesWithAttributeAliases() - throws Exception { + void synthesizeFromMapWithMinimalAttributesWithAttributeAliases() { Map map = Collections.singletonMap("location", "test.xml"); MergedAnnotation annotation = MergedAnnotation.of( TestConfiguration.class, map); @@ -1951,8 +1948,7 @@ class MergedAnnotationsTests { } @Test - void synthesizeFromMapWithAttributeAliasesThatOverrideArraysWithSingleElements() - throws Exception { + void synthesizeFromMapWithAttributeAliasesThatOverrideArraysWithSingleElements() { synthesizeFromMapWithAttributeAliasesThatOverrideArraysWithSingleElements( Collections.singletonMap("value", "/foo")); synthesizeFromMapWithAttributeAliasesThatOverrideArraysWithSingleElements( @@ -1978,8 +1974,7 @@ class MergedAnnotationsTests { testSynthesisFromMapWithImplicitAliases("groovyScript"); } - private void testSynthesisFromMapWithImplicitAliases(String attributeNameAndValue) - throws Exception { + private void testSynthesisFromMapWithImplicitAliases(String attributeNameAndValue) { Map map = Collections.singletonMap(attributeNameAndValue, attributeNameAndValue); MergedAnnotation annotation = MergedAnnotation.of( @@ -1994,12 +1989,12 @@ class MergedAnnotationsTests { } @Test - void synthesizeFromMapWithMissingAttributeValue() throws Exception { + void synthesizeFromMapWithMissingAttributeValue() { testMissingTextAttribute(Collections.emptyMap()); } @Test - void synthesizeFromMapWithNullAttributeValue() throws Exception { + void synthesizeFromMapWithNullAttributeValue() { Map map = Collections.singletonMap("text", null); assertThat(map).containsKey("text"); testMissingTextAttribute(map); @@ -2013,7 +2008,7 @@ class MergedAnnotationsTests { } @Test - void synthesizeFromMapWithAttributeOfIncorrectType() throws Exception { + void synthesizeFromMapWithAttributeOfIncorrectType() { Map map = Collections.singletonMap("value", 42L); MergedAnnotation annotation = MergedAnnotation.of(Component.class, map); assertThatIllegalStateException().isThrownBy(() -> annotation.synthesize().value()) @@ -2023,7 +2018,7 @@ class MergedAnnotationsTests { } @Test - void synthesizeFromAnnotationAttributesWithoutAttributeAliases() throws Exception { + void synthesizeFromAnnotationAttributesWithoutAttributeAliases() { Component component = WebController.class.getAnnotation(Component.class); assertThat(component).isNotNull(); Map attributes = MergedAnnotation.from(component).asMap(); @@ -2194,7 +2189,7 @@ class MergedAnnotationsTests { } @Test - void synthesizeWithArrayOfAnnotations() throws Exception { + void synthesizeWithArrayOfAnnotations() { Hierarchy hierarchy = HierarchyClass.class.getAnnotation(Hierarchy.class); assertThat(hierarchy).isNotNull(); Hierarchy synthesizedHierarchy = MergedAnnotation.from(hierarchy).synthesize(); @@ -2216,7 +2211,7 @@ class MergedAnnotationsTests { } @Test - void synthesizeWithArrayOfChars() throws Exception { + void synthesizeWithArrayOfChars() { CharsContainer charsContainer = GroupOfCharsClass.class.getAnnotation( CharsContainer.class); assertThat(charsContainer).isNotNull(); 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 dffb0c2101c..b9c4ec7613c 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-2022 the original author or authors. + * Copyright 2002-2023 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. @@ -186,7 +186,7 @@ class MultipleComposedAnnotationsOnSingleAnnotatedElementTests { * Bridge/bridged method setup code copied from * {@link org.springframework.core.BridgeMethodResolverTests#withGenericParameter()}. */ - Method getBridgeMethod() throws NoSuchMethodException { + Method getBridgeMethod() { Method[] methods = StringGenericParameter.class.getMethods(); Method bridgeMethod = null; Method bridgedMethod = null; 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 0aa583ae978..bb9325acece 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 @@ -48,7 +48,7 @@ class CharSequenceEncoderTests extends AbstractEncoderTests @Override @Test - public void canEncode() throws Exception { + public void canEncode() { assertThat(this.encoder.canEncode(ResolvableType.forClass(String.class), MimeTypeUtils.TEXT_PLAIN)).isTrue(); assertThat(this.encoder.canEncode(ResolvableType.forClass(StringBuilder.class), 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 e1296537bfd..3b519bcdfc8 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-2019 the original author or authors. + * Copyright 2002-2023 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. @@ -70,7 +70,7 @@ class DataBufferDecoderTests extends AbstractDecoderTests { @Override @Test - public void decodeToMono() throws Exception { + public 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 9a578ed403f..6d8c0f391f9 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-2019 the original author or authors. + * Copyright 2002-2023 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. @@ -59,7 +59,7 @@ class DataBufferEncoderTests extends AbstractEncoderTests { @Override @Test - public void encode() throws Exception { + public 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/convert/TypeDescriptorTests.java b/spring-core/src/test/java/org/springframework/core/convert/TypeDescriptorTests.java index 79a8daa99b7..eb3c7e37aa7 100644 --- a/spring-core/src/test/java/org/springframework/core/convert/TypeDescriptorTests.java +++ b/spring-core/src/test/java/org/springframework/core/convert/TypeDescriptorTests.java @@ -364,7 +364,7 @@ class TypeDescriptorTests { } @Test - void valueOfArray() throws Exception { + void valueOfArray() { TypeDescriptor typeDescriptor = TypeDescriptor.valueOf(int[].class); assertThat(typeDescriptor.isArray()).isTrue(); assertThat(typeDescriptor.isCollection()).isFalse(); @@ -373,7 +373,7 @@ class TypeDescriptorTests { } @Test - void valueOfCollection() throws Exception { + void valueOfCollection() { TypeDescriptor typeDescriptor = TypeDescriptor.valueOf(Collection.class); assertThat(typeDescriptor.isCollection()).isTrue(); assertThat(typeDescriptor.isArray()).isFalse(); @@ -412,7 +412,7 @@ class TypeDescriptorTests { } @Test - void nestedMethodParameterNot1NestedLevel() throws Exception { + void nestedMethodParameterNot1NestedLevel() { assertThatIllegalArgumentException().isThrownBy(() -> TypeDescriptor.nested(new MethodParameter(getClass().getMethod("test4", List.class), 0, 2), 2)); } @@ -430,7 +430,7 @@ class TypeDescriptorTests { } @Test - void nestedMethodParameterTypeInvalidNestingLevel() throws Exception { + void nestedMethodParameterTypeInvalidNestingLevel() { assertThatIllegalArgumentException().isThrownBy(() -> TypeDescriptor.nested(new MethodParameter(getClass().getMethod("test5", String.class), 0, 2), 2)); } diff --git a/spring-core/src/test/java/org/springframework/core/convert/converter/ConvertingComparatorTests.java b/spring-core/src/test/java/org/springframework/core/convert/converter/ConvertingComparatorTests.java index 67f71684286..1bebfc3d10e 100644 --- a/spring-core/src/test/java/org/springframework/core/convert/converter/ConvertingComparatorTests.java +++ b/spring-core/src/test/java/org/springframework/core/convert/converter/ConvertingComparatorTests.java @@ -45,45 +45,45 @@ class ConvertingComparatorTests { private final TestComparator comparator = new TestComparator(); @Test - void shouldThrowOnNullComparator() throws Exception { + void shouldThrowOnNullComparator() { assertThatIllegalArgumentException().isThrownBy(() -> new ConvertingComparator<>(null, this.converter)); } @Test - void shouldThrowOnNullConverter() throws Exception { + void shouldThrowOnNullConverter() { assertThatIllegalArgumentException().isThrownBy(() -> new ConvertingComparator(this.comparator, null)); } @Test - void shouldThrowOnNullConversionService() throws Exception { + void shouldThrowOnNullConversionService() { assertThatIllegalArgumentException().isThrownBy(() -> new ConvertingComparator(this.comparator, null, Integer.class)); } @Test - void shouldThrowOnNullType() throws Exception { + void shouldThrowOnNullType() { assertThatIllegalArgumentException().isThrownBy(() -> new ConvertingComparator(this.comparator, this.conversionService, null)); } @Test - void shouldUseConverterOnCompare() throws Exception { + void shouldUseConverterOnCompare() { ConvertingComparator convertingComparator = new ConvertingComparator<>( this.comparator, this.converter); testConversion(convertingComparator); } @Test - void shouldUseConversionServiceOnCompare() throws Exception { + void shouldUseConversionServiceOnCompare() { ConvertingComparator convertingComparator = new ConvertingComparator<>( comparator, conversionService, Integer.class); testConversion(convertingComparator); } @Test - void shouldGetForConverter() throws Exception { + void shouldGetForConverter() { testConversion(new ConvertingComparator<>(comparator, converter)); } 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 b42082635af..b7f3c31490d 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 @@ -17,7 +17,6 @@ package org.springframework.core.convert.support; import java.io.File; -import java.io.IOException; import java.io.InputStream; import java.net.URI; import java.net.URL; @@ -100,7 +99,7 @@ class CollectionToCollectionConverterTests { } @Test - void collectionToObjectInteraction() throws Exception { + void collectionToObjectInteraction() { List> list = new ArrayList<>(); list.add(Arrays.asList("9", "12")); list.add(Arrays.asList("37", "23")); @@ -111,7 +110,7 @@ class CollectionToCollectionConverterTests { @Test @SuppressWarnings("unchecked") - void arrayCollectionToObjectInteraction() throws Exception { + void arrayCollectionToObjectInteraction() { List[] array = new List[2]; array[0] = Arrays.asList("9", "12"); array[1] = Arrays.asList("37", "23"); @@ -238,7 +237,7 @@ class CollectionToCollectionConverterTests { } @Test - void nothingInCommon() throws Exception { + void nothingInCommon() { List resources = new ArrayList<>(); resources.add(new ClassPathResource("test")); resources.add(3); @@ -279,7 +278,7 @@ class CollectionToCollectionConverterTests { public abstract static class BaseResource implements Resource { @Override - public InputStream getInputStream() throws IOException { + public InputStream getInputStream() { return null; } @@ -304,32 +303,32 @@ class CollectionToCollectionConverterTests { } @Override - public URL getURL() throws IOException { + public URL getURL() { return null; } @Override - public URI getURI() throws IOException { + public URI getURI() { return null; } @Override - public File getFile() throws IOException { + public File getFile() { return null; } @Override - public long contentLength() throws IOException { + public long contentLength() { return 0; } @Override - public long lastModified() throws IOException { + public long lastModified() { return 0; } @Override - public Resource createRelative(String relativePath) throws IOException { + public Resource createRelative(String relativePath) { return null; } diff --git a/spring-core/src/test/java/org/springframework/core/convert/support/GenericConversionServiceTests.java b/spring-core/src/test/java/org/springframework/core/convert/support/GenericConversionServiceTests.java index 725c3373119..3238cffa9fa 100644 --- a/spring-core/src/test/java/org/springframework/core/convert/support/GenericConversionServiceTests.java +++ b/spring-core/src/test/java/org/springframework/core/convert/support/GenericConversionServiceTests.java @@ -476,7 +476,7 @@ class GenericConversionServiceTests { } @Test - void subclassOfEnumToString() throws Exception { + void subclassOfEnumToString() { conversionService.addConverter(new EnumToStringConverter(conversionService)); assertThat(conversionService.convert(EnumWithSubclass.FIRST, String.class)).isEqualTo("FIRST"); } 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 8c4a9f1b1d6..6e3d7672907 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 @@ -78,7 +78,7 @@ class MapToMapConverterTests { } @Test - void scalarMapNotGenericTarget() throws Exception { + void scalarMapNotGenericTarget() { Map map = new HashMap<>(); map.put("1", "9"); map.put("2", "37"); @@ -161,7 +161,7 @@ class MapToMapConverterTests { } @Test - void collectionMapNotGenericTarget() throws Exception { + void collectionMapNotGenericTarget() { Map> map = new HashMap<>(); map.put("1", Arrays.asList("9", "12")); map.put("2", Arrays.asList("37", "23")); @@ -171,7 +171,7 @@ class MapToMapConverterTests { } @Test - void collectionMapNotGenericTargetCollectionToObjectInteraction() throws Exception { + void collectionMapNotGenericTargetCollectionToObjectInteraction() { Map> map = new HashMap<>(); map.put("1", Arrays.asList("9", "12")); map.put("2", Arrays.asList("37", "23")); @@ -193,7 +193,7 @@ class MapToMapConverterTests { } @Test - void emptyMapNoTargetGenericInfo() throws Exception { + void emptyMapNoTargetGenericInfo() { Map map = new HashMap<>(); assertThat(conversionService.canConvert(Map.class, Map.class)).isTrue(); @@ -214,7 +214,7 @@ class MapToMapConverterTests { } @Test - void noDefaultConstructorCopyNotRequired() throws Exception { + void noDefaultConstructorCopyNotRequired() { // SPR-9284 NoDefaultConstructorMap map = new NoDefaultConstructorMap<>( Collections.singletonMap("1", 1)); diff --git a/spring-core/src/test/java/org/springframework/core/io/PathResourceTests.java b/spring-core/src/test/java/org/springframework/core/io/PathResourceTests.java index df00b8e8d5a..d120fd272a9 100644 --- a/spring-core/src/test/java/org/springframework/core/io/PathResourceTests.java +++ b/spring-core/src/test/java/org/springframework/core/io/PathResourceTests.java @@ -161,13 +161,13 @@ class PathResourceTests { } @Test - void getInputStreamForDir() throws IOException { + void getInputStreamForDir() { PathResource resource = new PathResource(TEST_DIR); assertThatExceptionOfType(FileNotFoundException.class).isThrownBy(resource::getInputStream); } @Test - void getInputStreamForNonExistingFile() throws IOException { + void getInputStreamForNonExistingFile() { PathResource resource = new PathResource(NON_EXISTING_FILE); assertThatExceptionOfType(FileNotFoundException.class).isThrownBy(resource::getInputStream); } @@ -192,7 +192,7 @@ class PathResourceTests { } @Test - void getFileUnsupported() throws IOException { + void getFileUnsupported() { Path path = mock(); given(path.normalize()).willReturn(path); given(path.toFile()).willThrow(new UnsupportedOperationException()); @@ -222,13 +222,13 @@ class PathResourceTests { } @Test - void createRelativeFromDir() throws IOException { + void createRelativeFromDir() { Resource resource = new PathResource(TEST_DIR).createRelative("example.properties"); assertThat(resource).isEqualTo(new PathResource(TEST_FILE)); } @Test - void createRelativeFromFile() throws IOException { + void createRelativeFromFile() { Resource resource = new PathResource(TEST_FILE).createRelative("../example.properties"); assertThat(resource).isEqualTo(new PathResource(TEST_FILE)); } @@ -316,7 +316,7 @@ class PathResourceTests { } @Test - void getReadableByteChannelForNonExistingFile() throws IOException { + void getReadableByteChannelForNonExistingFile() { PathResource resource = new PathResource(NON_EXISTING_FILE); assertThatExceptionOfType(FileNotFoundException.class).isThrownBy(resource::readableChannel); } diff --git a/spring-core/src/test/java/org/springframework/core/io/ResourceTests.java b/spring-core/src/test/java/org/springframework/core/io/ResourceTests.java index e1b83797462..7d89a396def 100644 --- a/spring-core/src/test/java/org/springframework/core/io/ResourceTests.java +++ b/spring-core/src/test/java/org/springframework/core/io/ResourceTests.java @@ -428,7 +428,7 @@ class ResourceTests { } @Override - protected void customizeConnection(HttpURLConnection con) throws IOException { + protected void customizeConnection(HttpURLConnection con) { con.setRequestProperty("Framework-Name", "Spring"); } } @@ -436,7 +436,7 @@ class ResourceTests { class ResourceDispatcher extends Dispatcher { @Override - public MockResponse dispatch(RecordedRequest request) throws InterruptedException { + public MockResponse dispatch(RecordedRequest request) { if (request.getPath().equals("/resource")) { return switch (request.getMethod()) { case "HEAD" -> new MockResponse() diff --git a/spring-core/src/test/java/org/springframework/core/io/buffer/DataBufferTests.java b/spring-core/src/test/java/org/springframework/core/io/buffer/DataBufferTests.java index cd3dd3c5798..d56ec894210 100644 --- a/spring-core/src/test/java/org/springframework/core/io/buffer/DataBufferTests.java +++ b/spring-core/src/test/java/org/springframework/core/io/buffer/DataBufferTests.java @@ -16,7 +16,6 @@ package org.springframework.core.io.buffer; -import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.nio.ByteBuffer; @@ -675,7 +674,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - void readableByteBuffers(DataBufferFactory bufferFactory) throws IOException { + void readableByteBuffers(DataBufferFactory bufferFactory) { super.bufferFactory = bufferFactory; DataBuffer dataBuffer = this.bufferFactory.join(Arrays.asList(stringBuffer("a"), 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 02e7ec0dee2..d7cbcecbb83 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 @@ -168,7 +168,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - void readAsynchronousFileChannelError(DataBufferFactory bufferFactory) throws Exception { + void readAsynchronousFileChannelError(DataBufferFactory bufferFactory) { super.bufferFactory = bufferFactory; AsynchronousFileChannel channel = mock(); @@ -237,7 +237,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - void readResource(DataBufferFactory bufferFactory) throws Exception { + void readResource(DataBufferFactory bufferFactory) { super.bufferFactory = bufferFactory; Flux flux = DataBufferUtils.read(this.resource, super.bufferFactory, 3); @@ -246,7 +246,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - void readResourcePosition(DataBufferFactory bufferFactory) throws Exception { + void readResourcePosition(DataBufferFactory bufferFactory) { super.bufferFactory = bufferFactory; Flux flux = DataBufferUtils.read(this.resource, 9, super.bufferFactory, 3); @@ -268,7 +268,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - void readResourcePositionAndTakeUntil(DataBufferFactory bufferFactory) throws Exception { + void readResourcePositionAndTakeUntil(DataBufferFactory bufferFactory) { super.bufferFactory = bufferFactory; Resource resource = new ClassPathResource("DataBufferUtilsTests.txt", getClass()); @@ -285,7 +285,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - void readByteArrayResourcePositionAndTakeUntil(DataBufferFactory bufferFactory) throws Exception { + void readByteArrayResourcePositionAndTakeUntil(DataBufferFactory bufferFactory) { super.bufferFactory = bufferFactory; Resource resource = new ByteArrayResource("foobarbazqux" .getBytes()); diff --git a/spring-core/src/test/java/org/springframework/core/io/support/PropertySourceProcessorTests.java b/spring-core/src/test/java/org/springframework/core/io/support/PropertySourceProcessorTests.java index a19e88529b5..5884f286cb7 100644 --- a/spring-core/src/test/java/org/springframework/core/io/support/PropertySourceProcessorTests.java +++ b/spring-core/src/test/java/org/springframework/core/io/support/PropertySourceProcessorTests.java @@ -137,7 +137,7 @@ class PropertySourceProcessorTests { private static class IllegalArgumentExceptionPropertySourceFactory implements PropertySourceFactory { @Override - public PropertySource createPropertySource(String name, EncodedResource resource) throws IOException { + public PropertySource createPropertySource(String name, EncodedResource resource) { throw new IllegalArgumentException("bogus"); } } diff --git a/spring-core/src/test/java/org/springframework/core/style/SimpleValueStylerTests.java b/spring-core/src/test/java/org/springframework/core/style/SimpleValueStylerTests.java index 83f56e42888..e0d013d22b6 100644 --- a/spring-core/src/test/java/org/springframework/core/style/SimpleValueStylerTests.java +++ b/spring-core/src/test/java/org/springframework/core/style/SimpleValueStylerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 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,7 @@ class SimpleValueStylerTests { private final SimpleValueStyler styler = new SimpleValueStyler(); @Test - void styleBasics() throws NoSuchMethodException { + void styleBasics() { assertThat(styler.style(null)).isEqualTo("null"); assertThat(styler.style(true)).isEqualTo("true"); assertThat(styler.style(99.9)).isEqualTo("99.9"); diff --git a/spring-core/src/test/java/org/springframework/core/testfixture/TestGroupTests.java b/spring-core/src/test/java/org/springframework/core/testfixture/TestGroupTests.java index 0a04ce34c32..65e742cd991 100644 --- a/spring-core/src/test/java/org/springframework/core/testfixture/TestGroupTests.java +++ b/spring-core/src/test/java/org/springframework/core/testfixture/TestGroupTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2023 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.testfixture; import java.util.Arrays; +import java.util.Objects; import java.util.Set; import org.junit.jupiter.api.AfterEach; @@ -52,12 +53,7 @@ class TestGroupTests { @AfterEach void restoreOriginalTestGroups() { - if (this.originalTestGroups != null) { - setTestGroups(this.originalTestGroups); - } - else { - setTestGroups(""); - } + setTestGroups(Objects.requireNonNullElse(this.originalTestGroups, "")); } @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 a0458f39209..98e238fbc6f 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 @@ -38,7 +38,7 @@ import static org.assertj.core.api.Assertions.entry; public abstract class AbstractAnnotationMetadataTests { @Test - public void verifyEquals() throws Exception { + public 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() throws Exception { + public void verifyHashCode() { AnnotationMetadata testClass1 = get(TestClass.class); AnnotationMetadata testClass2 = get(TestClass.class); AnnotationMetadata testMemberClass1 = get(TestMemberClass.class); @@ -74,7 +74,7 @@ public abstract class AbstractAnnotationMetadataTests { } @Test - public void verifyToString() throws Exception { + public void verifyToString() { assertThat(get(TestClass.class).toString()).isEqualTo(TestClass.class.getName()); } 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 99763d7cb67..dee457340ca 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 @@ -38,7 +38,7 @@ import static org.assertj.core.api.Assertions.entry; public abstract class AbstractMethodMetadataTests { @Test - public void verifyEquals() throws Exception { + public 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() throws Exception { + public 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() throws Exception { + public void verifyToString() { assertThat(getTagged(WithMethod.class).toString()) .endsWith(WithMethod.class.getName() + ".test()"); 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 c28af174d13..5d93cb8de26 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 @@ -297,7 +297,7 @@ class AnnotationMetadataTests { * behaves the same. */ @Test // gh-31041 - void multipleComposedRepeatableAnnotationsUsingAnnotatedElementUtils() throws Exception { + void multipleComposedRepeatableAnnotationsUsingAnnotatedElementUtils() { Class element = MultipleComposedRepeatableAnnotationsClass.class; Set annotations = AnnotatedElementUtils.getMergedRepeatableAnnotations(element, TestComponentScan.class); @@ -313,7 +313,7 @@ class AnnotationMetadataTests { * behaves the same. */ @Test // gh-31041 - void multipleRepeatableAnnotationsInContainersUsingAnnotatedElementUtils() throws Exception { + void multipleRepeatableAnnotationsInContainersUsingAnnotatedElementUtils() { Class element = MultipleRepeatableAnnotationsInContainersClass.class; Set annotations = AnnotatedElementUtils.getMergedRepeatableAnnotations(element, TestComponentScan.class); diff --git a/spring-core/src/test/java/org/springframework/util/AntPathMatcherTests.java b/spring-core/src/test/java/org/springframework/util/AntPathMatcherTests.java index 971f4b105e3..0771586b03c 100644 --- a/spring-core/src/test/java/org/springframework/util/AntPathMatcherTests.java +++ b/spring-core/src/test/java/org/springframework/util/AntPathMatcherTests.java @@ -143,7 +143,7 @@ class AntPathMatcherTests { // SPR-14247 @Test - void matchWithTrimTokensEnabled() throws Exception { + void matchWithTrimTokensEnabled() { pathMatcher.setTrimTokens(true); assertThat(pathMatcher.match("/foo/bar", "/foo /bar")).isTrue(); @@ -299,7 +299,7 @@ class AntPathMatcherTests { } @Test - void extractPathWithinPattern() throws Exception { + void extractPathWithinPattern() { assertThat(pathMatcher.extractPathWithinPattern("/docs/commit.html", "/docs/commit.html")).isEmpty(); assertThat(pathMatcher.extractPathWithinPattern("/docs/*", "/docs/cvs/commit")).isEqualTo("cvs/commit"); @@ -325,7 +325,7 @@ class AntPathMatcherTests { } @Test - void extractUriTemplateVariables() throws Exception { + void extractUriTemplateVariables() { Map result = pathMatcher.extractUriTemplateVariables("/hotels/{hotel}", "/hotels/1"); assertThat(result).isEqualTo(Collections.singletonMap("hotel", "1")); diff --git a/spring-core/src/test/java/org/springframework/util/AutoPopulatingListTests.java b/spring-core/src/test/java/org/springframework/util/AutoPopulatingListTests.java index 26bf722899b..369d37c9c76 100644 --- a/spring-core/src/test/java/org/springframework/util/AutoPopulatingListTests.java +++ b/spring-core/src/test/java/org/springframework/util/AutoPopulatingListTests.java @@ -32,22 +32,22 @@ import static org.assertj.core.api.Assertions.assertThat; class AutoPopulatingListTests { @Test - void withClass() throws Exception { + void withClass() { doTestWithClass(new AutoPopulatingList<>(TestObject.class)); } @Test - void withClassAndUserSuppliedBackingList() throws Exception { - doTestWithClass(new AutoPopulatingList(new ArrayList<>(), TestObject.class)); + void withClassAndUserSuppliedBackingList() { + doTestWithClass(new AutoPopulatingList<>(new ArrayList<>(), TestObject.class)); } @Test - void withElementFactory() throws Exception { + void withElementFactory() { doTestWithElementFactory(new AutoPopulatingList<>(new MockElementFactory())); } @Test - void withElementFactoryAndUserSuppliedBackingList() throws Exception { + void withElementFactoryAndUserSuppliedBackingList() { doTestWithElementFactory(new AutoPopulatingList<>(new ArrayList<>(), new MockElementFactory())); } diff --git a/spring-core/src/test/java/org/springframework/util/CollectionUtilsTests.java b/spring-core/src/test/java/org/springframework/util/CollectionUtilsTests.java index 8d2cb0972b0..3d73b322f9d 100644 --- a/spring-core/src/test/java/org/springframework/util/CollectionUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/util/CollectionUtilsTests.java @@ -118,7 +118,7 @@ class CollectionUtilsTests { } @Test - void containsAny() throws Exception { + void containsAny() { List source = new ArrayList<>(); source.add("abc"); source.add("def"); @@ -137,19 +137,19 @@ class CollectionUtilsTests { } @Test - void containsInstanceWithNullCollection() throws Exception { + void containsInstanceWithNullCollection() { assertThat(CollectionUtils.containsInstance(null, this)).as("Must return false if supplied Collection argument is null").isFalse(); } @Test - void containsInstanceWithInstancesThatAreEqualButDistinct() throws Exception { + void containsInstanceWithInstancesThatAreEqualButDistinct() { List list = new ArrayList<>(); list.add(new Instance("fiona")); assertThat(CollectionUtils.containsInstance(list, new Instance("fiona"))).as("Must return false if instance is not in the supplied Collection argument").isFalse(); } @Test - void containsInstanceWithSameInstance() throws Exception { + void containsInstanceWithSameInstance() { List list = new ArrayList<>(); list.add(new Instance("apple")); Instance instance = new Instance("fiona"); @@ -158,7 +158,7 @@ class CollectionUtilsTests { } @Test - void containsInstanceWithNullInstance() throws Exception { + void containsInstanceWithNullInstance() { List list = new ArrayList<>(); list.add(new Instance("apple")); list.add(new Instance("fiona")); @@ -166,7 +166,7 @@ class CollectionUtilsTests { } @Test - void findFirstMatch() throws Exception { + void findFirstMatch() { List source = new ArrayList<>(); source.add("abc"); source.add("def"); diff --git a/spring-core/src/test/java/org/springframework/util/FileSystemUtilsTests.java b/spring-core/src/test/java/org/springframework/util/FileSystemUtilsTests.java index e89c999055e..c121d1a3375 100644 --- a/spring-core/src/test/java/org/springframework/util/FileSystemUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/util/FileSystemUtilsTests.java @@ -80,7 +80,7 @@ class FileSystemUtilsTests { @AfterEach - void tearDown() throws Exception { + void tearDown() { File tmp = new File("./tmp"); if (tmp.exists()) { FileSystemUtils.deleteRecursively(tmp); diff --git a/spring-core/src/test/java/org/springframework/util/MethodInvokerTests.java b/spring-core/src/test/java/org/springframework/util/MethodInvokerTests.java index 13d265d5707..c0e20c1c8ca 100644 --- a/spring-core/src/test/java/org/springframework/util/MethodInvokerTests.java +++ b/spring-core/src/test/java/org/springframework/util/MethodInvokerTests.java @@ -80,7 +80,7 @@ class MethodInvokerTests { } @Test - void stringWithMethodInvoker() throws Exception { + void stringWithMethodInvoker() { MethodInvoker methodInvoker = new MethodInvoker(); methodInvoker.setTargetObject(new Greeter()); methodInvoker.setTargetMethod("greet"); diff --git a/spring-core/src/test/java/org/springframework/util/NumberUtilsTests.java b/spring-core/src/test/java/org/springframework/util/NumberUtilsTests.java index 5c07daf8d06..714e9de0085 100644 --- a/spring-core/src/test/java/org/springframework/util/NumberUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/util/NumberUtilsTests.java @@ -104,8 +104,8 @@ class NumberUtilsTests { @Test void parseNumberAsHex() { - String aByte = "0x" + Integer.toHexString(Byte.valueOf(Byte.MAX_VALUE)); - String aShort = "0x" + Integer.toHexString(Short.valueOf(Short.MAX_VALUE)); + String aByte = "0x" + Integer.toHexString(Byte.MAX_VALUE); + String aShort = "0x" + Integer.toHexString(Short.MAX_VALUE); String anInteger = "0x" + Integer.toHexString(Integer.MAX_VALUE); String aLong = "0x" + Long.toHexString(Long.MAX_VALUE); String aReallyBigInt = "FEBD4E677898DFEBFFEE44"; @@ -283,7 +283,7 @@ class NumberUtilsTests { assertThat(NumberUtils.convertNumberToTargetClass((long) -1, Integer.class)).isEqualTo(Integer.valueOf(-1)); assertThat(NumberUtils.convertNumberToTargetClass(0L, Integer.class)).isEqualTo(Integer.valueOf(0)); assertThat(NumberUtils.convertNumberToTargetClass(1L, Integer.class)).isEqualTo(Integer.valueOf(1)); - assertThat(NumberUtils.convertNumberToTargetClass(Long.valueOf(Integer.MAX_VALUE), Integer.class)).isEqualTo(Integer.valueOf(Integer.MAX_VALUE)); + assertThat(NumberUtils.convertNumberToTargetClass((long) Integer.MAX_VALUE, Integer.class)).isEqualTo(Integer.valueOf(Integer.MAX_VALUE)); assertThat(NumberUtils.convertNumberToTargetClass((long) (Integer.MAX_VALUE + 1), Integer.class)).isEqualTo(Integer.valueOf(Integer.MIN_VALUE)); assertThat(NumberUtils.convertNumberToTargetClass((long) Integer.MIN_VALUE, Integer.class)).isEqualTo(Integer.valueOf(Integer.MIN_VALUE)); assertThat(NumberUtils.convertNumberToTargetClass((long) (Integer.MIN_VALUE - 1), Integer.class)).isEqualTo(Integer.valueOf(Integer.MAX_VALUE)); diff --git a/spring-core/src/test/java/org/springframework/util/ReflectionUtilsTests.java b/spring-core/src/test/java/org/springframework/util/ReflectionUtilsTests.java index 28214a352cd..c962f096d0a 100644 --- a/spring-core/src/test/java/org/springframework/util/ReflectionUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/util/ReflectionUtilsTests.java @@ -334,7 +334,7 @@ class ReflectionUtilsTests { private List methods = new ArrayList<>(); @Override - public void doWith(Method m) throws IllegalArgumentException, IllegalAccessException { + public void doWith(Method m) throws IllegalArgumentException { this.methodNames.add(m.getName()); this.methods.add(m); } @@ -378,7 +378,7 @@ class ReflectionUtilsTests { private static class A { - @SuppressWarnings("unused") + @SuppressWarnings({ "unused", "RedundantThrows" }) private void foo(Integer i) throws RemoteException { } } diff --git a/spring-core/src/test/java/org/springframework/util/ResourceUtilsTests.java b/spring-core/src/test/java/org/springframework/util/ResourceUtilsTests.java index dc7b8339ac7..634969566d8 100644 --- a/spring-core/src/test/java/org/springframework/util/ResourceUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/util/ResourceUtilsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2023 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,7 +16,6 @@ package org.springframework.util; -import java.io.IOException; import java.net.URL; import java.net.URLConnection; import java.net.URLStreamHandler; @@ -77,7 +76,7 @@ class ResourceUtilsTests { private static class DummyURLStreamHandler extends URLStreamHandler { @Override - protected URLConnection openConnection(URL url) throws IOException { + protected URLConnection openConnection(URL url) { throw new UnsupportedOperationException(); } } 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 a24031a4608..cc294e12469 100644 --- a/spring-core/src/test/java/org/springframework/util/UnmodifiableMultiValueMapTests.java +++ b/spring-core/src/test/java/org/springframework/util/UnmodifiableMultiValueMapTests.java @@ -95,7 +95,7 @@ class UnmodifiableMultiValueMapTests { () -> map.computeIfPresent("foo", (s1, s2) -> List.of("bar"))); assertThatUnsupportedOperationException().isThrownBy(() -> map.compute("foo", (s1, s2) -> List.of("bar"))); assertThatUnsupportedOperationException().isThrownBy(() -> map.merge("foo", List.of("bar"), (s1, s2) -> s1)); - assertThatUnsupportedOperationException().isThrownBy(() -> map.clear()); + assertThatUnsupportedOperationException().isThrownBy(map::clear); } @Test @@ -137,7 +137,7 @@ class UnmodifiableMultiValueMapTests { assertThatUnsupportedOperationException().isThrownBy(() -> set.addAll(mock(List.class))); assertThatUnsupportedOperationException().isThrownBy(() -> set.retainAll(mock(List.class))); assertThatUnsupportedOperationException().isThrownBy(() -> set.removeAll(mock(List.class))); - assertThatUnsupportedOperationException().isThrownBy(() -> set.clear()); + assertThatUnsupportedOperationException().isThrownBy(set::clear); } @Test @@ -177,7 +177,7 @@ class UnmodifiableMultiValueMapTests { assertThatUnsupportedOperationException().isThrownBy(() -> values.removeAll(List.of(List.of("foo")))); assertThatUnsupportedOperationException().isThrownBy(() -> values.retainAll(List.of(List.of("foo")))); assertThatUnsupportedOperationException().isThrownBy(() -> values.removeIf(s -> true)); - assertThatUnsupportedOperationException().isThrownBy(() -> values.clear()); + assertThatUnsupportedOperationException().isThrownBy(values::clear); } private static ThrowableTypeAssert assertThatUnsupportedOperationException() { diff --git a/spring-core/src/test/java/org/springframework/util/comparator/InstanceComparatorTests.java b/spring-core/src/test/java/org/springframework/util/comparator/InstanceComparatorTests.java index 4d417c41310..fb1a015a26f 100644 --- a/spring-core/src/test/java/org/springframework/util/comparator/InstanceComparatorTests.java +++ b/spring-core/src/test/java/org/springframework/util/comparator/InstanceComparatorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2023 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. @@ -39,7 +39,7 @@ class InstanceComparatorTests { private C4 c4 = new C4(); @Test - void shouldCompareClasses() throws Exception { + void shouldCompareClasses() { Comparator comparator = new InstanceComparator<>(C1.class, C2.class); assertThat(comparator.compare(c1, c1)).isEqualTo(0); assertThat(comparator.compare(c1, c2)).isEqualTo(-1); @@ -50,7 +50,7 @@ class InstanceComparatorTests { } @Test - void shouldCompareInterfaces() throws Exception { + void shouldCompareInterfaces() { Comparator comparator = new InstanceComparator<>(I1.class, I2.class); assertThat(comparator.compare(c1, c1)).isEqualTo(0); assertThat(comparator.compare(c1, c2)).isEqualTo(0); @@ -61,7 +61,7 @@ class InstanceComparatorTests { } @Test - void shouldCompareMix() throws Exception { + void shouldCompareMix() { Comparator comparator = new InstanceComparator<>(I1.class, C3.class); assertThat(comparator.compare(c1, c1)).isEqualTo(0); assertThat(comparator.compare(c3, c4)).isEqualTo(-1); 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 b892d64ece3..e3e8bbc18bd 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 @@ -16,7 +16,6 @@ package org.springframework.util.concurrent; -import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; @@ -37,7 +36,7 @@ class FutureAdapterTests { private FutureAdapter adapter = new FutureAdapter<>(adaptee) { @Override - protected String adapt(Integer adapteeResult) throws ExecutionException { + protected String adapt(Integer adapteeResult) { return adapteeResult.toString(); } }; 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 815fdfbf731..db2f95e5723 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 @@ -42,11 +42,12 @@ class ListenableFutureTaskTests { Callable callable = () -> s; ListenableFutureTask task = new ListenableFutureTask<>(callable); - task.addCallback(new ListenableFutureCallback() { + task.addCallback(new ListenableFutureCallback<>() { @Override public void onSuccess(String result) { assertThat(result).isEqualTo(s); } + @Override public void onFailure(Throwable ex) { throw new AssertionError(ex.getMessage(), ex); @@ -60,18 +61,19 @@ class ListenableFutureTaskTests { } @Test - void failure() throws Exception { + void failure() { final String s = "Hello World"; Callable callable = () -> { throw new IOException(s); }; ListenableFutureTask task = new ListenableFutureTask<>(callable); - task.addCallback(new ListenableFutureCallback() { + task.addCallback(new ListenableFutureCallback<>() { @Override public void onSuccess(String result) { fail("onSuccess not expected"); } + @Override public void onFailure(Throwable ex) { assertThat(ex.getMessage()).isEqualTo(s); @@ -108,7 +110,7 @@ class ListenableFutureTaskTests { } @Test - void failureWithLambdas() throws Exception { + void failureWithLambdas() { final String s = "Hello World"; IOException ex = new IOException(s); Callable callable = () -> { diff --git a/spring-core/src/test/java/org/springframework/util/concurrent/SettableListenableFutureTests.java b/spring-core/src/test/java/org/springframework/util/concurrent/SettableListenableFutureTests.java index 36da800a8af..5fd9af58305 100644 --- a/spring-core/src/test/java/org/springframework/util/concurrent/SettableListenableFutureTests.java +++ b/spring-core/src/test/java/org/springframework/util/concurrent/SettableListenableFutureTests.java @@ -75,7 +75,7 @@ class SettableListenableFutureTests { } @Test - void throwsSetExceptionWrappedInExecutionException() throws Exception { + void throwsSetExceptionWrappedInExecutionException() { Throwable exception = new RuntimeException(); assertThat(settableListenableFuture.setException(exception)).isTrue(); @@ -88,7 +88,7 @@ class SettableListenableFutureTests { } @Test - void throwsSetExceptionWrappedInExecutionExceptionFromCompletable() throws Exception { + void throwsSetExceptionWrappedInExecutionExceptionFromCompletable() { Throwable exception = new RuntimeException(); assertThat(settableListenableFuture.setException(exception)).isTrue(); Future completable = settableListenableFuture.completable(); @@ -102,7 +102,7 @@ class SettableListenableFutureTests { } @Test - void throwsSetErrorWrappedInExecutionException() throws Exception { + void throwsSetErrorWrappedInExecutionException() { Throwable exception = new OutOfMemoryError(); assertThat(settableListenableFuture.setException(exception)).isTrue(); @@ -115,7 +115,7 @@ class SettableListenableFutureTests { } @Test - void throwsSetErrorWrappedInExecutionExceptionFromCompletable() throws Exception { + void throwsSetErrorWrappedInExecutionExceptionFromCompletable() { Throwable exception = new OutOfMemoryError(); assertThat(settableListenableFuture.setException(exception)).isTrue(); Future completable = settableListenableFuture.completable(); @@ -133,11 +133,12 @@ class SettableListenableFutureTests { String string = "hello"; final String[] callbackHolder = new String[1]; - settableListenableFuture.addCallback(new ListenableFutureCallback() { + settableListenableFuture.addCallback(new ListenableFutureCallback<>() { @Override public void onSuccess(String result) { callbackHolder[0] = result; } + @Override public void onFailure(Throwable ex) { throw new AssertionError("Expected onSuccess() to be called", ex); @@ -155,11 +156,12 @@ class SettableListenableFutureTests { String string = "hello"; final String[] callbackHolder = new String[1]; - settableListenableFuture.addCallback(new ListenableFutureCallback() { + settableListenableFuture.addCallback(new ListenableFutureCallback<>() { @Override public void onSuccess(String result) { callbackHolder[0] = result; } + @Override public void onFailure(Throwable ex) { throw new AssertionError("Expected onSuccess() to be called", ex); @@ -178,11 +180,12 @@ class SettableListenableFutureTests { Throwable exception = new RuntimeException(); final Throwable[] callbackHolder = new Throwable[1]; - settableListenableFuture.addCallback(new ListenableFutureCallback() { + settableListenableFuture.addCallback(new ListenableFutureCallback<>() { @Override public void onSuccess(String result) { fail("Expected onFailure() to be called"); } + @Override public void onFailure(Throwable ex) { callbackHolder[0] = ex; @@ -200,11 +203,12 @@ class SettableListenableFutureTests { Throwable exception = new RuntimeException(); final Throwable[] callbackHolder = new Throwable[1]; - settableListenableFuture.addCallback(new ListenableFutureCallback() { + settableListenableFuture.addCallback(new ListenableFutureCallback<>() { @Override public void onSuccess(String result) { fail("Expected onFailure() to be called"); } + @Override public void onFailure(Throwable ex) { callbackHolder[0] = ex; @@ -247,7 +251,7 @@ class SettableListenableFutureTests { } @Test - void getWithTimeoutThrowsTimeoutException() throws ExecutionException, InterruptedException { + void getWithTimeoutThrowsTimeoutException() { assertThatExceptionOfType(TimeoutException.class).isThrownBy(() -> settableListenableFuture.get(1L, TimeUnit.MILLISECONDS)); } @@ -330,7 +334,7 @@ class SettableListenableFutureTests { } @Test - void cancelStateThrowsExceptionWhenCallingGet() throws ExecutionException, InterruptedException { + void cancelStateThrowsExceptionWhenCallingGet() { settableListenableFuture.cancel(true); assertThatExceptionOfType(CancellationException.class).isThrownBy(settableListenableFuture::get); @@ -340,7 +344,7 @@ class SettableListenableFutureTests { } @Test - void cancelStateThrowsExceptionWhenCallingGetWithTimeout() throws ExecutionException, TimeoutException, InterruptedException { + void cancelStateThrowsExceptionWhenCallingGetWithTimeout() { new Thread(() -> { try { Thread.sleep(20L); diff --git a/spring-core/src/test/java/org/springframework/util/function/ThrowingBiFunctionTests.java b/spring-core/src/test/java/org/springframework/util/function/ThrowingBiFunctionTests.java index 93d4a55a2bf..07c2e6c85a9 100644 --- a/spring-core/src/test/java/org/springframework/util/function/ThrowingBiFunctionTests.java +++ b/spring-core/src/test/java/org/springframework/util/function/ThrowingBiFunctionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 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. @@ -80,7 +80,7 @@ class ThrowingBiFunctionTests { throw new IOException(); } - private Object throwIllegalArgumentException(Object o, Object u) throws IOException { + private Object throwIllegalArgumentException(Object o, Object u) { throw new IllegalArgumentException(); } diff --git a/spring-core/src/test/java/org/springframework/util/function/ThrowingConsumerTests.java b/spring-core/src/test/java/org/springframework/util/function/ThrowingConsumerTests.java index d1892d1d5a8..2d60b43ea90 100644 --- a/spring-core/src/test/java/org/springframework/util/function/ThrowingConsumerTests.java +++ b/spring-core/src/test/java/org/springframework/util/function/ThrowingConsumerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 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. @@ -80,7 +80,7 @@ class ThrowingConsumerTests { throw new IOException(); } - private void throwIllegalArgumentException(Object o) throws IOException { + private void throwIllegalArgumentException(Object o) { throw new IllegalArgumentException(); } diff --git a/spring-core/src/test/java/org/springframework/util/function/ThrowingFunctionTests.java b/spring-core/src/test/java/org/springframework/util/function/ThrowingFunctionTests.java index c985c23954a..389ea284d78 100644 --- a/spring-core/src/test/java/org/springframework/util/function/ThrowingFunctionTests.java +++ b/spring-core/src/test/java/org/springframework/util/function/ThrowingFunctionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 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. @@ -80,7 +80,7 @@ class ThrowingFunctionTests { throw new IOException(); } - private Object throwIllegalArgumentException(Object o) throws IOException { + private Object throwIllegalArgumentException(Object o) { throw new IllegalArgumentException(); } diff --git a/spring-core/src/test/java/org/springframework/util/function/ThrowingSupplierTests.java b/spring-core/src/test/java/org/springframework/util/function/ThrowingSupplierTests.java index 7e9ded1255b..ab6a0e5957f 100644 --- a/spring-core/src/test/java/org/springframework/util/function/ThrowingSupplierTests.java +++ b/spring-core/src/test/java/org/springframework/util/function/ThrowingSupplierTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 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. @@ -66,7 +66,7 @@ class ThrowingSupplierTests { ThrowingSupplier modified = supplier.throwing( IllegalStateException::new); assertThatIllegalStateException().isThrownBy( - () -> modified.get()).withCauseInstanceOf(IOException.class); + modified::get).withCauseInstanceOf(IOException.class); } @Test @@ -74,14 +74,14 @@ class ThrowingSupplierTests { ThrowingSupplier supplier = ThrowingSupplier.of( this::throwIOException, IllegalStateException::new); assertThatIllegalStateException().isThrownBy( - () -> supplier.get()).withCauseInstanceOf(IOException.class); + supplier::get).withCauseInstanceOf(IOException.class); } private Object throwIOException() throws IOException { throw new IOException(); } - private Object throwIllegalArgumentException() throws IOException { + private Object throwIllegalArgumentException() { throw new IllegalArgumentException(); } 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 655a6343976..a76d1f47de6 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 @@ -243,7 +243,7 @@ abstract class AbstractStaxXMLReaderTests { private static class CopyCharsAnswer implements Answer { @Override - public Object answer(InvocationOnMock invocation) throws Throwable { + public Object answer(InvocationOnMock invocation) { char[] chars = (char[]) invocation.getArguments()[0]; char[] copy = new char[chars.length]; System.arraycopy(chars, 0, copy, 0, chars.length); diff --git a/spring-core/src/test/java/org/springframework/util/xml/SimpleNamespaceContextTests.java b/spring-core/src/test/java/org/springframework/util/xml/SimpleNamespaceContextTests.java index 5eb06f5eca0..8b1695b109e 100644 --- a/spring-core/src/test/java/org/springframework/util/xml/SimpleNamespaceContextTests.java +++ b/spring-core/src/test/java/org/springframework/util/xml/SimpleNamespaceContextTests.java @@ -45,7 +45,7 @@ class SimpleNamespaceContextTests { @Test - void getNamespaceURI_withNull() throws Exception { + void getNamespaceURI_withNull() { assertThatIllegalArgumentException().isThrownBy(() -> context.getNamespaceURI(null)); } @@ -77,7 +77,7 @@ class SimpleNamespaceContextTests { } @Test - void getPrefix_withNull() throws Exception { + void getPrefix_withNull() { assertThatIllegalArgumentException().isThrownBy(() -> context.getPrefix(null)); } @@ -100,13 +100,13 @@ class SimpleNamespaceContextTests { } @Test - void getPrefixes_withNull() throws Exception { + void getPrefixes_withNull() { assertThatIllegalArgumentException().isThrownBy(() -> context.getPrefixes(null)); } @Test - void getPrefixes_IteratorIsNotModifiable() throws Exception { + void getPrefixes_IteratorIsNotModifiable() { context.bindNamespaceUri(prefix, namespaceUri); Iterator iterator = context.getPrefixes(namespaceUri); assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy( diff --git a/spring-core/src/test/java/org/springframework/util/xml/StaxUtilsTests.java b/spring-core/src/test/java/org/springframework/util/xml/StaxUtilsTests.java index 959bc0b8fb0..327248dd846 100644 --- a/spring-core/src/test/java/org/springframework/util/xml/StaxUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/util/xml/StaxUtilsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2023 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 @@ import static org.assertj.core.api.Assertions.assertThat; class StaxUtilsTests { @Test - void isStaxSourceInvalid() throws Exception { + void isStaxSourceInvalid() { assertThat(StaxUtils.isStaxSource(new DOMSource())).as("A StAX Source").isFalse(); assertThat(StaxUtils.isStaxSource(new SAXSource())).as("A StAX Source").isFalse(); assertThat(StaxUtils.isStaxSource(new StreamSource())).as("A StAX Source").isFalse(); @@ -71,7 +71,7 @@ class StaxUtilsTests { } @Test - void isStaxResultInvalid() throws Exception { + void isStaxResultInvalid() { assertThat(StaxUtils.isStaxResult(new DOMResult())).as("A StAX Result").isFalse(); assertThat(StaxUtils.isStaxResult(new SAXResult())).as("A StAX Result").isFalse(); assertThat(StaxUtils.isStaxResult(new StreamResult())).as("A StAX Result").isFalse(); diff --git a/spring-core/src/test/java/org/springframework/util/xml/TransformerUtilsTests.java b/spring-core/src/test/java/org/springframework/util/xml/TransformerUtilsTests.java index b4de128c01c..227a4440ae2 100644 --- a/spring-core/src/test/java/org/springframework/util/xml/TransformerUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/util/xml/TransformerUtilsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2023 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. @@ -40,7 +40,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException class TransformerUtilsTests { @Test - void enableIndentingSunnyDay() throws Exception { + void enableIndentingSunnyDay() { Transformer transformer = new StubTransformer(); TransformerUtils.enableIndenting(transformer); String indent = transformer.getOutputProperty(OutputKeys.INDENT); @@ -52,7 +52,7 @@ class TransformerUtilsTests { } @Test - void enableIndentingSunnyDayWithCustomKosherIndentAmount() throws Exception { + void enableIndentingSunnyDayWithCustomKosherIndentAmount() { final String indentAmountProperty = "10"; Transformer transformer = new StubTransformer(); TransformerUtils.enableIndenting(transformer, Integer.parseInt(indentAmountProperty)); @@ -65,7 +65,7 @@ class TransformerUtilsTests { } @Test - void disableIndentingSunnyDay() throws Exception { + void disableIndentingSunnyDay() { Transformer transformer = new StubTransformer(); TransformerUtils.disableIndenting(transformer); String indent = transformer.getOutputProperty(OutputKeys.INDENT); @@ -74,25 +74,25 @@ class TransformerUtilsTests { } @Test - void enableIndentingWithNullTransformer() throws Exception { + void enableIndentingWithNullTransformer() { assertThatIllegalArgumentException().isThrownBy(() -> TransformerUtils.enableIndenting(null)); } @Test - void disableIndentingWithNullTransformer() throws Exception { + void disableIndentingWithNullTransformer() { assertThatIllegalArgumentException().isThrownBy(() -> TransformerUtils.disableIndenting(null)); } @Test - void enableIndentingWithNegativeIndentAmount() throws Exception { + void enableIndentingWithNegativeIndentAmount() { assertThatIllegalArgumentException().isThrownBy(() -> TransformerUtils.enableIndenting(new StubTransformer(), -21938)); } @Test - void enableIndentingWithZeroIndentAmount() throws Exception { + void enableIndentingWithZeroIndentAmount() { TransformerUtils.enableIndenting(new StubTransformer(), 0); }