This commit is contained in:
Stéphane Nicoll 2024-01-05 06:34:09 +01:00
parent 7c9307e970
commit af2e13e211
49 changed files with 205 additions and 217 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -56,7 +56,6 @@ class ReflectionHintsTests {
}
@Test
@SuppressWarnings("unchecked")
void registerTypeIfPresentIgnoresMissingClass() {
Consumer<TypeHint.Builder> hintBuilder = mock();
this.reflectionHints.registerTypeIfPresent(null, "com.example.DoesNotExist", hintBuilder);

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -132,7 +132,6 @@ class ResourceHintsTests {
}
@Test
@SuppressWarnings("unchecked")
void registerIfPresentIgnoreMissingLocation() {
Consumer<ResourcePatternHints.Builder> hintBuilder = mock();
this.resourceHints.registerPatternIfPresent(null, "location/does-not-exist/", hintBuilder);

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -183,19 +183,19 @@ class GenericTypeResolverTests {
}
@Test
public void resolvePartiallySpecializedTypeVariables() {
void resolvePartiallySpecializedTypeVariables() {
Type resolved = resolveType(BiGenericClass.class.getTypeParameters()[0], TypeFixedBiGenericClass.class);
assertThat(resolved).isEqualTo(D.class);
}
@Test
public void resolveTransitiveTypeVariableWithDifferentName() {
void resolveTransitiveTypeVariableWithDifferentName() {
Type resolved = resolveType(BiGenericClass.class.getTypeParameters()[1], TypeFixedBiGenericClass.class);
assertThat(resolved).isEqualTo(E.class);
}
@Test
public void resolveMethodParameterWithNestedGenerics() {
void resolveMethodParameterWithNestedGenerics() {
Method method = method(WithMethodParameter.class, "nestedGenerics", List.class);
MethodParameter methodParameter = new MethodParameter(method, 0);
Type resolvedType = resolveType(methodParameter.getGenericParameterType(), WithMethodParameter.class);

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -293,7 +293,7 @@ class AnnotatedElementUtilsTests {
void getAllAnnotationAttributesOnClassWithLocalAnnotation() {
MultiValueMap<String, Object> attributes = getAllAnnotationAttributes(TxConfig.class, TX_NAME);
assertThat(attributes).as("Annotation attributes map for @Transactional on TxConfig").isNotNull();
assertThat(attributes.get("value")).as("value for TxConfig").isEqualTo(asList("TxConfig"));
assertThat(attributes.get("value")).as("value for TxConfig").isEqualTo(List.of("TxConfig"));
}
@Test
@ -307,14 +307,14 @@ class AnnotatedElementUtilsTests {
void getAllAnnotationAttributesFavorsInheritedAnnotationsOverMoreLocallyDeclaredComposedAnnotations() {
MultiValueMap<String, Object> attributes = getAllAnnotationAttributes(SubSubClassWithInheritedAnnotation.class, TX_NAME);
assertThat(attributes).as("Annotation attributes map for @Transactional on SubSubClassWithInheritedAnnotation").isNotNull();
assertThat(attributes.get("qualifier")).isEqualTo(asList("transactionManager"));
assertThat(attributes.get("qualifier")).isEqualTo(List.of("transactionManager"));
}
@Test
void getAllAnnotationAttributesFavorsInheritedComposedAnnotationsOverMoreLocallyDeclaredComposedAnnotations() {
MultiValueMap<String, Object> attributes = getAllAnnotationAttributes( SubSubClassWithInheritedComposedAnnotation.class, TX_NAME);
assertThat(attributes).as("Annotation attributes map for @Transactional on SubSubClassWithInheritedComposedAnnotation").isNotNull();
assertThat(attributes.get("qualifier")).isEqualTo(asList("composed1"));
assertThat(attributes.get("qualifier")).isEqualTo(List.of("composed1"));
}
/**
@ -329,7 +329,7 @@ class AnnotatedElementUtilsTests {
// See org.springframework.core.env.EnvironmentSystemIntegrationTests#mostSpecificDerivedClassDrivesEnvironment_withDevEnvAndDerivedDevConfigClass
MultiValueMap<String, Object> attributes = getAllAnnotationAttributes(DerivedTxConfig.class, TX_NAME);
assertThat(attributes).as("Annotation attributes map for @Transactional on DerivedTxConfig").isNotNull();
assertThat(attributes.get("value")).as("value for DerivedTxConfig").isEqualTo(asList("DerivedTxConfig"));
assertThat(attributes.get("value")).as("value for DerivedTxConfig").isEqualTo(List.of("DerivedTxConfig"));
}
/**
@ -348,7 +348,7 @@ class AnnotatedElementUtilsTests {
MultiValueMap<String, Object> attributes = getAllAnnotationAttributes(
NonNullApi.class, Nonnull.class.getName());
assertThat(attributes).as("Annotation attributes map for @Nonnull on NonNullApi").isNotNull();
assertThat(attributes.get("when")).as("value for NonNullApi").isEqualTo(asList(When.ALWAYS));
assertThat(attributes.get("when")).as("value for NonNullApi").isEqualTo(List.of(When.ALWAYS));
}
@Test
@ -356,7 +356,7 @@ class AnnotatedElementUtilsTests {
MultiValueMap<String, Object> attributes = getAllAnnotationAttributes(
ParametersAreNonnullByDefault.class, Nonnull.class.getName());
assertThat(attributes).as("Annotation attributes map for @Nonnull on NonNullApi").isNotNull();
assertThat(attributes.get("when")).as("value for NonNullApi").isEqualTo(asList(When.ALWAYS));
assertThat(attributes.get("when")).as("value for NonNullApi").isEqualTo(List.of(When.ALWAYS));
}
@Test

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -882,7 +882,7 @@ class AnnotationUtilsTests {
}
@Test
void synthesizeAnnotationFromMapWithImplicitAttributeAliases() throws Exception {
void synthesizeAnnotationFromMapWithImplicitAttributeAliases() {
assertAnnotationSynthesisFromMapWithImplicitAliases("value");
assertAnnotationSynthesisFromMapWithImplicitAliases("location1");
assertAnnotationSynthesisFromMapWithImplicitAliases("location2");

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -161,8 +161,7 @@ class MergedAnnotationsComposedOnSingleAnnotatedElementTests {
}
@Test
void typeHierarchyStrategyMultipleComposedAnnotationsOnBridgeMethod()
throws Exception {
void typeHierarchyStrategyMultipleComposedAnnotationsOnBridgeMethod() {
assertTypeHierarchyStrategyBehavior(getBridgeMethod());
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -415,7 +415,7 @@ class MergedAnnotationsTests {
MultiValueMap<String, Object> map = MergedAnnotations.from(TxConfig.class).stream(
Transactional.class).collect(
MergedAnnotationCollectors.toMultiValueMap());
assertThat(map).contains(entry("value", Arrays.asList("TxConfig")));
assertThat(map).contains(entry("value", List.of("TxConfig")));
}
@Test
@ -434,7 +434,7 @@ class MergedAnnotationsTests {
SubSubClassWithInheritedAnnotation.class,
SearchStrategy.INHERITED_ANNOTATIONS).stream(Transactional.class).collect(
MergedAnnotationCollectors.toMultiValueMap());
assertThat(map).contains(entry("qualifier", Arrays.asList("transactionManager")));
assertThat(map).contains(entry("qualifier", List.of("transactionManager")));
}
@Test
@ -443,7 +443,7 @@ class MergedAnnotationsTests {
SubSubClassWithInheritedComposedAnnotation.class,
SearchStrategy.INHERITED_ANNOTATIONS).stream(Transactional.class).collect(
MergedAnnotationCollectors.toMultiValueMap());
assertThat(map).contains(entry("qualifier", Arrays.asList("composed1")));
assertThat(map).contains(entry("qualifier", List.of("composed1")));
}
/**
@ -458,7 +458,7 @@ class MergedAnnotationsTests {
MultiValueMap<String, Object> map = MergedAnnotations.from(DerivedTxConfig.class,
SearchStrategy.INHERITED_ANNOTATIONS).stream(Transactional.class).collect(
MergedAnnotationCollectors.toMultiValueMap());
assertThat(map).contains(entry("value", Arrays.asList("DerivedTxConfig")));
assertThat(map).contains(entry("value", List.of("DerivedTxConfig")));
}
/**
@ -855,7 +855,6 @@ class MergedAnnotationsTests {
}
@Test
@SuppressWarnings("deprecation")
void getFromMethodWithMethodAnnotationOnLeaf() throws Exception {
Method method = Leaf.class.getMethod("annotatedOnLeaf");
assertThat(method.getAnnotation(Order.class)).isNotNull();
@ -1731,7 +1730,7 @@ class MergedAnnotationsTests {
}
@Test
void synthesizeWithImplicitAliases() throws Exception {
void synthesizeWithImplicitAliases() {
testSynthesisWithImplicitAliases(ValueImplicitAliasesTestConfigurationClass.class, "value");
testSynthesisWithImplicitAliases(Location1ImplicitAliasesTestConfigurationClass.class, "location1");
testSynthesisWithImplicitAliases(XmlImplicitAliasesTestConfigurationClass.class, "xmlFile");
@ -1965,7 +1964,7 @@ class MergedAnnotationsTests {
}
@Test
void synthesizeFromMapWithImplicitAttributeAliases() throws Exception {
void synthesizeFromMapWithImplicitAttributeAliases() {
testSynthesisFromMapWithImplicitAliases("value");
testSynthesisFromMapWithImplicitAliases("location1");
testSynthesisFromMapWithImplicitAliases("location2");

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -106,7 +106,7 @@ class MultipleComposedAnnotationsOnSingleAnnotatedElementTests {
@Test
@Disabled("Disabled since some Java 8 updates handle the bridge method differently")
void getMultipleComposedAnnotationsOnBridgeMethod() throws Exception {
void getMultipleComposedAnnotationsOnBridgeMethod() {
Set<Cacheable> cacheables = getAllMergedAnnotations(getBridgeMethod(), Cacheable.class);
assertThat(cacheables).isNotNull();
assertThat(cacheables).isEmpty();
@ -178,7 +178,7 @@ class MultipleComposedAnnotationsOnSingleAnnotatedElementTests {
}
@Test
void findMultipleComposedAnnotationsOnBridgeMethod() throws Exception {
void findMultipleComposedAnnotationsOnBridgeMethod() {
assertFindAllMergedAnnotationsBehavior(getBridgeMethod());
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -45,7 +45,7 @@ class ByteArrayDecoderTests extends AbstractDecoderTests<ByteArrayDecoder> {
@Override
@Test
public void canDecode() {
protected void canDecode() {
assertThat(this.decoder.canDecode(ResolvableType.forClass(byte[].class),
MimeTypeUtils.TEXT_PLAIN)).isTrue();
assertThat(this.decoder.canDecode(ResolvableType.forClass(Integer.class),
@ -56,7 +56,7 @@ class ByteArrayDecoderTests extends AbstractDecoderTests<ByteArrayDecoder> {
@Override
@Test
public void decode() {
protected void decode() {
Flux<DataBuffer> input = Flux.concat(
dataBuffer(this.fooBytes),
dataBuffer(this.barBytes));
@ -70,7 +70,7 @@ class ByteArrayDecoderTests extends AbstractDecoderTests<ByteArrayDecoder> {
@Override
@Test
public void decodeToMono() {
protected void decodeToMono() {
Flux<DataBuffer> input = Flux.concat(
dataBuffer(this.fooBytes),
dataBuffer(this.barBytes));

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -43,7 +43,7 @@ class ByteArrayEncoderTests extends AbstractEncoderTests<ByteArrayEncoder> {
@Override
@Test
public void canEncode() {
protected void canEncode() {
assertThat(this.encoder.canEncode(ResolvableType.forClass(byte[].class),
MimeTypeUtils.TEXT_PLAIN)).isTrue();
assertThat(this.encoder.canEncode(ResolvableType.forClass(Integer.class),
@ -57,7 +57,7 @@ class ByteArrayEncoderTests extends AbstractEncoderTests<ByteArrayEncoder> {
@Override
@Test
public void encode() {
protected void encode() {
Flux<byte[]> input = Flux.just(this.fooBytes, this.barBytes);
testEncodeAll(input, byte[].class, step -> step

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -46,7 +46,7 @@ class ByteBufferDecoderTests extends AbstractDecoderTests<ByteBufferDecoder> {
@Override
@Test
public void canDecode() {
protected void canDecode() {
assertThat(this.decoder.canDecode(ResolvableType.forClass(ByteBuffer.class),
MimeTypeUtils.TEXT_PLAIN)).isTrue();
assertThat(this.decoder.canDecode(ResolvableType.forClass(Integer.class),
@ -57,7 +57,7 @@ class ByteBufferDecoderTests extends AbstractDecoderTests<ByteBufferDecoder> {
@Override
@Test
public void decode() {
protected void decode() {
Flux<DataBuffer> input = Flux.concat(
dataBuffer(this.fooBytes),
dataBuffer(this.barBytes));
@ -72,7 +72,7 @@ class ByteBufferDecoderTests extends AbstractDecoderTests<ByteBufferDecoder> {
@Override
@Test
public void decodeToMono() {
protected void decodeToMono() {
Flux<DataBuffer> input = Flux.concat(
dataBuffer(this.fooBytes),
dataBuffer(this.barBytes));

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -43,7 +43,7 @@ class ByteBufferEncoderTests extends AbstractEncoderTests<ByteBufferEncoder> {
@Override
@Test
public void canEncode() {
protected void canEncode() {
assertThat(this.encoder.canEncode(ResolvableType.forClass(ByteBuffer.class),
MimeTypeUtils.TEXT_PLAIN)).isTrue();
assertThat(this.encoder.canEncode(ResolvableType.forClass(Integer.class),
@ -57,7 +57,7 @@ class ByteBufferEncoderTests extends AbstractEncoderTests<ByteBufferEncoder> {
@Override
@Test
public void encode() {
protected void encode() {
Flux<ByteBuffer> input = Flux.just(this.fooBytes, this.barBytes)
.map(ByteBuffer::wrap);

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -55,7 +55,7 @@ class CharBufferDecoderTests extends AbstractDecoderTests<CharBufferDecoder> {
@Override
@Test
public void canDecode() {
protected void canDecode() {
assertThat(this.decoder.canDecode(TYPE, MimeTypeUtils.TEXT_PLAIN)).isTrue();
assertThat(this.decoder.canDecode(TYPE, MimeTypeUtils.TEXT_HTML)).isTrue();
assertThat(this.decoder.canDecode(TYPE, MimeTypeUtils.APPLICATION_JSON)).isTrue();
@ -66,7 +66,7 @@ class CharBufferDecoderTests extends AbstractDecoderTests<CharBufferDecoder> {
@Override
@Test
public void decode() {
protected void decode() {
CharBuffer u = charBuffer("ü");
CharBuffer e = charBuffer("é");
CharBuffer o = charBuffer("ø");
@ -230,7 +230,7 @@ class CharBufferDecoderTests extends AbstractDecoderTests<CharBufferDecoder> {
@Override
@Test
public void decodeToMono() {
protected void decodeToMono() {
Flux<DataBuffer> input = Flux.just(
stringBuffer("foo"),
stringBuffer("bar"),

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -48,7 +48,7 @@ class CharSequenceEncoderTests extends AbstractEncoderTests<CharSequenceEncoder>
@Override
@Test
public void canEncode() {
protected void canEncode() {
assertThat(this.encoder.canEncode(ResolvableType.forClass(String.class),
MimeTypeUtils.TEXT_PLAIN)).isTrue();
assertThat(this.encoder.canEncode(ResolvableType.forClass(StringBuilder.class),
@ -66,7 +66,7 @@ class CharSequenceEncoderTests extends AbstractEncoderTests<CharSequenceEncoder>
@Override
@Test
public void encode() {
protected void encode() {
Flux<CharSequence> input = Flux.just(this.foo, this.bar);
testEncodeAll(input, CharSequence.class, step -> step

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -46,7 +46,7 @@ class DataBufferDecoderTests extends AbstractDecoderTests<DataBufferDecoder> {
@Override
@Test
public void canDecode() {
protected void canDecode() {
assertThat(this.decoder.canDecode(ResolvableType.forClass(DataBuffer.class),
MimeTypeUtils.TEXT_PLAIN)).isTrue();
assertThat(this.decoder.canDecode(ResolvableType.forClass(Integer.class),
@ -57,7 +57,7 @@ class DataBufferDecoderTests extends AbstractDecoderTests<DataBufferDecoder> {
@Override
@Test
public void decode() {
protected void decode() {
Flux<DataBuffer> input = Flux.just(
this.bufferFactory.wrap(this.fooBytes),
this.bufferFactory.wrap(this.barBytes));
@ -70,7 +70,7 @@ class DataBufferDecoderTests extends AbstractDecoderTests<DataBufferDecoder> {
@Override
@Test
public void decodeToMono() {
protected void decodeToMono() {
Flux<DataBuffer> input = Flux.concat(
dataBuffer(this.fooBytes),
dataBuffer(this.barBytes));

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -45,7 +45,7 @@ class DataBufferEncoderTests extends AbstractEncoderTests<DataBufferEncoder> {
@Override
@Test
public void canEncode() {
protected void canEncode() {
assertThat(this.encoder.canEncode(ResolvableType.forClass(DataBuffer.class),
MimeTypeUtils.TEXT_PLAIN)).isTrue();
assertThat(this.encoder.canEncode(ResolvableType.forClass(Integer.class),
@ -59,7 +59,7 @@ class DataBufferEncoderTests extends AbstractEncoderTests<DataBufferEncoder> {
@Override
@Test
public void encode() {
protected void encode() {
Flux<DataBuffer> input = Flux.just(this.fooBytes, this.barBytes)
.flatMap(bytes -> Mono.defer(() -> {
DataBuffer dataBuffer = this.bufferFactory.allocateBuffer(bytes.length);

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -47,7 +47,7 @@ class Netty5BufferDecoderTests extends AbstractDecoderTests<Netty5BufferDecoder>
@Override
@Test
public void canDecode() {
protected void canDecode() {
assertThat(this.decoder.canDecode(ResolvableType.forClass(Buffer.class),
MimeTypeUtils.TEXT_PLAIN)).isTrue();
assertThat(this.decoder.canDecode(ResolvableType.forClass(Integer.class),
@ -58,7 +58,7 @@ class Netty5BufferDecoderTests extends AbstractDecoderTests<Netty5BufferDecoder>
@Override
@Test
public void decode() {
protected void decode() {
Flux<DataBuffer> input = Flux.concat(
dataBuffer(this.fooBytes),
dataBuffer(this.barBytes));
@ -71,7 +71,7 @@ class Netty5BufferDecoderTests extends AbstractDecoderTests<Netty5BufferDecoder>
@Override
@Test
public void decodeToMono() {
protected void decodeToMono() {
Flux<DataBuffer> input = Flux.concat(
dataBuffer(this.fooBytes),
dataBuffer(this.barBytes));

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -47,7 +47,7 @@ class NettyByteBufDecoderTests extends AbstractDecoderTests<NettyByteBufDecoder>
@Override
@Test
public void canDecode() {
protected void canDecode() {
assertThat(this.decoder.canDecode(ResolvableType.forClass(ByteBuf.class),
MimeTypeUtils.TEXT_PLAIN)).isTrue();
assertThat(this.decoder.canDecode(ResolvableType.forClass(Integer.class),
@ -58,7 +58,7 @@ class NettyByteBufDecoderTests extends AbstractDecoderTests<NettyByteBufDecoder>
@Override
@Test
public void decode() {
protected void decode() {
Flux<DataBuffer> input = Flux.concat(
dataBuffer(this.fooBytes),
dataBuffer(this.barBytes));
@ -71,7 +71,7 @@ class NettyByteBufDecoderTests extends AbstractDecoderTests<NettyByteBufDecoder>
@Override
@Test
public void decodeToMono() {
protected void decodeToMono() {
Flux<DataBuffer> input = Flux.concat(
dataBuffer(this.fooBytes),
dataBuffer(this.barBytes));

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -44,7 +44,7 @@ class NettyByteBufEncoderTests extends AbstractEncoderTests<NettyByteBufEncoder>
@Override
@Test
public void canEncode() {
protected void canEncode() {
assertThat(this.encoder.canEncode(ResolvableType.forClass(ByteBuf.class),
MimeTypeUtils.TEXT_PLAIN)).isTrue();
assertThat(this.encoder.canEncode(ResolvableType.forClass(Integer.class),
@ -58,7 +58,7 @@ class NettyByteBufEncoderTests extends AbstractEncoderTests<NettyByteBufEncoder>
@Override
@Test
public void encode() {
protected void encode() {
Flux<ByteBuf> input = Flux.just(this.fooBytes, this.barBytes).map(Unpooled::copiedBuffer);
testEncodeAll(input, ByteBuf.class, step -> step

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -51,7 +51,7 @@ class ResourceDecoderTests extends AbstractDecoderTests<ResourceDecoder> {
@Override
@Test
public void canDecode() {
protected void canDecode() {
assertThat(this.decoder.canDecode(forClass(InputStreamResource.class), MimeTypeUtils.TEXT_PLAIN)).isTrue();
assertThat(this.decoder.canDecode(forClass(ByteArrayResource.class), MimeTypeUtils.TEXT_PLAIN)).isTrue();
assertThat(this.decoder.canDecode(forClass(Resource.class), MimeTypeUtils.TEXT_PLAIN)).isTrue();
@ -62,7 +62,7 @@ class ResourceDecoderTests extends AbstractDecoderTests<ResourceDecoder> {
@Override
@Test
public void decode() {
protected void decode() {
Flux<DataBuffer> input = Flux.concat(dataBuffer(this.fooBytes), dataBuffer(this.barBytes));
testDecodeAll(input, Resource.class, step -> step
@ -81,7 +81,7 @@ class ResourceDecoderTests extends AbstractDecoderTests<ResourceDecoder> {
@Override
@Test
public void decodeToMono() {
protected void decodeToMono() {
Flux<DataBuffer> input = Flux.concat(dataBuffer(this.fooBytes), dataBuffer(this.barBytes));
testDecodeToMonoAll(input, ResolvableType.forClass(Resource.class),
step -> step
@ -103,7 +103,7 @@ class ResourceDecoderTests extends AbstractDecoderTests<ResourceDecoder> {
}
@Test
public void decodeInputStreamResource() {
void decodeInputStreamResource() {
Flux<DataBuffer> input = Flux.concat(dataBuffer(this.fooBytes), dataBuffer(this.barBytes));
testDecodeAll(input, InputStreamResource.class, step -> step
.consumeNextWith(resource -> {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -50,7 +50,7 @@ class ResourceEncoderTests extends AbstractEncoderTests<ResourceEncoder> {
@Override
@Test
public void canEncode() {
protected void canEncode() {
assertThat(this.encoder.canEncode(ResolvableType.forClass(InputStreamResource.class),
MimeTypeUtils.TEXT_PLAIN)).isTrue();
assertThat(this.encoder.canEncode(ResolvableType.forClass(ByteArrayResource.class),
@ -66,7 +66,7 @@ class ResourceEncoderTests extends AbstractEncoderTests<ResourceEncoder> {
@Override
@Test
public void encode() {
protected void encode() {
Flux<Resource> input = Flux.just(new ByteArrayResource(this.bytes));
testEncodeAll(input, Resource.class, step -> step

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -58,7 +58,7 @@ class StringDecoderTests extends AbstractDecoderTests<StringDecoder> {
@Override
@Test
public void canDecode() {
protected void canDecode() {
assertThat(this.decoder.canDecode(TYPE, MimeTypeUtils.TEXT_PLAIN)).isTrue();
assertThat(this.decoder.canDecode(TYPE, MimeTypeUtils.TEXT_HTML)).isTrue();
assertThat(this.decoder.canDecode(TYPE, MimeTypeUtils.APPLICATION_JSON)).isTrue();
@ -69,7 +69,7 @@ class StringDecoderTests extends AbstractDecoderTests<StringDecoder> {
@Override
@Test
public void decode() {
protected void decode() {
String u = "ü";
String e = "é";
String o = "ø";
@ -238,7 +238,7 @@ class StringDecoderTests extends AbstractDecoderTests<StringDecoder> {
@Override
@Test
public void decodeToMono() {
protected void decodeToMono() {
Flux<DataBuffer> input = Flux.just(
stringBuffer("foo"),
stringBuffer("bar"),

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -143,8 +143,8 @@ class CollectionToCollectionConverterTests {
@SuppressWarnings("unchecked")
void stringToCollection() throws Exception {
List<List<String>> list = new ArrayList<>();
list.add(Arrays.asList("9,12"));
list.add(Arrays.asList("37,23"));
list.add(List.of("9,12"));
list.add(List.of("37,23"));
conversionService.addConverterFactory(new StringToNumberConverterFactory());
conversionService.addConverter(new StringToCollectionConverter(conversionService));
conversionService.addConverter(new ObjectToCollectionConverter(conversionService));

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -256,8 +256,8 @@ class MapToMapConverterTests {
MultiValueMap<String, String> converted = (MultiValueMap<String, String>) conversionService.convert(source, targetType);
assertThat(converted).hasSize(2);
assertThat(converted.get("a")).isEqualTo(Arrays.asList("1"));
assertThat(converted.get("b")).isEqualTo(Arrays.asList("2"));
assertThat(converted.get("a")).isEqualTo(List.of("1"));
assertThat(converted.get("b")).isEqualTo(List.of("2"));
}
@Test

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -98,7 +98,6 @@ class StreamConverterTests {
}
@Test
@SuppressWarnings("resource")
void convertFromListToStream() throws NoSuchFieldException {
this.conversionService.addConverterFactory(new StringToNumberConverterFactory());
List<String> list = Arrays.asList("1", "2", "3");
@ -112,7 +111,6 @@ class StreamConverterTests {
}
@Test
@SuppressWarnings("resource")
void convertFromArrayToStream() throws NoSuchFieldException {
Integer[] array = new Integer[] {1, 0, 1};
this.conversionService.addConverter(Integer.class, Boolean.class, source -> source == 1);
@ -123,7 +121,6 @@ class StreamConverterTests {
}
@Test
@SuppressWarnings("resource")
void convertFromListToRawStream() throws NoSuchFieldException {
List<String> list = Arrays.asList("1", "2", "3");
TypeDescriptor streamOfInteger = new TypeDescriptor(Types.class.getField("rawStream"));

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -75,7 +75,6 @@ class CustomEnvironmentTests {
void withMultiCustomReservedDefaultProfile() {
class CustomEnvironment extends AbstractEnvironment {
@Override
@SuppressWarnings("serial")
protected Set<String> getReservedDefaultProfiles() {
return Set.of("rd1", "rd2");
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -48,21 +48,20 @@ class PropertySourceTests {
MapPropertySource mps = new MapPropertySource("mps", map1);
assertThat(mps).isEqualTo(mps);
assertThat(new MapPropertySource("x", map1).equals(new MapPropertySource("x", map1))).isTrue();
assertThat(new MapPropertySource("x", map1).equals(new MapPropertySource("x", map2))).isTrue();
assertThat(new MapPropertySource("x", map1).equals(new PropertiesPropertySource("x", props1))).isTrue();
assertThat(new MapPropertySource("x", map1).equals(new PropertiesPropertySource("x", props2))).isTrue();
assertThat(new MapPropertySource("x", map1)).isEqualTo(new MapPropertySource("x", map1));
assertThat(new MapPropertySource("x", map1)).isEqualTo(new MapPropertySource("x", map2));
assertThat(new MapPropertySource("x", map1)).isEqualTo(new PropertiesPropertySource("x", props1));
assertThat(new MapPropertySource("x", map1)).isEqualTo(new PropertiesPropertySource("x", props2));
assertThat(new MapPropertySource("x", map1).equals(new Object())).isFalse();
assertThat(new MapPropertySource("x", map1).equals("x")).isFalse();
assertThat(new MapPropertySource("x", map1).equals(new MapPropertySource("y", map1))).isFalse();
assertThat(new MapPropertySource("x", map1).equals(new MapPropertySource("y", map2))).isFalse();
assertThat(new MapPropertySource("x", map1).equals(new PropertiesPropertySource("y", props1))).isFalse();
assertThat(new MapPropertySource("x", map1).equals(new PropertiesPropertySource("y", props2))).isFalse();
assertThat(new MapPropertySource("x", map1)).isNotEqualTo(new Object());
assertThat(new MapPropertySource("x", map1)).isNotEqualTo("x");
assertThat(new MapPropertySource("x", map1)).isNotEqualTo(new MapPropertySource("y", map1));
assertThat(new MapPropertySource("x", map1)).isNotEqualTo(new MapPropertySource("y", map2));
assertThat(new MapPropertySource("x", map1)).isNotEqualTo(new PropertiesPropertySource("y", props1));
assertThat(new MapPropertySource("x", map1)).isNotEqualTo(new PropertiesPropertySource("y", props2));
}
@Test
@SuppressWarnings("serial")
void collectionsOperations() {
Map<String, Object> map1 = Map.of("a", "b");
Map<String, Object> map2 = Map.of("c", "d");

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -454,26 +454,22 @@ class StandardEnvironmentTests {
class MatchesProfilesTests {
@Test
@SuppressWarnings("deprecation")
void withEmptyArgumentList() {
assertThatIllegalArgumentException().isThrownBy(environment::matchesProfiles);
}
@Test
@SuppressWarnings("deprecation")
void withNullArgumentList() {
assertThatIllegalArgumentException().isThrownBy(() -> environment.matchesProfiles((String[]) null));
}
@Test
@SuppressWarnings("deprecation")
void withNullArgument() {
assertThatIllegalArgumentException().isThrownBy(() -> environment.matchesProfiles((String) null));
assertThatIllegalArgumentException().isThrownBy(() -> environment.matchesProfiles("p1", null));
}
@Test
@SuppressWarnings("deprecation")
void withEmptyArgument() {
assertThatIllegalArgumentException().isThrownBy(() -> environment.matchesProfiles(""));
assertThatIllegalArgumentException().isThrownBy(() -> environment.matchesProfiles("p1", ""));
@ -481,13 +477,11 @@ class StandardEnvironmentTests {
}
@Test
@SuppressWarnings("deprecation")
void withInvalidNotOperator() {
assertThatIllegalArgumentException().isThrownBy(() -> environment.matchesProfiles("p1", "!"));
}
@Test
@SuppressWarnings("deprecation")
void withInvalidCompoundExpressionGrouping() {
assertThatIllegalArgumentException().isThrownBy(() -> environment.matchesProfiles("p1 | p2 & p3"));
assertThatIllegalArgumentException().isThrownBy(() -> environment.matchesProfiles("p1 & p2 | p3"));
@ -495,7 +489,6 @@ class StandardEnvironmentTests {
}
@Test
@SuppressWarnings("deprecation")
void activeProfileSetProgrammatically() {
assertThat(environment.matchesProfiles("p1", "p2")).isFalse();
@ -510,7 +503,6 @@ class StandardEnvironmentTests {
}
@Test
@SuppressWarnings("deprecation")
void activeProfileSetViaProperty() {
assertThat(environment.matchesProfiles("p1")).isFalse();
@ -519,7 +511,6 @@ class StandardEnvironmentTests {
}
@Test
@SuppressWarnings("deprecation")
void defaultProfile() {
assertThat(environment.matchesProfiles("pd")).isFalse();
@ -532,7 +523,6 @@ class StandardEnvironmentTests {
}
@Test
@SuppressWarnings("deprecation")
void withNotOperator() {
assertThat(environment.matchesProfiles("p1")).isFalse();
assertThat(environment.matchesProfiles("!p1")).isTrue();

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -468,7 +468,6 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
@SuppressWarnings("unchecked")
void writeAsynchronousFileChannelErrorInWrite(DataBufferFactory bufferFactory) throws Exception {
super.bufferFactory = bufferFactory;

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -17,6 +17,7 @@
package org.springframework.core.io.support;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import org.junit.jupiter.api.Test;
@ -35,8 +36,8 @@ class EncodedResourceTests {
private static final String UTF8 = "UTF-8";
private static final String UTF16 = "UTF-16";
private static final Charset UTF8_CS = Charset.forName(UTF8);
private static final Charset UTF16_CS = Charset.forName(UTF16);
private static final Charset UTF8_CS = StandardCharsets.UTF_8;
private static final Charset UTF16_CS = StandardCharsets.UTF_16;
private final Resource resource = new DescriptiveResource("test");

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -38,7 +38,7 @@ import static org.assertj.core.api.Assertions.entry;
public abstract class AbstractAnnotationMetadataTests {
@Test
public void verifyEquals() {
void verifyEquals() {
AnnotationMetadata testClass1 = get(TestClass.class);
AnnotationMetadata testClass2 = get(TestClass.class);
AnnotationMetadata testMemberClass1 = get(TestMemberClass.class);
@ -61,7 +61,7 @@ public abstract class AbstractAnnotationMetadataTests {
}
@Test
public void verifyHashCode() {
void verifyHashCode() {
AnnotationMetadata testClass1 = get(TestClass.class);
AnnotationMetadata testClass2 = get(TestClass.class);
AnnotationMetadata testMemberClass1 = get(TestMemberClass.class);
@ -74,106 +74,106 @@ public abstract class AbstractAnnotationMetadataTests {
}
@Test
public void verifyToString() {
void verifyToString() {
assertThat(get(TestClass.class).toString()).isEqualTo(TestClass.class.getName());
}
@Test
public void getClassNameReturnsClassName() {
void getClassNameReturnsClassName() {
assertThat(get(TestClass.class).getClassName()).isEqualTo(TestClass.class.getName());
}
@Test
public void isInterfaceWhenInterfaceReturnsTrue() {
void isInterfaceWhenInterfaceReturnsTrue() {
assertThat(get(TestInterface.class).isInterface()).isTrue();
assertThat(get(TestAnnotation.class).isInterface()).isTrue();
}
@Test
public void isInterfaceWhenNotInterfaceReturnsFalse() {
void isInterfaceWhenNotInterfaceReturnsFalse() {
assertThat(get(TestClass.class).isInterface()).isFalse();
}
@Test
public void isAnnotationWhenAnnotationReturnsTrue() {
void isAnnotationWhenAnnotationReturnsTrue() {
assertThat(get(TestAnnotation.class).isAnnotation()).isTrue();
}
@Test
public void isAnnotationWhenNotAnnotationReturnsFalse() {
void isAnnotationWhenNotAnnotationReturnsFalse() {
assertThat(get(TestClass.class).isAnnotation()).isFalse();
assertThat(get(TestInterface.class).isAnnotation()).isFalse();
}
@Test
public void isFinalWhenFinalReturnsTrue() {
void isFinalWhenFinalReturnsTrue() {
assertThat(get(TestFinalClass.class).isFinal()).isTrue();
}
@Test
public void isFinalWhenNonFinalReturnsFalse() {
void isFinalWhenNonFinalReturnsFalse() {
assertThat(get(TestClass.class).isFinal()).isFalse();
}
@Test
public void isIndependentWhenIndependentReturnsTrue() {
void isIndependentWhenIndependentReturnsTrue() {
assertThat(get(AbstractAnnotationMetadataTests.class).isIndependent()).isTrue();
assertThat(get(TestClass.class).isIndependent()).isTrue();
}
@Test
public void isIndependentWhenNotIndependentReturnsFalse() {
void isIndependentWhenNotIndependentReturnsFalse() {
assertThat(get(TestNonStaticInnerClass.class).isIndependent()).isFalse();
}
@Test
public void getEnclosingClassNameWhenHasEnclosingClassReturnsEnclosingClass() {
void getEnclosingClassNameWhenHasEnclosingClassReturnsEnclosingClass() {
assertThat(get(TestClass.class).getEnclosingClassName()).isEqualTo(
AbstractAnnotationMetadataTests.class.getName());
}
@Test
public void getEnclosingClassNameWhenHasNoEnclosingClassReturnsNull() {
void getEnclosingClassNameWhenHasNoEnclosingClassReturnsNull() {
assertThat(get(AbstractAnnotationMetadataTests.class).getEnclosingClassName()).isNull();
}
@Test
public void getSuperClassNameWhenHasSuperClassReturnsName() {
void getSuperClassNameWhenHasSuperClassReturnsName() {
assertThat(get(TestSubclass.class).getSuperClassName()).isEqualTo(TestClass.class.getName());
assertThat(get(TestClass.class).getSuperClassName()).isEqualTo(Object.class.getName());
}
@Test
public void getSuperClassNameWhenHasNoSuperClassReturnsNull() {
void getSuperClassNameWhenHasNoSuperClassReturnsNull() {
assertThat(get(Object.class).getSuperClassName()).isNull();
assertThat(get(TestInterface.class).getSuperClassName()).isNull();
assertThat(get(TestSubInterface.class).getSuperClassName()).isNull();
}
@Test
public void getInterfaceNamesWhenHasInterfacesReturnsNames() {
void getInterfaceNamesWhenHasInterfacesReturnsNames() {
assertThat(get(TestSubclass.class).getInterfaceNames()).containsExactlyInAnyOrder(TestInterface.class.getName());
assertThat(get(TestSubInterface.class).getInterfaceNames()).containsExactlyInAnyOrder(TestInterface.class.getName());
}
@Test
public void getInterfaceNamesWhenHasNoInterfacesReturnsEmptyArray() {
void getInterfaceNamesWhenHasNoInterfacesReturnsEmptyArray() {
assertThat(get(TestClass.class).getInterfaceNames()).isEmpty();
}
@Test
public void getMemberClassNamesWhenHasMemberClassesReturnsNames() {
void getMemberClassNamesWhenHasMemberClassesReturnsNames() {
assertThat(get(TestMemberClass.class).getMemberClassNames()).containsExactlyInAnyOrder(
TestMemberClassInnerClass.class.getName(), TestMemberClassInnerInterface.class.getName());
}
@Test
public void getMemberClassNamesWhenHasNoMemberClassesReturnsEmptyArray() {
void getMemberClassNamesWhenHasNoMemberClassesReturnsEmptyArray() {
assertThat(get(TestClass.class).getMemberClassNames()).isEmpty();
}
@Test
public void getAnnotationsReturnsDirectAnnotations() {
void getAnnotationsReturnsDirectAnnotations() {
assertThat(get(WithDirectAnnotations.class).getAnnotations().stream())
.filteredOn(MergedAnnotation::isDirectlyPresent)
.extracting(a -> a.getType().getName())
@ -181,28 +181,28 @@ public abstract class AbstractAnnotationMetadataTests {
}
@Test
public void isAnnotatedWhenMatchesDirectAnnotationReturnsTrue() {
void isAnnotatedWhenMatchesDirectAnnotationReturnsTrue() {
assertThat(get(WithDirectAnnotations.class).isAnnotated(DirectAnnotation1.class.getName())).isTrue();
}
@Test
public void isAnnotatedWhenMatchesMetaAnnotationReturnsTrue() {
void isAnnotatedWhenMatchesMetaAnnotationReturnsTrue() {
assertThat(get(WithMetaAnnotations.class).isAnnotated(MetaAnnotation2.class.getName())).isTrue();
}
@Test
public void isAnnotatedWhenDoesNotMatchDirectOrMetaAnnotationReturnsFalse() {
void isAnnotatedWhenDoesNotMatchDirectOrMetaAnnotationReturnsFalse() {
assertThat(get(TestClass.class).isAnnotated(DirectAnnotation1.class.getName())).isFalse();
}
@Test
public void getAnnotationAttributesReturnsAttributes() {
void getAnnotationAttributesReturnsAttributes() {
assertThat(get(WithAnnotationAttributes.class).getAnnotationAttributes(AnnotationAttributes.class.getName()))
.containsOnly(entry("name", "test"), entry("size", 1));
}
@Test
public void getAllAnnotationAttributesReturnsAllAttributes() {
void getAllAnnotationAttributesReturnsAllAttributes() {
MultiValueMap<String, Object> attributes =
get(WithMetaAnnotationAttributes.class).getAllAnnotationAttributes(AnnotationAttributes.class.getName());
assertThat(attributes).containsOnlyKeys("name", "size");
@ -211,69 +211,69 @@ public abstract class AbstractAnnotationMetadataTests {
}
@Test
public void getAnnotationTypesReturnsDirectAnnotations() {
void getAnnotationTypesReturnsDirectAnnotations() {
AnnotationMetadata metadata = get(WithDirectAnnotations.class);
assertThat(metadata.getAnnotationTypes()).containsExactlyInAnyOrder(
DirectAnnotation1.class.getName(), DirectAnnotation2.class.getName());
}
@Test
public void getMetaAnnotationTypesReturnsMetaAnnotations() {
void getMetaAnnotationTypesReturnsMetaAnnotations() {
AnnotationMetadata metadata = get(WithMetaAnnotations.class);
assertThat(metadata.getMetaAnnotationTypes(MetaAnnotationRoot.class.getName()))
.containsExactlyInAnyOrder(MetaAnnotation1.class.getName(), MetaAnnotation2.class.getName());
}
@Test
public void hasAnnotationWhenMatchesDirectAnnotationReturnsTrue() {
void hasAnnotationWhenMatchesDirectAnnotationReturnsTrue() {
assertThat(get(WithDirectAnnotations.class).hasAnnotation(DirectAnnotation1.class.getName())).isTrue();
}
@Test
public void hasAnnotationWhenMatchesMetaAnnotationReturnsFalse() {
void hasAnnotationWhenMatchesMetaAnnotationReturnsFalse() {
assertThat(get(WithMetaAnnotations.class).hasAnnotation(MetaAnnotation1.class.getName())).isFalse();
assertThat(get(WithMetaAnnotations.class).hasAnnotation(MetaAnnotation2.class.getName())).isFalse();
}
@Test
public void hasAnnotationWhenDoesNotMatchDirectOrMetaAnnotationReturnsFalse() {
void hasAnnotationWhenDoesNotMatchDirectOrMetaAnnotationReturnsFalse() {
assertThat(get(TestClass.class).hasAnnotation(DirectAnnotation1.class.getName())).isFalse();
}
@Test
public void hasMetaAnnotationWhenMatchesDirectReturnsFalse() {
void hasMetaAnnotationWhenMatchesDirectReturnsFalse() {
assertThat(get(WithDirectAnnotations.class).hasMetaAnnotation(DirectAnnotation1.class.getName())).isFalse();
}
@Test
public void hasMetaAnnotationWhenMatchesMetaAnnotationReturnsTrue() {
void hasMetaAnnotationWhenMatchesMetaAnnotationReturnsTrue() {
assertThat(get(WithMetaAnnotations.class).hasMetaAnnotation(MetaAnnotation1.class.getName())).isTrue();
assertThat(get(WithMetaAnnotations.class).hasMetaAnnotation(MetaAnnotation2.class.getName())).isTrue();
}
@Test
public void hasMetaAnnotationWhenDoesNotMatchDirectOrMetaAnnotationReturnsFalse() {
void hasMetaAnnotationWhenDoesNotMatchDirectOrMetaAnnotationReturnsFalse() {
assertThat(get(TestClass.class).hasMetaAnnotation(MetaAnnotation1.class.getName())).isFalse();
}
@Test
public void hasAnnotatedMethodsWhenMatchesDirectAnnotationReturnsTrue() {
void hasAnnotatedMethodsWhenMatchesDirectAnnotationReturnsTrue() {
assertThat(get(WithAnnotatedMethod.class).hasAnnotatedMethods(DirectAnnotation1.class.getName())).isTrue();
}
@Test
public void hasAnnotatedMethodsWhenMatchesMetaAnnotationReturnsTrue() {
void hasAnnotatedMethodsWhenMatchesMetaAnnotationReturnsTrue() {
assertThat(get(WithMetaAnnotatedMethod.class).hasAnnotatedMethods(MetaAnnotation2.class.getName())).isTrue();
}
@Test
public void hasAnnotatedMethodsWhenDoesNotMatchAnyAnnotationReturnsFalse() {
void hasAnnotatedMethodsWhenDoesNotMatchAnyAnnotationReturnsFalse() {
assertThat(get(WithAnnotatedMethod.class).hasAnnotatedMethods(MetaAnnotation2.class.getName())).isFalse();
assertThat(get(WithNonAnnotatedMethod.class).hasAnnotatedMethods(DirectAnnotation1.class.getName())).isFalse();
}
@Test
public void getAnnotatedMethodsReturnsMatchingAnnotatedAndMetaAnnotatedMethods() {
void getAnnotatedMethodsReturnsMatchingAnnotatedAndMetaAnnotatedMethods() {
assertThat(get(WithDirectAndMetaAnnotatedMethods.class).getAnnotatedMethods(MetaAnnotation2.class.getName()))
.extracting(MethodMetadata::getMethodName)
.containsExactlyInAnyOrder("direct", "meta");

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -38,7 +38,7 @@ import static org.assertj.core.api.Assertions.entry;
public abstract class AbstractMethodMetadataTests {
@Test
public void verifyEquals() {
void verifyEquals() {
MethodMetadata withMethod1 = getTagged(WithMethod.class);
MethodMetadata withMethod2 = getTagged(WithMethod.class);
MethodMetadata withMethodWithTwoArguments1 = getTagged(WithMethodWithTwoArguments.class);
@ -61,7 +61,7 @@ public abstract class AbstractMethodMetadataTests {
}
@Test
public void verifyHashCode() {
void verifyHashCode() {
MethodMetadata withMethod1 = getTagged(WithMethod.class);
MethodMetadata withMethod2 = getTagged(WithMethod.class);
MethodMetadata withMethodWithTwoArguments1 = getTagged(WithMethodWithTwoArguments.class);
@ -74,7 +74,7 @@ public abstract class AbstractMethodMetadataTests {
}
@Test
public void verifyToString() {
void verifyToString() {
assertThat(getTagged(WithMethod.class).toString())
.endsWith(WithMethod.class.getName() + ".test()");
@ -86,66 +86,66 @@ public abstract class AbstractMethodMetadataTests {
}
@Test
public void getMethodNameReturnsMethodName() {
void getMethodNameReturnsMethodName() {
assertThat(getTagged(WithMethod.class).getMethodName()).isEqualTo("test");
}
@Test
public void getDeclaringClassReturnsDeclaringClass() {
void getDeclaringClassReturnsDeclaringClass() {
assertThat(getTagged(WithMethod.class).getDeclaringClassName()).isEqualTo(
WithMethod.class.getName());
}
@Test
public void getReturnTypeReturnsReturnType() {
void getReturnTypeReturnsReturnType() {
assertThat(getTagged(WithMethod.class).getReturnTypeName()).isEqualTo(
String.class.getName());
}
@Test
public void isAbstractWhenAbstractReturnsTrue() {
void isAbstractWhenAbstractReturnsTrue() {
assertThat(getTagged(WithAbstractMethod.class).isAbstract()).isTrue();
}
@Test
public void isAbstractWhenNotAbstractReturnsFalse() {
void isAbstractWhenNotAbstractReturnsFalse() {
assertThat(getTagged(WithMethod.class).isAbstract()).isFalse();
}
@Test
public void isStatusWhenStaticReturnsTrue() {
void isStatusWhenStaticReturnsTrue() {
assertThat(getTagged(WithStaticMethod.class).isStatic()).isTrue();
}
@Test
public void isStaticWhenNotStaticReturnsFalse() {
void isStaticWhenNotStaticReturnsFalse() {
assertThat(getTagged(WithMethod.class).isStatic()).isFalse();
}
@Test
public void isFinalWhenFinalReturnsTrue() {
void isFinalWhenFinalReturnsTrue() {
assertThat(getTagged(WithFinalMethod.class).isFinal()).isTrue();
}
@Test
public void isFinalWhenNonFinalReturnsFalse() {
void isFinalWhenNonFinalReturnsFalse() {
assertThat(getTagged(WithMethod.class).isFinal()).isFalse();
}
@Test
public void isOverridableWhenOverridableReturnsTrue() {
void isOverridableWhenOverridableReturnsTrue() {
assertThat(getTagged(WithMethod.class).isOverridable()).isTrue();
}
@Test
public void isOverridableWhenNonOverridableReturnsFalse() {
void isOverridableWhenNonOverridableReturnsFalse() {
assertThat(getTagged(WithStaticMethod.class).isOverridable()).isFalse();
assertThat(getTagged(WithFinalMethod.class).isOverridable()).isFalse();
assertThat(getTagged(WithPrivateMethod.class).isOverridable()).isFalse();
}
@Test
public void getAnnotationsReturnsDirectAnnotations() {
void getAnnotationsReturnsDirectAnnotations() {
MethodMetadata metadata = getTagged(WithDirectAnnotation.class);
assertThat(metadata.getAnnotations().stream().filter(
MergedAnnotation::isDirectlyPresent).map(
@ -155,32 +155,32 @@ public abstract class AbstractMethodMetadataTests {
}
@Test
public void isAnnotatedWhenMatchesDirectAnnotationReturnsTrue() {
void isAnnotatedWhenMatchesDirectAnnotationReturnsTrue() {
assertThat(getTagged(WithDirectAnnotation.class).isAnnotated(
DirectAnnotation.class.getName())).isTrue();
}
@Test
public void isAnnotatedWhenMatchesMetaAnnotationReturnsTrue() {
void isAnnotatedWhenMatchesMetaAnnotationReturnsTrue() {
assertThat(getTagged(WithMetaAnnotation.class).isAnnotated(
DirectAnnotation.class.getName())).isTrue();
}
@Test
public void isAnnotatedWhenDoesNotMatchDirectOrMetaAnnotationReturnsFalse() {
void isAnnotatedWhenDoesNotMatchDirectOrMetaAnnotationReturnsFalse() {
assertThat(getTagged(WithMethod.class).isAnnotated(
DirectAnnotation.class.getName())).isFalse();
}
@Test
public void getAnnotationAttributesReturnsAttributes() {
void getAnnotationAttributesReturnsAttributes() {
assertThat(getTagged(WithAnnotationAttributes.class).getAnnotationAttributes(
AnnotationAttributes.class.getName())).containsOnly(entry("name", "test"),
entry("size", 1));
}
@Test
public void getAllAnnotationAttributesReturnsAllAttributes() {
void getAllAnnotationAttributesReturnsAllAttributes() {
MultiValueMap<String, Object> attributes = getTagged(WithMetaAnnotationAttributes.class)
.getAllAnnotationAttributes(AnnotationAttributes.class.getName());
assertThat(attributes).containsOnlyKeys("name", "size");

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -425,7 +425,7 @@ class AnnotationMetadataTests {
List<Object> allMeta = method.getAllAnnotationAttributes(DirectAnnotation.class.getName()).get("value");
assertThat(new HashSet<>(allMeta)).isEqualTo(new HashSet<Object>(Arrays.asList("direct", "meta")));
allMeta = method.getAllAnnotationAttributes(DirectAnnotation.class.getName()).get("additional");
assertThat(new HashSet<>(allMeta)).isEqualTo(new HashSet<Object>(Arrays.asList("direct")));
assertThat(new HashSet<>(allMeta)).isEqualTo(new HashSet<Object>(List.of("direct")));
assertThat(metadata.isAnnotated(IsAnnotatedAnnotation.class.getName())).isTrue();

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -450,6 +450,7 @@ class ClassUtilsTests {
}
@Test
@SuppressWarnings("Convert2Lambda")
void isNotLambda() {
assertIsNotLambda(new EnigmaSupplier());

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -61,7 +61,7 @@ class CompositeIteratorTests {
void multipleIterators() {
CompositeIterator<String> it = new CompositeIterator<>();
it.add(Arrays.asList("0", "1").iterator());
it.add(Arrays.asList("2").iterator());
it.add(List.of("2").iterator());
it.add(Arrays.asList("3", "4").iterator());
for (int i = 0; i < 5; i++) {
assertThat(it.hasNext()).isTrue();

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -19,6 +19,7 @@ package org.springframework.util;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@ -36,7 +37,7 @@ class DigestUtilsTests {
@BeforeEach
void createBytes() throws UnsupportedEncodingException {
bytes = "Hello World".getBytes("UTF-8");
bytes = "Hello World".getBytes(StandardCharsets.UTF_8);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -16,9 +16,10 @@
package org.springframework.util;
import java.util.List;
import org.junit.jupiter.api.Test;
import static java.util.Arrays.asList;
import static org.assertj.core.api.Assertions.assertThat;
/**
@ -28,7 +29,7 @@ class ExceptionTypeFilterTests {
@Test
void subClassMatch() {
ExceptionTypeFilter filter = new ExceptionTypeFilter(asList(RuntimeException.class), null, true);
ExceptionTypeFilter filter = new ExceptionTypeFilter(List.of(RuntimeException.class), null, true);
assertThat(filter.match(RuntimeException.class)).isTrue();
assertThat(filter.match(IllegalStateException.class)).isTrue();
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -16,6 +16,8 @@
package org.springframework.util;
import java.util.List;
import org.junit.jupiter.api.Test;
import static java.util.Arrays.asList;
@ -60,7 +62,7 @@ class InstanceFilterTests {
@Test
void includesAndExcludesFiltersConflict() {
InstanceFilter<String> filter = new InstanceFilter<>(
asList("First"), asList("First"), true);
List.of("First"), List.of("First"), true);
doNotMatch(filter, "First");
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -113,7 +113,7 @@ class PropertiesPersisterTests {
private String storeProperties(Properties props, String header, boolean useWriter) throws IOException {
DefaultPropertiesPersister persister = new DefaultPropertiesPersister();
String propCopy = null;
String propCopy;
if (useWriter) {
StringWriter propWriter = new StringWriter();
persister.store(props, propWriter, header);

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -16,6 +16,8 @@
package org.springframework.util;
import java.nio.charset.StandardCharsets;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@ -38,7 +40,7 @@ class ResizableByteArrayOutputStreamTests {
@BeforeEach
void setUp() throws Exception {
this.baos = new ResizableByteArrayOutputStream(INITIAL_CAPACITY);
this.helloBytes = "Hello World".getBytes("UTF-8");
this.helloBytes = "Hello World".getBytes(StandardCharsets.UTF_8);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -47,7 +47,6 @@ class SerializationUtilsTests {
}
@Test
@SuppressWarnings("deprecation")
void serializeNonSerializableRecord() {
record Person(String firstName, String lastName) {}
Person jane = new Person("Jane", "Doe");

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -41,7 +41,6 @@ import static org.mockito.Mockito.mock;
class UnmodifiableMultiValueMapTests {
@Test
@SuppressWarnings("unchecked")
void delegation() {
MultiValueMap<String, String> mock = mock();
UnmodifiableMultiValueMap<String, String> map = new UnmodifiableMultiValueMap<>(mock);

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -30,6 +30,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
* @author Chris Beams
* @author Phillip Webb
*/
@Deprecated
class ComparableComparatorTests {
@Test

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -29,6 +29,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Chris Beams
* @author Phillip Webb
*/
@Deprecated
class NullSafeComparatorTests {
@Test

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -31,7 +31,6 @@ import static org.mockito.Mockito.mock;
@SuppressWarnings("deprecation")
class FutureAdapterTests {
@SuppressWarnings("unchecked")
private Future<Integer> adaptee = mock();
private FutureAdapter<String, Integer> adapter = new FutureAdapter<>(adaptee) {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -33,7 +33,7 @@ import static org.mockito.Mockito.verifyNoInteractions;
* @author Arjen Poutsma
* @author Sebastien Deleuze
*/
@SuppressWarnings({ "unchecked", "deprecation" })
@SuppressWarnings({ "deprecation" })
class ListenableFutureTaskTests {
@Test

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -18,6 +18,7 @@ package org.springframework.util.xml;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
@ -133,7 +134,7 @@ abstract class AbstractStaxXMLReaderTests {
Transformer transformer = TransformerFactory.newInstance().newTransformer();
AbstractStaxXMLReader staxXmlReader = createStaxXmlReader(
new ByteArrayInputStream(xml.getBytes("UTF-8")));
new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8)));
SAXSource source = new SAXSource(staxXmlReader, new InputSource());
DOMResult result = new DOMResult();

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -67,21 +67,21 @@ public abstract class AbstractDecoderTests<D extends Decoder<?>> extends Abstrac
* Subclasses should implement this method to test {@link Decoder#canDecode}.
*/
@Test
public abstract void canDecode() throws Exception;
protected abstract void canDecode() throws Exception;
/**
* Subclasses should implement this method to test {@link Decoder#decode}, possibly using
* {@link #testDecodeAll} or other helper methods.
*/
@Test
public abstract void decode() throws Exception;
protected abstract void decode() throws Exception;
/**
* Subclasses should implement this method to test {@link Decoder#decodeToMono}, possibly using
* {@link #testDecodeToMonoAll}.
*/
@Test
public abstract void decodeToMono() throws Exception;
protected abstract void decodeToMono() throws Exception;
// Flux

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -67,14 +67,14 @@ public abstract class AbstractEncoderTests<E extends Encoder<?>> extends Abstrac
* Subclasses should implement this method to test {@link Encoder#canEncode}.
*/
@Test
public abstract void canEncode() throws Exception;
protected abstract void canEncode() throws Exception;
/**
* Subclasses should implement this method to test {@link Encoder#encode}, possibly using
* {@link #testEncodeAll} or other helper methods.
*/
@Test
public abstract void encode() throws Exception;
protected abstract void encode() throws Exception;
/**