This commit is contained in:
Stéphane Nicoll 2023-12-16 10:25:18 +01:00
parent b56fc50c27
commit 22bf4df290
52 changed files with 281 additions and 290 deletions

View File

@ -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;
}
}

View File

@ -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);

View File

@ -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<T> {
public Class<T> getPersistentClass();
Class<T> getPersistentClass();
List<T> findByQuery();
@ -884,7 +884,7 @@ class BridgeMethodResolverTests {
return null;
}
public void afterPropertiesSet() throws Exception {
public void afterPropertiesSet() {
}
}

View File

@ -306,7 +306,7 @@ class CollectionFactoryTests {
enum Color {
RED, BLUE;
RED, BLUE
}
}

View File

@ -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<Object> 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));
}

View File

@ -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<? extends Throwable> foundClass = findClosestMatch(TargetException.class, SameDepthException.class);
assertThat(foundClass).isEqualTo(TargetException.class);
}
@Test
void sameDepthBeforeTarget() throws Exception {
void sameDepthBeforeTarget() {
Class<? extends Throwable> foundClass = findClosestMatch(SameDepthException.class, TargetException.class);
assertThat(foundClass).isEqualTo(TargetException.class);
}
@Test
void lowestDepthBeforeTarget() throws Exception {
void lowestDepthBeforeTarget() {
Class<? extends Throwable> foundClass = findClosestMatch(LowestDepthException.class, TargetException.class);
assertThat(foundClass).isEqualTo(TargetException.class);
}
@Test
void targetBeforeLowestDepth() throws Exception {
void targetBeforeLowestDepth() {
Class<? extends Throwable> foundClass = findClosestMatch(TargetException.class, LowestDepthException.class);
assertThat(foundClass).isEqualTo(TargetException.class);
}
@Test
void noDepthBeforeTarget() throws Exception {
void noDepthBeforeTarget() {
Class<? extends Throwable> foundClass = findClosestMatch(NoDepthException.class, TargetException.class);
assertThat(foundClass).isEqualTo(TargetException.class);
}
@Test
void noDepthBeforeHighestDepth() throws Exception {
void noDepthBeforeHighestDepth() {
Class<? extends Throwable> foundClass = findClosestMatch(NoDepthException.class, HighestDepthException.class);
assertThat(foundClass).isEqualTo(HighestDepthException.class);
}
@Test
void highestDepthBeforeNoDepth() throws Exception {
void highestDepthBeforeNoDepth() {
Class<? extends Throwable> foundClass = findClosestMatch(HighestDepthException.class, NoDepthException.class);
assertThat(foundClass).isEqualTo(HighestDepthException.class);
}
@Test
void highestDepthBeforeLowestDepth() throws Exception {
void highestDepthBeforeLowestDepth() {
Class<? extends Throwable> foundClass = findClosestMatch(HighestDepthException.class, LowestDepthException.class);
assertThat(foundClass).isEqualTo(LowestDepthException.class);
}
@Test
void lowestDepthBeforeHighestDepth() throws Exception {
void lowestDepthBeforeHighestDepth() {
Class<? extends Throwable> foundClass = findClosestMatch(LowestDepthException.class, HighestDepthException.class);
assertThat(foundClass).isEqualTo(LowestDepthException.class);
}

View File

@ -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<String>(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<E>");
}
@Test
void asFromInheritedInterface() throws Exception {
void asFromInheritedInterface() {
ResolvableType type = ResolvableType.forClass(ExtendsList.class).as(Collection.class);
assertThat(type.getType().toString()).isEqualTo("java.util.Collection<E>");
}
@Test
void asFromSuperType() throws Exception {
void asFromSuperType() {
ResolvableType type = ResolvableType.forClass(ExtendsList.class).as(ArrayList.class);
assertThat(type.getType().toString()).isEqualTo("java.util.ArrayList<java.lang.CharSequence>");
}
@Test
void asFromInheritedSuperType() throws Exception {
void asFromInheritedSuperType() {
ResolvableType type = ResolvableType.forClass(ExtendsList.class).as(List.class);
assertThat(type.getType().toString()).isEqualTo("java.util.List<E>");
}
@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<String> 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<java.util.List<java.lang.String>>");
assertThat(type.asCollection().getGeneric().toString()).isEqualTo("java.util.List<java.lang.String>");
@ -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<java.util.Map<java.lang.Integer, java.lang.String>>");
@ -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<java.lang.Integer, java.util.List<java.lang.String>>");
}
@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);

View File

@ -752,7 +752,7 @@ class AnnotatedElementUtilsTests {
* @see <a href="https://github.com/spring-projects/spring-framework/issues/23767">#23767</a>
*/
@Test
void findMergedAnnotationAttributesOnClassWithComposedMetaTransactionalAnnotation() throws Exception {
void findMergedAnnotationAttributesOnClassWithComposedMetaTransactionalAnnotation() {
Class<?> clazz = ComposedTransactionalClass.class;
AnnotationAttributes attributes = findMergedAnnotationAttributes(clazz, AliasedTransactional.class);
@ -766,7 +766,7 @@ class AnnotatedElementUtilsTests {
* @see <a href="https://github.com/spring-projects/spring-framework/issues/23767">#23767</a>
*/
@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));
}

View File

@ -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);

View File

@ -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<ImplicitAliasesWithMissingDefaultValuesContextConfig> annotationType =
ImplicitAliasesWithMissingDefaultValuesContextConfig.class;
@ -734,7 +734,7 @@ class AnnotationUtilsTests {
}
@Test
void synthesizeAnnotationWithImplicitAliasesWithDifferentDefaultValues() throws Exception {
void synthesizeAnnotationWithImplicitAliasesWithDifferentDefaultValues() {
Class<?> clazz = ImplicitAliasesWithDifferentDefaultValuesContextConfigClass.class;
Class<ImplicitAliasesWithDifferentDefaultValuesContextConfig> annotationType =
ImplicitAliasesWithDifferentDefaultValuesContextConfig.class;
@ -749,7 +749,7 @@ class AnnotationUtilsTests {
}
@Test
void synthesizeAnnotationWithImplicitAliasesWithDuplicateValues() throws Exception {
void synthesizeAnnotationWithImplicitAliasesWithDuplicateValues() {
Class<?> clazz = ImplicitAliasesWithDuplicateValuesContextConfigClass.class;
Class<ImplicitAliasesWithDuplicateValuesContextConfig> 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<String, Object> 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<String, Object> 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<String, Object> 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<String, Object> 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<String, Object> 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();

View File

@ -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<Method> methods = new ArrayList<>();
ReflectionUtils.doWithLocalMethods(StringGenericParameter.class, method -> {
if ("getFor".equals(method.getName())) {

View File

@ -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<ImplicitAliasesWithMissingDefaultValuesTestConfiguration> annotationType =
ImplicitAliasesWithMissingDefaultValuesTestConfiguration.class;
@ -1826,8 +1825,7 @@ class MergedAnnotationsTests {
}
@Test
void synthesizeWithImplicitAliasesWithDifferentDefaultValues()
throws Exception {
void synthesizeWithImplicitAliasesWithDifferentDefaultValues() {
Class<?> clazz = ImplicitAliasesWithDifferentDefaultValuesTestConfigurationClass.class;
Class<ImplicitAliasesWithDifferentDefaultValuesTestConfiguration> annotationType =
ImplicitAliasesWithDifferentDefaultValuesTestConfiguration.class;
@ -1842,7 +1840,7 @@ class MergedAnnotationsTests {
}
@Test
void synthesizeWithImplicitAliasesWithDuplicateValues() throws Exception {
void synthesizeWithImplicitAliasesWithDuplicateValues() {
Class<?> clazz = ImplicitAliasesWithDuplicateValuesTestConfigurationClass.class;
Class<ImplicitAliasesWithDuplicateValuesTestConfiguration> 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<String, Object> 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<AnnotationWithDefaults> annotation = MergedAnnotation.of(
AnnotationWithDefaults.class);
AnnotationWithDefaults synthesized = annotation.synthesize();
@ -1925,7 +1923,7 @@ class MergedAnnotationsTests {
}
@Test
void synthesizeFromDefaultsWithAttributeAliases() throws Exception {
void synthesizeFromDefaultsWithAttributeAliases() {
MergedAnnotation<TestConfiguration> 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<String, Object> map = Collections.singletonMap("location", "test.xml");
MergedAnnotation<TestConfiguration> 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<String, Object> map = Collections.singletonMap(attributeNameAndValue,
attributeNameAndValue);
MergedAnnotation<ImplicitAliasesTestConfiguration> 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<String, Object> 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<String, Object> map = Collections.singletonMap("value", 42L);
MergedAnnotation<Component> 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<String, Object> 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();

View File

@ -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;

View File

@ -48,7 +48,7 @@ class CharSequenceEncoderTests extends AbstractEncoderTests<CharSequenceEncoder>
@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),

View File

@ -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<DataBufferDecoder> {
@Override
@Test
public void decodeToMono() throws Exception {
public void decodeToMono() {
Flux<DataBuffer> input = Flux.concat(
dataBuffer(this.fooBytes),
dataBuffer(this.barBytes));

View File

@ -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<DataBufferEncoder> {
@Override
@Test
public void encode() throws Exception {
public void encode() {
Flux<DataBuffer> input = Flux.just(this.fooBytes, this.barBytes)
.flatMap(bytes -> Mono.defer(() -> {
DataBuffer dataBuffer = this.bufferFactory.allocateBuffer(bytes.length);

View File

@ -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));
}

View File

@ -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<String, Integer>(this.comparator, null));
}
@Test
void shouldThrowOnNullConversionService() throws Exception {
void shouldThrowOnNullConversionService() {
assertThatIllegalArgumentException().isThrownBy(() ->
new ConvertingComparator<String, Integer>(this.comparator, null, Integer.class));
}
@Test
void shouldThrowOnNullType() throws Exception {
void shouldThrowOnNullType() {
assertThatIllegalArgumentException().isThrownBy(() ->
new ConvertingComparator<String, Integer>(this.comparator, this.conversionService, null));
}
@Test
void shouldUseConverterOnCompare() throws Exception {
void shouldUseConverterOnCompare() {
ConvertingComparator<String, Integer> convertingComparator = new ConvertingComparator<>(
this.comparator, this.converter);
testConversion(convertingComparator);
}
@Test
void shouldUseConversionServiceOnCompare() throws Exception {
void shouldUseConversionServiceOnCompare() {
ConvertingComparator<String, Integer> convertingComparator = new ConvertingComparator<>(
comparator, conversionService, Integer.class);
testConversion(convertingComparator);
}
@Test
void shouldGetForConverter() throws Exception {
void shouldGetForConverter() {
testConversion(new ConvertingComparator<>(comparator, converter));
}

View File

@ -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<String>> 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<String>[] 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<Object> 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;
}

View File

@ -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");
}

View File

@ -78,7 +78,7 @@ class MapToMapConverterTests {
}
@Test
void scalarMapNotGenericTarget() throws Exception {
void scalarMapNotGenericTarget() {
Map<String, String> 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<String, List<String>> 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<String, List<String>> 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<String, String> 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<String, Integer> map = new NoDefaultConstructorMap<>(
Collections.<String, Integer>singletonMap("1", 1));

View File

@ -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);
}

View File

@ -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()

View File

@ -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"),

View File

@ -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<DataBuffer> 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<DataBuffer> 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());

View File

@ -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");
}
}

View File

@ -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");

View File

@ -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

View File

@ -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());
}

View File

@ -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()");

View File

@ -297,7 +297,7 @@ class AnnotationMetadataTests {
* behaves the same.
*/
@Test // gh-31041
void multipleComposedRepeatableAnnotationsUsingAnnotatedElementUtils() throws Exception {
void multipleComposedRepeatableAnnotationsUsingAnnotatedElementUtils() {
Class<?> element = MultipleComposedRepeatableAnnotationsClass.class;
Set<TestComponentScan> 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<TestComponentScan> annotations = AnnotatedElementUtils.getMergedRepeatableAnnotations(element, TestComponentScan.class);

View File

@ -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<String, String> result = pathMatcher.extractUriTemplateVariables("/hotels/{hotel}", "/hotels/1");
assertThat(result).isEqualTo(Collections.singletonMap("hotel", "1"));

View File

@ -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<Object>(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()));
}

View File

@ -118,7 +118,7 @@ class CollectionUtilsTests {
}
@Test
void containsAny() throws Exception {
void containsAny() {
List<String> 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<Instance> 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<Instance> 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<Instance> 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<String> source = new ArrayList<>();
source.add("abc");
source.add("def");

View File

@ -80,7 +80,7 @@ class FileSystemUtilsTests {
@AfterEach
void tearDown() throws Exception {
void tearDown() {
File tmp = new File("./tmp");
if (tmp.exists()) {
FileSystemUtils.deleteRecursively(tmp);

View File

@ -80,7 +80,7 @@ class MethodInvokerTests {
}
@Test
void stringWithMethodInvoker() throws Exception {
void stringWithMethodInvoker() {
MethodInvoker methodInvoker = new MethodInvoker();
methodInvoker.setTargetObject(new Greeter());
methodInvoker.setTargetMethod("greet");

View File

@ -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));

View File

@ -334,7 +334,7 @@ class ReflectionUtilsTests {
private List<Method> 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 {
}
}

View File

@ -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();
}
}

View File

@ -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<UnsupportedOperationException> assertThatUnsupportedOperationException() {

View File

@ -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<Object> 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<Object> 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<Object> comparator = new InstanceComparator<>(I1.class, C3.class);
assertThat(comparator.compare(c1, c1)).isEqualTo(0);
assertThat(comparator.compare(c3, c4)).isEqualTo(-1);

View File

@ -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<String, Integer> adapter = new FutureAdapter<>(adaptee) {
@Override
protected String adapt(Integer adapteeResult) throws ExecutionException {
protected String adapt(Integer adapteeResult) {
return adapteeResult.toString();
}
};

View File

@ -42,11 +42,12 @@ class ListenableFutureTaskTests {
Callable<String> callable = () -> s;
ListenableFutureTask<String> task = new ListenableFutureTask<>(callable);
task.addCallback(new ListenableFutureCallback<String>() {
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<String> callable = () -> {
throw new IOException(s);
};
ListenableFutureTask<String> task = new ListenableFutureTask<>(callable);
task.addCallback(new ListenableFutureCallback<String>() {
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<String> callable = () -> {

View File

@ -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<String> 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<String> completable = settableListenableFuture.completable();
@ -133,11 +133,12 @@ class SettableListenableFutureTests {
String string = "hello";
final String[] callbackHolder = new String[1];
settableListenableFuture.addCallback(new ListenableFutureCallback<String>() {
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<String>() {
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<String>() {
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<String>() {
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);

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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<Object> 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<Object> 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();
}

View File

@ -243,7 +243,7 @@ abstract class AbstractStaxXMLReaderTests {
private static class CopyCharsAnswer implements Answer<Object> {
@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);

View File

@ -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<String> iterator = context.getPrefixes(namespaceUri);
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(

View File

@ -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();

View File

@ -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);
}