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