Browse Source

Polish

pull/31953/head
Stéphane Nicoll 2 years ago
parent
commit
af2e13e211
  1. 3
      spring-core/src/test/java/org/springframework/aot/hint/ReflectionHintsTests.java
  2. 3
      spring-core/src/test/java/org/springframework/aot/hint/ResourceHintsTests.java
  3. 8
      spring-core/src/test/java/org/springframework/core/GenericTypeResolverTests.java
  4. 14
      spring-core/src/test/java/org/springframework/core/annotation/AnnotatedElementUtilsTests.java
  5. 4
      spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java
  6. 5
      spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsComposedOnSingleAnnotatedElementTests.java
  7. 15
      spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsTests.java
  8. 6
      spring-core/src/test/java/org/springframework/core/annotation/MultipleComposedAnnotationsOnSingleAnnotatedElementTests.java
  9. 8
      spring-core/src/test/java/org/springframework/core/codec/ByteArrayDecoderTests.java
  10. 6
      spring-core/src/test/java/org/springframework/core/codec/ByteArrayEncoderTests.java
  11. 8
      spring-core/src/test/java/org/springframework/core/codec/ByteBufferDecoderTests.java
  12. 6
      spring-core/src/test/java/org/springframework/core/codec/ByteBufferEncoderTests.java
  13. 8
      spring-core/src/test/java/org/springframework/core/codec/CharBufferDecoderTests.java
  14. 6
      spring-core/src/test/java/org/springframework/core/codec/CharSequenceEncoderTests.java
  15. 8
      spring-core/src/test/java/org/springframework/core/codec/DataBufferDecoderTests.java
  16. 6
      spring-core/src/test/java/org/springframework/core/codec/DataBufferEncoderTests.java
  17. 8
      spring-core/src/test/java/org/springframework/core/codec/Netty5BufferDecoderTests.java
  18. 8
      spring-core/src/test/java/org/springframework/core/codec/NettyByteBufDecoderTests.java
  19. 6
      spring-core/src/test/java/org/springframework/core/codec/NettyByteBufEncoderTests.java
  20. 10
      spring-core/src/test/java/org/springframework/core/codec/ResourceDecoderTests.java
  21. 6
      spring-core/src/test/java/org/springframework/core/codec/ResourceEncoderTests.java
  22. 8
      spring-core/src/test/java/org/springframework/core/codec/StringDecoderTests.java
  23. 6
      spring-core/src/test/java/org/springframework/core/convert/support/CollectionToCollectionConverterTests.java
  24. 6
      spring-core/src/test/java/org/springframework/core/convert/support/MapToMapConverterTests.java
  25. 5
      spring-core/src/test/java/org/springframework/core/convert/support/StreamConverterTests.java
  26. 3
      spring-core/src/test/java/org/springframework/core/env/CustomEnvironmentTests.java
  27. 23
      spring-core/src/test/java/org/springframework/core/env/PropertySourceTests.java
  28. 12
      spring-core/src/test/java/org/springframework/core/env/StandardEnvironmentTests.java
  29. 3
      spring-core/src/test/java/org/springframework/core/io/buffer/DataBufferUtilsTests.java
  30. 7
      spring-core/src/test/java/org/springframework/core/io/support/EncodedResourceTests.java
  31. 78
      spring-core/src/test/java/org/springframework/core/type/AbstractAnnotationMetadataTests.java
  32. 42
      spring-core/src/test/java/org/springframework/core/type/AbstractMethodMetadataTests.java
  33. 4
      spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java
  34. 3
      spring-core/src/test/java/org/springframework/util/ClassUtilsTests.java
  35. 4
      spring-core/src/test/java/org/springframework/util/CompositeIteratorTests.java
  36. 5
      spring-core/src/test/java/org/springframework/util/DigestUtilsTests.java
  37. 7
      spring-core/src/test/java/org/springframework/util/ExceptionTypeFilterTests.java
  38. 6
      spring-core/src/test/java/org/springframework/util/InstanceFilterTests.java
  39. 4
      spring-core/src/test/java/org/springframework/util/PropertiesPersisterTests.java
  40. 6
      spring-core/src/test/java/org/springframework/util/ResizableByteArrayOutputStreamTests.java
  41. 3
      spring-core/src/test/java/org/springframework/util/SerializationUtilsTests.java
  42. 3
      spring-core/src/test/java/org/springframework/util/UnmodifiableMultiValueMapTests.java
  43. 3
      spring-core/src/test/java/org/springframework/util/comparator/ComparableComparatorTests.java
  44. 3
      spring-core/src/test/java/org/springframework/util/comparator/NullSafeComparatorTests.java
  45. 3
      spring-core/src/test/java/org/springframework/util/concurrent/FutureAdapterTests.java
  46. 4
      spring-core/src/test/java/org/springframework/util/concurrent/ListenableFutureTaskTests.java
  47. 5
      spring-core/src/test/java/org/springframework/util/xml/AbstractStaxXMLReaderTests.java
  48. 8
      spring-core/src/testFixtures/java/org/springframework/core/testfixture/codec/AbstractDecoderTests.java
  49. 6
      spring-core/src/testFixtures/java/org/springframework/core/testfixture/codec/AbstractEncoderTests.java

3
spring-core/src/test/java/org/springframework/aot/hint/ReflectionHintsTests.java

@ -1,5 +1,5 @@ @@ -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 { @@ -56,7 +56,6 @@ class ReflectionHintsTests {
}
@Test
@SuppressWarnings("unchecked")
void registerTypeIfPresentIgnoresMissingClass() {
Consumer<TypeHint.Builder> hintBuilder = mock();
this.reflectionHints.registerTypeIfPresent(null, "com.example.DoesNotExist", hintBuilder);

3
spring-core/src/test/java/org/springframework/aot/hint/ResourceHintsTests.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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);

8
spring-core/src/test/java/org/springframework/core/GenericTypeResolverTests.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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);

14
spring-core/src/test/java/org/springframework/core/annotation/AnnotatedElementUtilsTests.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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

4
spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java

@ -1,5 +1,5 @@ @@ -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 { @@ -882,7 +882,7 @@ class AnnotationUtilsTests {
}
@Test
void synthesizeAnnotationFromMapWithImplicitAttributeAliases() throws Exception {
void synthesizeAnnotationFromMapWithImplicitAttributeAliases() {
assertAnnotationSynthesisFromMapWithImplicitAliases("value");
assertAnnotationSynthesisFromMapWithImplicitAliases("location1");
assertAnnotationSynthesisFromMapWithImplicitAliases("location2");

5
spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsComposedOnSingleAnnotatedElementTests.java

@ -1,5 +1,5 @@ @@ -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 { @@ -161,8 +161,7 @@ class MergedAnnotationsComposedOnSingleAnnotatedElementTests {
}
@Test
void typeHierarchyStrategyMultipleComposedAnnotationsOnBridgeMethod()
throws Exception {
void typeHierarchyStrategyMultipleComposedAnnotationsOnBridgeMethod() {
assertTypeHierarchyStrategyBehavior(getBridgeMethod());
}

15
spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsTests.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -1965,7 +1964,7 @@ class MergedAnnotationsTests {
}
@Test
void synthesizeFromMapWithImplicitAttributeAliases() throws Exception {
void synthesizeFromMapWithImplicitAttributeAliases() {
testSynthesisFromMapWithImplicitAliases("value");
testSynthesisFromMapWithImplicitAliases("location1");
testSynthesisFromMapWithImplicitAliases("location2");

6
spring-core/src/test/java/org/springframework/core/annotation/MultipleComposedAnnotationsOnSingleAnnotatedElementTests.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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 { @@ -178,7 +178,7 @@ class MultipleComposedAnnotationsOnSingleAnnotatedElementTests {
}
@Test
void findMultipleComposedAnnotationsOnBridgeMethod() throws Exception {
void findMultipleComposedAnnotationsOnBridgeMethod() {
assertFindAllMergedAnnotationsBehavior(getBridgeMethod());
}

8
spring-core/src/test/java/org/springframework/core/codec/ByteArrayDecoderTests.java

@ -1,5 +1,5 @@ @@ -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> { @@ -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> { @@ -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> { @@ -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));

6
spring-core/src/test/java/org/springframework/core/codec/ByteArrayEncoderTests.java

@ -1,5 +1,5 @@ @@ -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> { @@ -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> { @@ -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

8
spring-core/src/test/java/org/springframework/core/codec/ByteBufferDecoderTests.java

@ -1,5 +1,5 @@ @@ -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> { @@ -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> { @@ -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> { @@ -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));

6
spring-core/src/test/java/org/springframework/core/codec/ByteBufferEncoderTests.java

@ -1,5 +1,5 @@ @@ -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> { @@ -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> { @@ -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);

8
spring-core/src/test/java/org/springframework/core/codec/CharBufferDecoderTests.java

@ -1,5 +1,5 @@ @@ -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> { @@ -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> { @@ -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> { @@ -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"),

6
spring-core/src/test/java/org/springframework/core/codec/CharSequenceEncoderTests.java

@ -1,5 +1,5 @@ @@ -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> @@ -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> @@ -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

8
spring-core/src/test/java/org/springframework/core/codec/DataBufferDecoderTests.java

@ -1,5 +1,5 @@ @@ -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> { @@ -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> { @@ -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> { @@ -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));

6
spring-core/src/test/java/org/springframework/core/codec/DataBufferEncoderTests.java

@ -1,5 +1,5 @@ @@ -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> { @@ -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> { @@ -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);

8
spring-core/src/test/java/org/springframework/core/codec/Netty5BufferDecoderTests.java

@ -1,5 +1,5 @@ @@ -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> @@ -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> @@ -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> @@ -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));

8
spring-core/src/test/java/org/springframework/core/codec/NettyByteBufDecoderTests.java

@ -1,5 +1,5 @@ @@ -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> @@ -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> @@ -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> @@ -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));

6
spring-core/src/test/java/org/springframework/core/codec/NettyByteBufEncoderTests.java

@ -1,5 +1,5 @@ @@ -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> @@ -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> @@ -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

10
spring-core/src/test/java/org/springframework/core/codec/ResourceDecoderTests.java

@ -1,5 +1,5 @@ @@ -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> { @@ -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> { @@ -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> { @@ -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> { @@ -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 -> {

6
spring-core/src/test/java/org/springframework/core/codec/ResourceEncoderTests.java

@ -1,5 +1,5 @@ @@ -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> { @@ -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> { @@ -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

8
spring-core/src/test/java/org/springframework/core/codec/StringDecoderTests.java

@ -1,5 +1,5 @@ @@ -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> { @@ -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> { @@ -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> { @@ -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"),

6
spring-core/src/test/java/org/springframework/core/convert/support/CollectionToCollectionConverterTests.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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));

6
spring-core/src/test/java/org/springframework/core/convert/support/MapToMapConverterTests.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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

5
spring-core/src/test/java/org/springframework/core/convert/support/StreamConverterTests.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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 { @@ -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 { @@ -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"));

3
spring-core/src/test/java/org/springframework/core/env/CustomEnvironmentTests.java vendored

@ -1,5 +1,5 @@ @@ -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 { @@ -75,7 +75,6 @@ class CustomEnvironmentTests {
void withMultiCustomReservedDefaultProfile() {
class CustomEnvironment extends AbstractEnvironment {
@Override
@SuppressWarnings("serial")
protected Set<String> getReservedDefaultProfiles() {
return Set.of("rd1", "rd2");
}

23
spring-core/src/test/java/org/springframework/core/env/PropertySourceTests.java vendored

@ -1,5 +1,5 @@ @@ -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 { @@ -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");

12
spring-core/src/test/java/org/springframework/core/env/StandardEnvironmentTests.java vendored

@ -1,5 +1,5 @@ @@ -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 { @@ -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 { @@ -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 { @@ -495,7 +489,6 @@ class StandardEnvironmentTests {
}
@Test
@SuppressWarnings("deprecation")
void activeProfileSetProgrammatically() {
assertThat(environment.matchesProfiles("p1", "p2")).isFalse();
@ -510,7 +503,6 @@ class StandardEnvironmentTests { @@ -510,7 +503,6 @@ class StandardEnvironmentTests {
}
@Test
@SuppressWarnings("deprecation")
void activeProfileSetViaProperty() {
assertThat(environment.matchesProfiles("p1")).isFalse();
@ -519,7 +511,6 @@ class StandardEnvironmentTests { @@ -519,7 +511,6 @@ class StandardEnvironmentTests {
}
@Test
@SuppressWarnings("deprecation")
void defaultProfile() {
assertThat(environment.matchesProfiles("pd")).isFalse();
@ -532,7 +523,6 @@ class StandardEnvironmentTests { @@ -532,7 +523,6 @@ class StandardEnvironmentTests {
}
@Test
@SuppressWarnings("deprecation")
void withNotOperator() {
assertThat(environment.matchesProfiles("p1")).isFalse();
assertThat(environment.matchesProfiles("!p1")).isTrue();

3
spring-core/src/test/java/org/springframework/core/io/buffer/DataBufferUtilsTests.java

@ -1,5 +1,5 @@ @@ -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 { @@ -468,7 +468,6 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
@SuppressWarnings("unchecked")
void writeAsynchronousFileChannelErrorInWrite(DataBufferFactory bufferFactory) throws Exception {
super.bufferFactory = bufferFactory;

7
spring-core/src/test/java/org/springframework/core/io/support/EncodedResourceTests.java

@ -1,5 +1,5 @@ @@ -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 @@ @@ -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 { @@ -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");

78
spring-core/src/test/java/org/springframework/core/type/AbstractAnnotationMetadataTests.java

@ -1,5 +1,5 @@ @@ -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; @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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");

42
spring-core/src/test/java/org/springframework/core/type/AbstractMethodMetadataTests.java

@ -1,5 +1,5 @@ @@ -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; @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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");

4
spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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();

3
spring-core/src/test/java/org/springframework/util/ClassUtilsTests.java

@ -1,5 +1,5 @@ @@ -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 { @@ -450,6 +450,7 @@ class ClassUtilsTests {
}
@Test
@SuppressWarnings("Convert2Lambda")
void isNotLambda() {
assertIsNotLambda(new EnigmaSupplier());

4
spring-core/src/test/java/org/springframework/util/CompositeIteratorTests.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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();

5
spring-core/src/test/java/org/springframework/util/DigestUtilsTests.java

@ -1,5 +1,5 @@ @@ -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; @@ -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 { @@ -36,7 +37,7 @@ class DigestUtilsTests {
@BeforeEach
void createBytes() throws UnsupportedEncodingException {
bytes = "Hello World".getBytes("UTF-8");
bytes = "Hello World".getBytes(StandardCharsets.UTF_8);
}

7
spring-core/src/test/java/org/springframework/util/ExceptionTypeFilterTests.java

@ -1,5 +1,5 @@ @@ -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 @@ @@ -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 { @@ -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();
}

6
spring-core/src/test/java/org/springframework/util/InstanceFilterTests.java

@ -1,5 +1,5 @@ @@ -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 @@ @@ -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 { @@ -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");
}

4
spring-core/src/test/java/org/springframework/util/PropertiesPersisterTests.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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);

6
spring-core/src/test/java/org/springframework/util/ResizableByteArrayOutputStreamTests.java

@ -1,5 +1,5 @@ @@ -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 @@ @@ -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 { @@ -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);
}

3
spring-core/src/test/java/org/springframework/util/SerializationUtilsTests.java

@ -1,5 +1,5 @@ @@ -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 { @@ -47,7 +47,6 @@ class SerializationUtilsTests {
}
@Test
@SuppressWarnings("deprecation")
void serializeNonSerializableRecord() {
record Person(String firstName, String lastName) {}
Person jane = new Person("Jane", "Doe");

3
spring-core/src/test/java/org/springframework/util/UnmodifiableMultiValueMapTests.java

@ -1,5 +1,5 @@ @@ -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; @@ -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);

3
spring-core/src/test/java/org/springframework/util/comparator/ComparableComparatorTests.java

@ -1,5 +1,5 @@ @@ -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; @@ -30,6 +30,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
* @author Chris Beams
* @author Phillip Webb
*/
@Deprecated
class ComparableComparatorTests {
@Test

3
spring-core/src/test/java/org/springframework/util/comparator/NullSafeComparatorTests.java

@ -1,5 +1,5 @@ @@ -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; @@ -29,6 +29,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Chris Beams
* @author Phillip Webb
*/
@Deprecated
class NullSafeComparatorTests {
@Test

3
spring-core/src/test/java/org/springframework/util/concurrent/FutureAdapterTests.java

@ -1,5 +1,5 @@ @@ -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; @@ -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) {

4
spring-core/src/test/java/org/springframework/util/concurrent/ListenableFutureTaskTests.java

@ -1,5 +1,5 @@ @@ -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; @@ -33,7 +33,7 @@ import static org.mockito.Mockito.verifyNoInteractions;
* @author Arjen Poutsma
* @author Sebastien Deleuze
*/
@SuppressWarnings({ "unchecked", "deprecation" })
@SuppressWarnings({ "deprecation" })
class ListenableFutureTaskTests {
@Test

5
spring-core/src/test/java/org/springframework/util/xml/AbstractStaxXMLReaderTests.java

@ -1,5 +1,5 @@ @@ -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; @@ -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 { @@ -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();

8
spring-core/src/testFixtures/java/org/springframework/core/testfixture/codec/AbstractDecoderTests.java

@ -1,5 +1,5 @@ @@ -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 @@ -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

6
spring-core/src/testFixtures/java/org/springframework/core/testfixture/codec/AbstractEncoderTests.java

@ -1,5 +1,5 @@ @@ -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 @@ -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;
/**

Loading…
Cancel
Save