From fab96cad67dbc86deaec31fcced8b4091488b8bc Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Tue, 20 Aug 2019 14:43:24 +0200 Subject: [PATCH] Use default visibility for test classes and methods in spring-core See gh-23451 --- .../type/AnnotationTypeFilterTestsTypes.java | 29 +- .../type/AspectJTypeFilterTestsTypes.java | 19 +- .../type/AssignableTypeFilterTestsTypes.java | 23 +- .../example/type/InheritedAnnotation.java | 26 ++ .../example/type/NonInheritedAnnotation.java | 24 ++ .../core/AttributeAccessorSupportTests.java | 10 +- .../core/BridgeMethodResolverTests.java | 50 +-- .../core/CollectionFactoryTests.java | 50 +-- .../springframework/core/ConstantsTests.java | 24 +- .../core/ConventionsTests.java | 20 +- .../core/ExceptionDepthComparatorTests.java | 20 +- .../core/GenericTypeResolverTests.java | 30 +- ...ableTableParameterNameDiscovererTests.java | 24 +- .../core/MethodParameterTests.java | 33 +- .../core/NestedExceptionTests.java | 10 +- .../core/OrderComparatorTests.java | 36 +- .../core/ParameterizedTypeReferenceTests.java | 12 +- ...ioritizedParameterNameDiscovererTests.java | 8 +- .../core/ReactiveAdapterRegistryTests.java | 42 +-- .../core/ResolvableTypeTests.java | 274 +++++++------- .../core/SerializableTypeWrapperTests.java | 18 +- .../core/SimpleAliasRegistryTests.java | 6 +- .../core/SortedPropertiesTests.java | 24 +- ...dReflectionParameterNameDiscoverTests.java | 10 +- .../AnnotatedElementUtilsTests.java | 158 ++++----- .../annotation/AnnotationAttributesTests.java | 24 +- .../AnnotationAwareOrderComparatorTests.java | 18 +- .../AnnotationBackCompatibiltyTests.java | 6 +- .../annotation/AnnotationFilterTests.java | 26 +- .../AnnotationIntrospectionFailureTests.java | 8 +- .../AnnotationTypeMappingsTests.java | 90 ++--- .../core/annotation/AnnotationUtilsTests.java | 144 ++++---- .../annotation/AnnotationsScannerTests.java | 137 +++---- .../annotation/AttributeMethodsTests.java | 38 +- .../ComposedRepeatableAnnotationsTests.java | 46 +-- .../MergedAnnotationClassLoaderTests.java | 4 +- .../MergedAnnotationCollectorsTests.java | 12 +- .../MergedAnnotationPredicatesTests.java | 24 +- .../MergedAnnotationsCollectionTests.java | 44 +-- ...ComposedOnSingleAnnotatedElementTests.java | 40 +-- ...dAnnotationsRepeatableAnnotationTests.java | 46 +-- .../annotation/MergedAnnotationsTests.java | 335 +++++++++--------- .../MissingMergedAnnotationTests.java | 92 ++--- ...otationsOnSingleAnnotatedElementTests.java | 42 +-- .../annotation/OrderSourceProviderTests.java | 16 +- .../core/annotation/OrderUtilsTests.java | 14 +- .../PackagesAnnotationFilterTests.java | 16 +- .../annotation/RepeatableContainersTests.java | 34 +- .../SynthesizingMethodParameterTests.java | 12 +- .../annotation/TypeMappedAnnotationTests.java | 16 +- .../core/codec/AbstractDecoderTestCase.java | 3 +- .../core/codec/AbstractEncoderTestCase.java | 4 +- .../core/codec/ByteArrayDecoderTests.java | 4 +- .../core/codec/ByteArrayEncoderTests.java | 4 +- .../core/codec/ByteBufferDecoderTests.java | 4 +- .../core/codec/ByteBufferEncoderTests.java | 7 +- .../core/codec/CharSequenceEncoderTests.java | 8 +- .../core/codec/DataBufferDecoderTests.java | 5 +- .../core/codec/DataBufferEncoderTests.java | 5 +- .../core/codec/ResourceDecoderTests.java | 4 +- .../core/codec/ResourceEncoderTests.java | 4 +- .../codec/ResourceRegionEncoderTests.java | 16 +- .../core/codec/StringDecoderTests.java | 17 +- .../core/convert/TypeDescriptorTests.java | 142 ++++---- .../converter/ConvertingComparatorTests.java | 21 +- .../DefaultConversionServiceTests.java | 248 ++++++------- .../support/ByteBufferConverterTests.java | 19 +- .../CollectionToCollectionConverterTests.java | 38 +- .../GenericConversionServiceTests.java | 134 +++---- .../support/MapToMapConverterTests.java | 32 +- .../convert/support/StreamConverterTests.java | 22 +- .../env/CompositePropertySourceTests.java | 4 +- .../core/env/CustomEnvironmentTests.java | 11 +- .../JOptCommandLinePropertySourceTests.java | 24 +- .../core/env/MutablePropertySourcesTests.java | 14 +- .../core/env/ProfilesTests.java | 64 ++-- .../core/env/PropertySourceTests.java | 7 +- .../PropertySourcesPropertyResolverTests.java | 52 +-- .../env/SimpleCommandLineParserTests.java | 25 +- .../SimpleCommandLinePropertySourceTests.java | 19 +- .../core/env/StandardEnvironmentTests.java | 80 ++--- .../SystemEnvironmentPropertySourceTests.java | 18 +- .../core/io/ClassPathResourceTests.java | 26 +- .../core/io/PathResourceTests.java | 76 ++-- .../core/io/ResourceEditorTests.java | 16 +- .../core/io/ResourceTests.java | 46 +-- .../buffer/AbstractLeakCheckingTestCase.java | 4 +- .../core/io/buffer/DataBufferTests.java | 76 ++-- .../core/io/buffer/DataBufferUtilsTests.java | 82 ++--- .../LeakAwareDataBufferFactoryTests.java | 4 +- .../support/DataBufferTestUtilsTests.java | 4 +- .../core/io/support/EncodedResourceTests.java | 14 +- ...hMatchingResourcePatternResolverTests.java | 16 +- .../ResourceArrayPropertyEditorTests.java | 10 +- .../support/ResourcePropertySourceTests.java | 18 +- .../core/io/support/ResourceRegionTests.java | 8 +- .../support/SpringFactoriesLoaderTests.java | 8 +- .../core/log/LogSupportTests.java | 14 +- .../SerializationConverterTests.java | 10 +- .../core/style/DefaultValueStylerTests.java | 16 +- .../core/style/ToStringCreatorTests.java | 20 +- .../task/SimpleAsyncTaskExecutorTests.java | 12 +- ...AbstractClassMetadataMemberClassTests.java | 8 +- .../type/AbstractMethodMetadataTests.java | 1 + .../core/type/AnnotationMetadataTests.java | 36 +- .../core/type/AnnotationTypeFilterTests.java | 41 +-- .../core/type/AspectJTypeFilterTests.java | 104 +++--- .../core/type/AssignableTypeFilterTests.java | 29 +- .../type/CachingMetadataReaderLeakTests.java | 4 +- .../type/StandardAnnotationMetadataTests.java | 2 +- ...StandardClassMetadataMemberClassTests.java | 3 +- .../type/StandardMethodMetadataTests.java | 2 +- ...AnnotationMetadataReadingVisitorTests.java | 3 +- ...etadataReadingVisitorMemberClassTests.java | 3 +- .../MergedAnnotationMetadataVisitorTests.java | 14 +- .../MethodMetadataReadingVisitorTests.java | 2 +- .../SimpleAnnotationMetadataTests.java | 2 +- .../SimpleMethodMetadataTests.java | 2 +- .../springframework/tests/MockitoUtils.java | 3 - .../util/AntPathMatcherTests.java | 50 +-- .../org/springframework/util/AssertTests.java | 203 ++++++----- .../util/AutoPopulatingListTests.java | 12 +- .../util/Base64UtilsTests.java | 8 +- .../springframework/util/ClassUtilsTests.java | 70 ++-- .../util/CollectionUtilsTests.java | 26 +- .../util/CompositeIteratorTests.java | 13 +- .../util/ConcurrentReferenceHashMapTests.java | 88 ++--- .../util/DigestUtilsTests.java | 10 +- .../util/ExceptionTypeFilterTests.java | 7 +- .../util/ExponentialBackOffTests.java | 21 +- .../util/FastByteArrayOutputStreamTests.java | 40 +-- .../util/FileCopyUtilsTests.java | 14 +- .../util/FileSystemUtilsTests.java | 8 +- .../util/FixedBackOffTests.java | 14 +- .../util/InstanceFilterTests.java | 12 +- .../util/LinkedCaseInsensitiveMapTests.java | 34 +- .../util/LinkedMultiValueMapTests.java | 24 +- .../util/MethodInvokerTests.java | 18 +- .../springframework/util/MimeTypeTests.java | 76 ++-- .../util/NumberUtilsTests.java | 44 +-- .../util/ObjectUtilsTests.java | 220 ++++++------ .../util/PatternMatchUtilsTests.java | 18 +- .../util/PropertiesPersisterTests.java | 18 +- .../util/PropertyPlaceholderHelperTests.java | 24 +- .../util/ReflectionUtilsTests.java | 44 +-- .../ResizableByteArrayOutputStreamTests.java | 14 +- .../util/ResourceUtilsTests.java | 8 +- .../util/SerializationUtilsTests.java | 14 +- .../util/SocketUtilsTests.java | 50 +-- .../springframework/util/StopWatchTests.java | 12 +- .../util/StreamUtilsTests.java | 20 +- .../util/StringUtilsTests.java | 128 +++---- .../util/SystemPropertyUtilsTests.java | 26 +- .../springframework/util/TypeUtilsTests.java | 10 +- .../comparator/BooleanComparatorTests.java | 10 +- .../comparator/ComparableComparatorTests.java | 6 +- .../comparator/CompoundComparatorTests.java | 4 +- .../comparator/InstanceComparatorTests.java | 8 +- .../comparator/InvertibleComparatorTests.java | 14 +- .../comparator/NullSafeComparatorTests.java | 6 +- .../util/concurrent/FutureAdapterTests.java | 14 +- .../concurrent/ListenableFutureTaskTests.java | 10 +- .../MonoToListenableFutureAdapterTests.java | 10 +- .../SettableListenableFutureTests.java | 52 +-- .../util/unit/DataSizeTests.java | 76 ++-- .../util/xml/AbstractStaxHandlerTestCase.java | 12 +- .../xml/AbstractStaxXMLReaderTestCase.java | 14 +- .../util/xml/DomContentHandlerTests.java | 10 +- .../xml/ListBasedXMLEventReaderTests.java | 8 +- .../util/xml/SimpleNamespaceContextTests.java | 29 +- .../util/xml/StaxEventHandlerTests.java | 2 +- .../util/xml/StaxEventXMLReaderTests.java | 4 +- .../util/xml/StaxResultTests.java | 8 +- .../util/xml/StaxSourceTests.java | 12 +- .../util/xml/StaxStreamHandlerTests.java | 2 +- .../util/xml/StaxStreamXMLReaderTests.java | 4 +- .../util/xml/StaxUtilsTests.java | 14 +- .../util/xml/TransformerUtilsTests.java | 16 +- .../util/xml/XMLEventStreamReaderTests.java | 8 +- .../util/xml/XMLEventStreamWriterTests.java | 6 +- 180 files changed, 2920 insertions(+), 2899 deletions(-) rename spring-core/src/test/java/{org/springframework/core => example}/type/AnnotationTypeFilterTestsTypes.java (53%) rename spring-core/src/test/java/{org/springframework/core => example}/type/AspectJTypeFilterTestsTypes.java (62%) rename spring-core/src/test/java/{org/springframework/core => example}/type/AssignableTypeFilterTestsTypes.java (55%) create mode 100644 spring-core/src/test/java/example/type/InheritedAnnotation.java create mode 100644 spring-core/src/test/java/example/type/NonInheritedAnnotation.java diff --git a/spring-core/src/test/java/org/springframework/core/type/AnnotationTypeFilterTestsTypes.java b/spring-core/src/test/java/example/type/AnnotationTypeFilterTestsTypes.java similarity index 53% rename from spring-core/src/test/java/org/springframework/core/type/AnnotationTypeFilterTestsTypes.java rename to spring-core/src/test/java/example/type/AnnotationTypeFilterTestsTypes.java index 32e72c30e5..25f6501fbc 100644 --- a/spring-core/src/test/java/org/springframework/core/type/AnnotationTypeFilterTestsTypes.java +++ b/spring-core/src/test/java/example/type/AnnotationTypeFilterTestsTypes.java @@ -14,51 +14,52 @@ * limitations under the License. */ -package org.springframework.core.type; +package example.type; /** * We must use a standalone set of types to ensure that no one else is loading - * them and interfering with {@link ClassloadingAssertions#assertClassNotLoaded(String)}. + * them and interfering with + * {@link org.springframework.core.type.ClassloadingAssertions#assertClassNotLoaded(String)}. * * @author Ramnivas Laddad * @author Juergen Hoeller * @author Oliver Gierke * @author Sam Brannen - * @see AnnotationTypeFilterTests + * @see org.springframework.core.type.AnnotationTypeFilterTests */ -class AnnotationTypeFilterTestsTypes { +public class AnnotationTypeFilterTestsTypes { - @AnnotationTypeFilterTests.InheritedAnnotation - private static class SomeComponent { + @InheritedAnnotation + public static class SomeComponent { } - @AnnotationTypeFilterTests.InheritedAnnotation - private interface SomeComponentInterface { + @InheritedAnnotation + public interface SomeComponentInterface { } @SuppressWarnings("unused") - private static class SomeClassWithSomeComponentInterface implements Cloneable, SomeComponentInterface { + public static class SomeClassWithSomeComponentInterface implements Cloneable, SomeComponentInterface { } @SuppressWarnings("unused") - private static class SomeSubclassOfSomeComponent extends SomeComponent { + public static class SomeSubclassOfSomeComponent extends SomeComponent { } - @AnnotationTypeFilterTests.NonInheritedAnnotation - private static class SomeClassMarkedWithNonInheritedAnnotation { + @NonInheritedAnnotation + public static class SomeClassMarkedWithNonInheritedAnnotation { } @SuppressWarnings("unused") - private static class SomeSubclassOfSomeClassMarkedWithNonInheritedAnnotation extends SomeClassMarkedWithNonInheritedAnnotation { + public static class SomeSubclassOfSomeClassMarkedWithNonInheritedAnnotation extends SomeClassMarkedWithNonInheritedAnnotation { } @SuppressWarnings("unused") - private static class SomeNonCandidateClass { + public static class SomeNonCandidateClass { } } diff --git a/spring-core/src/test/java/org/springframework/core/type/AspectJTypeFilterTestsTypes.java b/spring-core/src/test/java/example/type/AspectJTypeFilterTestsTypes.java similarity index 62% rename from spring-core/src/test/java/org/springframework/core/type/AspectJTypeFilterTestsTypes.java rename to spring-core/src/test/java/example/type/AspectJTypeFilterTestsTypes.java index d0931304dc..d415164752 100644 --- a/spring-core/src/test/java/org/springframework/core/type/AspectJTypeFilterTestsTypes.java +++ b/spring-core/src/test/java/example/type/AspectJTypeFilterTestsTypes.java @@ -14,38 +14,39 @@ * limitations under the License. */ -package org.springframework.core.type; +package example.type; import org.springframework.stereotype.Component; /** * We must use a standalone set of types to ensure that no one else is loading - * them and interfering with {@link ClassloadingAssertions#assertClassNotLoaded(String)}. + * them and interfering with + * {@link org.springframework.core.type.ClassloadingAssertions#assertClassNotLoaded(String)}. * * @author Ramnivas Laddad * @author Sam Brannen - * @see AspectJTypeFilterTests + * @see org.springframework.core.type.AspectJTypeFilterTests */ public class AspectJTypeFilterTestsTypes { - interface SomeInterface { + public interface SomeInterface { } - static class SomeClass { + public static class SomeClass { } - static class SomeClassExtendingSomeClass extends SomeClass { + public static class SomeClassExtendingSomeClass extends SomeClass { } - static class SomeClassImplementingSomeInterface implements SomeInterface { + public static class SomeClassImplementingSomeInterface implements SomeInterface { } - static class SomeClassExtendingSomeClassExtendingSomeClassAndImplementingSomeInterface + public static class SomeClassExtendingSomeClassExtendingSomeClassAndImplementingSomeInterface extends SomeClassExtendingSomeClass implements SomeInterface { } @Component - static class SomeClassAnnotatedWithComponent { + public static class SomeClassAnnotatedWithComponent { } } diff --git a/spring-core/src/test/java/org/springframework/core/type/AssignableTypeFilterTestsTypes.java b/spring-core/src/test/java/example/type/AssignableTypeFilterTestsTypes.java similarity index 55% rename from spring-core/src/test/java/org/springframework/core/type/AssignableTypeFilterTestsTypes.java rename to spring-core/src/test/java/example/type/AssignableTypeFilterTestsTypes.java index c86b23a1c3..ceb4da3721 100644 --- a/spring-core/src/test/java/org/springframework/core/type/AssignableTypeFilterTestsTypes.java +++ b/spring-core/src/test/java/example/type/AssignableTypeFilterTestsTypes.java @@ -14,38 +14,39 @@ * limitations under the License. */ -package org.springframework.core.type; +package example.type; /** * We must use a standalone set of types to ensure that no one else is loading - * them and interfering with {@link ClassloadingAssertions#assertClassNotLoaded(String)}. + * them and interfering with + * {@link org.springframework.core.type.ClassloadingAssertions#assertClassNotLoaded(String)}. * * @author Ramnivas Laddad * @author Juergen Hoeller * @author Sam Brannen - * @see AssignableTypeFilterTests + * @see org.springframework.core.type.AssignableTypeFilterTests */ -class AssignableTypeFilterTestsTypes { +public class AssignableTypeFilterTestsTypes { - static class TestNonInheritingClass { + public static class TestNonInheritingClass { } - interface TestInterface { + public interface TestInterface { } - static class TestInterfaceImpl implements TestInterface { + public static class TestInterfaceImpl implements TestInterface { } - interface SomeDaoLikeInterface { + public interface SomeDaoLikeInterface { } - static class SomeDaoLikeImpl extends SimpleJdbcDaoSupport implements SomeDaoLikeInterface { + public static class SomeDaoLikeImpl extends SimpleJdbcDaoSupport implements SomeDaoLikeInterface { } - interface JdbcDaoSupport { + public interface JdbcDaoSupport { } - static class SimpleJdbcDaoSupport implements JdbcDaoSupport { + public static class SimpleJdbcDaoSupport implements JdbcDaoSupport { } } diff --git a/spring-core/src/test/java/example/type/InheritedAnnotation.java b/spring-core/src/test/java/example/type/InheritedAnnotation.java new file mode 100644 index 0000000000..961a3f8d6c --- /dev/null +++ b/spring-core/src/test/java/example/type/InheritedAnnotation.java @@ -0,0 +1,26 @@ +/* + * Copyright 2002-2019 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package example.type; + +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +@Inherited +@Retention(RetentionPolicy.RUNTIME) +public @interface InheritedAnnotation { +} diff --git a/spring-core/src/test/java/example/type/NonInheritedAnnotation.java b/spring-core/src/test/java/example/type/NonInheritedAnnotation.java new file mode 100644 index 0000000000..1e3a11812c --- /dev/null +++ b/spring-core/src/test/java/example/type/NonInheritedAnnotation.java @@ -0,0 +1,24 @@ +/* + * Copyright 2002-2019 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package example.type; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +@Retention(RetentionPolicy.RUNTIME) +public @interface NonInheritedAnnotation { +} diff --git a/spring-core/src/test/java/org/springframework/core/AttributeAccessorSupportTests.java b/spring-core/src/test/java/org/springframework/core/AttributeAccessorSupportTests.java index 23afd8918e..bd56c919ce 100644 --- a/spring-core/src/test/java/org/springframework/core/AttributeAccessorSupportTests.java +++ b/spring-core/src/test/java/org/springframework/core/AttributeAccessorSupportTests.java @@ -27,7 +27,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Sam Brannen * @since 2.0 */ -public class AttributeAccessorSupportTests { +class AttributeAccessorSupportTests { private static final String NAME = "foo"; @@ -36,20 +36,20 @@ public class AttributeAccessorSupportTests { private AttributeAccessor attributeAccessor = new SimpleAttributeAccessorSupport(); @Test - public void setAndGet() throws Exception { + void setAndGet() throws Exception { this.attributeAccessor.setAttribute(NAME, VALUE); assertThat(this.attributeAccessor.getAttribute(NAME)).isEqualTo(VALUE); } @Test - public void setAndHas() throws Exception { + void setAndHas() throws Exception { assertThat(this.attributeAccessor.hasAttribute(NAME)).isFalse(); this.attributeAccessor.setAttribute(NAME, VALUE); assertThat(this.attributeAccessor.hasAttribute(NAME)).isTrue(); } @Test - public void remove() throws Exception { + void remove() throws Exception { assertThat(this.attributeAccessor.hasAttribute(NAME)).isFalse(); this.attributeAccessor.setAttribute(NAME, VALUE); assertThat(this.attributeAccessor.removeAttribute(NAME)).isEqualTo(VALUE); @@ -57,7 +57,7 @@ public class AttributeAccessorSupportTests { } @Test - public void attributeNames() throws Exception { + void attributeNames() throws Exception { this.attributeAccessor.setAttribute(NAME, VALUE); this.attributeAccessor.setAttribute("abc", "123"); String[] attributeNames = this.attributeAccessor.attributeNames(); diff --git a/spring-core/src/test/java/org/springframework/core/BridgeMethodResolverTests.java b/spring-core/src/test/java/org/springframework/core/BridgeMethodResolverTests.java index 8486927b45..00f9653d54 100644 --- a/spring-core/src/test/java/org/springframework/core/BridgeMethodResolverTests.java +++ b/spring-core/src/test/java/org/springframework/core/BridgeMethodResolverTests.java @@ -40,7 +40,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Chris Beams */ @SuppressWarnings("rawtypes") -public class BridgeMethodResolverTests { +class BridgeMethodResolverTests { private static Method findMethodWithReturnType(String name, Class returnType, Class targetType) { Method[] methods = targetType.getMethods(); @@ -54,7 +54,7 @@ public class BridgeMethodResolverTests { @Test - public void testFindBridgedMethod() throws Exception { + void findBridgedMethod() throws Exception { Method unbridged = MyFoo.class.getDeclaredMethod("someMethod", String.class, Object.class); Method bridged = MyFoo.class.getDeclaredMethod("someMethod", Serializable.class, Object.class); assertThat(unbridged.isBridge()).isFalse(); @@ -65,7 +65,7 @@ public class BridgeMethodResolverTests { } @Test - public void testFindBridgedVarargMethod() throws Exception { + void findBridgedVarargMethod() throws Exception { Method unbridged = MyFoo.class.getDeclaredMethod("someVarargMethod", String.class, Object[].class); Method bridged = MyFoo.class.getDeclaredMethod("someVarargMethod", Serializable.class, Object[].class); assertThat(unbridged.isBridge()).isFalse(); @@ -76,7 +76,7 @@ public class BridgeMethodResolverTests { } @Test - public void testFindBridgedMethodInHierarchy() throws Exception { + void findBridgedMethodInHierarchy() throws Exception { Method bridgeMethod = DateAdder.class.getMethod("add", Object.class); assertThat(bridgeMethod.isBridge()).isTrue(); Method bridgedMethod = BridgeMethodResolver.findBridgedMethod(bridgeMethod); @@ -87,7 +87,7 @@ public class BridgeMethodResolverTests { } @Test - public void testIsBridgeMethodFor() throws Exception { + void isBridgeMethodFor() throws Exception { Method bridged = MyBar.class.getDeclaredMethod("someMethod", String.class, Object.class); Method other = MyBar.class.getDeclaredMethod("someMethod", Integer.class, Object.class); Method bridge = MyBar.class.getDeclaredMethod("someMethod", Object.class, Object.class); @@ -97,7 +97,7 @@ public class BridgeMethodResolverTests { } @Test - public void testDoubleParameterization() throws Exception { + void doubleParameterization() throws Exception { Method objectBridge = MyBoo.class.getDeclaredMethod("foo", Object.class); Method serializableBridge = MyBoo.class.getDeclaredMethod("foo", Serializable.class); @@ -109,7 +109,7 @@ public class BridgeMethodResolverTests { } @Test - public void testFindBridgedMethodFromMultipleBridges() throws Exception { + void findBridgedMethodFromMultipleBridges() throws Exception { Method loadWithObjectReturn = findMethodWithReturnType("load", Object.class, SettingsDaoImpl.class); assertThat(loadWithObjectReturn).isNotNull(); @@ -123,7 +123,7 @@ public class BridgeMethodResolverTests { } @Test - public void testFindBridgedMethodFromParent() throws Exception { + void findBridgedMethodFromParent() throws Exception { Method loadFromParentBridge = SettingsDaoImpl.class.getMethod("loadFromParent"); assertThat(loadFromParentBridge.isBridge()).isTrue(); @@ -134,7 +134,7 @@ public class BridgeMethodResolverTests { } @Test - public void testWithSingleBoundParameterizedOnInstantiate() throws Exception { + void withSingleBoundParameterizedOnInstantiate() throws Exception { Method bridgeMethod = DelayQueue.class.getMethod("add", Object.class); assertThat(bridgeMethod.isBridge()).isTrue(); Method actualMethod = DelayQueue.class.getMethod("add", Delayed.class); @@ -143,7 +143,7 @@ public class BridgeMethodResolverTests { } @Test - public void testWithDoubleBoundParameterizedOnInstantiate() throws Exception { + void withDoubleBoundParameterizedOnInstantiate() throws Exception { Method bridgeMethod = SerializableBounded.class.getMethod("boundedOperation", Object.class); assertThat(bridgeMethod.isBridge()).isTrue(); Method actualMethod = SerializableBounded.class.getMethod("boundedOperation", HashMap.class); @@ -152,7 +152,7 @@ public class BridgeMethodResolverTests { } @Test - public void testWithGenericParameter() throws Exception { + void withGenericParameter() throws Exception { Method[] methods = StringGenericParameter.class.getMethods(); Method bridgeMethod = null; Method bridgedMethod = null; @@ -173,7 +173,7 @@ public class BridgeMethodResolverTests { } @Test - public void testOnAllMethods() throws Exception { + void onAllMethods() throws Exception { Method[] methods = StringList.class.getMethods(); for (Method method : methods) { assertThat(BridgeMethodResolver.findBridgedMethod(method)).isNotNull(); @@ -181,7 +181,7 @@ public class BridgeMethodResolverTests { } @Test - public void testSPR2583() throws Exception { + void spr2583() throws Exception { Method bridgedMethod = MessageBroadcasterImpl.class.getMethod("receive", MessageEvent.class); assertThat(bridgedMethod.isBridge()).isFalse(); Method bridgeMethod = MessageBroadcasterImpl.class.getMethod("receive", Event.class); @@ -197,7 +197,7 @@ public class BridgeMethodResolverTests { } @Test - public void testSPR2603() throws Exception { + void spr2603() throws Exception { Method objectBridge = YourHomer.class.getDeclaredMethod("foo", Bounded.class); Method abstractBoundedFoo = YourHomer.class.getDeclaredMethod("foo", AbstractBounded.class); @@ -206,7 +206,7 @@ public class BridgeMethodResolverTests { } @Test - public void testSPR2648() throws Exception { + void spr2648() throws Exception { Method bridgeMethod = ReflectionUtils.findMethod(GenericSqlMapIntegerDao.class, "saveOrUpdate", Object.class); assertThat(bridgeMethod != null && bridgeMethod.isBridge()).isTrue(); Method bridgedMethod = BridgeMethodResolver.findBridgedMethod(bridgeMethod); @@ -215,7 +215,7 @@ public class BridgeMethodResolverTests { } @Test - public void testSPR2763() throws Exception { + void spr2763() throws Exception { Method bridgedMethod = AbstractDao.class.getDeclaredMethod("save", Object.class); assertThat(bridgedMethod.isBridge()).isFalse(); @@ -226,7 +226,7 @@ public class BridgeMethodResolverTests { } @Test - public void testSPR3041() throws Exception { + void spr3041() throws Exception { Method bridgedMethod = BusinessDao.class.getDeclaredMethod("save", Business.class); assertThat(bridgedMethod.isBridge()).isFalse(); @@ -237,7 +237,7 @@ public class BridgeMethodResolverTests { } @Test - public void testSPR3173() throws Exception { + void spr3173() throws Exception { Method bridgedMethod = UserDaoImpl.class.getDeclaredMethod("saveVararg", User.class, Object[].class); assertThat(bridgedMethod.isBridge()).isFalse(); @@ -248,7 +248,7 @@ public class BridgeMethodResolverTests { } @Test - public void testSPR3304() throws Exception { + void spr3304() throws Exception { Method bridgedMethod = MegaMessageProducerImpl.class.getDeclaredMethod("receive", MegaMessageEvent.class); assertThat(bridgedMethod.isBridge()).isFalse(); @@ -259,7 +259,7 @@ public class BridgeMethodResolverTests { } @Test - public void testSPR3324() throws Exception { + void spr3324() throws Exception { Method bridgedMethod = BusinessDao.class.getDeclaredMethod("get", Long.class); assertThat(bridgedMethod.isBridge()).isFalse(); @@ -270,7 +270,7 @@ public class BridgeMethodResolverTests { } @Test - public void testSPR3357() throws Exception { + void spr3357() throws Exception { Method bridgedMethod = ExtendsAbstractImplementsInterface.class.getDeclaredMethod( "doSomething", DomainObjectExtendsSuper.class, Object.class); assertThat(bridgedMethod.isBridge()).isFalse(); @@ -283,7 +283,7 @@ public class BridgeMethodResolverTests { } @Test - public void testSPR3485() throws Exception { + void spr3485() throws Exception { Method bridgedMethod = DomainObject.class.getDeclaredMethod( "method2", ParameterType.class, byte[].class); assertThat(bridgedMethod.isBridge()).isFalse(); @@ -296,7 +296,7 @@ public class BridgeMethodResolverTests { } @Test - public void testSPR3534() throws Exception { + void spr3534() throws Exception { Method bridgeMethod = ReflectionUtils.findMethod(TestEmailProvider.class, "findBy", Object.class); assertThat(bridgeMethod != null && bridgeMethod.isBridge()).isTrue(); Method bridgedMethod = BridgeMethodResolver.findBridgedMethod(bridgeMethod); @@ -305,12 +305,12 @@ public class BridgeMethodResolverTests { } @Test // SPR-16103 - public void testClassHierarchy() throws Exception { + void testClassHierarchy() throws Exception { doTestHierarchyResolution(FooClass.class); } @Test // SPR-16103 - public void testInterfaceHierarchy() throws Exception { + void testInterfaceHierarchy() throws Exception { doTestHierarchyResolution(FooInterface.class); } diff --git a/spring-core/src/test/java/org/springframework/core/CollectionFactoryTests.java b/spring-core/src/test/java/org/springframework/core/CollectionFactoryTests.java index 151b61f4ed..56dbd932f5 100644 --- a/spring-core/src/test/java/org/springframework/core/CollectionFactoryTests.java +++ b/spring-core/src/test/java/org/springframework/core/CollectionFactoryTests.java @@ -55,7 +55,7 @@ import static org.springframework.core.CollectionFactory.createMap; * @author Sam Brannen * @since 4.1.4 */ -public class CollectionFactoryTests { +class CollectionFactoryTests { /** * The test demonstrates that the generics-based API for @@ -69,7 +69,7 @@ public class CollectionFactoryTests { * actually contains elements of type {@code E}. */ @Test - public void createApproximateCollectionIsNotTypeSafeForEnumSet() { + void createApproximateCollectionIsNotTypeSafeForEnumSet() { Collection ints = createApproximateCollection(EnumSet.of(Color.BLUE), 3); // Use a try-catch block to ensure that the exception is thrown as a result of the @@ -84,7 +84,7 @@ public class CollectionFactoryTests { } @Test - public void createCollectionIsNotTypeSafeForEnumSet() { + void createCollectionIsNotTypeSafeForEnumSet() { Collection ints = createCollection(EnumSet.class, Color.class, 3); // Use a try-catch block to ensure that the exception is thrown as a result of the @@ -106,7 +106,7 @@ public class CollectionFactoryTests { * {@link #createApproximateCollectionIsNotTypeSafeForEnumSet}. */ @Test - public void createApproximateMapIsNotTypeSafeForEnumMap() { + void createApproximateMapIsNotTypeSafeForEnumMap() { EnumMap enumMap = new EnumMap<>(Color.class); enumMap.put(Color.RED, 1); enumMap.put(Color.BLUE, 2); @@ -124,7 +124,7 @@ public class CollectionFactoryTests { } @Test - public void createMapIsNotTypeSafeForEnumMap() { + void createMapIsNotTypeSafeForEnumMap() { Map map = createMap(EnumMap.class, Color.class, 3); // Use a try-catch block to ensure that the exception is thrown as a result of the @@ -139,7 +139,7 @@ public class CollectionFactoryTests { } @Test - public void createMapIsNotTypeSafeForLinkedMultiValueMap() { + void createMapIsNotTypeSafeForLinkedMultiValueMap() { Map map = createMap(MultiValueMap.class, null, 3); // Use a try-catch block to ensure that the exception is thrown as a result of the @@ -154,13 +154,13 @@ public class CollectionFactoryTests { } @Test - public void createApproximateCollectionFromEmptyHashSet() { + void createApproximateCollectionFromEmptyHashSet() { Collection set = createApproximateCollection(new HashSet(), 2); Assertions.assertThat(set).isEmpty(); } @Test - public void createApproximateCollectionFromNonEmptyHashSet() { + void createApproximateCollectionFromNonEmptyHashSet() { HashSet hashSet = new HashSet<>(); hashSet.add("foo"); Collection set = createApproximateCollection(hashSet, 2); @@ -168,25 +168,25 @@ public class CollectionFactoryTests { } @Test - public void createApproximateCollectionFromEmptyEnumSet() { + void createApproximateCollectionFromEmptyEnumSet() { Collection colors = createApproximateCollection(EnumSet.noneOf(Color.class), 2); assertThat(colors).isEmpty(); } @Test - public void createApproximateCollectionFromNonEmptyEnumSet() { + void createApproximateCollectionFromNonEmptyEnumSet() { Collection colors = createApproximateCollection(EnumSet.of(Color.BLUE), 2); assertThat(colors).isEmpty(); } @Test - public void createApproximateMapFromEmptyHashMap() { + void createApproximateMapFromEmptyHashMap() { Map map = createApproximateMap(new HashMap(), 2); assertThat(map).isEmpty(); } @Test - public void createApproximateMapFromNonEmptyHashMap() { + void createApproximateMapFromNonEmptyHashMap() { Map hashMap = new HashMap<>(); hashMap.put("foo", "bar"); Map map = createApproximateMap(hashMap, 2); @@ -194,13 +194,13 @@ public class CollectionFactoryTests { } @Test - public void createApproximateMapFromEmptyEnumMap() { + void createApproximateMapFromEmptyEnumMap() { Map colors = createApproximateMap(new EnumMap(Color.class), 2); assertThat(colors).isEmpty(); } @Test - public void createApproximateMapFromNonEmptyEnumMap() { + void createApproximateMapFromNonEmptyEnumMap() { EnumMap enumMap = new EnumMap<>(Color.class); enumMap.put(Color.BLUE, "blue"); Map colors = createApproximateMap(enumMap, 2); @@ -208,7 +208,7 @@ public class CollectionFactoryTests { } @Test - public void createsCollectionsCorrectly() { + void createsCollectionsCorrectly() { // interfaces assertThat(createCollection(List.class, 0)).isInstanceOf(ArrayList.class); assertThat(createCollection(Set.class, 0)).isInstanceOf(LinkedHashSet.class); @@ -228,36 +228,36 @@ public class CollectionFactoryTests { } @Test - public void createsEnumSet() { + void createsEnumSet() { assertThat(createCollection(EnumSet.class, Color.class, 0)).isInstanceOf(EnumSet.class); } @Test // SPR-17619 - public void createsEnumSetSubclass() { + void createsEnumSetSubclass() { EnumSet enumSet = EnumSet.noneOf(Color.class); assertThat(createCollection(enumSet.getClass(), Color.class, 0)).isInstanceOf(enumSet.getClass()); } @Test - public void rejectsInvalidElementTypeForEnumSet() { + void rejectsInvalidElementTypeForEnumSet() { assertThatIllegalArgumentException().isThrownBy(() -> createCollection(EnumSet.class, Object.class, 0)); } @Test - public void rejectsNullElementTypeForEnumSet() { + void rejectsNullElementTypeForEnumSet() { assertThatIllegalArgumentException().isThrownBy(() -> createCollection(EnumSet.class, null, 0)); } @Test - public void rejectsNullCollectionType() { + void rejectsNullCollectionType() { assertThatIllegalArgumentException().isThrownBy(() -> createCollection(null, Object.class, 0)); } @Test - public void createsMapsCorrectly() { + void createsMapsCorrectly() { // interfaces assertThat(createMap(Map.class, 0)).isInstanceOf(LinkedHashMap.class); assertThat(createMap(SortedMap.class, 0)).isInstanceOf(TreeMap.class); @@ -276,24 +276,24 @@ public class CollectionFactoryTests { } @Test - public void createsEnumMap() { + void createsEnumMap() { assertThat(createMap(EnumMap.class, Color.class, 0)).isInstanceOf(EnumMap.class); } @Test - public void rejectsInvalidKeyTypeForEnumMap() { + void rejectsInvalidKeyTypeForEnumMap() { assertThatIllegalArgumentException().isThrownBy(() -> createMap(EnumMap.class, Object.class, 0)); } @Test - public void rejectsNullKeyTypeForEnumMap() { + void rejectsNullKeyTypeForEnumMap() { assertThatIllegalArgumentException().isThrownBy(() -> createMap(EnumMap.class, null, 0)); } @Test - public void rejectsNullMapType() { + void rejectsNullMapType() { assertThatIllegalArgumentException().isThrownBy(() -> createMap(null, Object.class, 0)); } diff --git a/spring-core/src/test/java/org/springframework/core/ConstantsTests.java b/spring-core/src/test/java/org/springframework/core/ConstantsTests.java index 235cb12c42..377f6f8acd 100644 --- a/spring-core/src/test/java/org/springframework/core/ConstantsTests.java +++ b/spring-core/src/test/java/org/springframework/core/ConstantsTests.java @@ -31,10 +31,10 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException * @author Rick Evans * @since 28.04.2003 */ -public class ConstantsTests { +class ConstantsTests { @Test - public void constants() { + void constants() { Constants c = new Constants(A.class); assertThat(c.getClassName()).isEqualTo(A.class.getName()); assertThat(c.getSize()).isEqualTo(9); @@ -52,7 +52,7 @@ public class ConstantsTests { } @Test - public void getNames() { + void getNames() { Constants c = new Constants(A.class); Set names = c.getNames(""); @@ -71,7 +71,7 @@ public class ConstantsTests { } @Test - public void getValues() { + void getValues() { Constants c = new Constants(A.class); Set values = c.getValues(""); @@ -96,7 +96,7 @@ public class ConstantsTests { } @Test - public void getValuesInTurkey() { + void getValuesInTurkey() { Locale oldLocale = Locale.getDefault(); Locale.setDefault(new Locale("tr", "")); try { @@ -128,7 +128,7 @@ public class ConstantsTests { } @Test - public void suffixAccess() { + void suffixAccess() { Constants c = new Constants(A.class); Set names = c.getNamesForSuffix("_PROPERTY"); @@ -143,7 +143,7 @@ public class ConstantsTests { } @Test - public void toCode() { + void toCode() { Constants c = new Constants(A.class); assertThat(c.toCode(Integer.valueOf(0), "")).isEqualTo("DOG"); @@ -191,28 +191,28 @@ public class ConstantsTests { } @Test - public void getValuesWithNullPrefix() throws Exception { + void getValuesWithNullPrefix() throws Exception { Constants c = new Constants(A.class); Set values = c.getValues(null); assertThat(values.size()).as("Must have returned *all* public static final values").isEqualTo(7); } @Test - public void getValuesWithEmptyStringPrefix() throws Exception { + void getValuesWithEmptyStringPrefix() throws Exception { Constants c = new Constants(A.class); Set values = c.getValues(""); assertThat(values.size()).as("Must have returned *all* public static final values").isEqualTo(7); } @Test - public void getValuesWithWhitespacedStringPrefix() throws Exception { + void getValuesWithWhitespacedStringPrefix() throws Exception { Constants c = new Constants(A.class); Set values = c.getValues(" "); assertThat(values.size()).as("Must have returned *all* public static final values").isEqualTo(7); } @Test - public void withClassThatExposesNoConstants() throws Exception { + void withClassThatExposesNoConstants() throws Exception { Constants c = new Constants(NoConstants.class); assertThat(c.getSize()).isEqualTo(0); final Set values = c.getValues(""); @@ -221,7 +221,7 @@ public class ConstantsTests { } @Test - public void ctorWithNullClass() throws Exception { + void ctorWithNullClass() throws Exception { assertThatIllegalArgumentException().isThrownBy(() -> new Constants(null)); } diff --git a/spring-core/src/test/java/org/springframework/core/ConventionsTests.java b/spring-core/src/test/java/org/springframework/core/ConventionsTests.java index 890b0e6e05..3017ef3a55 100644 --- a/spring-core/src/test/java/org/springframework/core/ConventionsTests.java +++ b/spring-core/src/test/java/org/springframework/core/ConventionsTests.java @@ -41,43 +41,43 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException * @author Rob Harrop * @author Sam Brannen */ -public class ConventionsTests { +class ConventionsTests { @Test - public void simpleObject() { + void simpleObject() { assertThat(Conventions.getVariableName(new TestObject())).as("Incorrect singular variable name").isEqualTo("testObject"); assertThat(Conventions.getVariableNameForParameter(getMethodParameter(TestObject.class))).as("Incorrect singular variable name").isEqualTo("testObject"); assertThat(Conventions.getVariableNameForReturnType(getMethodForReturnType(TestObject.class))).as("Incorrect singular variable name").isEqualTo("testObject"); } @Test - public void array() { + void array() { Object actual = Conventions.getVariableName(new TestObject[0]); assertThat(actual).as("Incorrect plural array form").isEqualTo("testObjectList"); } @Test - public void list() { + void list() { assertThat(Conventions.getVariableName(Collections.singletonList(new TestObject()))).as("Incorrect plural List form").isEqualTo("testObjectList"); assertThat(Conventions.getVariableNameForParameter(getMethodParameter(List.class))).as("Incorrect plural List form").isEqualTo("testObjectList"); assertThat(Conventions.getVariableNameForReturnType(getMethodForReturnType(List.class))).as("Incorrect plural List form").isEqualTo("testObjectList"); } @Test - public void emptyList() { + void emptyList() { assertThatIllegalArgumentException().isThrownBy(() -> Conventions.getVariableName(new ArrayList<>())); } @Test - public void set() { + void set() { assertThat(Conventions.getVariableName(Collections.singleton(new TestObject()))).as("Incorrect plural Set form").isEqualTo("testObjectList"); assertThat(Conventions.getVariableNameForParameter(getMethodParameter(Set.class))).as("Incorrect plural Set form").isEqualTo("testObjectList"); assertThat(Conventions.getVariableNameForReturnType(getMethodForReturnType(Set.class))).as("Incorrect plural Set form").isEqualTo("testObjectList"); } @Test - public void reactiveParameters() { + void reactiveParameters() { assertThat(Conventions.getVariableNameForParameter(getMethodParameter(Mono.class))).isEqualTo("testObjectMono"); assertThat(Conventions.getVariableNameForParameter(getMethodParameter(Flux.class))).isEqualTo("testObjectFlux"); assertThat(Conventions.getVariableNameForParameter(getMethodParameter(Single.class))).isEqualTo("testObjectSingle"); @@ -85,7 +85,7 @@ public class ConventionsTests { } @Test - public void reactiveReturnTypes() { + void reactiveReturnTypes() { assertThat(Conventions.getVariableNameForReturnType(getMethodForReturnType(Mono.class))).isEqualTo("testObjectMono"); assertThat(Conventions.getVariableNameForReturnType(getMethodForReturnType(Flux.class))).isEqualTo("testObjectFlux"); assertThat(Conventions.getVariableNameForReturnType(getMethodForReturnType(Single.class))).isEqualTo("testObjectSingle"); @@ -93,14 +93,14 @@ public class ConventionsTests { } @Test - public void attributeNameToPropertyName() { + void attributeNameToPropertyName() { assertThat(Conventions.attributeNameToPropertyName("transaction-manager")).isEqualTo("transactionManager"); assertThat(Conventions.attributeNameToPropertyName("pointcut-ref")).isEqualTo("pointcutRef"); assertThat(Conventions.attributeNameToPropertyName("lookup-on-startup")).isEqualTo("lookupOnStartup"); } @Test - public void getQualifiedAttributeName() { + void getQualifiedAttributeName() { String baseName = "foo"; Class cls = String.class; String desiredResult = "java.lang.String.foo"; diff --git a/spring-core/src/test/java/org/springframework/core/ExceptionDepthComparatorTests.java b/spring-core/src/test/java/org/springframework/core/ExceptionDepthComparatorTests.java index e7a87b9ab4..f30f04bf78 100644 --- a/spring-core/src/test/java/org/springframework/core/ExceptionDepthComparatorTests.java +++ b/spring-core/src/test/java/org/springframework/core/ExceptionDepthComparatorTests.java @@ -27,58 +27,58 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Chris Shepperd */ @SuppressWarnings("unchecked") -public class ExceptionDepthComparatorTests { +class ExceptionDepthComparatorTests { @Test - public void targetBeforeSameDepth() throws Exception { + void targetBeforeSameDepth() throws Exception { Class foundClass = findClosestMatch(TargetException.class, SameDepthException.class); assertThat(foundClass).isEqualTo(TargetException.class); } @Test - public void sameDepthBeforeTarget() throws Exception { + void sameDepthBeforeTarget() throws Exception { Class foundClass = findClosestMatch(SameDepthException.class, TargetException.class); assertThat(foundClass).isEqualTo(TargetException.class); } @Test - public void lowestDepthBeforeTarget() throws Exception { + void lowestDepthBeforeTarget() throws Exception { Class foundClass = findClosestMatch(LowestDepthException.class, TargetException.class); assertThat(foundClass).isEqualTo(TargetException.class); } @Test - public void targetBeforeLowestDepth() throws Exception { + void targetBeforeLowestDepth() throws Exception { Class foundClass = findClosestMatch(TargetException.class, LowestDepthException.class); assertThat(foundClass).isEqualTo(TargetException.class); } @Test - public void noDepthBeforeTarget() throws Exception { + void noDepthBeforeTarget() throws Exception { Class foundClass = findClosestMatch(NoDepthException.class, TargetException.class); assertThat(foundClass).isEqualTo(TargetException.class); } @Test - public void noDepthBeforeHighestDepth() throws Exception { + void noDepthBeforeHighestDepth() throws Exception { Class foundClass = findClosestMatch(NoDepthException.class, HighestDepthException.class); assertThat(foundClass).isEqualTo(HighestDepthException.class); } @Test - public void highestDepthBeforeNoDepth() throws Exception { + void highestDepthBeforeNoDepth() throws Exception { Class foundClass = findClosestMatch(HighestDepthException.class, NoDepthException.class); assertThat(foundClass).isEqualTo(HighestDepthException.class); } @Test - public void highestDepthBeforeLowestDepth() throws Exception { + void highestDepthBeforeLowestDepth() throws Exception { Class foundClass = findClosestMatch(HighestDepthException.class, LowestDepthException.class); assertThat(foundClass).isEqualTo(LowestDepthException.class); } @Test - public void lowestDepthBeforeHighestDepth() throws Exception { + void lowestDepthBeforeHighestDepth() throws Exception { Class foundClass = findClosestMatch(LowestDepthException.class, HighestDepthException.class); assertThat(foundClass).isEqualTo(LowestDepthException.class); } diff --git a/spring-core/src/test/java/org/springframework/core/GenericTypeResolverTests.java b/spring-core/src/test/java/org/springframework/core/GenericTypeResolverTests.java index 209071a316..26f42dc742 100644 --- a/spring-core/src/test/java/org/springframework/core/GenericTypeResolverTests.java +++ b/spring-core/src/test/java/org/springframework/core/GenericTypeResolverTests.java @@ -39,36 +39,36 @@ import static org.springframework.util.ReflectionUtils.findMethod; * @author Sam Brannen */ @SuppressWarnings({"unchecked", "rawtypes"}) -public class GenericTypeResolverTests { +class GenericTypeResolverTests { @Test - public void simpleInterfaceType() { + void simpleInterfaceType() { assertThat(resolveTypeArgument(MySimpleInterfaceType.class, MyInterfaceType.class)).isEqualTo(String.class); } @Test - public void simpleCollectionInterfaceType() { + void simpleCollectionInterfaceType() { assertThat(resolveTypeArgument(MyCollectionInterfaceType.class, MyInterfaceType.class)).isEqualTo(Collection.class); } @Test - public void simpleSuperclassType() { + void simpleSuperclassType() { assertThat(resolveTypeArgument(MySimpleSuperclassType.class, MySuperclassType.class)).isEqualTo(String.class); } @Test - public void simpleCollectionSuperclassType() { + void simpleCollectionSuperclassType() { assertThat(resolveTypeArgument(MyCollectionSuperclassType.class, MySuperclassType.class)).isEqualTo(Collection.class); } @Test - public void nullIfNotResolvable() { + void nullIfNotResolvable() { GenericClass obj = new GenericClass<>(); assertThat((Object) resolveTypeArgument(obj.getClass(), GenericClass.class)).isNull(); } @Test - public void methodReturnTypes() { + void methodReturnTypes() { assertThat(resolveReturnTypeArgument(findMethod(MyTypeWithMethods.class, "integer"), MyInterfaceType.class)).isEqualTo(Integer.class); assertThat(resolveReturnTypeArgument(findMethod(MyTypeWithMethods.class, "string"), MyInterfaceType.class)).isEqualTo(String.class); assertThat(resolveReturnTypeArgument(findMethod(MyTypeWithMethods.class, "raw"), MyInterfaceType.class)).isEqualTo(null); @@ -76,7 +76,7 @@ public class GenericTypeResolverTests { } @Test - public void testResolveType() { + void testResolveType() { Method intMessageMethod = findMethod(MyTypeWithMethods.class, "readIntegerInputMessage", MyInterfaceType.class); MethodParameter intMessageMethodParam = new MethodParameter(intMessageMethod, 0); assertThat(resolveType(intMessageMethodParam.getGenericParameterType(), new HashMap<>())).isEqualTo(MyInterfaceType.class); @@ -94,12 +94,12 @@ public class GenericTypeResolverTests { } @Test - public void testBoundParameterizedType() { + void boundParameterizedType() { assertThat(resolveTypeArgument(TestImpl.class, TestIfc.class)).isEqualTo(B.class); } @Test - public void testGetTypeVariableMap() throws Exception { + void testGetTypeVariableMap() throws Exception { Map map; map = GenericTypeResolver.getTypeVariableMap(MySimpleInterfaceType.class); @@ -137,19 +137,19 @@ public class GenericTypeResolverTests { } @Test // SPR-11030 - public void getGenericsCannotBeResolved() throws Exception { + void getGenericsCannotBeResolved() throws Exception { Class[] resolved = GenericTypeResolver.resolveTypeArguments(List.class, Iterable.class); assertThat((Object) resolved).isNull(); } @Test // SPR-11052 - public void getRawMapTypeCannotBeResolved() throws Exception { + void getRawMapTypeCannotBeResolved() throws Exception { Class[] resolved = GenericTypeResolver.resolveTypeArguments(Map.class, Map.class); assertThat((Object) resolved).isNull(); } @Test // SPR-11044 - public void getGenericsOnArrayFromParamCannotBeResolved() throws Exception { + void getGenericsOnArrayFromParamCannotBeResolved() throws Exception { MethodParameter methodParameter = MethodParameter.forExecutable( WithArrayBase.class.getDeclaredMethod("array", Object[].class), 0); Class resolved = GenericTypeResolver.resolveParameterType(methodParameter, WithArray.class); @@ -157,14 +157,14 @@ public class GenericTypeResolverTests { } @Test // SPR-11044 - public void getGenericsOnArrayFromReturnCannotBeResolved() throws Exception { + void getGenericsOnArrayFromReturnCannotBeResolved() throws Exception { Class resolved = GenericTypeResolver.resolveReturnType( WithArrayBase.class.getDeclaredMethod("array", Object[].class), WithArray.class); assertThat(resolved).isEqualTo(Object[].class); } @Test // SPR-11763 - public void resolveIncompleteTypeVariables() { + void resolveIncompleteTypeVariables() { Class[] resolved = GenericTypeResolver.resolveTypeArguments(IdFixingRepository.class, Repository.class); assertThat(resolved).isNotNull(); assertThat(resolved.length).isEqualTo(2); diff --git a/spring-core/src/test/java/org/springframework/core/LocalVariableTableParameterNameDiscovererTests.java b/spring-core/src/test/java/org/springframework/core/LocalVariableTableParameterNameDiscovererTests.java index 88c4c2d2fd..4ab6fc8696 100644 --- a/spring-core/src/test/java/org/springframework/core/LocalVariableTableParameterNameDiscovererTests.java +++ b/spring-core/src/test/java/org/springframework/core/LocalVariableTableParameterNameDiscovererTests.java @@ -32,13 +32,13 @@ import static org.assertj.core.api.Assertions.assertThat; /** * @author Adrian Colyer */ -public class LocalVariableTableParameterNameDiscovererTests { +class LocalVariableTableParameterNameDiscovererTests { private final LocalVariableTableParameterNameDiscoverer discoverer = new LocalVariableTableParameterNameDiscoverer(); @Test - public void methodParameterNameDiscoveryNoArgs() throws NoSuchMethodException { + void methodParameterNameDiscoveryNoArgs() throws NoSuchMethodException { Method getName = TestObject.class.getMethod("getName"); String[] names = discoverer.getParameterNames(getName); assertThat(names).as("should find method info").isNotNull(); @@ -46,7 +46,7 @@ public class LocalVariableTableParameterNameDiscovererTests { } @Test - public void methodParameterNameDiscoveryWithArgs() throws NoSuchMethodException { + void methodParameterNameDiscoveryWithArgs() throws NoSuchMethodException { Method setName = TestObject.class.getMethod("setName", String.class); String[] names = discoverer.getParameterNames(setName); assertThat(names).as("should find method info").isNotNull(); @@ -55,7 +55,7 @@ public class LocalVariableTableParameterNameDiscovererTests { } @Test - public void consParameterNameDiscoveryNoArgs() throws NoSuchMethodException { + void consParameterNameDiscoveryNoArgs() throws NoSuchMethodException { Constructor noArgsCons = TestObject.class.getConstructor(); String[] names = discoverer.getParameterNames(noArgsCons); assertThat(names).as("should find cons info").isNotNull(); @@ -63,7 +63,7 @@ public class LocalVariableTableParameterNameDiscovererTests { } @Test - public void consParameterNameDiscoveryArgs() throws NoSuchMethodException { + void consParameterNameDiscoveryArgs() throws NoSuchMethodException { Constructor twoArgCons = TestObject.class.getConstructor(String.class, int.class); String[] names = discoverer.getParameterNames(twoArgCons); assertThat(names).as("should find cons info").isNotNull(); @@ -73,7 +73,7 @@ public class LocalVariableTableParameterNameDiscovererTests { } @Test - public void staticMethodParameterNameDiscoveryNoArgs() throws NoSuchMethodException { + void staticMethodParameterNameDiscoveryNoArgs() throws NoSuchMethodException { Method m = getClass().getMethod("staticMethodNoLocalVars"); String[] names = discoverer.getParameterNames(m); assertThat(names).as("should find method info").isNotNull(); @@ -81,7 +81,7 @@ public class LocalVariableTableParameterNameDiscovererTests { } @Test - public void overloadedStaticMethod() throws Exception { + void overloadedStaticMethod() throws Exception { Class clazz = this.getClass(); Method m1 = clazz.getMethod("staticMethod", Long.TYPE, Long.TYPE); @@ -101,7 +101,7 @@ public class LocalVariableTableParameterNameDiscovererTests { } @Test - public void overloadedStaticMethodInInnerClass() throws Exception { + void overloadedStaticMethodInInnerClass() throws Exception { Class clazz = InnerClass.class; Method m1 = clazz.getMethod("staticMethod", Long.TYPE); @@ -119,7 +119,7 @@ public class LocalVariableTableParameterNameDiscovererTests { } @Test - public void overloadedMethod() throws Exception { + void overloadedMethod() throws Exception { Class clazz = this.getClass(); Method m1 = clazz.getMethod("instanceMethod", Double.TYPE, Double.TYPE); @@ -139,7 +139,7 @@ public class LocalVariableTableParameterNameDiscovererTests { } @Test - public void overloadedMethodInInnerClass() throws Exception { + void overloadedMethodInInnerClass() throws Exception { Class clazz = InnerClass.class; Method m1 = clazz.getMethod("instanceMethod", String.class); @@ -157,7 +157,7 @@ public class LocalVariableTableParameterNameDiscovererTests { } @Test - public void generifiedClass() throws Exception { + void generifiedClass() throws Exception { Class clazz = GenerifiedClass.class; Constructor ctor = clazz.getDeclaredConstructor(Object.class); @@ -205,7 +205,7 @@ public class LocalVariableTableParameterNameDiscovererTests { @Disabled("Ignored because Ubuntu packages OpenJDK with debug symbols enabled. See SPR-8078.") @Test - public void classesWithoutDebugSymbols() throws Exception { + void classesWithoutDebugSymbols() throws Exception { // JDK classes don't have debug information (usually) Class clazz = Component.class; String methodName = "list"; diff --git a/spring-core/src/test/java/org/springframework/core/MethodParameterTests.java b/spring-core/src/test/java/org/springframework/core/MethodParameterTests.java index 8b10e3604b..160aa064fb 100644 --- a/spring-core/src/test/java/org/springframework/core/MethodParameterTests.java +++ b/spring-core/src/test/java/org/springframework/core/MethodParameterTests.java @@ -39,7 +39,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException * @author Sam Brannen * @author Phillip Webb */ -public class MethodParameterTests { +class MethodParameterTests { private Method method; @@ -51,7 +51,7 @@ public class MethodParameterTests { @BeforeEach - public void setup() throws NoSuchMethodException { + void setup() throws NoSuchMethodException { method = getClass().getMethod("method", String.class, Long.TYPE); stringParameter = new MethodParameter(method, 0); longParameter = new MethodParameter(method, 1); @@ -60,7 +60,7 @@ public class MethodParameterTests { @Test - public void testEquals() throws NoSuchMethodException { + void equals() throws NoSuchMethodException { assertThat(stringParameter).isEqualTo(stringParameter); assertThat(longParameter).isEqualTo(longParameter); assertThat(intReturnType).isEqualTo(intReturnType); @@ -81,7 +81,7 @@ public class MethodParameterTests { } @Test - public void testHashCode() throws NoSuchMethodException { + void testHashCode() throws NoSuchMethodException { assertThat(stringParameter.hashCode()).isEqualTo(stringParameter.hashCode()); assertThat(longParameter.hashCode()).isEqualTo(longParameter.hashCode()); assertThat(intReturnType.hashCode()).isEqualTo(intReturnType.hashCode()); @@ -94,7 +94,7 @@ public class MethodParameterTests { @Test @SuppressWarnings("deprecation") - public void testFactoryMethods() { + void testFactoryMethods() { assertThat(MethodParameter.forMethodOrConstructor(method, 0)).isEqualTo(stringParameter); assertThat(MethodParameter.forMethodOrConstructor(method, 1)).isEqualTo(longParameter); @@ -106,13 +106,13 @@ public class MethodParameterTests { } @Test - public void testIndexValidation() { + void indexValidation() { assertThatIllegalArgumentException().isThrownBy(() -> new MethodParameter(method, 2)); } @Test - public void annotatedConstructorParameterInStaticNestedClass() throws Exception { + void annotatedConstructorParameterInStaticNestedClass() throws Exception { Constructor constructor = NestedClass.class.getDeclaredConstructor(String.class); MethodParameter methodParameter = MethodParameter.forExecutable(constructor, 0); assertThat(methodParameter.getParameterType()).isEqualTo(String.class); @@ -120,7 +120,7 @@ public class MethodParameterTests { } @Test // SPR-16652 - public void annotatedConstructorParameterInInnerClass() throws Exception { + void annotatedConstructorParameterInInnerClass() throws Exception { Constructor constructor = InnerClass.class.getConstructor(getClass(), String.class, Callable.class); MethodParameter methodParameter = MethodParameter.forExecutable(constructor, 0); @@ -137,7 +137,7 @@ public class MethodParameterTests { } @Test // SPR-16734 - public void genericConstructorParameterInInnerClass() throws Exception { + void genericConstructorParameterInInnerClass() throws Exception { Constructor constructor = InnerClass.class.getConstructor(getClass(), String.class, Callable.class); MethodParameter methodParameter = MethodParameter.forExecutable(constructor, 0); @@ -155,7 +155,7 @@ public class MethodParameterTests { @Test @Deprecated - public void multipleResolveParameterTypeCalls() throws Exception { + void multipleResolveParameterTypeCalls() throws Exception { Method method = ArrayList.class.getMethod("get", int.class); MethodParameter methodParameter = MethodParameter.forExecutable(method, -1); assertThat(methodParameter.getParameterType()).isEqualTo(Object.class); @@ -166,7 +166,7 @@ public class MethodParameterTests { } @Test - public void equalsAndHashCodeConsidersContainingClass() throws Exception { + void equalsAndHashCodeConsidersContainingClass() throws Exception { Method method = ArrayList.class.getMethod("get", int.class); MethodParameter m1 = MethodParameter.forExecutable(method, -1); MethodParameter m2 = MethodParameter.forExecutable(method, -1); @@ -176,7 +176,7 @@ public class MethodParameterTests { } @Test - public void equalsAndHashCodeConsidersNesting() throws Exception { + void equalsAndHashCodeConsidersNesting() throws Exception { Method method = ArrayList.class.getMethod("get", int.class); MethodParameter m1 = MethodParameter.forExecutable(method, -1) .withContainingClass(StringList.class); @@ -189,7 +189,8 @@ public class MethodParameterTests { assertThat(m1.hashCode()).isEqualTo(m2.hashCode()); } - public void withContainingClassReturnsNewInstance() throws Exception { + @Test + void withContainingClassReturnsNewInstance() throws Exception { Method method = ArrayList.class.getMethod("get", int.class); MethodParameter m1 = MethodParameter.forExecutable(method, -1); MethodParameter m2 = m1.withContainingClass(StringList.class); @@ -201,7 +202,7 @@ public class MethodParameterTests { } @Test - public void withTypeIndexReturnsNewInstance() throws Exception { + void withTypeIndexReturnsNewInstance() throws Exception { Method method = ArrayList.class.getMethod("get", int.class); MethodParameter m1 = MethodParameter.forExecutable(method, -1); MethodParameter m2 = m1.withTypeIndex(2); @@ -214,7 +215,7 @@ public class MethodParameterTests { @Test @SuppressWarnings("deprecation") - public void mutatingNestingLevelShouldNotChangeNewInstance() throws Exception { + void mutatingNestingLevelShouldNotChangeNewInstance() throws Exception { Method method = ArrayList.class.getMethod("get", int.class); MethodParameter m1 = MethodParameter.forExecutable(method, -1); MethodParameter m2 = m1.withTypeIndex(2); @@ -225,7 +226,7 @@ public class MethodParameterTests { } @Test - public void nestedWithTypeIndexReturnsNewInstance() throws Exception { + void nestedWithTypeIndexReturnsNewInstance() throws Exception { Method method = ArrayList.class.getMethod("get", int.class); MethodParameter m1 = MethodParameter.forExecutable(method, -1); MethodParameter m2 = m1.nested(2); diff --git a/spring-core/src/test/java/org/springframework/core/NestedExceptionTests.java b/spring-core/src/test/java/org/springframework/core/NestedExceptionTests.java index 8e4d44bfb1..5134ced05c 100644 --- a/spring-core/src/test/java/org/springframework/core/NestedExceptionTests.java +++ b/spring-core/src/test/java/org/springframework/core/NestedExceptionTests.java @@ -28,10 +28,10 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Juergen Hoeller */ @SuppressWarnings("serial") -public class NestedExceptionTests { +class NestedExceptionTests { @Test - public void nestedRuntimeExceptionWithNoRootCause() { + void nestedRuntimeExceptionWithNoRootCause() { String mesg = "mesg of mine"; // Making a class abstract doesn't _really_ prevent instantiation :-) NestedRuntimeException nex = new NestedRuntimeException(mesg) {}; @@ -48,7 +48,7 @@ public class NestedExceptionTests { } @Test - public void nestedRuntimeExceptionWithRootCause() { + void nestedRuntimeExceptionWithRootCause() { String myMessage = "mesg for this exception"; String rootCauseMsg = "this is the obscure message of the root cause"; Exception rootCause = new Exception(rootCauseMsg); @@ -69,7 +69,7 @@ public class NestedExceptionTests { } @Test - public void nestedCheckedExceptionWithNoRootCause() { + void nestedCheckedExceptionWithNoRootCause() { String mesg = "mesg of mine"; // Making a class abstract doesn't _really_ prevent instantiation :-) NestedCheckedException nex = new NestedCheckedException(mesg) {}; @@ -86,7 +86,7 @@ public class NestedExceptionTests { } @Test - public void nestedCheckedExceptionWithRootCause() { + void nestedCheckedExceptionWithRootCause() { String myMessage = "mesg for this exception"; String rootCauseMsg = "this is the obscure message of the root cause"; Exception rootCause = new Exception(rootCauseMsg); diff --git a/spring-core/src/test/java/org/springframework/core/OrderComparatorTests.java b/spring-core/src/test/java/org/springframework/core/OrderComparatorTests.java index c27ff5c44e..cd67f213fd 100644 --- a/spring-core/src/test/java/org/springframework/core/OrderComparatorTests.java +++ b/spring-core/src/test/java/org/springframework/core/OrderComparatorTests.java @@ -30,73 +30,73 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Juergen Hoeller * @author Sam Brannen */ -public class OrderComparatorTests { +class OrderComparatorTests { private final OrderComparator comparator = new OrderComparator(); @Test - public void compareOrderedInstancesBefore() { + void compareOrderedInstancesBefore() { assertThat(this.comparator.compare(new StubOrdered(100), new StubOrdered(2000))).isEqualTo(-1); } @Test - public void compareOrderedInstancesSame() { + void compareOrderedInstancesSame() { assertThat(this.comparator.compare(new StubOrdered(100), new StubOrdered(100))).isEqualTo(0); } @Test - public void compareOrderedInstancesAfter() { + void compareOrderedInstancesAfter() { assertThat(this.comparator.compare(new StubOrdered(982300), new StubOrdered(100))).isEqualTo(1); } @Test - public void compareOrderedInstancesNullFirst() { + void compareOrderedInstancesNullFirst() { assertThat(this.comparator.compare(null, new StubOrdered(100))).isEqualTo(1); } @Test - public void compareOrderedInstancesNullLast() { + void compareOrderedInstancesNullLast() { assertThat(this.comparator.compare(new StubOrdered(100), null)).isEqualTo(-1); } @Test - public void compareOrderedInstancesDoubleNull() { + void compareOrderedInstancesDoubleNull() { assertThat(this.comparator.compare(null, null)).isEqualTo(0); } @Test - public void compareTwoNonOrderedInstancesEndsUpAsSame() { + void compareTwoNonOrderedInstancesEndsUpAsSame() { assertThat(this.comparator.compare(new Object(), new Object())).isEqualTo(0); } @Test - public void comparePriorityOrderedInstancesBefore() { + void comparePriorityOrderedInstancesBefore() { assertThat(this.comparator.compare(new StubPriorityOrdered(100), new StubPriorityOrdered(2000))).isEqualTo(-1); } @Test - public void comparePriorityOrderedInstancesSame() { + void comparePriorityOrderedInstancesSame() { assertThat(this.comparator.compare(new StubPriorityOrdered(100), new StubPriorityOrdered(100))).isEqualTo(0); } @Test - public void comparePriorityOrderedInstancesAfter() { + void comparePriorityOrderedInstancesAfter() { assertThat(this.comparator.compare(new StubPriorityOrdered(982300), new StubPriorityOrdered(100))).isEqualTo(1); } @Test - public void comparePriorityOrderedInstanceToStandardOrderedInstanceWithHigherPriority() { + void comparePriorityOrderedInstanceToStandardOrderedInstanceWithHigherPriority() { assertThatPriorityOrderedAlwaysWins(new StubPriorityOrdered(200), new StubOrdered(100)); } @Test - public void comparePriorityOrderedInstanceToStandardOrderedInstanceWithSamePriority() { + void comparePriorityOrderedInstanceToStandardOrderedInstanceWithSamePriority() { assertThatPriorityOrderedAlwaysWins(new StubPriorityOrdered(100), new StubOrdered(100)); } @Test - public void comparePriorityOrderedInstanceToStandardOrderedInstanceWithLowerPriority() { + void comparePriorityOrderedInstanceToStandardOrderedInstanceWithLowerPriority() { assertThatPriorityOrderedAlwaysWins(new StubPriorityOrdered(100), new StubOrdered(200)); } @@ -106,28 +106,28 @@ public class OrderComparatorTests { } @Test - public void compareWithSimpleSourceProvider() { + void compareWithSimpleSourceProvider() { Comparator customComparator = this.comparator.withSourceProvider( new TestSourceProvider(5L, new StubOrdered(25))); assertThat(customComparator.compare(new StubOrdered(10), 5L)).isEqualTo(-1); } @Test - public void compareWithSourceProviderArray() { + void compareWithSourceProviderArray() { Comparator customComparator = this.comparator.withSourceProvider( new TestSourceProvider(5L, new Object[] {new StubOrdered(10), new StubOrdered(-25)})); assertThat(customComparator.compare(5L, new Object())).isEqualTo(-1); } @Test - public void compareWithSourceProviderArrayNoMatch() { + void compareWithSourceProviderArrayNoMatch() { Comparator customComparator = this.comparator.withSourceProvider( new TestSourceProvider(5L, new Object[] {new Object(), new Object()})); assertThat(customComparator.compare(new Object(), 5L)).isEqualTo(0); } @Test - public void compareWithSourceProviderEmpty() { + void compareWithSourceProviderEmpty() { Comparator customComparator = this.comparator.withSourceProvider( new TestSourceProvider(50L, new Object())); assertThat(customComparator.compare(new Object(), 5L)).isEqualTo(0); diff --git a/spring-core/src/test/java/org/springframework/core/ParameterizedTypeReferenceTests.java b/spring-core/src/test/java/org/springframework/core/ParameterizedTypeReferenceTests.java index 8259010142..cb7e0414df 100644 --- a/spring-core/src/test/java/org/springframework/core/ParameterizedTypeReferenceTests.java +++ b/spring-core/src/test/java/org/springframework/core/ParameterizedTypeReferenceTests.java @@ -30,37 +30,37 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Arjen Poutsma * @author Rossen Stoyanchev */ -public class ParameterizedTypeReferenceTests { +class ParameterizedTypeReferenceTests { @Test - public void stringTypeReference() { + void stringTypeReference() { ParameterizedTypeReference typeReference = new ParameterizedTypeReference() {}; assertThat(typeReference.getType()).isEqualTo(String.class); } @Test - public void mapTypeReference() throws Exception { + void mapTypeReference() throws Exception { Type mapType = getClass().getMethod("mapMethod").getGenericReturnType(); ParameterizedTypeReference> typeReference = new ParameterizedTypeReference>() {}; assertThat(typeReference.getType()).isEqualTo(mapType); } @Test - public void listTypeReference() throws Exception { + void listTypeReference() throws Exception { Type listType = getClass().getMethod("listMethod").getGenericReturnType(); ParameterizedTypeReference> typeReference = new ParameterizedTypeReference>() {}; assertThat(typeReference.getType()).isEqualTo(listType); } @Test - public void reflectiveTypeReferenceWithSpecificDeclaration() throws Exception{ + void reflectiveTypeReferenceWithSpecificDeclaration() throws Exception{ Type listType = getClass().getMethod("listMethod").getGenericReturnType(); ParameterizedTypeReference> typeReference = ParameterizedTypeReference.forType(listType); assertThat(typeReference.getType()).isEqualTo(listType); } @Test - public void reflectiveTypeReferenceWithGenericDeclaration() throws Exception{ + void reflectiveTypeReferenceWithGenericDeclaration() throws Exception{ Type listType = getClass().getMethod("listMethod").getGenericReturnType(); ParameterizedTypeReference typeReference = ParameterizedTypeReference.forType(listType); assertThat(typeReference.getType()).isEqualTo(listType); diff --git a/spring-core/src/test/java/org/springframework/core/PrioritizedParameterNameDiscovererTests.java b/spring-core/src/test/java/org/springframework/core/PrioritizedParameterNameDiscovererTests.java index edd68764be..0a6918f2a4 100644 --- a/spring-core/src/test/java/org/springframework/core/PrioritizedParameterNameDiscovererTests.java +++ b/spring-core/src/test/java/org/springframework/core/PrioritizedParameterNameDiscovererTests.java @@ -26,7 +26,7 @@ import org.springframework.tests.sample.objects.TestObject; import static org.assertj.core.api.Assertions.assertThat; -public class PrioritizedParameterNameDiscovererTests { +class PrioritizedParameterNameDiscovererTests { private static final String[] FOO_BAR = new String[] { "foo", "bar" }; @@ -61,14 +61,14 @@ public class PrioritizedParameterNameDiscovererTests { } @Test - public void noParametersDiscoverers() { + void noParametersDiscoverers() { ParameterNameDiscoverer pnd = new PrioritizedParameterNameDiscoverer(); assertThat(pnd.getParameterNames(anyMethod)).isNull(); assertThat(pnd.getParameterNames((Constructor) null)).isNull(); } @Test - public void orderedParameterDiscoverers1() { + void orderedParameterDiscoverers1() { PrioritizedParameterNameDiscoverer pnd = new PrioritizedParameterNameDiscoverer(); pnd.addDiscoverer(returnsFooBar); assertThat(Arrays.equals(FOO_BAR, pnd.getParameterNames(anyMethod))).isTrue(); @@ -79,7 +79,7 @@ public class PrioritizedParameterNameDiscovererTests { } @Test - public void orderedParameterDiscoverers2() { + void orderedParameterDiscoverers2() { PrioritizedParameterNameDiscoverer pnd = new PrioritizedParameterNameDiscoverer(); pnd.addDiscoverer(returnsSomethingElse); assertThat(Arrays.equals(SOMETHING_ELSE, pnd.getParameterNames(anyMethod))).isTrue(); diff --git a/spring-core/src/test/java/org/springframework/core/ReactiveAdapterRegistryTests.java b/spring-core/src/test/java/org/springframework/core/ReactiveAdapterRegistryTests.java index ccb1475eb1..50f7b8b77b 100644 --- a/spring-core/src/test/java/org/springframework/core/ReactiveAdapterRegistryTests.java +++ b/spring-core/src/test/java/org/springframework/core/ReactiveAdapterRegistryTests.java @@ -40,13 +40,13 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Rossen Stoyanchev */ @SuppressWarnings("unchecked") -public class ReactiveAdapterRegistryTests { +class ReactiveAdapterRegistryTests { private final ReactiveAdapterRegistry registry = ReactiveAdapterRegistry.getSharedInstance(); @Test - public void defaultAdapterRegistrations() { + void defaultAdapterRegistrations() { // Reactor assertThat(getAdapter(Mono.class)).isNotNull(); @@ -75,7 +75,7 @@ public class ReactiveAdapterRegistryTests { } @Test - public void getAdapterForReactiveSubType() { + void getAdapterForReactiveSubType() { ReactiveAdapter adapter1 = getAdapter(Flux.class); ReactiveAdapter adapter2 = getAdapter(FluxProcessor.class); @@ -94,7 +94,7 @@ public class ReactiveAdapterRegistryTests { } @Test - public void publisherToFlux() { + void publisherToFlux() { List sequence = Arrays.asList(1, 2, 3); Publisher source = Flowable.fromIterable(sequence); Object target = getAdapter(Flux.class).fromPublisher(source); @@ -106,7 +106,7 @@ public class ReactiveAdapterRegistryTests { // TODO: publisherToMono/CompletableFuture vs Single (ISE on multiple elements)? @Test - public void publisherToMono() { + void publisherToMono() { Publisher source = Flowable.fromArray(1, 2, 3); Object target = getAdapter(Mono.class).fromPublisher(source); boolean condition = target instanceof Mono; @@ -115,7 +115,7 @@ public class ReactiveAdapterRegistryTests { } @Test - public void publisherToCompletableFuture() throws Exception { + void publisherToCompletableFuture() throws Exception { Publisher source = Flowable.fromArray(1, 2, 3); Object target = getAdapter(CompletableFuture.class).fromPublisher(source); boolean condition = target instanceof CompletableFuture; @@ -124,7 +124,7 @@ public class ReactiveAdapterRegistryTests { } @Test - public void publisherToRxObservable() { + void publisherToRxObservable() { List sequence = Arrays.asList(1, 2, 3); Publisher source = Flowable.fromIterable(sequence); Object target = getAdapter(rx.Observable.class).fromPublisher(source); @@ -134,7 +134,7 @@ public class ReactiveAdapterRegistryTests { } @Test - public void publisherToRxSingle() { + void publisherToRxSingle() { Publisher source = Flowable.fromArray(1); Object target = getAdapter(rx.Single.class).fromPublisher(source); boolean condition = target instanceof Single; @@ -143,7 +143,7 @@ public class ReactiveAdapterRegistryTests { } @Test - public void publisherToRxCompletable() { + void publisherToRxCompletable() { Publisher source = Flowable.fromArray(1, 2, 3); Object target = getAdapter(rx.Completable.class).fromPublisher(source); boolean condition = target instanceof Completable; @@ -152,7 +152,7 @@ public class ReactiveAdapterRegistryTests { } @Test - public void publisherToReactivexFlowable() { + void publisherToReactivexFlowable() { List sequence = Arrays.asList(1, 2, 3); Publisher source = Flux.fromIterable(sequence); Object target = getAdapter(io.reactivex.Flowable.class).fromPublisher(source); @@ -162,7 +162,7 @@ public class ReactiveAdapterRegistryTests { } @Test - public void publisherToReactivexObservable() { + void publisherToReactivexObservable() { List sequence = Arrays.asList(1, 2, 3); Publisher source = Flowable.fromIterable(sequence); Object target = getAdapter(io.reactivex.Observable.class).fromPublisher(source); @@ -172,7 +172,7 @@ public class ReactiveAdapterRegistryTests { } @Test - public void publisherToReactivexSingle() { + void publisherToReactivexSingle() { Publisher source = Flowable.fromArray(1); Object target = getAdapter(io.reactivex.Single.class).fromPublisher(source); boolean condition = target instanceof io.reactivex.Single; @@ -181,7 +181,7 @@ public class ReactiveAdapterRegistryTests { } @Test - public void publisherToReactivexCompletable() { + void publisherToReactivexCompletable() { Publisher source = Flowable.fromArray(1, 2, 3); Object target = getAdapter(io.reactivex.Completable.class).fromPublisher(source); boolean condition = target instanceof io.reactivex.Completable; @@ -190,7 +190,7 @@ public class ReactiveAdapterRegistryTests { } @Test - public void rxObservableToPublisher() { + void rxObservableToPublisher() { List sequence = Arrays.asList(1, 2, 3); Object source = rx.Observable.from(sequence); Object target = getAdapter(rx.Observable.class).toPublisher(source); @@ -200,7 +200,7 @@ public class ReactiveAdapterRegistryTests { } @Test - public void rxSingleToPublisher() { + void rxSingleToPublisher() { Object source = rx.Single.just(1); Object target = getAdapter(rx.Single.class).toPublisher(source); boolean condition = target instanceof Mono; @@ -209,7 +209,7 @@ public class ReactiveAdapterRegistryTests { } @Test - public void rxCompletableToPublisher() { + void rxCompletableToPublisher() { Object source = rx.Completable.complete(); Object target = getAdapter(rx.Completable.class).toPublisher(source); boolean condition = target instanceof Mono; @@ -218,7 +218,7 @@ public class ReactiveAdapterRegistryTests { } @Test - public void reactivexFlowableToPublisher() { + void reactivexFlowableToPublisher() { List sequence = Arrays.asList(1, 2, 3); Object source = io.reactivex.Flowable.fromIterable(sequence); Object target = getAdapter(io.reactivex.Flowable.class).toPublisher(source); @@ -228,7 +228,7 @@ public class ReactiveAdapterRegistryTests { } @Test - public void reactivexObservableToPublisher() { + void reactivexObservableToPublisher() { List sequence = Arrays.asList(1, 2, 3); Object source = io.reactivex.Observable.fromIterable(sequence); Object target = getAdapter(io.reactivex.Observable.class).toPublisher(source); @@ -238,7 +238,7 @@ public class ReactiveAdapterRegistryTests { } @Test - public void reactivexSingleToPublisher() { + void reactivexSingleToPublisher() { Object source = io.reactivex.Single.just(1); Object target = getAdapter(io.reactivex.Single.class).toPublisher(source); boolean condition = target instanceof Mono; @@ -247,7 +247,7 @@ public class ReactiveAdapterRegistryTests { } @Test - public void reactivexCompletableToPublisher() { + void reactivexCompletableToPublisher() { Object source = io.reactivex.Completable.complete(); Object target = getAdapter(io.reactivex.Completable.class).toPublisher(source); boolean condition = target instanceof Mono; @@ -256,7 +256,7 @@ public class ReactiveAdapterRegistryTests { } @Test - public void CompletableFutureToPublisher() { + void completableFutureToPublisher() { CompletableFuture future = new CompletableFuture<>(); future.complete(1); Object target = getAdapter(CompletableFuture.class).toPublisher(future); diff --git a/spring-core/src/test/java/org/springframework/core/ResolvableTypeTests.java b/spring-core/src/test/java/org/springframework/core/ResolvableTypeTests.java index 5395c54455..da36fff689 100644 --- a/spring-core/src/test/java/org/springframework/core/ResolvableTypeTests.java +++ b/spring-core/src/test/java/org/springframework/core/ResolvableTypeTests.java @@ -69,14 +69,14 @@ import static org.mockito.Mockito.verify; */ @SuppressWarnings("rawtypes") @ExtendWith(MockitoExtension.class) -public class ResolvableTypeTests { +class ResolvableTypeTests { @Captor private ArgumentCaptor> typeVariableCaptor; @Test - public void noneReturnValues() throws Exception { + void noneReturnValues() throws Exception { ResolvableType none = ResolvableType.NONE; assertThat(none.as(Object.class)).isEqualTo(ResolvableType.NONE); assertThat(none.asCollection()).isEqualTo(ResolvableType.NONE); @@ -99,7 +99,7 @@ public class ResolvableTypeTests { } @Test - public void forClass() throws Exception { + void forClass() throws Exception { ResolvableType type = ResolvableType.forClass(ExtendsList.class); assertThat(type.getType()).isEqualTo(ExtendsList.class); assertThat(type.getRawClass()).isEqualTo(ExtendsList.class); @@ -108,7 +108,7 @@ public class ResolvableTypeTests { } @Test - public void forClassWithNull() throws Exception { + void forClassWithNull() throws Exception { ResolvableType type = ResolvableType.forClass(null); assertThat(type.getType()).isEqualTo(Object.class); assertThat(type.getRawClass()).isEqualTo(Object.class); @@ -117,7 +117,7 @@ public class ResolvableTypeTests { } @Test - public void forRawClass() throws Exception { + void forRawClass() throws Exception { ResolvableType type = ResolvableType.forRawClass(ExtendsList.class); assertThat(type.getType()).isEqualTo(ExtendsList.class); assertThat(type.getRawClass()).isEqualTo(ExtendsList.class); @@ -126,7 +126,7 @@ public class ResolvableTypeTests { } @Test - public void forRawClassWithNull() throws Exception { + void forRawClassWithNull() throws Exception { ResolvableType type = ResolvableType.forRawClass(null); assertThat(type.getType()).isEqualTo(Object.class); assertThat(type.getRawClass()).isEqualTo(Object.class); @@ -135,7 +135,7 @@ public class ResolvableTypeTests { } @Test // gh-23321 - public void forRawClassAssignableFromTypeVariable() throws Exception { + void forRawClassAssignableFromTypeVariable() throws Exception { ResolvableType typeVariable = ResolvableType.forClass(ExtendsList.class).as(List.class).getGeneric(); ResolvableType raw = ResolvableType.forRawClass(CharSequence.class); assertThat(raw.resolve()).isEqualTo(CharSequence.class); @@ -147,42 +147,42 @@ public class ResolvableTypeTests { } @Test - public void forInstanceMustNotBeNull() throws Exception { + void forInstanceMustNotBeNull() throws Exception { assertThatIllegalArgumentException().isThrownBy(() -> ResolvableType.forInstance(null)) .withMessageContaining("Instance must not be null"); } @Test - public void forInstanceNoProvider() throws Exception { + void forInstanceNoProvider() throws Exception { ResolvableType type = ResolvableType.forInstance(new Object()); assertThat(type.getType()).isEqualTo(Object.class); assertThat(type.resolve()).isEqualTo(Object.class); } @Test - public void forInstanceProvider() throws Exception { + void forInstanceProvider() throws Exception { ResolvableType type = ResolvableType.forInstance(new MyGenericInterfaceType<>(String.class)); assertThat(type.getRawClass()).isEqualTo(MyGenericInterfaceType.class); assertThat(type.getGeneric().resolve()).isEqualTo(String.class); } @Test - public void forInstanceProviderNull() throws Exception { + void forInstanceProviderNull() throws Exception { ResolvableType type = ResolvableType.forInstance(new MyGenericInterfaceType(null)); assertThat(type.getType()).isEqualTo(MyGenericInterfaceType.class); assertThat(type.resolve()).isEqualTo(MyGenericInterfaceType.class); } @Test - public void forField() throws Exception { + void forField() throws Exception { Field field = Fields.class.getField("charSequenceList"); ResolvableType type = ResolvableType.forField(field); assertThat(type.getType()).isEqualTo(field.getGenericType()); } @Test - public void forPrivateField() throws Exception { + void forPrivateField() throws Exception { Field field = Fields.class.getDeclaredField("privateField"); ResolvableType type = ResolvableType.forField(field); assertThat(type.getType()).isEqualTo(field.getGenericType()); @@ -200,42 +200,42 @@ public class ResolvableTypeTests { } @Test - public void forFieldMustNotBeNull() throws Exception { + void forFieldMustNotBeNull() throws Exception { assertThatIllegalArgumentException().isThrownBy(() -> ResolvableType.forField(null)) .withMessageContaining("Field must not be null"); } @Test - public void forConstructorParameter() throws Exception { + void forConstructorParameter() throws Exception { Constructor constructor = Constructors.class.getConstructor(List.class); ResolvableType type = ResolvableType.forConstructorParameter(constructor, 0); assertThat(type.getType()).isEqualTo(constructor.getGenericParameterTypes()[0]); } @Test - public void forConstructorParameterMustNotBeNull() throws Exception { + void forConstructorParameterMustNotBeNull() throws Exception { assertThatIllegalArgumentException().isThrownBy(() -> ResolvableType.forConstructorParameter(null, 0)) .withMessageContaining("Constructor must not be null"); } @Test - public void forMethodParameterByIndex() throws Exception { + void forMethodParameterByIndex() throws Exception { Method method = Methods.class.getMethod("charSequenceParameter", List.class); ResolvableType type = ResolvableType.forMethodParameter(method, 0); assertThat(type.getType()).isEqualTo(method.getGenericParameterTypes()[0]); } @Test - public void forMethodParameterByIndexMustNotBeNull() throws Exception { + void forMethodParameterByIndexMustNotBeNull() throws Exception { assertThatIllegalArgumentException().isThrownBy(() -> ResolvableType.forMethodParameter(null, 0)) .withMessageContaining("Method must not be null"); } @Test - public void forMethodParameter() throws Exception { + void forMethodParameter() throws Exception { Method method = Methods.class.getMethod("charSequenceParameter", List.class); MethodParameter methodParameter = MethodParameter.forExecutable(method, 0); ResolvableType type = ResolvableType.forMethodParameter(methodParameter); @@ -243,7 +243,7 @@ public class ResolvableTypeTests { } @Test - public void forMethodParameterWithNesting() throws Exception { + void forMethodParameterWithNesting() throws Exception { Method method = Methods.class.getMethod("nested", Map.class); MethodParameter methodParameter = MethodParameter.forExecutable(method, 0); methodParameter.increaseNestingLevel(); @@ -254,7 +254,7 @@ public class ResolvableTypeTests { } @Test - public void forMethodParameterWithNestingAndLevels() throws Exception { + void forMethodParameterWithNestingAndLevels() throws Exception { Method method = Methods.class.getMethod("nested", Map.class); MethodParameter methodParameter = MethodParameter.forExecutable(method, 0); methodParameter.increaseNestingLevel(); @@ -266,14 +266,14 @@ public class ResolvableTypeTests { } @Test - public void forMethodParameterMustNotBeNull() throws Exception { + void forMethodParameterMustNotBeNull() throws Exception { assertThatIllegalArgumentException().isThrownBy(() -> ResolvableType.forMethodParameter(null)) .withMessageContaining("MethodParameter must not be null"); } @Test // SPR-16210 - public void forMethodParameterWithSameSignatureAndGenerics() throws Exception { + void forMethodParameterWithSameSignatureAndGenerics() throws Exception { Method method = Methods.class.getMethod("list1"); MethodParameter methodParameter = MethodParameter.forExecutable(method, -1); ResolvableType type = ResolvableType.forMethodParameter(methodParameter); @@ -286,59 +286,59 @@ public class ResolvableTypeTests { } @Test - public void forMethodReturn() throws Exception { + void forMethodReturn() throws Exception { Method method = Methods.class.getMethod("charSequenceReturn"); ResolvableType type = ResolvableType.forMethodReturnType(method); assertThat(type.getType()).isEqualTo(method.getGenericReturnType()); } @Test - public void forMethodReturnMustNotBeNull() throws Exception { + void forMethodReturnMustNotBeNull() throws Exception { assertThatIllegalArgumentException().isThrownBy(() -> ResolvableType.forMethodReturnType(null)) .withMessageContaining("Method must not be null"); } @Test - public void classType() throws Exception { + void classType() throws Exception { ResolvableType type = ResolvableType.forField(Fields.class.getField("classType")); assertThat(type.getType().getClass()).isEqualTo(Class.class); } @Test - public void paramaterizedType() throws Exception { + void paramaterizedType() throws Exception { ResolvableType type = ResolvableType.forField(Fields.class.getField("parameterizedType")); assertThat(type.getType()).isInstanceOf(ParameterizedType.class); } @Test - public void arrayClassType() throws Exception { + void arrayClassType() throws Exception { ResolvableType type = ResolvableType.forField(Fields.class.getField("arrayClassType")); assertThat(type.getType()).isInstanceOf(Class.class); assertThat(((Class) type.getType()).isArray()).isEqualTo(true); } @Test - public void genericArrayType() throws Exception { + void genericArrayType() throws Exception { ResolvableType type = ResolvableType.forField(Fields.class.getField("genericArrayType")); assertThat(type.getType()).isInstanceOf(GenericArrayType.class); } @Test - public void wildcardType() throws Exception { + void wildcardType() throws Exception { ResolvableType type = ResolvableType.forField(Fields.class.getField("wildcardType")); assertThat(type.getType()).isInstanceOf(ParameterizedType.class); assertThat(type.getGeneric().getType()).isInstanceOf(WildcardType.class); } @Test - public void typeVariableType() throws Exception { + void typeVariableType() throws Exception { ResolvableType type = ResolvableType.forField(Fields.class.getField("typeVariableType")); assertThat(type.getType()).isInstanceOf(TypeVariable.class); } @Test - public void getComponentTypeForClassArray() throws Exception { + void getComponentTypeForClassArray() throws Exception { Field field = Fields.class.getField("arrayClassType"); ResolvableType type = ResolvableType.forField(field); assertThat(type.isArray()).isEqualTo(true); @@ -347,7 +347,7 @@ public class ResolvableTypeTests { } @Test - public void getComponentTypeForGenericArrayType() throws Exception { + void getComponentTypeForGenericArrayType() throws Exception { ResolvableType type = ResolvableType.forField(Fields.class.getField("genericArrayType")); assertThat(type.isArray()).isEqualTo(true); assertThat(type.getComponentType().getType()).isEqualTo( @@ -355,7 +355,7 @@ public class ResolvableTypeTests { } @Test - public void getComponentTypeForVariableThatResolvesToGenericArray() throws Exception { + void getComponentTypeForVariableThatResolvesToGenericArray() throws Exception { ResolvableType type = ResolvableType.forClass(ListOfGenericArray.class).asCollection().getGeneric(); assertThat(type.isArray()).isEqualTo(true); assertThat(type.getType()).isInstanceOf(TypeVariable.class); @@ -364,21 +364,21 @@ public class ResolvableTypeTests { } @Test - public void getComponentTypeForNonArray() throws Exception { + void getComponentTypeForNonArray() throws Exception { ResolvableType type = ResolvableType.forClass(String.class); assertThat(type.isArray()).isEqualTo(false); assertThat(type.getComponentType()).isEqualTo(ResolvableType.NONE); } @Test - public void asCollection() throws Exception { + void asCollection() throws Exception { ResolvableType type = ResolvableType.forClass(ExtendsList.class).asCollection(); assertThat(type.resolve()).isEqualTo(Collection.class); assertThat(type.resolveGeneric()).isEqualTo(CharSequence.class); } @Test - public void asMap() throws Exception { + void asMap() throws Exception { ResolvableType type = ResolvableType.forClass(ExtendsMap.class).asMap(); assertThat(type.resolve()).isEqualTo(Map.class); assertThat(type.resolveGeneric(0)).isEqualTo(String.class); @@ -386,43 +386,43 @@ public class ResolvableTypeTests { } @Test - public void asFromInterface() throws Exception { + void asFromInterface() throws Exception { ResolvableType type = ResolvableType.forClass(ExtendsList.class).as(List.class); assertThat(type.getType().toString()).isEqualTo("java.util.List"); } @Test - public void asFromInheritedInterface() throws Exception { + void asFromInheritedInterface() throws Exception { ResolvableType type = ResolvableType.forClass(ExtendsList.class).as(Collection.class); assertThat(type.getType().toString()).isEqualTo("java.util.Collection"); } @Test - public void asFromSuperType() throws Exception { + void asFromSuperType() throws Exception { ResolvableType type = ResolvableType.forClass(ExtendsList.class).as(ArrayList.class); assertThat(type.getType().toString()).isEqualTo("java.util.ArrayList"); } @Test - public void asFromInheritedSuperType() throws Exception { + void asFromInheritedSuperType() throws Exception { ResolvableType type = ResolvableType.forClass(ExtendsList.class).as(List.class); assertThat(type.getType().toString()).isEqualTo("java.util.List"); } @Test - public void asNotFound() throws Exception { + void asNotFound() throws Exception { ResolvableType type = ResolvableType.forClass(ExtendsList.class).as(Map.class); assertThat(type).isSameAs(ResolvableType.NONE); } @Test - public void asSelf() throws Exception { + void asSelf() throws Exception { ResolvableType type = ResolvableType.forClass(ExtendsList.class); assertThat(type.as(ExtendsList.class)).isEqualTo(type); } @Test - public void getSuperType() throws Exception { + void getSuperType() throws Exception { ResolvableType type = ResolvableType.forClass(ExtendsList.class).getSuperType(); assertThat(type.resolve()).isEqualTo(ArrayList.class); type = type.getSuperType(); @@ -434,7 +434,7 @@ public class ResolvableTypeTests { } @Test - public void getInterfaces() throws Exception { + void getInterfaces() throws Exception { ResolvableType type = ResolvableType.forClass(ExtendsList.class); assertThat(type.getInterfaces().length).isEqualTo(0); SortedSet interfaces = new TreeSet<>(); @@ -447,18 +447,18 @@ public class ResolvableTypeTests { } @Test - public void noSuperType() throws Exception { + void noSuperType() throws Exception { assertThat(ResolvableType.forClass(Object.class).getSuperType()) .isEqualTo(ResolvableType.NONE); } @Test - public void noInterfaces() throws Exception { + void noInterfaces() throws Exception { assertThat(ResolvableType.forClass(Object.class).getInterfaces()).isEmpty(); } @Test - public void nested() throws Exception { + void nested() throws Exception { ResolvableType type = ResolvableType.forField(Fields.class.getField("nested")); type = type.getNested(2); assertThat(type.resolve()).isEqualTo(Map.class); @@ -467,7 +467,7 @@ public class ResolvableTypeTests { } @Test - public void nestedWithIndexes() throws Exception { + void nestedWithIndexes() throws Exception { ResolvableType type = ResolvableType.forField(Fields.class.getField("nested")); type = type.getNested(2, Collections.singletonMap(2, 0)); assertThat(type.resolve()).isEqualTo(Map.class); @@ -476,7 +476,7 @@ public class ResolvableTypeTests { } @Test - public void nestedWithArray() throws Exception { + void nestedWithArray() throws Exception { ResolvableType type = ResolvableType.forField(Fields.class.getField("genericArrayType")); type = type.getNested(2); assertThat(type.resolve()).isEqualTo(List.class); @@ -484,40 +484,40 @@ public class ResolvableTypeTests { } @Test - public void getGeneric() throws Exception { + void getGeneric() throws Exception { ResolvableType type = ResolvableType.forField(Fields.class.getField("stringList")); assertThat(type.getGeneric().getType()).isEqualTo(String.class); } @Test - public void getGenericByIndex() throws Exception { + void getGenericByIndex() throws Exception { ResolvableType type = ResolvableType.forField(Fields.class.getField("stringIntegerMultiValueMap")); assertThat(type.getGeneric(0).getType()).isEqualTo(String.class); assertThat(type.getGeneric(1).getType()).isEqualTo(Integer.class); } @Test - public void getGenericOfGeneric() throws Exception { + void getGenericOfGeneric() throws Exception { ResolvableType type = ResolvableType.forField(Fields.class.getField("stringListList")); assertThat(type.getGeneric().getType().toString()).isEqualTo("java.util.List"); assertThat(type.getGeneric().getGeneric().getType()).isEqualTo(String.class); } @Test - public void genericOfGenericWithAs() throws Exception { + void genericOfGenericWithAs() throws Exception { ResolvableType type = ResolvableType.forField(Fields.class.getField("stringListList")).asCollection(); assertThat(type.toString()).isEqualTo("java.util.Collection>"); assertThat(type.getGeneric().asCollection().toString()).isEqualTo("java.util.Collection"); } @Test - public void getGenericOfGenericByIndexes() throws Exception { + void getGenericOfGenericByIndexes() throws Exception { ResolvableType type = ResolvableType.forField(Fields.class.getField("stringListList")); assertThat(type.getGeneric(0, 0).getType()).isEqualTo(String.class); } @Test - public void getGenericOutOfBounds() throws Exception { + void getGenericOutOfBounds() throws Exception { ResolvableType type = ResolvableType.forClass(List.class, ExtendsList.class); assertThat(type.getGeneric(0)).isNotEqualTo(ResolvableType.NONE); assertThat(type.getGeneric(1)).isEqualTo(ResolvableType.NONE); @@ -525,14 +525,14 @@ public class ResolvableTypeTests { } @Test - public void hasGenerics() throws Exception { + void hasGenerics() throws Exception { ResolvableType type = ResolvableType.forClass(ExtendsList.class); assertThat(type.hasGenerics()).isEqualTo(false); assertThat(type.asCollection().hasGenerics()).isEqualTo(true); } @Test - public void getGenericsFromParameterizedType() throws Exception { + void getGenericsFromParameterizedType() throws Exception { ResolvableType type = ResolvableType.forClass(List.class, ExtendsList.class); ResolvableType[] generics = type.getGenerics(); assertThat(generics.length).isEqualTo(1); @@ -540,7 +540,7 @@ public class ResolvableTypeTests { } @Test - public void getGenericsFromClass() throws Exception { + void getGenericsFromClass() throws Exception { ResolvableType type = ResolvableType.forClass(List.class); ResolvableType[] generics = type.getGenerics(); assertThat(generics.length).isEqualTo(1); @@ -548,14 +548,14 @@ public class ResolvableTypeTests { } @Test - public void noGetGenerics() throws Exception { + void noGetGenerics() throws Exception { ResolvableType type = ResolvableType.forClass(ExtendsList.class); ResolvableType[] generics = type.getGenerics(); assertThat(generics.length).isEqualTo(0); } @Test - public void getResolvedGenerics() throws Exception { + void getResolvedGenerics() throws Exception { ResolvableType type = ResolvableType.forClass(List.class, ExtendsList.class); Class[] generics = type.resolveGenerics(); assertThat(generics.length).isEqualTo(1); @@ -563,25 +563,25 @@ public class ResolvableTypeTests { } @Test - public void resolveClassType() throws Exception { + void resolveClassType() throws Exception { ResolvableType type = ResolvableType.forField(Fields.class.getField("classType")); assertThat(type.resolve()).isEqualTo(List.class); } @Test - public void resolveParameterizedType() throws Exception { + void resolveParameterizedType() throws Exception { ResolvableType type = ResolvableType.forField(Fields.class.getField("parameterizedType")); assertThat(type.resolve()).isEqualTo(List.class); } @Test - public void resolveArrayClassType() throws Exception { + void resolveArrayClassType() throws Exception { ResolvableType type = ResolvableType.forField(Fields.class.getField("arrayClassType")); assertThat(type.resolve()).isEqualTo(List[].class); } @Test - public void resolveGenericArrayType() throws Exception { + void resolveGenericArrayType() throws Exception { ResolvableType type = ResolvableType.forField(Fields.class.getField("genericArrayType")); assertThat(type.resolve()).isEqualTo(List[].class); assertThat(type.getComponentType().resolve()).isEqualTo(List.class); @@ -589,14 +589,14 @@ public class ResolvableTypeTests { } @Test - public void resolveGenericMultiArrayType() throws Exception { + void resolveGenericMultiArrayType() throws Exception { ResolvableType type = ResolvableType.forField(Fields.class.getField("genericMultiArrayType")); assertThat(type.resolve()).isEqualTo(List[][][].class); assertThat(type.getComponentType().resolve()).isEqualTo(List[][].class); } @Test - public void resolveGenericArrayFromGeneric() throws Exception { + void resolveGenericArrayFromGeneric() throws Exception { ResolvableType type = ResolvableType.forField(Fields.class.getField("stringArrayList")); ResolvableType generic = type.asCollection().getGeneric(); assertThat(generic.getType().toString()).isEqualTo("E"); @@ -605,7 +605,7 @@ public class ResolvableTypeTests { } @Test - public void resolveVariableGenericArray() throws Exception { + void resolveVariableGenericArray() throws Exception { ResolvableType type = ResolvableType.forField(Fields.class.getField("variableTypeGenericArray"), TypedFields.class); assertThat(type.getType().toString()).isEqualTo("T[]"); assertThat(type.isArray()).isEqualTo(true); @@ -613,7 +613,7 @@ public class ResolvableTypeTests { } @Test - public void resolveVariableGenericArrayUnknown() throws Exception { + void resolveVariableGenericArrayUnknown() throws Exception { ResolvableType type = ResolvableType.forField(Fields.class.getField("variableTypeGenericArray")); assertThat(type.getType().toString()).isEqualTo("T[]"); assertThat(type.isArray()).isEqualTo(true); @@ -621,7 +621,7 @@ public class ResolvableTypeTests { } @Test - public void resolveVariableGenericArrayUnknownWithFallback() throws Exception { + void resolveVariableGenericArrayUnknownWithFallback() throws Exception { ResolvableType type = ResolvableType.forField(Fields.class.getField("variableTypeGenericArray")); assertThat(type.getType().toString()).isEqualTo("T[]"); assertThat(type.isArray()).isEqualTo(true); @@ -629,33 +629,33 @@ public class ResolvableTypeTests { } @Test - public void resolveWildcardTypeUpperBounds() throws Exception { + void resolveWildcardTypeUpperBounds() throws Exception { ResolvableType type = ResolvableType.forField(Fields.class.getField("wildcardType")); assertThat(type.getGeneric().resolve()).isEqualTo(Number.class); } @Test - public void resolveWildcardLowerBounds() throws Exception { + void resolveWildcardLowerBounds() throws Exception { ResolvableType type = ResolvableType.forField(Fields.class.getField("wildcardSuperType")); assertThat(type.getGeneric().resolve()).isEqualTo(Number.class); } @Test - public void resolveVariableFromFieldType() throws Exception { + void resolveVariableFromFieldType() throws Exception { ResolvableType type = ResolvableType.forField(Fields.class.getField("stringList")); assertThat(type.resolve()).isEqualTo(List.class); assertThat(type.getGeneric().resolve()).isEqualTo(String.class); } @Test - public void resolveVariableFromFieldTypeUnknown() throws Exception { + void resolveVariableFromFieldTypeUnknown() throws Exception { ResolvableType type = ResolvableType.forField(Fields.class.getField("parameterizedType")); assertThat(type.resolve()).isEqualTo(List.class); assertThat(type.getGeneric().resolve()).isNull(); } @Test - public void resolveVariableFromInheritedField() throws Exception { + void resolveVariableFromInheritedField() throws Exception { ResolvableType type = ResolvableType.forField( Fields.class.getField("stringIntegerMultiValueMap")).as(Map.class); assertThat(type.getGeneric(0).resolve()).isEqualTo(String.class); @@ -664,7 +664,7 @@ public class ResolvableTypeTests { } @Test - public void resolveVariableFromInheritedFieldSwitched() throws Exception { + void resolveVariableFromInheritedFieldSwitched() throws Exception { ResolvableType type = ResolvableType.forField( Fields.class.getField("stringIntegerMultiValueMapSwitched")).as(Map.class); assertThat(type.getGeneric(0).resolve()).isEqualTo(String.class); @@ -673,7 +673,7 @@ public class ResolvableTypeTests { } @Test - public void doesResolveFromOuterOwner() throws Exception { + void doesResolveFromOuterOwner() throws Exception { ResolvableType type = ResolvableType.forField( Fields.class.getField("listOfListOfUnknown")).as(Collection.class); assertThat(type.getGeneric(0).resolve()).isEqualTo(List.class); @@ -681,39 +681,39 @@ public class ResolvableTypeTests { } @Test - public void resolveBoundedTypeVariableResult() throws Exception { + void resolveBoundedTypeVariableResult() throws Exception { ResolvableType type = ResolvableType.forMethodReturnType(Methods.class.getMethod("boundedTypeVaraibleResult")); assertThat(type.resolve()).isEqualTo(CharSequence.class); } @Test - public void resolveVariableNotFound() throws Exception { + void resolveVariableNotFound() throws Exception { ResolvableType type = ResolvableType.forMethodReturnType(Methods.class.getMethod("typedReturn")); assertThat(type.resolve()).isNull(); } @Test - public void resolveTypeVaraibleFromMethodReturn() throws Exception { + void resolveTypeVaraibleFromMethodReturn() throws Exception { ResolvableType type = ResolvableType.forMethodReturnType(Methods.class.getMethod("typedReturn")); assertThat(type.resolve()).isNull(); } @Test - public void resolveTypeVaraibleFromMethodReturnWithInstanceClass() throws Exception { + void resolveTypeVaraibleFromMethodReturnWithInstanceClass() throws Exception { ResolvableType type = ResolvableType.forMethodReturnType( Methods.class.getMethod("typedReturn"), TypedMethods.class); assertThat(type.resolve()).isEqualTo(String.class); } @Test - public void resolveTypeVaraibleFromSimpleInterfaceType() { + void resolveTypeVaraibleFromSimpleInterfaceType() { ResolvableType type = ResolvableType.forClass( MySimpleInterfaceType.class).as(MyInterfaceType.class); assertThat(type.resolveGeneric()).isEqualTo(String.class); } @Test - public void resolveTypeVaraibleFromSimpleCollectionInterfaceType() { + void resolveTypeVaraibleFromSimpleCollectionInterfaceType() { ResolvableType type = ResolvableType.forClass( MyCollectionInterfaceType.class).as(MyInterfaceType.class); assertThat(type.resolveGeneric()).isEqualTo(Collection.class); @@ -721,14 +721,14 @@ public class ResolvableTypeTests { } @Test - public void resolveTypeVaraibleFromSimpleSuperclassType() { + void resolveTypeVaraibleFromSimpleSuperclassType() { ResolvableType type = ResolvableType.forClass( MySimpleSuperclassType.class).as(MySuperclassType.class); assertThat(type.resolveGeneric()).isEqualTo(String.class); } @Test - public void resolveTypeVaraibleFromSimpleCollectionSuperclassType() { + void resolveTypeVaraibleFromSimpleCollectionSuperclassType() { ResolvableType type = ResolvableType.forClass( MyCollectionSuperclassType.class).as(MySuperclassType.class); assertThat(type.resolveGeneric()).isEqualTo(Collection.class); @@ -736,7 +736,7 @@ public class ResolvableTypeTests { } @Test - public void resolveTypeVariableFromFieldTypeWithImplementsClass() throws Exception { + void resolveTypeVariableFromFieldTypeWithImplementsClass() throws Exception { ResolvableType type = ResolvableType.forField( Fields.class.getField("parameterizedType"), TypedFields.class); assertThat(type.resolve()).isEqualTo(List.class); @@ -744,7 +744,7 @@ public class ResolvableTypeTests { } @Test - public void resolveTypeVariableFromFieldTypeWithImplementsType() throws Exception { + void resolveTypeVariableFromFieldTypeWithImplementsType() throws Exception { ResolvableType implementationType = ResolvableType.forClassWithGenerics( Fields.class, Integer.class); ResolvableType type = ResolvableType.forField( @@ -754,7 +754,7 @@ public class ResolvableTypeTests { } @Test - public void resolveTypeVariableFromSuperType() throws Exception { + void resolveTypeVariableFromSuperType() throws Exception { ResolvableType type = ResolvableType.forClass(ExtendsList.class); assertThat(type.resolve()).isEqualTo(ExtendsList.class); assertThat(type.asCollection().resolveGeneric()) @@ -762,7 +762,7 @@ public class ResolvableTypeTests { } @Test - public void resolveTypeVariableFromClassWithImplementsClass() throws Exception { + void resolveTypeVariableFromClassWithImplementsClass() throws Exception { ResolvableType type = ResolvableType.forClass( MySuperclassType.class, MyCollectionSuperclassType.class); assertThat(type.resolveGeneric()).isEqualTo(Collection.class); @@ -770,7 +770,7 @@ public class ResolvableTypeTests { } @Test - public void resolveTypeVariableFromConstructorParameter() throws Exception { + void resolveTypeVariableFromConstructorParameter() throws Exception { Constructor constructor = Constructors.class.getConstructor(List.class); ResolvableType type = ResolvableType.forConstructorParameter(constructor, 0); assertThat(type.resolve()).isEqualTo(List.class); @@ -778,7 +778,7 @@ public class ResolvableTypeTests { } @Test - public void resolveUnknownTypeVariableFromConstructorParameter() throws Exception { + void resolveUnknownTypeVariableFromConstructorParameter() throws Exception { Constructor constructor = Constructors.class.getConstructor(Map.class); ResolvableType type = ResolvableType.forConstructorParameter(constructor, 0); assertThat(type.resolve()).isEqualTo(Map.class); @@ -786,7 +786,7 @@ public class ResolvableTypeTests { } @Test - public void resolveTypeVariableFromConstructorParameterWithImplementsClass() throws Exception { + void resolveTypeVariableFromConstructorParameterWithImplementsClass() throws Exception { Constructor constructor = Constructors.class.getConstructor(Map.class); ResolvableType type = ResolvableType.forConstructorParameter( constructor, 0, TypedConstructors.class); @@ -795,7 +795,7 @@ public class ResolvableTypeTests { } @Test - public void resolveTypeVariableFromMethodParameter() throws Exception { + void resolveTypeVariableFromMethodParameter() throws Exception { Method method = Methods.class.getMethod("typedParameter", Object.class); ResolvableType type = ResolvableType.forMethodParameter(method, 0); assertThat(type.resolve()).isNull(); @@ -803,7 +803,7 @@ public class ResolvableTypeTests { } @Test - public void resolveTypeVariableFromMethodParameterWithImplementsClass() throws Exception { + void resolveTypeVariableFromMethodParameterWithImplementsClass() throws Exception { Method method = Methods.class.getMethod("typedParameter", Object.class); ResolvableType type = ResolvableType.forMethodParameter(method, 0, TypedMethods.class); assertThat(type.resolve()).isEqualTo(String.class); @@ -811,7 +811,7 @@ public class ResolvableTypeTests { } @Test - public void resolveTypeVariableFromMethodParameterType() throws Exception { + void resolveTypeVariableFromMethodParameterType() throws Exception { Method method = Methods.class.getMethod("typedParameter", Object.class); MethodParameter methodParameter = MethodParameter.forExecutable(method, 0); ResolvableType type = ResolvableType.forMethodParameter(methodParameter); @@ -820,7 +820,7 @@ public class ResolvableTypeTests { } @Test - public void resolveTypeVariableFromMethodParameterTypeWithImplementsClass() throws Exception { + void resolveTypeVariableFromMethodParameterTypeWithImplementsClass() throws Exception { Method method = Methods.class.getMethod("typedParameter", Object.class); MethodParameter methodParameter = MethodParameter.forExecutable(method, 0); methodParameter.setContainingClass(TypedMethods.class); @@ -830,7 +830,7 @@ public class ResolvableTypeTests { } @Test - public void resolveTypeVariableFromMethodParameterTypeWithImplementsType() throws Exception { + void resolveTypeVariableFromMethodParameterTypeWithImplementsType() throws Exception { Method method = Methods.class.getMethod("typedParameter", Object.class); MethodParameter methodParameter = MethodParameter.forExecutable(method, 0); ResolvableType implementationType = ResolvableType.forClassWithGenerics(Methods.class, Integer.class); @@ -840,7 +840,7 @@ public class ResolvableTypeTests { } @Test - public void resolveTypeVariableFromMethodReturn() throws Exception { + void resolveTypeVariableFromMethodReturn() throws Exception { Method method = Methods.class.getMethod("typedReturn"); ResolvableType type = ResolvableType.forMethodReturnType(method); assertThat(type.resolve()).isNull(); @@ -848,7 +848,7 @@ public class ResolvableTypeTests { } @Test - public void resolveTypeVariableFromMethodReturnWithImplementsClass() throws Exception { + void resolveTypeVariableFromMethodReturnWithImplementsClass() throws Exception { Method method = Methods.class.getMethod("typedReturn"); ResolvableType type = ResolvableType.forMethodReturnType(method, TypedMethods.class); assertThat(type.resolve()).isEqualTo(String.class); @@ -856,7 +856,7 @@ public class ResolvableTypeTests { } @Test - public void resolveTypeVariableFromType() throws Exception { + void resolveTypeVariableFromType() throws Exception { Type sourceType = Methods.class.getMethod("typedReturn").getGenericReturnType(); ResolvableType type = ResolvableType.forType(sourceType); assertThat(type.resolve()).isNull(); @@ -864,7 +864,7 @@ public class ResolvableTypeTests { } @Test - public void resolveTypeVariableFromTypeWithVariableResolver() throws Exception { + void resolveTypeVariableFromTypeWithVariableResolver() throws Exception { Type sourceType = Methods.class.getMethod("typedReturn").getGenericReturnType(); ResolvableType type = ResolvableType.forType( sourceType, ResolvableType.forClass(TypedMethods.class).as(Methods.class).asVariableResolver()); @@ -873,7 +873,7 @@ public class ResolvableTypeTests { } @Test - public void resolveTypeWithCustomVariableResolver() throws Exception { + void resolveTypeWithCustomVariableResolver() throws Exception { VariableResolver variableResolver = mock(VariableResolver.class); given(variableResolver.getSource()).willReturn(this); ResolvableType longType = ResolvableType.forClass(Long.class); @@ -892,7 +892,7 @@ public class ResolvableTypeTests { } @Test - public void resolveTypeVariableFromReflectiveParameterizedTypeReference() throws Exception { + void resolveTypeVariableFromReflectiveParameterizedTypeReference() throws Exception { Type sourceType = Methods.class.getMethod("typedReturn").getGenericReturnType(); ResolvableType type = ResolvableType.forType(ParameterizedTypeReference.forType(sourceType)); assertThat(type.resolve()).isNull(); @@ -900,7 +900,7 @@ public class ResolvableTypeTests { } @Test - public void resolveTypeVariableFromDeclaredParameterizedTypeReference() throws Exception { + void resolveTypeVariableFromDeclaredParameterizedTypeReference() throws Exception { Type sourceType = Methods.class.getMethod("charSequenceReturn").getGenericReturnType(); ResolvableType reflectiveType = ResolvableType.forType(sourceType); ResolvableType declaredType = ResolvableType.forType(new ParameterizedTypeReference>() {}); @@ -908,7 +908,7 @@ public class ResolvableTypeTests { } @Test - public void toStrings() throws Exception { + void toStrings() throws Exception { assertThat(ResolvableType.NONE.toString()).isEqualTo("?"); assertThat(forField("classType")).hasToString("java.util.List"); @@ -935,7 +935,7 @@ public class ResolvableTypeTests { } @Test - public void getSource() throws Exception { + void getSource() throws Exception { Class classType = MySimpleInterfaceType.class; Field basicField = Fields.class.getField("classType"); Field field = Fields.class.getField("charSequenceList"); @@ -950,14 +950,14 @@ public class ResolvableTypeTests { } @Test - public void resolveFromOuterClass() throws Exception { + void resolveFromOuterClass() throws Exception { Field field = EnclosedInParameterizedType.InnerTyped.class.getField("field"); ResolvableType type = ResolvableType.forField(field, TypedEnclosedInParameterizedType.TypedInnerTyped.class); assertThat(type.resolve()).isEqualTo(Integer.class); } @Test - public void resolveFromClassWithGenerics() throws Exception { + void resolveFromClassWithGenerics() throws Exception { ResolvableType type = ResolvableType.forClassWithGenerics(List.class, ResolvableType.forClassWithGenerics(List.class, String.class)); assertThat(type.asCollection().toString()).isEqualTo("java.util.Collection>"); assertThat(type.asCollection().getGeneric().toString()).isEqualTo("java.util.List"); @@ -967,21 +967,21 @@ public class ResolvableTypeTests { } @Test - public void isAssignableFromMustNotBeNull() throws Exception { + void isAssignableFromMustNotBeNull() throws Exception { assertThatIllegalArgumentException().isThrownBy(() -> ResolvableType.forClass(Object.class).isAssignableFrom((ResolvableType) null)) .withMessageContaining("Type must not be null"); } @Test - public void isAssignableFromForNone() throws Exception { + void isAssignableFromForNone() throws Exception { ResolvableType objectType = ResolvableType.forClass(Object.class); assertThat(objectType.isAssignableFrom(ResolvableType.NONE)).isEqualTo(false); assertThat(ResolvableType.NONE.isAssignableFrom(objectType)).isEqualTo(false); } @Test - public void isAssignableFromForClassAndClass() throws Exception { + void isAssignableFromForClassAndClass() throws Exception { ResolvableType objectType = ResolvableType.forClass(Object.class); ResolvableType charSequenceType = ResolvableType.forClass(CharSequence.class); ResolvableType stringType = ResolvableType.forClass(String.class); @@ -1006,7 +1006,7 @@ public class ResolvableTypeTests { } @Test - public void isAssignableFromCannotBeResolved() throws Exception { + void isAssignableFromCannotBeResolved() throws Exception { ResolvableType objectType = ResolvableType.forClass(Object.class); ResolvableType unresolvableVariable = ResolvableType.forField(AssignmentBase.class.getField("o")); assertThat(unresolvableVariable.resolve()).isNull(); @@ -1015,7 +1015,7 @@ public class ResolvableTypeTests { } @Test - public void isAssignableFromForClassAndSimpleVariable() throws Exception { + void isAssignableFromForClassAndSimpleVariable() throws Exception { ResolvableType objectType = ResolvableType.forClass(Object.class); ResolvableType charSequenceType = ResolvableType.forClass(CharSequence.class); ResolvableType stringType = ResolvableType.forClass(String.class); @@ -1038,7 +1038,7 @@ public class ResolvableTypeTests { } @Test - public void isAssignableFromForSameClassNonExtendsGenerics() throws Exception { + void isAssignableFromForSameClassNonExtendsGenerics() throws Exception { ResolvableType objectList = ResolvableType.forField(AssignmentBase.class.getField("listo"), Assignment.class); ResolvableType stringList = ResolvableType.forField(AssignmentBase.class.getField("lists"), Assignment.class); @@ -1048,7 +1048,7 @@ public class ResolvableTypeTests { } @Test - public void isAssignableFromForSameClassExtendsGenerics() throws Exception { + void isAssignableFromForSameClassExtendsGenerics() throws Exception { // Generic assignment can be a little confusing, given: // @@ -1082,7 +1082,7 @@ public class ResolvableTypeTests { } @Test - public void isAssignableFromForDifferentClassesWithGenerics() throws Exception { + void isAssignableFromForDifferentClassesWithGenerics() throws Exception { ResolvableType extendsCharSequenceCollection = ResolvableType.forField(AssignmentBase.class.getField("collectionxc"), Assignment.class); ResolvableType charSequenceCollection = ResolvableType.forField(AssignmentBase.class.getField("collectionc"), Assignment.class); ResolvableType charSequenceList = ResolvableType.forField(AssignmentBase.class.getField("listc"), Assignment.class); @@ -1097,7 +1097,7 @@ public class ResolvableTypeTests { } @Test - public void isAssignableFromForArrays() throws Exception { + void isAssignableFromForArrays() throws Exception { ResolvableType object = ResolvableType.forField(AssignmentBase.class.getField("o"), Assignment.class); ResolvableType objectArray = ResolvableType.forField(AssignmentBase.class.getField("oarray"), Assignment.class); ResolvableType charSequenceArray = ResolvableType.forField(AssignmentBase.class.getField("carray"), Assignment.class); @@ -1110,7 +1110,7 @@ public class ResolvableTypeTests { } @Test - public void isAssignableFromForWildcards() throws Exception { + void isAssignableFromForWildcards() throws Exception { ResolvableType object = ResolvableType.forClass(Object.class); ResolvableType charSequence = ResolvableType.forClass(CharSequence.class); ResolvableType string = ResolvableType.forClass(String.class); @@ -1150,7 +1150,7 @@ public class ResolvableTypeTests { } @Test - public void isAssignableFromForComplexWildcards() throws Exception { + void isAssignableFromForComplexWildcards() throws Exception { ResolvableType complex1 = ResolvableType.forField(AssignmentBase.class.getField("complexWildcard1")); ResolvableType complex2 = ResolvableType.forField(AssignmentBase.class.getField("complexWildcard2")); ResolvableType complex3 = ResolvableType.forField(AssignmentBase.class.getField("complexWildcard3")); @@ -1163,7 +1163,7 @@ public class ResolvableTypeTests { } @Test - public void hashCodeAndEquals() throws Exception { + void hashCodeAndEquals() throws Exception { ResolvableType forClass = ResolvableType.forClass(List.class); ResolvableType forFieldDirect = ResolvableType.forField(Fields.class.getDeclaredField("stringList")); ResolvableType forFieldViaType = ResolvableType.forType(Fields.class.getDeclaredField("stringList").getGenericType(), (VariableResolver) null); @@ -1180,7 +1180,7 @@ public class ResolvableTypeTests { } @Test - public void javaDocSample() throws Exception { + void javaDocSample() throws Exception { ResolvableType t = ResolvableType.forField(getClass().getDeclaredField("myMap")); assertThat(t.toString()).isEqualTo("java.util.HashMap>"); assertThat(t.getType().getTypeName()).isEqualTo("java.util.HashMap>"); @@ -1194,7 +1194,7 @@ public class ResolvableTypeTests { } @Test - public void forClassWithGenerics() throws Exception { + void forClassWithGenerics() throws Exception { ResolvableType elementType = ResolvableType.forClassWithGenerics(Map.class, Integer.class, String.class); ResolvableType listType = ResolvableType.forClassWithGenerics(List.class, elementType); assertThat(listType.toString()).isEqualTo("java.util.List>"); @@ -1203,20 +1203,20 @@ public class ResolvableTypeTests { } @Test - public void classWithGenericsAs() throws Exception { + void classWithGenericsAs() throws Exception { ResolvableType type = ResolvableType.forClassWithGenerics(MultiValueMap.class, Integer.class, String.class); assertThat(type.asMap().toString()).isEqualTo("java.util.Map>"); } @Test - public void forClassWithMismatchedGenerics() throws Exception { + void forClassWithMismatchedGenerics() throws Exception { assertThatIllegalArgumentException().isThrownBy(() -> ResolvableType.forClassWithGenerics(Map.class, Integer.class)) .withMessageContaining("Mismatched number of generics specified"); } @Test - public void forArrayComponent() throws Exception { + void forArrayComponent() throws Exception { ResolvableType elementType = ResolvableType.forField(Fields.class.getField("stringList")); ResolvableType type = ResolvableType.forArrayComponent(elementType); assertThat(type.toString()).isEqualTo("java.util.List[]"); @@ -1224,7 +1224,7 @@ public class ResolvableTypeTests { } @Test - public void serialize() throws Exception { + void serialize() throws Exception { testSerialization(ResolvableType.forClass(List.class)); testSerialization(ResolvableType.forField(Fields.class.getField("charSequenceList"))); testSerialization(ResolvableType.forMethodParameter(Methods.class.getMethod("charSequenceParameter", List.class), 0)); @@ -1236,38 +1236,38 @@ public class ResolvableTypeTests { } @Test - public void canResolveVoid() throws Exception { + void canResolveVoid() throws Exception { ResolvableType type = ResolvableType.forClass(void.class); assertThat(type.resolve()).isEqualTo(void.class); } @Test - public void narrow() throws Exception { + void narrow() throws Exception { ResolvableType type = ResolvableType.forField(Fields.class.getField("stringList")); ResolvableType narrow = ResolvableType.forType(ArrayList.class, type); assertThat(narrow.getGeneric().resolve()).isEqualTo(String.class); } @Test - public void hasUnresolvableGenerics() throws Exception { + void hasUnresolvableGenerics() throws Exception { ResolvableType type = ResolvableType.forField(Fields.class.getField("stringList")); assertThat(type.hasUnresolvableGenerics()).isEqualTo(false); } @Test - public void hasUnresolvableGenericsBasedOnOwnGenerics() throws Exception { + void hasUnresolvableGenericsBasedOnOwnGenerics() throws Exception { ResolvableType type = ResolvableType.forClass(List.class); assertThat(type.hasUnresolvableGenerics()).isEqualTo(true); } @Test - public void hasUnresolvableGenericsWhenSelfNotResolvable() throws Exception { + void hasUnresolvableGenericsWhenSelfNotResolvable() throws Exception { ResolvableType type = ResolvableType.forClass(List.class).getGeneric(); assertThat(type.hasUnresolvableGenerics()).isEqualTo(false); } @Test - public void hasUnresolvableGenericsWhenImplementesRawInterface() throws Exception { + void hasUnresolvableGenericsWhenImplementesRawInterface() throws Exception { ResolvableType type = ResolvableType.forClass(MySimpleInterfaceTypeWithImplementsRaw.class); for (ResolvableType generic : type.getGenerics()) { assertThat(generic.resolve()).isNotNull(); @@ -1276,7 +1276,7 @@ public class ResolvableTypeTests { } @Test - public void hasUnresolvableGenericsWhenExtends() throws Exception { + void hasUnresolvableGenericsWhenExtends() throws Exception { ResolvableType type = ResolvableType.forClass(ExtendsMySimpleInterfaceTypeWithImplementsRaw.class); for (ResolvableType generic : type.getGenerics()) { assertThat(generic.resolve()).isNotNull(); @@ -1285,14 +1285,14 @@ public class ResolvableTypeTests { } @Test - public void testSpr11219() throws Exception { + void spr11219() throws Exception { ResolvableType type = ResolvableType.forField(BaseProvider.class.getField("stuff"), BaseProvider.class); assertThat(type.getNested(2).isAssignableFrom(ResolvableType.forClass(BaseImplementation.class))).isTrue(); assertThat(type.toString()).isEqualTo("java.util.Collection>"); } @Test - public void testSpr12701() throws Exception { + void spr12701() throws Exception { ResolvableType resolvableType = ResolvableType.forClassWithGenerics(Callable.class, String.class); Type type = resolvableType.getType(); assertThat(type).isInstanceOf(ParameterizedType.class); @@ -1302,7 +1302,7 @@ public class ResolvableTypeTests { } @Test - public void testSpr14648() throws Exception { + void spr14648() throws Exception { ResolvableType collectionClass = ResolvableType.forRawClass(Collection.class); ResolvableType setClass = ResolvableType.forRawClass(Set.class); ResolvableType fromReturnType = ResolvableType.forMethodReturnType(Methods.class.getMethod("wildcardSet")); @@ -1311,7 +1311,7 @@ public class ResolvableTypeTests { } @Test - public void testSpr16456() throws Exception { + void spr16456() throws Exception { ResolvableType genericType = ResolvableType.forField( UnresolvedWithGenerics.class.getDeclaredField("set")).asCollection(); ResolvableType type = ResolvableType.forClassWithGenerics(ArrayList.class, genericType.getGeneric()); diff --git a/spring-core/src/test/java/org/springframework/core/SerializableTypeWrapperTests.java b/spring-core/src/test/java/org/springframework/core/SerializableTypeWrapperTests.java index 8e0418c659..8cd70d0cbd 100644 --- a/spring-core/src/test/java/org/springframework/core/SerializableTypeWrapperTests.java +++ b/spring-core/src/test/java/org/springframework/core/SerializableTypeWrapperTests.java @@ -38,17 +38,17 @@ import static org.assertj.core.api.Assertions.assertThat; * * @author Phillip Webb */ -public class SerializableTypeWrapperTests { +class SerializableTypeWrapperTests { @Test - public void forField() throws Exception { + void forField() throws Exception { Type type = SerializableTypeWrapper.forField(Fields.class.getField("parameterizedType")); assertThat(type.toString()).isEqualTo("java.util.List"); assertSerializable(type); } @Test - public void forMethodParameter() throws Exception { + void forMethodParameter() throws Exception { Method method = Methods.class.getDeclaredMethod("method", Class.class, Object.class); Type type = SerializableTypeWrapper.forMethodParameter(MethodParameter.forExecutable(method, 0)); assertThat(type.toString()).isEqualTo("java.lang.Class"); @@ -56,7 +56,7 @@ public class SerializableTypeWrapperTests { } @Test - public void forConstructor() throws Exception { + void forConstructor() throws Exception { Constructor constructor = Constructors.class.getDeclaredConstructor(List.class); Type type = SerializableTypeWrapper.forMethodParameter(MethodParameter.forExecutable(constructor, 0)); assertThat(type.toString()).isEqualTo("java.util.List"); @@ -64,14 +64,14 @@ public class SerializableTypeWrapperTests { } @Test - public void classType() throws Exception { + void classType() throws Exception { Type type = SerializableTypeWrapper.forField(Fields.class.getField("classType")); assertThat(type.toString()).isEqualTo("class java.lang.String"); assertSerializable(type); } @Test - public void genericArrayType() throws Exception { + void genericArrayType() throws Exception { GenericArrayType type = (GenericArrayType) SerializableTypeWrapper.forField(Fields.class.getField("genericArrayType")); assertThat(type.toString()).isEqualTo("java.util.List[]"); assertSerializable(type); @@ -79,7 +79,7 @@ public class SerializableTypeWrapperTests { } @Test - public void parameterizedType() throws Exception { + void parameterizedType() throws Exception { ParameterizedType type = (ParameterizedType) SerializableTypeWrapper.forField(Fields.class.getField("parameterizedType")); assertThat(type.toString()).isEqualTo("java.util.List"); assertSerializable(type); @@ -90,7 +90,7 @@ public class SerializableTypeWrapperTests { } @Test - public void typeVariableType() throws Exception { + void typeVariableType() throws Exception { TypeVariable type = (TypeVariable) SerializableTypeWrapper.forField(Fields.class.getField("typeVariableType")); assertThat(type.toString()).isEqualTo("T"); assertSerializable(type); @@ -98,7 +98,7 @@ public class SerializableTypeWrapperTests { } @Test - public void wildcardType() throws Exception { + void wildcardType() throws Exception { ParameterizedType typeSource = (ParameterizedType) SerializableTypeWrapper.forField(Fields.class.getField("wildcardType")); WildcardType type = (WildcardType) typeSource.getActualTypeArguments()[0]; assertThat(type.toString()).isEqualTo("? extends java.lang.CharSequence"); diff --git a/spring-core/src/test/java/org/springframework/core/SimpleAliasRegistryTests.java b/spring-core/src/test/java/org/springframework/core/SimpleAliasRegistryTests.java index f3ac030470..802b705c98 100644 --- a/spring-core/src/test/java/org/springframework/core/SimpleAliasRegistryTests.java +++ b/spring-core/src/test/java/org/springframework/core/SimpleAliasRegistryTests.java @@ -23,10 +23,10 @@ import static org.assertj.core.api.Assertions.assertThat; /** * @author Juergen Hoeller */ -public class SimpleAliasRegistryTests { +class SimpleAliasRegistryTests { @Test - public void testAliasChaining() { + void aliasChaining() { SimpleAliasRegistry registry = new SimpleAliasRegistry(); registry.registerAlias("test", "testAlias"); registry.registerAlias("testAlias", "testAlias2"); @@ -41,7 +41,7 @@ public class SimpleAliasRegistryTests { } @Test // SPR-17191 - public void testAliasChainingWithMultipleAliases() { + void testAliasChainingWithMultipleAliases() { SimpleAliasRegistry registry = new SimpleAliasRegistry(); registry.registerAlias("name", "alias_a"); registry.registerAlias("name", "alias_b"); diff --git a/spring-core/src/test/java/org/springframework/core/SortedPropertiesTests.java b/spring-core/src/test/java/org/springframework/core/SortedPropertiesTests.java index 72825f9c30..491be2a659 100644 --- a/spring-core/src/test/java/org/springframework/core/SortedPropertiesTests.java +++ b/spring-core/src/test/java/org/springframework/core/SortedPropertiesTests.java @@ -35,40 +35,40 @@ import static org.assertj.core.api.Assertions.entry; * @author Sam Brannen * @since 5.2 */ -public class SortedPropertiesTests { +class SortedPropertiesTests { @Test - public void keys() { + void keys() { assertKeys(createSortedProps()); } @Test - public void keysFromPrototype() { + void keysFromPrototype() { assertKeys(createSortedPropsFromPrototype()); } @Test - public void keySet() { + void keySet() { assertKeySet(createSortedProps()); } @Test - public void keySetFromPrototype() { + void keySetFromPrototype() { assertKeySet(createSortedPropsFromPrototype()); } @Test - public void entrySet() { + void entrySet() { assertEntrySet(createSortedProps()); } @Test - public void entrySetFromPrototype() { + void entrySetFromPrototype() { assertEntrySet(createSortedPropsFromPrototype()); } @Test - public void sortsPropertiesUsingOutputStream() throws IOException { + void sortsPropertiesUsingOutputStream() throws IOException { SortedProperties sortedProperties = createSortedProps(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); @@ -83,7 +83,7 @@ public class SortedPropertiesTests { } @Test - public void sortsPropertiesUsingWriter() throws IOException { + void sortsPropertiesUsingWriter() throws IOException { SortedProperties sortedProperties = createSortedProps(); StringWriter writer = new StringWriter(); @@ -98,7 +98,7 @@ public class SortedPropertiesTests { } @Test - public void sortsPropertiesAndOmitsCommentsUsingOutputStream() throws IOException { + void sortsPropertiesAndOmitsCommentsUsingOutputStream() throws IOException { SortedProperties sortedProperties = createSortedProps(true); ByteArrayOutputStream baos = new ByteArrayOutputStream(); @@ -111,7 +111,7 @@ public class SortedPropertiesTests { } @Test - public void sortsPropertiesAndOmitsCommentsUsingWriter() throws IOException { + void sortsPropertiesAndOmitsCommentsUsingWriter() throws IOException { SortedProperties sortedProperties = createSortedProps(true); StringWriter writer = new StringWriter(); @@ -124,7 +124,7 @@ public class SortedPropertiesTests { } @Test - public void storingAsXmlSortsPropertiesAndOmitsComments() throws IOException { + void storingAsXmlSortsPropertiesAndOmitsComments() throws IOException { SortedProperties sortedProperties = createSortedProps(true); ByteArrayOutputStream baos = new ByteArrayOutputStream(); diff --git a/spring-core/src/test/java/org/springframework/core/StandardReflectionParameterNameDiscoverTests.java b/spring-core/src/test/java/org/springframework/core/StandardReflectionParameterNameDiscoverTests.java index 0bd71711a2..8f51f220f2 100644 --- a/spring-core/src/test/java/org/springframework/core/StandardReflectionParameterNameDiscoverTests.java +++ b/spring-core/src/test/java/org/springframework/core/StandardReflectionParameterNameDiscoverTests.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.core; import java.lang.reflect.Method; @@ -24,22 +25,22 @@ import org.springframework.util.ReflectionUtils; import static org.assertj.core.api.Assertions.assertThat; - /** * Tests for StandardReflectionParameterNameDiscoverer * * @author Rob Winch */ -public class StandardReflectionParameterNameDiscoverTests { +class StandardReflectionParameterNameDiscoverTests { + private ParameterNameDiscoverer parameterNameDiscoverer; @BeforeEach - public void setup() { + void setup() { parameterNameDiscoverer = new StandardReflectionParameterNameDiscoverer(); } @Test - public void getParameterNamesOnInterface() { + void getParameterNamesOnInterface() { Method method = ReflectionUtils.findMethod(MessageService.class,"sendMessage", String.class); String[] actualParams = parameterNameDiscoverer.getParameterNames(method); assertThat(actualParams).isEqualTo(new String[]{"message"}); @@ -48,4 +49,5 @@ public class StandardReflectionParameterNameDiscoverTests { public interface MessageService { void sendMessage(String message); } + } diff --git a/spring-core/src/test/java/org/springframework/core/annotation/AnnotatedElementUtilsTests.java b/spring-core/src/test/java/org/springframework/core/annotation/AnnotatedElementUtilsTests.java index 89954c2b15..694ef30712 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/AnnotatedElementUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/AnnotatedElementUtilsTests.java @@ -76,19 +76,19 @@ import static org.springframework.core.annotation.AnnotationUtilsTests.asArray; * @see MultipleComposedAnnotationsOnSingleAnnotatedElementTests * @see ComposedRepeatableAnnotationsTests */ -public class AnnotatedElementUtilsTests { +class AnnotatedElementUtilsTests { private static final String TX_NAME = Transactional.class.getName(); @Test - public void getMetaAnnotationTypesOnNonAnnotatedClass() { + void getMetaAnnotationTypesOnNonAnnotatedClass() { assertThat(getMetaAnnotationTypes(NonAnnotatedClass.class, TransactionalComponent.class).isEmpty()).isTrue(); assertThat(getMetaAnnotationTypes(NonAnnotatedClass.class, TransactionalComponent.class.getName()).isEmpty()).isTrue(); } @Test - public void getMetaAnnotationTypesOnClassWithMetaDepth1() { + void getMetaAnnotationTypesOnClassWithMetaDepth1() { Set names = getMetaAnnotationTypes(TransactionalComponentClass.class, TransactionalComponent.class); assertThat(names).isEqualTo(names(Transactional.class, Component.class, Indexed.class)); @@ -97,7 +97,7 @@ public class AnnotatedElementUtilsTests { } @Test - public void getMetaAnnotationTypesOnClassWithMetaDepth2() { + void getMetaAnnotationTypesOnClassWithMetaDepth2() { Set names = getMetaAnnotationTypes(ComposedTransactionalComponentClass.class, ComposedTransactionalComponent.class); assertThat(names).isEqualTo(names(TransactionalComponent.class, Transactional.class, Component.class, Indexed.class)); @@ -110,35 +110,35 @@ public class AnnotatedElementUtilsTests { } @Test - public void hasMetaAnnotationTypesOnNonAnnotatedClass() { + void hasMetaAnnotationTypesOnNonAnnotatedClass() { assertThat(hasMetaAnnotationTypes(NonAnnotatedClass.class, TX_NAME)).isFalse(); } @Test - public void hasMetaAnnotationTypesOnClassWithMetaDepth0() { + void hasMetaAnnotationTypesOnClassWithMetaDepth0() { assertThat(hasMetaAnnotationTypes(TransactionalComponentClass.class, TransactionalComponent.class.getName())).isFalse(); } @Test - public void hasMetaAnnotationTypesOnClassWithMetaDepth1() { + void hasMetaAnnotationTypesOnClassWithMetaDepth1() { assertThat(hasMetaAnnotationTypes(TransactionalComponentClass.class, TX_NAME)).isTrue(); assertThat(hasMetaAnnotationTypes(TransactionalComponentClass.class, Component.class.getName())).isTrue(); } @Test - public void hasMetaAnnotationTypesOnClassWithMetaDepth2() { + void hasMetaAnnotationTypesOnClassWithMetaDepth2() { assertThat(hasMetaAnnotationTypes(ComposedTransactionalComponentClass.class, TX_NAME)).isTrue(); assertThat(hasMetaAnnotationTypes(ComposedTransactionalComponentClass.class, Component.class.getName())).isTrue(); assertThat(hasMetaAnnotationTypes(ComposedTransactionalComponentClass.class, ComposedTransactionalComponent.class.getName())).isFalse(); } @Test - public void isAnnotatedOnNonAnnotatedClass() { + void isAnnotatedOnNonAnnotatedClass() { assertThat(isAnnotated(NonAnnotatedClass.class, Transactional.class)).isFalse(); } @Test - public void isAnnotatedOnClassWithMetaDepth() { + void isAnnotatedOnClassWithMetaDepth() { assertThat(isAnnotated(TransactionalComponentClass.class, TransactionalComponent.class)).isTrue(); assertThat(isAnnotated(SubTransactionalComponentClass.class, TransactionalComponent.class)).as("isAnnotated() does not search the class hierarchy.").isFalse(); assertThat(isAnnotated(TransactionalComponentClass.class, Transactional.class)).isTrue(); @@ -149,7 +149,7 @@ public class AnnotatedElementUtilsTests { } @Test - public void isAnnotatedForPlainTypes() { + void isAnnotatedForPlainTypes() { assertThat(isAnnotated(Order.class, Documented.class)).isTrue(); assertThat(isAnnotated(NonNullApi.class, Documented.class)).isTrue(); assertThat(isAnnotated(NonNullApi.class, Nonnull.class)).isTrue(); @@ -157,12 +157,12 @@ public class AnnotatedElementUtilsTests { } @Test - public void isAnnotatedWithNameOnNonAnnotatedClass() { + void isAnnotatedWithNameOnNonAnnotatedClass() { assertThat(isAnnotated(NonAnnotatedClass.class, TX_NAME)).isFalse(); } @Test - public void isAnnotatedWithNameOnClassWithMetaDepth() { + void isAnnotatedWithNameOnClassWithMetaDepth() { assertThat(isAnnotated(TransactionalComponentClass.class, TransactionalComponent.class.getName())).isTrue(); assertThat(isAnnotated(SubTransactionalComponentClass.class, TransactionalComponent.class.getName())).as("isAnnotated() does not search the class hierarchy.").isFalse(); assertThat(isAnnotated(TransactionalComponentClass.class, TX_NAME)).isTrue(); @@ -173,12 +173,12 @@ public class AnnotatedElementUtilsTests { } @Test - public void hasAnnotationOnNonAnnotatedClass() { + void hasAnnotationOnNonAnnotatedClass() { assertThat(hasAnnotation(NonAnnotatedClass.class, Transactional.class)).isFalse(); } @Test - public void hasAnnotationOnClassWithMetaDepth() { + void hasAnnotationOnClassWithMetaDepth() { assertThat(hasAnnotation(TransactionalComponentClass.class, TransactionalComponent.class)).isTrue(); assertThat(hasAnnotation(SubTransactionalComponentClass.class, TransactionalComponent.class)).isTrue(); assertThat(hasAnnotation(TransactionalComponentClass.class, Transactional.class)).isTrue(); @@ -189,7 +189,7 @@ public class AnnotatedElementUtilsTests { } @Test - public void hasAnnotationForPlainTypes() { + void hasAnnotationForPlainTypes() { assertThat(hasAnnotation(Order.class, Documented.class)).isTrue(); assertThat(hasAnnotation(NonNullApi.class, Documented.class)).isTrue(); assertThat(hasAnnotation(NonNullApi.class, Nonnull.class)).isTrue(); @@ -197,33 +197,33 @@ public class AnnotatedElementUtilsTests { } @Test - public void getAllAnnotationAttributesOnNonAnnotatedClass() { + void getAllAnnotationAttributesOnNonAnnotatedClass() { assertThat(getAllAnnotationAttributes(NonAnnotatedClass.class, TX_NAME)).isNull(); } @Test - public void getAllAnnotationAttributesOnClassWithLocalAnnotation() { + void getAllAnnotationAttributesOnClassWithLocalAnnotation() { MultiValueMap 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")); } @Test - public void getAllAnnotationAttributesOnClassWithLocalComposedAnnotationAndInheritedAnnotation() { + void getAllAnnotationAttributesOnClassWithLocalComposedAnnotationAndInheritedAnnotation() { MultiValueMap attributes = getAllAnnotationAttributes(SubClassWithInheritedAnnotation.class, TX_NAME); assertThat(attributes).as("Annotation attributes map for @Transactional on SubClassWithInheritedAnnotation").isNotNull(); assertThat(attributes.get("qualifier")).isEqualTo(asList("composed2", "transactionManager")); } @Test - public void getAllAnnotationAttributesFavorsInheritedAnnotationsOverMoreLocallyDeclaredComposedAnnotations() { + void getAllAnnotationAttributesFavorsInheritedAnnotationsOverMoreLocallyDeclaredComposedAnnotations() { MultiValueMap attributes = getAllAnnotationAttributes(SubSubClassWithInheritedAnnotation.class, TX_NAME); assertThat(attributes).as("Annotation attributes map for @Transactional on SubSubClassWithInheritedAnnotation").isNotNull(); assertThat(attributes.get("qualifier")).isEqualTo(asList("transactionManager")); } @Test - public void getAllAnnotationAttributesFavorsInheritedComposedAnnotationsOverMoreLocallyDeclaredComposedAnnotations() { + void getAllAnnotationAttributesFavorsInheritedComposedAnnotationsOverMoreLocallyDeclaredComposedAnnotations() { MultiValueMap attributes = getAllAnnotationAttributes( SubSubClassWithInheritedComposedAnnotation.class, TX_NAME); assertThat(attributes).as("Annotation attributes map for @Transactional on SubSubClassWithInheritedComposedAnnotation").isNotNull(); assertThat(attributes.get("qualifier")).isEqualTo(asList("composed1")); @@ -237,7 +237,7 @@ public class AnnotatedElementUtilsTests { * to fail. */ @Test - public void getAllAnnotationAttributesOnClassWithLocalAnnotationThatShadowsAnnotationFromSuperclass() { + void getAllAnnotationAttributesOnClassWithLocalAnnotationThatShadowsAnnotationFromSuperclass() { // See org.springframework.core.env.EnvironmentSystemIntegrationTests#mostSpecificDerivedClassDrivesEnvironment_withDevEnvAndDerivedDevConfigClass MultiValueMap attributes = getAllAnnotationAttributes(DerivedTxConfig.class, TX_NAME); assertThat(attributes).as("Annotation attributes map for @Transactional on DerivedTxConfig").isNotNull(); @@ -248,7 +248,7 @@ public class AnnotatedElementUtilsTests { * Note: this functionality is required by {@code org.springframework.context.annotation.ProfileCondition}. */ @Test - public void getAllAnnotationAttributesOnClassWithMultipleComposedAnnotations() { + void getAllAnnotationAttributesOnClassWithMultipleComposedAnnotations() { // See org.springframework.core.env.EnvironmentSystemIntegrationTests MultiValueMap attributes = getAllAnnotationAttributes(TxFromMultipleComposedAnnotations.class, TX_NAME); assertThat(attributes).as("Annotation attributes map for @Transactional on TxFromMultipleComposedAnnotations").isNotNull(); @@ -256,7 +256,7 @@ public class AnnotatedElementUtilsTests { } @Test - public void getAllAnnotationAttributesOnLangType() { + void getAllAnnotationAttributesOnLangType() { MultiValueMap attributes = getAllAnnotationAttributes( NonNullApi.class, Nonnull.class.getName()); assertThat(attributes).as("Annotation attributes map for @Nonnull on NonNullApi").isNotNull(); @@ -264,7 +264,7 @@ public class AnnotatedElementUtilsTests { } @Test - public void getAllAnnotationAttributesOnJavaxType() { + void getAllAnnotationAttributesOnJavaxType() { MultiValueMap attributes = getAllAnnotationAttributes( ParametersAreNonnullByDefault.class, Nonnull.class.getName()); assertThat(attributes).as("Annotation attributes map for @Nonnull on NonNullApi").isNotNull(); @@ -272,7 +272,7 @@ public class AnnotatedElementUtilsTests { } @Test - public void getMergedAnnotationAttributesOnClassWithLocalAnnotation() { + void getMergedAnnotationAttributesOnClassWithLocalAnnotation() { Class element = TxConfig.class; String name = TX_NAME; AnnotationAttributes attributes = getMergedAnnotationAttributes(element, name); @@ -283,7 +283,7 @@ public class AnnotatedElementUtilsTests { } @Test - public void getMergedAnnotationAttributesOnClassWithLocalAnnotationThatShadowsAnnotationFromSuperclass() { + void getMergedAnnotationAttributesOnClassWithLocalAnnotationThatShadowsAnnotationFromSuperclass() { Class element = DerivedTxConfig.class; String name = TX_NAME; AnnotationAttributes attributes = getMergedAnnotationAttributes(element, name); @@ -294,13 +294,13 @@ public class AnnotatedElementUtilsTests { } @Test - public void getMergedAnnotationAttributesOnMetaCycleAnnotatedClassWithMissingTargetMetaAnnotation() { + void getMergedAnnotationAttributesOnMetaCycleAnnotatedClassWithMissingTargetMetaAnnotation() { AnnotationAttributes attributes = getMergedAnnotationAttributes(MetaCycleAnnotatedClass.class, TX_NAME); assertThat(attributes).as("Should not find annotation attributes for @Transactional on MetaCycleAnnotatedClass").isNull(); } @Test - public void getMergedAnnotationAttributesFavorsLocalComposedAnnotationOverInheritedAnnotation() { + void getMergedAnnotationAttributesFavorsLocalComposedAnnotationOverInheritedAnnotation() { Class element = SubClassWithInheritedAnnotation.class; String name = TX_NAME; AnnotationAttributes attributes = getMergedAnnotationAttributes(element, name); @@ -311,7 +311,7 @@ public class AnnotatedElementUtilsTests { } @Test - public void getMergedAnnotationAttributesFavorsInheritedAnnotationsOverMoreLocallyDeclaredComposedAnnotations() { + void getMergedAnnotationAttributesFavorsInheritedAnnotationsOverMoreLocallyDeclaredComposedAnnotations() { Class element = SubSubClassWithInheritedAnnotation.class; String name = TX_NAME; AnnotationAttributes attributes = getMergedAnnotationAttributes(element, name); @@ -322,7 +322,7 @@ public class AnnotatedElementUtilsTests { } @Test - public void getMergedAnnotationAttributesFavorsInheritedComposedAnnotationsOverMoreLocallyDeclaredComposedAnnotations() { + void getMergedAnnotationAttributesFavorsInheritedComposedAnnotationsOverMoreLocallyDeclaredComposedAnnotations() { Class element = SubSubClassWithInheritedComposedAnnotation.class; String name = TX_NAME; AnnotationAttributes attributes = getMergedAnnotationAttributes(element, name); @@ -333,7 +333,7 @@ public class AnnotatedElementUtilsTests { } @Test - public void getMergedAnnotationAttributesFromInterfaceImplementedBySuperclass() { + void getMergedAnnotationAttributesFromInterfaceImplementedBySuperclass() { Class element = ConcreteClassWithInheritedAnnotation.class; String name = TX_NAME; AnnotationAttributes attributes = getMergedAnnotationAttributes(element, name); @@ -343,7 +343,7 @@ public class AnnotatedElementUtilsTests { } @Test - public void getMergedAnnotationAttributesOnInheritedAnnotationInterface() { + void getMergedAnnotationAttributesOnInheritedAnnotationInterface() { Class element = InheritedAnnotationInterface.class; String name = TX_NAME; AnnotationAttributes attributes = getMergedAnnotationAttributes(element, name); @@ -353,7 +353,7 @@ public class AnnotatedElementUtilsTests { } @Test - public void getMergedAnnotationAttributesOnNonInheritedAnnotationInterface() { + void getMergedAnnotationAttributesOnNonInheritedAnnotationInterface() { Class element = NonInheritedAnnotationInterface.class; String name = Order.class.getName(); AnnotationAttributes attributes = getMergedAnnotationAttributes(element, name); @@ -363,7 +363,7 @@ public class AnnotatedElementUtilsTests { } @Test - public void getMergedAnnotationAttributesWithConventionBasedComposedAnnotation() { + void getMergedAnnotationAttributesWithConventionBasedComposedAnnotation() { Class element = ConventionBasedComposedContextConfigClass.class; String name = ContextConfig.class.getName(); AnnotationAttributes attributes = getMergedAnnotationAttributes(element, name); @@ -386,7 +386,7 @@ public class AnnotatedElementUtilsTests { */ @Disabled("Permanently disabled but left in place for illustrative purposes") @Test - public void getMergedAnnotationAttributesWithHalfConventionBasedAndHalfAliasedComposedAnnotation() { + void getMergedAnnotationAttributesWithHalfConventionBasedAndHalfAliasedComposedAnnotation() { for (Class clazz : asList(HalfConventionBasedAndHalfAliasedComposedContextConfigClassV1.class, HalfConventionBasedAndHalfAliasedComposedContextConfigClassV2.class)) { getMergedAnnotationAttributesWithHalfConventionBasedAndHalfAliasedComposedAnnotation(clazz); @@ -408,7 +408,7 @@ public class AnnotatedElementUtilsTests { } @Test - public void getMergedAnnotationAttributesWithAliasedComposedAnnotation() { + void getMergedAnnotationAttributesWithAliasedComposedAnnotation() { Class element = AliasedComposedContextConfigClass.class; String name = ContextConfig.class.getName(); AnnotationAttributes attributes = getMergedAnnotationAttributes(element, name); @@ -422,7 +422,7 @@ public class AnnotatedElementUtilsTests { } @Test - public void getMergedAnnotationAttributesWithAliasedValueComposedAnnotation() { + void getMergedAnnotationAttributesWithAliasedValueComposedAnnotation() { Class element = AliasedValueComposedContextConfigClass.class; String name = ContextConfig.class.getName(); AnnotationAttributes attributes = getMergedAnnotationAttributes(element, name); @@ -436,7 +436,7 @@ public class AnnotatedElementUtilsTests { } @Test - public void getMergedAnnotationAttributesWithImplicitAliasesInMetaAnnotationOnComposedAnnotation() { + void getMergedAnnotationAttributesWithImplicitAliasesInMetaAnnotationOnComposedAnnotation() { Class element = ComposedImplicitAliasesContextConfigClass.class; String name = ImplicitAliasesContextConfig.class.getName(); AnnotationAttributes attributes = getMergedAnnotationAttributes(element, name); @@ -453,34 +453,34 @@ public class AnnotatedElementUtilsTests { } @Test - public void getMergedAnnotationWithAliasedValueComposedAnnotation() { + void getMergedAnnotationWithAliasedValueComposedAnnotation() { assertGetMergedAnnotation(AliasedValueComposedContextConfigClass.class, "test.xml"); } @Test - public void getMergedAnnotationWithImplicitAliasesForSameAttributeInComposedAnnotation() { + void getMergedAnnotationWithImplicitAliasesForSameAttributeInComposedAnnotation() { assertGetMergedAnnotation(ImplicitAliasesContextConfigClass1.class, "foo.xml"); assertGetMergedAnnotation(ImplicitAliasesContextConfigClass2.class, "bar.xml"); assertGetMergedAnnotation(ImplicitAliasesContextConfigClass3.class, "baz.xml"); } @Test - public void getMergedAnnotationWithTransitiveImplicitAliases() { + void getMergedAnnotationWithTransitiveImplicitAliases() { assertGetMergedAnnotation(TransitiveImplicitAliasesContextConfigClass.class, "test.groovy"); } @Test - public void getMergedAnnotationWithTransitiveImplicitAliasesWithSingleElementOverridingAnArrayViaAliasFor() { + void getMergedAnnotationWithTransitiveImplicitAliasesWithSingleElementOverridingAnArrayViaAliasFor() { assertGetMergedAnnotation(SingleLocationTransitiveImplicitAliasesContextConfigClass.class, "test.groovy"); } @Test - public void getMergedAnnotationWithTransitiveImplicitAliasesWithSkippedLevel() { + void getMergedAnnotationWithTransitiveImplicitAliasesWithSkippedLevel() { assertGetMergedAnnotation(TransitiveImplicitAliasesWithSkippedLevelContextConfigClass.class, "test.xml"); } @Test - public void getMergedAnnotationWithTransitiveImplicitAliasesWithSkippedLevelWithSingleElementOverridingAnArrayViaAliasFor() { + void getMergedAnnotationWithTransitiveImplicitAliasesWithSkippedLevelWithSingleElementOverridingAnArrayViaAliasFor() { assertGetMergedAnnotation(SingleLocationTransitiveImplicitAliasesWithSkippedLevelContextConfigClass.class, "test.xml"); } @@ -499,7 +499,7 @@ public class AnnotatedElementUtilsTests { } @Test - public void getMergedAnnotationWithImplicitAliasesInMetaAnnotationOnComposedAnnotation() { + void getMergedAnnotationWithImplicitAliasesInMetaAnnotationOnComposedAnnotation() { Class element = ComposedImplicitAliasesContextConfigClass.class; String name = ImplicitAliasesContextConfig.class.getName(); ImplicitAliasesContextConfig config = getMergedAnnotation(element, ImplicitAliasesContextConfig.class); @@ -516,7 +516,7 @@ public class AnnotatedElementUtilsTests { } @Test - public void getMergedAnnotationAttributesWithInvalidConventionBasedComposedAnnotation() { + void getMergedAnnotationAttributesWithInvalidConventionBasedComposedAnnotation() { Class element = InvalidConventionBasedComposedContextConfigClass.class; assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> getMergedAnnotationAttributes(element, ContextConfig.class)) @@ -526,7 +526,7 @@ public class AnnotatedElementUtilsTests { } @Test - public void getMergedAnnotationAttributesWithShadowedAliasComposedAnnotation() { + void getMergedAnnotationAttributesWithShadowedAliasComposedAnnotation() { Class element = ShadowedAliasComposedContextConfigClass.class; AnnotationAttributes attributes = getMergedAnnotationAttributes(element, ContextConfig.class); @@ -538,57 +538,57 @@ public class AnnotatedElementUtilsTests { } @Test - public void findMergedAnnotationAttributesOnInheritedAnnotationInterface() { + void findMergedAnnotationAttributesOnInheritedAnnotationInterface() { AnnotationAttributes attributes = findMergedAnnotationAttributes(InheritedAnnotationInterface.class, Transactional.class); assertThat(attributes).as("Should find @Transactional on InheritedAnnotationInterface").isNotNull(); } @Test - public void findMergedAnnotationAttributesOnSubInheritedAnnotationInterface() { + void findMergedAnnotationAttributesOnSubInheritedAnnotationInterface() { AnnotationAttributes attributes = findMergedAnnotationAttributes(SubInheritedAnnotationInterface.class, Transactional.class); assertThat(attributes).as("Should find @Transactional on SubInheritedAnnotationInterface").isNotNull(); } @Test - public void findMergedAnnotationAttributesOnSubSubInheritedAnnotationInterface() { + void findMergedAnnotationAttributesOnSubSubInheritedAnnotationInterface() { AnnotationAttributes attributes = findMergedAnnotationAttributes(SubSubInheritedAnnotationInterface.class, Transactional.class); assertThat(attributes).as("Should find @Transactional on SubSubInheritedAnnotationInterface").isNotNull(); } @Test - public void findMergedAnnotationAttributesOnNonInheritedAnnotationInterface() { + void findMergedAnnotationAttributesOnNonInheritedAnnotationInterface() { AnnotationAttributes attributes = findMergedAnnotationAttributes(NonInheritedAnnotationInterface.class, Order.class); assertThat(attributes).as("Should find @Order on NonInheritedAnnotationInterface").isNotNull(); } @Test - public void findMergedAnnotationAttributesOnSubNonInheritedAnnotationInterface() { + void findMergedAnnotationAttributesOnSubNonInheritedAnnotationInterface() { AnnotationAttributes attributes = findMergedAnnotationAttributes(SubNonInheritedAnnotationInterface.class, Order.class); assertThat(attributes).as("Should find @Order on SubNonInheritedAnnotationInterface").isNotNull(); } @Test - public void findMergedAnnotationAttributesOnSubSubNonInheritedAnnotationInterface() { + void findMergedAnnotationAttributesOnSubSubNonInheritedAnnotationInterface() { AnnotationAttributes attributes = findMergedAnnotationAttributes(SubSubNonInheritedAnnotationInterface.class, Order.class); assertThat(attributes).as("Should find @Order on SubSubNonInheritedAnnotationInterface").isNotNull(); } @Test - public void findMergedAnnotationAttributesInheritedFromInterfaceMethod() throws NoSuchMethodException { + void findMergedAnnotationAttributesInheritedFromInterfaceMethod() throws NoSuchMethodException { Method method = ConcreteClassWithInheritedAnnotation.class.getMethod("handleFromInterface"); AnnotationAttributes attributes = findMergedAnnotationAttributes(method, Order.class); assertThat(attributes).as("Should find @Order on ConcreteClassWithInheritedAnnotation.handleFromInterface() method").isNotNull(); } @Test - public void findMergedAnnotationAttributesInheritedFromAbstractMethod() throws NoSuchMethodException { + void findMergedAnnotationAttributesInheritedFromAbstractMethod() throws NoSuchMethodException { Method method = ConcreteClassWithInheritedAnnotation.class.getMethod("handle"); AnnotationAttributes attributes = findMergedAnnotationAttributes(method, Transactional.class); assertThat(attributes).as("Should find @Transactional on ConcreteClassWithInheritedAnnotation.handle() method").isNotNull(); } @Test - public void findMergedAnnotationAttributesInheritedFromBridgedMethod() throws NoSuchMethodException { + void findMergedAnnotationAttributesInheritedFromBridgedMethod() throws NoSuchMethodException { Method method = ConcreteClassWithInheritedAnnotation.class.getMethod("handleParameterized", String.class); AnnotationAttributes attributes = findMergedAnnotationAttributes(method, Transactional.class); assertThat(attributes).as("Should find @Transactional on bridged ConcreteClassWithInheritedAnnotation.handleParameterized()").isNotNull(); @@ -600,7 +600,7 @@ public class AnnotatedElementUtilsTests { * @since 4.2 */ @Test - public void findMergedAnnotationAttributesFromBridgeMethod() { + void findMergedAnnotationAttributesFromBridgeMethod() { Method[] methods = StringGenericParameter.class.getMethods(); Method bridgeMethod = null; Method bridgedMethod = null; @@ -624,14 +624,14 @@ public class AnnotatedElementUtilsTests { } @Test - public void findMergedAnnotationAttributesOnClassWithMetaAndLocalTxConfig() { + void findMergedAnnotationAttributesOnClassWithMetaAndLocalTxConfig() { AnnotationAttributes attributes = findMergedAnnotationAttributes(MetaAndLocalTxConfigClass.class, Transactional.class); assertThat(attributes).as("Should find @Transactional on MetaAndLocalTxConfigClass").isNotNull(); assertThat(attributes.getString("qualifier")).as("TX qualifier for MetaAndLocalTxConfigClass.").isEqualTo("localTxMgr"); } @Test - public void findAndSynthesizeAnnotationAttributesOnClassWithAttributeAliasesInTargetAnnotation() { + void findAndSynthesizeAnnotationAttributesOnClassWithAttributeAliasesInTargetAnnotation() { String qualifier = "aliasForQualifier"; // 1) Find and merge AnnotationAttributes from the annotation hierarchy @@ -652,7 +652,7 @@ public class AnnotatedElementUtilsTests { } @Test - public void findMergedAnnotationAttributesOnClassWithAttributeAliasInComposedAnnotationAndNestedAnnotationsInTargetAnnotation() { + void findMergedAnnotationAttributesOnClassWithAttributeAliasInComposedAnnotationAndNestedAnnotationsInTargetAnnotation() { AnnotationAttributes attributes = assertComponentScanAttributes(TestComponentScanClass.class, "com.example.app.test"); Filter[] excludeFilters = attributes.getAnnotationArray("excludeFilters", Filter.class); @@ -668,17 +668,17 @@ public class AnnotatedElementUtilsTests { * attributes since attributes may be arrays. */ @Test - public void findMergedAnnotationAttributesOnClassWithBothAttributesOfAnAliasPairDeclared() { + void findMergedAnnotationAttributesOnClassWithBothAttributesOfAnAliasPairDeclared() { assertComponentScanAttributes(ComponentScanWithBasePackagesAndValueAliasClass.class, "com.example.app.test"); } @Test - public void findMergedAnnotationAttributesWithSingleElementOverridingAnArrayViaConvention() { + void findMergedAnnotationAttributesWithSingleElementOverridingAnArrayViaConvention() { assertComponentScanAttributes(ConventionBasedSinglePackageComponentScanClass.class, "com.example.app.test"); } @Test - public void findMergedAnnotationAttributesWithSingleElementOverridingAnArrayViaAliasFor() { + void findMergedAnnotationAttributesWithSingleElementOverridingAnArrayViaAliasFor() { assertComponentScanAttributes(AliasForBasedSinglePackageComponentScanClass.class, "com.example.app.test"); } @@ -697,7 +697,7 @@ public class AnnotatedElementUtilsTests { } @Test - public void findMergedAnnotationWithAttributeAliasesInTargetAnnotation() { + void findMergedAnnotationWithAttributeAliasesInTargetAnnotation() { Class element = AliasedTransactionalComponentClass.class; AliasedTransactional annotation = findMergedAnnotation(element, AliasedTransactional.class); assertThat(annotation).as("@AliasedTransactional on " + element).isNotNull(); @@ -706,7 +706,7 @@ public class AnnotatedElementUtilsTests { } @Test - public void findMergedAnnotationForMultipleMetaAnnotationsWithClashingAttributeNames() { + void findMergedAnnotationForMultipleMetaAnnotationsWithClashingAttributeNames() { String[] xmlLocations = asArray("test.xml"); String[] propFiles = asArray("test.properties"); @@ -730,7 +730,7 @@ public class AnnotatedElementUtilsTests { } @Test - public void findMergedAnnotationWithLocalAliasesThatConflictWithAttributesInMetaAnnotationByConvention() { + void findMergedAnnotationWithLocalAliasesThatConflictWithAttributesInMetaAnnotationByConvention() { final String[] EMPTY = new String[0]; Class element = SpringAppConfigClass.class; ContextConfig contextConfig = findMergedAnnotation(element, ContextConfig.class); @@ -743,12 +743,12 @@ public class AnnotatedElementUtilsTests { } @Test - public void findMergedAnnotationWithSingleElementOverridingAnArrayViaConvention() throws Exception { + void findMergedAnnotationWithSingleElementOverridingAnArrayViaConvention() throws Exception { assertWebMapping(WebController.class.getMethod("postMappedWithPathAttribute")); } @Test - public void findMergedAnnotationWithSingleElementOverridingAnArrayViaAliasFor() throws Exception { + void findMergedAnnotationWithSingleElementOverridingAnArrayViaAliasFor() throws Exception { assertWebMapping(WebController.class.getMethod("getMappedWithValueAttribute")); assertWebMapping(WebController.class.getMethod("getMappedWithPathAttribute")); } @@ -761,60 +761,60 @@ public class AnnotatedElementUtilsTests { } @Test - public void javaLangAnnotationTypeViaFindMergedAnnotation() throws Exception { + void javaLangAnnotationTypeViaFindMergedAnnotation() throws Exception { Constructor deprecatedCtor = Date.class.getConstructor(String.class); assertThat(findMergedAnnotation(deprecatedCtor, Deprecated.class)).isEqualTo(deprecatedCtor.getAnnotation(Deprecated.class)); assertThat(findMergedAnnotation(Date.class, Deprecated.class)).isEqualTo(Date.class.getAnnotation(Deprecated.class)); } @Test - public void javaxAnnotationTypeViaFindMergedAnnotation() throws Exception { + void javaxAnnotationTypeViaFindMergedAnnotation() throws Exception { assertThat(findMergedAnnotation(ResourceHolder.class, Resource.class)).isEqualTo(ResourceHolder.class.getAnnotation(Resource.class)); assertThat(findMergedAnnotation(SpringAppConfigClass.class, Resource.class)).isEqualTo(SpringAppConfigClass.class.getAnnotation(Resource.class)); } @Test - public void javaxMetaAnnotationTypeViaFindMergedAnnotation() throws Exception { + void javaxMetaAnnotationTypeViaFindMergedAnnotation() throws Exception { assertThat(findMergedAnnotation(ParametersAreNonnullByDefault.class, Nonnull.class)).isEqualTo(ParametersAreNonnullByDefault.class.getAnnotation(Nonnull.class)); assertThat(findMergedAnnotation(ResourceHolder.class, Nonnull.class)).isEqualTo(ParametersAreNonnullByDefault.class.getAnnotation(Nonnull.class)); } @Test - public void nullableAnnotationTypeViaFindMergedAnnotation() throws Exception { + void nullableAnnotationTypeViaFindMergedAnnotation() throws Exception { Method method = TransactionalServiceImpl.class.getMethod("doIt"); assertThat(findMergedAnnotation(method, Resource.class)).isEqualTo(method.getAnnotation(Resource.class)); } @Test - public void getAllMergedAnnotationsOnClassWithInterface() throws Exception { + void getAllMergedAnnotationsOnClassWithInterface() throws Exception { Method method = TransactionalServiceImpl.class.getMethod("doIt"); Set allMergedAnnotations = getAllMergedAnnotations(method, Transactional.class); assertThat(allMergedAnnotations.isEmpty()).isTrue(); } @Test - public void findAllMergedAnnotationsOnClassWithInterface() throws Exception { + void findAllMergedAnnotationsOnClassWithInterface() throws Exception { Method method = TransactionalServiceImpl.class.getMethod("doIt"); Set allMergedAnnotations = findAllMergedAnnotations(method, Transactional.class); assertThat(allMergedAnnotations.size()).isEqualTo(1); } @Test // SPR-16060 - public void findMethodAnnotationFromGenericInterface() throws Exception { + void findMethodAnnotationFromGenericInterface() throws Exception { Method method = ImplementsInterfaceWithGenericAnnotatedMethod.class.getMethod("foo", String.class); Order order = findMergedAnnotation(method, Order.class); assertThat(order).isNotNull(); } @Test // SPR-17146 - public void findMethodAnnotationFromGenericSuperclass() throws Exception { + void findMethodAnnotationFromGenericSuperclass() throws Exception { Method method = ExtendsBaseClassWithGenericAnnotatedMethod.class.getMethod("foo", String.class); Order order = findMergedAnnotation(method, Order.class); assertThat(order).isNotNull(); } @Test // gh-22655 - public void forAnnotationsCreatesCopyOfArrayOnEachCall() { + void forAnnotationsCreatesCopyOfArrayOnEachCall() { AnnotatedElement element = AnnotatedElementUtils.forAnnotations(ForAnnotationsClass.class.getDeclaredAnnotations()); // Trigger the NPE as originally reported in the bug AnnotationsScanner.getDeclaredAnnotations(element, false); @@ -824,7 +824,7 @@ public class AnnotatedElementUtilsTests { } @Test // gh-22703 - public void getMergedAnnotationOnThreeDeepMetaWithValue() { + void getMergedAnnotationOnThreeDeepMetaWithValue() { ValueAttribute annotation = AnnotatedElementUtils.getMergedAnnotation( ValueAttributeMetaMetaClass.class, ValueAttribute.class); assertThat(annotation.value()).containsExactly("FromValueAttributeMeta"); diff --git a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationAttributesTests.java b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationAttributesTests.java index ff85b7b236..4d99c42d9e 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationAttributesTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationAttributesTests.java @@ -36,13 +36,13 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException * @author Juergen Hoeller * @since 3.1.1 */ -public class AnnotationAttributesTests { +class AnnotationAttributesTests { private AnnotationAttributes attributes = new AnnotationAttributes(); @Test - public void typeSafeAttributeAccess() { + void typeSafeAttributeAccess() { AnnotationAttributes nestedAttributes = new AnnotationAttributes(); nestedAttributes.put("value", 10); nestedAttributes.put("name", "algernon"); @@ -72,7 +72,7 @@ public class AnnotationAttributesTests { } @Test - public void unresolvableClassWithClassNotFoundException() throws Exception { + void unresolvableClassWithClassNotFoundException() throws Exception { attributes.put("unresolvableClass", new ClassNotFoundException("myclass")); assertThatIllegalArgumentException() .isThrownBy(() -> attributes.getClass("unresolvableClass")) @@ -81,7 +81,7 @@ public class AnnotationAttributesTests { } @Test - public void unresolvableClassWithLinkageError() throws Exception { + void unresolvableClassWithLinkageError() throws Exception { attributes.put("unresolvableClass", new LinkageError("myclass")); assertThatIllegalArgumentException() .isThrownBy(() -> attributes.getClass("unresolvableClass")) @@ -90,7 +90,7 @@ public class AnnotationAttributesTests { } @Test - public void singleElementToSingleElementArrayConversionSupport() throws Exception { + void singleElementToSingleElementArrayConversionSupport() throws Exception { Filter filter = FilteredClass.class.getAnnotation(Filter.class); AnnotationAttributes nestedAttributes = new AnnotationAttributes(); @@ -118,7 +118,7 @@ public class AnnotationAttributesTests { } @Test - public void nestedAnnotations() throws Exception { + void nestedAnnotations() throws Exception { Filter filter = FilteredClass.class.getAnnotation(Filter.class); attributes.put("filter", filter); @@ -135,28 +135,28 @@ public class AnnotationAttributesTests { } @Test - public void getEnumWithNullAttributeName() { + void getEnumWithNullAttributeName() { assertThatIllegalArgumentException() .isThrownBy(() -> attributes.getEnum(null)) .withMessageContaining("must not be null or empty"); } @Test - public void getEnumWithEmptyAttributeName() { + void getEnumWithEmptyAttributeName() { assertThatIllegalArgumentException() .isThrownBy(() -> attributes.getEnum("")) .withMessageContaining("must not be null or empty"); } @Test - public void getEnumWithUnknownAttributeName() { + void getEnumWithUnknownAttributeName() { assertThatIllegalArgumentException() .isThrownBy(() -> attributes.getEnum("bogus")) .withMessageContaining("Attribute 'bogus' not found"); } @Test - public void getEnumWithTypeMismatch() { + void getEnumWithTypeMismatch() { attributes.put("color", "RED"); assertThatIllegalArgumentException() .isThrownBy(() -> attributes.getEnum("color")) @@ -164,7 +164,7 @@ public class AnnotationAttributesTests { } @Test - public void getAliasedStringWithImplicitAliases() { + void getAliasedStringWithImplicitAliases() { String value = "metaverse"; List aliases = Arrays.asList("value", "location1", "location2", "location3", "xmlFile", "groovyScript"); @@ -188,7 +188,7 @@ public class AnnotationAttributesTests { } @Test - public void getAliasedStringArrayWithImplicitAliases() { + void getAliasedStringArrayWithImplicitAliases() { String[] value = new String[] {"test.xml"}; List aliases = Arrays.asList("value", "location1", "location2", "location3", "xmlFile", "groovyScript"); diff --git a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationAwareOrderComparatorTests.java b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationAwareOrderComparatorTests.java index 689eeee3bb..654ae89d44 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationAwareOrderComparatorTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationAwareOrderComparatorTests.java @@ -28,15 +28,15 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Juergen Hoeller * @author Oliver Gierke */ -public class AnnotationAwareOrderComparatorTests { +class AnnotationAwareOrderComparatorTests { @Test - public void instanceVariableIsAnAnnotationAwareOrderComparator() { + void instanceVariableIsAnAnnotationAwareOrderComparator() { assertThat(AnnotationAwareOrderComparator.INSTANCE).isInstanceOf(AnnotationAwareOrderComparator.class); } @Test - public void sortInstances() { + void sortInstances() { List list = new ArrayList<>(); list.add(new B()); list.add(new A()); @@ -46,7 +46,7 @@ public class AnnotationAwareOrderComparatorTests { } @Test - public void sortInstancesWithPriority() { + void sortInstancesWithPriority() { List list = new ArrayList<>(); list.add(new B2()); list.add(new A2()); @@ -56,7 +56,7 @@ public class AnnotationAwareOrderComparatorTests { } @Test - public void sortInstancesWithOrderAndPriority() { + void sortInstancesWithOrderAndPriority() { List list = new ArrayList<>(); list.add(new B()); list.add(new A2()); @@ -66,7 +66,7 @@ public class AnnotationAwareOrderComparatorTests { } @Test - public void sortInstancesWithSubclass() { + void sortInstancesWithSubclass() { List list = new ArrayList<>(); list.add(new B()); list.add(new C()); @@ -76,7 +76,7 @@ public class AnnotationAwareOrderComparatorTests { } @Test - public void sortClasses() { + void sortClasses() { List list = new ArrayList<>(); list.add(B.class); list.add(A.class); @@ -86,7 +86,7 @@ public class AnnotationAwareOrderComparatorTests { } @Test - public void sortClassesWithSubclass() { + void sortClassesWithSubclass() { List list = new ArrayList<>(); list.add(B.class); list.add(C.class); @@ -96,7 +96,7 @@ public class AnnotationAwareOrderComparatorTests { } @Test - public void sortWithNulls() { + void sortWithNulls() { List list = new ArrayList<>(); list.add(null); list.add(B.class); diff --git a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationBackCompatibiltyTests.java b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationBackCompatibiltyTests.java index d8a927e72b..39f1bdd6fe 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationBackCompatibiltyTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationBackCompatibiltyTests.java @@ -29,10 +29,10 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Phillip Webb * @since 5.2 */ -public class AnnotationBackCompatibiltyTests { +class AnnotationBackCompatibiltyTests { @Test - public void multiplRoutesToMetaAnnotation() { + void multiplRoutesToMetaAnnotation() { Class source = WithMetaMetaTestAnnotation1AndMetaTestAnnotation2.class; // Merged annotation chooses lowest depth MergedAnnotation mergedAnnotation = MergedAnnotations.from(source).get(TestAnnotation.class); @@ -43,7 +43,7 @@ public class AnnotationBackCompatibiltyTests { } @Test - public void defaultValue() { + void defaultValue() { DefaultValueAnnotation synthesized = MergedAnnotations.from(WithDefaultValue.class).get(DefaultValueAnnotation.class).synthesize(); assertThat(synthesized).isInstanceOf(SynthesizedAnnotation.class); Object defaultValue = AnnotationUtils.getDefaultValue(synthesized, "enumValue"); diff --git a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationFilterTests.java b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationFilterTests.java index d7b8b3ba52..bb6ec3e227 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationFilterTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationFilterTests.java @@ -32,73 +32,73 @@ import static org.assertj.core.api.Assertions.assertThat; * * @author Phillip Webb */ -public class AnnotationFilterTests { +class AnnotationFilterTests { private static final AnnotationFilter FILTER = annotationType -> ObjectUtils.nullSafeEquals(annotationType, TestAnnotation.class.getName()); @Test - public void matchesAnnotationWhenMatchReturnsTrue() { + void matchesAnnotationWhenMatchReturnsTrue() { TestAnnotation annotation = WithTestAnnotation.class.getDeclaredAnnotation(TestAnnotation.class); assertThat(FILTER.matches(annotation)).isTrue(); } @Test - public void matchesAnnotationWhenNoMatchReturnsFalse() { + void matchesAnnotationWhenNoMatchReturnsFalse() { OtherAnnotation annotation = WithOtherAnnotation.class.getDeclaredAnnotation(OtherAnnotation.class); assertThat(FILTER.matches(annotation)).isFalse(); } @Test - public void matchesAnnotationClassWhenMatchReturnsTrue() { + void matchesAnnotationClassWhenMatchReturnsTrue() { Class annotationType = TestAnnotation.class; assertThat(FILTER.matches(annotationType)).isTrue(); } @Test - public void matchesAnnotationClassWhenNoMatchReturnsFalse() { + void matchesAnnotationClassWhenNoMatchReturnsFalse() { Class annotationType = OtherAnnotation.class; assertThat(FILTER.matches(annotationType)).isFalse(); } @Test - public void plainWhenJavaLangAnnotationReturnsTrue() { + void plainWhenJavaLangAnnotationReturnsTrue() { assertThat(AnnotationFilter.PLAIN.matches(Retention.class)).isTrue(); } @Test - public void plainWhenSpringLangAnnotationReturnsTrue() { + void plainWhenSpringLangAnnotationReturnsTrue() { assertThat(AnnotationFilter.PLAIN.matches(Nullable.class)).isTrue(); } @Test - public void plainWhenOtherAnnotationReturnsFalse() { + void plainWhenOtherAnnotationReturnsFalse() { assertThat(AnnotationFilter.PLAIN.matches(TestAnnotation.class)).isFalse(); } @Test - public void javaWhenJavaLangAnnotationReturnsTrue() { + void javaWhenJavaLangAnnotationReturnsTrue() { assertThat(AnnotationFilter.JAVA.matches(Retention.class)).isTrue(); } @Test - public void javaWhenJavaxAnnotationReturnsTrue() { + void javaWhenJavaxAnnotationReturnsTrue() { assertThat(AnnotationFilter.JAVA.matches(Nonnull.class)).isTrue(); } @Test - public void javaWhenSpringLangAnnotationReturnsFalse() { + void javaWhenSpringLangAnnotationReturnsFalse() { assertThat(AnnotationFilter.JAVA.matches(Nullable.class)).isFalse(); } @Test - public void javaWhenOtherAnnotationReturnsFalse() { + void javaWhenOtherAnnotationReturnsFalse() { assertThat(AnnotationFilter.JAVA.matches(TestAnnotation.class)).isFalse(); } @Test - public void noneReturnsFalse() { + void noneReturnsFalse() { assertThat(AnnotationFilter.NONE.matches(Retention.class)).isFalse(); assertThat(AnnotationFilter.NONE.matches(Nullable.class)).isFalse(); assertThat(AnnotationFilter.NONE.matches(TestAnnotation.class)).isFalse(); diff --git a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationIntrospectionFailureTests.java b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationIntrospectionFailureTests.java index c56b3719be..0fa93c99e9 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationIntrospectionFailureTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationIntrospectionFailureTests.java @@ -39,10 +39,10 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; * @see AnnotationUtils * @see AnnotatedElementUtils */ -public class AnnotationIntrospectionFailureTests { +class AnnotationIntrospectionFailureTests { @Test - public void filteredTypeThrowsTypeNotPresentException() throws Exception { + void filteredTypeThrowsTypeNotPresentException() throws Exception { FilteringClassLoader classLoader = new FilteringClassLoader( getClass().getClassLoader()); Class withExampleAnnotation = ClassUtils.forName( @@ -57,7 +57,7 @@ public class AnnotationIntrospectionFailureTests { @Test @SuppressWarnings("unchecked") - public void filteredTypeInMetaAnnotationWhenUsingAnnotatedElementUtilsHandlesException() throws Exception { + void filteredTypeInMetaAnnotationWhenUsingAnnotatedElementUtilsHandlesException() throws Exception { FilteringClassLoader classLoader = new FilteringClassLoader( getClass().getClassLoader()); Class withExampleMetaAnnotation = ClassUtils.forName( @@ -78,7 +78,7 @@ public class AnnotationIntrospectionFailureTests { @Test @SuppressWarnings("unchecked") - public void filteredTypeInMetaAnnotationWhenUsingMergedAnnotationsHandlesException() throws Exception { + void filteredTypeInMetaAnnotationWhenUsingMergedAnnotationsHandlesException() throws Exception { FilteringClassLoader classLoader = new FilteringClassLoader( getClass().getClassLoader()); Class withExampleMetaAnnotation = ClassUtils.forName( diff --git a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationTypeMappingsTests.java b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationTypeMappingsTests.java index 74b7b7ffc4..1b2a8c49b5 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationTypeMappingsTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationTypeMappingsTests.java @@ -45,10 +45,10 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; * * @author Phillip Webb */ -public class AnnotationTypeMappingsTests { +class AnnotationTypeMappingsTests { @Test - public void forAnnotationTypeWhenNoMetaAnnotationsReturnsMappings() { + void forAnnotationTypeWhenNoMetaAnnotationsReturnsMappings() { AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(SimpleAnnotation.class); assertThat(mappings.size()).isEqualTo(1); assertThat(mappings.get(0).getAnnotationType()).isEqualTo(SimpleAnnotation.class); @@ -57,13 +57,13 @@ public class AnnotationTypeMappingsTests { } @Test - public void forAnnotationWhenHasSpringAnnotationReturnsFilteredMappings() { + void forAnnotationWhenHasSpringAnnotationReturnsFilteredMappings() { AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(WithSpringLangAnnotation.class); assertThat(mappings.size()).isEqualTo(1); } @Test - public void forAnnotationTypeWhenMetaAnnotationsReturnsMappings() { + void forAnnotationTypeWhenMetaAnnotationsReturnsMappings() { AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(MetaAnnotated.class); assertThat(mappings.size()).isEqualTo(6); assertThat(getAll(mappings)).flatExtracting( @@ -73,7 +73,7 @@ public class AnnotationTypeMappingsTests { } @Test - public void forAnnotationTypeWhenHasRepeatingMetaAnnotationReturnsMapping() { + void forAnnotationTypeWhenHasRepeatingMetaAnnotationReturnsMapping() { AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(WithRepeatedMetaAnnotations.class); assertThat(mappings.size()).isEqualTo(3); assertThat(getAll(mappings)).flatExtracting( @@ -82,7 +82,7 @@ public class AnnotationTypeMappingsTests { } @Test - public void forAnnotationTypeWhenSelfAnnotatedReturnsMapping() { + void forAnnotationTypeWhenSelfAnnotatedReturnsMapping() { AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(SelfAnnotated.class); assertThat(mappings.size()).isEqualTo(1); assertThat(getAll(mappings)).flatExtracting( @@ -90,7 +90,7 @@ public class AnnotationTypeMappingsTests { } @Test - public void forAnnotationTypeWhenFormsLoopReturnsMapping() { + void forAnnotationTypeWhenFormsLoopReturnsMapping() { AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(LoopA.class); assertThat(mappings.size()).isEqualTo(2); assertThat(getAll(mappings)).flatExtracting( @@ -98,7 +98,7 @@ public class AnnotationTypeMappingsTests { } @Test - public void forAnnotationTypeWhenHasAliasForWithBothValueAndAttributeThrowsException() { + void forAnnotationTypeWhenHasAliasForWithBothValueAndAttributeThrowsException() { assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> AnnotationTypeMappings.forAnnotationType(AliasForWithBothValueAndAttribute.class)) .withMessage("In @AliasFor declared on attribute 'test' in annotation [" @@ -107,7 +107,7 @@ public class AnnotationTypeMappingsTests { } @Test - public void forAnnotationTypeWhenAliasForToSelfNonExistingAttribute() { + void forAnnotationTypeWhenAliasForToSelfNonExistingAttribute() { assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> AnnotationTypeMappings.forAnnotationType(AliasForToSelfNonExistingAttribute.class)) .withMessage("@AliasFor declaration on attribute 'test' in annotation [" @@ -116,7 +116,7 @@ public class AnnotationTypeMappingsTests { } @Test - public void forAnnotationTypeWhenAliasForToOtherNonExistingAttribute() { + void forAnnotationTypeWhenAliasForToOtherNonExistingAttribute() { assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> AnnotationTypeMappings.forAnnotationType(AliasForToOtherNonExistingAttribute.class)) .withMessage("Attribute 'test' in annotation [" @@ -128,7 +128,7 @@ public class AnnotationTypeMappingsTests { } @Test - public void forAnnotationTypeWhenAliasForToSelf() { + void forAnnotationTypeWhenAliasForToSelf() { assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> AnnotationTypeMappings.forAnnotationType(AliasForToSelf.class)) .withMessage("@AliasFor declaration on attribute 'test' in annotation [" @@ -138,7 +138,7 @@ public class AnnotationTypeMappingsTests { } @Test - public void forAnnotationTypeWhenAliasForWithArrayCompatibleReturnTypes() { + void forAnnotationTypeWhenAliasForWithArrayCompatibleReturnTypes() { AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType( AliasForWithArrayCompatibleReturnTypes.class); AnnotationTypeMapping mapping = getMapping(mappings, @@ -147,7 +147,7 @@ public class AnnotationTypeMappingsTests { } @Test - public void forAnnotationTypeWhenAliasForWithIncompatibleReturnTypes() { + void forAnnotationTypeWhenAliasForWithIncompatibleReturnTypes() { assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> AnnotationTypeMappings.forAnnotationType(AliasForWithIncompatibleReturnTypes.class)) .withMessage("Misconfigured aliases: attribute 'test' in annotation [" @@ -158,7 +158,7 @@ public class AnnotationTypeMappingsTests { } @Test - public void forAnnotationTypeWhenAliasForToSelfNonAnnotatedAttribute() { + void forAnnotationTypeWhenAliasForToSelfNonAnnotatedAttribute() { assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> AnnotationTypeMappings.forAnnotationType(AliasForToSelfNonAnnotatedAttribute.class)) .withMessage("Attribute 'other' in annotation [" @@ -167,7 +167,7 @@ public class AnnotationTypeMappingsTests { } @Test - public void forAnnotationTypeWhenAliasForToSelfAnnotatedToOtherAttribute() { + void forAnnotationTypeWhenAliasForToSelfAnnotatedToOtherAttribute() { assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> AnnotationTypeMappings.forAnnotationType(AliasForToSelfAnnotatedToOtherAttribute.class)) .withMessage("Attribute 'b' in annotation [" @@ -176,7 +176,7 @@ public class AnnotationTypeMappingsTests { } @Test - public void forAnnotationTypeWhenAliasForNonMetaAnnotated() { + void forAnnotationTypeWhenAliasForNonMetaAnnotated() { assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> AnnotationTypeMappings.forAnnotationType(AliasForNonMetaAnnotated.class)) .withMessage("@AliasFor declaration on attribute 'test' in annotation [" @@ -187,7 +187,7 @@ public class AnnotationTypeMappingsTests { } @Test - public void forAnnotationTypeWhenAliasForSelfWithDifferentDefaults() { + void forAnnotationTypeWhenAliasForSelfWithDifferentDefaults() { assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> AnnotationTypeMappings.forAnnotationType(AliasForSelfWithDifferentDefaults.class)) .withMessage("Misconfigured aliases: attribute 'a' in annotation [" @@ -198,7 +198,7 @@ public class AnnotationTypeMappingsTests { } @Test - public void forAnnotationTypeWhenAliasForSelfWithMissingDefault() { + void forAnnotationTypeWhenAliasForSelfWithMissingDefault() { assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> AnnotationTypeMappings.forAnnotationType(AliasForSelfWithMissingDefault.class)) .withMessage("Misconfigured aliases: attribute 'a' in annotation [" @@ -209,7 +209,7 @@ public class AnnotationTypeMappingsTests { } @Test - public void forAnnotationTypeWhenAliasWithExplicitMirrorAndDifferentDefaults() { + void forAnnotationTypeWhenAliasWithExplicitMirrorAndDifferentDefaults() { assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> AnnotationTypeMappings.forAnnotationType(AliasWithExplicitMirrorAndDifferentDefaults.class)) .withMessage("Misconfigured aliases: attribute 'a' in annotation [" @@ -220,7 +220,7 @@ public class AnnotationTypeMappingsTests { } @Test - public void getDistanceReturnsDistance() { + void getDistanceReturnsDistance() { AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType( Mapped.class); assertThat(mappings.get(0).getDistance()).isEqualTo(0); @@ -228,7 +228,7 @@ public class AnnotationTypeMappingsTests { } @Test - public void getAnnotationTypeReturnsAnnotationType() { + void getAnnotationTypeReturnsAnnotationType() { AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType( Mapped.class); assertThat(mappings.get(0).getAnnotationType()).isEqualTo(Mapped.class); @@ -236,7 +236,7 @@ public class AnnotationTypeMappingsTests { } @Test - public void getMetaTypeReturnsTypes() { + void getMetaTypeReturnsTypes() { AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType( ThreeDeepA.class); AnnotationTypeMapping mappingC = mappings.get(2); @@ -245,14 +245,14 @@ public class AnnotationTypeMappingsTests { } @Test - public void getAnnotationWhenRootReturnsNull() { + void getAnnotationWhenRootReturnsNull() { AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType( Mapped.class); assertThat(mappings.get(0).getAnnotation()).isNull(); } @Test - public void getAnnotationWhenMetaAnnotationReturnsAnnotation() { + void getAnnotationWhenMetaAnnotationReturnsAnnotation() { AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType( Mapped.class); assertThat(mappings.get(1).getAnnotation()).isEqualTo( @@ -261,7 +261,7 @@ public class AnnotationTypeMappingsTests { } @Test - public void getAttributesReturnsAttributes() { + void getAttributesReturnsAttributes() { AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType( Mapped.class).get(0); AttributeMethods attributes = mapping.getAttributes(); @@ -271,7 +271,7 @@ public class AnnotationTypeMappingsTests { } @Test - public void getAliasMappingReturnsAttributes() throws Exception { + void getAliasMappingReturnsAttributes() throws Exception { AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType( Mapped.class).get(1); assertThat(getAliasMapping(mapping, 0)).isEqualTo( @@ -279,7 +279,7 @@ public class AnnotationTypeMappingsTests { } @Test - public void getConventionMappingReturnsAttributes() throws Exception { + void getConventionMappingReturnsAttributes() throws Exception { AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType( Mapped.class).get(1); assertThat(getConventionMapping(mapping, 1)).isEqualTo( @@ -287,7 +287,7 @@ public class AnnotationTypeMappingsTests { } @Test - public void getMirrorSetWhenAliasPairReturnsMirrors() { + void getMirrorSetWhenAliasPairReturnsMirrors() { AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType( AliasPair.class).get(0); MirrorSets mirrorSets = mapping.getMirrorSets(); @@ -298,7 +298,7 @@ public class AnnotationTypeMappingsTests { } @Test - public void getMirrorSetWhenImplicitMirrorsReturnsMirrors() { + void getMirrorSetWhenImplicitMirrorsReturnsMirrors() { AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType( ImplicitMirrors.class).get(0); MirrorSets mirrorSets = mapping.getMirrorSets(); @@ -309,7 +309,7 @@ public class AnnotationTypeMappingsTests { } @Test - public void getMirrorSetWhenThreeDeepReturnsMirrors() { + void getMirrorSetWhenThreeDeepReturnsMirrors() { AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType( ThreeDeepA.class); AnnotationTypeMapping mappingA = mappings.get(0); @@ -326,7 +326,7 @@ public class AnnotationTypeMappingsTests { } @Test - public void getAliasMappingWhenThreeDeepReturnsMappedAttributes() { + void getAliasMappingWhenThreeDeepReturnsMappedAttributes() { AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType( ThreeDeepA.class); AnnotationTypeMapping mappingA = mappings.get(0); @@ -344,7 +344,7 @@ public class AnnotationTypeMappingsTests { } @Test - public void getAliasMappingsWhenHasDefinedAttributesReturnsMappedAttributes() { + void getAliasMappingsWhenHasDefinedAttributesReturnsMappedAttributes() { AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType( DefinedAttributes.class).get(1); assertThat(getAliasMapping(mapping, 0)).isNull(); @@ -352,7 +352,7 @@ public class AnnotationTypeMappingsTests { } @Test - public void resolveMirrorsWhenAliasPairResolves() { + void resolveMirrorsWhenAliasPairResolves() { AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType( AliasPair.class).get(0); Method[] resolvedA = resolveMirrorSets(mapping, WithAliasPairA.class, @@ -366,7 +366,7 @@ public class AnnotationTypeMappingsTests { } @Test - public void resolveMirrorsWhenHasSameValuesUsesFirst() { + void resolveMirrorsWhenHasSameValuesUsesFirst() { AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType( AliasPair.class).get(0); Method[] resolved = resolveMirrorSets(mapping, WithSameValueAliasPair.class, @@ -376,7 +376,7 @@ public class AnnotationTypeMappingsTests { } @Test - public void resolveMirrorsWhenOnlyHasDefaultValuesResolvesNone() { + void resolveMirrorsWhenOnlyHasDefaultValuesResolvesNone() { AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType( AliasPair.class).get(0); Method[] resolved = resolveMirrorSets(mapping, WithDefaultValueAliasPair.class, @@ -386,7 +386,7 @@ public class AnnotationTypeMappingsTests { } @Test - public void resolveMirrorsWhenHasDifferentValuesThrowsException() { + void resolveMirrorsWhenHasDifferentValuesThrowsException() { AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType( AliasPair.class).get(0); assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> @@ -398,7 +398,7 @@ public class AnnotationTypeMappingsTests { } @Test - public void resolveMirrorsWhenHasWithMulipleRoutesToAliasReturnsMirrors() { + void resolveMirrorsWhenHasWithMulipleRoutesToAliasReturnsMirrors() { AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType( MulipleRoutesToAliasA.class); AnnotationTypeMapping mappingsA = getMapping(mappings, @@ -415,7 +415,7 @@ public class AnnotationTypeMappingsTests { } @Test - public void getAliasMappingWhenHasWithMulipleRoutesToAliasReturnsMappedAttributes() { + void getAliasMappingWhenHasWithMulipleRoutesToAliasReturnsMappedAttributes() { AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType( MulipleRoutesToAliasA.class); AnnotationTypeMapping mappingsA = getMapping(mappings, @@ -433,7 +433,7 @@ public class AnnotationTypeMappingsTests { } @Test - public void getConventionMappingWhenConventionToExplicitAliasesReturnsMappedAttributes() { + void getConventionMappingWhenConventionToExplicitAliasesReturnsMappedAttributes() { AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType( ConventionToExplicitAliases.class); AnnotationTypeMapping mapping = getMapping(mappings, @@ -443,7 +443,7 @@ public class AnnotationTypeMappingsTests { } @Test - public void isEquivalentToDefaultValueWhenValueAndDefaultAreNullReturnsTrue() { + void isEquivalentToDefaultValueWhenValueAndDefaultAreNullReturnsTrue() { AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType( ClassValue.class).get(0); assertThat(mapping.isEquivalentToDefaultValue(0, null, @@ -451,7 +451,7 @@ public class AnnotationTypeMappingsTests { } @Test - public void isEquivalentToDefaultValueWhenValueAndDefaultMatchReturnsTrue() { + void isEquivalentToDefaultValueWhenValueAndDefaultMatchReturnsTrue() { AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType( ClassValueWithDefault.class).get(0); assertThat(mapping.isEquivalentToDefaultValue(0, InputStream.class, @@ -459,7 +459,7 @@ public class AnnotationTypeMappingsTests { } @Test - public void isEquivalentToDefaultValueWhenClassAndStringNamesMatchReturnsTrue() { + void isEquivalentToDefaultValueWhenClassAndStringNamesMatchReturnsTrue() { AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType( ClassValueWithDefault.class).get(0); assertThat(mapping.isEquivalentToDefaultValue(0, "java.io.InputStream", @@ -467,7 +467,7 @@ public class AnnotationTypeMappingsTests { } @Test - public void isEquivalentToDefaultValueWhenClassArrayAndStringArrayNamesMatchReturnsTrue() { + void isEquivalentToDefaultValueWhenClassArrayAndStringArrayNamesMatchReturnsTrue() { AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType( ClassArrayValueWithDefault.class).get(0); assertThat(mapping.isEquivalentToDefaultValue(0, @@ -476,7 +476,7 @@ public class AnnotationTypeMappingsTests { } @Test - public void isEquivalentToDefaultValueWhenNestedAnnotationAndExtractedValuesMatchReturnsTrue() { + void isEquivalentToDefaultValueWhenNestedAnnotationAndExtractedValuesMatchReturnsTrue() { AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType( NestedValue.class).get(0); Map value = Collections.singletonMap("value", @@ -486,7 +486,7 @@ public class AnnotationTypeMappingsTests { } @Test - public void isEquivalentToDefaultValueWhenNotMatchingReturnsFalse() { + void isEquivalentToDefaultValueWhenNotMatchingReturnsFalse() { AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType( ClassValueWithDefault.class).get(0); assertThat(mapping.isEquivalentToDefaultValue(0, OutputStream.class, diff --git a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java index 3377db1a60..81f5264a7f 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java @@ -72,16 +72,16 @@ import static org.springframework.core.annotation.AnnotationUtils.synthesizeAnno * @author Oleg Zhurakousky */ @SuppressWarnings("deprecation") -public class AnnotationUtilsTests { +class AnnotationUtilsTests { @BeforeEach - public void clearCacheBeforeTests() { + void clearCacheBeforeTests() { AnnotationUtils.clearCache(); } @Test - public void findMethodAnnotationOnLeaf() throws Exception { + void findMethodAnnotationOnLeaf() throws Exception { Method m = Leaf.class.getMethod("annotatedOnLeaf"); assertThat(m.getAnnotation(Order.class)).isNotNull(); assertThat(getAnnotation(m, Order.class)).isNotNull(); @@ -90,7 +90,7 @@ public class AnnotationUtilsTests { // @since 4.2 @Test - public void findMethodAnnotationWithAnnotationOnMethodInInterface() throws Exception { + void findMethodAnnotationWithAnnotationOnMethodInInterface() throws Exception { Method m = Leaf.class.getMethod("fromInterfaceImplementedByRoot"); // @Order is not @Inherited assertThat(m.getAnnotation(Order.class)).isNull(); @@ -102,7 +102,7 @@ public class AnnotationUtilsTests { // @since 4.2 @Test - public void findMethodAnnotationWithMetaAnnotationOnLeaf() throws Exception { + void findMethodAnnotationWithMetaAnnotationOnLeaf() throws Exception { Method m = Leaf.class.getMethod("metaAnnotatedOnLeaf"); assertThat(m.getAnnotation(Order.class)).isNull(); assertThat(getAnnotation(m, Order.class)).isNotNull(); @@ -111,7 +111,7 @@ public class AnnotationUtilsTests { // @since 4.2 @Test - public void findMethodAnnotationWithMetaMetaAnnotationOnLeaf() throws Exception { + void findMethodAnnotationWithMetaMetaAnnotationOnLeaf() throws Exception { Method m = Leaf.class.getMethod("metaMetaAnnotatedOnLeaf"); assertThat(m.getAnnotation(Component.class)).isNull(); assertThat(getAnnotation(m, Component.class)).isNull(); @@ -119,7 +119,7 @@ public class AnnotationUtilsTests { } @Test - public void findMethodAnnotationOnRoot() throws Exception { + void findMethodAnnotationOnRoot() throws Exception { Method m = Leaf.class.getMethod("annotatedOnRoot"); assertThat(m.getAnnotation(Order.class)).isNotNull(); assertThat(getAnnotation(m, Order.class)).isNotNull(); @@ -128,7 +128,7 @@ public class AnnotationUtilsTests { // @since 4.2 @Test - public void findMethodAnnotationWithMetaAnnotationOnRoot() throws Exception { + void findMethodAnnotationWithMetaAnnotationOnRoot() throws Exception { Method m = Leaf.class.getMethod("metaAnnotatedOnRoot"); assertThat(m.getAnnotation(Order.class)).isNull(); assertThat(getAnnotation(m, Order.class)).isNotNull(); @@ -136,7 +136,7 @@ public class AnnotationUtilsTests { } @Test - public void findMethodAnnotationOnRootButOverridden() throws Exception { + void findMethodAnnotationOnRootButOverridden() throws Exception { Method m = Leaf.class.getMethod("overrideWithoutNewAnnotation"); assertThat(m.getAnnotation(Order.class)).isNull(); assertThat(getAnnotation(m, Order.class)).isNull(); @@ -144,13 +144,13 @@ public class AnnotationUtilsTests { } @Test - public void findMethodAnnotationNotAnnotated() throws Exception { + void findMethodAnnotationNotAnnotated() throws Exception { Method m = Leaf.class.getMethod("notAnnotated"); assertThat(findAnnotation(m, Order.class)).isNull(); } @Test - public void findMethodAnnotationOnBridgeMethod() throws Exception { + void findMethodAnnotationOnBridgeMethod() throws Exception { Method bridgeMethod = SimpleFoo.class.getMethod("something", Object.class); assertThat(bridgeMethod.isBridge()).isTrue(); @@ -177,7 +177,7 @@ public class AnnotationUtilsTests { } @Test - public void findMethodAnnotationOnBridgedMethod() throws Exception { + void findMethodAnnotationOnBridgedMethod() throws Exception { Method bridgedMethod = SimpleFoo.class.getMethod("something", String.class); assertThat(bridgedMethod.isBridge()).isFalse(); @@ -191,35 +191,35 @@ public class AnnotationUtilsTests { } @Test - public void findMethodAnnotationFromInterface() throws Exception { + void findMethodAnnotationFromInterface() throws Exception { Method method = ImplementsInterfaceWithAnnotatedMethod.class.getMethod("foo"); Order order = findAnnotation(method, Order.class); assertThat(order).isNotNull(); } @Test // SPR-16060 - public void findMethodAnnotationFromGenericInterface() throws Exception { + void findMethodAnnotationFromGenericInterface() throws Exception { Method method = ImplementsInterfaceWithGenericAnnotatedMethod.class.getMethod("foo", String.class); Order order = findAnnotation(method, Order.class); assertThat(order).isNotNull(); } @Test // SPR-17146 - public void findMethodAnnotationFromGenericSuperclass() throws Exception { + void findMethodAnnotationFromGenericSuperclass() throws Exception { Method method = ExtendsBaseClassWithGenericAnnotatedMethod.class.getMethod("foo", String.class); Order order = findAnnotation(method, Order.class); assertThat(order).isNotNull(); } @Test - public void findMethodAnnotationFromInterfaceOnSuper() throws Exception { + void findMethodAnnotationFromInterfaceOnSuper() throws Exception { Method method = SubOfImplementsInterfaceWithAnnotatedMethod.class.getMethod("foo"); Order order = findAnnotation(method, Order.class); assertThat(order).isNotNull(); } @Test - public void findMethodAnnotationFromInterfaceWhenSuperDoesNotImplementMethod() throws Exception { + void findMethodAnnotationFromInterfaceWhenSuperDoesNotImplementMethod() throws Exception { Method method = SubOfAbstractImplementsInterfaceWithAnnotatedMethod.class.getMethod("foo"); Order order = findAnnotation(method, Order.class); assertThat(order).isNotNull(); @@ -227,7 +227,7 @@ public class AnnotationUtilsTests { // @since 4.1.2 @Test - public void findClassAnnotationFavorsMoreLocallyDeclaredComposedAnnotationsOverAnnotationsOnInterfaces() { + void findClassAnnotationFavorsMoreLocallyDeclaredComposedAnnotationsOverAnnotationsOnInterfaces() { Component component = findAnnotation(ClassWithLocalMetaAnnotationAndMetaAnnotatedInterface.class, Component.class); assertThat(component).isNotNull(); assertThat(component.value()).isEqualTo("meta2"); @@ -235,7 +235,7 @@ public class AnnotationUtilsTests { // @since 4.0.3 @Test - public void findClassAnnotationFavorsMoreLocallyDeclaredComposedAnnotationsOverInheritedAnnotations() { + void findClassAnnotationFavorsMoreLocallyDeclaredComposedAnnotationsOverInheritedAnnotations() { Transactional transactional = findAnnotation(SubSubClassWithInheritedAnnotation.class, Transactional.class); assertThat(transactional).isNotNull(); assertThat(transactional.readOnly()).as("readOnly flag for SubSubClassWithInheritedAnnotation").isTrue(); @@ -243,83 +243,83 @@ public class AnnotationUtilsTests { // @since 4.0.3 @Test - public void findClassAnnotationFavorsMoreLocallyDeclaredComposedAnnotationsOverInheritedComposedAnnotations() { + void findClassAnnotationFavorsMoreLocallyDeclaredComposedAnnotationsOverInheritedComposedAnnotations() { Component component = findAnnotation(SubSubClassWithInheritedMetaAnnotation.class, Component.class); assertThat(component).isNotNull(); assertThat(component.value()).isEqualTo("meta2"); } @Test - public void findClassAnnotationOnMetaMetaAnnotatedClass() { + void findClassAnnotationOnMetaMetaAnnotatedClass() { Component component = findAnnotation(MetaMetaAnnotatedClass.class, Component.class); assertThat(component).as("Should find meta-annotation on composed annotation on class").isNotNull(); assertThat(component.value()).isEqualTo("meta2"); } @Test - public void findClassAnnotationOnMetaMetaMetaAnnotatedClass() { + void findClassAnnotationOnMetaMetaMetaAnnotatedClass() { Component component = findAnnotation(MetaMetaMetaAnnotatedClass.class, Component.class); assertThat(component).as("Should find meta-annotation on meta-annotation on composed annotation on class").isNotNull(); assertThat(component.value()).isEqualTo("meta2"); } @Test - public void findClassAnnotationOnAnnotatedClassWithMissingTargetMetaAnnotation() { + void findClassAnnotationOnAnnotatedClassWithMissingTargetMetaAnnotation() { // TransactionalClass is NOT annotated or meta-annotated with @Component Component component = findAnnotation(TransactionalClass.class, Component.class); assertThat(component).as("Should not find @Component on TransactionalClass").isNull(); } @Test - public void findClassAnnotationOnMetaCycleAnnotatedClassWithMissingTargetMetaAnnotation() { + void findClassAnnotationOnMetaCycleAnnotatedClassWithMissingTargetMetaAnnotation() { Component component = findAnnotation(MetaCycleAnnotatedClass.class, Component.class); assertThat(component).as("Should not find @Component on MetaCycleAnnotatedClass").isNull(); } // @since 4.2 @Test - public void findClassAnnotationOnInheritedAnnotationInterface() { + void findClassAnnotationOnInheritedAnnotationInterface() { Transactional tx = findAnnotation(InheritedAnnotationInterface.class, Transactional.class); assertThat(tx).as("Should find @Transactional on InheritedAnnotationInterface").isNotNull(); } // @since 4.2 @Test - public void findClassAnnotationOnSubInheritedAnnotationInterface() { + void findClassAnnotationOnSubInheritedAnnotationInterface() { Transactional tx = findAnnotation(SubInheritedAnnotationInterface.class, Transactional.class); assertThat(tx).as("Should find @Transactional on SubInheritedAnnotationInterface").isNotNull(); } // @since 4.2 @Test - public void findClassAnnotationOnSubSubInheritedAnnotationInterface() { + void findClassAnnotationOnSubSubInheritedAnnotationInterface() { Transactional tx = findAnnotation(SubSubInheritedAnnotationInterface.class, Transactional.class); assertThat(tx).as("Should find @Transactional on SubSubInheritedAnnotationInterface").isNotNull(); } // @since 4.2 @Test - public void findClassAnnotationOnNonInheritedAnnotationInterface() { + void findClassAnnotationOnNonInheritedAnnotationInterface() { Order order = findAnnotation(NonInheritedAnnotationInterface.class, Order.class); assertThat(order).as("Should find @Order on NonInheritedAnnotationInterface").isNotNull(); } // @since 4.2 @Test - public void findClassAnnotationOnSubNonInheritedAnnotationInterface() { + void findClassAnnotationOnSubNonInheritedAnnotationInterface() { Order order = findAnnotation(SubNonInheritedAnnotationInterface.class, Order.class); assertThat(order).as("Should find @Order on SubNonInheritedAnnotationInterface").isNotNull(); } // @since 4.2 @Test - public void findClassAnnotationOnSubSubNonInheritedAnnotationInterface() { + void findClassAnnotationOnSubSubNonInheritedAnnotationInterface() { Order order = findAnnotation(SubSubNonInheritedAnnotationInterface.class, Order.class); assertThat(order).as("Should find @Order on SubSubNonInheritedAnnotationInterface").isNotNull(); } @Test - public void findAnnotationDeclaringClassForAllScenarios() { + void findAnnotationDeclaringClassForAllScenarios() { // no class-level annotation assertThat((Object) findAnnotationDeclaringClass(Transactional.class, NonAnnotatedInterface.class)).isNull(); assertThat((Object) findAnnotationDeclaringClass(Transactional.class, NonAnnotatedClass.class)).isNull(); @@ -339,7 +339,7 @@ public class AnnotationUtilsTests { } @Test - public void findAnnotationDeclaringClassForTypesWithSingleCandidateType() { + void findAnnotationDeclaringClassForTypesWithSingleCandidateType() { // no class-level annotation List> transactionalCandidateList = Collections.singletonList(Transactional.class); assertThat((Object) findAnnotationDeclaringClassForTypes(transactionalCandidateList, NonAnnotatedInterface.class)).isNull(); @@ -361,7 +361,7 @@ public class AnnotationUtilsTests { } @Test - public void findAnnotationDeclaringClassForTypesWithMultipleCandidateTypes() { + void findAnnotationDeclaringClassForTypesWithMultipleCandidateTypes() { List> candidates = asList(Transactional.class, Order.class); // no class-level annotation @@ -388,7 +388,7 @@ public class AnnotationUtilsTests { } @Test - public void isAnnotationDeclaredLocallyForAllScenarios() { + void isAnnotationDeclaredLocallyForAllScenarios() { // no class-level annotation assertThat(isAnnotationDeclaredLocally(Transactional.class, NonAnnotatedInterface.class)).isFalse(); assertThat(isAnnotationDeclaredLocally(Transactional.class, NonAnnotatedClass.class)).isFalse(); @@ -407,7 +407,7 @@ public class AnnotationUtilsTests { } @Test - public void isAnnotationInheritedForAllScenarios() { + void isAnnotationInheritedForAllScenarios() { // no class-level annotation assertThat(isAnnotationInherited(Transactional.class, NonAnnotatedInterface.class)).isFalse(); assertThat(isAnnotationInherited(Transactional.class, NonAnnotatedClass.class)).isFalse(); @@ -428,7 +428,7 @@ public class AnnotationUtilsTests { } @Test - public void isAnnotationMetaPresentForPlainType() { + void isAnnotationMetaPresentForPlainType() { assertThat(isAnnotationMetaPresent(Order.class, Documented.class)).isTrue(); assertThat(isAnnotationMetaPresent(NonNullApi.class, Documented.class)).isTrue(); assertThat(isAnnotationMetaPresent(NonNullApi.class, Nonnull.class)).isTrue(); @@ -436,7 +436,7 @@ public class AnnotationUtilsTests { } @Test - public void getAnnotationAttributesWithoutAttributeAliases() { + void getAnnotationAttributesWithoutAttributeAliases() { Component component = WebController.class.getAnnotation(Component.class); assertThat(component).isNotNull(); @@ -447,7 +447,7 @@ public class AnnotationUtilsTests { } @Test - public void getAnnotationAttributesWithNestedAnnotations() { + void getAnnotationAttributesWithNestedAnnotations() { ComponentScan componentScan = ComponentScanClass.class.getAnnotation(ComponentScan.class); assertThat(componentScan).isNotNull(); @@ -463,7 +463,7 @@ public class AnnotationUtilsTests { } @Test - public void getAnnotationAttributesWithAttributeAliases() throws Exception { + void getAnnotationAttributesWithAttributeAliases() throws Exception { Method method = WebController.class.getMethod("handleMappedWithValueAttribute"); WebMapping webMapping = method.getAnnotation(WebMapping.class); AnnotationAttributes attributes = (AnnotationAttributes) getAnnotationAttributes(webMapping); @@ -484,7 +484,7 @@ public class AnnotationUtilsTests { } @Test - public void getAnnotationAttributesWithAttributeAliasesWithDifferentValues() throws Exception { + void getAnnotationAttributesWithAttributeAliasesWithDifferentValues() throws Exception { Method method = WebController.class.getMethod("handleMappedWithDifferentPathAndValueAttributes"); WebMapping webMapping = method.getAnnotation(WebMapping.class); assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> @@ -494,7 +494,7 @@ public class AnnotationUtilsTests { } @Test - public void getValueFromAnnotation() throws Exception { + void getValueFromAnnotation() throws Exception { Method method = SimpleFoo.class.getMethod("something", Object.class); Order order = findAnnotation(method, Order.class); @@ -503,7 +503,7 @@ public class AnnotationUtilsTests { } @Test - public void getValueFromNonPublicAnnotation() throws Exception { + void getValueFromNonPublicAnnotation() throws Exception { Annotation[] declaredAnnotations = NonPublicAnnotatedClass.class.getDeclaredAnnotations(); assertThat(declaredAnnotations.length).isEqualTo(1); Annotation annotation = declaredAnnotations[0]; @@ -514,7 +514,7 @@ public class AnnotationUtilsTests { } @Test - public void getDefaultValueFromAnnotation() throws Exception { + void getDefaultValueFromAnnotation() throws Exception { Method method = SimpleFoo.class.getMethod("something", Object.class); Order order = findAnnotation(method, Order.class); @@ -523,7 +523,7 @@ public class AnnotationUtilsTests { } @Test - public void getDefaultValueFromNonPublicAnnotation() { + void getDefaultValueFromNonPublicAnnotation() { Annotation[] declaredAnnotations = NonPublicAnnotatedClass.class.getDeclaredAnnotations(); assertThat(declaredAnnotations.length).isEqualTo(1); Annotation annotation = declaredAnnotations[0]; @@ -534,20 +534,20 @@ public class AnnotationUtilsTests { } @Test - public void getDefaultValueFromAnnotationType() { + void getDefaultValueFromAnnotationType() { assertThat(getDefaultValue(Order.class, VALUE)).isEqualTo(Ordered.LOWEST_PRECEDENCE); assertThat(getDefaultValue(Order.class)).isEqualTo(Ordered.LOWEST_PRECEDENCE); } @Test - public void findRepeatableAnnotation() { + void findRepeatableAnnotation() { Repeatable repeatable = findAnnotation(MyRepeatable.class, Repeatable.class); assertThat(repeatable).isNotNull(); assertThat(repeatable.value()).isEqualTo(MyRepeatableContainer.class); } @Test - public void getRepeatableAnnotationsDeclaredOnMethod() throws Exception { + void getRepeatableAnnotationsDeclaredOnMethod() throws Exception { Method method = InterfaceWithRepeated.class.getMethod("foo"); Set annotations = getRepeatableAnnotations(method, MyRepeatable.class, MyRepeatableContainer.class); assertThat(annotations).isNotNull(); @@ -556,7 +556,7 @@ public class AnnotationUtilsTests { } @Test - public void getRepeatableAnnotationsDeclaredOnClassWithMissingAttributeAliasDeclaration() throws Exception { + void getRepeatableAnnotationsDeclaredOnClassWithMissingAttributeAliasDeclaration() throws Exception { assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> getRepeatableAnnotations(BrokenConfigHierarchyTestCase.class, BrokenContextConfig.class, BrokenHierarchy.class)) .withMessageStartingWith("Attribute 'value' in") @@ -566,7 +566,7 @@ public class AnnotationUtilsTests { } @Test - public void getRepeatableAnnotationsDeclaredOnClassWithAttributeAliases() { + void getRepeatableAnnotationsDeclaredOnClassWithAttributeAliases() { final List expectedLocations = asList("A", "B"); Set annotations = getRepeatableAnnotations(ConfigHierarchyTestCase.class, ContextConfig.class, null); @@ -584,7 +584,7 @@ public class AnnotationUtilsTests { } @Test - public void getRepeatableAnnotationsDeclaredOnClass() { + void getRepeatableAnnotationsDeclaredOnClass() { final List expectedValuesJava = asList("A", "B", "C"); final List expectedValuesSpring = asList("A", "B", "C", "meta1"); @@ -608,7 +608,7 @@ public class AnnotationUtilsTests { } @Test - public void getRepeatableAnnotationsDeclaredOnSuperclass() { + void getRepeatableAnnotationsDeclaredOnSuperclass() { final Class clazz = SubMyRepeatableClass.class; final List expectedValuesJava = asList("A", "B", "C"); final List expectedValuesSpring = asList("A", "B", "C", "meta1"); @@ -633,7 +633,7 @@ public class AnnotationUtilsTests { } @Test - public void getRepeatableAnnotationsDeclaredOnClassAndSuperclass() { + void getRepeatableAnnotationsDeclaredOnClassAndSuperclass() { final Class clazz = SubMyRepeatableWithAdditionalLocalDeclarationsClass.class; final List expectedValuesJava = asList("X", "Y", "Z"); final List expectedValuesSpring = asList("X", "Y", "Z", "meta2"); @@ -658,7 +658,7 @@ public class AnnotationUtilsTests { } @Test - public void getRepeatableAnnotationsDeclaredOnMultipleSuperclasses() { + void getRepeatableAnnotationsDeclaredOnMultipleSuperclasses() { final Class clazz = SubSubMyRepeatableWithAdditionalLocalDeclarationsClass.class; final List expectedValuesJava = asList("X", "Y", "Z"); final List expectedValuesSpring = asList("X", "Y", "Z", "meta2"); @@ -683,7 +683,7 @@ public class AnnotationUtilsTests { } @Test - public void getDeclaredRepeatableAnnotationsDeclaredOnClass() { + void getDeclaredRepeatableAnnotationsDeclaredOnClass() { final List expectedValuesJava = asList("A", "B", "C"); final List expectedValuesSpring = asList("A", "B", "C", "meta1"); @@ -707,7 +707,7 @@ public class AnnotationUtilsTests { } @Test - public void getDeclaredRepeatableAnnotationsDeclaredOnSuperclass() { + void getDeclaredRepeatableAnnotationsDeclaredOnSuperclass() { final Class clazz = SubMyRepeatableClass.class; // Java 8 @@ -727,7 +727,7 @@ public class AnnotationUtilsTests { } @Test - public void synthesizeAnnotationWithImplicitAliasesWithMissingDefaultValues() throws Exception { + void synthesizeAnnotationWithImplicitAliasesWithMissingDefaultValues() throws Exception { Class clazz = ImplicitAliasesWithMissingDefaultValuesContextConfigClass.class; Class annotationType = ImplicitAliasesWithMissingDefaultValuesContextConfig.class; ImplicitAliasesWithMissingDefaultValuesContextConfig config = clazz.getAnnotation(annotationType); @@ -742,7 +742,7 @@ public class AnnotationUtilsTests { } @Test - public void synthesizeAnnotationWithImplicitAliasesWithDifferentDefaultValues() throws Exception { + void synthesizeAnnotationWithImplicitAliasesWithDifferentDefaultValues() throws Exception { Class clazz = ImplicitAliasesWithDifferentDefaultValuesContextConfigClass.class; Class annotationType = ImplicitAliasesWithDifferentDefaultValuesContextConfig.class; ImplicitAliasesWithDifferentDefaultValuesContextConfig config = clazz.getAnnotation(annotationType); @@ -756,7 +756,7 @@ public class AnnotationUtilsTests { } @Test - public void synthesizeAnnotationWithImplicitAliasesWithDuplicateValues() throws Exception { + void synthesizeAnnotationWithImplicitAliasesWithDuplicateValues() throws Exception { Class clazz = ImplicitAliasesWithDuplicateValuesContextConfigClass.class; Class annotationType = ImplicitAliasesWithDuplicateValuesContextConfig.class; ImplicitAliasesWithDuplicateValuesContextConfig config = clazz.getAnnotation(annotationType); @@ -773,7 +773,7 @@ public class AnnotationUtilsTests { } @Test - public void synthesizeAnnotationFromMapWithoutAttributeAliases() throws Exception { + void synthesizeAnnotationFromMapWithoutAttributeAliases() throws Exception { Component component = WebController.class.getAnnotation(Component.class); assertThat(component).isNotNull(); @@ -788,7 +788,7 @@ public class AnnotationUtilsTests { @Test @SuppressWarnings("unchecked") - public void synthesizeAnnotationFromMapWithNestedMap() throws Exception { + void synthesizeAnnotationFromMapWithNestedMap() throws Exception { ComponentScanSingleFilter componentScan = ComponentScanSingleFilterClass.class.getAnnotation(ComponentScanSingleFilter.class); assertThat(componentScan).isNotNull(); assertThat(componentScan.value().pattern()).as("value from ComponentScan: ").isEqualTo("*Foo"); @@ -816,7 +816,7 @@ public class AnnotationUtilsTests { @Test @SuppressWarnings("unchecked") - public void synthesizeAnnotationFromMapWithNestedArrayOfMaps() throws Exception { + void synthesizeAnnotationFromMapWithNestedArrayOfMaps() throws Exception { ComponentScan componentScan = ComponentScanClass.class.getAnnotation(ComponentScan.class); assertThat(componentScan).isNotNull(); @@ -845,7 +845,7 @@ public class AnnotationUtilsTests { } @Test - public void synthesizeAnnotationFromDefaultsWithoutAttributeAliases() throws Exception { + void synthesizeAnnotationFromDefaultsWithoutAttributeAliases() throws Exception { AnnotationWithDefaults annotationWithDefaults = synthesizeAnnotation(AnnotationWithDefaults.class); assertThat(annotationWithDefaults).isNotNull(); assertThat(annotationWithDefaults.text()).as("text: ").isEqualTo("enigma"); @@ -854,7 +854,7 @@ public class AnnotationUtilsTests { } @Test - public void synthesizeAnnotationFromDefaultsWithAttributeAliases() throws Exception { + void synthesizeAnnotationFromDefaultsWithAttributeAliases() throws Exception { ContextConfig contextConfig = synthesizeAnnotation(ContextConfig.class); assertThat(contextConfig).isNotNull(); assertThat(contextConfig.value()).as("value: ").isEqualTo(""); @@ -862,7 +862,7 @@ public class AnnotationUtilsTests { } @Test - public void synthesizeAnnotationFromMapWithMinimalAttributesWithAttributeAliases() throws Exception { + void synthesizeAnnotationFromMapWithMinimalAttributesWithAttributeAliases() throws Exception { Map map = Collections.singletonMap("location", "test.xml"); ContextConfig contextConfig = synthesizeAnnotation(map, ContextConfig.class, null); assertThat(contextConfig).isNotNull(); @@ -871,7 +871,7 @@ public class AnnotationUtilsTests { } @Test - public void synthesizeAnnotationFromMapWithAttributeAliasesThatOverrideArraysWithSingleElements() throws Exception { + void synthesizeAnnotationFromMapWithAttributeAliasesThatOverrideArraysWithSingleElements() throws Exception { Map map = Collections.singletonMap("value", "/foo"); Get get = synthesizeAnnotation(map, Get.class, null); assertThat(get).isNotNull(); @@ -886,7 +886,7 @@ public class AnnotationUtilsTests { } @Test - public void synthesizeAnnotationFromMapWithImplicitAttributeAliases() throws Exception { + void synthesizeAnnotationFromMapWithImplicitAttributeAliases() throws Exception { assertAnnotationSynthesisFromMapWithImplicitAliases("value"); assertAnnotationSynthesisFromMapWithImplicitAliases("location1"); assertAnnotationSynthesisFromMapWithImplicitAliases("location2"); @@ -908,12 +908,12 @@ public class AnnotationUtilsTests { } @Test - public void synthesizeAnnotationFromMapWithMissingAttributeValue() throws Exception { + void synthesizeAnnotationFromMapWithMissingAttributeValue() throws Exception { assertMissingTextAttribute(Collections.emptyMap()); } @Test - public void synthesizeAnnotationFromMapWithNullAttributeValue() throws Exception { + void synthesizeAnnotationFromMapWithNullAttributeValue() throws Exception { Map map = Collections.singletonMap("text", null); assertThat(map.containsKey("text")).isTrue(); assertMissingTextAttribute(map); @@ -926,7 +926,7 @@ public class AnnotationUtilsTests { } @Test - public void synthesizeAnnotationFromMapWithAttributeOfIncorrectType() throws Exception { + void synthesizeAnnotationFromMapWithAttributeOfIncorrectType() throws Exception { Map map = Collections.singletonMap(VALUE, 42L); assertThatIllegalArgumentException().isThrownBy(() -> synthesizeAnnotation(map, Component.class, null)) @@ -935,7 +935,7 @@ public class AnnotationUtilsTests { } @Test - public void synthesizeAnnotationFromAnnotationAttributesWithoutAttributeAliases() throws Exception { + void synthesizeAnnotationFromAnnotationAttributesWithoutAttributeAliases() throws Exception { // 1) Get an annotation Component component = WebController.class.getAnnotation(Component.class); assertThat(component).isNotNull(); @@ -956,7 +956,7 @@ public class AnnotationUtilsTests { } @Test // gh-22702 - public void findAnnotationWithRepeatablesElements() { + void findAnnotationWithRepeatablesElements() { assertThat(AnnotationUtils.findAnnotation(TestRepeatablesClass.class, TestRepeatable.class)).isNull(); assertThat(AnnotationUtils.findAnnotation(TestRepeatablesClass.class, @@ -1216,6 +1216,7 @@ public class AnnotationUtilsTests { public static class ImplementsInterfaceWithGenericAnnotatedMethod implements InterfaceWithGenericAnnotatedMethod { + @Override public void foo(String t) { } } @@ -1228,6 +1229,7 @@ public class AnnotationUtilsTests { public static class ExtendsBaseClassWithGenericAnnotatedMethod extends BaseClassWithGenericAnnotatedMethod { + @Override public void foo(String t) { } } diff --git a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationsScannerTests.java b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationsScannerTests.java index 9e1704181b..190b0b3330 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationsScannerTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationsScannerTests.java @@ -42,92 +42,92 @@ import static org.assertj.core.api.Assertions.assertThat; * * @author Phillip Webb */ -public class AnnotationsScannerTests { +class AnnotationsScannerTests { @Test - public void directStrategyOnClassWhenNotAnnoatedScansNone() { + void directStrategyOnClassWhenNotAnnoatedScansNone() { Class source = WithNoAnnotations.class; assertThat(scan(source, SearchStrategy.DIRECT)).isEmpty(); } @Test - public void directStrategyOnClassScansAnnotations() { + void directStrategyOnClassScansAnnotations() { Class source = WithSingleAnnotation.class; assertThat(scan(source, SearchStrategy.DIRECT)).containsExactly( "0:TestAnnotation1"); } @Test - public void directStrategyOnClassWhenMultipleAnnotationsScansAnnotations() { + void directStrategyOnClassWhenMultipleAnnotationsScansAnnotations() { Class source = WithMultipleAnnotations.class; assertThat(scan(source, SearchStrategy.DIRECT)).containsExactly( "0:TestAnnotation1", "0:TestAnnotation2"); } @Test - public void directStrategyOnClassWhenHasSuperclassScansOnlyDirect() { + void directStrategyOnClassWhenHasSuperclassScansOnlyDirect() { Class source = WithSingleSuperclass.class; assertThat(scan(source, SearchStrategy.DIRECT)).containsExactly( "0:TestAnnotation1"); } @Test - public void directStrategyOnClassWhenHasInterfaceScansOnlyDirect() { + void directStrategyOnClassWhenHasInterfaceScansOnlyDirect() { Class source = WithSingleInterface.class; assertThat(scan(source, SearchStrategy.DIRECT)).containsExactly( "0:TestAnnotation1"); } @Test - public void directStrategyOnClassHierarchyScansInCorrectOrder() { + void directStrategyOnClassHierarchyScansInCorrectOrder() { Class source = WithHierarchy.class; assertThat(scan(source, SearchStrategy.DIRECT)).containsExactly( "0:TestAnnotation1"); } @Test - public void inheritedAnnotationsStrategyOnClassWhenNotAnnoatedScansNone() { + void inheritedAnnotationsStrategyOnClassWhenNotAnnoatedScansNone() { Class source = WithNoAnnotations.class; assertThat(scan(source, SearchStrategy.INHERITED_ANNOTATIONS)).isEmpty(); } @Test - public void inheritedAnnotationsStrategyOnClassScansAnnotations() { + void inheritedAnnotationsStrategyOnClassScansAnnotations() { Class source = WithSingleAnnotation.class; assertThat(scan(source, SearchStrategy.INHERITED_ANNOTATIONS)).containsExactly( "0:TestAnnotation1"); } @Test - public void inheritedAnnotationsStrategyOnClassWhenMultipleAnnotationsScansAnnotations() { + void inheritedAnnotationsStrategyOnClassWhenMultipleAnnotationsScansAnnotations() { Class source = WithMultipleAnnotations.class; assertThat(scan(source, SearchStrategy.INHERITED_ANNOTATIONS)).containsExactly( "0:TestAnnotation1", "0:TestAnnotation2"); } @Test - public void inheritedAnnotationsStrategyOnClassWhenHasSuperclassScansOnlyInherited() { + void inheritedAnnotationsStrategyOnClassWhenHasSuperclassScansOnlyInherited() { Class source = WithSingleSuperclass.class; assertThat(scan(source, SearchStrategy.INHERITED_ANNOTATIONS)).containsExactly( "0:TestAnnotation1", "1:TestInheritedAnnotation2"); } @Test - public void inheritedAnnotationsStrategyOnClassWhenHasInterfaceDoesNotIncludeInterfaces() { + void inheritedAnnotationsStrategyOnClassWhenHasInterfaceDoesNotIncludeInterfaces() { Class source = WithSingleInterface.class; assertThat(scan(source, SearchStrategy.INHERITED_ANNOTATIONS)).containsExactly( "0:TestAnnotation1"); } @Test - public void inheritedAnnotationsStrategyOnClassHierarchyScansInCorrectOrder() { + void inheritedAnnotationsStrategyOnClassHierarchyScansInCorrectOrder() { Class source = WithHierarchy.class; assertThat(scan(source, SearchStrategy.INHERITED_ANNOTATIONS)).containsExactly( "0:TestAnnotation1", "1:TestInheritedAnnotation2"); } @Test - public void inheritedAnnotationsStrategyOnClassWhenHasAnnotationOnBothClassesIncudesOnlyOne() { + void inheritedAnnotationsStrategyOnClassWhenHasAnnotationOnBothClassesIncudesOnlyOne() { Class source = WithSingleSuperclassAndDoubleInherited.class; assertThat(Arrays.stream(source.getAnnotations()).map( Annotation::annotationType).map(Class::getName)).containsExactly( @@ -137,41 +137,41 @@ public class AnnotationsScannerTests { } @Test - public void superclassStrategyOnClassWhenNotAnnoatedScansNone() { + void superclassStrategyOnClassWhenNotAnnoatedScansNone() { Class source = WithNoAnnotations.class; assertThat(scan(source, SearchStrategy.SUPERCLASS)).isEmpty(); } @Test - public void superclassStrategyOnClassScansAnnotations() { + void superclassStrategyOnClassScansAnnotations() { Class source = WithSingleAnnotation.class; assertThat(scan(source, SearchStrategy.SUPERCLASS)).containsExactly( "0:TestAnnotation1"); } @Test - public void superclassStrategyOnClassWhenMultipleAnnotationsScansAnnotations() { + void superclassStrategyOnClassWhenMultipleAnnotationsScansAnnotations() { Class source = WithMultipleAnnotations.class; assertThat(scan(source, SearchStrategy.SUPERCLASS)).containsExactly( "0:TestAnnotation1", "0:TestAnnotation2"); } @Test - public void superclassStrategyOnClassWhenHasSuperclassScansSuperclass() { + void superclassStrategyOnClassWhenHasSuperclassScansSuperclass() { Class source = WithSingleSuperclass.class; assertThat(scan(source, SearchStrategy.SUPERCLASS)).containsExactly( "0:TestAnnotation1", "1:TestAnnotation2", "1:TestInheritedAnnotation2"); } @Test - public void superclassStrategyOnClassWhenHasInterfaceDoesNotIncludeInterfaces() { + void superclassStrategyOnClassWhenHasInterfaceDoesNotIncludeInterfaces() { Class source = WithSingleInterface.class; assertThat(scan(source, SearchStrategy.SUPERCLASS)).containsExactly( "0:TestAnnotation1"); } @Test - public void superclassStrategyOnClassHierarchyScansInCorrectOrder() { + void superclassStrategyOnClassHierarchyScansInCorrectOrder() { Class source = WithHierarchy.class; assertThat(scan(source, SearchStrategy.SUPERCLASS)).containsExactly( "0:TestAnnotation1", "1:TestAnnotation2", "1:TestInheritedAnnotation2", @@ -179,41 +179,41 @@ public class AnnotationsScannerTests { } @Test - public void typeHierarchyStrategyOnClassWhenNotAnnoatedScansNone() { + void typeHierarchyStrategyOnClassWhenNotAnnoatedScansNone() { Class source = WithNoAnnotations.class; assertThat(scan(source, SearchStrategy.TYPE_HIERARCHY)).isEmpty(); } @Test - public void typeHierarchyStrategyOnClassScansAnnotations() { + void typeHierarchyStrategyOnClassScansAnnotations() { Class source = WithSingleAnnotation.class; assertThat(scan(source, SearchStrategy.TYPE_HIERARCHY)).containsExactly( "0:TestAnnotation1"); } @Test - public void typeHierarchyStrategyOnClassWhenMultipleAnnotationsScansAnnotations() { + void typeHierarchyStrategyOnClassWhenMultipleAnnotationsScansAnnotations() { Class source = WithMultipleAnnotations.class; assertThat(scan(source, SearchStrategy.TYPE_HIERARCHY)).containsExactly( "0:TestAnnotation1", "0:TestAnnotation2"); } @Test - public void typeHierarchyStrategyOnClassWhenHasSuperclassScansSuperclass() { + void typeHierarchyStrategyOnClassWhenHasSuperclassScansSuperclass() { Class source = WithSingleSuperclass.class; assertThat(scan(source, SearchStrategy.TYPE_HIERARCHY)).containsExactly( "0:TestAnnotation1", "1:TestAnnotation2", "1:TestInheritedAnnotation2"); } @Test - public void typeHierarchyStrategyOnClassWhenHasInterfaceDoesNotIncludeInterfaces() { + void typeHierarchyStrategyOnClassWhenHasInterfaceDoesNotIncludeInterfaces() { Class source = WithSingleInterface.class; assertThat(scan(source, SearchStrategy.TYPE_HIERARCHY)).containsExactly( "0:TestAnnotation1", "1:TestAnnotation2", "1:TestInheritedAnnotation2"); } @Test - public void typeHierarchyStrategyOnClassHierarchyScansInCorrectOrder() { + void typeHierarchyStrategyOnClassHierarchyScansInCorrectOrder() { Class source = WithHierarchy.class; assertThat(scan(source, SearchStrategy.TYPE_HIERARCHY)).containsExactly( "0:TestAnnotation1", "1:TestAnnotation5", "1:TestInheritedAnnotation5", @@ -222,123 +222,123 @@ public class AnnotationsScannerTests { } @Test - public void directStrategyOnMethodWhenNotAnnoatedScansNone() { + void directStrategyOnMethodWhenNotAnnoatedScansNone() { Method source = methodFrom(WithNoAnnotations.class); assertThat(scan(source, SearchStrategy.DIRECT)).isEmpty(); } @Test - public void directStrategyOnMethodScansAnnotations() { + void directStrategyOnMethodScansAnnotations() { Method source = methodFrom(WithSingleAnnotation.class); assertThat(scan(source, SearchStrategy.DIRECT)).containsExactly( "0:TestAnnotation1"); } @Test - public void directStrategyOnMethodWhenMultipleAnnotationsScansAnnotations() { + void directStrategyOnMethodWhenMultipleAnnotationsScansAnnotations() { Method source = methodFrom(WithMultipleAnnotations.class); assertThat(scan(source, SearchStrategy.DIRECT)).containsExactly( "0:TestAnnotation1", "0:TestAnnotation2"); } @Test - public void directStrategyOnMethodWhenHasSuperclassScansOnlyDirect() { + void directStrategyOnMethodWhenHasSuperclassScansOnlyDirect() { Method source = methodFrom(WithSingleSuperclass.class); assertThat(scan(source, SearchStrategy.DIRECT)).containsExactly( "0:TestAnnotation1"); } @Test - public void directStrategyOnMethodWhenHasInterfaceScansOnlyDirect() { + void directStrategyOnMethodWhenHasInterfaceScansOnlyDirect() { Method source = methodFrom(WithSingleInterface.class); assertThat(scan(source, SearchStrategy.DIRECT)).containsExactly( "0:TestAnnotation1"); } @Test - public void directStrategyOnMethodHierarchyScansInCorrectOrder() { + void directStrategyOnMethodHierarchyScansInCorrectOrder() { Method source = methodFrom(WithHierarchy.class); assertThat(scan(source, SearchStrategy.DIRECT)).containsExactly( "0:TestAnnotation1"); } @Test - public void inheritedAnnotationsStrategyOnMethodWhenNotAnnoatedScansNone() { + void inheritedAnnotationsStrategyOnMethodWhenNotAnnoatedScansNone() { Method source = methodFrom(WithNoAnnotations.class); assertThat(scan(source, SearchStrategy.INHERITED_ANNOTATIONS)).isEmpty(); } @Test - public void inheritedAnnotationsStrategyOnMethodScansAnnotations() { + void inheritedAnnotationsStrategyOnMethodScansAnnotations() { Method source = methodFrom(WithSingleAnnotation.class); assertThat(scan(source, SearchStrategy.INHERITED_ANNOTATIONS)).containsExactly( "0:TestAnnotation1"); } @Test - public void inheritedAnnotationsStrategyOnMethodWhenMultipleAnnotationsScansAnnotations() { + void inheritedAnnotationsStrategyOnMethodWhenMultipleAnnotationsScansAnnotations() { Method source = methodFrom(WithMultipleAnnotations.class); assertThat(scan(source, SearchStrategy.INHERITED_ANNOTATIONS)).containsExactly( "0:TestAnnotation1", "0:TestAnnotation2"); } @Test - public void inheritedAnnotationsMethodOnMethodWhenHasSuperclassIgnoresInherited() { + void inheritedAnnotationsMethodOnMethodWhenHasSuperclassIgnoresInherited() { Method source = methodFrom(WithSingleSuperclass.class); assertThat(scan(source, SearchStrategy.INHERITED_ANNOTATIONS)).containsExactly( "0:TestAnnotation1"); } @Test - public void inheritedAnnotationsStrategyOnMethodWhenHasInterfaceDoesNotIncludeInterfaces() { + void inheritedAnnotationsStrategyOnMethodWhenHasInterfaceDoesNotIncludeInterfaces() { Method source = methodFrom(WithSingleInterface.class); assertThat(scan(source, SearchStrategy.INHERITED_ANNOTATIONS)).containsExactly( "0:TestAnnotation1"); } @Test - public void inheritedAnnotationsStrategyOnMethodHierarchyScansInCorrectOrder() { + void inheritedAnnotationsStrategyOnMethodHierarchyScansInCorrectOrder() { Method source = methodFrom(WithHierarchy.class); assertThat(scan(source, SearchStrategy.INHERITED_ANNOTATIONS)).containsExactly( "0:TestAnnotation1"); } @Test - public void superclassStrategyOnMethodWhenNotAnnoatedScansNone() { + void superclassStrategyOnMethodWhenNotAnnoatedScansNone() { Method source = methodFrom(WithNoAnnotations.class); assertThat(scan(source, SearchStrategy.SUPERCLASS)).isEmpty(); } @Test - public void superclassStrategyOnMethodScansAnnotations() { + void superclassStrategyOnMethodScansAnnotations() { Method source = methodFrom(WithSingleAnnotation.class); assertThat(scan(source, SearchStrategy.SUPERCLASS)).containsExactly( "0:TestAnnotation1"); } @Test - public void superclassStrategyOnMethodWhenMultipleAnnotationsScansAnnotations() { + void superclassStrategyOnMethodWhenMultipleAnnotationsScansAnnotations() { Method source = methodFrom(WithMultipleAnnotations.class); assertThat(scan(source, SearchStrategy.SUPERCLASS)).containsExactly( "0:TestAnnotation1", "0:TestAnnotation2"); } @Test - public void superclassStrategyOnMethodWhenHasSuperclassScansSuperclass() { + void superclassStrategyOnMethodWhenHasSuperclassScansSuperclass() { Method source = methodFrom(WithSingleSuperclass.class); assertThat(scan(source, SearchStrategy.SUPERCLASS)).containsExactly( "0:TestAnnotation1", "1:TestAnnotation2", "1:TestInheritedAnnotation2"); } @Test - public void superclassStrategyOnMethodWhenHasInterfaceDoesNotIncludeInterfaces() { + void superclassStrategyOnMethodWhenHasInterfaceDoesNotIncludeInterfaces() { Method source = methodFrom(WithSingleInterface.class); assertThat(scan(source, SearchStrategy.SUPERCLASS)).containsExactly( "0:TestAnnotation1"); } @Test - public void superclassStrategyOnMethodHierarchyScansInCorrectOrder() { + void superclassStrategyOnMethodHierarchyScansInCorrectOrder() { Method source = methodFrom(WithHierarchy.class); assertThat(scan(source, SearchStrategy.SUPERCLASS)).containsExactly( "0:TestAnnotation1", "1:TestAnnotation2", "1:TestInheritedAnnotation2", @@ -346,41 +346,41 @@ public class AnnotationsScannerTests { } @Test - public void typeHierarchyStrategyOnMethodWhenNotAnnoatedScansNone() { + void typeHierarchyStrategyOnMethodWhenNotAnnoatedScansNone() { Method source = methodFrom(WithNoAnnotations.class); assertThat(scan(source, SearchStrategy.TYPE_HIERARCHY)).isEmpty(); } @Test - public void typeHierarchyStrategyOnMethodScansAnnotations() { + void typeHierarchyStrategyOnMethodScansAnnotations() { Method source = methodFrom(WithSingleAnnotation.class); assertThat(scan(source, SearchStrategy.TYPE_HIERARCHY)).containsExactly( "0:TestAnnotation1"); } @Test - public void typeHierarchyStrategyOnMethodWhenMultipleAnnotationsScansAnnotations() { + void typeHierarchyStrategyOnMethodWhenMultipleAnnotationsScansAnnotations() { Method source = methodFrom(WithMultipleAnnotations.class); assertThat(scan(source, SearchStrategy.TYPE_HIERARCHY)).containsExactly( "0:TestAnnotation1", "0:TestAnnotation2"); } @Test - public void typeHierarchyStrategyOnMethodWhenHasSuperclassScansSuperclass() { + void typeHierarchyStrategyOnMethodWhenHasSuperclassScansSuperclass() { Method source = methodFrom(WithSingleSuperclass.class); assertThat(scan(source, SearchStrategy.TYPE_HIERARCHY)).containsExactly( "0:TestAnnotation1", "1:TestAnnotation2", "1:TestInheritedAnnotation2"); } @Test - public void typeHierarchyStrategyOnMethodWhenHasInterfaceDoesNotIncludeInterfaces() { + void typeHierarchyStrategyOnMethodWhenHasInterfaceDoesNotIncludeInterfaces() { Method source = methodFrom(WithSingleInterface.class); assertThat(scan(source, SearchStrategy.TYPE_HIERARCHY)).containsExactly( "0:TestAnnotation1", "1:TestAnnotation2", "1:TestInheritedAnnotation2"); } @Test - public void typeHierarchyStrategyOnMethodHierarchyScansInCorrectOrder() { + void typeHierarchyStrategyOnMethodHierarchyScansInCorrectOrder() { Method source = methodFrom(WithHierarchy.class); assertThat(scan(source, SearchStrategy.TYPE_HIERARCHY)).containsExactly( "0:TestAnnotation1", "1:TestAnnotation5", "1:TestInheritedAnnotation5", @@ -389,7 +389,7 @@ public class AnnotationsScannerTests { } @Test - public void typeHierarchyStrategyOnBridgeMethodScansAnnotations() throws Exception { + void typeHierarchyStrategyOnBridgeMethodScansAnnotations() throws Exception { Method source = BridgedMethod.class.getDeclaredMethod("method", Object.class); assertThat(source.isBridge()).isTrue(); assertThat(scan(source, SearchStrategy.TYPE_HIERARCHY)).containsExactly( @@ -397,7 +397,7 @@ public class AnnotationsScannerTests { } @Test - public void typeHierarchyStrategyOnBridgedMethodScansAnnotations() throws Exception { + void typeHierarchyStrategyOnBridgedMethodScansAnnotations() throws Exception { Method source = BridgedMethod.class.getDeclaredMethod("method", String.class); assertThat(source.isBridge()).isFalse(); assertThat(scan(source, SearchStrategy.TYPE_HIERARCHY)).containsExactly( @@ -405,7 +405,7 @@ public class AnnotationsScannerTests { } @Test - public void directStrategyOnBridgeMethodScansAnnotations() throws Exception { + void directStrategyOnBridgeMethodScansAnnotations() throws Exception { Method source = BridgedMethod.class.getDeclaredMethod("method", Object.class); assertThat(source.isBridge()).isTrue(); assertThat(scan(source, SearchStrategy.DIRECT)).containsExactly( @@ -413,7 +413,7 @@ public class AnnotationsScannerTests { } @Test - public void dirextStrategyOnBridgedMethodScansAnnotations() throws Exception { + void dirextStrategyOnBridgedMethodScansAnnotations() throws Exception { Method source = BridgedMethod.class.getDeclaredMethod("method", String.class); assertThat(source.isBridge()).isFalse(); assertThat(scan(source, SearchStrategy.DIRECT)).containsExactly( @@ -421,7 +421,7 @@ public class AnnotationsScannerTests { } @Test - public void typeHierarchyStrategyOnMethodWithIgnorablesScansAnnotations() + void typeHierarchyStrategyOnMethodWithIgnorablesScansAnnotations() throws Exception { Method source = methodFrom(Ignoreable.class); assertThat(scan(source, SearchStrategy.TYPE_HIERARCHY)).containsExactly( @@ -429,7 +429,7 @@ public class AnnotationsScannerTests { } @Test - public void typeHierarchyStrategyOnMethodWithMultipleCandidatesScansAnnotations() + void typeHierarchyStrategyOnMethodWithMultipleCandidatesScansAnnotations() throws Exception { Method source = methodFrom(MultipleMethods.class); assertThat(scan(source, SearchStrategy.TYPE_HIERARCHY)).containsExactly( @@ -437,7 +437,7 @@ public class AnnotationsScannerTests { } @Test - public void typeHierarchyStrategyOnMethodWithGenericParameterOverrideScansAnnotations() + void typeHierarchyStrategyOnMethodWithGenericParameterOverrideScansAnnotations() throws Exception { Method source = ReflectionUtils.findMethod(GenericOverride.class, "method", String.class); @@ -446,7 +446,7 @@ public class AnnotationsScannerTests { } @Test - public void typeHierarchyStrategyOnMethodWithGenericParameterNonOverrideScansAnnotations() + void typeHierarchyStrategyOnMethodWithGenericParameterNonOverrideScansAnnotations() throws Exception { Method source = ReflectionUtils.findMethod(GenericNonOverride.class, "method", StringBuilder.class); @@ -455,21 +455,21 @@ public class AnnotationsScannerTests { } @Test - public void typeHierarchyWithEnclosedStrategyOnEnclosedStaticClassScansAnnotations() { + void typeHierarchyWithEnclosedStrategyOnEnclosedStaticClassScansAnnotations() { Class source = AnnotationEnclosingClassSample.EnclosedStatic.EnclosedStaticStatic.class; assertThat(scan(source, SearchStrategy.TYPE_HIERARCHY_AND_ENCLOSING_CLASSES)) .containsExactly("0:EnclosedThree", "1:EnclosedTwo", "2:EnclosedOne"); } @Test - public void typeHierarchyWithEnclosedStrategyOnEnclosedInnerClassScansAnnotations() { + void typeHierarchyWithEnclosedStrategyOnEnclosedInnerClassScansAnnotations() { Class source = AnnotationEnclosingClassSample.EnclosedInner.EnclosedInnerInner.class; assertThat(scan(source, SearchStrategy.TYPE_HIERARCHY_AND_ENCLOSING_CLASSES)) .containsExactly("0:EnclosedThree", "1:EnclosedTwo", "2:EnclosedOne"); } @Test - public void typeHierarchyWithEnclosedStrategyOnMethodHierarchyUsesTypeHierarchyScan() { + void typeHierarchyWithEnclosedStrategyOnMethodHierarchyUsesTypeHierarchyScan() { Method source = methodFrom(WithHierarchy.class); assertThat(scan(source, SearchStrategy.TYPE_HIERARCHY_AND_ENCLOSING_CLASSES)).containsExactly( "0:TestAnnotation1", "1:TestAnnotation5", "1:TestInheritedAnnotation5", @@ -478,7 +478,7 @@ public class AnnotationsScannerTests { } @Test - public void scanWhenProcessorReturnsFromDoWithAggregateExitsEarly() { + void scanWhenProcessorReturnsFromDoWithAggregateExitsEarly() { String result = AnnotationsScanner.scan(this, WithSingleSuperclass.class, SearchStrategy.TYPE_HIERARCHY, new AnnotationsProcessor() { @@ -500,7 +500,7 @@ public class AnnotationsScannerTests { } @Test - public void scanWhenProcessorReturnsFromDoWithAnnotationsExitsEarly() { + void scanWhenProcessorReturnsFromDoWithAnnotationsExitsEarly() { List indexes = new ArrayList<>(); String result = AnnotationsScanner.scan(this, WithSingleSuperclass.class, SearchStrategy.TYPE_HIERARCHY, @@ -513,7 +513,7 @@ public class AnnotationsScannerTests { } @Test - public void scanWhenProcessorHasFinishMethodUsesFinishResult() { + void scanWhenProcessorHasFinishMethodUsesFinishResult() { String result = AnnotationsScanner.scan(this, WithSingleSuperclass.class, SearchStrategy.TYPE_HIERARCHY, new AnnotationsProcessor() { @@ -651,6 +651,7 @@ public class AnnotationsScannerTests { @TestAnnotation1 static class WithSingleSuperclass extends SingleSuperclass { + @Override @TestAnnotation1 public void method() { } @@ -659,6 +660,7 @@ public class AnnotationsScannerTests { @TestInheritedAnnotation2 static class WithSingleSuperclassAndDoubleInherited extends SingleSuperclass { + @Override @TestAnnotation1 public void method() { } @@ -667,6 +669,7 @@ public class AnnotationsScannerTests { @TestAnnotation1 static class WithSingleInterface implements SingleInterface { + @Override @TestAnnotation1 public void method() { } @@ -684,6 +687,7 @@ public class AnnotationsScannerTests { @TestAnnotation1 static class WithHierarchy extends HierarchySuperclass implements HierarchyInterface { + @Override @TestAnnotation1 public void method() { } @@ -693,6 +697,7 @@ public class AnnotationsScannerTests { @TestInheritedAnnotation2 static class HierarchySuperclass extends HierarchySuperSuperclass { + @Override @TestAnnotation2 @TestInheritedAnnotation2 public void method() { @@ -702,6 +707,7 @@ public class AnnotationsScannerTests { @TestAnnotation3 static class HierarchySuperSuperclass implements HierarchySuperSuperclassInterface { + @Override @TestAnnotation3 public void method() { } @@ -718,6 +724,7 @@ public class AnnotationsScannerTests { @TestInheritedAnnotation5 interface HierarchyInterface extends HierarchyInterfaceInterface { + @Override @TestAnnotation5 @TestInheritedAnnotation5 void method(); @@ -747,6 +754,7 @@ public class AnnotationsScannerTests { @SuppressWarnings("serial") static class Ignoreable implements IgnoreableOverrideInterface1, IgnoreableOverrideInterface2, Serializable { + @Override @TestAnnotation1 public void method() { } @@ -782,6 +790,7 @@ public class AnnotationsScannerTests { static class GenericOverride implements GenericOverrideInterface { + @Override @TestAnnotation1 public void method(String argument) { } diff --git a/spring-core/src/test/java/org/springframework/core/annotation/AttributeMethodsTests.java b/spring-core/src/test/java/org/springframework/core/annotation/AttributeMethodsTests.java index c3728d27f7..6fb0dcdb43 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/AttributeMethodsTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/AttributeMethodsTests.java @@ -36,22 +36,22 @@ import static org.mockito.Mockito.mock; * * @author Phillip Webb */ -public class AttributeMethodsTests { +class AttributeMethodsTests { @Test - public void forAnnotationTypeWhenNullReturnsNone() { + void forAnnotationTypeWhenNullReturnsNone() { AttributeMethods methods = AttributeMethods.forAnnotationType(null); assertThat(methods).isSameAs(AttributeMethods.NONE); } @Test - public void forAnnotationTypeWhenHasNoAttributesReturnsNone() { + void forAnnotationTypeWhenHasNoAttributesReturnsNone() { AttributeMethods methods = AttributeMethods.forAnnotationType(NoAttributes.class); assertThat(methods).isSameAs(AttributeMethods.NONE); } @Test - public void forAnnotationTypeWhenHasMultipleAttributesReturnsAttributes() { + void forAnnotationTypeWhenHasMultipleAttributesReturnsAttributes() { AttributeMethods methods = AttributeMethods.forAnnotationType(MultipleAttributes.class); assertThat(methods.get("value").getName()).isEqualTo("value"); assertThat(methods.get("intValue").getName()).isEqualTo("intValue"); @@ -59,74 +59,74 @@ public class AttributeMethodsTests { } @Test - public void hasOnlyValueAttributeWhenHasOnlyValueAttributeReturnsTrue() { + void hasOnlyValueAttributeWhenHasOnlyValueAttributeReturnsTrue() { AttributeMethods methods = AttributeMethods.forAnnotationType(ValueOnly.class); assertThat(methods.hasOnlyValueAttribute()).isTrue(); } @Test - public void hasOnlyValueAttributeWhenHasOnlySingleNonValueAttributeReturnsFalse() { + void hasOnlyValueAttributeWhenHasOnlySingleNonValueAttributeReturnsFalse() { AttributeMethods methods = AttributeMethods.forAnnotationType(NonValueOnly.class); assertThat(methods.hasOnlyValueAttribute()).isFalse(); } @Test - public void hasOnlyValueAttributeWhenHasOnlyMultipleAttributesIncludingValueReturnsFalse() { + void hasOnlyValueAttributeWhenHasOnlyMultipleAttributesIncludingValueReturnsFalse() { AttributeMethods methods = AttributeMethods.forAnnotationType(MultipleAttributes.class); assertThat(methods.hasOnlyValueAttribute()).isFalse(); } @Test - public void indexOfNameReturnsIndex() { + void indexOfNameReturnsIndex() { AttributeMethods methods = AttributeMethods.forAnnotationType(MultipleAttributes.class); assertThat(methods.indexOf("value")).isEqualTo(1); } @Test - public void indexOfMethodReturnsIndex() throws Exception { + void indexOfMethodReturnsIndex() throws Exception { AttributeMethods methods = AttributeMethods.forAnnotationType(MultipleAttributes.class); Method method = MultipleAttributes.class.getDeclaredMethod("value"); assertThat(methods.indexOf(method)).isEqualTo(1); } @Test - public void sizeReturnsSize() { + void sizeReturnsSize() { AttributeMethods methods = AttributeMethods.forAnnotationType(MultipleAttributes.class); assertThat(methods.size()).isEqualTo(2); } @Test - public void canThrowTypeNotPresentExceptionWhenHasClassAttributeReturnsTrue() { + void canThrowTypeNotPresentExceptionWhenHasClassAttributeReturnsTrue() { AttributeMethods methods = AttributeMethods.forAnnotationType(ClassValue.class); assertThat(methods.canThrowTypeNotPresentException(0)).isTrue(); } @Test - public void canThrowTypeNotPresentExceptionWhenHasClassArrayAttributeReturnsTrue() { + void canThrowTypeNotPresentExceptionWhenHasClassArrayAttributeReturnsTrue() { AttributeMethods methods = AttributeMethods.forAnnotationType(ClassArrayValue.class); assertThat(methods.canThrowTypeNotPresentException(0)).isTrue(); } @Test - public void canThrowTypeNotPresentExceptionWhenNotClassOrClassArrayAttributeReturnsFalse() { + void canThrowTypeNotPresentExceptionWhenNotClassOrClassArrayAttributeReturnsFalse() { AttributeMethods methods = AttributeMethods.forAnnotationType(ValueOnly.class); assertThat(methods.canThrowTypeNotPresentException(0)).isFalse(); } @Test - public void hasDefaultValueMethodWhenHasDefaultValueMethodReturnsTrue() { + void hasDefaultValueMethodWhenHasDefaultValueMethodReturnsTrue() { AttributeMethods methods = AttributeMethods.forAnnotationType(DefaultValueAttribute.class); assertThat(methods.hasDefaultValueMethod()).isTrue(); } @Test - public void hasDefaultValueMethodWhenHasNoDefaultValueMethodsReturnsFalse() { + void hasDefaultValueMethodWhenHasNoDefaultValueMethodsReturnsFalse() { AttributeMethods methods = AttributeMethods.forAnnotationType(MultipleAttributes.class); assertThat(methods.hasDefaultValueMethod()).isFalse(); } @Test - public void isValidWhenHasTypeNotPresentExceptionReturnsFalse() { + void isValidWhenHasTypeNotPresentExceptionReturnsFalse() { ClassValue annotation = mockAnnotation(ClassValue.class); given(annotation.value()).willThrow(TypeNotPresentException.class); AttributeMethods attributes = AttributeMethods.forAnnotationType(annotation.annotationType()); @@ -135,7 +135,7 @@ public class AttributeMethodsTests { @Test @SuppressWarnings({ "unchecked", "rawtypes" }) - public void isValidWhenDoesNotHaveTypeNotPresentExceptionReturnsTrue() { + void isValidWhenDoesNotHaveTypeNotPresentExceptionReturnsTrue() { ClassValue annotation = mock(ClassValue.class); given(annotation.value()).willReturn((Class) InputStream.class); AttributeMethods attributes = AttributeMethods.forAnnotationType(annotation.annotationType()); @@ -143,7 +143,7 @@ public class AttributeMethodsTests { } @Test - public void validateWhenHasTypeNotPresentExceptionThrowsException() { + void validateWhenHasTypeNotPresentExceptionThrowsException() { ClassValue annotation = mockAnnotation(ClassValue.class); given(annotation.value()).willThrow(TypeNotPresentException.class); AttributeMethods attributes = AttributeMethods.forAnnotationType(annotation.annotationType()); @@ -152,7 +152,7 @@ public class AttributeMethodsTests { @Test @SuppressWarnings({ "unchecked", "rawtypes" }) - public void validateWhenDoesNotHaveTypeNotPresentExceptionThrowsNothing() { + void validateWhenDoesNotHaveTypeNotPresentExceptionThrowsNothing() { ClassValue annotation = mockAnnotation(ClassValue.class); given(annotation.value()).willReturn((Class) InputStream.class); AttributeMethods attributes = AttributeMethods.forAnnotationType(annotation.annotationType()); diff --git a/spring-core/src/test/java/org/springframework/core/annotation/ComposedRepeatableAnnotationsTests.java b/spring-core/src/test/java/org/springframework/core/annotation/ComposedRepeatableAnnotationsTests.java index 95eddb1fb6..655013383d 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/ComposedRepeatableAnnotationsTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/ComposedRepeatableAnnotationsTests.java @@ -48,67 +48,67 @@ import static org.springframework.core.annotation.AnnotatedElementUtils.getMerge * @see AnnotatedElementUtilsTests * @see MultipleComposedAnnotationsOnSingleAnnotatedElementTests */ -public class ComposedRepeatableAnnotationsTests { +class ComposedRepeatableAnnotationsTests { @Test - public void getNonRepeatableAnnotation() { + void getNonRepeatableAnnotation() { expectNonRepeatableAnnotation(() -> getMergedRepeatableAnnotations(getClass(), NonRepeatable.class)); } @Test - public void getInvalidRepeatableAnnotationContainerMissingValueAttribute() { + void getInvalidRepeatableAnnotationContainerMissingValueAttribute() { expectContainerMissingValueAttribute(() -> getMergedRepeatableAnnotations(getClass(), InvalidRepeatable.class, ContainerMissingValueAttribute.class)); } @Test - public void getInvalidRepeatableAnnotationContainerWithNonArrayValueAttribute() { + void getInvalidRepeatableAnnotationContainerWithNonArrayValueAttribute() { expectContainerWithNonArrayValueAttribute(() -> getMergedRepeatableAnnotations(getClass(), InvalidRepeatable.class, ContainerWithNonArrayValueAttribute.class)); } @Test - public void getInvalidRepeatableAnnotationContainerWithArrayValueAttributeButWrongComponentType() { + void getInvalidRepeatableAnnotationContainerWithArrayValueAttributeButWrongComponentType() { expectContainerWithArrayValueAttributeButWrongComponentType(() -> getMergedRepeatableAnnotations(getClass(), InvalidRepeatable.class, ContainerWithArrayValueAttributeButWrongComponentType.class)); } @Test - public void getRepeatableAnnotationsOnClass() { + void getRepeatableAnnotationsOnClass() { assertGetRepeatableAnnotations(RepeatableClass.class); } @Test - public void getRepeatableAnnotationsOnSuperclass() { + void getRepeatableAnnotationsOnSuperclass() { assertGetRepeatableAnnotations(SubRepeatableClass.class); } @Test - public void getComposedRepeatableAnnotationsOnClass() { + void getComposedRepeatableAnnotationsOnClass() { assertGetRepeatableAnnotations(ComposedRepeatableClass.class); } @Test - public void getComposedRepeatableAnnotationsMixedWithContainerOnClass() { + void getComposedRepeatableAnnotationsMixedWithContainerOnClass() { assertGetRepeatableAnnotations(ComposedRepeatableMixedWithContainerClass.class); } @Test - public void getComposedContainerForRepeatableAnnotationsOnClass() { + void getComposedContainerForRepeatableAnnotationsOnClass() { assertGetRepeatableAnnotations(ComposedContainerClass.class); } @Test - public void getNoninheritedComposedRepeatableAnnotationsOnClass() { + void getNoninheritedComposedRepeatableAnnotationsOnClass() { Class element = NoninheritedRepeatableClass.class; Set annotations = getMergedRepeatableAnnotations(element, Noninherited.class); assertNoninheritedRepeatableAnnotations(annotations); } @Test - public void getNoninheritedComposedRepeatableAnnotationsOnSuperclass() { + void getNoninheritedComposedRepeatableAnnotationsOnSuperclass() { Class element = SubNoninheritedRepeatableClass.class; Set annotations = getMergedRepeatableAnnotations(element, Noninherited.class); assertThat(annotations).isNotNull(); @@ -116,66 +116,66 @@ public class ComposedRepeatableAnnotationsTests { } @Test - public void findNonRepeatableAnnotation() { + void findNonRepeatableAnnotation() { expectNonRepeatableAnnotation(() -> findMergedRepeatableAnnotations(getClass(), NonRepeatable.class)); } @Test - public void findInvalidRepeatableAnnotationContainerMissingValueAttribute() { + void findInvalidRepeatableAnnotationContainerMissingValueAttribute() { expectContainerMissingValueAttribute(() -> findMergedRepeatableAnnotations(getClass(), InvalidRepeatable.class, ContainerMissingValueAttribute.class)); } @Test - public void findInvalidRepeatableAnnotationContainerWithNonArrayValueAttribute() { + void findInvalidRepeatableAnnotationContainerWithNonArrayValueAttribute() { expectContainerWithNonArrayValueAttribute(() -> findMergedRepeatableAnnotations(getClass(), InvalidRepeatable.class, ContainerWithNonArrayValueAttribute.class)); } @Test - public void findInvalidRepeatableAnnotationContainerWithArrayValueAttributeButWrongComponentType() { + void findInvalidRepeatableAnnotationContainerWithArrayValueAttributeButWrongComponentType() { expectContainerWithArrayValueAttributeButWrongComponentType(() -> findMergedRepeatableAnnotations(getClass(), InvalidRepeatable.class, ContainerWithArrayValueAttributeButWrongComponentType.class)); } @Test - public void findRepeatableAnnotationsOnClass() { + void findRepeatableAnnotationsOnClass() { assertFindRepeatableAnnotations(RepeatableClass.class); } @Test - public void findRepeatableAnnotationsOnSuperclass() { + void findRepeatableAnnotationsOnSuperclass() { assertFindRepeatableAnnotations(SubRepeatableClass.class); } @Test - public void findComposedRepeatableAnnotationsOnClass() { + void findComposedRepeatableAnnotationsOnClass() { assertFindRepeatableAnnotations(ComposedRepeatableClass.class); } @Test - public void findComposedRepeatableAnnotationsMixedWithContainerOnClass() { + void findComposedRepeatableAnnotationsMixedWithContainerOnClass() { assertFindRepeatableAnnotations(ComposedRepeatableMixedWithContainerClass.class); } @Test - public void findNoninheritedComposedRepeatableAnnotationsOnClass() { + void findNoninheritedComposedRepeatableAnnotationsOnClass() { Class element = NoninheritedRepeatableClass.class; Set annotations = findMergedRepeatableAnnotations(element, Noninherited.class); assertNoninheritedRepeatableAnnotations(annotations); } @Test - public void findNoninheritedComposedRepeatableAnnotationsOnSuperclass() { + void findNoninheritedComposedRepeatableAnnotationsOnSuperclass() { Class element = SubNoninheritedRepeatableClass.class; Set annotations = findMergedRepeatableAnnotations(element, Noninherited.class); assertNoninheritedRepeatableAnnotations(annotations); } @Test - public void findComposedContainerForRepeatableAnnotationsOnClass() { + void findComposedContainerForRepeatableAnnotationsOnClass() { assertFindRepeatableAnnotations(ComposedContainerClass.class); } diff --git a/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationClassLoaderTests.java b/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationClassLoaderTests.java index 73782bc946..c21ab51a40 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationClassLoaderTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationClassLoaderTests.java @@ -34,7 +34,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Phillip Webb * @since 5.2 */ -public class MergedAnnotationClassLoaderTests { +class MergedAnnotationClassLoaderTests { private static final String TEST_ANNOTATION = TestAnnotation.class.getName(); @@ -45,7 +45,7 @@ public class MergedAnnotationClassLoaderTests { private static final String TEST_REFERENCE = TestReference.class.getName(); @Test - public void synthesizedUsesCorrectClassLoader() throws Exception { + void synthesizedUsesCorrectClassLoader() throws Exception { ClassLoader parent = getClass().getClassLoader(); TestClassLoader child = new TestClassLoader(parent); Class source = child.loadClass(WITH_TEST_ANNOTATION); diff --git a/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationCollectorsTests.java b/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationCollectorsTests.java index 46d6e45dc5..0aaeb5732c 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationCollectorsTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationCollectorsTests.java @@ -37,10 +37,10 @@ import static org.assertj.core.api.Assertions.assertThat; * * @author Phillip Webb */ -public class MergedAnnotationCollectorsTests { +class MergedAnnotationCollectorsTests { @Test - public void toAnnotationSetCollectsLinkedHashSetWithSynthesizedAnnotations() { + void toAnnotationSetCollectsLinkedHashSetWithSynthesizedAnnotations() { Set set = stream().collect( MergedAnnotationCollectors.toAnnotationSet()); assertThat(set).isInstanceOf(LinkedHashSet.class).flatExtracting( @@ -49,7 +49,7 @@ public class MergedAnnotationCollectorsTests { } @Test - public void toAnnotationArrayCollectsAnnotationArrayWithSynthesizedAnnotations() { + void toAnnotationArrayCollectsAnnotationArrayWithSynthesizedAnnotations() { Annotation[] array = stream().collect( MergedAnnotationCollectors.toAnnotationArray()); assertThat(Arrays.stream(array).map( @@ -59,7 +59,7 @@ public class MergedAnnotationCollectorsTests { } @Test - public void toSuppliedAnnotationArrayCollectsAnnotationArrayWithSynthesizedAnnotations() { + void toSuppliedAnnotationArrayCollectsAnnotationArrayWithSynthesizedAnnotations() { TestAnnotation[] array = stream().collect( MergedAnnotationCollectors.toAnnotationArray(TestAnnotation[]::new)); assertThat(Arrays.stream(array).map(TestAnnotation::value)).containsExactly("a", @@ -68,7 +68,7 @@ public class MergedAnnotationCollectorsTests { } @Test - public void toMultiValueMapCollectsMultiValueMap() { + void toMultiValueMapCollectsMultiValueMap() { MultiValueMap map = stream().map( MergedAnnotation::filterDefaultValues).collect( MergedAnnotationCollectors.toMultiValueMap( @@ -79,7 +79,7 @@ public class MergedAnnotationCollectorsTests { } @Test - public void toFinishedMultiValueMapCollectsMultiValueMap() { + void toFinishedMultiValueMapCollectsMultiValueMap() { MultiValueMap map = stream().collect( MergedAnnotationCollectors.toMultiValueMap(result -> { result.add("finished", true); diff --git a/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationPredicatesTests.java b/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationPredicatesTests.java index a194c2061b..96e94cadea 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationPredicatesTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationPredicatesTests.java @@ -34,10 +34,10 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException * * @author Phillip Webb */ -public class MergedAnnotationPredicatesTests { +class MergedAnnotationPredicatesTests { @Test - public void typeInStringArrayWhenNameMatchesAccepts() { + void typeInStringArrayWhenNameMatchesAccepts() { MergedAnnotation annotation = MergedAnnotations.from( WithTestAnnotation.class).get(TestAnnotation.class); assertThat(MergedAnnotationPredicates.typeIn( @@ -45,7 +45,7 @@ public class MergedAnnotationPredicatesTests { } @Test - public void typeInStringArrayWhenNameDoesNotMatchRejects() { + void typeInStringArrayWhenNameDoesNotMatchRejects() { MergedAnnotation annotation = MergedAnnotations.from( WithTestAnnotation.class).get(TestAnnotation.class); assertThat(MergedAnnotationPredicates.typeIn( @@ -53,21 +53,21 @@ public class MergedAnnotationPredicatesTests { } @Test - public void typeInClassArrayWhenNameMatchesAccepts() { + void typeInClassArrayWhenNameMatchesAccepts() { MergedAnnotation annotation = MergedAnnotations.from(WithTestAnnotation.class).get(TestAnnotation.class); assertThat(MergedAnnotationPredicates.typeIn(TestAnnotation.class)).accepts(annotation); } @Test - public void typeInClassArrayWhenNameDoesNotMatchRejects() { + void typeInClassArrayWhenNameDoesNotMatchRejects() { MergedAnnotation annotation = MergedAnnotations.from(WithTestAnnotation.class).get(TestAnnotation.class); assertThat(MergedAnnotationPredicates.typeIn(MissingAnnotation.class)).rejects(annotation); } @Test - public void typeInCollectionWhenMatchesStringInCollectionAccepts() { + void typeInCollectionWhenMatchesStringInCollectionAccepts() { MergedAnnotation annotation = MergedAnnotations.from( WithTestAnnotation.class).get(TestAnnotation.class); assertThat(MergedAnnotationPredicates.typeIn( @@ -75,7 +75,7 @@ public class MergedAnnotationPredicatesTests { } @Test - public void typeInCollectionWhenMatchesClassInCollectionAccepts() { + void typeInCollectionWhenMatchesClassInCollectionAccepts() { MergedAnnotation annotation = MergedAnnotations.from( WithTestAnnotation.class).get(TestAnnotation.class); assertThat(MergedAnnotationPredicates.typeIn( @@ -83,7 +83,7 @@ public class MergedAnnotationPredicatesTests { } @Test - public void typeInCollectionWhenDoesNotMatchAnyRejects() { + void typeInCollectionWhenDoesNotMatchAnyRejects() { MergedAnnotation annotation = MergedAnnotations.from( WithTestAnnotation.class).get(TestAnnotation.class); assertThat(MergedAnnotationPredicates.typeIn(Arrays.asList( @@ -91,7 +91,7 @@ public class MergedAnnotationPredicatesTests { } @Test - public void firstRunOfAcceptsOnlyFirstRun() { + void firstRunOfAcceptsOnlyFirstRun() { List> filtered = MergedAnnotations.from( WithMultipleTestAnnotation.class).stream(TestAnnotation.class).filter( MergedAnnotationPredicates.firstRunOf( @@ -101,13 +101,13 @@ public class MergedAnnotationPredicatesTests { } @Test - public void firstRunOfWhenValueExtractorIsNullThrowsException() { + void firstRunOfWhenValueExtractorIsNullThrowsException() { assertThatIllegalArgumentException().isThrownBy(() -> MergedAnnotationPredicates.firstRunOf(null)); } @Test - public void uniqueAcceptsUniquely() { + void uniqueAcceptsUniquely() { List> filtered = MergedAnnotations.from( WithMultipleTestAnnotation.class).stream(TestAnnotation.class).filter( MergedAnnotationPredicates.unique( @@ -117,7 +117,7 @@ public class MergedAnnotationPredicatesTests { } @Test - public void uniqueWhenKeyExtractorIsNullThrowsException() { + void uniqueWhenKeyExtractorIsNullThrowsException() { assertThatIllegalArgumentException().isThrownBy(() -> MergedAnnotationPredicates.unique(null)); } diff --git a/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsCollectionTests.java b/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsCollectionTests.java index e25428bd25..e657f7a1c9 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsCollectionTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsCollectionTests.java @@ -36,23 +36,23 @@ import static org.mockito.Mockito.mock; * * @author Phillip Webb */ -public class MergedAnnotationsCollectionTests { +class MergedAnnotationsCollectionTests { @Test - public void ofWhenDirectAnnotationsIsNullThrowsException() { + void ofWhenDirectAnnotationsIsNullThrowsException() { assertThatIllegalArgumentException().isThrownBy( () -> MergedAnnotationsCollection.of(null)).withMessage( "Annotations must not be null"); } @Test - public void ofWhenEmptyReturnsSharedNoneInstance() { + void ofWhenEmptyReturnsSharedNoneInstance() { MergedAnnotations annotations = MergedAnnotationsCollection.of(new ArrayList<>()); assertThat(annotations).isSameAs(TypeMappedAnnotations.NONE); } @Test - public void createWhenAnnotationIsNotDirectlyPresentThrowsException() { + void createWhenAnnotationIsNotDirectlyPresentThrowsException() { MergedAnnotation annotation = mock(MergedAnnotation.class); given(annotation.isDirectlyPresent()).willReturn(false); assertThatIllegalArgumentException().isThrownBy(() -> @@ -61,7 +61,7 @@ public class MergedAnnotationsCollectionTests { } @Test - public void createWhenAnnotationAggregateIndexIsNotZeroThrowsException() { + void createWhenAnnotationAggregateIndexIsNotZeroThrowsException() { MergedAnnotation annotation = mock(MergedAnnotation.class); given(annotation.isDirectlyPresent()).willReturn(true); given(annotation.getAggregateIndex()).willReturn(1); @@ -71,7 +71,7 @@ public class MergedAnnotationsCollectionTests { } @Test - public void interateIteratesInCorrectOrder() { + void interateIteratesInCorrectOrder() { MergedAnnotations annotations = getDirectAndSimple(); List> types = new ArrayList<>(); for (MergedAnnotation annotation : annotations) { @@ -82,7 +82,7 @@ public class MergedAnnotationsCollectionTests { } @Test - public void spliteratorIteratesInCorrectOrder() { + void spliteratorIteratesInCorrectOrder() { MergedAnnotations annotations = getDirectAndSimple(); Spliterator> spliterator = annotations.spliterator(); List> types = new ArrayList<>(); @@ -92,7 +92,7 @@ public class MergedAnnotationsCollectionTests { } @Test - public void spliteratorEstimatesSize() { + void spliteratorEstimatesSize() { MergedAnnotations annotations = getDirectAndSimple(); Spliterator> spliterator = annotations.spliterator(); assertThat(spliterator.estimateSize()).isEqualTo(5); @@ -102,21 +102,21 @@ public class MergedAnnotationsCollectionTests { } @Test - public void isPresentWhenDirectlyPresentReturnsTrue() { + void isPresentWhenDirectlyPresentReturnsTrue() { MergedAnnotations annotations = getDirectAndSimple(); assertThat(annotations.isPresent(Direct.class)).isTrue(); assertThat(annotations.isPresent(Direct.class.getName())).isTrue(); } @Test - public void isPresentWhenMetaPresentReturnsTrue() { + void isPresentWhenMetaPresentReturnsTrue() { MergedAnnotations annotations = getDirectAndSimple(); assertThat(annotations.isPresent(Meta11.class)).isTrue(); assertThat(annotations.isPresent(Meta11.class.getName())).isTrue(); } @Test - public void isPresentWhenNotPresentReturnsFalse() { + void isPresentWhenNotPresentReturnsFalse() { MergedAnnotations annotations = getDirectAndSimple(); assertThat(annotations.isPresent(Missing.class)).isFalse(); assertThat(annotations.isPresent(Missing.class.getName())).isFalse(); @@ -124,28 +124,28 @@ public class MergedAnnotationsCollectionTests { } @Test - public void isDirectlyPresentWhenDirectlyPresentReturnsTrue() { + void isDirectlyPresentWhenDirectlyPresentReturnsTrue() { MergedAnnotations annotations = getDirectAndSimple(); assertThat(annotations.isDirectlyPresent(Direct.class)).isTrue(); assertThat(annotations.isDirectlyPresent(Direct.class.getName())).isTrue(); } @Test - public void isDirectlyPresentWhenMetaPresentReturnsFalse() { + void isDirectlyPresentWhenMetaPresentReturnsFalse() { MergedAnnotations annotations = getDirectAndSimple(); assertThat(annotations.isDirectlyPresent(Meta11.class)).isFalse(); assertThat(annotations.isDirectlyPresent(Meta11.class.getName())).isFalse(); } @Test - public void isDirectlyPresentWhenNotPresentReturnsFalse() { + void isDirectlyPresentWhenNotPresentReturnsFalse() { MergedAnnotations annotations = getDirectAndSimple(); assertThat(annotations.isDirectlyPresent(Missing.class)).isFalse(); assertThat(annotations.isDirectlyPresent(Missing.class.getName())).isFalse(); } @Test - public void getReturnsAppropriateAnnotation() { + void getReturnsAppropriateAnnotation() { MergedAnnotations annotations = getMutiRoute1(); assertThat(annotations.get(MutiRouteTarget.class).getString( MergedAnnotation.VALUE)).isEqualTo("12"); @@ -154,13 +154,13 @@ public class MergedAnnotationsCollectionTests { } @Test - public void getWhenNotPresentReturnsMissing() { + void getWhenNotPresentReturnsMissing() { MergedAnnotations annotations = getDirectAndSimple(); assertThat(annotations.get(Missing.class)).isEqualTo(MergedAnnotation.missing()); } @Test - public void getWithPredicateReturnsOnlyMatching() { + void getWithPredicateReturnsOnlyMatching() { MergedAnnotations annotations = getMutiRoute1(); assertThat(annotations.get(MutiRouteTarget.class, annotation -> annotation.getDistance() >= 3).getString( @@ -168,7 +168,7 @@ public class MergedAnnotationsCollectionTests { } @Test - public void getWithSelectorReturnsSelected() { + void getWithSelectorReturnsSelected() { MergedAnnotations annotations = getMutiRoute1(); MergedAnnotationSelector deepest = (existing, candidate) -> candidate.getDistance() > existing.getDistance() ? candidate @@ -178,7 +178,7 @@ public class MergedAnnotationsCollectionTests { } @Test - public void streamStreamsInCorrectOrder() { + void streamStreamsInCorrectOrder() { MergedAnnotations annotations = getDirectAndSimple(); List> types = new ArrayList<>(); annotations.stream().forEach(annotation -> types.add(annotation.getType())); @@ -187,7 +187,7 @@ public class MergedAnnotationsCollectionTests { } @Test - public void streamWithTypeStreamsInCorrectOrder() { + void streamWithTypeStreamsInCorrectOrder() { MergedAnnotations annotations = getMutiRoute1(); List values = new ArrayList<>(); annotations.stream(MutiRouteTarget.class).forEach( @@ -196,7 +196,7 @@ public class MergedAnnotationsCollectionTests { } @Test - public void getMetaWhenRootHasAttributeValuesShouldAlaisAttributes() { + void getMetaWhenRootHasAttributeValuesShouldAlaisAttributes() { MergedAnnotation root = MergedAnnotation.of(null, null, Alaised.class, Collections.singletonMap("testAlias", "test")); MergedAnnotations annotations = MergedAnnotationsCollection.of( @@ -206,7 +206,7 @@ public class MergedAnnotationsCollectionTests { } @Test - public void getMetaWhenRootHasNoAttributeValuesShouldAlaisAttributes() { + void getMetaWhenRootHasNoAttributeValuesShouldAlaisAttributes() { MergedAnnotation root = MergedAnnotation.of(null, null, Alaised.class, Collections.emptyMap()); MergedAnnotations annotations = MergedAnnotationsCollection.of( diff --git a/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsComposedOnSingleAnnotatedElementTests.java b/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsComposedOnSingleAnnotatedElementTests.java index 2e90e77957..5c6aa83ee1 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsComposedOnSingleAnnotatedElementTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsComposedOnSingleAnnotatedElementTests.java @@ -41,22 +41,22 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Phillip Webb * @author Sam Brannen */ -public class MergedAnnotationsComposedOnSingleAnnotatedElementTests { +class MergedAnnotationsComposedOnSingleAnnotatedElementTests { // See SPR-13486 @Test - public void inheritedStrategyMultipleComposedAnnotationsOnClass() { + void inheritedStrategyMultipleComposedAnnotationsOnClass() { assertInheritedStrategyBehavior(MultipleComposedCachesClass.class); } @Test - public void inheritedStrategyMultipleInheritedComposedAnnotationsOnSuperclass() { + void inheritedStrategyMultipleInheritedComposedAnnotationsOnSuperclass() { assertInheritedStrategyBehavior(SubMultipleComposedCachesClass.class); } @Test - public void inheritedStrategyMultipleNoninheritedComposedAnnotationsOnClass() { + void inheritedStrategyMultipleNoninheritedComposedAnnotationsOnClass() { MergedAnnotations annotations = MergedAnnotations.from( MultipleNoninheritedComposedCachesClass.class, SearchStrategy.INHERITED_ANNOTATIONS); @@ -65,7 +65,7 @@ public class MergedAnnotationsComposedOnSingleAnnotatedElementTests { } @Test - public void inheritedStrategyMultipleNoninheritedComposedAnnotationsOnSuperclass() { + void inheritedStrategyMultipleNoninheritedComposedAnnotationsOnSuperclass() { MergedAnnotations annotations = MergedAnnotations.from( SubMultipleNoninheritedComposedCachesClass.class, SearchStrategy.INHERITED_ANNOTATIONS); @@ -73,12 +73,12 @@ public class MergedAnnotationsComposedOnSingleAnnotatedElementTests { } @Test - public void inheritedStrategyComposedPlusLocalAnnotationsOnClass() { + void inheritedStrategyComposedPlusLocalAnnotationsOnClass() { assertInheritedStrategyBehavior(ComposedPlusLocalCachesClass.class); } @Test - public void inheritedStrategyMultipleComposedAnnotationsOnInterface() { + void inheritedStrategyMultipleComposedAnnotationsOnInterface() { MergedAnnotations annotations = MergedAnnotations.from( MultipleComposedCachesOnInterfaceClass.class, SearchStrategy.INHERITED_ANNOTATIONS); @@ -86,13 +86,13 @@ public class MergedAnnotationsComposedOnSingleAnnotatedElementTests { } @Test - public void inheritedStrategyMultipleComposedAnnotationsOnMethod() throws Exception { + void inheritedStrategyMultipleComposedAnnotationsOnMethod() throws Exception { assertInheritedStrategyBehavior( getClass().getDeclaredMethod("multipleComposedCachesMethod")); } @Test - public void inheritedStrategyComposedPlusLocalAnnotationsOnMethod() throws Exception { + void inheritedStrategyComposedPlusLocalAnnotationsOnMethod() throws Exception { assertInheritedStrategyBehavior( getClass().getDeclaredMethod("composedPlusLocalCachesMethod")); } @@ -105,17 +105,17 @@ public class MergedAnnotationsComposedOnSingleAnnotatedElementTests { } @Test - public void typeHierarchyStrategyMultipleComposedAnnotationsOnClass() { + void typeHierarchyStrategyMultipleComposedAnnotationsOnClass() { assertTypeHierarchyStrategyBehavior(MultipleComposedCachesClass.class); } @Test - public void typeHierarchyStrategyMultipleInheritedComposedAnnotationsOnSuperclass() { + void typeHierarchyStrategyMultipleInheritedComposedAnnotationsOnSuperclass() { assertTypeHierarchyStrategyBehavior(SubMultipleComposedCachesClass.class); } @Test - public void typeHierarchyStrategyMultipleNoninheritedComposedAnnotationsOnClass() { + void typeHierarchyStrategyMultipleNoninheritedComposedAnnotationsOnClass() { MergedAnnotations annotations = MergedAnnotations.from( MultipleNoninheritedComposedCachesClass.class, SearchStrategy.TYPE_HIERARCHY); assertThat(stream(annotations, "value")).containsExactly("noninheritedCache1", @@ -123,7 +123,7 @@ public class MergedAnnotationsComposedOnSingleAnnotatedElementTests { } @Test - public void typeHierarchyStrategyMultipleNoninheritedComposedAnnotationsOnSuperclass() { + void typeHierarchyStrategyMultipleNoninheritedComposedAnnotationsOnSuperclass() { MergedAnnotations annotations = MergedAnnotations.from( SubMultipleNoninheritedComposedCachesClass.class, SearchStrategy.TYPE_HIERARCHY); @@ -132,36 +132,36 @@ public class MergedAnnotationsComposedOnSingleAnnotatedElementTests { } @Test - public void typeHierarchyStrategyComposedPlusLocalAnnotationsOnClass() { + void typeHierarchyStrategyComposedPlusLocalAnnotationsOnClass() { assertTypeHierarchyStrategyBehavior(ComposedPlusLocalCachesClass.class); } @Test - public void typeHierarchyStrategyMultipleComposedAnnotationsOnInterface() { + void typeHierarchyStrategyMultipleComposedAnnotationsOnInterface() { assertTypeHierarchyStrategyBehavior(MultipleComposedCachesOnInterfaceClass.class); } @Test - public void typeHierarchyStrategyComposedCacheOnInterfaceAndLocalCacheOnClass() { + void typeHierarchyStrategyComposedCacheOnInterfaceAndLocalCacheOnClass() { assertTypeHierarchyStrategyBehavior( ComposedCacheOnInterfaceAndLocalCacheClass.class); } @Test - public void typeHierarchyStrategyMultipleComposedAnnotationsOnMethod() throws Exception { + void typeHierarchyStrategyMultipleComposedAnnotationsOnMethod() throws Exception { assertTypeHierarchyStrategyBehavior( getClass().getDeclaredMethod("multipleComposedCachesMethod")); } @Test - public void typeHierarchyStrategyComposedPlusLocalAnnotationsOnMethod() + void typeHierarchyStrategyComposedPlusLocalAnnotationsOnMethod() throws Exception { assertTypeHierarchyStrategyBehavior( getClass().getDeclaredMethod("composedPlusLocalCachesMethod")); } @Test - public void typeHierarchyStrategyMultipleComposedAnnotationsOnBridgeMethod() + void typeHierarchyStrategyMultipleComposedAnnotationsOnBridgeMethod() throws Exception { assertTypeHierarchyStrategyBehavior(getBridgeMethod()); } @@ -173,7 +173,7 @@ public class MergedAnnotationsComposedOnSingleAnnotatedElementTests { assertThat(stream(annotations, "value")).containsExactly("fooCache", "barCache"); } - public Method getBridgeMethod() throws NoSuchMethodException { + Method getBridgeMethod() throws NoSuchMethodException { List methods = new ArrayList<>(); ReflectionUtils.doWithLocalMethods(StringGenericParameter.class, method -> { if ("getFor".equals(method.getName())) { diff --git a/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsRepeatableAnnotationTests.java b/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsRepeatableAnnotationTests.java index 3faa4c41b2..0b9fe0bbdb 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsRepeatableAnnotationTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsRepeatableAnnotationTests.java @@ -42,19 +42,19 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException * @author Phillip Webb * @author Sam Brannen */ -public class MergedAnnotationsRepeatableAnnotationTests { +class MergedAnnotationsRepeatableAnnotationTests { // See SPR-13973 @Test - public void inheritedAnnotationsWhenNonRepeatableThrowsException() { + void inheritedAnnotationsWhenNonRepeatableThrowsException() { assertThatIllegalArgumentException().isThrownBy(() -> getAnnotations(null, NonRepeatable.class, SearchStrategy.INHERITED_ANNOTATIONS, getClass())) .satisfies(this::nonRepeatableRequirements); } @Test - public void inheritedAnnotationsWhenContainerMissingValueAttributeThrowsException() { + void inheritedAnnotationsWhenContainerMissingValueAttributeThrowsException() { assertThatAnnotationConfigurationException().isThrownBy(() -> getAnnotations(ContainerMissingValueAttribute.class, InvalidRepeatable.class, SearchStrategy.INHERITED_ANNOTATIONS, getClass())) @@ -62,7 +62,7 @@ public class MergedAnnotationsRepeatableAnnotationTests { } @Test - public void inheritedAnnotationsWhenWhenNonArrayValueAttributeThrowsException() { + void inheritedAnnotationsWhenWhenNonArrayValueAttributeThrowsException() { assertThatAnnotationConfigurationException().isThrownBy(() -> getAnnotations(ContainerWithNonArrayValueAttribute.class, InvalidRepeatable.class, SearchStrategy.INHERITED_ANNOTATIONS, getClass())) @@ -70,7 +70,7 @@ public class MergedAnnotationsRepeatableAnnotationTests { } @Test - public void inheritedAnnotationsWhenWrongComponentTypeThrowsException() { + void inheritedAnnotationsWhenWrongComponentTypeThrowsException() { assertThatAnnotationConfigurationException().isThrownBy(() -> getAnnotations(ContainerWithArrayValueAttributeButWrongComponentType.class, InvalidRepeatable.class, SearchStrategy.INHERITED_ANNOTATIONS, getClass())) @@ -78,7 +78,7 @@ public class MergedAnnotationsRepeatableAnnotationTests { } @Test - public void inheritedAnnotationsWhenOnClassReturnsAnnotations() { + void inheritedAnnotationsWhenOnClassReturnsAnnotations() { Set annotations = getAnnotations(null, PeteRepeat.class, SearchStrategy.INHERITED_ANNOTATIONS, RepeatableClass.class); assertThat(annotations.stream().map(PeteRepeat::value)).containsExactly("A", "B", @@ -86,7 +86,7 @@ public class MergedAnnotationsRepeatableAnnotationTests { } @Test - public void inheritedAnnotationsWhenWhenOnSuperclassReturnsAnnotations() { + void inheritedAnnotationsWhenWhenOnSuperclassReturnsAnnotations() { Set annotations = getAnnotations(null, PeteRepeat.class, SearchStrategy.INHERITED_ANNOTATIONS, SubRepeatableClass.class); assertThat(annotations.stream().map(PeteRepeat::value)).containsExactly("A", "B", @@ -94,7 +94,7 @@ public class MergedAnnotationsRepeatableAnnotationTests { } @Test - public void inheritedAnnotationsWhenComposedOnClassReturnsAnnotations() { + void inheritedAnnotationsWhenComposedOnClassReturnsAnnotations() { Set annotations = getAnnotations(null, PeteRepeat.class, SearchStrategy.INHERITED_ANNOTATIONS, ComposedRepeatableClass.class); assertThat(annotations.stream().map(PeteRepeat::value)).containsExactly("A", "B", @@ -102,7 +102,7 @@ public class MergedAnnotationsRepeatableAnnotationTests { } @Test - public void inheritedAnnotationsWhenComposedMixedWithContainerOnClassReturnsAnnotations() { + void inheritedAnnotationsWhenComposedMixedWithContainerOnClassReturnsAnnotations() { Set annotations = getAnnotations(null, PeteRepeat.class, SearchStrategy.INHERITED_ANNOTATIONS, ComposedRepeatableMixedWithContainerClass.class); @@ -111,7 +111,7 @@ public class MergedAnnotationsRepeatableAnnotationTests { } @Test - public void inheritedAnnotationsWhenComposedContainerForRepeatableOnClassReturnsAnnotations() { + void inheritedAnnotationsWhenComposedContainerForRepeatableOnClassReturnsAnnotations() { Set annotations = getAnnotations(null, PeteRepeat.class, SearchStrategy.INHERITED_ANNOTATIONS, ComposedContainerClass.class); assertThat(annotations.stream().map(PeteRepeat::value)).containsExactly("A", "B", @@ -119,7 +119,7 @@ public class MergedAnnotationsRepeatableAnnotationTests { } @Test - public void inheritedAnnotationsWhenNoninheritedComposedRepeatableOnClassReturnsAnnotations() { + void inheritedAnnotationsWhenNoninheritedComposedRepeatableOnClassReturnsAnnotations() { Set annotations = getAnnotations(null, Noninherited.class, SearchStrategy.INHERITED_ANNOTATIONS, NoninheritedRepeatableClass.class); assertThat(annotations.stream().map(Noninherited::value)).containsExactly("A", @@ -127,7 +127,7 @@ public class MergedAnnotationsRepeatableAnnotationTests { } @Test - public void inheritedAnnotationsWhenNoninheritedComposedRepeatableOnSuperclassReturnsAnnotations() { + void inheritedAnnotationsWhenNoninheritedComposedRepeatableOnSuperclassReturnsAnnotations() { Set annotations = getAnnotations(null, Noninherited.class, SearchStrategy.INHERITED_ANNOTATIONS, SubNoninheritedRepeatableClass.class); @@ -135,14 +135,14 @@ public class MergedAnnotationsRepeatableAnnotationTests { } @Test - public void typeHierarchyWhenNonRepeatableThrowsException() { + void typeHierarchyWhenNonRepeatableThrowsException() { assertThatIllegalArgumentException().isThrownBy(() -> getAnnotations(null, NonRepeatable.class, SearchStrategy.TYPE_HIERARCHY, getClass())) .satisfies(this::nonRepeatableRequirements); } @Test - public void typeHierarchyWhenContainerMissingValueAttributeThrowsException() { + void typeHierarchyWhenContainerMissingValueAttributeThrowsException() { assertThatAnnotationConfigurationException().isThrownBy(() -> getAnnotations(ContainerMissingValueAttribute.class, InvalidRepeatable.class, SearchStrategy.TYPE_HIERARCHY, getClass())) @@ -150,7 +150,7 @@ public class MergedAnnotationsRepeatableAnnotationTests { } @Test - public void typeHierarchyWhenWhenNonArrayValueAttributeThrowsException() { + void typeHierarchyWhenWhenNonArrayValueAttributeThrowsException() { assertThatAnnotationConfigurationException().isThrownBy(() -> getAnnotations(ContainerWithNonArrayValueAttribute.class, InvalidRepeatable.class, SearchStrategy.TYPE_HIERARCHY, getClass())) @@ -158,7 +158,7 @@ public class MergedAnnotationsRepeatableAnnotationTests { } @Test - public void typeHierarchyWhenWrongComponentTypeThrowsException() { + void typeHierarchyWhenWrongComponentTypeThrowsException() { assertThatAnnotationConfigurationException().isThrownBy(() -> getAnnotations(ContainerWithArrayValueAttributeButWrongComponentType.class, InvalidRepeatable.class, SearchStrategy.TYPE_HIERARCHY, getClass())) @@ -166,7 +166,7 @@ public class MergedAnnotationsRepeatableAnnotationTests { } @Test - public void typeHierarchyWhenOnClassReturnsAnnotations() { + void typeHierarchyWhenOnClassReturnsAnnotations() { Set annotations = getAnnotations(null, PeteRepeat.class, SearchStrategy.TYPE_HIERARCHY, RepeatableClass.class); assertThat(annotations.stream().map(PeteRepeat::value)).containsExactly("A", "B", @@ -174,7 +174,7 @@ public class MergedAnnotationsRepeatableAnnotationTests { } @Test - public void typeHierarchyWhenWhenOnSuperclassReturnsAnnotations() { + void typeHierarchyWhenWhenOnSuperclassReturnsAnnotations() { Set annotations = getAnnotations(null, PeteRepeat.class, SearchStrategy.TYPE_HIERARCHY, SubRepeatableClass.class); assertThat(annotations.stream().map(PeteRepeat::value)).containsExactly("A", "B", @@ -182,7 +182,7 @@ public class MergedAnnotationsRepeatableAnnotationTests { } @Test - public void typeHierarchyWhenComposedOnClassReturnsAnnotations() { + void typeHierarchyWhenComposedOnClassReturnsAnnotations() { Set annotations = getAnnotations(null, PeteRepeat.class, SearchStrategy.TYPE_HIERARCHY, ComposedRepeatableClass.class); assertThat(annotations.stream().map(PeteRepeat::value)).containsExactly("A", "B", @@ -190,7 +190,7 @@ public class MergedAnnotationsRepeatableAnnotationTests { } @Test - public void typeHierarchyWhenComposedMixedWithContainerOnClassReturnsAnnotations() { + void typeHierarchyWhenComposedMixedWithContainerOnClassReturnsAnnotations() { Set annotations = getAnnotations(null, PeteRepeat.class, SearchStrategy.TYPE_HIERARCHY, ComposedRepeatableMixedWithContainerClass.class); @@ -199,7 +199,7 @@ public class MergedAnnotationsRepeatableAnnotationTests { } @Test - public void typeHierarchyWhenComposedContainerForRepeatableOnClassReturnsAnnotations() { + void typeHierarchyWhenComposedContainerForRepeatableOnClassReturnsAnnotations() { Set annotations = getAnnotations(null, PeteRepeat.class, SearchStrategy.TYPE_HIERARCHY, ComposedContainerClass.class); assertThat(annotations.stream().map(PeteRepeat::value)).containsExactly("A", "B", @@ -207,7 +207,7 @@ public class MergedAnnotationsRepeatableAnnotationTests { } @Test - public void typeHierarchyAnnotationsWhenNoninheritedComposedRepeatableOnClassReturnsAnnotations() { + void typeHierarchyAnnotationsWhenNoninheritedComposedRepeatableOnClassReturnsAnnotations() { Set annotations = getAnnotations(null, Noninherited.class, SearchStrategy.TYPE_HIERARCHY, NoninheritedRepeatableClass.class); assertThat(annotations.stream().map(Noninherited::value)).containsExactly("A", @@ -215,7 +215,7 @@ public class MergedAnnotationsRepeatableAnnotationTests { } @Test - public void typeHierarchyAnnotationsWhenNoninheritedComposedRepeatableOnSuperclassReturnsAnnotations() { + void typeHierarchyAnnotationsWhenNoninheritedComposedRepeatableOnSuperclassReturnsAnnotations() { Set annotations = getAnnotations(null, Noninherited.class, SearchStrategy.TYPE_HIERARCHY, SubNoninheritedRepeatableClass.class); assertThat(annotations.stream().map(Noninherited::value)).containsExactly("A", diff --git a/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsTests.java b/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsTests.java index fc5900f7dc..b23f0b5eae 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsTests.java @@ -69,23 +69,23 @@ import static org.assertj.core.api.Assertions.entry; * @see MergedAnnotationsRepeatableAnnotationTests * @see MergedAnnotationClassLoaderTests */ -public class MergedAnnotationsTests { +class MergedAnnotationsTests { @Test - public void streamWhenFromNonAnnotatedClass() { + void streamWhenFromNonAnnotatedClass() { assertThat(MergedAnnotations.from(NonAnnotatedClass.class). stream(TransactionalComponent.class)).isEmpty(); } @Test - public void streamWhenFromClassWithMetaDepth1() { + void streamWhenFromClassWithMetaDepth1() { Stream> classes = MergedAnnotations.from(TransactionalComponent.class) .stream().map(MergedAnnotation::getType); assertThat(classes).containsExactly(Transactional.class, Component.class, Indexed.class); } @Test - public void streamWhenFromClassWithMetaDepth2() { + void streamWhenFromClassWithMetaDepth2() { Stream> classes = MergedAnnotations.from(ComposedTransactionalComponent.class) .stream().map(MergedAnnotation::getType); assertThat(classes).containsExactly(TransactionalComponent.class, @@ -93,26 +93,26 @@ public class MergedAnnotationsTests { } @Test - public void isPresentWhenFromNonAnnotatedClass() { + void isPresentWhenFromNonAnnotatedClass() { assertThat(MergedAnnotations.from(NonAnnotatedClass.class). isPresent(Transactional.class)).isFalse(); } @Test - public void isPresentWhenFromAnnotationClassWithMetaDepth0() { + void isPresentWhenFromAnnotationClassWithMetaDepth0() { assertThat(MergedAnnotations.from(TransactionalComponent.class). isPresent(TransactionalComponent.class)).isFalse(); } @Test - public void isPresentWhenFromAnnotationClassWithMetaDepth1() { + void isPresentWhenFromAnnotationClassWithMetaDepth1() { MergedAnnotations annotations = MergedAnnotations.from(TransactionalComponent.class); assertThat(annotations.isPresent(Transactional.class)).isTrue(); assertThat(annotations.isPresent(Component.class)).isTrue(); } @Test - public void isPresentWhenFromAnnotationClassWithMetaDepth2() { + void isPresentWhenFromAnnotationClassWithMetaDepth2() { MergedAnnotations annotations = MergedAnnotations.from( ComposedTransactionalComponent.class); assertThat(annotations.isPresent(Transactional.class)).isTrue(); @@ -121,19 +121,19 @@ public class MergedAnnotationsTests { } @Test - public void isPresentWhenFromClassWithMetaDepth0() { + void isPresentWhenFromClassWithMetaDepth0() { assertThat(MergedAnnotations.from(TransactionalComponentClass.class).isPresent( TransactionalComponent.class)).isTrue(); } @Test - public void isPresentWhenFromSubclassWithMetaDepth0() { + void isPresentWhenFromSubclassWithMetaDepth0() { assertThat(MergedAnnotations.from(SubTransactionalComponentClass.class).isPresent( TransactionalComponent.class)).isFalse(); } @Test - public void isPresentWhenFromClassWithMetaDepth1() { + void isPresentWhenFromClassWithMetaDepth1() { MergedAnnotations annotations = MergedAnnotations.from( TransactionalComponentClass.class); assertThat(annotations.isPresent(Transactional.class)).isTrue(); @@ -141,7 +141,7 @@ public class MergedAnnotationsTests { } @Test - public void isPresentWhenFromClassWithMetaDepth2() { + void isPresentWhenFromClassWithMetaDepth2() { MergedAnnotations annotations = MergedAnnotations.from( ComposedTransactionalComponentClass.class); assertThat(annotations.isPresent(Transactional.class)).isTrue(); @@ -150,14 +150,14 @@ public class MergedAnnotationsTests { } @Test - public void getParent() { + void getParent() { MergedAnnotations annotations = MergedAnnotations.from(ComposedTransactionalComponentClass.class); assertThat(annotations.get(TransactionalComponent.class).getMetaSource().getType()) .isEqualTo(ComposedTransactionalComponent.class); } @Test - public void getRootWhenNotDirect() { + void getRootWhenNotDirect() { MergedAnnotations annotations = MergedAnnotations.from(ComposedTransactionalComponentClass.class); MergedAnnotation annotation = annotations.get(TransactionalComponent.class); assertThat(annotation.getDistance()).isGreaterThan(0); @@ -165,7 +165,7 @@ public class MergedAnnotationsTests { } @Test - public void getRootWhenDirect() { + void getRootWhenDirect() { MergedAnnotations annotations = MergedAnnotations.from(ComposedTransactionalComponentClass.class); MergedAnnotation annotation = annotations.get(ComposedTransactionalComponent.class); assertThat(annotation.getDistance()).isEqualTo(0); @@ -173,7 +173,7 @@ public class MergedAnnotationsTests { } @Test - public void getMetaTypes() { + void getMetaTypes() { MergedAnnotation annotation = MergedAnnotations.from( ComposedTransactionalComponentClass.class).get( TransactionalComponent.class); @@ -182,7 +182,7 @@ public class MergedAnnotationsTests { } @Test - public void collectMultiValueMapFromNonAnnotatedClass() { + void collectMultiValueMapFromNonAnnotatedClass() { MultiValueMap map = MergedAnnotations.from( NonAnnotatedClass.class).stream(Transactional.class).collect( MergedAnnotationCollectors.toMultiValueMap()); @@ -190,7 +190,7 @@ public class MergedAnnotationsTests { } @Test - public void collectMultiValueMapFromClassWithLocalAnnotation() { + void collectMultiValueMapFromClassWithLocalAnnotation() { MultiValueMap map = MergedAnnotations.from(TxConfig.class).stream( Transactional.class).collect( MergedAnnotationCollectors.toMultiValueMap()); @@ -198,7 +198,7 @@ public class MergedAnnotationsTests { } @Test - public void collectMultiValueMapFromClassWithLocalComposedAnnotationAndInheritedAnnotation() { + void collectMultiValueMapFromClassWithLocalComposedAnnotationAndInheritedAnnotation() { MultiValueMap map = MergedAnnotations.from( SubClassWithInheritedAnnotation.class, SearchStrategy.INHERITED_ANNOTATIONS).stream(Transactional.class).collect( @@ -208,7 +208,7 @@ public class MergedAnnotationsTests { } @Test - public void collectMultiValueMapFavorsInheritedAnnotationsOverMoreLocallyDeclaredComposedAnnotations() { + void collectMultiValueMapFavorsInheritedAnnotationsOverMoreLocallyDeclaredComposedAnnotations() { MultiValueMap map = MergedAnnotations.from( SubSubClassWithInheritedAnnotation.class, SearchStrategy.INHERITED_ANNOTATIONS).stream(Transactional.class).collect( @@ -217,7 +217,7 @@ public class MergedAnnotationsTests { } @Test - public void collectMultiValueMapFavorsInheritedComposedAnnotationsOverMoreLocallyDeclaredComposedAnnotations() { + void collectMultiValueMapFavorsInheritedComposedAnnotationsOverMoreLocallyDeclaredComposedAnnotations() { MultiValueMap map = MergedAnnotations.from( SubSubClassWithInheritedComposedAnnotation.class, SearchStrategy.INHERITED_ANNOTATIONS).stream(Transactional.class).collect( @@ -233,7 +233,7 @@ public class MergedAnnotationsTests { * {@code org.springframework.context.annotation.ProfileCondition} to fail. */ @Test - public void collectMultiValueMapFromClassWithLocalAnnotationThatShadowsAnnotationFromSuperclass() { + void collectMultiValueMapFromClassWithLocalAnnotationThatShadowsAnnotationFromSuperclass() { MultiValueMap map = MergedAnnotations.from(DerivedTxConfig.class, SearchStrategy.INHERITED_ANNOTATIONS).stream(Transactional.class).collect( MergedAnnotationCollectors.toMultiValueMap()); @@ -245,7 +245,7 @@ public class MergedAnnotationsTests { * {@code org.springframework.context.annotation.ProfileCondition}. */ @Test - public void collectMultiValueMapFromClassWithMultipleComposedAnnotations() { + void collectMultiValueMapFromClassWithMultipleComposedAnnotations() { MultiValueMap map = MergedAnnotations.from( TxFromMultipleComposedAnnotations.class, SearchStrategy.INHERITED_ANNOTATIONS).stream(Transactional.class).collect( @@ -255,21 +255,21 @@ public class MergedAnnotationsTests { } @Test - public void getWithInheritedAnnotationsFromClassWithLocalAnnotation() { + void getWithInheritedAnnotationsFromClassWithLocalAnnotation() { MergedAnnotation annotation = MergedAnnotations.from(TxConfig.class, SearchStrategy.INHERITED_ANNOTATIONS).get(Transactional.class); assertThat(annotation.getString("value")).isEqualTo("TxConfig"); } @Test - public void getWithInheritedAnnotationsFromClassWithLocalAnnotationThatShadowsAnnotationFromSuperclass() { + void getWithInheritedAnnotationsFromClassWithLocalAnnotationThatShadowsAnnotationFromSuperclass() { MergedAnnotation annotation = MergedAnnotations.from(DerivedTxConfig.class, SearchStrategy.INHERITED_ANNOTATIONS).get(Transactional.class); assertThat(annotation.getString("value")).isEqualTo("DerivedTxConfig"); } @Test - public void getWithInheritedAnnotationsFromMetaCycleAnnotatedClassWithMissingTargetMetaAnnotation() { + void getWithInheritedAnnotationsFromMetaCycleAnnotatedClassWithMissingTargetMetaAnnotation() { MergedAnnotation annotation = MergedAnnotations.from( MetaCycleAnnotatedClass.class, SearchStrategy.INHERITED_ANNOTATIONS).get( Transactional.class); @@ -277,7 +277,7 @@ public class MergedAnnotationsTests { } @Test - public void getWithInheritedAnnotationsFavorsLocalComposedAnnotationOverInheritedAnnotation() { + void getWithInheritedAnnotationsFavorsLocalComposedAnnotationOverInheritedAnnotation() { MergedAnnotation annotation = MergedAnnotations.from( SubClassWithInheritedAnnotation.class, SearchStrategy.INHERITED_ANNOTATIONS).get(Transactional.class); @@ -285,7 +285,7 @@ public class MergedAnnotationsTests { } @Test - public void getWithInheritedAnnotationsFavorsInheritedAnnotationsOverMoreLocallyDeclaredComposedAnnotations() { + void getWithInheritedAnnotationsFavorsInheritedAnnotationsOverMoreLocallyDeclaredComposedAnnotations() { MergedAnnotation annotation = MergedAnnotations.from( SubSubClassWithInheritedAnnotation.class, SearchStrategy.INHERITED_ANNOTATIONS).get(Transactional.class); @@ -293,7 +293,7 @@ public class MergedAnnotationsTests { } @Test - public void getWithInheritedAnnotationsFavorsInheritedComposedAnnotationsOverMoreLocallyDeclaredComposedAnnotations() { + void getWithInheritedAnnotationsFavorsInheritedComposedAnnotationsOverMoreLocallyDeclaredComposedAnnotations() { MergedAnnotation annotation = MergedAnnotations.from( SubSubClassWithInheritedComposedAnnotation.class, SearchStrategy.INHERITED_ANNOTATIONS).get(Transactional.class); @@ -301,7 +301,7 @@ public class MergedAnnotationsTests { } @Test - public void getWithInheritedAnnotationsFromInterfaceImplementedBySuperclass() { + void getWithInheritedAnnotationsFromInterfaceImplementedBySuperclass() { MergedAnnotation annotation = MergedAnnotations.from( ConcreteClassWithInheritedAnnotation.class, SearchStrategy.INHERITED_ANNOTATIONS).get(Transactional.class); @@ -309,7 +309,7 @@ public class MergedAnnotationsTests { } @Test - public void getWithInheritedAnnotationsFromInheritedAnnotationInterface() { + void getWithInheritedAnnotationsFromInheritedAnnotationInterface() { MergedAnnotation annotation = MergedAnnotations.from( InheritedAnnotationInterface.class, SearchStrategy.INHERITED_ANNOTATIONS).get(Transactional.class); @@ -317,7 +317,7 @@ public class MergedAnnotationsTests { } @Test - public void getWithInheritedAnnotationsFromNonInheritedAnnotationInterface() { + void getWithInheritedAnnotationsFromNonInheritedAnnotationInterface() { MergedAnnotation annotation = MergedAnnotations.from( NonInheritedAnnotationInterface.class, SearchStrategy.INHERITED_ANNOTATIONS).get(Order.class); @@ -325,7 +325,7 @@ public class MergedAnnotationsTests { } @Test - public void getWithInheritedAnnotationsAttributesWithConventionBasedComposedAnnotation() { + void getWithInheritedAnnotationsAttributesWithConventionBasedComposedAnnotation() { MergedAnnotation annotation = MergedAnnotations.from( ConventionBasedComposedContextConfigurationClass.class, SearchStrategy.INHERITED_ANNOTATIONS).get(ContextConfiguration.class); @@ -337,7 +337,7 @@ public class MergedAnnotationsTests { } @Test - public void getWithInheritedAnnotationsFromHalfConventionBasedAndHalfAliasedComposedAnnotation1() { + void getWithInheritedAnnotationsFromHalfConventionBasedAndHalfAliasedComposedAnnotation1() { // SPR-13554: convention mapping mixed with AlaisFor annotations // xmlConfigFiles can be used because it has an AlaisFor annotation MergedAnnotation annotation = MergedAnnotations.from( @@ -350,7 +350,7 @@ public class MergedAnnotationsTests { } @Test - public void WithInheritedAnnotationsFromHalfConventionBasedAndHalfAliasedComposedAnnotation2() { + void withInheritedAnnotationsFromHalfConventionBasedAndHalfAliasedComposedAnnotation2() { // SPR-13554: convention mapping mixed with AlaisFor annotations // locations doesn't apply because it has no AlaisFor annotation MergedAnnotation annotation = MergedAnnotations.from( @@ -361,7 +361,7 @@ public class MergedAnnotationsTests { } @Test - public void WithInheritedAnnotationsFromAliasedComposedAnnotation() { + void withInheritedAnnotationsFromAliasedComposedAnnotation() { MergedAnnotation annotation = MergedAnnotations.from( AliasedComposedContextConfigurationClass.class, SearchStrategy.INHERITED_ANNOTATIONS).get(ContextConfiguration.class); @@ -370,7 +370,7 @@ public class MergedAnnotationsTests { } @Test - public void WithInheritedAnnotationsFromAliasedValueComposedAnnotation() { + void withInheritedAnnotationsFromAliasedValueComposedAnnotation() { MergedAnnotation annotation = MergedAnnotations.from( AliasedValueComposedContextConfigurationClass.class, SearchStrategy.INHERITED_ANNOTATIONS).get(ContextConfiguration.class); @@ -379,7 +379,7 @@ public class MergedAnnotationsTests { } @Test - public void getWithInheritedAnnotationsFromImplicitAliasesInMetaAnnotationOnComposedAnnotation() { + void getWithInheritedAnnotationsFromImplicitAliasesInMetaAnnotationOnComposedAnnotation() { MergedAnnotation annotation = MergedAnnotations.from( ComposedImplicitAliasesContextConfigurationClass.class, SearchStrategy.INHERITED_ANNOTATIONS).get( @@ -394,40 +394,40 @@ public class MergedAnnotationsTests { } @Test - public void getWithInheritedAnnotationsFromAliasedValueComposedAnnotation() { + void getWithInheritedAnnotationsFromAliasedValueComposedAnnotation() { testGetWithInherited(AliasedValueComposedContextConfigurationClass.class, "test.xml"); } @Test - public void getWithInheritedAnnotationsFromImplicitAliasesForSameAttributeInComposedAnnotation() { + void getWithInheritedAnnotationsFromImplicitAliasesForSameAttributeInComposedAnnotation() { testGetWithInherited(ImplicitAliasesContextConfigurationClass1.class, "foo.xml"); testGetWithInherited(ImplicitAliasesContextConfigurationClass2.class, "bar.xml"); testGetWithInherited(ImplicitAliasesContextConfigurationClass3.class, "baz.xml"); } @Test - public void getWithInheritedAnnotationsFromTransitiveImplicitAliases() { + void getWithInheritedAnnotationsFromTransitiveImplicitAliases() { testGetWithInherited(TransitiveImplicitAliasesContextConfigurationClass.class, "test.groovy"); } @Test - public void getWithInheritedAnnotationsFromTransitiveImplicitAliasesWithSingleElementOverridingAnArrayViaAliasFor() { + void getWithInheritedAnnotationsFromTransitiveImplicitAliasesWithSingleElementOverridingAnArrayViaAliasFor() { testGetWithInherited( SingleLocationTransitiveImplicitAliasesContextConfigurationClass.class, "test.groovy"); } @Test - public void getWithInheritedAnnotationsFromTransitiveImplicitAliasesWithSkippedLevel() { + void getWithInheritedAnnotationsFromTransitiveImplicitAliasesWithSkippedLevel() { testGetWithInherited( TransitiveImplicitAliasesWithSkippedLevelContextConfigurationClass.class, "test.xml"); } @Test - public void getWithInheritedAnnotationsFromTransitiveImplicitAliasesWithSkippedLevelWithSingleElementOverridingAnArrayViaAliasFor() { + void getWithInheritedAnnotationsFromTransitiveImplicitAliasesWithSkippedLevelWithSingleElementOverridingAnArrayViaAliasFor() { testGetWithInherited( SingleLocationTransitiveImplicitAliasesWithSkippedLevelContextConfigurationClass.class, "test.xml"); @@ -442,14 +442,14 @@ public class MergedAnnotationsTests { } @Test - public void getWithInheritedAnnotationsFromInvalidConventionBasedComposedAnnotation() { + void getWithInheritedAnnotationsFromInvalidConventionBasedComposedAnnotation() { assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> MergedAnnotations.from(InvalidConventionBasedComposedContextConfigurationClass.class, SearchStrategy.INHERITED_ANNOTATIONS).get(ContextConfiguration.class)); } @Test - public void getWithInheritedAnnotationsFromShadowedAliasComposedAnnotation() { + void getWithInheritedAnnotationsFromShadowedAliasComposedAnnotation() { MergedAnnotation annotation = MergedAnnotations.from( ShadowedAliasComposedContextConfigurationClass.class, SearchStrategy.INHERITED_ANNOTATIONS).get(ContextConfiguration.class); @@ -458,7 +458,7 @@ public class MergedAnnotationsTests { } @Test - public void getWithTypeHierarchyFromInheritedAnnotationInterface() { + void getWithTypeHierarchyFromInheritedAnnotationInterface() { MergedAnnotation annotation = MergedAnnotations.from( InheritedAnnotationInterface.class, SearchStrategy.TYPE_HIERARCHY).get( Transactional.class); @@ -467,7 +467,7 @@ public class MergedAnnotationsTests { } @Test - public void getWithTypeHierarchyFromSubInheritedAnnotationInterface() { + void getWithTypeHierarchyFromSubInheritedAnnotationInterface() { MergedAnnotation annotation = MergedAnnotations.from( SubInheritedAnnotationInterface.class, SearchStrategy.TYPE_HIERARCHY).get( Transactional.class); @@ -476,7 +476,7 @@ public class MergedAnnotationsTests { } @Test - public void getWithTypeHierarchyFromSubSubInheritedAnnotationInterface() { + void getWithTypeHierarchyFromSubSubInheritedAnnotationInterface() { MergedAnnotation annotation = MergedAnnotations.from( SubSubInheritedAnnotationInterface.class, SearchStrategy.TYPE_HIERARCHY).get( Transactional.class); @@ -485,7 +485,7 @@ public class MergedAnnotationsTests { } @Test - public void getWithTypeHierarchyFromNonInheritedAnnotationInterface() { + void getWithTypeHierarchyFromNonInheritedAnnotationInterface() { MergedAnnotation annotation = MergedAnnotations.from( NonInheritedAnnotationInterface.class, SearchStrategy.TYPE_HIERARCHY).get( Order.class); @@ -494,7 +494,7 @@ public class MergedAnnotationsTests { } @Test - public void getWithTypeHierarchyFromSubNonInheritedAnnotationInterface() { + void getWithTypeHierarchyFromSubNonInheritedAnnotationInterface() { MergedAnnotation annotation = MergedAnnotations.from( SubNonInheritedAnnotationInterface.class, SearchStrategy.TYPE_HIERARCHY).get( Order.class); @@ -503,7 +503,7 @@ public class MergedAnnotationsTests { } @Test - public void getWithTypeHierarchyFromSubSubNonInheritedAnnotationInterface() { + void getWithTypeHierarchyFromSubSubNonInheritedAnnotationInterface() { MergedAnnotation annotation = MergedAnnotations.from( SubSubNonInheritedAnnotationInterface.class, SearchStrategy.TYPE_HIERARCHY).get(Order.class); @@ -512,7 +512,7 @@ public class MergedAnnotationsTests { } @Test - public void getWithTypeHierarchyInheritedFromInterfaceMethod() + void getWithTypeHierarchyInheritedFromInterfaceMethod() throws NoSuchMethodException { Method method = ConcreteClassWithInheritedAnnotation.class.getMethod( "handleFromInterface"); @@ -523,7 +523,7 @@ public class MergedAnnotationsTests { } @Test - public void getWithTypeHierarchyInheritedFromAbstractMethod() + void getWithTypeHierarchyInheritedFromAbstractMethod() throws NoSuchMethodException { Method method = ConcreteClassWithInheritedAnnotation.class.getMethod("handle"); MergedAnnotation annotation = MergedAnnotations.from(method, @@ -533,7 +533,7 @@ public class MergedAnnotationsTests { } @Test - public void getWithTypeHierarchyInheritedFromBridgedMethod() + void getWithTypeHierarchyInheritedFromBridgedMethod() throws NoSuchMethodException { Method method = ConcreteClassWithInheritedAnnotation.class.getMethod( "handleParameterized", String.class); @@ -544,7 +544,7 @@ public class MergedAnnotationsTests { } @Test - public void getWithTypeHierarchyFromBridgeMethod() { + void getWithTypeHierarchyFromBridgeMethod() { List methods = new ArrayList<>(); ReflectionUtils.doWithLocalMethods(StringGenericParameter.class, method -> { if ("getFor".equals(method.getName())) { @@ -566,7 +566,7 @@ public class MergedAnnotationsTests { } @Test - public void getWithTypeHierarchyFromClassWithMetaAndLocalTxConfig() { + void getWithTypeHierarchyFromClassWithMetaAndLocalTxConfig() { MergedAnnotation annotation = MergedAnnotations.from( MetaAndLocalTxConfigClass.class, SearchStrategy.TYPE_HIERARCHY).get( Transactional.class); @@ -574,7 +574,7 @@ public class MergedAnnotationsTests { } @Test - public void getWithTypeHierarchyFromClassWithAttributeAliasesInTargetAnnotation() { + void getWithTypeHierarchyFromClassWithAttributeAliasesInTargetAnnotation() { MergedAnnotation mergedAnnotation = MergedAnnotations.from( AliasedTransactionalComponentClass.class, SearchStrategy.TYPE_HIERARCHY).get( AliasedTransactional.class); @@ -587,7 +587,7 @@ public class MergedAnnotationsTests { } @Test - public void getWithTypeHierarchyFromClassWithAttributeAliasInComposedAnnotationAndNestedAnnotationsInTargetAnnotation() { + void getWithTypeHierarchyFromClassWithAttributeAliasInComposedAnnotationAndNestedAnnotationsInTargetAnnotation() { MergedAnnotation annotation = testGetWithTypeHierarchy( TestComponentScanClass.class, "com.example.app.test"); MergedAnnotation[] excludeFilters = annotation.getAnnotationArray( @@ -598,19 +598,19 @@ public class MergedAnnotationsTests { } @Test - public void getWithTypeHierarchyFromClassWithBothAttributesOfAnAliasPairDeclared() { + void getWithTypeHierarchyFromClassWithBothAttributesOfAnAliasPairDeclared() { testGetWithTypeHierarchy(ComponentScanWithBasePackagesAndValueAliasClass.class, "com.example.app.test"); } @Test - public void getWithTypeHierarchyWithSingleElementOverridingAnArrayViaConvention() { + void getWithTypeHierarchyWithSingleElementOverridingAnArrayViaConvention() { testGetWithTypeHierarchy(ConventionBasedSinglePackageComponentScanClass.class, "com.example.app.test"); } @Test - public void getWithTypeHierarchyWithSingleElementOverridingAnArrayViaAliasFor() { + void getWithTypeHierarchyWithSingleElementOverridingAnArrayViaAliasFor() { testGetWithTypeHierarchy(AliasForBasedSinglePackageComponentScanClass.class, "com.example.app.test"); } @@ -625,7 +625,7 @@ public class MergedAnnotationsTests { } @Test - public void getWithTypeHierarchyWhenMultipleMetaAnnotationsHaveClashingAttributeNames() { + void getWithTypeHierarchyWhenMultipleMetaAnnotationsHaveClashingAttributeNames() { MergedAnnotations annotations = MergedAnnotations.from( AliasedComposedContextConfigurationAndTestPropertySourceClass.class, SearchStrategy.TYPE_HIERARCHY); @@ -640,7 +640,7 @@ public class MergedAnnotationsTests { } @Test - public void getWithTypeHierarchyWithLocalAliasesThatConflictWithAttributesInMetaAnnotationByConvention() { + void getWithTypeHierarchyWithLocalAliasesThatConflictWithAttributesInMetaAnnotationByConvention() { MergedAnnotation annotation = MergedAnnotations.from( SpringApplicationConfigurationClass.class, SearchStrategy.TYPE_HIERARCHY).get( ContextConfiguration.class); @@ -650,13 +650,13 @@ public class MergedAnnotationsTests { } @Test - public void getWithTypeHierarchyOnMethodWithSingleElementOverridingAnArrayViaConvention() throws Exception { + void getWithTypeHierarchyOnMethodWithSingleElementOverridingAnArrayViaConvention() throws Exception { testGetWithTypeHierarchyWebMapping( WebController.class.getMethod("postMappedWithPathAttribute")); } @Test - public void getWithTypeHierarchyOnMethodWithSingleElementOverridingAnArrayViaAliasFor() throws Exception { + void getWithTypeHierarchyOnMethodWithSingleElementOverridingAnArrayViaAliasFor() throws Exception { testGetWithTypeHierarchyWebMapping( WebController.class.getMethod("getMappedWithValueAttribute")); testGetWithTypeHierarchyWebMapping( @@ -671,13 +671,13 @@ public class MergedAnnotationsTests { } @Test - public void getDirectWithJavaxAnnotationType() throws Exception { + void getDirectWithJavaxAnnotationType() throws Exception { assertThat(MergedAnnotations.from(ResourceHolder.class).get( Resource.class).getString("name")).isEqualTo("x"); } @Test - public void streamInheritedFromClassWithInterface() throws Exception { + void streamInheritedFromClassWithInterface() throws Exception { Method method = TransactionalServiceImpl.class.getMethod("doIt"); assertThat(MergedAnnotations.from(method, SearchStrategy.INHERITED_ANNOTATIONS).stream( @@ -685,27 +685,27 @@ public class MergedAnnotationsTests { } @Test - public void streamTypeHierarchyFromClassWithInterface() throws Exception { + void streamTypeHierarchyFromClassWithInterface() throws Exception { Method method = TransactionalServiceImpl.class.getMethod("doIt"); assertThat(MergedAnnotations.from(method, SearchStrategy.TYPE_HIERARCHY).stream( Transactional.class)).hasSize(1); } @Test - public void streamTypeHierarchyAndEnclosingClassesFromNonAnnotatedInnerClassWithAnnotatedEnclosingClass() { + void streamTypeHierarchyAndEnclosingClassesFromNonAnnotatedInnerClassWithAnnotatedEnclosingClass() { Stream> classes = MergedAnnotations.from(AnnotatedClass.NonAnnotatedInnerClass.class, SearchStrategy.TYPE_HIERARCHY_AND_ENCLOSING_CLASSES).stream().map(MergedAnnotation::getType); assertThat(classes).containsExactly(Component.class, Indexed.class); } @Test - public void streamTypeHierarchyAndEnclosingClassesFromNonAnnotatedStaticNestedClassWithAnnotatedEnclosingClass() { + void streamTypeHierarchyAndEnclosingClassesFromNonAnnotatedStaticNestedClassWithAnnotatedEnclosingClass() { Stream> classes = MergedAnnotations.from(AnnotatedClass.NonAnnotatedStaticNestedClass.class, SearchStrategy.TYPE_HIERARCHY_AND_ENCLOSING_CLASSES).stream().map(MergedAnnotation::getType); assertThat(classes).containsExactly(Component.class, Indexed.class); } @Test - public void getFromMethodWithMethodAnnotationOnLeaf() throws Exception { + void getFromMethodWithMethodAnnotationOnLeaf() throws Exception { Method method = Leaf.class.getMethod("annotatedOnLeaf"); assertThat(method.getAnnotation(Order.class)).isNotNull(); assertThat(MergedAnnotations.from(method).get(Order.class).getDistance()).isEqualTo( @@ -715,7 +715,7 @@ public class MergedAnnotationsTests { } @Test - public void getFromMethodWithAnnotationOnMethodInInterface() throws Exception { + void getFromMethodWithAnnotationOnMethodInInterface() throws Exception { Method method = Leaf.class.getMethod("fromInterfaceImplementedByRoot"); assertThat(method.getAnnotation(Order.class)).isNull(); assertThat(MergedAnnotations.from(method).get(Order.class).getDistance()).isEqualTo( @@ -725,7 +725,7 @@ public class MergedAnnotationsTests { } @Test - public void getFromMethodWithMetaAnnotationOnLeaf() throws Exception { + void getFromMethodWithMetaAnnotationOnLeaf() throws Exception { Method method = Leaf.class.getMethod("metaAnnotatedOnLeaf"); assertThat(method.getAnnotation(Order.class)).isNull(); assertThat(MergedAnnotations.from(method).get(Order.class).getDistance()).isEqualTo( @@ -735,7 +735,7 @@ public class MergedAnnotationsTests { } @Test - public void getFromMethodWithMetaMetaAnnotationOnLeaf() throws Exception { + void getFromMethodWithMetaMetaAnnotationOnLeaf() throws Exception { Method method = Leaf.class.getMethod("metaMetaAnnotatedOnLeaf"); assertThat(method.getAnnotation(Component.class)).isNull(); assertThat( @@ -746,7 +746,7 @@ public class MergedAnnotationsTests { } @Test - public void getWithAnnotationOnRoot() throws Exception { + void getWithAnnotationOnRoot() throws Exception { Method method = Leaf.class.getMethod("annotatedOnRoot"); assertThat(method.getAnnotation(Order.class)).isNotNull(); assertThat(MergedAnnotations.from(method).get(Order.class).getDistance()).isEqualTo( @@ -756,7 +756,7 @@ public class MergedAnnotationsTests { } @Test - public void getFromMethodWithMetaAnnotationOnRoot() throws Exception { + void getFromMethodWithMetaAnnotationOnRoot() throws Exception { Method method = Leaf.class.getMethod("metaAnnotatedOnRoot"); assertThat(method.getAnnotation(Order.class)).isNull(); assertThat(MergedAnnotations.from(method).get(Order.class).getDistance()).isEqualTo( @@ -766,7 +766,7 @@ public class MergedAnnotationsTests { } @Test - public void getFromMethodWithOnRootButOverridden() throws Exception { + void getFromMethodWithOnRootButOverridden() throws Exception { Method method = Leaf.class.getMethod("overrideWithoutNewAnnotation"); assertThat(method.getAnnotation(Order.class)).isNull(); assertThat(MergedAnnotations.from(method).get(Order.class).getDistance()).isEqualTo( @@ -776,7 +776,7 @@ public class MergedAnnotationsTests { } @Test - public void getFromMethodWithNotAnnotated() throws Exception { + void getFromMethodWithNotAnnotated() throws Exception { Method method = Leaf.class.getMethod("notAnnotated"); assertThat(method.getAnnotation(Order.class)).isNull(); assertThat(MergedAnnotations.from(method).get(Order.class).getDistance()).isEqualTo( @@ -786,7 +786,7 @@ public class MergedAnnotationsTests { } @Test - public void getFromMethodWithBridgeMethod() throws Exception { + void getFromMethodWithBridgeMethod() throws Exception { Method method = TransactionalStringGeneric.class.getMethod("something", Object.class); assertThat(method.isBridge()).isTrue(); @@ -817,7 +817,7 @@ public class MergedAnnotationsTests { } @Test - public void getFromMethodWithBridgedMethod() throws Exception { + void getFromMethodWithBridgedMethod() throws Exception { Method method = TransactionalStringGeneric.class.getMethod("something", String.class); assertThat(method.isBridge()).isFalse(); @@ -834,14 +834,14 @@ public class MergedAnnotationsTests { } @Test - public void getFromMethodWithInterface() throws Exception { + void getFromMethodWithInterface() throws Exception { Method method = ImplementsInterfaceWithAnnotatedMethod.class.getMethod("foo"); assertThat(MergedAnnotations.from(method, SearchStrategy.TYPE_HIERARCHY).get( Order.class).getDistance()).isEqualTo(0); } @Test // SPR-16060 - public void getFromMethodWithGenericInterface() throws Exception { + void getFromMethodWithGenericInterface() throws Exception { Method method = ImplementsInterfaceWithGenericAnnotatedMethod.class.getMethod( "foo", String.class); assertThat(MergedAnnotations.from(method, SearchStrategy.TYPE_HIERARCHY).get( @@ -849,7 +849,7 @@ public class MergedAnnotationsTests { } @Test // SPR-17146 - public void getFromMethodWithGenericSuperclass() throws Exception { + void getFromMethodWithGenericSuperclass() throws Exception { Method method = ExtendsBaseClassWithGenericAnnotatedMethod.class.getMethod("foo", String.class); assertThat(MergedAnnotations.from(method, SearchStrategy.TYPE_HIERARCHY).get( @@ -857,7 +857,7 @@ public class MergedAnnotationsTests { } @Test - public void getFromMethodWithInterfaceOnSuper() throws Exception { + void getFromMethodWithInterfaceOnSuper() throws Exception { Method method = SubOfImplementsInterfaceWithAnnotatedMethod.class.getMethod( "foo"); assertThat(MergedAnnotations.from(method, SearchStrategy.TYPE_HIERARCHY).get( @@ -865,7 +865,7 @@ public class MergedAnnotationsTests { } @Test - public void getFromMethodWhenInterfaceWhenSuperDoesNotImplementMethod() + void getFromMethodWhenInterfaceWhenSuperDoesNotImplementMethod() throws Exception { Method method = SubOfAbstractImplementsInterfaceWithAnnotatedMethod.class.getMethod( "foo"); @@ -874,7 +874,7 @@ public class MergedAnnotationsTests { } @Test - public void getDirectFromClassFavorsMoreLocallyDeclaredComposedAnnotationsOverAnnotationsOnInterfaces() { + void getDirectFromClassFavorsMoreLocallyDeclaredComposedAnnotationsOverAnnotationsOnInterfaces() { MergedAnnotation annotation = MergedAnnotations.from( ClassWithLocalMetaAnnotationAndMetaAnnotatedInterface.class, SearchStrategy.TYPE_HIERARCHY).get(Component.class); @@ -882,7 +882,7 @@ public class MergedAnnotationsTests { } @Test - public void getDirectFromClassFavorsMoreLocallyDeclaredComposedAnnotationsOverInheritedAnnotations() { + void getDirectFromClassFavorsMoreLocallyDeclaredComposedAnnotationsOverInheritedAnnotations() { MergedAnnotation annotation = MergedAnnotations.from( SubSubClassWithInheritedAnnotation.class, SearchStrategy.TYPE_HIERARCHY).get( Transactional.class); @@ -890,7 +890,7 @@ public class MergedAnnotationsTests { } @Test - public void getDirectFromClassFavorsMoreLocallyDeclaredComposedAnnotationsOverInheritedComposedAnnotations() { + void getDirectFromClassFavorsMoreLocallyDeclaredComposedAnnotationsOverInheritedComposedAnnotations() { MergedAnnotation annotation = MergedAnnotations.from( SubSubClassWithInheritedMetaAnnotation.class, SearchStrategy.TYPE_HIERARCHY).get(Component.class); @@ -898,7 +898,7 @@ public class MergedAnnotationsTests { } @Test - public void getDirectFromClassgetDirectFromClassMetaMetaAnnotatedClass() { + void getDirectFromClassgetDirectFromClassMetaMetaAnnotatedClass() { MergedAnnotation annotation = MergedAnnotations.from( MetaMetaAnnotatedClass.class, SearchStrategy.TYPE_HIERARCHY).get( Component.class); @@ -906,7 +906,7 @@ public class MergedAnnotationsTests { } @Test - public void getDirectFromClassWithMetaMetaMetaAnnotatedClass() { + void getDirectFromClassWithMetaMetaMetaAnnotatedClass() { MergedAnnotation annotation = MergedAnnotations.from( MetaMetaMetaAnnotatedClass.class, SearchStrategy.TYPE_HIERARCHY).get( Component.class); @@ -914,7 +914,7 @@ public class MergedAnnotationsTests { } @Test - public void getDirectFromClassWithAnnotatedClassWithMissingTargetMetaAnnotation() { + void getDirectFromClassWithAnnotatedClassWithMissingTargetMetaAnnotation() { // TransactionalClass is NOT annotated or meta-annotated with @Component MergedAnnotation annotation = MergedAnnotations.from(TransactionalClass.class, SearchStrategy.TYPE_HIERARCHY).get(Component.class); @@ -922,7 +922,7 @@ public class MergedAnnotationsTests { } @Test - public void getDirectFromClassWithMetaCycleAnnotatedClassWithMissingTargetMetaAnnotation() { + void getDirectFromClassWithMetaCycleAnnotatedClassWithMissingTargetMetaAnnotation() { MergedAnnotation annotation = MergedAnnotations.from( MetaCycleAnnotatedClass.class, SearchStrategy.TYPE_HIERARCHY).get( Component.class); @@ -930,7 +930,7 @@ public class MergedAnnotationsTests { } @Test - public void getDirectFromClassWithInheritedAnnotationInterface() { + void getDirectFromClassWithInheritedAnnotationInterface() { MergedAnnotation annotation = MergedAnnotations.from( InheritedAnnotationInterface.class, SearchStrategy.TYPE_HIERARCHY).get( Transactional.class); @@ -938,7 +938,7 @@ public class MergedAnnotationsTests { } @Test - public void getDirectFromClassWithSubInheritedAnnotationInterface() { + void getDirectFromClassWithSubInheritedAnnotationInterface() { MergedAnnotation annotation = MergedAnnotations.from( SubInheritedAnnotationInterface.class, SearchStrategy.TYPE_HIERARCHY).get( Transactional.class); @@ -946,7 +946,7 @@ public class MergedAnnotationsTests { } @Test - public void getDirectFromClassWithSubSubInheritedAnnotationInterface() { + void getDirectFromClassWithSubSubInheritedAnnotationInterface() { MergedAnnotation annotation = MergedAnnotations.from( SubSubInheritedAnnotationInterface.class, SearchStrategy.TYPE_HIERARCHY).get( Transactional.class); @@ -954,7 +954,7 @@ public class MergedAnnotationsTests { } @Test - public void getDirectFromClassWithNonInheritedAnnotationInterface() { + void getDirectFromClassWithNonInheritedAnnotationInterface() { MergedAnnotation annotation = MergedAnnotations.from( NonInheritedAnnotationInterface.class, SearchStrategy.TYPE_HIERARCHY).get( Order.class); @@ -962,7 +962,7 @@ public class MergedAnnotationsTests { } @Test - public void getDirectFromClassWithSubNonInheritedAnnotationInterface() { + void getDirectFromClassWithSubNonInheritedAnnotationInterface() { MergedAnnotation annotation = MergedAnnotations.from( SubNonInheritedAnnotationInterface.class, SearchStrategy.TYPE_HIERARCHY).get( Order.class); @@ -970,7 +970,7 @@ public class MergedAnnotationsTests { } @Test - public void getDirectFromClassWithSubSubNonInheritedAnnotationInterface() { + void getDirectFromClassWithSubSubNonInheritedAnnotationInterface() { MergedAnnotation annotation = MergedAnnotations.from( SubSubNonInheritedAnnotationInterface.class, SearchStrategy.TYPE_HIERARCHY).get(Order.class); @@ -978,7 +978,7 @@ public class MergedAnnotationsTests { } @Test - public void getSuperClassForAllScenarios() { + void getSuperClassForAllScenarios() { // no class-level annotation assertThat(MergedAnnotations.from(NonAnnotatedInterface.class, SearchStrategy.SUPERCLASS).get( @@ -1018,7 +1018,7 @@ public class MergedAnnotationsTests { } @Test - public void getSuperClassSourceForTypesWithSingleCandidateType() { + void getSuperClassSourceForTypesWithSingleCandidateType() { // no class-level annotation List> transactionalCandidateList = Collections.singletonList( Transactional.class); @@ -1051,7 +1051,7 @@ public class MergedAnnotationsTests { } @Test - public void getSuperClassSourceForTypesWithMultipleCandidateTypes() { + void getSuperClassSourceForTypesWithMultipleCandidateTypes() { List> candidates = Arrays.asList(Transactional.class, Order.class); // no class-level annotation @@ -1097,7 +1097,7 @@ public class MergedAnnotationsTests { } @Test - public void isDirectlyPresentForAllScenarios() throws Exception { + void isDirectlyPresentForAllScenarios() throws Exception { // no class-level annotation assertThat(MergedAnnotations.from(NonAnnotatedInterface.class).get( Transactional.class).isDirectlyPresent()).isFalse(); @@ -1152,7 +1152,7 @@ public class MergedAnnotationsTests { } @Test - public void getAggregateIndexForAllScenarios() { + void getAggregateIndexForAllScenarios() { // no class-level annotation assertThat(MergedAnnotations.from(NonAnnotatedInterface.class, SearchStrategy.INHERITED_ANNOTATIONS).get( @@ -1192,14 +1192,14 @@ public class MergedAnnotationsTests { } @Test - public void getDirectWithoutAttributeAliases() { + void getDirectWithoutAttributeAliases() { MergedAnnotation annotation = MergedAnnotations.from(WebController.class) .get(Component.class); assertThat(annotation.getString("value")).isEqualTo("webController"); } @Test - public void getDirectWithNestedAnnotations() { + void getDirectWithNestedAnnotations() { MergedAnnotation annotation = MergedAnnotations.from(ComponentScanClass.class) .get(ComponentScan.class); MergedAnnotation[] filters = annotation.getAnnotationArray("excludeFilters", Filter.class); @@ -1208,7 +1208,7 @@ public class MergedAnnotationsTests { } @Test - public void getDirectWithAttributeAliases1() throws Exception { + void getDirectWithAttributeAliases1() throws Exception { Method method = WebController.class.getMethod("handleMappedWithValueAttribute"); MergedAnnotation annotation = MergedAnnotations.from(method).get(RequestMapping.class); assertThat(annotation.getString("name")).isEqualTo("foo"); @@ -1217,7 +1217,7 @@ public class MergedAnnotationsTests { } @Test - public void getDirectWithAttributeAliases2() throws Exception { + void getDirectWithAttributeAliases2() throws Exception { Method method = WebController.class.getMethod("handleMappedWithPathAttribute"); MergedAnnotation annotation = MergedAnnotations.from(method).get(RequestMapping.class); assertThat(annotation.getString("name")).isEqualTo("bar"); @@ -1226,7 +1226,7 @@ public class MergedAnnotationsTests { } @Test - public void getDirectWithAttributeAliasesWithDifferentValues() throws Exception { + void getDirectWithAttributeAliasesWithDifferentValues() throws Exception { Method method = WebController.class.getMethod("handleMappedWithDifferentPathAndValueAttributes"); assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> MergedAnnotations.from(method).get(RequestMapping.class)) @@ -1235,7 +1235,7 @@ public class MergedAnnotationsTests { } @Test - public void getValueFromAnnotation() throws Exception { + void getValueFromAnnotation() throws Exception { Method method = TransactionalStringGeneric.class.getMethod("something", Object.class); MergedAnnotation annotation = MergedAnnotations.from(method, SearchStrategy.TYPE_HIERARCHY) .get(Order.class); @@ -1243,7 +1243,7 @@ public class MergedAnnotationsTests { } @Test - public void getValueFromNonPublicAnnotation() throws Exception { + void getValueFromNonPublicAnnotation() throws Exception { Annotation[] declaredAnnotations = NonPublicAnnotatedClass.class.getDeclaredAnnotations(); assertThat(declaredAnnotations).hasSize(1); Annotation annotation = declaredAnnotations[0]; @@ -1254,7 +1254,7 @@ public class MergedAnnotationsTests { } @Test - public void getDefaultValueFromAnnotation() throws Exception { + void getDefaultValueFromAnnotation() throws Exception { Method method = TransactionalStringGeneric.class.getMethod("something", Object.class); MergedAnnotation annotation = MergedAnnotations.from(method, SearchStrategy.TYPE_HIERARCHY) .get(Order.class); @@ -1262,7 +1262,7 @@ public class MergedAnnotationsTests { } @Test - public void getDefaultValueFromNonPublicAnnotation() { + void getDefaultValueFromNonPublicAnnotation() { Annotation[] declaredAnnotations = NonPublicAnnotatedClass.class.getDeclaredAnnotations(); assertThat(declaredAnnotations).hasSize(1); Annotation declaredAnnotation = declaredAnnotations[0]; @@ -1273,14 +1273,14 @@ public class MergedAnnotationsTests { } @Test - public void getDefaultValueFromAnnotationType() { + void getDefaultValueFromAnnotationType() { MergedAnnotation annotation = MergedAnnotation.of(Order.class); assertThat(annotation.getDefaultValue("value")).contains( Ordered.LOWEST_PRECEDENCE); } @Test - public void getRepeatableDeclaredOnMethod() throws Exception { + void getRepeatableDeclaredOnMethod() throws Exception { Method method = InterfaceWithRepeated.class.getMethod("foo"); Stream> annotations = MergedAnnotations.from( method, SearchStrategy.TYPE_HIERARCHY).stream(MyRepeatable.class); @@ -1290,7 +1290,7 @@ public class MergedAnnotationsTests { } @Test - public void getRepeatableDeclaredOnClassWithMissingAttributeAliasDeclaration() { + void getRepeatableDeclaredOnClassWithMissingAttributeAliasDeclaration() { RepeatableContainers containers = RepeatableContainers.of( BrokenContextConfiguration.class, BrokenHierarchy.class); assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> @@ -1302,7 +1302,7 @@ public class MergedAnnotationsTests { } @Test - public void getRepeatableDeclaredOnClassWithAttributeAliases() { + void getRepeatableDeclaredOnClassWithAttributeAliases() { assertThat(MergedAnnotations.from(HierarchyClass.class).stream( TestConfiguration.class)).isEmpty(); RepeatableContainers containers = RepeatableContainers.of(TestConfiguration.class, @@ -1317,7 +1317,7 @@ public class MergedAnnotationsTests { } @Test - public void getRepeatableDeclaredOnClass() { + void getRepeatableDeclaredOnClass() { Class element = MyRepeatableClass.class; String[] expectedValuesJava = { "A", "B", "C" }; String[] expectedValuesSpring = { "A", "B", "C", "meta1" }; @@ -1326,7 +1326,7 @@ public class MergedAnnotationsTests { } @Test - public void getRepeatableDeclaredOnSuperclass() { + void getRepeatableDeclaredOnSuperclass() { Class element = SubMyRepeatableClass.class; String[] expectedValuesJava = { "A", "B", "C" }; String[] expectedValuesSpring = { "A", "B", "C", "meta1" }; @@ -1335,7 +1335,7 @@ public class MergedAnnotationsTests { } @Test - public void getRepeatableDeclaredOnClassAndSuperclass() { + void getRepeatableDeclaredOnClassAndSuperclass() { Class element = SubMyRepeatableWithAdditionalLocalDeclarationsClass.class; String[] expectedValuesJava = { "X", "Y", "Z" }; String[] expectedValuesSpring = { "X", "Y", "Z", "meta2" }; @@ -1344,7 +1344,7 @@ public class MergedAnnotationsTests { } @Test - public void getRepeatableDeclaredOnMultipleSuperclasses() { + void getRepeatableDeclaredOnMultipleSuperclasses() { Class element = SubSubMyRepeatableWithAdditionalLocalDeclarationsClass.class; String[] expectedValuesJava = { "X", "Y", "Z" }; String[] expectedValuesSpring = { "X", "Y", "Z", "meta2" }; @@ -1353,7 +1353,7 @@ public class MergedAnnotationsTests { } @Test - public void getDirectRepeatablesDeclaredOnClass() { + void getDirectRepeatablesDeclaredOnClass() { Class element = MyRepeatableClass.class; String[] expectedValuesJava = { "A", "B", "C" }; String[] expectedValuesSpring = { "A", "B", "C", "meta1" }; @@ -1362,7 +1362,7 @@ public class MergedAnnotationsTests { } @Test - public void getDirectRepeatablesDeclaredOnSuperclass() { + void getDirectRepeatablesDeclaredOnSuperclass() { Class element = SubMyRepeatableClass.class; String[] expectedValuesJava = {}; String[] expectedValuesSpring = {}; @@ -1409,7 +1409,7 @@ public class MergedAnnotationsTests { } @Test - public void synthesizeWithoutAttributeAliases() throws Exception { + void synthesizeWithoutAttributeAliases() throws Exception { Component component = WebController.class.getAnnotation(Component.class); assertThat(component).isNotNull(); Component synthesizedComponent = MergedAnnotation.from(component).synthesize(); @@ -1419,7 +1419,7 @@ public class MergedAnnotationsTests { } @Test - public void synthesizeAlreadySynthesized() throws Exception { + void synthesizeAlreadySynthesized() throws Exception { Method method = WebController.class.getMethod("handleMappedWithValueAttribute"); RequestMapping webMapping = method.getAnnotation(RequestMapping.class); assertThat(webMapping).isNotNull(); @@ -1436,7 +1436,7 @@ public class MergedAnnotationsTests { } @Test - public void synthesizeWhenAliasForIsMissingAttributeDeclaration() throws Exception { + void synthesizeWhenAliasForIsMissingAttributeDeclaration() throws Exception { AliasForWithMissingAttributeDeclaration annotation = AliasForWithMissingAttributeDeclarationClass.class.getAnnotation( AliasForWithMissingAttributeDeclaration.class); assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> @@ -1447,7 +1447,7 @@ public class MergedAnnotationsTests { } @Test - public void synthesizeWhenAliasForHasDuplicateAttributeDeclaration() + void synthesizeWhenAliasForHasDuplicateAttributeDeclaration() throws Exception { AliasForWithDuplicateAttributeDeclaration annotation = AliasForWithDuplicateAttributeDeclarationClass.class.getAnnotation( AliasForWithDuplicateAttributeDeclaration.class); @@ -1459,7 +1459,7 @@ public class MergedAnnotationsTests { } @Test - public void synthesizeWhenAttributeAliasForNonexistentAttribute() throws Exception { + void synthesizeWhenAttributeAliasForNonexistentAttribute() throws Exception { AliasForNonexistentAttribute annotation = AliasForNonexistentAttributeClass.class.getAnnotation( AliasForNonexistentAttribute.class); assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> @@ -1470,7 +1470,7 @@ public class MergedAnnotationsTests { } @Test - public void synthesizeWhenAttributeAliasWithoutMirroredAliasFor() throws Exception { + void synthesizeWhenAttributeAliasWithoutMirroredAliasFor() throws Exception { AliasForWithoutMirroredAliasFor annotation = AliasForWithoutMirroredAliasForClass.class.getAnnotation( AliasForWithoutMirroredAliasFor.class); assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> @@ -1481,7 +1481,7 @@ public class MergedAnnotationsTests { } @Test - public void synthesizeWhenAttributeAliasWithMirroredAliasForWrongAttribute() + void synthesizeWhenAttributeAliasWithMirroredAliasForWrongAttribute() throws Exception { AliasForWithMirroredAliasForWrongAttribute annotation = AliasForWithMirroredAliasForWrongAttributeClass.class.getAnnotation( AliasForWithMirroredAliasForWrongAttribute.class); @@ -1493,7 +1493,7 @@ public class MergedAnnotationsTests { } @Test - public void synthesizeWhenAttributeAliasForAttributeOfDifferentType() + void synthesizeWhenAttributeAliasForAttributeOfDifferentType() throws Exception { AliasForAttributeOfDifferentType annotation = AliasForAttributeOfDifferentTypeClass.class.getAnnotation( AliasForAttributeOfDifferentType.class); @@ -1507,7 +1507,7 @@ public class MergedAnnotationsTests { } @Test - public void synthesizeWhenAttributeAliasForWithMissingDefaultValues() + void synthesizeWhenAttributeAliasForWithMissingDefaultValues() throws Exception { AliasForWithMissingDefaultValues annotation = AliasForWithMissingDefaultValuesClass.class.getAnnotation( AliasForWithMissingDefaultValues.class); @@ -1521,7 +1521,7 @@ public class MergedAnnotationsTests { } @Test - public void synthesizeWhenAttributeAliasForAttributeWithDifferentDefaultValue() + void synthesizeWhenAttributeAliasForAttributeWithDifferentDefaultValue() throws Exception { AliasForAttributeWithDifferentDefaultValue annotation = AliasForAttributeWithDifferentDefaultValueClass.class.getAnnotation( AliasForAttributeWithDifferentDefaultValue.class); @@ -1535,7 +1535,7 @@ public class MergedAnnotationsTests { } @Test - public void synthesizeWhenAttributeAliasForMetaAnnotationThatIsNotMetaPresent() + void synthesizeWhenAttributeAliasForMetaAnnotationThatIsNotMetaPresent() throws Exception { AliasedComposedTestConfigurationNotMetaPresent annotation = AliasedComposedTestConfigurationNotMetaPresentClass.class.getAnnotation( AliasedComposedTestConfigurationNotMetaPresent.class); @@ -1549,7 +1549,7 @@ public class MergedAnnotationsTests { } @Test - public void synthesizeWithImplicitAliases() throws Exception { + void synthesizeWithImplicitAliases() throws Exception { testSynthesisWithImplicitAliases(ValueImplicitAliasesTestConfigurationClass.class, "value"); testSynthesisWithImplicitAliases( @@ -1575,7 +1575,7 @@ public class MergedAnnotationsTests { } @Test - public void synthesizeWithImplicitAliasesWithImpliedAliasNamesOmitted() + void synthesizeWithImplicitAliasesWithImpliedAliasNamesOmitted() throws Exception { testSynthesisWithImplicitAliasesWithImpliedAliasNamesOmitted( ValueImplicitAliasesWithImpliedAliasNamesOmittedTestConfigurationClass.class, @@ -1602,7 +1602,7 @@ public class MergedAnnotationsTests { } @Test - public void synthesizeWithImplicitAliasesForAliasPair() throws Exception { + void synthesizeWithImplicitAliasesForAliasPair() throws Exception { ImplicitAliasesForAliasPairTestConfiguration config = ImplicitAliasesForAliasPairTestConfigurationClass.class.getAnnotation( ImplicitAliasesForAliasPairTestConfiguration.class); ImplicitAliasesForAliasPairTestConfiguration synthesized = MergedAnnotation.from( @@ -1613,7 +1613,7 @@ public class MergedAnnotationsTests { } @Test - public void synthesizeWithTransitiveImplicitAliases() throws Exception { + void synthesizeWithTransitiveImplicitAliases() throws Exception { TransitiveImplicitAliasesTestConfiguration config = TransitiveImplicitAliasesTestConfigurationClass.class.getAnnotation( TransitiveImplicitAliasesTestConfiguration.class); TransitiveImplicitAliasesTestConfiguration synthesized = MergedAnnotation.from( @@ -1624,7 +1624,7 @@ public class MergedAnnotationsTests { } @Test - public void synthesizeWithTransitiveImplicitAliasesForAliasPair() throws Exception { + void synthesizeWithTransitiveImplicitAliasesForAliasPair() throws Exception { TransitiveImplicitAliasesForAliasPairTestConfiguration config = TransitiveImplicitAliasesForAliasPairTestConfigurationClass.class.getAnnotation( TransitiveImplicitAliasesForAliasPairTestConfiguration.class); TransitiveImplicitAliasesForAliasPairTestConfiguration synthesized = MergedAnnotation.from( @@ -1635,7 +1635,7 @@ public class MergedAnnotationsTests { } @Test - public void synthesizeWithImplicitAliasesWithMissingDefaultValues() throws Exception { + void synthesizeWithImplicitAliasesWithMissingDefaultValues() throws Exception { Class clazz = ImplicitAliasesWithMissingDefaultValuesTestConfigurationClass.class; Class annotationType = ImplicitAliasesWithMissingDefaultValuesTestConfiguration.class; ImplicitAliasesWithMissingDefaultValuesTestConfiguration config = clazz.getAnnotation( @@ -1649,7 +1649,7 @@ public class MergedAnnotationsTests { } @Test - public void synthesizeWithImplicitAliasesWithDifferentDefaultValues() + void synthesizeWithImplicitAliasesWithDifferentDefaultValues() throws Exception { Class clazz = ImplicitAliasesWithDifferentDefaultValuesTestConfigurationClass.class; Class annotationType = ImplicitAliasesWithDifferentDefaultValuesTestConfiguration.class; @@ -1664,7 +1664,7 @@ public class MergedAnnotationsTests { } @Test - public void synthesizeWithImplicitAliasesWithDuplicateValues() throws Exception { + void synthesizeWithImplicitAliasesWithDuplicateValues() throws Exception { Class clazz = ImplicitAliasesWithDuplicateValuesTestConfigurationClass.class; Class annotationType = ImplicitAliasesWithDuplicateValuesTestConfiguration.class; ImplicitAliasesWithDuplicateValuesTestConfiguration config = clazz.getAnnotation( @@ -1679,7 +1679,7 @@ public class MergedAnnotationsTests { } @Test - public void synthesizeFromMapWithoutAttributeAliases() throws Exception { + void synthesizeFromMapWithoutAttributeAliases() throws Exception { Component component = WebController.class.getAnnotation(Component.class); assertThat(component).isNotNull(); Map map = Collections.singletonMap("value", "webController"); @@ -1692,7 +1692,7 @@ public class MergedAnnotationsTests { @Test @SuppressWarnings("unchecked") - public void synthesizeFromMapWithNestedMap() throws Exception { + void synthesizeFromMapWithNestedMap() throws Exception { ComponentScanSingleFilter componentScan = ComponentScanSingleFilterClass.class.getAnnotation( ComponentScanSingleFilter.class); assertThat(componentScan).isNotNull(); @@ -1713,7 +1713,7 @@ public class MergedAnnotationsTests { @Test @SuppressWarnings("unchecked") - public void synthesizeFromMapWithNestedArrayOfMaps() throws Exception { + void synthesizeFromMapWithNestedArrayOfMaps() throws Exception { ComponentScan componentScan = ComponentScanClass.class.getAnnotation( ComponentScan.class); assertThat(componentScan).isNotNull(); @@ -1737,7 +1737,7 @@ public class MergedAnnotationsTests { } @Test - public void synthesizeFromDefaultsWithoutAttributeAliases() throws Exception { + void synthesizeFromDefaultsWithoutAttributeAliases() throws Exception { MergedAnnotation annotation = MergedAnnotation.of( AnnotationWithDefaults.class); AnnotationWithDefaults synthesized = annotation.synthesize(); @@ -1747,7 +1747,7 @@ public class MergedAnnotationsTests { } @Test - public void synthesizeFromDefaultsWithAttributeAliases() throws Exception { + void synthesizeFromDefaultsWithAttributeAliases() throws Exception { MergedAnnotation annotation = MergedAnnotation.of( TestConfiguration.class); TestConfiguration synthesized = annotation.synthesize(); @@ -1756,13 +1756,13 @@ public class MergedAnnotationsTests { } @Test - public void synthesizeWhenAttributeAliasesWithDifferentValues() throws Exception { + void synthesizeWhenAttributeAliasesWithDifferentValues() throws Exception { assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> MergedAnnotation.from(TestConfigurationMismatch.class.getAnnotation(TestConfiguration.class)).synthesize()); } @Test - public void synthesizeFromMapWithMinimalAttributesWithAttributeAliases() + void synthesizeFromMapWithMinimalAttributesWithAttributeAliases() throws Exception { Map map = Collections.singletonMap("location", "test.xml"); MergedAnnotation annotation = MergedAnnotation.of( @@ -1773,7 +1773,7 @@ public class MergedAnnotationsTests { } @Test - public void synthesizeFromMapWithAttributeAliasesThatOverrideArraysWithSingleElements() + void synthesizeFromMapWithAttributeAliasesThatOverrideArraysWithSingleElements() throws Exception { synthesizeFromMapWithAttributeAliasesThatOverrideArraysWithSingleElements( Collections.singletonMap("value", "/foo")); @@ -1791,7 +1791,7 @@ public class MergedAnnotationsTests { } @Test - public void synthesizeFromMapWithImplicitAttributeAliases() throws Exception { + void synthesizeFromMapWithImplicitAttributeAliases() throws Exception { testSynthesisFromMapWithImplicitAliases("value"); testSynthesisFromMapWithImplicitAliases("location1"); testSynthesisFromMapWithImplicitAliases("location2"); @@ -1816,12 +1816,12 @@ public class MergedAnnotationsTests { } @Test - public void synthesizeFromMapWithMissingAttributeValue() throws Exception { + void synthesizeFromMapWithMissingAttributeValue() throws Exception { testMissingTextAttribute(Collections.emptyMap()); } @Test - public void synthesizeFromMapWithNullAttributeValue() throws Exception { + void synthesizeFromMapWithNullAttributeValue() throws Exception { Map map = Collections.singletonMap("text", null); assertThat(map).containsKey("text"); testMissingTextAttribute(map); @@ -1835,7 +1835,7 @@ public class MergedAnnotationsTests { } @Test - public void synthesizeFromMapWithAttributeOfIncorrectType() throws Exception { + void synthesizeFromMapWithAttributeOfIncorrectType() throws Exception { Map map = Collections.singletonMap("value", 42L); MergedAnnotation annotation = MergedAnnotation.of(Component.class, map); @@ -1848,7 +1848,7 @@ public class MergedAnnotationsTests { } @Test - public void synthesizeFromAnnotationAttributesWithoutAttributeAliases() + void synthesizeFromAnnotationAttributesWithoutAttributeAliases() throws Exception { Component component = WebController.class.getAnnotation(Component.class); assertThat(component).isNotNull(); @@ -1860,7 +1860,7 @@ public class MergedAnnotationsTests { } @Test - public void toStringForSynthesizedAnnotations() throws Exception { + void toStringForSynthesizedAnnotations() throws Exception { Method methodWithPath = WebController.class.getMethod( "handleMappedWithPathAttribute"); RequestMapping webMappingWithAliases = methodWithPath.getAnnotation( @@ -1888,7 +1888,7 @@ public class MergedAnnotationsTests { } @Test - public void equalsForSynthesizedAnnotations() throws Exception { + void equalsForSynthesizedAnnotations() throws Exception { Method methodWithPath = WebController.class.getMethod( "handleMappedWithPathAttribute"); RequestMapping webMappingWithAliases = methodWithPath.getAnnotation( @@ -1923,7 +1923,7 @@ public class MergedAnnotationsTests { } @Test - public void hashCodeForSynthesizedAnnotations() throws Exception { + void hashCodeForSynthesizedAnnotations() throws Exception { Method methodWithPath = WebController.class.getMethod( "handleMappedWithPathAttribute"); RequestMapping webMappingWithAliases = methodWithPath.getAnnotation( @@ -1978,8 +1978,7 @@ public class MergedAnnotationsTests { */ @Test @SuppressWarnings("unchecked") - public void synthesizeNonPublicWithAttributeAliasesFromDifferentPackage() - throws Exception { + void synthesizeNonPublicWithAttributeAliasesFromDifferentPackage() throws Exception { Class type = ClassUtils.forName( "org.springframework.core.annotation.subpackage.NonPublicAliasedAnnotatedClass", null); @@ -1997,7 +1996,7 @@ public class MergedAnnotationsTests { } @Test - public void synthesizeWithAttributeAliasesInNestedAnnotations() throws Exception { + void synthesizeWithAttributeAliasesInNestedAnnotations() throws Exception { Hierarchy hierarchy = HierarchyClass.class.getAnnotation(Hierarchy.class); assertThat(hierarchy).isNotNull(); Hierarchy synthesizedHierarchy = MergedAnnotation.from(hierarchy).synthesize(); @@ -2013,7 +2012,7 @@ public class MergedAnnotationsTests { } @Test - public void synthesizeWithArrayOfAnnotations() throws Exception { + void synthesizeWithArrayOfAnnotations() throws Exception { Hierarchy hierarchy = HierarchyClass.class.getAnnotation(Hierarchy.class); assertThat(hierarchy).isNotNull(); Hierarchy synthesizedHierarchy = MergedAnnotation.from(hierarchy).synthesize(); @@ -2035,7 +2034,7 @@ public class MergedAnnotationsTests { } @Test - public void synthesizeWithArrayOfChars() throws Exception { + void synthesizeWithArrayOfChars() throws Exception { CharsContainer charsContainer = GroupOfCharsClass.class.getAnnotation( CharsContainer.class); assertThat(charsContainer).isNotNull(); @@ -2052,14 +2051,14 @@ public class MergedAnnotationsTests { } @Test - public void getValueWhenHasDefaultOverride() { + void getValueWhenHasDefaultOverride() { MergedAnnotation annotation = MergedAnnotations.from( DefaultOverrideClass.class).get(DefaultOverrideRoot.class); assertThat(annotation.getString("text")).isEqualTo("metameta"); } @Test // gh-22654 - public void getValueWhenHasDefaultOverrideWithImplicitAlias() { + void getValueWhenHasDefaultOverrideWithImplicitAlias() { MergedAnnotation annotation1 = MergedAnnotations.from( DefaultOverrideImplicitAliasMetaClass1.class).get(DefaultOverrideRoot.class); assertThat(annotation1.getString("text")).isEqualTo("alias-meta-1"); @@ -2069,7 +2068,7 @@ public class MergedAnnotationsTests { } @Test // gh-22654 - public void getValueWhenHasDefaultOverrideWithExplicitAlias() { + void getValueWhenHasDefaultOverrideWithExplicitAlias() { MergedAnnotation annotation = MergedAnnotations.from( DefaultOverrideExplicitAliasRootMetaMetaClass.class).get( DefaultOverrideExplicitAliasRoot.class); @@ -2078,7 +2077,7 @@ public class MergedAnnotationsTests { } @Test // gh-22703 - public void getValueWhenThreeDeepMetaWithValue() { + void getValueWhenThreeDeepMetaWithValue() { MergedAnnotation annotation = MergedAnnotations.from( ValueAttributeMetaMetaClass.class).get(ValueAttribute.class); assertThat(annotation.getStringArray(MergedAnnotation.VALUE)).containsExactly( @@ -2086,7 +2085,7 @@ public class MergedAnnotationsTests { } @Test - public void asAnnotationAttributesReturnsPopulatedAnnotationAttributes() { + void asAnnotationAttributesReturnsPopulatedAnnotationAttributes() { MergedAnnotation annotation = MergedAnnotations.from( SpringApplicationConfigurationClass.class).get( SpringApplicationConfiguration.class); diff --git a/spring-core/src/test/java/org/springframework/core/annotation/MissingMergedAnnotationTests.java b/spring-core/src/test/java/org/springframework/core/annotation/MissingMergedAnnotationTests.java index 9c33388d23..383536912f 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/MissingMergedAnnotationTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/MissingMergedAnnotationTests.java @@ -35,262 +35,262 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; * * @author Phillip Webb */ -public class MissingMergedAnnotationTests { +class MissingMergedAnnotationTests { private final MergedAnnotation missing = MissingMergedAnnotation.getInstance(); @Test - public void getTypeThrowsNoSuchElementException() { + void getTypeThrowsNoSuchElementException() { assertThatNoSuchElementException().isThrownBy(this.missing::getType); } @Test - public void MetaTypesReturnsEmptyList() { + void metaTypesReturnsEmptyList() { assertThat(this.missing.getMetaTypes()).isEmpty(); } @Test - public void isPresentReturnsFalse() { + void isPresentReturnsFalse() { assertThat(this.missing.isPresent()).isFalse(); } @Test - public void isDirectlyPresentReturnsFalse() { + void isDirectlyPresentReturnsFalse() { assertThat(this.missing.isDirectlyPresent()).isFalse(); } @Test - public void isMetaPresentReturnsFalse() { + void isMetaPresentReturnsFalse() { assertThat(this.missing.isMetaPresent()).isFalse(); } @Test - public void getDistanceReturnsMinusOne() { + void getDistanceReturnsMinusOne() { assertThat(this.missing.getDistance()).isEqualTo(-1); } @Test - public void getAggregateIndexReturnsMinusOne() { + void getAggregateIndexReturnsMinusOne() { assertThat(this.missing.getAggregateIndex()).isEqualTo(-1); } @Test - public void getSourceReturnsNull() { + void getSourceReturnsNull() { assertThat(this.missing.getSource()).isNull(); } @Test - public void getMetaSourceReturnsNull() { + void getMetaSourceReturnsNull() { assertThat(this.missing.getMetaSource()).isNull(); } @Test - public void getRootReturnsEmptyAnnotation() { + void getRootReturnsEmptyAnnotation() { assertThat(this.missing.getRoot()).isSameAs(this.missing); } @Test - public void hasNonDefaultValueThrowsNoSuchElementException() { + void hasNonDefaultValueThrowsNoSuchElementException() { assertThatNoSuchElementException().isThrownBy( () -> this.missing.hasNonDefaultValue("value")); } @Test - public void hasDefaultValueThrowsNoSuchElementException() { + void hasDefaultValueThrowsNoSuchElementException() { assertThatNoSuchElementException().isThrownBy( () -> this.missing.hasDefaultValue("value")); } @Test - public void getByteThrowsNoSuchElementException() { + void getByteThrowsNoSuchElementException() { assertThatNoSuchElementException().isThrownBy( () -> this.missing.getByte("value")); } @Test - public void getByteArrayThrowsNoSuchElementException() { + void getByteArrayThrowsNoSuchElementException() { assertThatNoSuchElementException().isThrownBy( () -> this.missing.getByteArray("value")); } @Test - public void getBooleanThrowsNoSuchElementException() { + void getBooleanThrowsNoSuchElementException() { assertThatNoSuchElementException().isThrownBy( () -> this.missing.getBoolean("value")); } @Test - public void getBooleanArrayThrowsNoSuchElementException() { + void getBooleanArrayThrowsNoSuchElementException() { assertThatNoSuchElementException().isThrownBy( () -> this.missing.getBooleanArray("value")); } @Test - public void getCharThrowsNoSuchElementException() { + void getCharThrowsNoSuchElementException() { assertThatNoSuchElementException().isThrownBy( () -> this.missing.getChar("value")); } @Test - public void getCharArrayThrowsNoSuchElementException() { + void getCharArrayThrowsNoSuchElementException() { assertThatNoSuchElementException().isThrownBy( () -> this.missing.getCharArray("value")); } @Test - public void getShortThrowsNoSuchElementException() { + void getShortThrowsNoSuchElementException() { assertThatNoSuchElementException().isThrownBy( () -> this.missing.getShort("value")); } @Test - public void getShortArrayThrowsNoSuchElementException() { + void getShortArrayThrowsNoSuchElementException() { assertThatNoSuchElementException().isThrownBy( () -> this.missing.getShortArray("value")); } @Test - public void getIntThrowsNoSuchElementException() { + void getIntThrowsNoSuchElementException() { assertThatNoSuchElementException().isThrownBy(() -> this.missing.getInt("value")); } @Test - public void getIntArrayThrowsNoSuchElementException() { + void getIntArrayThrowsNoSuchElementException() { assertThatNoSuchElementException().isThrownBy( () -> this.missing.getIntArray("value")); } @Test - public void getLongThrowsNoSuchElementException() { + void getLongThrowsNoSuchElementException() { assertThatNoSuchElementException().isThrownBy( () -> this.missing.getLong("value")); } @Test - public void getLongArrayThrowsNoSuchElementException() { + void getLongArrayThrowsNoSuchElementException() { assertThatNoSuchElementException().isThrownBy( () -> this.missing.getLongArray("value")); } @Test - public void getDoubleThrowsNoSuchElementException() { + void getDoubleThrowsNoSuchElementException() { assertThatNoSuchElementException().isThrownBy( () -> this.missing.getDouble("value")); } @Test - public void getDoubleArrayThrowsNoSuchElementException() { + void getDoubleArrayThrowsNoSuchElementException() { assertThatNoSuchElementException().isThrownBy( () -> this.missing.getDoubleArray("value")); } @Test - public void getFloatThrowsNoSuchElementException() { + void getFloatThrowsNoSuchElementException() { assertThatNoSuchElementException().isThrownBy( () -> this.missing.getFloat("value")); } @Test - public void getFloatArrayThrowsNoSuchElementException() { + void getFloatArrayThrowsNoSuchElementException() { assertThatNoSuchElementException().isThrownBy( () -> this.missing.getFloatArray("value")); } @Test - public void getStringThrowsNoSuchElementException() { + void getStringThrowsNoSuchElementException() { assertThatNoSuchElementException().isThrownBy( () -> this.missing.getString("value")); } @Test - public void getStringArrayThrowsNoSuchElementException() { + void getStringArrayThrowsNoSuchElementException() { assertThatNoSuchElementException().isThrownBy( () -> this.missing.getStringArray("value")); } @Test - public void getClassThrowsNoSuchElementException() { + void getClassThrowsNoSuchElementException() { assertThatNoSuchElementException().isThrownBy( () -> this.missing.getClass("value")); } @Test - public void getClassArrayThrowsNoSuchElementException() { + void getClassArrayThrowsNoSuchElementException() { assertThatNoSuchElementException().isThrownBy( () -> this.missing.getClassArray("value")); } @Test - public void getEnumThrowsNoSuchElementException() { + void getEnumThrowsNoSuchElementException() { assertThatNoSuchElementException().isThrownBy( () -> this.missing.getEnum("value", TestEnum.class)); } @Test - public void getEnumArrayThrowsNoSuchElementException() { + void getEnumArrayThrowsNoSuchElementException() { assertThatNoSuchElementException().isThrownBy( () -> this.missing.getEnumArray("value", TestEnum.class)); } @Test - public void getAnnotationThrowsNoSuchElementException() { + void getAnnotationThrowsNoSuchElementException() { assertThatNoSuchElementException().isThrownBy( () -> this.missing.getAnnotation("value", TestAnnotation.class)); } @Test - public void getAnnotationArrayThrowsNoSuchElementException() { + void getAnnotationArrayThrowsNoSuchElementException() { assertThatNoSuchElementException().isThrownBy( () -> this.missing.getAnnotationArray("value", TestAnnotation.class)); } @Test - public void getValueReturnsEmpty() { + void getValueReturnsEmpty() { assertThat(this.missing.getValue("value", Integer.class)).isEmpty(); } @Test - public void getDefaultValueReturnsEmpty() { + void getDefaultValueReturnsEmpty() { assertThat(this.missing.getDefaultValue("value", Integer.class)).isEmpty(); } @Test - public void synthesizeThrowsNoSuchElementException() { + void synthesizeThrowsNoSuchElementException() { assertThatNoSuchElementException().isThrownBy(() -> this.missing.synthesize()); } @Test - public void synthesizeWithPredicateWhenPredicateMatchesThrowsNoSuchElementException() { + void synthesizeWithPredicateWhenPredicateMatchesThrowsNoSuchElementException() { assertThatNoSuchElementException().isThrownBy( () -> this.missing.synthesize(annotation -> true)); } @Test - public void synthesizeWithPredicateWhenPredicateDoesNotMatchReturnsEmpty() { + void synthesizeWithPredicateWhenPredicateDoesNotMatchReturnsEmpty() { assertThat(this.missing.synthesize(annotation -> false)).isEmpty(); } @Test - public void toStringReturnsString() { + void toStringReturnsString() { assertThat(this.missing.toString()).isEqualTo("(missing)"); } @Test - public void asAnnotationAttributesReturnsNewAnnotationAttributes() { + void asAnnotationAttributesReturnsNewAnnotationAttributes() { AnnotationAttributes attributes = this.missing.asAnnotationAttributes(); assertThat(attributes).isEmpty(); assertThat(this.missing.asAnnotationAttributes()).isNotSameAs(attributes); } @Test - public void asMapReturnsEmptyMap() { + void asMapReturnsEmptyMap() { Map map = this.missing.asMap(); assertThat(map).isSameAs(Collections.EMPTY_MAP); } @Test - public void asMapWithFactoryReturnsNewMapFromFactory() { + void asMapWithFactoryReturnsNewMapFromFactory() { Map map = this.missing.asMap(annotation->new ConcurrentReferenceHashMap<>()); assertThat(map).isInstanceOf(ConcurrentReferenceHashMap.class); } diff --git a/spring-core/src/test/java/org/springframework/core/annotation/MultipleComposedAnnotationsOnSingleAnnotatedElementTests.java b/spring-core/src/test/java/org/springframework/core/annotation/MultipleComposedAnnotationsOnSingleAnnotatedElementTests.java index cf48e3d107..138971e642 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/MultipleComposedAnnotationsOnSingleAnnotatedElementTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/MultipleComposedAnnotationsOnSingleAnnotatedElementTests.java @@ -45,20 +45,20 @@ import static org.springframework.core.annotation.AnnotatedElementUtils.getAllMe * @see AnnotatedElementUtilsTests * @see ComposedRepeatableAnnotationsTests */ -public class MultipleComposedAnnotationsOnSingleAnnotatedElementTests { +class MultipleComposedAnnotationsOnSingleAnnotatedElementTests { @Test - public void getMultipleComposedAnnotationsOnClass() { + void getMultipleComposedAnnotationsOnClass() { assertGetAllMergedAnnotationsBehavior(MultipleComposedCachesClass.class); } @Test - public void getMultipleInheritedComposedAnnotationsOnSuperclass() { + void getMultipleInheritedComposedAnnotationsOnSuperclass() { assertGetAllMergedAnnotationsBehavior(SubMultipleComposedCachesClass.class); } @Test - public void getMultipleNoninheritedComposedAnnotationsOnClass() { + void getMultipleNoninheritedComposedAnnotationsOnClass() { Class element = MultipleNoninheritedComposedCachesClass.class; Set cacheables = getAllMergedAnnotations(element, Cacheable.class); assertThat(cacheables).isNotNull(); @@ -72,7 +72,7 @@ public class MultipleComposedAnnotationsOnSingleAnnotatedElementTests { } @Test - public void getMultipleNoninheritedComposedAnnotationsOnSuperclass() { + void getMultipleNoninheritedComposedAnnotationsOnSuperclass() { Class element = SubMultipleNoninheritedComposedCachesClass.class; Set cacheables = getAllMergedAnnotations(element, Cacheable.class); assertThat(cacheables).isNotNull(); @@ -80,12 +80,12 @@ public class MultipleComposedAnnotationsOnSingleAnnotatedElementTests { } @Test - public void getComposedPlusLocalAnnotationsOnClass() { + void getComposedPlusLocalAnnotationsOnClass() { assertGetAllMergedAnnotationsBehavior(ComposedPlusLocalCachesClass.class); } @Test - public void getMultipleComposedAnnotationsOnInterface() { + void getMultipleComposedAnnotationsOnInterface() { Class element = MultipleComposedCachesOnInterfaceClass.class; Set cacheables = getAllMergedAnnotations(element, Cacheable.class); assertThat(cacheables).isNotNull(); @@ -93,37 +93,37 @@ public class MultipleComposedAnnotationsOnSingleAnnotatedElementTests { } @Test - public void getMultipleComposedAnnotationsOnMethod() throws Exception { + void getMultipleComposedAnnotationsOnMethod() throws Exception { AnnotatedElement element = getClass().getDeclaredMethod("multipleComposedCachesMethod"); assertGetAllMergedAnnotationsBehavior(element); } @Test - public void getComposedPlusLocalAnnotationsOnMethod() throws Exception { + void getComposedPlusLocalAnnotationsOnMethod() throws Exception { AnnotatedElement element = getClass().getDeclaredMethod("composedPlusLocalCachesMethod"); assertGetAllMergedAnnotationsBehavior(element); } @Test @Disabled("Disabled since some Java 8 updates handle the bridge method differently") - public void getMultipleComposedAnnotationsOnBridgeMethod() throws Exception { + void getMultipleComposedAnnotationsOnBridgeMethod() throws Exception { Set cacheables = getAllMergedAnnotations(getBridgeMethod(), Cacheable.class); assertThat(cacheables).isNotNull(); assertThat(cacheables.size()).isEqualTo(0); } @Test - public void findMultipleComposedAnnotationsOnClass() { + void findMultipleComposedAnnotationsOnClass() { assertFindAllMergedAnnotationsBehavior(MultipleComposedCachesClass.class); } @Test - public void findMultipleInheritedComposedAnnotationsOnSuperclass() { + void findMultipleInheritedComposedAnnotationsOnSuperclass() { assertFindAllMergedAnnotationsBehavior(SubMultipleComposedCachesClass.class); } @Test - public void findMultipleNoninheritedComposedAnnotationsOnClass() { + void findMultipleNoninheritedComposedAnnotationsOnClass() { Class element = MultipleNoninheritedComposedCachesClass.class; Set cacheables = findAllMergedAnnotations(element, Cacheable.class); assertThat(cacheables).isNotNull(); @@ -137,7 +137,7 @@ public class MultipleComposedAnnotationsOnSingleAnnotatedElementTests { } @Test - public void findMultipleNoninheritedComposedAnnotationsOnSuperclass() { + void findMultipleNoninheritedComposedAnnotationsOnSuperclass() { Class element = SubMultipleNoninheritedComposedCachesClass.class; Set cacheables = findAllMergedAnnotations(element, Cacheable.class); assertThat(cacheables).isNotNull(); @@ -151,34 +151,34 @@ public class MultipleComposedAnnotationsOnSingleAnnotatedElementTests { } @Test - public void findComposedPlusLocalAnnotationsOnClass() { + void findComposedPlusLocalAnnotationsOnClass() { assertFindAllMergedAnnotationsBehavior(ComposedPlusLocalCachesClass.class); } @Test - public void findMultipleComposedAnnotationsOnInterface() { + void findMultipleComposedAnnotationsOnInterface() { assertFindAllMergedAnnotationsBehavior(MultipleComposedCachesOnInterfaceClass.class); } @Test - public void findComposedCacheOnInterfaceAndLocalCacheOnClass() { + void findComposedCacheOnInterfaceAndLocalCacheOnClass() { assertFindAllMergedAnnotationsBehavior(ComposedCacheOnInterfaceAndLocalCacheClass.class); } @Test - public void findMultipleComposedAnnotationsOnMethod() throws Exception { + void findMultipleComposedAnnotationsOnMethod() throws Exception { AnnotatedElement element = getClass().getDeclaredMethod("multipleComposedCachesMethod"); assertFindAllMergedAnnotationsBehavior(element); } @Test - public void findComposedPlusLocalAnnotationsOnMethod() throws Exception { + void findComposedPlusLocalAnnotationsOnMethod() throws Exception { AnnotatedElement element = getClass().getDeclaredMethod("composedPlusLocalCachesMethod"); assertFindAllMergedAnnotationsBehavior(element); } @Test - public void findMultipleComposedAnnotationsOnBridgeMethod() throws Exception { + void findMultipleComposedAnnotationsOnBridgeMethod() throws Exception { assertFindAllMergedAnnotationsBehavior(getBridgeMethod()); } @@ -186,7 +186,7 @@ public class MultipleComposedAnnotationsOnSingleAnnotatedElementTests { * Bridge/bridged method setup code copied from * {@link org.springframework.core.BridgeMethodResolverTests#testWithGenericParameter()}. */ - public Method getBridgeMethod() throws NoSuchMethodException { + Method getBridgeMethod() throws NoSuchMethodException { Method[] methods = StringGenericParameter.class.getMethods(); Method bridgeMethod = null; Method bridgedMethod = null; diff --git a/spring-core/src/test/java/org/springframework/core/annotation/OrderSourceProviderTests.java b/spring-core/src/test/java/org/springframework/core/annotation/OrderSourceProviderTests.java index 8b983cd63c..edbea15e94 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/OrderSourceProviderTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/OrderSourceProviderTests.java @@ -31,13 +31,13 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Stephane Nicoll * @author Juergen Hoeller */ -public class OrderSourceProviderTests { +class OrderSourceProviderTests { private final AnnotationAwareOrderComparator comparator = AnnotationAwareOrderComparator.INSTANCE; @Test - public void plainComparator() { + void plainComparator() { List items = new ArrayList<>(); C c = new C(5); C c2 = new C(-5); @@ -48,7 +48,7 @@ public class OrderSourceProviderTests { } @Test - public void listNoFactoryMethod() { + void listNoFactoryMethod() { A a = new A(); C c = new C(-50); B b = new B(); @@ -59,7 +59,7 @@ public class OrderSourceProviderTests { } @Test - public void listFactoryMethod() { + void listFactoryMethod() { A a = new A(); C c = new C(3); B b = new B(); @@ -78,7 +78,7 @@ public class OrderSourceProviderTests { } @Test - public void listFactoryMethodOverridesStaticOrder() { + void listFactoryMethodOverridesStaticOrder() { A a = new A(); C c = new C(5); C c2 = new C(-5); @@ -97,7 +97,7 @@ public class OrderSourceProviderTests { } @Test - public void arrayNoFactoryMethod() { + void arrayNoFactoryMethod() { A a = new A(); C c = new C(-50); B b = new B(); @@ -108,7 +108,7 @@ public class OrderSourceProviderTests { } @Test - public void arrayFactoryMethod() { + void arrayFactoryMethod() { A a = new A(); C c = new C(3); B b = new B(); @@ -127,7 +127,7 @@ public class OrderSourceProviderTests { } @Test - public void arrayFactoryMethodOverridesStaticOrder() { + void arrayFactoryMethodOverridesStaticOrder() { A a = new A(); C c = new C(5); C c2 = new C(-5); diff --git a/spring-core/src/test/java/org/springframework/core/annotation/OrderUtilsTests.java b/spring-core/src/test/java/org/springframework/core/annotation/OrderUtilsTests.java index dbb1577e44..08d980baf0 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/OrderUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/OrderUtilsTests.java @@ -26,40 +26,40 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Stephane Nicoll * @author Juergen Hoeller */ -public class OrderUtilsTests { +class OrderUtilsTests { @Test - public void getSimpleOrder() { + void getSimpleOrder() { assertThat(OrderUtils.getOrder(SimpleOrder.class, null)).isEqualTo(Integer.valueOf(50)); assertThat(OrderUtils.getOrder(SimpleOrder.class, null)).isEqualTo(Integer.valueOf(50)); } @Test - public void getPriorityOrder() { + void getPriorityOrder() { assertThat(OrderUtils.getOrder(SimplePriority.class, null)).isEqualTo(Integer.valueOf(55)); assertThat(OrderUtils.getOrder(SimplePriority.class, null)).isEqualTo(Integer.valueOf(55)); } @Test - public void getOrderWithBoth() { + void getOrderWithBoth() { assertThat(OrderUtils.getOrder(OrderAndPriority.class, null)).isEqualTo(Integer.valueOf(50)); assertThat(OrderUtils.getOrder(OrderAndPriority.class, null)).isEqualTo(Integer.valueOf(50)); } @Test - public void getDefaultOrder() { + void getDefaultOrder() { assertThat(OrderUtils.getOrder(NoOrder.class, 33)).isEqualTo(33); assertThat(OrderUtils.getOrder(NoOrder.class, 33)).isEqualTo(33); } @Test - public void getPriorityValueNoAnnotation() { + void getPriorityValueNoAnnotation() { assertThat(OrderUtils.getPriority(SimpleOrder.class)).isNull(); assertThat(OrderUtils.getPriority(SimpleOrder.class)).isNull(); } @Test - public void getPriorityValue() { + void getPriorityValue() { assertThat(OrderUtils.getPriority(OrderAndPriority.class)).isEqualTo(Integer.valueOf(55)); assertThat(OrderUtils.getPriority(OrderAndPriority.class)).isEqualTo(Integer.valueOf(55)); } diff --git a/spring-core/src/test/java/org/springframework/core/annotation/PackagesAnnotationFilterTests.java b/spring-core/src/test/java/org/springframework/core/annotation/PackagesAnnotationFilterTests.java index d8a8b2c4c7..12c5c87dc2 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/PackagesAnnotationFilterTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/PackagesAnnotationFilterTests.java @@ -26,49 +26,49 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException * * @author Phillip Webb */ -public class PackagesAnnotationFilterTests { +class PackagesAnnotationFilterTests { @Test - public void createWhenPackagesIsNullThrowsException() { + void createWhenPackagesIsNullThrowsException() { assertThatIllegalArgumentException().isThrownBy(() -> new PackagesAnnotationFilter((String[]) null)) .withMessage("Packages array must not be null"); } @Test - public void createWhenPackagesContainsNullThrowsException() { + void createWhenPackagesContainsNullThrowsException() { assertThatIllegalArgumentException().isThrownBy(() -> new PackagesAnnotationFilter((String) null)) .withMessage("Packages array must not have empty elements"); } @Test - public void createWhenPackagesContainsEmptyTextThrowsException() { + void createWhenPackagesContainsEmptyTextThrowsException() { assertThatIllegalArgumentException().isThrownBy(() -> new PackagesAnnotationFilter("")) .withMessage("Packages array must not have empty elements"); } @Test - public void matchesWhenInPackageReturnsTrue() { + void matchesWhenInPackageReturnsTrue() { PackagesAnnotationFilter filter = new PackagesAnnotationFilter("com.example"); assertThat(filter.matches("com.example.Component")).isTrue(); } @Test - public void matchesWhenNotInPackageReturnsFalse() { + void matchesWhenNotInPackageReturnsFalse() { PackagesAnnotationFilter filter = new PackagesAnnotationFilter("com.example"); assertThat(filter.matches("org.springframework.sterotype.Component")).isFalse(); } @Test - public void matchesWhenInSimilarPackageReturnsFalse() { + void matchesWhenInSimilarPackageReturnsFalse() { PackagesAnnotationFilter filter = new PackagesAnnotationFilter("com.example"); assertThat(filter.matches("com.examples.Component")).isFalse(); } @Test - public void equalsAndHashCode() { + void equalsAndHashCode() { PackagesAnnotationFilter filter1 = new PackagesAnnotationFilter("com.example", "org.springframework"); PackagesAnnotationFilter filter2 = new PackagesAnnotationFilter( diff --git a/spring-core/src/test/java/org/springframework/core/annotation/RepeatableContainersTests.java b/spring-core/src/test/java/org/springframework/core/annotation/RepeatableContainersTests.java index d710d02e73..29aeb70856 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/RepeatableContainersTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/RepeatableContainersTests.java @@ -32,10 +32,10 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException * * @author Phillip Webb */ -public class RepeatableContainersTests { +class RepeatableContainersTests { @Test - public void standardRepeatablesWhenNonRepeatableReturnsNull() { + void standardRepeatablesWhenNonRepeatableReturnsNull() { Object[] values = findRepeatedAnnotationValues( RepeatableContainers.standardRepeatables(), WithNonRepeatable.class, NonRepeatable.class); @@ -43,7 +43,7 @@ public class RepeatableContainersTests { } @Test - public void standardRepeatablesWhenSingleReturnsNull() { + void standardRepeatablesWhenSingleReturnsNull() { Object[] values = findRepeatedAnnotationValues( RepeatableContainers.standardRepeatables(), WithSingleStandardRepeatable.class, StandardRepeatable.class); @@ -51,7 +51,7 @@ public class RepeatableContainersTests { } @Test - public void standardRepeatablesWhenContainerReturnsRepeats() { + void standardRepeatablesWhenContainerReturnsRepeats() { Object[] values = findRepeatedAnnotationValues( RepeatableContainers.standardRepeatables(), WithStandardRepeatables.class, StandardContainer.class); @@ -59,7 +59,7 @@ public class RepeatableContainersTests { } @Test - public void standardRepeatablesWhenContainerButNotRepeatableReturnsNull() { + void standardRepeatablesWhenContainerButNotRepeatableReturnsNull() { Object[] values = findRepeatedAnnotationValues( RepeatableContainers.standardRepeatables(), WithExplicitRepeatables.class, ExplicitContainer.class); @@ -67,7 +67,7 @@ public class RepeatableContainersTests { } @Test - public void ofExplicitWhenNonRepeatableReturnsNull() { + void ofExplicitWhenNonRepeatableReturnsNull() { Object[] values = findRepeatedAnnotationValues( RepeatableContainers.of(ExplicitRepeatable.class, ExplicitContainer.class), @@ -76,7 +76,7 @@ public class RepeatableContainersTests { } @Test - public void ofExplicitWhenStandardRepeatableContainerReturnsNull() { + void ofExplicitWhenStandardRepeatableContainerReturnsNull() { Object[] values = findRepeatedAnnotationValues( RepeatableContainers.of(ExplicitRepeatable.class, ExplicitContainer.class), @@ -85,7 +85,7 @@ public class RepeatableContainersTests { } @Test - public void ofExplicitWhenContainerReturnsRepeats() { + void ofExplicitWhenContainerReturnsRepeats() { Object[] values = findRepeatedAnnotationValues( RepeatableContainers.of(ExplicitRepeatable.class, ExplicitContainer.class), @@ -94,7 +94,7 @@ public class RepeatableContainersTests { } @Test - public void ofExplicitWhenHasNoValueThrowsException() { + void ofExplicitWhenHasNoValueThrowsException() { assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> RepeatableContainers.of(ExplicitRepeatable.class, InvalidNoValue.class)) .withMessageContaining("Invalid declaration of container type [" @@ -104,7 +104,7 @@ public class RepeatableContainersTests { } @Test - public void ofExplicitWhenValueIsNotArrayThrowsException() { + void ofExplicitWhenValueIsNotArrayThrowsException() { assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> RepeatableContainers.of(ExplicitRepeatable.class, InvalidNotArray.class)) .withMessage("Container type [" @@ -114,7 +114,7 @@ public class RepeatableContainersTests { } @Test - public void ofExplicitWhenValueIsArrayOfWrongTypeThrowsException() { + void ofExplicitWhenValueIsArrayOfWrongTypeThrowsException() { assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> RepeatableContainers.of(ExplicitRepeatable.class, InvalidWrongArrayType.class)) .withMessage("Container type [" @@ -124,14 +124,14 @@ public class RepeatableContainersTests { } @Test - public void ofExplicitWhenAnnotationIsNullThrowsException() { + void ofExplicitWhenAnnotationIsNullThrowsException() { assertThatIllegalArgumentException().isThrownBy(() -> RepeatableContainers.of(null, null)) .withMessage("Repeatable must not be null"); } @Test - public void ofExplicitWhenContainerIsNullDeducesContainer() { + void ofExplicitWhenContainerIsNullDeducesContainer() { Object[] values = findRepeatedAnnotationValues( RepeatableContainers.of(StandardRepeatable.class, null), WithStandardRepeatables.class, StandardContainer.class); @@ -139,7 +139,7 @@ public class RepeatableContainersTests { } @Test - public void ofExplicitWhenContainerIsNullAndNotRepeatableThrowsException() { + void ofExplicitWhenContainerIsNullAndNotRepeatableThrowsException() { assertThatIllegalArgumentException().isThrownBy(() -> RepeatableContainers.of(ExplicitRepeatable.class, null)) .withMessage("Annotation type must be a repeatable annotation: " + @@ -148,7 +148,7 @@ public class RepeatableContainersTests { } @Test - public void standardAndExplicitReturnsRepeats() { + void standardAndExplicitReturnsRepeats() { RepeatableContainers repeatableContainers = RepeatableContainers.standardRepeatables().and( ExplicitContainer.class, ExplicitRepeatable.class); assertThat(findRepeatedAnnotationValues(repeatableContainers, @@ -160,7 +160,7 @@ public class RepeatableContainersTests { } @Test - public void noneAlwaysReturnsNull() { + void noneAlwaysReturnsNull() { Object[] values = findRepeatedAnnotationValues( RepeatableContainers.none(), WithStandardRepeatables.class, StandardContainer.class); @@ -168,7 +168,7 @@ public class RepeatableContainersTests { } @Test - public void equalsAndHashcode() { + void equalsAndHashcode() { RepeatableContainers c1 = RepeatableContainers.of(ExplicitRepeatable.class, ExplicitContainer.class); RepeatableContainers c2 = RepeatableContainers.of(ExplicitRepeatable.class, diff --git a/spring-core/src/test/java/org/springframework/core/annotation/SynthesizingMethodParameterTests.java b/spring-core/src/test/java/org/springframework/core/annotation/SynthesizingMethodParameterTests.java index e822b1ced7..52b1c77f3d 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/SynthesizingMethodParameterTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/SynthesizingMethodParameterTests.java @@ -30,7 +30,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException * @author Juergen Hoeller * @since 5.0 */ -public class SynthesizingMethodParameterTests { +class SynthesizingMethodParameterTests { private Method method; @@ -42,7 +42,7 @@ public class SynthesizingMethodParameterTests { @BeforeEach - public void setUp() throws NoSuchMethodException { + void setUp() throws NoSuchMethodException { method = getClass().getMethod("method", String.class, Long.TYPE); stringParameter = new SynthesizingMethodParameter(method, 0); longParameter = new SynthesizingMethodParameter(method, 1); @@ -51,7 +51,7 @@ public class SynthesizingMethodParameterTests { @Test - public void testEquals() throws NoSuchMethodException { + void equals() throws NoSuchMethodException { assertThat(stringParameter).isEqualTo(stringParameter); assertThat(longParameter).isEqualTo(longParameter); assertThat(intReturnType).isEqualTo(intReturnType); @@ -78,7 +78,7 @@ public class SynthesizingMethodParameterTests { } @Test - public void testHashCode() throws NoSuchMethodException { + void testHashCode() throws NoSuchMethodException { assertThat(stringParameter.hashCode()).isEqualTo(stringParameter.hashCode()); assertThat(longParameter.hashCode()).isEqualTo(longParameter.hashCode()); assertThat(intReturnType.hashCode()).isEqualTo(intReturnType.hashCode()); @@ -90,7 +90,7 @@ public class SynthesizingMethodParameterTests { } @Test - public void testFactoryMethods() { + void factoryMethods() { assertThat(SynthesizingMethodParameter.forExecutable(method, 0)).isEqualTo(stringParameter); assertThat(SynthesizingMethodParameter.forExecutable(method, 1)).isEqualTo(longParameter); @@ -99,7 +99,7 @@ public class SynthesizingMethodParameterTests { } @Test - public void testIndexValidation() { + void indexValidation() { assertThatIllegalArgumentException().isThrownBy(() -> new SynthesizingMethodParameter(method, 2)); } diff --git a/spring-core/src/test/java/org/springframework/core/annotation/TypeMappedAnnotationTests.java b/spring-core/src/test/java/org/springframework/core/annotation/TypeMappedAnnotationTests.java index 6b13b945cc..d4ec258455 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/TypeMappedAnnotationTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/TypeMappedAnnotationTests.java @@ -34,10 +34,10 @@ import static org.assertj.core.api.Assertions.assertThat; * * @author Phillip Webb */ -public class TypeMappedAnnotationTests { +class TypeMappedAnnotationTests { @Test - public void mappingWhenMirroredReturnsMirroredValues() { + void mappingWhenMirroredReturnsMirroredValues() { testExplicitMirror(WithExplicitMirrorA.class); testExplicitMirror(WithExplicitMirrorB.class); } @@ -50,7 +50,7 @@ public class TypeMappedAnnotationTests { } @Test - public void mappingExplicitAliasToMetaAnnotationReturnsMappedValues() { + void mappingExplicitAliasToMetaAnnotationReturnsMappedValues() { TypeMappedAnnotation annotation = getTypeMappedAnnotation( WithExplicitAliasToMetaAnnotation.class, ExplicitAliasToMetaAnnotation.class, @@ -60,7 +60,7 @@ public class TypeMappedAnnotationTests { } @Test - public void mappingConventionAliasToMetaAnnotationReturnsMappedValues() { + void mappingConventionAliasToMetaAnnotationReturnsMappedValues() { TypeMappedAnnotation annotation = getTypeMappedAnnotation( WithConventionAliasToMetaAnnotation.class, ConventionAliasToMetaAnnotation.class, @@ -70,7 +70,7 @@ public class TypeMappedAnnotationTests { } @Test - public void adaptFromEmptyArrayToAnyComponentType() { + void adaptFromEmptyArrayToAnyComponentType() { AttributeMethods methods = AttributeMethods.forAnnotationType(ArrayTypes.class); Map attributes = new HashMap<>(); for (int i = 0; i < methods.size(); i++) { @@ -93,7 +93,7 @@ public class TypeMappedAnnotationTests { } @Test - public void adaptFromNestedMergedAnnotation() { + void adaptFromNestedMergedAnnotation() { MergedAnnotation nested = MergedAnnotation.of(Nested.class); MergedAnnotation annotation = TypeMappedAnnotation.of(null, null, NestedContainer.class, Collections.singletonMap("value", nested)); @@ -101,7 +101,7 @@ public class TypeMappedAnnotationTests { } @Test - public void adaptFromStringToClass() { + void adaptFromStringToClass() { MergedAnnotation annotation = TypeMappedAnnotation.of(null, null, ClassAttributes.class, Collections.singletonMap("classValue", InputStream.class.getName())); @@ -110,7 +110,7 @@ public class TypeMappedAnnotationTests { } @Test - public void adaptFromStringArrayToClassArray() { + void adaptFromStringArrayToClassArray() { MergedAnnotation annotation = TypeMappedAnnotation.of(null, null, ClassAttributes.class, Collections.singletonMap("classArrayValue", new String[] { InputStream.class.getName() })); assertThat(annotation.getStringArray("classArrayValue")).containsExactly(InputStream.class.getName()); diff --git a/spring-core/src/test/java/org/springframework/core/codec/AbstractDecoderTestCase.java b/spring-core/src/test/java/org/springframework/core/codec/AbstractDecoderTestCase.java index eb1c5bd8d7..93ecdbf39c 100644 --- a/spring-core/src/test/java/org/springframework/core/codec/AbstractDecoderTestCase.java +++ b/spring-core/src/test/java/org/springframework/core/codec/AbstractDecoderTestCase.java @@ -44,8 +44,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; * @since 5.1.3 */ @SuppressWarnings("ProtectedField") -public abstract class AbstractDecoderTestCase> - extends AbstractLeakCheckingTestCase { +public abstract class AbstractDecoderTestCase> extends AbstractLeakCheckingTestCase { /** * The decoder to test. diff --git a/spring-core/src/test/java/org/springframework/core/codec/AbstractEncoderTestCase.java b/spring-core/src/test/java/org/springframework/core/codec/AbstractEncoderTestCase.java index 653c0b033f..b9ec7a4948 100644 --- a/spring-core/src/test/java/org/springframework/core/codec/AbstractEncoderTestCase.java +++ b/spring-core/src/test/java/org/springframework/core/codec/AbstractEncoderTestCase.java @@ -45,8 +45,7 @@ import static org.springframework.core.io.buffer.DataBufferUtils.release; * @since 5.1.3 */ @SuppressWarnings("ProtectedField") -public abstract class AbstractEncoderTestCase> - extends AbstractLeakCheckingTestCase { +public abstract class AbstractEncoderTestCase> extends AbstractLeakCheckingTestCase { /** * The encoder to test. @@ -273,5 +272,4 @@ public abstract class AbstractEncoderTestCase> } - } diff --git a/spring-core/src/test/java/org/springframework/core/codec/ByteArrayDecoderTests.java b/spring-core/src/test/java/org/springframework/core/codec/ByteArrayDecoderTests.java index aab062bb66..43dd8ebfd4 100644 --- a/spring-core/src/test/java/org/springframework/core/codec/ByteArrayDecoderTests.java +++ b/spring-core/src/test/java/org/springframework/core/codec/ByteArrayDecoderTests.java @@ -31,14 +31,14 @@ import static org.assertj.core.api.Assertions.assertThat; /** * @author Arjen Poutsma */ -public class ByteArrayDecoderTests extends AbstractDecoderTestCase { +class ByteArrayDecoderTests extends AbstractDecoderTestCase { private final byte[] fooBytes = "foo".getBytes(StandardCharsets.UTF_8); private final byte[] barBytes = "bar".getBytes(StandardCharsets.UTF_8); - public ByteArrayDecoderTests() { + ByteArrayDecoderTests() { super(new ByteArrayDecoder()); } diff --git a/spring-core/src/test/java/org/springframework/core/codec/ByteArrayEncoderTests.java b/spring-core/src/test/java/org/springframework/core/codec/ByteArrayEncoderTests.java index 9d20c93134..d217625a65 100644 --- a/spring-core/src/test/java/org/springframework/core/codec/ByteArrayEncoderTests.java +++ b/spring-core/src/test/java/org/springframework/core/codec/ByteArrayEncoderTests.java @@ -29,13 +29,13 @@ import static org.assertj.core.api.Assertions.assertThat; /** * @author Arjen Poutsma */ -public class ByteArrayEncoderTests extends AbstractEncoderTestCase { +class ByteArrayEncoderTests extends AbstractEncoderTestCase { private final byte[] fooBytes = "foo".getBytes(StandardCharsets.UTF_8); private final byte[] barBytes = "bar".getBytes(StandardCharsets.UTF_8); - public ByteArrayEncoderTests() { + ByteArrayEncoderTests() { super(new ByteArrayEncoder()); } diff --git a/spring-core/src/test/java/org/springframework/core/codec/ByteBufferDecoderTests.java b/spring-core/src/test/java/org/springframework/core/codec/ByteBufferDecoderTests.java index 5b003c397b..afc9d774ab 100644 --- a/spring-core/src/test/java/org/springframework/core/codec/ByteBufferDecoderTests.java +++ b/spring-core/src/test/java/org/springframework/core/codec/ByteBufferDecoderTests.java @@ -32,14 +32,14 @@ import static org.assertj.core.api.Assertions.assertThat; /** * @author Sebastien Deleuze */ -public class ByteBufferDecoderTests extends AbstractDecoderTestCase { +class ByteBufferDecoderTests extends AbstractDecoderTestCase { private final byte[] fooBytes = "foo".getBytes(StandardCharsets.UTF_8); private final byte[] barBytes = "bar".getBytes(StandardCharsets.UTF_8); - public ByteBufferDecoderTests() { + ByteBufferDecoderTests() { super(new ByteBufferDecoder()); } diff --git a/spring-core/src/test/java/org/springframework/core/codec/ByteBufferEncoderTests.java b/spring-core/src/test/java/org/springframework/core/codec/ByteBufferEncoderTests.java index e6275a4484..156127d7fd 100644 --- a/spring-core/src/test/java/org/springframework/core/codec/ByteBufferEncoderTests.java +++ b/spring-core/src/test/java/org/springframework/core/codec/ByteBufferEncoderTests.java @@ -30,13 +30,13 @@ import static org.assertj.core.api.Assertions.assertThat; /** * @author Sebastien Deleuze */ -public class ByteBufferEncoderTests extends AbstractEncoderTestCase { +class ByteBufferEncoderTests extends AbstractEncoderTestCase { private final byte[] fooBytes = "foo".getBytes(StandardCharsets.UTF_8); private final byte[] barBytes = "bar".getBytes(StandardCharsets.UTF_8); - public ByteBufferEncoderTests() { + ByteBufferEncoderTests() { super(new ByteBufferEncoder()); } @@ -64,7 +64,6 @@ public class ByteBufferEncoderTests extends AbstractEncoderTestCase { +class CharSequenceEncoderTests extends AbstractEncoderTestCase { private final String foo = "foo"; private final String bar = "bar"; - public CharSequenceEncoderTests() { + CharSequenceEncoderTests() { super(CharSequenceEncoder.textPlainOnly()); } @@ -74,7 +73,7 @@ public class CharSequenceEncoderTests } @Test - public void calculateCapacity() { + void calculateCapacity() { String sequence = "Hello World!"; Stream.of(UTF_8, UTF_16, ISO_8859_1, US_ASCII, Charset.forName("BIG5")) .forEach(charset -> { @@ -82,7 +81,6 @@ public class CharSequenceEncoderTests int length = sequence.length(); assertThat(capacity >= length).as(String.format("%s has capacity %d; length %d", charset, capacity, length)).isTrue(); }); - } } diff --git a/spring-core/src/test/java/org/springframework/core/codec/DataBufferDecoderTests.java b/spring-core/src/test/java/org/springframework/core/codec/DataBufferDecoderTests.java index 5829d953ce..9719450038 100644 --- a/spring-core/src/test/java/org/springframework/core/codec/DataBufferDecoderTests.java +++ b/spring-core/src/test/java/org/springframework/core/codec/DataBufferDecoderTests.java @@ -32,14 +32,14 @@ import static org.assertj.core.api.Assertions.assertThat; /** * @author Sebastien Deleuze */ -public class DataBufferDecoderTests extends AbstractDecoderTestCase { +class DataBufferDecoderTests extends AbstractDecoderTestCase { private final byte[] fooBytes = "foo".getBytes(StandardCharsets.UTF_8); private final byte[] barBytes = "bar".getBytes(StandardCharsets.UTF_8); - public DataBufferDecoderTests() { + DataBufferDecoderTests() { super(new DataBufferDecoder()); } @@ -90,4 +90,5 @@ public class DataBufferDecoderTests extends AbstractDecoderTestCase { +class DataBufferEncoderTests extends AbstractEncoderTestCase { private final byte[] fooBytes = "foo".getBytes(StandardCharsets.UTF_8); private final byte[] barBytes = "bar".getBytes(StandardCharsets.UTF_8); - public DataBufferEncoderTests() { + DataBufferEncoderTests() { super(new DataBufferEncoder()); } @@ -72,5 +72,4 @@ public class DataBufferEncoderTests extends AbstractEncoderTestCase { +class ResourceDecoderTests extends AbstractDecoderTestCase { private final byte[] fooBytes = "foo".getBytes(StandardCharsets.UTF_8); private final byte[] barBytes = "bar".getBytes(StandardCharsets.UTF_8); - public ResourceDecoderTests() { + ResourceDecoderTests() { super(new ResourceDecoder()); } diff --git a/spring-core/src/test/java/org/springframework/core/codec/ResourceEncoderTests.java b/spring-core/src/test/java/org/springframework/core/codec/ResourceEncoderTests.java index 387ba67aca..14c11fdd22 100644 --- a/spring-core/src/test/java/org/springframework/core/codec/ResourceEncoderTests.java +++ b/spring-core/src/test/java/org/springframework/core/codec/ResourceEncoderTests.java @@ -38,12 +38,12 @@ import static org.assertj.core.api.Assertions.assertThat; /** * @author Arjen Poutsma */ -public class ResourceEncoderTests extends AbstractEncoderTestCase { +class ResourceEncoderTests extends AbstractEncoderTestCase { private final byte[] bytes = "foo".getBytes(UTF_8); - public ResourceEncoderTests() { + ResourceEncoderTests() { super(new ResourceEncoder()); } diff --git a/spring-core/src/test/java/org/springframework/core/codec/ResourceRegionEncoderTests.java b/spring-core/src/test/java/org/springframework/core/codec/ResourceRegionEncoderTests.java index 7891f158cc..18f374a005 100644 --- a/spring-core/src/test/java/org/springframework/core/codec/ResourceRegionEncoderTests.java +++ b/spring-core/src/test/java/org/springframework/core/codec/ResourceRegionEncoderTests.java @@ -45,7 +45,7 @@ import static org.assertj.core.api.Assertions.assertThat; * Test cases for {@link ResourceRegionEncoder} class. * @author Brian Clozel */ -public class ResourceRegionEncoderTests { +class ResourceRegionEncoderTests { private ResourceRegionEncoder encoder = new ResourceRegionEncoder(); @@ -53,12 +53,12 @@ public class ResourceRegionEncoderTests { @AfterEach - public void tearDown() throws Exception { + void tearDown() throws Exception { this.bufferFactory.checkForLeaks(); } @Test - public void canEncode() { + void canEncode() { ResolvableType resourceRegion = ResolvableType.forClass(ResourceRegion.class); MimeType allMimeType = MimeType.valueOf("*/*"); @@ -73,7 +73,7 @@ public class ResourceRegionEncoderTests { } @Test - public void shouldEncodeResourceRegionFileResource() throws Exception { + void shouldEncodeResourceRegionFileResource() throws Exception { ResourceRegion region = new ResourceRegion( new ClassPathResource("ResourceRegionEncoderTests.txt", getClass()), 0, 6); Flux result = this.encoder.encode(Mono.just(region), this.bufferFactory, @@ -88,7 +88,7 @@ public class ResourceRegionEncoderTests { } @Test - public void shouldEncodeMultipleResourceRegionsFileResource() { + void shouldEncodeMultipleResourceRegionsFileResource() { Resource resource = new ClassPathResource("ResourceRegionEncoderTests.txt", getClass()); Flux regions = Flux.just( new ResourceRegion(resource, 0, 6), @@ -127,7 +127,7 @@ public class ResourceRegionEncoderTests { } @Test // gh-22107 - public void cancelWithoutDemandForMultipleResourceRegions() { + void cancelWithoutDemandForMultipleResourceRegions() { Resource resource = new ClassPathResource("ResourceRegionEncoderTests.txt", getClass()); Flux regions = Flux.just( new ResourceRegion(resource, 0, 6), @@ -149,7 +149,7 @@ public class ResourceRegionEncoderTests { } @Test // gh-22107 - public void cancelWithoutDemandForSingleResourceRegion() { + void cancelWithoutDemandForSingleResourceRegion() { Resource resource = new ClassPathResource("ResourceRegionEncoderTests.txt", getClass()); Mono regions = Mono.just(new ResourceRegion(resource, 0, 6)); String boundary = MimeTypeUtils.generateMultipartBoundaryString(); @@ -166,7 +166,7 @@ public class ResourceRegionEncoderTests { } @Test - public void nonExisting() { + void nonExisting() { Resource resource = new ClassPathResource("ResourceRegionEncoderTests.txt", getClass()); Resource nonExisting = new ClassPathResource("does not exist", getClass()); Flux regions = Flux.just( diff --git a/spring-core/src/test/java/org/springframework/core/codec/StringDecoderTests.java b/spring-core/src/test/java/org/springframework/core/codec/StringDecoderTests.java index 5ead7d8ef8..e22426827d 100644 --- a/spring-core/src/test/java/org/springframework/core/codec/StringDecoderTests.java +++ b/spring-core/src/test/java/org/springframework/core/codec/StringDecoderTests.java @@ -43,12 +43,12 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Brian Clozel * @author Mark Paluch */ -public class StringDecoderTests extends AbstractDecoderTestCase { +class StringDecoderTests extends AbstractDecoderTestCase { private static final ResolvableType TYPE = ResolvableType.forClass(String.class); - public StringDecoderTests() { + StringDecoderTests() { super(StringDecoder.allMimeTypes()); } @@ -77,7 +77,7 @@ public class StringDecoderTests extends AbstractDecoderTestCase { } @Test - public void decodeMultibyteCharacterUtf16() { + void decodeMultibyteCharacterUtf16() { String u = "ü"; String e = "é"; String o = "ø"; @@ -103,7 +103,7 @@ public class StringDecoderTests extends AbstractDecoderTestCase { } @Test - public void decodeNewLine() { + void decodeNewLine() { Flux input = Flux.just( stringBuffer("\r\nabc\n"), stringBuffer("def"), @@ -128,7 +128,7 @@ public class StringDecoderTests extends AbstractDecoderTestCase { } @Test - public void decodeNewLineIncludeDelimiters() { + void decodeNewLineIncludeDelimiters() { this.decoder = StringDecoder.allMimeTypes(StringDecoder.DEFAULT_DELIMITERS, false); Flux input = Flux.just( @@ -155,7 +155,7 @@ public class StringDecoderTests extends AbstractDecoderTestCase { } @Test - public void decodeEmptyFlux() { + void decodeEmptyFlux() { Flux input = Flux.empty(); testDecode(input, String.class, step -> step @@ -164,7 +164,7 @@ public class StringDecoderTests extends AbstractDecoderTestCase { } @Test - public void decodeEmptyDataBuffer() { + void decodeEmptyDataBuffer() { Flux input = Flux.just(stringBuffer("")); Flux output = this.decoder.decode(input, TYPE, null, Collections.emptyMap()); @@ -190,7 +190,7 @@ public class StringDecoderTests extends AbstractDecoderTestCase { } @Test - public void decodeToMonoWithEmptyFlux() { + void decodeToMonoWithEmptyFlux() { Flux input = Flux.empty(); testDecodeToMono(input, String.class, step -> step @@ -205,5 +205,4 @@ public class StringDecoderTests extends AbstractDecoderTestCase { return buffer; } - } diff --git a/spring-core/src/test/java/org/springframework/core/convert/TypeDescriptorTests.java b/spring-core/src/test/java/org/springframework/core/convert/TypeDescriptorTests.java index 428d40dd99..e77ffaa41b 100644 --- a/spring-core/src/test/java/org/springframework/core/convert/TypeDescriptorTests.java +++ b/spring-core/src/test/java/org/springframework/core/convert/TypeDescriptorTests.java @@ -55,10 +55,10 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException * @author Nathan Piper */ @SuppressWarnings("rawtypes") -public class TypeDescriptorTests { +class TypeDescriptorTests { @Test - public void parameterPrimitive() throws Exception { + void parameterPrimitive() throws Exception { TypeDescriptor desc = new TypeDescriptor(new MethodParameter(getClass().getMethod("testParameterPrimitive", int.class), 0)); assertThat(desc.getType()).isEqualTo(int.class); assertThat(desc.getObjectType()).isEqualTo(Integer.class); @@ -71,7 +71,7 @@ public class TypeDescriptorTests { } @Test - public void parameterScalar() throws Exception { + void parameterScalar() throws Exception { TypeDescriptor desc = new TypeDescriptor(new MethodParameter(getClass().getMethod("testParameterScalar", String.class), 0)); assertThat(desc.getType()).isEqualTo(String.class); assertThat(desc.getObjectType()).isEqualTo(String.class); @@ -85,7 +85,7 @@ public class TypeDescriptorTests { } @Test - public void parameterList() throws Exception { + void parameterList() throws Exception { MethodParameter methodParameter = new MethodParameter(getClass().getMethod("testParameterList", List.class), 0); TypeDescriptor desc = new TypeDescriptor(methodParameter); assertThat(desc.getType()).isEqualTo(List.class); @@ -106,7 +106,7 @@ public class TypeDescriptorTests { } @Test - public void parameterListNoParamTypes() throws Exception { + void parameterListNoParamTypes() throws Exception { MethodParameter methodParameter = new MethodParameter(getClass().getMethod("testParameterListNoParamTypes", List.class), 0); TypeDescriptor desc = new TypeDescriptor(methodParameter); assertThat(desc.getType()).isEqualTo(List.class); @@ -122,7 +122,7 @@ public class TypeDescriptorTests { } @Test - public void parameterArray() throws Exception { + void parameterArray() throws Exception { MethodParameter methodParameter = new MethodParameter(getClass().getMethod("testParameterArray", Integer[].class), 0); TypeDescriptor desc = new TypeDescriptor(methodParameter); assertThat(desc.getType()).isEqualTo(Integer[].class); @@ -139,7 +139,7 @@ public class TypeDescriptorTests { } @Test - public void parameterMap() throws Exception { + void parameterMap() throws Exception { MethodParameter methodParameter = new MethodParameter(getClass().getMethod("testParameterMap", Map.class), 0); TypeDescriptor desc = new TypeDescriptor(methodParameter); assertThat(desc.getType()).isEqualTo(Map.class); @@ -159,7 +159,7 @@ public class TypeDescriptorTests { } @Test - public void parameterAnnotated() throws Exception { + void parameterAnnotated() throws Exception { TypeDescriptor t1 = new TypeDescriptor(new MethodParameter(getClass().getMethod("testAnnotatedMethod", String.class), 0)); assertThat(t1.getType()).isEqualTo(String.class); assertThat(t1.getAnnotations().length).isEqualTo(1); @@ -169,14 +169,14 @@ public class TypeDescriptorTests { } @Test - public void getAnnotationsReturnsClonedArray() throws Exception { + void getAnnotationsReturnsClonedArray() throws Exception { TypeDescriptor t = new TypeDescriptor(new MethodParameter(getClass().getMethod("testAnnotatedMethod", String.class), 0)); t.getAnnotations()[0] = null; assertThat(t.getAnnotations()[0]).isNotNull(); } @Test - public void propertyComplex() throws Exception { + void propertyComplex() throws Exception { Property property = new Property(getClass(), getClass().getMethod("getComplexProperty"), getClass().getMethod("setComplexProperty", Map.class)); TypeDescriptor desc = new TypeDescriptor(property); @@ -185,7 +185,7 @@ public class TypeDescriptorTests { } @Test - public void propertyGenericType() throws Exception { + void propertyGenericType() throws Exception { GenericType genericBean = new IntegerType(); Property property = new Property(getClass(), genericBean.getClass().getMethod("getProperty"), genericBean.getClass().getMethod("setProperty", Integer.class)); @@ -194,7 +194,7 @@ public class TypeDescriptorTests { } @Test - public void propertyTypeCovariance() throws Exception { + void propertyTypeCovariance() throws Exception { GenericType genericBean = new NumberType(); Property property = new Property(getClass(), genericBean.getClass().getMethod("getProperty"), genericBean.getClass().getMethod("setProperty", Number.class)); @@ -203,7 +203,7 @@ public class TypeDescriptorTests { } @Test - public void propertyGenericTypeList() throws Exception { + void propertyGenericTypeList() throws Exception { GenericType genericBean = new IntegerType(); Property property = new Property(getClass(), genericBean.getClass().getMethod("getListProperty"), genericBean.getClass().getMethod("setListProperty", List.class)); @@ -213,7 +213,7 @@ public class TypeDescriptorTests { } @Test - public void propertyGenericClassList() throws Exception { + void propertyGenericClassList() throws Exception { IntegerClass genericBean = new IntegerClass(); Property property = new Property(genericBean.getClass(), genericBean.getClass().getMethod("getListProperty"), genericBean.getClass().getMethod("setListProperty", List.class)); @@ -225,7 +225,7 @@ public class TypeDescriptorTests { } @Test - public void property() throws Exception { + void property() throws Exception { Property property = new Property( getClass(), getClass().getMethod("getProperty"), getClass().getMethod("setProperty", Map.class)); TypeDescriptor desc = new TypeDescriptor(property); @@ -238,17 +238,17 @@ public class TypeDescriptorTests { } @Test - public void getAnnotationOnMethodThatIsLocallyAnnotated() throws Exception { + void getAnnotationOnMethodThatIsLocallyAnnotated() throws Exception { assertAnnotationFoundOnMethod(MethodAnnotation1.class, "methodWithLocalAnnotation"); } @Test - public void getAnnotationOnMethodThatIsMetaAnnotated() throws Exception { + void getAnnotationOnMethodThatIsMetaAnnotated() throws Exception { assertAnnotationFoundOnMethod(MethodAnnotation1.class, "methodWithComposedAnnotation"); } @Test - public void getAnnotationOnMethodThatIsMetaMetaAnnotated() throws Exception { + void getAnnotationOnMethodThatIsMetaMetaAnnotated() throws Exception { assertAnnotationFoundOnMethod(MethodAnnotation1.class, "methodWithComposedComposedAnnotation"); } @@ -258,7 +258,7 @@ public class TypeDescriptorTests { } @Test - public void fieldScalar() throws Exception { + void fieldScalar() throws Exception { TypeDescriptor typeDescriptor = new TypeDescriptor(getClass().getField("fieldScalar")); assertThat(typeDescriptor.isPrimitive()).isFalse(); assertThat(typeDescriptor.isArray()).isFalse(); @@ -269,7 +269,7 @@ public class TypeDescriptorTests { } @Test - public void fieldList() throws Exception { + void fieldList() throws Exception { TypeDescriptor typeDescriptor = new TypeDescriptor(TypeDescriptorTests.class.getDeclaredField("listOfString")); assertThat(typeDescriptor.isArray()).isFalse(); assertThat(typeDescriptor.getType()).isEqualTo(List.class); @@ -278,7 +278,7 @@ public class TypeDescriptorTests { } @Test - public void fieldListOfListOfString() throws Exception { + void fieldListOfListOfString() throws Exception { TypeDescriptor typeDescriptor = new TypeDescriptor(TypeDescriptorTests.class.getDeclaredField("listOfListOfString")); assertThat(typeDescriptor.isArray()).isFalse(); assertThat(typeDescriptor.getType()).isEqualTo(List.class); @@ -288,7 +288,7 @@ public class TypeDescriptorTests { } @Test - public void fieldListOfListUnknown() throws Exception { + void fieldListOfListUnknown() throws Exception { TypeDescriptor typeDescriptor = new TypeDescriptor(TypeDescriptorTests.class.getDeclaredField("listOfListOfUnknown")); assertThat(typeDescriptor.isArray()).isFalse(); assertThat(typeDescriptor.getType()).isEqualTo(List.class); @@ -298,7 +298,7 @@ public class TypeDescriptorTests { } @Test - public void fieldArray() throws Exception { + void fieldArray() throws Exception { TypeDescriptor typeDescriptor = new TypeDescriptor(TypeDescriptorTests.class.getDeclaredField("intArray")); assertThat(typeDescriptor.isArray()).isTrue(); assertThat(typeDescriptor.getElementTypeDescriptor().getType()).isEqualTo(Integer.TYPE); @@ -306,7 +306,7 @@ public class TypeDescriptorTests { } @Test - public void fieldComplexTypeDescriptor() throws Exception { + void fieldComplexTypeDescriptor() throws Exception { TypeDescriptor typeDescriptor = new TypeDescriptor(TypeDescriptorTests.class.getDeclaredField("arrayOfListOfString")); assertThat(typeDescriptor.isArray()).isTrue(); assertThat(typeDescriptor.getElementTypeDescriptor().getType()).isEqualTo(List.class); @@ -315,7 +315,7 @@ public class TypeDescriptorTests { } @Test - public void fieldComplexTypeDescriptor2() throws Exception { + void fieldComplexTypeDescriptor2() throws Exception { TypeDescriptor typeDescriptor = new TypeDescriptor(TypeDescriptorTests.class.getDeclaredField("nestedMapField")); assertThat(typeDescriptor.isMap()).isTrue(); assertThat(typeDescriptor.getMapKeyTypeDescriptor().getType()).isEqualTo(String.class); @@ -325,7 +325,7 @@ public class TypeDescriptorTests { } @Test - public void fieldMap() throws Exception { + void fieldMap() throws Exception { TypeDescriptor desc = new TypeDescriptor(TypeDescriptorTests.class.getField("fieldMap")); assertThat(desc.isMap()).isTrue(); assertThat(desc.getMapKeyTypeDescriptor().getElementTypeDescriptor().getType()).isEqualTo(Integer.class); @@ -333,14 +333,14 @@ public class TypeDescriptorTests { } @Test - public void fieldAnnotated() throws Exception { + void fieldAnnotated() throws Exception { TypeDescriptor typeDescriptor = new TypeDescriptor(getClass().getField("fieldAnnotated")); assertThat(typeDescriptor.getAnnotations().length).isEqualTo(1); assertThat(typeDescriptor.getAnnotation(FieldAnnotation.class)).isNotNull(); } @Test - public void valueOfScalar() { + void valueOfScalar() { TypeDescriptor typeDescriptor = TypeDescriptor.valueOf(Integer.class); assertThat(typeDescriptor.isPrimitive()).isFalse(); assertThat(typeDescriptor.isArray()).isFalse(); @@ -351,7 +351,7 @@ public class TypeDescriptorTests { } @Test - public void valueOfPrimitive() { + void valueOfPrimitive() { TypeDescriptor typeDescriptor = TypeDescriptor.valueOf(int.class); assertThat(typeDescriptor.isPrimitive()).isTrue(); assertThat(typeDescriptor.isArray()).isFalse(); @@ -362,7 +362,7 @@ public class TypeDescriptorTests { } @Test - public void valueOfArray() throws Exception { + void valueOfArray() throws Exception { TypeDescriptor typeDescriptor = TypeDescriptor.valueOf(int[].class); assertThat(typeDescriptor.isArray()).isTrue(); assertThat(typeDescriptor.isCollection()).isFalse(); @@ -371,7 +371,7 @@ public class TypeDescriptorTests { } @Test - public void valueOfCollection() throws Exception { + void valueOfCollection() throws Exception { TypeDescriptor typeDescriptor = TypeDescriptor.valueOf(Collection.class); assertThat(typeDescriptor.isCollection()).isTrue(); assertThat(typeDescriptor.isArray()).isFalse(); @@ -380,61 +380,61 @@ public class TypeDescriptorTests { } @Test - public void forObject() { + void forObject() { TypeDescriptor desc = TypeDescriptor.forObject("3"); assertThat(desc.getType()).isEqualTo(String.class); } @Test - public void forObjectNullTypeDescriptor() { + void forObjectNullTypeDescriptor() { TypeDescriptor desc = TypeDescriptor.forObject(null); assertThat((Object) desc).isNull(); } @Test - public void nestedMethodParameterType2Levels() throws Exception { + void nestedMethodParameterType2Levels() throws Exception { TypeDescriptor t1 = TypeDescriptor.nested(new MethodParameter(getClass().getMethod("test2", List.class), 0), 2); assertThat(t1.getType()).isEqualTo(String.class); } @Test - public void nestedMethodParameterTypeMap() throws Exception { + void nestedMethodParameterTypeMap() throws Exception { TypeDescriptor t1 = TypeDescriptor.nested(new MethodParameter(getClass().getMethod("test3", Map.class), 0), 1); assertThat(t1.getType()).isEqualTo(String.class); } @Test - public void nestedMethodParameterTypeMapTwoLevels() throws Exception { + void nestedMethodParameterTypeMapTwoLevels() throws Exception { TypeDescriptor t1 = TypeDescriptor.nested(new MethodParameter(getClass().getMethod("test4", List.class), 0), 2); assertThat(t1.getType()).isEqualTo(String.class); } @Test - public void nestedMethodParameterNot1NestedLevel() throws Exception { + void nestedMethodParameterNot1NestedLevel() throws Exception { assertThatIllegalArgumentException().isThrownBy(() -> TypeDescriptor.nested(new MethodParameter(getClass().getMethod("test4", List.class), 0, 2), 2)); } @Test - public void nestedTooManyLevels() throws Exception { + void nestedTooManyLevels() throws Exception { TypeDescriptor t1 = TypeDescriptor.nested(new MethodParameter(getClass().getMethod("test4", List.class), 0), 3); assertThat((Object) t1).isNull(); } @Test - public void nestedMethodParameterTypeNotNestable() throws Exception { + void nestedMethodParameterTypeNotNestable() throws Exception { TypeDescriptor t1 = TypeDescriptor.nested(new MethodParameter(getClass().getMethod("test5", String.class), 0), 2); assertThat((Object) t1).isNull(); } @Test - public void nestedMethodParameterTypeInvalidNestingLevel() throws Exception { + void nestedMethodParameterTypeInvalidNestingLevel() throws Exception { assertThatIllegalArgumentException().isThrownBy(() -> TypeDescriptor.nested(new MethodParameter(getClass().getMethod("test5", String.class), 0, 2), 2)); } @Test - public void nestedNotParameterized() throws Exception { + void nestedNotParameterized() throws Exception { TypeDescriptor t1 = TypeDescriptor.nested(new MethodParameter(getClass().getMethod("test6", List.class), 0), 1); assertThat(t1.getType()).isEqualTo(List.class); assertThat(t1.toString()).isEqualTo("java.util.List"); @@ -443,20 +443,20 @@ public class TypeDescriptorTests { } @Test - public void nestedFieldTypeMapTwoLevels() throws Exception { + void nestedFieldTypeMapTwoLevels() throws Exception { TypeDescriptor t1 = TypeDescriptor.nested(getClass().getField("test4"), 2); assertThat(t1.getType()).isEqualTo(String.class); } @Test - public void nestedPropertyTypeMapTwoLevels() throws Exception { + void nestedPropertyTypeMapTwoLevels() throws Exception { Property property = new Property(getClass(), getClass().getMethod("getTest4"), getClass().getMethod("setTest4", List.class)); TypeDescriptor t1 = TypeDescriptor.nested(property, 2); assertThat(t1.getType()).isEqualTo(String.class); } @Test - public void collection() { + void collection() { TypeDescriptor desc = TypeDescriptor.collection(List.class, TypeDescriptor.valueOf(Integer.class)); assertThat(desc.getType()).isEqualTo(List.class); assertThat(desc.getObjectType()).isEqualTo(List.class); @@ -472,7 +472,7 @@ public class TypeDescriptorTests { } @Test - public void collectionNested() { + void collectionNested() { TypeDescriptor desc = TypeDescriptor.collection(List.class, TypeDescriptor.collection(List.class, TypeDescriptor.valueOf(Integer.class))); assertThat(desc.getType()).isEqualTo(List.class); assertThat(desc.getObjectType()).isEqualTo(List.class); @@ -488,7 +488,7 @@ public class TypeDescriptorTests { } @Test - public void map() { + void map() { TypeDescriptor desc = TypeDescriptor.map(Map.class, TypeDescriptor.valueOf(String.class), TypeDescriptor.valueOf(Integer.class)); assertThat(desc.getType()).isEqualTo(Map.class); assertThat(desc.getObjectType()).isEqualTo(Map.class); @@ -504,7 +504,7 @@ public class TypeDescriptorTests { } @Test - public void mapNested() { + void mapNested() { TypeDescriptor desc = TypeDescriptor.map(Map.class, TypeDescriptor.valueOf(String.class), TypeDescriptor.map(Map.class, TypeDescriptor.valueOf(String.class), TypeDescriptor.valueOf(Integer.class))); assertThat(desc.getType()).isEqualTo(Map.class); @@ -522,7 +522,7 @@ public class TypeDescriptorTests { } @Test - public void narrow() { + void narrow() { TypeDescriptor desc = TypeDescriptor.valueOf(Number.class); Integer value = Integer.valueOf(3); desc = desc.narrow(value); @@ -530,7 +530,7 @@ public class TypeDescriptorTests { } @Test - public void elementType() { + void elementType() { TypeDescriptor desc = TypeDescriptor.valueOf(List.class); Integer value = Integer.valueOf(3); desc = desc.elementTypeDescriptor(value); @@ -538,7 +538,7 @@ public class TypeDescriptorTests { } @Test - public void elementTypePreserveContext() throws Exception { + void elementTypePreserveContext() throws Exception { TypeDescriptor desc = new TypeDescriptor(getClass().getField("listPreserveContext")); assertThat(desc.getElementTypeDescriptor().getElementTypeDescriptor().getType()).isEqualTo(Integer.class); List value = new ArrayList<>(3); @@ -548,7 +548,7 @@ public class TypeDescriptorTests { } @Test - public void mapKeyType() { + void mapKeyType() { TypeDescriptor desc = TypeDescriptor.valueOf(Map.class); Integer value = Integer.valueOf(3); desc = desc.getMapKeyTypeDescriptor(value); @@ -556,7 +556,7 @@ public class TypeDescriptorTests { } @Test - public void mapKeyTypePreserveContext() throws Exception { + void mapKeyTypePreserveContext() throws Exception { TypeDescriptor desc = new TypeDescriptor(getClass().getField("mapPreserveContext")); assertThat(desc.getMapKeyTypeDescriptor().getElementTypeDescriptor().getType()).isEqualTo(Integer.class); List value = new ArrayList<>(3); @@ -566,7 +566,7 @@ public class TypeDescriptorTests { } @Test - public void mapValueType() { + void mapValueType() { TypeDescriptor desc = TypeDescriptor.valueOf(Map.class); Integer value = Integer.valueOf(3); desc = desc.getMapValueTypeDescriptor(value); @@ -574,7 +574,7 @@ public class TypeDescriptorTests { } @Test - public void mapValueTypePreserveContext() throws Exception { + void mapValueTypePreserveContext() throws Exception { TypeDescriptor desc = new TypeDescriptor(getClass().getField("mapPreserveContext")); assertThat(desc.getMapValueTypeDescriptor().getElementTypeDescriptor().getType()).isEqualTo(Integer.class); List value = new ArrayList<>(3); @@ -584,7 +584,7 @@ public class TypeDescriptorTests { } @Test - public void equality() throws Exception { + void equality() throws Exception { TypeDescriptor t1 = TypeDescriptor.valueOf(String.class); TypeDescriptor t2 = TypeDescriptor.valueOf(String.class); TypeDescriptor t3 = TypeDescriptor.valueOf(Date.class); @@ -621,14 +621,14 @@ public class TypeDescriptorTests { } @Test - public void isAssignableTypes() { + void isAssignableTypes() { assertThat(TypeDescriptor.valueOf(Integer.class).isAssignableTo(TypeDescriptor.valueOf(Number.class))).isTrue(); assertThat(TypeDescriptor.valueOf(Number.class).isAssignableTo(TypeDescriptor.valueOf(Integer.class))).isFalse(); assertThat(TypeDescriptor.valueOf(String.class).isAssignableTo(TypeDescriptor.valueOf(String[].class))).isFalse(); } @Test - public void isAssignableElementTypes() throws Exception { + void isAssignableElementTypes() throws Exception { assertThat(new TypeDescriptor(getClass().getField("listField")).isAssignableTo(new TypeDescriptor(getClass().getField("listField")))).isTrue(); assertThat(new TypeDescriptor(getClass().getField("notGenericList")).isAssignableTo(new TypeDescriptor(getClass().getField("listField")))).isTrue(); assertThat(new TypeDescriptor(getClass().getField("listField")).isAssignableTo(new TypeDescriptor(getClass().getField("notGenericList")))).isTrue(); @@ -637,7 +637,7 @@ public class TypeDescriptorTests { } @Test - public void isAssignableMapKeyValueTypes() throws Exception { + void isAssignableMapKeyValueTypes() throws Exception { assertThat(new TypeDescriptor(getClass().getField("mapField")).isAssignableTo(new TypeDescriptor(getClass().getField("mapField")))).isTrue(); assertThat(new TypeDescriptor(getClass().getField("notGenericMap")).isAssignableTo(new TypeDescriptor(getClass().getField("mapField")))).isTrue(); assertThat(new TypeDescriptor(getClass().getField("mapField")).isAssignableTo(new TypeDescriptor(getClass().getField("notGenericMap")))).isTrue(); @@ -646,7 +646,7 @@ public class TypeDescriptorTests { } @Test - public void multiValueMap() throws Exception { + void multiValueMap() throws Exception { TypeDescriptor td = new TypeDescriptor(getClass().getField("multiValueMap")); assertThat(td.isMap()).isTrue(); assertThat(td.getMapKeyTypeDescriptor().getType()).isEqualTo(String.class); @@ -655,7 +655,7 @@ public class TypeDescriptorTests { } @Test - public void passDownGeneric() throws Exception { + void passDownGeneric() throws Exception { TypeDescriptor td = new TypeDescriptor(getClass().getField("passDownGeneric")); assertThat(td.getElementTypeDescriptor().getType()).isEqualTo(List.class); assertThat(td.getElementTypeDescriptor().getElementTypeDescriptor().getType()).isEqualTo(Set.class); @@ -663,7 +663,7 @@ public class TypeDescriptorTests { } @Test - public void testUpCast() throws Exception { + void upCast() throws Exception { Property property = new Property(getClass(), getClass().getMethod("getProperty"), getClass().getMethod("setProperty", Map.class)); TypeDescriptor typeDescriptor = new TypeDescriptor(property); @@ -672,7 +672,7 @@ public class TypeDescriptorTests { } @Test - public void testUpCastNotSuper() throws Exception { + void upCastNotSuper() throws Exception { Property property = new Property(getClass(), getClass().getMethod("getProperty"), getClass().getMethod("setProperty", Map.class)); TypeDescriptor typeDescriptor = new TypeDescriptor(property); @@ -682,7 +682,7 @@ public class TypeDescriptorTests { } @Test - public void elementTypeForCollectionSubclass() throws Exception { + void elementTypeForCollectionSubclass() throws Exception { @SuppressWarnings("serial") class CustomSet extends HashSet { } @@ -692,7 +692,7 @@ public class TypeDescriptorTests { } @Test - public void elementTypeForMapSubclass() throws Exception { + void elementTypeForMapSubclass() throws Exception { @SuppressWarnings("serial") class CustomMap extends HashMap { } @@ -704,7 +704,7 @@ public class TypeDescriptorTests { } @Test - public void createMapArray() throws Exception { + void createMapArray() throws Exception { TypeDescriptor mapType = TypeDescriptor.map( LinkedHashMap.class, TypeDescriptor.valueOf(String.class), TypeDescriptor.valueOf(Integer.class)); TypeDescriptor arrayType = TypeDescriptor.array(mapType); @@ -713,18 +713,18 @@ public class TypeDescriptorTests { } @Test - public void createStringArray() throws Exception { + void createStringArray() throws Exception { TypeDescriptor arrayType = TypeDescriptor.array(TypeDescriptor.valueOf(String.class)); assertThat(TypeDescriptor.valueOf(String[].class)).isEqualTo(arrayType); } @Test - public void createNullArray() throws Exception { + void createNullArray() throws Exception { assertThat((Object) TypeDescriptor.array(null)).isNull(); } @Test - public void serializable() throws Exception { + void serializable() throws Exception { TypeDescriptor typeDescriptor = TypeDescriptor.forObject(""); ByteArrayOutputStream out = new ByteArrayOutputStream(); ObjectOutputStream outputStream = new ObjectOutputStream(out); @@ -736,20 +736,20 @@ public class TypeDescriptorTests { } @Test - public void createCollectionWithNullElement() throws Exception { + void createCollectionWithNullElement() throws Exception { TypeDescriptor typeDescriptor = TypeDescriptor.collection(List.class, null); assertThat(typeDescriptor.getElementTypeDescriptor()).isNull(); } @Test - public void createMapWithNullElements() throws Exception { + void createMapWithNullElements() throws Exception { TypeDescriptor typeDescriptor = TypeDescriptor.map(LinkedHashMap.class, null, null); assertThat(typeDescriptor.getMapKeyTypeDescriptor()).isNull(); assertThat(typeDescriptor.getMapValueTypeDescriptor()).isNull(); } @Test - public void getSource() throws Exception { + void getSource() throws Exception { Field field = getClass().getField("fieldScalar"); MethodParameter methodParameter = new MethodParameter(getClass().getMethod("testParameterPrimitive", int.class), 0); assertThat(new TypeDescriptor(field).getSource()).isEqualTo(field); diff --git a/spring-core/src/test/java/org/springframework/core/convert/converter/ConvertingComparatorTests.java b/spring-core/src/test/java/org/springframework/core/convert/converter/ConvertingComparatorTests.java index 8ed29d1752..840e10f7c9 100644 --- a/spring-core/src/test/java/org/springframework/core/convert/converter/ConvertingComparatorTests.java +++ b/spring-core/src/test/java/org/springframework/core/convert/converter/ConvertingComparatorTests.java @@ -32,13 +32,12 @@ import org.springframework.util.comparator.ComparableComparator; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; - /** * Tests for {@link ConvertingComparator}. * * @author Phillip Webb */ -public class ConvertingComparatorTests { +class ConvertingComparatorTests { private final StringToInteger converter = new StringToInteger(); @@ -47,45 +46,45 @@ public class ConvertingComparatorTests { private final TestComparator comparator = new TestComparator(); @Test - public void shouldThrowOnNullComparator() throws Exception { + void shouldThrowOnNullComparator() throws Exception { assertThatIllegalArgumentException().isThrownBy(() -> new ConvertingComparator<>(null, this.converter)); } @Test - public void shouldThrowOnNullConverter() throws Exception { + void shouldThrowOnNullConverter() throws Exception { assertThatIllegalArgumentException().isThrownBy(() -> new ConvertingComparator(this.comparator, null)); } @Test - public void shouldThrowOnNullConversionService() throws Exception { + void shouldThrowOnNullConversionService() throws Exception { assertThatIllegalArgumentException().isThrownBy(() -> new ConvertingComparator(this.comparator, null, Integer.class)); } @Test - public void shouldThrowOnNullType() throws Exception { + void shouldThrowOnNullType() throws Exception { assertThatIllegalArgumentException().isThrownBy(() -> new ConvertingComparator(this.comparator, this.conversionService, null)); } @Test - public void shouldUseConverterOnCompare() throws Exception { + void shouldUseConverterOnCompare() throws Exception { ConvertingComparator convertingComparator = new ConvertingComparator<>( this.comparator, this.converter); testConversion(convertingComparator); } @Test - public void shouldUseConversionServiceOnCompare() throws Exception { + void shouldUseConversionServiceOnCompare() throws Exception { ConvertingComparator convertingComparator = new ConvertingComparator<>( comparator, conversionService, Integer.class); testConversion(convertingComparator); } @Test - public void shouldGetForConverter() throws Exception { + void shouldGetForConverter() throws Exception { testConversion(new ConvertingComparator<>(comparator, converter)); } @@ -97,7 +96,7 @@ public class ConvertingComparatorTests { } @Test - public void shouldGetMapEntryKeys() throws Exception { + void shouldGetMapEntryKeys() throws Exception { ArrayList> list = createReverseOrderMapEntryList(); Comparator> comparator = ConvertingComparator.mapEntryKeys(new ComparableComparator()); Collections.sort(list, comparator); @@ -105,7 +104,7 @@ public class ConvertingComparatorTests { } @Test - public void shouldGetMapEntryValues() throws Exception { + void shouldGetMapEntryValues() throws Exception { ArrayList> list = createReverseOrderMapEntryList(); Comparator> comparator = ConvertingComparator.mapEntryValues(new ComparableComparator()); Collections.sort(list, comparator); diff --git a/spring-core/src/test/java/org/springframework/core/convert/converter/DefaultConversionServiceTests.java b/spring-core/src/test/java/org/springframework/core/convert/converter/DefaultConversionServiceTests.java index b2cec3a7c1..8deb6d3f3c 100644 --- a/spring-core/src/test/java/org/springframework/core/convert/converter/DefaultConversionServiceTests.java +++ b/spring-core/src/test/java/org/springframework/core/convert/converter/DefaultConversionServiceTests.java @@ -71,34 +71,34 @@ import static org.springframework.tests.TestGroup.PERFORMANCE; * @author Stephane Nicoll * @author Sam Brannen */ -public class DefaultConversionServiceTests { +class DefaultConversionServiceTests { private final DefaultConversionService conversionService = new DefaultConversionService(); @Test - public void testStringToCharacter() { + void stringToCharacter() { assertThat(conversionService.convert("1", Character.class)).isEqualTo(Character.valueOf('1')); } @Test - public void testStringToCharacterEmptyString() { + void stringToCharacterEmptyString() { assertThat(conversionService.convert("", Character.class)).isEqualTo(null); } @Test - public void testStringToCharacterInvalidString() { + void stringToCharacterInvalidString() { assertThatExceptionOfType(ConversionFailedException.class).isThrownBy(() -> conversionService.convert("invalid", Character.class)); } @Test - public void testCharacterToString() { + void characterToString() { assertThat(conversionService.convert('3', String.class)).isEqualTo("3"); } @Test - public void testStringToBooleanTrue() { + void stringToBooleanTrue() { assertThat(conversionService.convert("true", Boolean.class)).isEqualTo(true); assertThat(conversionService.convert("on", Boolean.class)).isEqualTo(true); assertThat(conversionService.convert("yes", Boolean.class)).isEqualTo(true); @@ -109,7 +109,7 @@ public class DefaultConversionServiceTests { } @Test - public void testStringToBooleanFalse() { + void stringToBooleanFalse() { assertThat(conversionService.convert("false", Boolean.class)).isEqualTo(false); assertThat(conversionService.convert("off", Boolean.class)).isEqualTo(false); assertThat(conversionService.convert("no", Boolean.class)).isEqualTo(false); @@ -120,201 +120,201 @@ public class DefaultConversionServiceTests { } @Test - public void testStringToBooleanEmptyString() { + void stringToBooleanEmptyString() { assertThat(conversionService.convert("", Boolean.class)).isEqualTo(null); } @Test - public void testStringToBooleanInvalidString() { + void stringToBooleanInvalidString() { assertThatExceptionOfType(ConversionFailedException.class).isThrownBy(() -> conversionService.convert("invalid", Boolean.class)); } @Test - public void testBooleanToString() { + void booleanToString() { assertThat(conversionService.convert(true, String.class)).isEqualTo("true"); } @Test - public void testStringToByte() { + void stringToByte() { assertThat(conversionService.convert("1", Byte.class)).isEqualTo((byte) 1); } @Test - public void testByteToString() { + void byteToString() { assertThat(conversionService.convert("A".getBytes()[0], String.class)).isEqualTo("65"); } @Test - public void testStringToShort() { + void stringToShort() { assertThat(conversionService.convert("1", Short.class)).isEqualTo((short) 1); } @Test - public void testShortToString() { + void shortToString() { short three = 3; assertThat(conversionService.convert(three, String.class)).isEqualTo("3"); } @Test - public void testStringToInteger() { + void stringToInteger() { assertThat(conversionService.convert("1", Integer.class)).isEqualTo((int) Integer.valueOf(1)); } @Test - public void testIntegerToString() { + void integerToString() { assertThat(conversionService.convert(3, String.class)).isEqualTo("3"); } @Test - public void testStringToLong() { + void stringToLong() { assertThat(conversionService.convert("1", Long.class)).isEqualTo(Long.valueOf(1)); } @Test - public void testLongToString() { + void longToString() { assertThat(conversionService.convert(3L, String.class)).isEqualTo("3"); } @Test - public void testStringToFloat() { + void stringToFloat() { assertThat(conversionService.convert("1.0", Float.class)).isEqualTo(Float.valueOf("1.0")); } @Test - public void testFloatToString() { + void floatToString() { assertThat(conversionService.convert(Float.valueOf("1.0"), String.class)).isEqualTo("1.0"); } @Test - public void testStringToDouble() { + void stringToDouble() { assertThat(conversionService.convert("1.0", Double.class)).isEqualTo(Double.valueOf("1.0")); } @Test - public void testDoubleToString() { + void doubleToString() { assertThat(conversionService.convert(Double.valueOf("1.0"), String.class)).isEqualTo("1.0"); } @Test - public void testStringToBigInteger() { + void stringToBigInteger() { assertThat(conversionService.convert("1", BigInteger.class)).isEqualTo(new BigInteger("1")); } @Test - public void testBigIntegerToString() { + void bigIntegerToString() { assertThat(conversionService.convert(new BigInteger("100"), String.class)).isEqualTo("100"); } @Test - public void testStringToBigDecimal() { + void stringToBigDecimal() { assertThat(conversionService.convert("1.0", BigDecimal.class)).isEqualTo(new BigDecimal("1.0")); } @Test - public void testBigDecimalToString() { + void bigDecimalToString() { assertThat(conversionService.convert(new BigDecimal("100.00"), String.class)).isEqualTo("100.00"); } @Test - public void testStringToNumber() { + void stringToNumber() { assertThat(conversionService.convert("1.0", Number.class)).isEqualTo(new BigDecimal("1.0")); } @Test - public void testStringToNumberEmptyString() { + void stringToNumberEmptyString() { assertThat(conversionService.convert("", Number.class)).isEqualTo(null); } @Test - public void testStringToEnum() { + void stringToEnum() { assertThat(conversionService.convert("BAR", Foo.class)).isEqualTo(Foo.BAR); } @Test - public void testStringToEnumWithSubclass() { + void stringToEnumWithSubclass() { assertThat(conversionService.convert("BAZ", SubFoo.BAR.getClass())).isEqualTo(SubFoo.BAZ); } @Test - public void testStringToEnumEmptyString() { + void stringToEnumEmptyString() { assertThat(conversionService.convert("", Foo.class)).isEqualTo(null); } @Test - public void testEnumToString() { + void enumToString() { assertThat(conversionService.convert(Foo.BAR, String.class)).isEqualTo("BAR"); } @Test - public void testIntegerToEnum() { + void integerToEnum() { assertThat(conversionService.convert(0, Foo.class)).isEqualTo(Foo.BAR); } @Test - public void testIntegerToEnumWithSubclass() { + void integerToEnumWithSubclass() { assertThat(conversionService.convert(1, SubFoo.BAR.getClass())).isEqualTo(SubFoo.BAZ); } @Test - public void testIntegerToEnumNull() { + void integerToEnumNull() { assertThat(conversionService.convert(null, Foo.class)).isEqualTo(null); } @Test - public void testEnumToInteger() { + void enumToInteger() { assertThat(conversionService.convert(Foo.BAR, Integer.class)).isEqualTo((int) Integer.valueOf(0)); } @Test - public void testStringToEnumSet() throws Exception { + void stringToEnumSet() throws Exception { assertThat(conversionService.convert("BAR", TypeDescriptor.valueOf(String.class), new TypeDescriptor(getClass().getField("enumSet")))).isEqualTo(EnumSet.of(Foo.BAR)); } @Test - public void testStringToLocale() { + void stringToLocale() { assertThat(conversionService.convert("en", Locale.class)).isEqualTo(Locale.ENGLISH); } @Test - public void testStringToLocaleWithCountry() { + void stringToLocaleWithCountry() { assertThat(conversionService.convert("en_US", Locale.class)).isEqualTo(Locale.US); } @Test - public void testStringToLocaleWithLanguageTag() { + void stringToLocaleWithLanguageTag() { assertThat(conversionService.convert("en-US", Locale.class)).isEqualTo(Locale.US); } @Test - public void testStringToCharset() { + void stringToCharset() { assertThat(conversionService.convert("UTF-8", Charset.class)).isEqualTo(StandardCharsets.UTF_8); } @Test - public void testCharsetToString() { + void charsetToString() { assertThat(conversionService.convert(StandardCharsets.UTF_8, String.class)).isEqualTo("UTF-8"); } @Test - public void testStringToCurrency() { + void stringToCurrency() { assertThat(conversionService.convert("EUR", Currency.class)).isEqualTo(Currency.getInstance("EUR")); } @Test - public void testCurrencyToString() { + void currencyToString() { assertThat(conversionService.convert(Currency.getInstance("USD"), String.class)).isEqualTo("USD"); } @Test - public void testStringToString() { + void stringToString() { String str = "test"; assertThat(conversionService.convert(str, String.class)).isSameAs(str); } @Test - public void testUuidToStringAndStringToUuid() { + void uuidToStringAndStringToUuid() { UUID uuid = UUID.randomUUID(); String convertToString = conversionService.convert(uuid, String.class); UUID convertToUUID = conversionService.convert(convertToString, UUID.class); @@ -322,30 +322,30 @@ public class DefaultConversionServiceTests { } @Test - public void testNumberToNumber() { + void numberToNumber() { assertThat(conversionService.convert(1, Long.class)).isEqualTo(Long.valueOf(1)); } @Test - public void testNumberToNumberNotSupportedNumber() { + void numberToNumberNotSupportedNumber() { assertThatExceptionOfType(ConversionFailedException.class).isThrownBy(() -> conversionService.convert(1, CustomNumber.class)); } @Test - public void testNumberToCharacter() { + void numberToCharacter() { assertThat(conversionService.convert(65, Character.class)).isEqualTo(Character.valueOf('A')); } @Test - public void testCharacterToNumber() { + void characterToNumber() { assertThat(conversionService.convert('A', Integer.class)).isEqualTo(65); } // collection conversion @Test - public void convertArrayToCollectionInterface() { + void convertArrayToCollectionInterface() { List result = conversionService.convert(new String[] {"1", "2", "3"}, List.class); assertThat(result.get(0)).isEqualTo("1"); assertThat(result.get(1)).isEqualTo("2"); @@ -353,7 +353,7 @@ public class DefaultConversionServiceTests { } @Test - public void convertArrayToCollectionGenericTypeConversion() throws Exception { + void convertArrayToCollectionGenericTypeConversion() throws Exception { @SuppressWarnings("unchecked") List result = (List) conversionService.convert(new String[] {"1", "2", "3"}, TypeDescriptor .valueOf(String[].class), new TypeDescriptor(getClass().getDeclaredField("genericList"))); @@ -363,7 +363,7 @@ public class DefaultConversionServiceTests { } @Test - public void convertArrayToStream() throws Exception { + void convertArrayToStream() throws Exception { String[] source = {"1", "3", "4"}; @SuppressWarnings("unchecked") Stream result = (Stream) this.conversionService.convert(source, @@ -373,7 +373,7 @@ public class DefaultConversionServiceTests { } @Test - public void testSpr7766() throws Exception { + void spr7766() throws Exception { ConverterRegistry registry = (conversionService); registry.addConverter(new ColorConverter()); @SuppressWarnings("unchecked") @@ -386,7 +386,7 @@ public class DefaultConversionServiceTests { } @Test - public void convertArrayToCollectionImpl() { + void convertArrayToCollectionImpl() { LinkedList result = conversionService.convert(new String[] {"1", "2", "3"}, LinkedList.class); assertThat(result.get(0)).isEqualTo("1"); assertThat(result.get(1)).isEqualTo("2"); @@ -394,31 +394,31 @@ public class DefaultConversionServiceTests { } @Test - public void convertArrayToAbstractCollection() { + void convertArrayToAbstractCollection() { assertThatExceptionOfType(ConversionFailedException.class).isThrownBy(() -> conversionService.convert(new String[]{"1", "2", "3"}, AbstractList.class)); } @Test - public void convertArrayToString() { + void convertArrayToString() { String result = conversionService.convert(new String[] {"1", "2", "3"}, String.class); assertThat(result).isEqualTo("1,2,3"); } @Test - public void convertArrayToStringWithElementConversion() { + void convertArrayToStringWithElementConversion() { String result = conversionService.convert(new Integer[] {1, 2, 3}, String.class); assertThat(result).isEqualTo("1,2,3"); } @Test - public void convertEmptyArrayToString() { + void convertEmptyArrayToString() { String result = conversionService.convert(new String[0], String.class); assertThat(result).isEqualTo(""); } @Test - public void convertStringToArray() { + void convertStringToArray() { String[] result = conversionService.convert("1,2,3", String[].class); assertThat(result.length).isEqualTo(3); assertThat(result[0]).isEqualTo("1"); @@ -427,7 +427,7 @@ public class DefaultConversionServiceTests { } @Test - public void convertStringToArrayWithElementConversion() { + void convertStringToArrayWithElementConversion() { Integer[] result = conversionService.convert("1,2,3", Integer[].class); assertThat(result.length).isEqualTo(3); assertThat((int) result[0]).isEqualTo((int) Integer.valueOf(1)); @@ -436,7 +436,7 @@ public class DefaultConversionServiceTests { } @Test - public void convertStringToPrimitiveArrayWithElementConversion() { + void convertStringToPrimitiveArrayWithElementConversion() { int[] result = conversionService.convert("1,2,3", int[].class); assertThat(result.length).isEqualTo(3); assertThat(result[0]).isEqualTo(1); @@ -445,48 +445,48 @@ public class DefaultConversionServiceTests { } @Test - public void convertEmptyStringToArray() { + void convertEmptyStringToArray() { String[] result = conversionService.convert("", String[].class); assertThat(result.length).isEqualTo(0); } @Test - public void convertArrayToObject() { + void convertArrayToObject() { Object[] array = new Object[] {3L}; Object result = conversionService.convert(array, Long.class); assertThat(result).isEqualTo(3L); } @Test - public void convertArrayToObjectWithElementConversion() { + void convertArrayToObjectWithElementConversion() { String[] array = new String[] {"3"}; Integer result = conversionService.convert(array, Integer.class); assertThat((int) result).isEqualTo((int) Integer.valueOf(3)); } @Test - public void convertArrayToObjectAssignableTargetType() { + void convertArrayToObjectAssignableTargetType() { Long[] array = new Long[] {3L}; Long[] result = (Long[]) conversionService.convert(array, Object.class); assertThat(result).isEqualTo(array); } @Test - public void convertObjectToArray() { + void convertObjectToArray() { Object[] result = conversionService.convert(3L, Object[].class); assertThat(result.length).isEqualTo(1); assertThat(result[0]).isEqualTo(3L); } @Test - public void convertObjectToArrayWithElementConversion() { + void convertObjectToArrayWithElementConversion() { Integer[] result = conversionService.convert(3L, Integer[].class); assertThat(result.length).isEqualTo(1); assertThat((int) result[0]).isEqualTo((int) Integer.valueOf(3)); } @Test - public void convertCollectionToArray() { + void convertCollectionToArray() { List list = new ArrayList<>(); list.add("1"); list.add("2"); @@ -498,7 +498,7 @@ public class DefaultConversionServiceTests { } @Test - public void convertCollectionToArrayWithElementConversion() { + void convertCollectionToArrayWithElementConversion() { List list = new ArrayList<>(); list.add("1"); list.add("2"); @@ -510,14 +510,14 @@ public class DefaultConversionServiceTests { } @Test - public void convertCollectionToString() { + void convertCollectionToString() { List list = Arrays.asList("foo", "bar"); String result = conversionService.convert(list, String.class); assertThat(result).isEqualTo("foo,bar"); } @Test - public void convertCollectionToStringWithElementConversion() throws Exception { + void convertCollectionToStringWithElementConversion() throws Exception { List list = Arrays.asList(3, 5); String result = (String) conversionService.convert(list, new TypeDescriptor(getClass().getField("genericList")), TypeDescriptor.valueOf(String.class)); @@ -525,7 +525,7 @@ public class DefaultConversionServiceTests { } @Test - public void convertStringToCollection() { + void convertStringToCollection() { List result = conversionService.convert("1,2,3", List.class); assertThat(result.size()).isEqualTo(3); assertThat(result.get(0)).isEqualTo("1"); @@ -534,7 +534,7 @@ public class DefaultConversionServiceTests { } @Test - public void convertStringToCollectionWithElementConversion() throws Exception { + void convertStringToCollectionWithElementConversion() throws Exception { List result = (List) conversionService.convert("1,2,3", TypeDescriptor.valueOf(String.class), new TypeDescriptor(getClass().getField("genericList"))); assertThat(result.size()).isEqualTo(3); @@ -544,27 +544,27 @@ public class DefaultConversionServiceTests { } @Test - public void convertEmptyStringToCollection() { + void convertEmptyStringToCollection() { Collection result = conversionService.convert("", Collection.class); assertThat(result.size()).isEqualTo(0); } @Test - public void convertCollectionToObject() { + void convertCollectionToObject() { List list = Collections.singletonList(3L); Long result = conversionService.convert(list, Long.class); assertThat(result).isEqualTo(Long.valueOf(3)); } @Test - public void convertCollectionToObjectWithElementConversion() { + void convertCollectionToObjectWithElementConversion() { List list = Collections.singletonList("3"); Integer result = conversionService.convert(list, Integer.class); assertThat((int) result).isEqualTo((int) Integer.valueOf(3)); } @Test - public void convertCollectionToObjectAssignableTarget() throws Exception { + void convertCollectionToObjectAssignableTarget() throws Exception { Collection source = new ArrayList<>(); source.add("foo"); Object result = conversionService.convert(source, new TypeDescriptor(getClass().getField("assignableTarget"))); @@ -572,7 +572,7 @@ public class DefaultConversionServiceTests { } @Test - public void convertCollectionToObjectWithCustomConverter() { + void convertCollectionToObjectWithCustomConverter() { List source = new ArrayList<>(); source.add("A"); source.add("B"); @@ -582,14 +582,14 @@ public class DefaultConversionServiceTests { } @Test - public void convertObjectToCollection() { + void convertObjectToCollection() { List result = conversionService.convert(3L, List.class); assertThat(result.size()).isEqualTo(1); assertThat(result.get(0)).isEqualTo(3L); } @Test - public void convertObjectToCollectionWithElementConversion() throws Exception { + void convertObjectToCollectionWithElementConversion() throws Exception { @SuppressWarnings("unchecked") List result = (List) conversionService.convert(3L, TypeDescriptor.valueOf(Long.class), new TypeDescriptor(getClass().getField("genericList"))); @@ -598,7 +598,7 @@ public class DefaultConversionServiceTests { } @Test - public void convertStringArrayToIntegerArray() { + void convertStringArrayToIntegerArray() { Integer[] result = conversionService.convert(new String[] {"1", "2", "3"}, Integer[].class); assertThat((int) result[0]).isEqualTo((int) Integer.valueOf(1)); assertThat((int) result[1]).isEqualTo((int) Integer.valueOf(2)); @@ -606,7 +606,7 @@ public class DefaultConversionServiceTests { } @Test - public void convertStringArrayToIntArray() { + void convertStringArrayToIntArray() { int[] result = conversionService.convert(new String[] {"1", "2", "3"}, int[].class); assertThat(result[0]).isEqualTo(1); assertThat(result[1]).isEqualTo(2); @@ -614,7 +614,7 @@ public class DefaultConversionServiceTests { } @Test - public void convertIntegerArrayToIntegerArray() { + void convertIntegerArrayToIntegerArray() { Integer[] result = conversionService.convert(new Integer[] {1, 2, 3}, Integer[].class); assertThat((int) result[0]).isEqualTo((int) Integer.valueOf(1)); assertThat((int) result[1]).isEqualTo((int) Integer.valueOf(2)); @@ -622,7 +622,7 @@ public class DefaultConversionServiceTests { } @Test - public void convertIntegerArrayToIntArray() { + void convertIntegerArrayToIntArray() { int[] result = conversionService.convert(new Integer[] {1, 2, 3}, int[].class); assertThat(result[0]).isEqualTo(1); assertThat(result[1]).isEqualTo(2); @@ -630,7 +630,7 @@ public class DefaultConversionServiceTests { } @Test - public void convertObjectArrayToIntegerArray() { + void convertObjectArrayToIntegerArray() { Integer[] result = conversionService.convert(new Object[] {1, 2, 3}, Integer[].class); assertThat((int) result[0]).isEqualTo((int) Integer.valueOf(1)); assertThat((int) result[1]).isEqualTo((int) Integer.valueOf(2)); @@ -638,7 +638,7 @@ public class DefaultConversionServiceTests { } @Test - public void convertObjectArrayToIntArray() { + void convertObjectArrayToIntArray() { int[] result = conversionService.convert(new Object[] {1, 2, 3}, int[].class); assertThat(result[0]).isEqualTo(1); assertThat(result[1]).isEqualTo(2); @@ -646,14 +646,14 @@ public class DefaultConversionServiceTests { } @Test - public void convertByteArrayToWrapperArray() { + void convertByteArrayToWrapperArray() { byte[] byteArray = new byte[] {1, 2, 3}; Byte[] converted = conversionService.convert(byteArray, Byte[].class); assertThat(converted).isEqualTo(new Byte[]{1, 2, 3}); } @Test - public void convertArrayToArrayAssignable() { + void convertArrayToArrayAssignable() { int[] result = conversionService.convert(new int[] {1, 2, 3}, int[].class); assertThat(result[0]).isEqualTo(1); assertThat(result[1]).isEqualTo(2); @@ -661,7 +661,7 @@ public class DefaultConversionServiceTests { } @Test - public void convertListOfNonStringifiable() { + void convertListOfNonStringifiable() { List list = Arrays.asList(new TestEntity(1L), new TestEntity(2L)); assertThat(conversionService.canConvert(list.getClass(), String.class)).isTrue(); try { @@ -675,7 +675,7 @@ public class DefaultConversionServiceTests { } @Test - public void convertListOfStringToString() { + void convertListOfStringToString() { List list = Arrays.asList("Foo", "Bar"); assertThat(conversionService.canConvert(list.getClass(), String.class)).isTrue(); String result = conversionService.convert(list, String.class); @@ -683,7 +683,7 @@ public class DefaultConversionServiceTests { } @Test - public void convertListOfListToString() { + void convertListOfListToString() { List list1 = Arrays.asList("Foo", "Bar"); List list2 = Arrays.asList("Baz", "Boop"); List> list = Arrays.asList(list1, list2); @@ -693,7 +693,7 @@ public class DefaultConversionServiceTests { } @Test - public void convertCollectionToCollection() throws Exception { + void convertCollectionToCollection() throws Exception { Set foo = new LinkedHashSet<>(); foo.add("1"); foo.add("2"); @@ -707,7 +707,7 @@ public class DefaultConversionServiceTests { } @Test - public void convertCollectionToCollectionNull() throws Exception { + void convertCollectionToCollectionNull() throws Exception { @SuppressWarnings("unchecked") List bar = (List) conversionService.convert(null, TypeDescriptor.valueOf(LinkedHashSet.class), new TypeDescriptor(getClass().getField("genericList"))); @@ -716,7 +716,7 @@ public class DefaultConversionServiceTests { @Test @SuppressWarnings("rawtypes") - public void convertCollectionToCollectionNotGeneric() { + void convertCollectionToCollectionNotGeneric() { Set foo = new LinkedHashSet<>(); foo.add("1"); foo.add("2"); @@ -730,7 +730,7 @@ public class DefaultConversionServiceTests { @Test @SuppressWarnings({"unchecked", "rawtypes"}) - public void convertCollectionToCollectionSpecialCaseSourceImpl() throws Exception { + void convertCollectionToCollectionSpecialCaseSourceImpl() throws Exception { Map map = new LinkedHashMap(); map.put("1", "1"); map.put("2", "2"); @@ -745,7 +745,7 @@ public class DefaultConversionServiceTests { } @Test - public void collection() { + void collection() { List strings = new ArrayList<>(); strings.add("3"); strings.add("9"); @@ -757,7 +757,7 @@ public class DefaultConversionServiceTests { } @Test - public void convertMapToMap() throws Exception { + void convertMapToMap() throws Exception { Map foo = new HashMap<>(); foo.put("1", "BAR"); foo.put("2", "BAZ"); @@ -769,7 +769,7 @@ public class DefaultConversionServiceTests { } @Test - public void convertHashMapValuesToList() { + void convertHashMapValuesToList() { Map hashMap = new LinkedHashMap<>(); hashMap.put("1", 1); hashMap.put("2", 2); @@ -778,7 +778,7 @@ public class DefaultConversionServiceTests { } @Test - public void map() { + void map() { Map strings = new HashMap<>(); strings.put("3", "9"); strings.put("6", "31"); @@ -790,7 +790,7 @@ public class DefaultConversionServiceTests { } @Test - public void convertPropertiesToString() { + void convertPropertiesToString() { Properties foo = new Properties(); foo.setProperty("1", "BAR"); foo.setProperty("2", "BAZ"); @@ -800,7 +800,7 @@ public class DefaultConversionServiceTests { } @Test - public void convertStringToProperties() { + void convertStringToProperties() { Properties result = conversionService.convert("a=b\nc=2\nd=", Properties.class); assertThat(result.size()).isEqualTo(3); assertThat(result.getProperty("a")).isEqualTo("b"); @@ -809,7 +809,7 @@ public class DefaultConversionServiceTests { } @Test - public void convertStringToPropertiesWithSpaces() { + void convertStringToPropertiesWithSpaces() { Properties result = conversionService.convert(" foo=bar\n bar=baz\n baz=boop", Properties.class); assertThat(result.get("foo")).isEqualTo("bar"); assertThat(result.get("bar")).isEqualTo("baz"); @@ -819,7 +819,7 @@ public class DefaultConversionServiceTests { // generic object conversion @Test - public void convertObjectToStringWithValueOfMethodPresentUsingToString() { + void convertObjectToStringWithValueOfMethodPresentUsingToString() { ISBN.reset(); assertThat(conversionService.convert(new ISBN("123456789"), String.class)).isEqualTo("123456789"); @@ -829,7 +829,7 @@ public class DefaultConversionServiceTests { } @Test - public void convertObjectToObjectUsingValueOfMethod() { + void convertObjectToObjectUsingValueOfMethod() { ISBN.reset(); assertThat(conversionService.convert("123456789", ISBN.class)).isEqualTo(new ISBN("123456789")); @@ -840,7 +840,7 @@ public class DefaultConversionServiceTests { } @Test - public void convertObjectToStringUsingToString() { + void convertObjectToStringUsingToString() { SSN.reset(); assertThat(conversionService.convert(new SSN("123456789"), String.class)).isEqualTo("123456789"); @@ -849,7 +849,7 @@ public class DefaultConversionServiceTests { } @Test - public void convertObjectToObjectUsingObjectConstructor() { + void convertObjectToObjectUsingObjectConstructor() { SSN.reset(); assertThat(conversionService.convert("123456789", SSN.class)).isEqualTo(new SSN("123456789")); @@ -858,64 +858,64 @@ public class DefaultConversionServiceTests { } @Test - public void convertStringToTimezone() { + void convertStringToTimezone() { assertThat(conversionService.convert("GMT+2", TimeZone.class).getID()).isEqualTo("GMT+02:00"); } @Test - public void convertObjectToStringWithJavaTimeOfMethodPresent() { + void convertObjectToStringWithJavaTimeOfMethodPresent() { assertThat(conversionService.convert(ZoneId.of("GMT+1"), String.class).startsWith("GMT+")).isTrue(); } @Test - public void convertObjectToStringNotSupported() { + void convertObjectToStringNotSupported() { assertThat(conversionService.canConvert(TestEntity.class, String.class)).isFalse(); } @Test - public void convertObjectToObjectWithJavaTimeOfMethod() { + void convertObjectToObjectWithJavaTimeOfMethod() { assertThat(conversionService.convert("GMT+1", ZoneId.class)).isEqualTo(ZoneId.of("GMT+1")); } @Test - public void convertObjectToObjectNoValueOfMethodOrConstructor() { + void convertObjectToObjectNoValueOfMethodOrConstructor() { assertThatExceptionOfType(ConverterNotFoundException.class).isThrownBy(() -> conversionService.convert(Long.valueOf(3), SSN.class)); } @Test - public void convertObjectToObjectFinderMethod() { + void convertObjectToObjectFinderMethod() { TestEntity e = conversionService.convert(1L, TestEntity.class); assertThat(e.getId()).isEqualTo(Long.valueOf(1)); } @Test - public void convertObjectToObjectFinderMethodWithNull() { + void convertObjectToObjectFinderMethodWithNull() { TestEntity entity = (TestEntity) conversionService.convert(null, TypeDescriptor.valueOf(String.class), TypeDescriptor.valueOf(TestEntity.class)); assertThat((Object) entity).isNull(); } @Test - public void convertObjectToObjectFinderMethodWithIdConversion() { + void convertObjectToObjectFinderMethodWithIdConversion() { TestEntity entity = conversionService.convert("1", TestEntity.class); assertThat(entity.getId()).isEqualTo(Long.valueOf(1)); } @Test - public void convertCharArrayToString() { + void convertCharArrayToString() { String converted = conversionService.convert(new char[] {'a', 'b', 'c'}, String.class); assertThat(converted).isEqualTo("a,b,c"); } @Test - public void convertStringToCharArray() { + void convertStringToCharArray() { char[] converted = conversionService.convert("a,b,c", char[].class); assertThat(converted).isEqualTo(new char[]{'a', 'b', 'c'}); } @Test - public void convertStringToCustomCharArray() { + void convertStringToCustomCharArray() { conversionService.addConverter(String.class, char[].class, String::toCharArray); char[] converted = conversionService.convert("abc", char[].class); assertThat(converted).isEqualTo(new char[] {'a', 'b', 'c'}); @@ -923,7 +923,7 @@ public class DefaultConversionServiceTests { @Test @SuppressWarnings("unchecked") - public void multidimensionalArrayToListConversionShouldConvertEntriesCorrectly() { + void multidimensionalArrayToListConversionShouldConvertEntriesCorrectly() { String[][] grid = new String[][] {new String[] {"1", "2", "3", "4"}, new String[] {"5", "6", "7", "8"}, new String[] {"9", "10", "11", "12"}}; List converted = conversionService.convert(grid, List.class); @@ -932,7 +932,7 @@ public class DefaultConversionServiceTests { } @Test - public void convertCannotOptimizeArray() { + void convertCannotOptimizeArray() { conversionService.addConverter(Byte.class, Byte.class, source -> (byte) (source + 1)); byte[] byteArray = new byte[] {1, 2, 3}; byte[] converted = conversionService.convert(byteArray, byte[].class); @@ -942,7 +942,7 @@ public class DefaultConversionServiceTests { @Test @SuppressWarnings("unchecked") - public void convertObjectToOptional() { + void convertObjectToOptional() { Method method = ClassUtils.getMethod(TestEntity.class, "handleOptionalValue", Optional.class); MethodParameter parameter = new MethodParameter(method, 0); TypeDescriptor descriptor = new TypeDescriptor(parameter); @@ -952,14 +952,14 @@ public class DefaultConversionServiceTests { } @Test - public void convertObjectToOptionalNull() { + void convertObjectToOptionalNull() { assertThat(conversionService.convert(null, TypeDescriptor.valueOf(Object.class), TypeDescriptor.valueOf(Optional.class))).isSameAs(Optional.empty()); assertThat((Object) conversionService.convert(null, Optional.class)).isSameAs(Optional.empty()); } @Test - public void convertExistingOptional() { + void convertExistingOptional() { assertThat(conversionService.convert(Optional.empty(), TypeDescriptor.valueOf(Object.class), TypeDescriptor.valueOf(Optional.class))).isSameAs(Optional.empty()); assertThat((Object) conversionService.convert(Optional.empty(), Optional.class)).isSameAs(Optional.empty()); @@ -967,7 +967,7 @@ public class DefaultConversionServiceTests { @Test @EnabledForTestGroups(PERFORMANCE) - public void testPerformance1() { + void testPerformance1() { StopWatch watch = new StopWatch("integer->string conversionPerformance"); watch.start("convert 4,000,000 with conversion service"); for (int i = 0; i < 4000000; i++) { diff --git a/spring-core/src/test/java/org/springframework/core/convert/support/ByteBufferConverterTests.java b/spring-core/src/test/java/org/springframework/core/convert/support/ByteBufferConverterTests.java index 71825d2d44..9c0f46ecb4 100644 --- a/spring-core/src/test/java/org/springframework/core/convert/support/ByteBufferConverterTests.java +++ b/spring-core/src/test/java/org/springframework/core/convert/support/ByteBufferConverterTests.java @@ -25,23 +25,19 @@ import org.springframework.core.convert.converter.Converter; import static org.assertj.core.api.Assertions.assertThat; - - - - /** * Tests for {@link ByteBufferConverter}. * * @author Phillip Webb * @author Juergen Hoeller */ -public class ByteBufferConverterTests { +class ByteBufferConverterTests { private GenericConversionService conversionService; @BeforeEach - public void setup() { + void setup() { this.conversionService = new DefaultConversionService(); this.conversionService.addConverter(new ByteArrayToOtherTypeConverter()); this.conversionService.addConverter(new OtherTypeToByteArrayConverter()); @@ -49,7 +45,7 @@ public class ByteBufferConverterTests { @Test - public void byteArrayToByteBuffer() throws Exception { + void byteArrayToByteBuffer() throws Exception { byte[] bytes = new byte[] { 1, 2, 3 }; ByteBuffer convert = this.conversionService.convert(bytes, ByteBuffer.class); assertThat(convert.array()).isNotSameAs(bytes); @@ -57,7 +53,7 @@ public class ByteBufferConverterTests { } @Test - public void byteBufferToByteArray() throws Exception { + void byteBufferToByteArray() throws Exception { byte[] bytes = new byte[] { 1, 2, 3 }; ByteBuffer byteBuffer = ByteBuffer.wrap(bytes); byte[] convert = this.conversionService.convert(byteBuffer, byte[].class); @@ -66,7 +62,7 @@ public class ByteBufferConverterTests { } @Test - public void byteBufferToOtherType() throws Exception { + void byteBufferToOtherType() throws Exception { byte[] bytes = new byte[] { 1, 2, 3 }; ByteBuffer byteBuffer = ByteBuffer.wrap(bytes); OtherType convert = this.conversionService.convert(byteBuffer, OtherType.class); @@ -75,7 +71,7 @@ public class ByteBufferConverterTests { } @Test - public void otherTypeToByteBuffer() throws Exception { + void otherTypeToByteBuffer() throws Exception { byte[] bytes = new byte[] { 1, 2, 3 }; OtherType otherType = new OtherType(bytes); ByteBuffer convert = this.conversionService.convert(otherType, ByteBuffer.class); @@ -84,7 +80,7 @@ public class ByteBufferConverterTests { } @Test - public void byteBufferToByteBuffer() throws Exception { + void byteBufferToByteBuffer() throws Exception { byte[] bytes = new byte[] { 1, 2, 3 }; ByteBuffer byteBuffer = ByteBuffer.wrap(bytes); ByteBuffer convert = this.conversionService.convert(byteBuffer, ByteBuffer.class); @@ -105,7 +101,6 @@ public class ByteBufferConverterTests { } - private static class ByteArrayToOtherTypeConverter implements Converter { @Override diff --git a/spring-core/src/test/java/org/springframework/core/convert/support/CollectionToCollectionConverterTests.java b/spring-core/src/test/java/org/springframework/core/convert/support/CollectionToCollectionConverterTests.java index c9cd470c32..b9eea5c207 100644 --- a/spring-core/src/test/java/org/springframework/core/convert/support/CollectionToCollectionConverterTests.java +++ b/spring-core/src/test/java/org/springframework/core/convert/support/CollectionToCollectionConverterTests.java @@ -48,19 +48,19 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; * @author Juergen Hoeller * @author Stephane Nicoll */ -public class CollectionToCollectionConverterTests { +class CollectionToCollectionConverterTests { private GenericConversionService conversionService = new GenericConversionService(); @BeforeEach - public void setUp() { + void setUp() { conversionService.addConverter(new CollectionToCollectionConverter(conversionService)); } @Test - public void scalarList() throws Exception { + void scalarList() throws Exception { List list = new ArrayList<>(); list.add("9"); list.add("37"); @@ -84,7 +84,7 @@ public class CollectionToCollectionConverterTests { } @Test - public void emptyListToList() throws Exception { + void emptyListToList() throws Exception { conversionService.addConverter(new CollectionToCollectionConverter(conversionService)); conversionService.addConverterFactory(new StringToNumberConverterFactory()); List list = new ArrayList<>(); @@ -95,7 +95,7 @@ public class CollectionToCollectionConverterTests { } @Test - public void emptyListToListDifferentTargetType() throws Exception { + void emptyListToListDifferentTargetType() throws Exception { conversionService.addConverter(new CollectionToCollectionConverter(conversionService)); conversionService.addConverterFactory(new StringToNumberConverterFactory()); List list = new ArrayList<>(); @@ -109,7 +109,7 @@ public class CollectionToCollectionConverterTests { } @Test - public void collectionToObjectInteraction() throws Exception { + void collectionToObjectInteraction() throws Exception { List> list = new ArrayList<>(); list.add(Arrays.asList("9", "12")); list.add(Arrays.asList("37", "23")); @@ -120,7 +120,7 @@ public class CollectionToCollectionConverterTests { @Test @SuppressWarnings("unchecked") - public void arrayCollectionToObjectInteraction() throws Exception { + void arrayCollectionToObjectInteraction() throws Exception { List[] array = new List[2]; array[0] = Arrays.asList("9", "12"); array[1] = Arrays.asList("37", "23"); @@ -132,7 +132,7 @@ public class CollectionToCollectionConverterTests { @Test @SuppressWarnings("unchecked") - public void objectToCollection() throws Exception { + void objectToCollection() throws Exception { List> list = new ArrayList<>(); list.add(Arrays.asList("9", "12")); list.add(Arrays.asList("37", "23")); @@ -151,7 +151,7 @@ public class CollectionToCollectionConverterTests { @Test @SuppressWarnings("unchecked") - public void stringToCollection() throws Exception { + void stringToCollection() throws Exception { List> list = new ArrayList<>(); list.add(Arrays.asList("9,12")); list.add(Arrays.asList("37,23")); @@ -170,21 +170,21 @@ public class CollectionToCollectionConverterTests { } @Test - public void convertEmptyVector_shouldReturnEmptyArrayList() { + void convertEmptyVector_shouldReturnEmptyArrayList() { Vector vector = new Vector<>(); vector.add("Element"); testCollectionConversionToArrayList(vector); } @Test - public void convertNonEmptyVector_shouldReturnNonEmptyArrayList() { + void convertNonEmptyVector_shouldReturnNonEmptyArrayList() { Vector vector = new Vector<>(); vector.add("Element"); testCollectionConversionToArrayList(vector); } @Test - public void testCollectionsEmptyList() throws Exception { + void collectionsEmptyList() throws Exception { CollectionToCollectionConverter converter = new CollectionToCollectionConverter(new GenericConversionService()); TypeDescriptor type = new TypeDescriptor(getClass().getField("list")); converter.convert(list, type, TypeDescriptor.valueOf(Class.forName("java.util.Collections$EmptyList"))); @@ -200,14 +200,14 @@ public class CollectionToCollectionConverterTests { } @Test - public void listToCollectionNoCopyRequired() throws NoSuchFieldException { + void listToCollectionNoCopyRequired() throws NoSuchFieldException { List input = new ArrayList<>(Arrays.asList("foo", "bar")); assertThat(conversionService.convert(input, TypeDescriptor.forObject(input), new TypeDescriptor(getClass().getField("wildcardCollection")))).isSameAs(input); } @Test - public void differentImpls() throws Exception { + void differentImpls() throws Exception { List resources = new ArrayList<>(); resources.add(new ClassPathResource("test")); resources.add(new FileSystemResource("test")); @@ -217,7 +217,7 @@ public class CollectionToCollectionConverterTests { } @Test - public void mixedInNulls() throws Exception { + void mixedInNulls() throws Exception { List resources = new ArrayList<>(); resources.add(new ClassPathResource("test")); resources.add(null); @@ -228,7 +228,7 @@ public class CollectionToCollectionConverterTests { } @Test - public void allNulls() throws Exception { + void allNulls() throws Exception { List resources = new ArrayList<>(); resources.add(null); resources.add(null); @@ -237,7 +237,7 @@ public class CollectionToCollectionConverterTests { } @Test - public void elementTypesNotConvertible() throws Exception { + void elementTypesNotConvertible() throws Exception { List resources = new ArrayList<>(); resources.add(null); resources.add(null); @@ -247,7 +247,7 @@ public class CollectionToCollectionConverterTests { } @Test - public void nothingInCommon() throws Exception { + void nothingInCommon() throws Exception { List resources = new ArrayList<>(); resources.add(new ClassPathResource("test")); resources.add(3); @@ -257,7 +257,7 @@ public class CollectionToCollectionConverterTests { } @Test - public void testStringToEnumSet() throws Exception { + void stringToEnumSet() throws Exception { conversionService.addConverterFactory(new StringToEnumConverterFactory()); List list = new ArrayList<>(); list.add("A"); diff --git a/spring-core/src/test/java/org/springframework/core/convert/support/GenericConversionServiceTests.java b/spring-core/src/test/java/org/springframework/core/convert/support/GenericConversionServiceTests.java index ad5fcb3690..a91c64bb32 100644 --- a/spring-core/src/test/java/org/springframework/core/convert/support/GenericConversionServiceTests.java +++ b/spring-core/src/test/java/org/springframework/core/convert/support/GenericConversionServiceTests.java @@ -67,20 +67,20 @@ import static org.springframework.tests.TestGroup.PERFORMANCE; * @author David Haraburda * @author Sam Brannen */ -public class GenericConversionServiceTests { +class GenericConversionServiceTests { private final GenericConversionService conversionService = new GenericConversionService(); @Test - public void canConvert() { + void canConvert() { assertThat(conversionService.canConvert(String.class, Integer.class)).isFalse(); conversionService.addConverterFactory(new StringToNumberConverterFactory()); assertThat(conversionService.canConvert(String.class, Integer.class)).isTrue(); } @Test - public void canConvertAssignable() { + void canConvertAssignable() { assertThat(conversionService.canConvert(String.class, String.class)).isTrue(); assertThat(conversionService.canConvert(Integer.class, Number.class)).isTrue(); assertThat(conversionService.canConvert(boolean.class, boolean.class)).isTrue(); @@ -88,112 +88,112 @@ public class GenericConversionServiceTests { } @Test - public void canConvertFromClassSourceTypeToNullTargetType() { + void canConvertFromClassSourceTypeToNullTargetType() { assertThatIllegalArgumentException().isThrownBy(() -> conversionService.canConvert(String.class, null)); } @Test - public void canConvertFromTypeDescriptorSourceTypeToNullTargetType() { + void canConvertFromTypeDescriptorSourceTypeToNullTargetType() { assertThatIllegalArgumentException().isThrownBy(() -> conversionService.canConvert(TypeDescriptor.valueOf(String.class), null)); } @Test - public void canConvertNullSourceType() { + void canConvertNullSourceType() { assertThat(conversionService.canConvert(null, Integer.class)).isTrue(); assertThat(conversionService.canConvert(null, TypeDescriptor.valueOf(Integer.class))).isTrue(); } @Test - public void convert() { + void convert() { conversionService.addConverterFactory(new StringToNumberConverterFactory()); assertThat(conversionService.convert("3", Integer.class)).isEqualTo((int) Integer.valueOf(3)); } @Test - public void convertNullSource() { + void convertNullSource() { assertThat(conversionService.convert(null, Integer.class)).isEqualTo(null); } @Test - public void convertNullSourcePrimitiveTarget() { + void convertNullSourcePrimitiveTarget() { assertThatExceptionOfType(ConversionFailedException.class).isThrownBy(() -> conversionService.convert(null, int.class)); } @Test - public void convertNullSourcePrimitiveTargetTypeDescriptor() { + void convertNullSourcePrimitiveTargetTypeDescriptor() { assertThatExceptionOfType(ConversionFailedException.class).isThrownBy(() -> conversionService.convert(null, TypeDescriptor.valueOf(String.class), TypeDescriptor.valueOf(int.class))); } @Test - public void convertNotNullSourceNullSourceTypeDescriptor() { + void convertNotNullSourceNullSourceTypeDescriptor() { assertThatIllegalArgumentException().isThrownBy(() -> conversionService.convert("3", null, TypeDescriptor.valueOf(int.class))); } @Test - public void convertAssignableSource() { + void convertAssignableSource() { assertThat(conversionService.convert(false, boolean.class)).isEqualTo(Boolean.FALSE); assertThat(conversionService.convert(false, Boolean.class)).isEqualTo(Boolean.FALSE); } @Test - public void converterNotFound() { + void converterNotFound() { assertThatExceptionOfType(ConverterNotFoundException.class).isThrownBy(() -> conversionService.convert("3", Integer.class)); } @Test - public void addConverterNoSourceTargetClassInfoAvailable() { + void addConverterNoSourceTargetClassInfoAvailable() { assertThatIllegalArgumentException().isThrownBy(() -> conversionService.addConverter(new UntypedConverter())); } @Test - public void sourceTypeIsVoid() { + void sourceTypeIsVoid() { assertThat(conversionService.canConvert(void.class, String.class)).isFalse(); } @Test - public void targetTypeIsVoid() { + void targetTypeIsVoid() { assertThat(conversionService.canConvert(String.class, void.class)).isFalse(); } @Test - public void convertNull() { + void convertNull() { assertThat(conversionService.convert(null, Integer.class)).isNull(); } @Test - public void convertToNullTargetClass() { + void convertToNullTargetClass() { assertThatIllegalArgumentException().isThrownBy(() -> conversionService.convert("3", (Class) null)); } @Test - public void convertToNullTargetTypeDescriptor() { + void convertToNullTargetTypeDescriptor() { assertThatIllegalArgumentException().isThrownBy(() -> conversionService.convert("3", TypeDescriptor.valueOf(String.class), null)); } @Test - public void convertWrongSourceTypeDescriptor() { + void convertWrongSourceTypeDescriptor() { assertThatIllegalArgumentException().isThrownBy(() -> conversionService.convert("3", TypeDescriptor.valueOf(Integer.class), TypeDescriptor.valueOf(Long.class))); } @Test - public void convertWrongTypeArgument() { + void convertWrongTypeArgument() { conversionService.addConverterFactory(new StringToNumberConverterFactory()); assertThatExceptionOfType(ConversionFailedException.class).isThrownBy(() -> conversionService.convert("BOGUS", Integer.class)); } @Test - public void convertSuperSourceType() { + void convertSuperSourceType() { conversionService.addConverter(new Converter() { @Override public Integer convert(CharSequence source) { @@ -206,14 +206,14 @@ public class GenericConversionServiceTests { // SPR-8718 @Test - public void convertSuperTarget() { + void convertSuperTarget() { conversionService.addConverter(new ColorConverter()); assertThatExceptionOfType(ConverterNotFoundException.class).isThrownBy(() -> conversionService.convert("#000000", SystemColor.class)); } @Test - public void convertObjectToPrimitive() { + void convertObjectToPrimitive() { assertThat(conversionService.canConvert(String.class, boolean.class)).isFalse(); conversionService.addConverter(new StringToBooleanConverter()); assertThat(conversionService.canConvert(String.class, boolean.class)).isTrue(); @@ -225,7 +225,7 @@ public class GenericConversionServiceTests { } @Test - public void convertObjectToPrimitiveViaConverterFactory() { + void convertObjectToPrimitiveViaConverterFactory() { assertThat(conversionService.canConvert(String.class, int.class)).isFalse(); conversionService.addConverterFactory(new StringToNumberConverterFactory()); assertThat(conversionService.canConvert(String.class, int.class)).isTrue(); @@ -234,7 +234,7 @@ public class GenericConversionServiceTests { } @Test - public void genericConverterDelegatingBackToConversionServiceConverterNotFound() { + void genericConverterDelegatingBackToConversionServiceConverterNotFound() { conversionService.addConverter(new ObjectToArrayConverter(conversionService)); assertThat(conversionService.canConvert(String.class, Integer[].class)).isFalse(); assertThatExceptionOfType(ConverterNotFoundException.class).isThrownBy(() -> @@ -242,7 +242,7 @@ public class GenericConversionServiceTests { } @Test - public void testListToIterableConversion() { + void listToIterableConversion() { List raw = new ArrayList<>(); raw.add("one"); raw.add("two"); @@ -251,7 +251,7 @@ public class GenericConversionServiceTests { } @Test - public void testListToObjectConversion() { + void listToObjectConversion() { List raw = new ArrayList<>(); raw.add("one"); raw.add("two"); @@ -260,7 +260,7 @@ public class GenericConversionServiceTests { } @Test - public void testMapToObjectConversion() { + void mapToObjectConversion() { Map raw = new HashMap<>(); raw.put("key", "value"); Object converted = conversionService.convert(raw, Object.class); @@ -268,7 +268,7 @@ public class GenericConversionServiceTests { } @Test - public void testInterfaceToString() { + void interfaceToString() { conversionService.addConverter(new MyBaseInterfaceToStringConverter()); conversionService.addConverter(new ObjectToStringConverter()); Object converted = conversionService.convert(new MyInterfaceImplementer(), String.class); @@ -276,7 +276,7 @@ public class GenericConversionServiceTests { } @Test - public void testInterfaceArrayToStringArray() { + void interfaceArrayToStringArray() { conversionService.addConverter(new MyBaseInterfaceToStringConverter()); conversionService.addConverter(new ArrayToArrayConverter(conversionService)); String[] converted = conversionService.convert(new MyInterface[] {new MyInterfaceImplementer()}, String[].class); @@ -284,7 +284,7 @@ public class GenericConversionServiceTests { } @Test - public void testObjectArrayToStringArray() { + void objectArrayToStringArray() { conversionService.addConverter(new MyBaseInterfaceToStringConverter()); conversionService.addConverter(new ArrayToArrayConverter(conversionService)); String[] converted = conversionService.convert(new MyInterfaceImplementer[] {new MyInterfaceImplementer()}, String[].class); @@ -292,7 +292,7 @@ public class GenericConversionServiceTests { } @Test - public void testStringArrayToResourceArray() { + void stringArrayToResourceArray() { conversionService.addConverter(new MyStringArrayToResourceArrayConverter()); Resource[] converted = conversionService.convert(new String[] { "x1", "z3" }, Resource[].class); List descriptions = Arrays.stream(converted).map(Resource::getDescription).sorted(naturalOrder()).collect(toList()); @@ -300,21 +300,21 @@ public class GenericConversionServiceTests { } @Test - public void testStringArrayToIntegerArray() { + void stringArrayToIntegerArray() { conversionService.addConverter(new MyStringArrayToIntegerArrayConverter()); Integer[] converted = conversionService.convert(new String[] {"x1", "z3"}, Integer[].class); assertThat(converted).isEqualTo(new Integer[] { 1, 3 }); } @Test - public void testStringToIntegerArray() { + void stringToIntegerArray() { conversionService.addConverter(new MyStringToIntegerArrayConverter()); Integer[] converted = conversionService.convert("x1,z3", Integer[].class); assertThat(converted).isEqualTo(new Integer[] { 1, 3 }); } @Test - public void testWildcardMap() throws Exception { + void wildcardMap() throws Exception { Map input = new LinkedHashMap<>(); input.put("key", "value"); Object converted = conversionService.convert(input, TypeDescriptor.forObject(input), new TypeDescriptor(getClass().getField("wildcardMap"))); @@ -322,21 +322,21 @@ public class GenericConversionServiceTests { } @Test - public void testStringToString() { + void stringToString() { String value = "myValue"; String result = conversionService.convert(value, String.class); assertThat(result).isSameAs(value); } @Test - public void testStringToObject() { + void stringToObject() { String value = "myValue"; Object result = conversionService.convert(value, Object.class); assertThat(result).isSameAs(value); } @Test - public void testIgnoreCopyConstructor() { + void ignoreCopyConstructor() { WithCopyConstructor value = new WithCopyConstructor(); Object result = conversionService.convert(value, WithCopyConstructor.class); assertThat(result).isSameAs(value); @@ -344,7 +344,7 @@ public class GenericConversionServiceTests { @Test @EnabledForTestGroups(PERFORMANCE) - public void testPerformance2() throws Exception { + void testPerformance2() throws Exception { StopWatch watch = new StopWatch("list -> list conversionPerformance"); watch.start("convert 4,000,000 with conversion service"); List source = new LinkedList<>(); @@ -369,7 +369,7 @@ public class GenericConversionServiceTests { @Test @EnabledForTestGroups(PERFORMANCE) - public void testPerformance3() throws Exception { + void testPerformance3() throws Exception { StopWatch watch = new StopWatch("map -> map conversionPerformance"); watch.start("convert 4,000,000 with conversion service"); Map source = new HashMap<>(); @@ -391,7 +391,7 @@ public class GenericConversionServiceTests { } @Test - public void emptyListToArray() { + void emptyListToArray() { conversionService.addConverter(new CollectionToArrayConverter(conversionService)); conversionService.addConverterFactory(new StringToNumberConverterFactory()); List list = new ArrayList<>(); @@ -402,7 +402,7 @@ public class GenericConversionServiceTests { } @Test - public void emptyListToObject() { + void emptyListToObject() { conversionService.addConverter(new CollectionToObjectConverter(conversionService)); conversionService.addConverterFactory(new StringToNumberConverterFactory()); List list = new ArrayList<>(); @@ -413,7 +413,7 @@ public class GenericConversionServiceTests { } @Test - public void stringToArrayCanConvert() { + void stringToArrayCanConvert() { conversionService.addConverter(new StringToArrayConverter(conversionService)); assertThat(conversionService.canConvert(String.class, Integer[].class)).isFalse(); conversionService.addConverterFactory(new StringToNumberConverterFactory()); @@ -421,7 +421,7 @@ public class GenericConversionServiceTests { } @Test - public void stringToCollectionCanConvert() throws Exception { + void stringToCollectionCanConvert() throws Exception { conversionService.addConverter(new StringToCollectionConverter(conversionService)); assertThat(conversionService.canConvert(String.class, Collection.class)).isTrue(); TypeDescriptor targetType = new TypeDescriptor(getClass().getField("integerCollection")); @@ -431,14 +431,14 @@ public class GenericConversionServiceTests { } @Test - public void testConvertiblePairsInSet() { + void convertiblePairsInSet() { Set set = new HashSet<>(); set.add(new GenericConverter.ConvertiblePair(Number.class, String.class)); assert set.contains(new GenericConverter.ConvertiblePair(Number.class, String.class)); } @Test - public void testConvertiblePairEqualsAndHash() { + void convertiblePairEqualsAndHash() { GenericConverter.ConvertiblePair pair = new GenericConverter.ConvertiblePair(Number.class, String.class); GenericConverter.ConvertiblePair pairEqual = new GenericConverter.ConvertiblePair(Number.class, String.class); assertThat(pairEqual).isEqualTo(pair); @@ -446,7 +446,7 @@ public class GenericConversionServiceTests { } @Test - public void testConvertiblePairDifferentEqualsAndHash() { + void convertiblePairDifferentEqualsAndHash() { GenericConverter.ConvertiblePair pair = new GenericConverter.ConvertiblePair(Number.class, String.class); GenericConverter.ConvertiblePair pairOpposite = new GenericConverter.ConvertiblePair(String.class, Number.class); assertThat(pair.equals(pairOpposite)).isFalse(); @@ -454,19 +454,19 @@ public class GenericConversionServiceTests { } @Test - public void canConvertIllegalArgumentNullTargetTypeFromClass() { + void canConvertIllegalArgumentNullTargetTypeFromClass() { assertThatIllegalArgumentException().isThrownBy(() -> conversionService.canConvert(String.class, null)); } @Test - public void canConvertIllegalArgumentNullTargetTypeFromTypeDescriptor() { + void canConvertIllegalArgumentNullTargetTypeFromTypeDescriptor() { assertThatIllegalArgumentException().isThrownBy(() -> conversionService.canConvert(TypeDescriptor.valueOf(String.class), null)); } @Test - public void removeConvertible() { + void removeConvertible() { conversionService.addConverter(new ColorConverter()); assertThat(conversionService.canConvert(String.class, Color.class)).isTrue(); conversionService.removeConvertible(String.class, Color.class); @@ -474,7 +474,7 @@ public class GenericConversionServiceTests { } @Test - public void conditionalConverter() { + void conditionalConverter() { MyConditionalConverter converter = new MyConditionalConverter(); conversionService.addConverter(new ColorConverter()); conversionService.addConverter(converter); @@ -483,7 +483,7 @@ public class GenericConversionServiceTests { } @Test - public void conditionalConverterFactory() { + void conditionalConverterFactory() { MyConditionalConverterFactory converter = new MyConditionalConverterFactory(); conversionService.addConverter(new ColorConverter()); conversionService.addConverterFactory(converter); @@ -493,7 +493,7 @@ public class GenericConversionServiceTests { } @Test - public void conditionalConverterCachingForDifferentAnnotationAttributes() throws Exception { + void conditionalConverterCachingForDifferentAnnotationAttributes() throws Exception { conversionService.addConverter(new ColorConverter()); conversionService.addConverter(new MyConditionalColorConverter()); @@ -508,7 +508,7 @@ public class GenericConversionServiceTests { } @Test - public void shouldNotSupportNullConvertibleTypesFromNonConditionalGenericConverter() { + void shouldNotSupportNullConvertibleTypesFromNonConditionalGenericConverter() { GenericConverter converter = new NonConditionalGenericConverter(); assertThatIllegalStateException().isThrownBy(() -> conversionService.addConverter(converter)) @@ -516,7 +516,7 @@ public class GenericConversionServiceTests { } @Test - public void conditionalConversionForAllTypes() { + void conditionalConversionForAllTypes() { MyConditionalGenericConverter converter = new MyConditionalGenericConverter(); conversionService.addConverter(converter); assertThat(conversionService.convert(3, Integer.class)).isEqualTo(3); @@ -525,7 +525,7 @@ public class GenericConversionServiceTests { } @Test - public void convertOptimizeArray() { + void convertOptimizeArray() { // SPR-9566 byte[] byteArray = new byte[] { 1, 2, 3 }; byte[] converted = conversionService.convert(byteArray, byte[].class); @@ -533,19 +533,19 @@ public class GenericConversionServiceTests { } @Test - public void testEnumToStringConversion() { + void enumToStringConversion() { conversionService.addConverter(new EnumToStringConverter(conversionService)); assertThat(conversionService.convert(MyEnum.A, String.class)).isEqualTo("A"); } @Test - public void testSubclassOfEnumToString() throws Exception { + void subclassOfEnumToString() throws Exception { conversionService.addConverter(new EnumToStringConverter(conversionService)); assertThat(conversionService.convert(EnumWithSubclass.FIRST, String.class)).isEqualTo("FIRST"); } @Test - public void testEnumWithInterfaceToStringConversion() { + void enumWithInterfaceToStringConversion() { // SPR-9692 conversionService.addConverter(new EnumToStringConverter(conversionService)); conversionService.addConverter(new MyEnumInterfaceToStringConverter()); @@ -553,21 +553,21 @@ public class GenericConversionServiceTests { } @Test - public void testStringToEnumWithInterfaceConversion() { + void stringToEnumWithInterfaceConversion() { conversionService.addConverterFactory(new StringToEnumConverterFactory()); conversionService.addConverterFactory(new StringToMyEnumInterfaceConverterFactory()); assertThat(conversionService.convert("1", MyEnum.class)).isEqualTo(MyEnum.A); } @Test - public void testStringToEnumWithBaseInterfaceConversion() { + void stringToEnumWithBaseInterfaceConversion() { conversionService.addConverterFactory(new StringToEnumConverterFactory()); conversionService.addConverterFactory(new StringToMyEnumBaseInterfaceConverterFactory()); assertThat(conversionService.convert("base1", MyEnum.class)).isEqualTo(MyEnum.A); } @Test - public void convertNullAnnotatedStringToString() throws Exception { + void convertNullAnnotatedStringToString() throws Exception { String source = null; TypeDescriptor sourceType = new TypeDescriptor(getClass().getField("annotatedString")); TypeDescriptor targetType = TypeDescriptor.valueOf(String.class); @@ -575,7 +575,7 @@ public class GenericConversionServiceTests { } @Test - public void multipleCollectionTypesFromSameSourceType() throws Exception { + void multipleCollectionTypesFromSameSourceType() throws Exception { conversionService.addConverter(new MyStringToRawCollectionConverter()); conversionService.addConverter(new MyStringToGenericCollectionConverter()); conversionService.addConverter(new MyStringToStringCollectionConverter()); @@ -590,7 +590,7 @@ public class GenericConversionServiceTests { } @Test - public void adaptedCollectionTypesFromSameSourceType() throws Exception { + void adaptedCollectionTypesFromSameSourceType() throws Exception { conversionService.addConverter(new MyStringToStringCollectionConverter()); assertThat(conversionService.convert("test", TypeDescriptor.valueOf(String.class), new TypeDescriptor(getClass().getField("stringCollection")))).isEqualTo(Collections.singleton("testX")); @@ -605,7 +605,7 @@ public class GenericConversionServiceTests { } @Test - public void genericCollectionAsSource() throws Exception { + void genericCollectionAsSource() throws Exception { conversionService.addConverter(new MyStringToGenericCollectionConverter()); assertThat(conversionService.convert("test", TypeDescriptor.valueOf(String.class), new TypeDescriptor(getClass().getField("stringCollection")))).isEqualTo(Collections.singleton("testX")); @@ -617,7 +617,7 @@ public class GenericConversionServiceTests { } @Test - public void rawCollectionAsSource() throws Exception { + void rawCollectionAsSource() throws Exception { conversionService.addConverter(new MyStringToRawCollectionConverter()); assertThat(conversionService.convert("test", TypeDescriptor.valueOf(String.class), new TypeDescriptor(getClass().getField("stringCollection")))).isEqualTo(Collections.singleton("testX")); diff --git a/spring-core/src/test/java/org/springframework/core/convert/support/MapToMapConverterTests.java b/spring-core/src/test/java/org/springframework/core/convert/support/MapToMapConverterTests.java index 9284af61bb..fd900a79e7 100644 --- a/spring-core/src/test/java/org/springframework/core/convert/support/MapToMapConverterTests.java +++ b/spring-core/src/test/java/org/springframework/core/convert/support/MapToMapConverterTests.java @@ -41,19 +41,19 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; * @author Phil Webb * @author Juergen Hoeller */ -public class MapToMapConverterTests { +class MapToMapConverterTests { private final GenericConversionService conversionService = new GenericConversionService(); @BeforeEach - public void setUp() { + void setUp() { conversionService.addConverter(new MapToMapConverter(conversionService)); } @Test - public void scalarMap() throws Exception { + void scalarMap() throws Exception { Map map = new HashMap<>(); map.put("1", "9"); map.put("2", "37"); @@ -78,7 +78,7 @@ public class MapToMapConverterTests { } @Test - public void scalarMapNotGenericTarget() throws Exception { + void scalarMapNotGenericTarget() throws Exception { Map map = new HashMap<>(); map.put("1", "9"); map.put("2", "37"); @@ -88,7 +88,7 @@ public class MapToMapConverterTests { } @Test - public void scalarMapNotGenericSourceField() throws Exception { + void scalarMapNotGenericSourceField() throws Exception { Map map = new HashMap<>(); map.put("1", "9"); map.put("2", "37"); @@ -113,7 +113,7 @@ public class MapToMapConverterTests { } @Test - public void collectionMap() throws Exception { + void collectionMap() throws Exception { Map> map = new HashMap<>(); map.put("1", Arrays.asList("9", "12")); map.put("2", Arrays.asList("37", "23")); @@ -139,7 +139,7 @@ public class MapToMapConverterTests { } @Test - public void collectionMapSourceTarget() throws Exception { + void collectionMapSourceTarget() throws Exception { Map> map = new HashMap<>(); map.put("1", Arrays.asList("9", "12")); map.put("2", Arrays.asList("37", "23")); @@ -161,7 +161,7 @@ public class MapToMapConverterTests { } @Test - public void collectionMapNotGenericTarget() throws Exception { + void collectionMapNotGenericTarget() throws Exception { Map> map = new HashMap<>(); map.put("1", Arrays.asList("9", "12")); map.put("2", Arrays.asList("37", "23")); @@ -171,7 +171,7 @@ public class MapToMapConverterTests { } @Test - public void collectionMapNotGenericTargetCollectionToObjectInteraction() throws Exception { + void collectionMapNotGenericTargetCollectionToObjectInteraction() throws Exception { Map> map = new HashMap<>(); map.put("1", Arrays.asList("9", "12")); map.put("2", Arrays.asList("37", "23")); @@ -183,7 +183,7 @@ public class MapToMapConverterTests { } @Test - public void emptyMap() throws Exception { + void emptyMap() throws Exception { Map map = new HashMap<>(); TypeDescriptor sourceType = TypeDescriptor.forObject(map); TypeDescriptor targetType = new TypeDescriptor(getClass().getField("emptyMapTarget")); @@ -193,7 +193,7 @@ public class MapToMapConverterTests { } @Test - public void emptyMapNoTargetGenericInfo() throws Exception { + void emptyMapNoTargetGenericInfo() throws Exception { Map map = new HashMap<>(); assertThat(conversionService.canConvert(Map.class, Map.class)).isTrue(); @@ -201,7 +201,7 @@ public class MapToMapConverterTests { } @Test - public void emptyMapDifferentTargetImplType() throws Exception { + void emptyMapDifferentTargetImplType() throws Exception { Map map = new HashMap<>(); TypeDescriptor sourceType = TypeDescriptor.forObject(map); TypeDescriptor targetType = new TypeDescriptor(getClass().getField("emptyMapDifferentTarget")); @@ -214,7 +214,7 @@ public class MapToMapConverterTests { } @Test - public void noDefaultConstructorCopyNotRequired() throws Exception { + void noDefaultConstructorCopyNotRequired() throws Exception { // SPR-9284 NoDefaultConstructorMap map = new NoDefaultConstructorMap<>( Collections.singletonMap("1", 1)); @@ -232,7 +232,7 @@ public class MapToMapConverterTests { @Test @SuppressWarnings("unchecked") - public void multiValueMapToMultiValueMap() throws Exception { + void multiValueMapToMultiValueMap() throws Exception { DefaultConversionService.addDefaultConverters(conversionService); MultiValueMap source = new LinkedMultiValueMap<>(); source.put("a", Arrays.asList(1, 2, 3)); @@ -247,7 +247,7 @@ public class MapToMapConverterTests { @Test @SuppressWarnings("unchecked") - public void mapToMultiValueMap() throws Exception { + void mapToMultiValueMap() throws Exception { DefaultConversionService.addDefaultConverters(conversionService); Map source = new HashMap<>(); source.put("a", 1); @@ -261,7 +261,7 @@ public class MapToMapConverterTests { } @Test - public void testStringToEnumMap() throws Exception { + void stringToEnumMap() throws Exception { conversionService.addConverterFactory(new StringToEnumConverterFactory()); Map source = new HashMap<>(); source.put("A", 1); diff --git a/spring-core/src/test/java/org/springframework/core/convert/support/StreamConverterTests.java b/spring-core/src/test/java/org/springframework/core/convert/support/StreamConverterTests.java index e8b32a7e59..42f4041ca9 100644 --- a/spring-core/src/test/java/org/springframework/core/convert/support/StreamConverterTests.java +++ b/spring-core/src/test/java/org/springframework/core/convert/support/StreamConverterTests.java @@ -38,7 +38,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException; * @author Stephane Nicoll * @since 4.2 */ -public class StreamConverterTests { +class StreamConverterTests { private final GenericConversionService conversionService = new GenericConversionService(); @@ -46,7 +46,7 @@ public class StreamConverterTests { @BeforeEach - public void setup() { + void setup() { this.conversionService.addConverter(new CollectionToCollectionConverter(this.conversionService)); this.conversionService.addConverter(new ArrayToCollectionConverter(this.conversionService)); this.conversionService.addConverter(new CollectionToArrayConverter(this.conversionService)); @@ -55,7 +55,7 @@ public class StreamConverterTests { @Test - public void convertFromStreamToList() throws NoSuchFieldException { + void convertFromStreamToList() throws NoSuchFieldException { this.conversionService.addConverter(Number.class, String.class, new ObjectToStringConverter()); Stream stream = Arrays.asList(1, 2, 3).stream(); TypeDescriptor listOfStrings = new TypeDescriptor(Types.class.getField("listOfStrings")); @@ -73,7 +73,7 @@ public class StreamConverterTests { } @Test - public void convertFromStreamToArray() throws NoSuchFieldException { + void convertFromStreamToArray() throws NoSuchFieldException { this.conversionService.addConverterFactory(new NumberToNumberConverterFactory()); Stream stream = Arrays.asList(1, 2, 3).stream(); TypeDescriptor arrayOfLongs = new TypeDescriptor(Types.class.getField("arrayOfLongs")); @@ -89,7 +89,7 @@ public class StreamConverterTests { } @Test - public void convertFromStreamToRawList() throws NoSuchFieldException { + void convertFromStreamToRawList() throws NoSuchFieldException { Stream stream = Arrays.asList(1, 2, 3).stream(); TypeDescriptor listOfStrings = new TypeDescriptor(Types.class.getField("rawList")); Object result = this.conversionService.convert(stream, listOfStrings); @@ -106,7 +106,7 @@ public class StreamConverterTests { } @Test - public void convertFromStreamToArrayNoConverter() throws NoSuchFieldException { + void convertFromStreamToArrayNoConverter() throws NoSuchFieldException { Stream stream = Arrays.asList(1, 2, 3).stream(); TypeDescriptor arrayOfLongs = new TypeDescriptor(Types.class.getField("arrayOfLongs")); assertThatExceptionOfType(ConversionFailedException.class).isThrownBy(() -> @@ -116,7 +116,7 @@ public class StreamConverterTests { @Test @SuppressWarnings("resource") - public void convertFromListToStream() throws NoSuchFieldException { + void convertFromListToStream() throws NoSuchFieldException { this.conversionService.addConverterFactory(new StringToNumberConverterFactory()); List stream = Arrays.asList("1", "2", "3"); TypeDescriptor streamOfInteger = new TypeDescriptor(Types.class.getField("streamOfIntegers")); @@ -132,7 +132,7 @@ public class StreamConverterTests { @Test @SuppressWarnings("resource") - public void convertFromArrayToStream() throws NoSuchFieldException { + void convertFromArrayToStream() throws NoSuchFieldException { Integer[] stream = new Integer[] {1, 0, 1}; this.conversionService.addConverter(new Converter() { @Override @@ -153,7 +153,7 @@ public class StreamConverterTests { @Test @SuppressWarnings("resource") - public void convertFromListToRawStream() throws NoSuchFieldException { + void convertFromListToRawStream() throws NoSuchFieldException { List stream = Arrays.asList("1", "2", "3"); TypeDescriptor streamOfInteger = new TypeDescriptor(Types.class.getField("rawStream")); Object result = this.conversionService.convert(stream, streamOfInteger); @@ -169,14 +169,14 @@ public class StreamConverterTests { } @Test - public void doesNotMatchIfNoStream() throws NoSuchFieldException { + void doesNotMatchIfNoStream() throws NoSuchFieldException { assertThat(this.streamConverter.matches( new TypeDescriptor(Types.class.getField("listOfStrings")), new TypeDescriptor(Types.class.getField("arrayOfLongs")))).as("Should not match non stream type").isFalse(); } @Test - public void shouldFailToConvertIfNoStream() throws NoSuchFieldException { + void shouldFailToConvertIfNoStream() throws NoSuchFieldException { TypeDescriptor sourceType = new TypeDescriptor(Types.class.getField("listOfStrings")); TypeDescriptor targetType = new TypeDescriptor(Types.class.getField("arrayOfLongs")); assertThatIllegalStateException().isThrownBy(() -> diff --git a/spring-core/src/test/java/org/springframework/core/env/CompositePropertySourceTests.java b/spring-core/src/test/java/org/springframework/core/env/CompositePropertySourceTests.java index 11936a0fe4..d7bafe3764 100644 --- a/spring-core/src/test/java/org/springframework/core/env/CompositePropertySourceTests.java +++ b/spring-core/src/test/java/org/springframework/core/env/CompositePropertySourceTests.java @@ -27,10 +27,10 @@ import static org.assertj.core.api.Assertions.assertThat; * * @author Phillip Webb */ -public class CompositePropertySourceTests { +class CompositePropertySourceTests { @Test - public void addFirst() { + void addFirst() { PropertySource p1 = new MapPropertySource("p1", Collections.emptyMap()); PropertySource p2 = new MapPropertySource("p2", Collections.emptyMap()); PropertySource p3 = new MapPropertySource("p3", Collections.emptyMap()); diff --git a/spring-core/src/test/java/org/springframework/core/env/CustomEnvironmentTests.java b/spring-core/src/test/java/org/springframework/core/env/CustomEnvironmentTests.java index a768c6f5ac..f564c74a60 100644 --- a/spring-core/src/test/java/org/springframework/core/env/CustomEnvironmentTests.java +++ b/spring-core/src/test/java/org/springframework/core/env/CustomEnvironmentTests.java @@ -24,25 +24,24 @@ import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; - /** * Unit tests covering the extensibility of {@link AbstractEnvironment}. * * @author Chris Beams * @since 3.1 */ -public class CustomEnvironmentTests { +class CustomEnvironmentTests { // -- tests relating to customizing reserved default profiles ---------------------- @Test - public void control() { + void control() { Environment env = new AbstractEnvironment() { }; assertThat(env.acceptsProfiles(defaultProfile())).isTrue(); } @Test - public void withNoReservedDefaultProfile() { + void withNoReservedDefaultProfile() { class CustomEnvironment extends AbstractEnvironment { @Override protected Set getReservedDefaultProfiles() { @@ -55,7 +54,7 @@ public class CustomEnvironmentTests { } @Test - public void withSingleCustomReservedDefaultProfile() { + void withSingleCustomReservedDefaultProfile() { class CustomEnvironment extends AbstractEnvironment { @Override protected Set getReservedDefaultProfiles() { @@ -69,7 +68,7 @@ public class CustomEnvironmentTests { } @Test - public void withMultiCustomReservedDefaultProfile() { + void withMultiCustomReservedDefaultProfile() { class CustomEnvironment extends AbstractEnvironment { @Override @SuppressWarnings("serial") diff --git a/spring-core/src/test/java/org/springframework/core/env/JOptCommandLinePropertySourceTests.java b/spring-core/src/test/java/org/springframework/core/env/JOptCommandLinePropertySourceTests.java index 1183ef0142..252f11157e 100644 --- a/spring-core/src/test/java/org/springframework/core/env/JOptCommandLinePropertySourceTests.java +++ b/spring-core/src/test/java/org/springframework/core/env/JOptCommandLinePropertySourceTests.java @@ -30,10 +30,10 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Chris Beams * @since 3.1 */ -public class JOptCommandLinePropertySourceTests { +class JOptCommandLinePropertySourceTests { @Test - public void withRequiredArg_andArgIsPresent() { + void withRequiredArg_andArgIsPresent() { OptionParser parser = new OptionParser(); parser.accepts("foo").withRequiredArg(); OptionSet options = parser.parse("--foo=bar"); @@ -43,7 +43,7 @@ public class JOptCommandLinePropertySourceTests { } @Test - public void withOptionalArg_andArgIsMissing() { + void withOptionalArg_andArgIsMissing() { OptionParser parser = new OptionParser(); parser.accepts("foo").withOptionalArg(); OptionSet options = parser.parse("--foo"); @@ -54,7 +54,7 @@ public class JOptCommandLinePropertySourceTests { } @Test - public void withNoArg() { + void withNoArg() { OptionParser parser = new OptionParser(); parser.accepts("o1"); parser.accepts("o2"); @@ -68,7 +68,7 @@ public class JOptCommandLinePropertySourceTests { } @Test - public void withRequiredArg_andMultipleArgsPresent_usingDelimiter() { + void withRequiredArg_andMultipleArgsPresent_usingDelimiter() { OptionParser parser = new OptionParser(); parser.accepts("foo").withRequiredArg().withValuesSeparatedBy(','); OptionSet options = parser.parse("--foo=bar,baz,biz"); @@ -79,7 +79,7 @@ public class JOptCommandLinePropertySourceTests { } @Test - public void withRequiredArg_andMultipleArgsPresent_usingRepeatedOption() { + void withRequiredArg_andMultipleArgsPresent_usingRepeatedOption() { OptionParser parser = new OptionParser(); parser.accepts("foo").withRequiredArg().withValuesSeparatedBy(','); OptionSet options = parser.parse("--foo=bar", "--foo=baz", "--foo=biz"); @@ -90,7 +90,7 @@ public class JOptCommandLinePropertySourceTests { } @Test - public void withMissingOption() { + void withMissingOption() { OptionParser parser = new OptionParser(); parser.accepts("foo").withRequiredArg().withValuesSeparatedBy(','); OptionSet options = parser.parse(); // <-- no options whatsoever @@ -100,7 +100,7 @@ public class JOptCommandLinePropertySourceTests { } @Test - public void withDottedOptionName() { + void withDottedOptionName() { OptionParser parser = new OptionParser(); parser.accepts("spring.profiles.active").withRequiredArg(); OptionSet options = parser.parse("--spring.profiles.active=p1"); @@ -110,7 +110,7 @@ public class JOptCommandLinePropertySourceTests { } @Test - public void withDefaultNonOptionArgsNameAndNoNonOptionArgsPresent() { + void withDefaultNonOptionArgsNameAndNoNonOptionArgsPresent() { OptionParser parser = new OptionParser(); parser.acceptsAll(Arrays.asList("o1","option1")).withRequiredArg(); parser.accepts("o2"); @@ -127,7 +127,7 @@ public class JOptCommandLinePropertySourceTests { } @Test - public void withDefaultNonOptionArgsNameAndNonOptionArgsPresent() { + void withDefaultNonOptionArgsNameAndNonOptionArgsPresent() { OptionParser parser = new OptionParser(); parser.accepts("o1").withRequiredArg(); parser.accepts("o2"); @@ -143,7 +143,7 @@ public class JOptCommandLinePropertySourceTests { } @Test - public void withCustomNonOptionArgsNameAndNoNonOptionArgsPresent() { + void withCustomNonOptionArgsNameAndNoNonOptionArgsPresent() { OptionParser parser = new OptionParser(); parser.accepts("o1").withRequiredArg(); parser.accepts("o2"); @@ -160,7 +160,7 @@ public class JOptCommandLinePropertySourceTests { } @Test - public void withRequiredArg_ofTypeEnum() { + void withRequiredArg_ofTypeEnum() { OptionParser parser = new OptionParser(); parser.accepts("o1").withRequiredArg().ofType(OptionEnum.class); OptionSet options = parser.parse("--o1=VAL_1"); diff --git a/spring-core/src/test/java/org/springframework/core/env/MutablePropertySourcesTests.java b/spring-core/src/test/java/org/springframework/core/env/MutablePropertySourcesTests.java index 5fa1fd58f7..fa79f18044 100644 --- a/spring-core/src/test/java/org/springframework/core/env/MutablePropertySourcesTests.java +++ b/spring-core/src/test/java/org/springframework/core/env/MutablePropertySourcesTests.java @@ -30,10 +30,10 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException * @author Chris Beams * @author Juergen Hoeller */ -public class MutablePropertySourcesTests { +class MutablePropertySourcesTests { @Test - public void test() { + void test() { MutablePropertySources sources = new MutablePropertySources(); sources.addLast(new MockPropertySource("b").withProperty("p1", "bValue")); sources.addLast(new MockPropertySource("d").withProperty("p1", "dValue")); @@ -135,13 +135,13 @@ public class MutablePropertySourcesTests { } @Test - public void getNonExistentPropertySourceReturnsNull() { + void getNonExistentPropertySourceReturnsNull() { MutablePropertySources sources = new MutablePropertySources(); assertThat(sources.get("bogus")).isNull(); } @Test - public void iteratorContainsPropertySource() { + void iteratorContainsPropertySource() { MutablePropertySources sources = new MutablePropertySources(); sources.addLast(new MockPropertySource("test")); @@ -155,14 +155,14 @@ public class MutablePropertySourcesTests { } @Test - public void iteratorIsEmptyForEmptySources() { + void iteratorIsEmptyForEmptySources() { MutablePropertySources sources = new MutablePropertySources(); Iterator> it = sources.iterator(); assertThat(it.hasNext()).isFalse(); } @Test - public void streamContainsPropertySource() { + void streamContainsPropertySource() { MutablePropertySources sources = new MutablePropertySources(); sources.addLast(new MockPropertySource("test")); @@ -173,7 +173,7 @@ public class MutablePropertySourcesTests { } @Test - public void streamIsEmptyForEmptySources() { + void streamIsEmptyForEmptySources() { MutablePropertySources sources = new MutablePropertySources(); assertThat(sources.stream()).isNotNull(); assertThat(sources.stream().count()).isEqualTo(0L); diff --git a/spring-core/src/test/java/org/springframework/core/env/ProfilesTests.java b/spring-core/src/test/java/org/springframework/core/env/ProfilesTests.java index 3767916ea0..a4805f59ef 100644 --- a/spring-core/src/test/java/org/springframework/core/env/ProfilesTests.java +++ b/spring-core/src/test/java/org/springframework/core/env/ProfilesTests.java @@ -36,52 +36,52 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException * @author Sam Brannen * @since 5.1 */ -public class ProfilesTests { +class ProfilesTests { @Test - public void ofWhenNullThrowsException() { + void ofWhenNullThrowsException() { assertThatIllegalArgumentException().isThrownBy(() -> Profiles.of((String[]) null)) .withMessageContaining("Must specify at least one profile"); } @Test - public void ofWhenEmptyThrowsException() { + void ofWhenEmptyThrowsException() { assertThatIllegalArgumentException().isThrownBy(() -> Profiles.of()) .withMessageContaining("Must specify at least one profile"); } @Test - public void ofNullElement() { + void ofNullElement() { assertThatIllegalArgumentException().isThrownBy(() -> Profiles.of((String) null)) .withMessageContaining("must contain text"); } @Test - public void ofEmptyElement() { + void ofEmptyElement() { assertThatIllegalArgumentException().isThrownBy(() -> Profiles.of(" ")) .withMessageContaining("must contain text"); } @Test - public void ofSingleElement() { + void ofSingleElement() { Profiles profiles = Profiles.of("spring"); assertThat(profiles.matches(activeProfiles("spring"))).isTrue(); assertThat(profiles.matches(activeProfiles("framework"))).isFalse(); } @Test - public void ofSingleInvertedElement() { + void ofSingleInvertedElement() { Profiles profiles = Profiles.of("!spring"); assertThat(profiles.matches(activeProfiles("spring"))).isFalse(); assertThat(profiles.matches(activeProfiles("framework"))).isTrue(); } @Test - public void ofMultipleElements() { + void ofMultipleElements() { Profiles profiles = Profiles.of("spring", "framework"); assertThat(profiles.matches(activeProfiles("spring"))).isTrue(); assertThat(profiles.matches(activeProfiles("framework"))).isTrue(); @@ -89,7 +89,7 @@ public class ProfilesTests { } @Test - public void ofMultipleElementsWithInverted() { + void ofMultipleElementsWithInverted() { Profiles profiles = Profiles.of("!spring", "framework"); assertThat(profiles.matches(activeProfiles("spring"))).isFalse(); assertThat(profiles.matches(activeProfiles("spring", "framework"))).isTrue(); @@ -98,7 +98,7 @@ public class ProfilesTests { } @Test - public void ofMultipleElementsAllInverted() { + void ofMultipleElementsAllInverted() { Profiles profiles = Profiles.of("!spring", "!framework"); assertThat(profiles.matches(activeProfiles("spring"))).isTrue(); assertThat(profiles.matches(activeProfiles("framework"))).isTrue(); @@ -108,34 +108,34 @@ public class ProfilesTests { } @Test - public void ofSingleExpression() { + void ofSingleExpression() { Profiles profiles = Profiles.of("(spring)"); assertThat(profiles.matches(activeProfiles("spring"))).isTrue(); assertThat(profiles.matches(activeProfiles("framework"))).isFalse(); } @Test - public void ofSingleExpressionInverted() { + void ofSingleExpressionInverted() { Profiles profiles = Profiles.of("!(spring)"); assertThat(profiles.matches(activeProfiles("spring"))).isFalse(); assertThat(profiles.matches(activeProfiles("framework"))).isTrue(); } @Test - public void ofSingleInvertedExpression() { + void ofSingleInvertedExpression() { Profiles profiles = Profiles.of("(!spring)"); assertThat(profiles.matches(activeProfiles("spring"))).isFalse(); assertThat(profiles.matches(activeProfiles("framework"))).isTrue(); } @Test - public void ofOrExpression() { + void ofOrExpression() { Profiles profiles = Profiles.of("(spring | framework)"); assertOrExpression(profiles); } @Test - public void ofOrExpressionWithoutSpaces() { + void ofOrExpressionWithoutSpaces() { Profiles profiles = Profiles.of("(spring|framework)"); assertOrExpression(profiles); } @@ -148,19 +148,19 @@ public class ProfilesTests { } @Test - public void ofAndExpression() { + void ofAndExpression() { Profiles profiles = Profiles.of("(spring & framework)"); assertAndExpression(profiles); } @Test - public void ofAndExpressionWithoutSpaces() { + void ofAndExpressionWithoutSpaces() { Profiles profiles = Profiles.of("spring&framework)"); assertAndExpression(profiles); } @Test - public void ofAndExpressionWithoutParentheses() { + void ofAndExpressionWithoutParentheses() { Profiles profiles = Profiles.of("spring & framework"); assertAndExpression(profiles); } @@ -173,13 +173,13 @@ public class ProfilesTests { } @Test - public void ofNotAndExpression() { + void ofNotAndExpression() { Profiles profiles = Profiles.of("!(spring & framework)"); assertOfNotAndExpression(profiles); } @Test - public void ofNotAndExpressionWithoutSpaces() { + void ofNotAndExpressionWithoutSpaces() { Profiles profiles = Profiles.of("!(spring&framework)"); assertOfNotAndExpression(profiles); } @@ -192,31 +192,31 @@ public class ProfilesTests { } @Test - public void ofAndExpressionWithInvertedSingleElement() { + void ofAndExpressionWithInvertedSingleElement() { Profiles profiles = Profiles.of("!spring & framework"); assertOfAndExpressionWithInvertedSingleElement(profiles); } @Test - public void ofAndExpressionWithInBracketsInvertedSingleElement() { + void ofAndExpressionWithInBracketsInvertedSingleElement() { Profiles profiles = Profiles.of("(!spring) & framework"); assertOfAndExpressionWithInvertedSingleElement(profiles); } @Test - public void ofAndExpressionWithInvertedSingleElementInBrackets() { + void ofAndExpressionWithInvertedSingleElementInBrackets() { Profiles profiles = Profiles.of("! (spring) & framework"); assertOfAndExpressionWithInvertedSingleElement(profiles); } @Test - public void ofAndExpressionWithInvertedSingleElementInBracketsWithoutSpaces() { + void ofAndExpressionWithInvertedSingleElementInBracketsWithoutSpaces() { Profiles profiles = Profiles.of("!(spring)&framework"); assertOfAndExpressionWithInvertedSingleElement(profiles); } @Test - public void ofAndExpressionWithInvertedSingleElementWithoutSpaces() { + void ofAndExpressionWithInvertedSingleElementWithoutSpaces() { Profiles profiles = Profiles.of("!spring&framework"); assertOfAndExpressionWithInvertedSingleElement(profiles); } @@ -229,7 +229,7 @@ public class ProfilesTests { } @Test - public void ofOrExpressionWithInvertedSingleElementWithoutSpaces() { + void ofOrExpressionWithInvertedSingleElementWithoutSpaces() { Profiles profiles = Profiles.of("!spring|framework"); assertOfOrExpressionWithInvertedSingleElement(profiles); } @@ -242,13 +242,13 @@ public class ProfilesTests { } @Test - public void ofNotOrExpression() { + void ofNotOrExpression() { Profiles profiles = Profiles.of("!(spring | framework)"); assertOfNotOrExpression(profiles); } @Test - public void ofNotOrExpressionWithoutSpaces() { + void ofNotOrExpressionWithoutSpaces() { Profiles profiles = Profiles.of("!(spring|framework)"); assertOfNotOrExpression(profiles); } @@ -261,13 +261,13 @@ public class ProfilesTests { } @Test - public void ofComplexExpression() { + void ofComplexExpression() { Profiles profiles = Profiles.of("(spring & framework) | (spring & java)"); assertComplexExpression(profiles); } @Test - public void ofComplexExpressionWithoutSpaces() { + void ofComplexExpressionWithoutSpaces() { Profiles profiles = Profiles.of("(spring&framework)|(spring&java)"); assertComplexExpression(profiles); } @@ -280,14 +280,14 @@ public class ProfilesTests { } @Test - public void malformedExpressions() { + void malformedExpressions() { assertMalformed(() -> Profiles.of("(")); assertMalformed(() -> Profiles.of(")")); assertMalformed(() -> Profiles.of("a & b | c")); } @Test - public void sensibleToString() { + void sensibleToString() { assertThat(Profiles.of("spring & framework", "java | kotlin").toString()).isEqualTo("spring & framework or java | kotlin"); } diff --git a/spring-core/src/test/java/org/springframework/core/env/PropertySourceTests.java b/spring-core/src/test/java/org/springframework/core/env/PropertySourceTests.java index f255abff35..1a7bed2d05 100644 --- a/spring-core/src/test/java/org/springframework/core/env/PropertySourceTests.java +++ b/spring-core/src/test/java/org/springframework/core/env/PropertySourceTests.java @@ -26,18 +26,17 @@ import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; - /** * Unit tests for {@link PropertySource} implementations. * * @author Chris Beams * @since 3.1 */ -public class PropertySourceTests { +class PropertySourceTests { @Test @SuppressWarnings("serial") - public void equals() { + void equals() { Map map1 = new HashMap() {{ put("a", "b"); }}; @@ -69,7 +68,7 @@ public class PropertySourceTests { @Test @SuppressWarnings("serial") - public void collectionsOperations() { + void collectionsOperations() { Map map1 = new HashMap() {{ put("a", "b"); }}; diff --git a/spring-core/src/test/java/org/springframework/core/env/PropertySourcesPropertyResolverTests.java b/spring-core/src/test/java/org/springframework/core/env/PropertySourcesPropertyResolverTests.java index a6b6b76a6c..d3eaa2804f 100644 --- a/spring-core/src/test/java/org/springframework/core/env/PropertySourcesPropertyResolverTests.java +++ b/spring-core/src/test/java/org/springframework/core/env/PropertySourcesPropertyResolverTests.java @@ -35,7 +35,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException; * @author Chris Beams * @since 3.1 */ -public class PropertySourcesPropertyResolverTests { +class PropertySourcesPropertyResolverTests { private Properties testProperties; @@ -45,7 +45,7 @@ public class PropertySourcesPropertyResolverTests { @BeforeEach - public void setUp() { + void setUp() { propertySources = new MutablePropertySources(); propertyResolver = new PropertySourcesPropertyResolver(propertySources); testProperties = new Properties(); @@ -54,28 +54,28 @@ public class PropertySourcesPropertyResolverTests { @Test - public void containsProperty() { + void containsProperty() { assertThat(propertyResolver.containsProperty("foo")).isFalse(); testProperties.put("foo", "bar"); assertThat(propertyResolver.containsProperty("foo")).isTrue(); } @Test - public void getProperty() { + void getProperty() { assertThat(propertyResolver.getProperty("foo")).isNull(); testProperties.put("foo", "bar"); assertThat(propertyResolver.getProperty("foo")).isEqualTo("bar"); } @Test - public void getProperty_withDefaultValue() { + void getProperty_withDefaultValue() { assertThat(propertyResolver.getProperty("foo", "myDefault")).isEqualTo("myDefault"); testProperties.put("foo", "bar"); assertThat(propertyResolver.getProperty("foo")).isEqualTo("bar"); } @Test - public void getProperty_propertySourceSearchOrderIsFIFO() { + void getProperty_propertySourceSearchOrderIsFIFO() { MutablePropertySources sources = new MutablePropertySources(); PropertyResolver resolver = new PropertySourcesPropertyResolver(sources); sources.addFirst(new MockPropertySource("ps1").withProperty("pName", "ps1Value")); @@ -87,7 +87,7 @@ public class PropertySourcesPropertyResolverTests { } @Test - public void getProperty_withExplicitNullValue() { + void getProperty_withExplicitNullValue() { // java.util.Properties does not allow null values (because Hashtable does not) Map nullableProperties = new HashMap<>(); propertySources.addLast(new MapPropertySource("nullableProperties", nullableProperties)); @@ -96,20 +96,20 @@ public class PropertySourcesPropertyResolverTests { } @Test - public void getProperty_withTargetType_andDefaultValue() { + void getProperty_withTargetType_andDefaultValue() { assertThat(propertyResolver.getProperty("foo", Integer.class, 42)).isEqualTo(42); testProperties.put("foo", 13); assertThat(propertyResolver.getProperty("foo", Integer.class, 42)).isEqualTo(13); } @Test - public void getProperty_withStringArrayConversion() { + void getProperty_withStringArrayConversion() { testProperties.put("foo", "bar,baz"); assertThat(propertyResolver.getProperty("foo", String[].class)).isEqualTo(new String[] { "bar", "baz" }); } @Test - public void getProperty_withNonConvertibleTargetType() { + void getProperty_withNonConvertibleTargetType() { testProperties.put("foo", "bar"); class TestType { } @@ -119,7 +119,7 @@ public class PropertySourcesPropertyResolverTests { } @Test - public void getProperty_doesNotCache_replaceExistingKeyPostConstruction() { + void getProperty_doesNotCache_replaceExistingKeyPostConstruction() { String key = "foo"; String value1 = "bar"; String value2 = "biz"; @@ -135,7 +135,7 @@ public class PropertySourcesPropertyResolverTests { } @Test - public void getProperty_doesNotCache_addNewKeyPostConstruction() { + void getProperty_doesNotCache_addNewKeyPostConstruction() { HashMap map = new HashMap<>(); MutablePropertySources propertySources = new MutablePropertySources(); propertySources.addFirst(new MapPropertySource("testProperties", map)); @@ -146,7 +146,7 @@ public class PropertySourcesPropertyResolverTests { } @Test - public void getPropertySources_replacePropertySource() { + void getPropertySources_replacePropertySource() { propertySources = new MutablePropertySources(); propertyResolver = new PropertySourcesPropertyResolver(propertySources); propertySources.addLast(new MockPropertySource("local").withProperty("foo", "localValue")); @@ -165,7 +165,7 @@ public class PropertySourcesPropertyResolverTests { } @Test - public void getRequiredProperty() { + void getRequiredProperty() { testProperties.put("exists", "xyz"); assertThat(propertyResolver.getRequiredProperty("exists")).isEqualTo("xyz"); @@ -174,7 +174,7 @@ public class PropertySourcesPropertyResolverTests { } @Test - public void getRequiredProperty_withStringArrayConversion() { + void getRequiredProperty_withStringArrayConversion() { testProperties.put("exists", "abc,123"); assertThat(propertyResolver.getRequiredProperty("exists", String[].class)).isEqualTo(new String[] { "abc", "123" }); @@ -183,7 +183,7 @@ public class PropertySourcesPropertyResolverTests { } @Test - public void resolvePlaceholders() { + void resolvePlaceholders() { MutablePropertySources propertySources = new MutablePropertySources(); propertySources.addFirst(new MockPropertySource().withProperty("key", "value")); PropertyResolver resolver = new PropertySourcesPropertyResolver(propertySources); @@ -191,7 +191,7 @@ public class PropertySourcesPropertyResolverTests { } @Test - public void resolvePlaceholders_withUnresolvable() { + void resolvePlaceholders_withUnresolvable() { MutablePropertySources propertySources = new MutablePropertySources(); propertySources.addFirst(new MockPropertySource().withProperty("key", "value")); PropertyResolver resolver = new PropertySourcesPropertyResolver(propertySources); @@ -200,7 +200,7 @@ public class PropertySourcesPropertyResolverTests { } @Test - public void resolvePlaceholders_withDefaultValue() { + void resolvePlaceholders_withDefaultValue() { MutablePropertySources propertySources = new MutablePropertySources(); propertySources.addFirst(new MockPropertySource().withProperty("key", "value")); PropertyResolver resolver = new PropertySourcesPropertyResolver(propertySources); @@ -209,13 +209,13 @@ public class PropertySourcesPropertyResolverTests { } @Test - public void resolvePlaceholders_withNullInput() { + void resolvePlaceholders_withNullInput() { assertThatIllegalArgumentException().isThrownBy(() -> new PropertySourcesPropertyResolver(new MutablePropertySources()).resolvePlaceholders(null)); } @Test - public void resolveRequiredPlaceholders() { + void resolveRequiredPlaceholders() { MutablePropertySources propertySources = new MutablePropertySources(); propertySources.addFirst(new MockPropertySource().withProperty("key", "value")); PropertyResolver resolver = new PropertySourcesPropertyResolver(propertySources); @@ -223,7 +223,7 @@ public class PropertySourcesPropertyResolverTests { } @Test - public void resolveRequiredPlaceholders_withUnresolvable() { + void resolveRequiredPlaceholders_withUnresolvable() { MutablePropertySources propertySources = new MutablePropertySources(); propertySources.addFirst(new MockPropertySource().withProperty("key", "value")); PropertyResolver resolver = new PropertySourcesPropertyResolver(propertySources); @@ -232,7 +232,7 @@ public class PropertySourcesPropertyResolverTests { } @Test - public void resolveRequiredPlaceholders_withDefaultValue() { + void resolveRequiredPlaceholders_withDefaultValue() { MutablePropertySources propertySources = new MutablePropertySources(); propertySources.addFirst(new MockPropertySource().withProperty("key", "value")); PropertyResolver resolver = new PropertySourcesPropertyResolver(propertySources); @@ -241,13 +241,13 @@ public class PropertySourcesPropertyResolverTests { } @Test - public void resolveRequiredPlaceholders_withNullInput() { + void resolveRequiredPlaceholders_withNullInput() { assertThatIllegalArgumentException().isThrownBy(() -> new PropertySourcesPropertyResolver(new MutablePropertySources()).resolveRequiredPlaceholders(null)); } @Test - public void setRequiredProperties_andValidateRequiredProperties() { + void setRequiredProperties_andValidateRequiredProperties() { // no properties have been marked as required -> validation should pass propertyResolver.validateRequiredProperties(); @@ -273,7 +273,7 @@ public class PropertySourcesPropertyResolverTests { } @Test - public void resolveNestedPropertyPlaceholders() { + void resolveNestedPropertyPlaceholders() { MutablePropertySources ps = new MutablePropertySources(); ps.addFirst(new MockPropertySource() .withProperty("p1", "v1") @@ -300,7 +300,7 @@ public class PropertySourcesPropertyResolverTests { } @Test - public void ignoreUnresolvableNestedPlaceholdersIsConfigurable() { + void ignoreUnresolvableNestedPlaceholdersIsConfigurable() { MutablePropertySources ps = new MutablePropertySources(); ps.addFirst(new MockPropertySource() .withProperty("p1", "v1") diff --git a/spring-core/src/test/java/org/springframework/core/env/SimpleCommandLineParserTests.java b/spring-core/src/test/java/org/springframework/core/env/SimpleCommandLineParserTests.java index 25be04bab3..471af3e759 100644 --- a/spring-core/src/test/java/org/springframework/core/env/SimpleCommandLineParserTests.java +++ b/spring-core/src/test/java/org/springframework/core/env/SimpleCommandLineParserTests.java @@ -25,17 +25,16 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; - -public class SimpleCommandLineParserTests { +class SimpleCommandLineParserTests { @Test - public void withNoOptions() { + void withNoOptions() { SimpleCommandLineArgsParser parser = new SimpleCommandLineArgsParser(); assertThat(parser.parse().getOptionValues("foo")).isNull(); } @Test - public void withSingleOptionAndNoValue() { + void withSingleOptionAndNoValue() { SimpleCommandLineArgsParser parser = new SimpleCommandLineArgsParser(); CommandLineArgs args = parser.parse("--o1"); assertThat(args.containsOption("o1")).isTrue(); @@ -43,7 +42,7 @@ public class SimpleCommandLineParserTests { } @Test - public void withSingleOptionAndValue() { + void withSingleOptionAndValue() { SimpleCommandLineArgsParser parser = new SimpleCommandLineArgsParser(); CommandLineArgs args = parser.parse("--o1=v1"); assertThat(args.containsOption("o1")).isTrue(); @@ -51,7 +50,7 @@ public class SimpleCommandLineParserTests { } @Test - public void withMixOfOptionsHavingValueAndOptionsHavingNoValue() { + void withMixOfOptionsHavingValueAndOptionsHavingNoValue() { SimpleCommandLineArgsParser parser = new SimpleCommandLineArgsParser(); CommandLineArgs args = parser.parse("--o1=v1", "--o2"); assertThat(args.containsOption("o1")).isTrue(); @@ -63,35 +62,35 @@ public class SimpleCommandLineParserTests { } @Test - public void withEmptyOptionText() { + void withEmptyOptionText() { SimpleCommandLineArgsParser parser = new SimpleCommandLineArgsParser(); assertThatIllegalArgumentException().isThrownBy(() -> parser.parse("--")); } @Test - public void withEmptyOptionName() { + void withEmptyOptionName() { SimpleCommandLineArgsParser parser = new SimpleCommandLineArgsParser(); assertThatIllegalArgumentException().isThrownBy(() -> parser.parse("--=v1")); } @Test - public void withEmptyOptionValue() { + void withEmptyOptionValue() { SimpleCommandLineArgsParser parser = new SimpleCommandLineArgsParser(); assertThatIllegalArgumentException().isThrownBy(() -> parser.parse("--o1=")); } @Test - public void withEmptyOptionNameAndEmptyOptionValue() { + void withEmptyOptionNameAndEmptyOptionValue() { SimpleCommandLineArgsParser parser = new SimpleCommandLineArgsParser(); assertThatIllegalArgumentException().isThrownBy(() -> parser.parse("--=")); } @Test - public void withNonOptionArguments() { + void withNonOptionArguments() { SimpleCommandLineArgsParser parser = new SimpleCommandLineArgsParser(); CommandLineArgs args = parser.parse("--o1=v1", "noa1", "--o2=v2", "noa2"); assertThat(args.getOptionValues("o1").get(0)).isEqualTo("v1"); @@ -104,14 +103,14 @@ public class SimpleCommandLineParserTests { } @Test - public void assertOptionNamesIsUnmodifiable() { + void assertOptionNamesIsUnmodifiable() { CommandLineArgs args = new SimpleCommandLineArgsParser().parse(); assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> args.getOptionNames().add("bogus")); } @Test - public void assertNonOptionArgsIsUnmodifiable() { + void assertNonOptionArgsIsUnmodifiable() { CommandLineArgs args = new SimpleCommandLineArgsParser().parse(); assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> args.getNonOptionArgs().add("foo")); diff --git a/spring-core/src/test/java/org/springframework/core/env/SimpleCommandLinePropertySourceTests.java b/spring-core/src/test/java/org/springframework/core/env/SimpleCommandLinePropertySourceTests.java index 676c19a781..8d18f609a5 100644 --- a/spring-core/src/test/java/org/springframework/core/env/SimpleCommandLinePropertySourceTests.java +++ b/spring-core/src/test/java/org/springframework/core/env/SimpleCommandLinePropertySourceTests.java @@ -22,37 +22,36 @@ import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; - /** * Unit tests for {@link SimpleCommandLinePropertySource}. * * @author Chris Beams * @since 3.1 */ -public class SimpleCommandLinePropertySourceTests { +class SimpleCommandLinePropertySourceTests { @Test - public void withDefaultName() { + void withDefaultName() { PropertySource ps = new SimpleCommandLinePropertySource(); assertThat(ps.getName()) .isEqualTo(CommandLinePropertySource.COMMAND_LINE_PROPERTY_SOURCE_NAME); } @Test - public void withCustomName() { + void withCustomName() { PropertySource ps = new SimpleCommandLinePropertySource("ps1", new String[0]); assertThat(ps.getName()).isEqualTo("ps1"); } @Test - public void withNoArgs() { + void withNoArgs() { PropertySource ps = new SimpleCommandLinePropertySource(); assertThat(ps.containsProperty("foo")).isFalse(); assertThat(ps.getProperty("foo")).isNull(); } @Test - public void withOptionArgsOnly() { + void withOptionArgsOnly() { CommandLinePropertySource ps = new SimpleCommandLinePropertySource("--o1=v1", "--o2"); assertThat(ps.containsProperty("o1")).isTrue(); @@ -64,7 +63,7 @@ public class SimpleCommandLinePropertySourceTests { } @Test - public void withDefaultNonOptionArgsNameAndNoNonOptionArgsPresent() { + void withDefaultNonOptionArgsNameAndNoNonOptionArgsPresent() { EnumerablePropertySource ps = new SimpleCommandLinePropertySource("--o1=v1", "--o2"); assertThat(ps.containsProperty("nonOptionArgs")).isFalse(); @@ -77,7 +76,7 @@ public class SimpleCommandLinePropertySourceTests { } @Test - public void withDefaultNonOptionArgsNameAndNonOptionArgsPresent() { + void withDefaultNonOptionArgsNameAndNonOptionArgsPresent() { CommandLinePropertySource ps = new SimpleCommandLinePropertySource("--o1=v1", "noa1", "--o2", "noa2"); @@ -90,7 +89,7 @@ public class SimpleCommandLinePropertySourceTests { } @Test - public void withCustomNonOptionArgsNameAndNoNonOptionArgsPresent() { + void withCustomNonOptionArgsNameAndNoNonOptionArgsPresent() { CommandLinePropertySource ps = new SimpleCommandLinePropertySource("--o1=v1", "noa1", "--o2", "noa2"); ps.setNonOptionArgsPropertyName("NOA"); @@ -104,7 +103,7 @@ public class SimpleCommandLinePropertySourceTests { } @Test - public void covertNonOptionArgsToStringArrayAndList() { + void covertNonOptionArgsToStringArrayAndList() { CommandLinePropertySource ps = new SimpleCommandLinePropertySource("--o1=v1", "noa1", "--o2", "noa2"); StandardEnvironment env = new StandardEnvironment(); diff --git a/spring-core/src/test/java/org/springframework/core/env/StandardEnvironmentTests.java b/spring-core/src/test/java/org/springframework/core/env/StandardEnvironmentTests.java index ac7f715319..f7218b9c48 100644 --- a/spring-core/src/test/java/org/springframework/core/env/StandardEnvironmentTests.java +++ b/spring-core/src/test/java/org/springframework/core/env/StandardEnvironmentTests.java @@ -58,7 +58,7 @@ public class StandardEnvironmentTests { @Test - public void merge() { + void merge() { ConfigurableEnvironment child = new StandardEnvironment(); child.setActiveProfiles("c1", "c2"); child.getPropertySources().addLast( @@ -99,7 +99,7 @@ public class StandardEnvironmentTests { } @Test - public void propertySourceOrder() { + void propertySourceOrder() { ConfigurableEnvironment env = new StandardEnvironment(); MutablePropertySources sources = env.getPropertySources(); assertThat(sources.precedenceOf(PropertySource.named(StandardEnvironment.SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME))).isEqualTo(0); @@ -108,25 +108,25 @@ public class StandardEnvironmentTests { } @Test - public void propertySourceTypes() { + void propertySourceTypes() { ConfigurableEnvironment env = new StandardEnvironment(); MutablePropertySources sources = env.getPropertySources(); assertThat(sources.get(StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME)).isInstanceOf(SystemEnvironmentPropertySource.class); } @Test - public void activeProfilesIsEmptyByDefault() { + void activeProfilesIsEmptyByDefault() { assertThat(environment.getActiveProfiles().length).isEqualTo(0); } @Test - public void defaultProfilesContainsDefaultProfileByDefault() { + void defaultProfilesContainsDefaultProfileByDefault() { assertThat(environment.getDefaultProfiles().length).isEqualTo(1); assertThat(environment.getDefaultProfiles()[0]).isEqualTo("default"); } @Test - public void setActiveProfiles() { + void setActiveProfiles() { environment.setActiveProfiles("local", "embedded"); String[] activeProfiles = environment.getActiveProfiles(); assertThat(activeProfiles).contains("local", "embedded"); @@ -134,55 +134,55 @@ public class StandardEnvironmentTests { } @Test - public void setActiveProfiles_withNullProfileArray() { + void setActiveProfiles_withNullProfileArray() { assertThatIllegalArgumentException().isThrownBy(() -> environment.setActiveProfiles((String[]) null)); } @Test - public void setActiveProfiles_withNullProfile() { + void setActiveProfiles_withNullProfile() { assertThatIllegalArgumentException().isThrownBy(() -> environment.setActiveProfiles((String) null)); } @Test - public void setActiveProfiles_withEmptyProfile() { + void setActiveProfiles_withEmptyProfile() { assertThatIllegalArgumentException().isThrownBy(() -> environment.setActiveProfiles("")); } @Test - public void setActiveProfiles_withNotOperator() { + void setActiveProfiles_withNotOperator() { assertThatIllegalArgumentException().isThrownBy(() -> environment.setActiveProfiles("p1", "!p2")); } @Test - public void setDefaultProfiles_withNullProfileArray() { + void setDefaultProfiles_withNullProfileArray() { assertThatIllegalArgumentException().isThrownBy(() -> environment.setDefaultProfiles((String[]) null)); } @Test - public void setDefaultProfiles_withNullProfile() { + void setDefaultProfiles_withNullProfile() { assertThatIllegalArgumentException().isThrownBy(() -> environment.setDefaultProfiles((String) null)); } @Test - public void setDefaultProfiles_withEmptyProfile() { + void setDefaultProfiles_withEmptyProfile() { assertThatIllegalArgumentException().isThrownBy(() -> environment.setDefaultProfiles("")); } @Test - public void setDefaultProfiles_withNotOperator() { + void setDefaultProfiles_withNotOperator() { assertThatIllegalArgumentException().isThrownBy(() -> environment.setDefaultProfiles("d1", "!d2")); } @Test - public void addActiveProfile() { + void addActiveProfile() { assertThat(environment.getActiveProfiles().length).isEqualTo(0); environment.setActiveProfiles("local", "embedded"); assertThat(environment.getActiveProfiles()).contains("local", "embedded"); @@ -197,7 +197,7 @@ public class StandardEnvironmentTests { } @Test - public void addActiveProfile_whenActiveProfilesPropertyIsAlreadySet() { + void addActiveProfile_whenActiveProfilesPropertyIsAlreadySet() { ConfigurableEnvironment env = new StandardEnvironment(); assertThat(env.getProperty(ACTIVE_PROFILES_PROPERTY_NAME)).isNull(); env.getPropertySources().addFirst(new MockPropertySource().withProperty(ACTIVE_PROFILES_PROPERTY_NAME, "p1")); @@ -207,7 +207,7 @@ public class StandardEnvironmentTests { } @Test - public void reservedDefaultProfile() { + void reservedDefaultProfile() { assertThat(environment.getDefaultProfiles()).isEqualTo(new String[]{RESERVED_DEFAULT_PROFILE_NAME}); System.setProperty(DEFAULT_PROFILES_PROPERTY_NAME, "d0"); assertThat(environment.getDefaultProfiles()).isEqualTo(new String[]{"d0"}); @@ -217,7 +217,7 @@ public class StandardEnvironmentTests { } @Test - public void defaultProfileWithCircularPlaceholder() { + void defaultProfileWithCircularPlaceholder() { System.setProperty(DEFAULT_PROFILES_PROPERTY_NAME, "${spring.profiles.default}"); try { assertThatIllegalArgumentException().isThrownBy(() -> @@ -229,7 +229,7 @@ public class StandardEnvironmentTests { } @Test - public void getActiveProfiles_systemPropertiesEmpty() { + void getActiveProfiles_systemPropertiesEmpty() { assertThat(environment.getActiveProfiles().length).isEqualTo(0); System.setProperty(ACTIVE_PROFILES_PROPERTY_NAME, ""); assertThat(environment.getActiveProfiles().length).isEqualTo(0); @@ -237,28 +237,28 @@ public class StandardEnvironmentTests { } @Test - public void getActiveProfiles_fromSystemProperties() { + void getActiveProfiles_fromSystemProperties() { System.setProperty(ACTIVE_PROFILES_PROPERTY_NAME, "foo"); assertThat(Arrays.asList(environment.getActiveProfiles())).contains("foo"); System.getProperties().remove(ACTIVE_PROFILES_PROPERTY_NAME); } @Test - public void getActiveProfiles_fromSystemProperties_withMultipleProfiles() { + void getActiveProfiles_fromSystemProperties_withMultipleProfiles() { System.setProperty(ACTIVE_PROFILES_PROPERTY_NAME, "foo,bar"); assertThat(environment.getActiveProfiles()).contains("foo", "bar"); System.getProperties().remove(ACTIVE_PROFILES_PROPERTY_NAME); } @Test - public void getActiveProfiles_fromSystemProperties_withMulitpleProfiles_withWhitespace() { + void getActiveProfiles_fromSystemProperties_withMulitpleProfiles_withWhitespace() { System.setProperty(ACTIVE_PROFILES_PROPERTY_NAME, " bar , baz "); // notice whitespace assertThat(environment.getActiveProfiles()).contains("bar", "baz"); System.getProperties().remove(ACTIVE_PROFILES_PROPERTY_NAME); } @Test - public void getDefaultProfiles() { + void getDefaultProfiles() { assertThat(environment.getDefaultProfiles()).isEqualTo(new String[] {RESERVED_DEFAULT_PROFILE_NAME}); environment.getPropertySources().addFirst(new MockPropertySource().withProperty(DEFAULT_PROFILES_PROPERTY_NAME, "pd1")); assertThat(environment.getDefaultProfiles().length).isEqualTo(1); @@ -266,7 +266,7 @@ public class StandardEnvironmentTests { } @Test - public void setDefaultProfiles() { + void setDefaultProfiles() { environment.setDefaultProfiles(); assertThat(environment.getDefaultProfiles().length).isEqualTo(0); environment.setDefaultProfiles("pd1"); @@ -277,31 +277,31 @@ public class StandardEnvironmentTests { } @Test - public void acceptsProfiles_withEmptyArgumentList() { + void acceptsProfiles_withEmptyArgumentList() { assertThatIllegalArgumentException().isThrownBy( environment::acceptsProfiles); } @Test - public void acceptsProfiles_withNullArgumentList() { + void acceptsProfiles_withNullArgumentList() { assertThatIllegalArgumentException().isThrownBy(() -> environment.acceptsProfiles((String[]) null)); } @Test - public void acceptsProfiles_withNullArgument() { + void acceptsProfiles_withNullArgument() { assertThatIllegalArgumentException().isThrownBy(() -> environment.acceptsProfiles((String) null)); } @Test - public void acceptsProfiles_withEmptyArgument() { + void acceptsProfiles_withEmptyArgument() { assertThatIllegalArgumentException().isThrownBy(() -> environment.acceptsProfiles("")); } @Test - public void acceptsProfiles_activeProfileSetProgrammatically() { + void acceptsProfiles_activeProfileSetProgrammatically() { assertThat(environment.acceptsProfiles("p1", "p2")).isFalse(); environment.setActiveProfiles("p1"); assertThat(environment.acceptsProfiles("p1", "p2")).isTrue(); @@ -312,14 +312,14 @@ public class StandardEnvironmentTests { } @Test - public void acceptsProfiles_activeProfileSetViaProperty() { + void acceptsProfiles_activeProfileSetViaProperty() { assertThat(environment.acceptsProfiles("p1")).isFalse(); environment.getPropertySources().addFirst(new MockPropertySource().withProperty(ACTIVE_PROFILES_PROPERTY_NAME, "p1")); assertThat(environment.acceptsProfiles("p1")).isTrue(); } @Test - public void acceptsProfiles_defaultProfile() { + void acceptsProfiles_defaultProfile() { assertThat(environment.acceptsProfiles("pd")).isFalse(); environment.setDefaultProfiles("pd"); assertThat(environment.acceptsProfiles("pd")).isTrue(); @@ -329,7 +329,7 @@ public class StandardEnvironmentTests { } @Test - public void acceptsProfiles_withNotOperator() { + void acceptsProfiles_withNotOperator() { assertThat(environment.acceptsProfiles("p1")).isFalse(); assertThat(environment.acceptsProfiles("!p1")).isTrue(); environment.addActiveProfile("p1"); @@ -338,13 +338,13 @@ public class StandardEnvironmentTests { } @Test - public void acceptsProfiles_withInvalidNotOperator() { + void acceptsProfiles_withInvalidNotOperator() { assertThatIllegalArgumentException().isThrownBy(() -> environment.acceptsProfiles("p1", "!")); } @Test - public void acceptsProfiles_withProfileExpression() { + void acceptsProfiles_withProfileExpression() { assertThat(environment.acceptsProfiles(Profiles.of("p1 & p2"))).isFalse(); environment.addActiveProfile("p1"); assertThat(environment.acceptsProfiles(Profiles.of("p1 & p2"))).isFalse(); @@ -353,7 +353,7 @@ public class StandardEnvironmentTests { } @Test - public void environmentSubclass_withCustomProfileValidation() { + void environmentSubclass_withCustomProfileValidation() { ConfigurableEnvironment env = new AbstractEnvironment() { @Override protected void validateProfile(String profile) { @@ -373,28 +373,28 @@ public class StandardEnvironmentTests { } @Test - public void suppressGetenvAccessThroughSystemProperty() { + void suppressGetenvAccessThroughSystemProperty() { System.setProperty("spring.getenv.ignore", "true"); assertThat(environment.getSystemEnvironment().isEmpty()).isTrue(); System.clearProperty("spring.getenv.ignore"); } @Test - public void suppressGetenvAccessThroughSpringProperty() { + void suppressGetenvAccessThroughSpringProperty() { SpringProperties.setProperty("spring.getenv.ignore", "true"); assertThat(environment.getSystemEnvironment().isEmpty()).isTrue(); SpringProperties.setProperty("spring.getenv.ignore", null); } @Test - public void suppressGetenvAccessThroughSpringFlag() { + void suppressGetenvAccessThroughSpringFlag() { SpringProperties.setFlag("spring.getenv.ignore"); assertThat(environment.getSystemEnvironment().isEmpty()).isTrue(); SpringProperties.setProperty("spring.getenv.ignore", null); } @Test - public void getSystemProperties_withAndWithoutSecurityManager() { + void getSystemProperties_withAndWithoutSecurityManager() { System.setProperty(ALLOWED_PROPERTY_NAME, ALLOWED_PROPERTY_VALUE); System.setProperty(DISALLOWED_PROPERTY_NAME, DISALLOWED_PROPERTY_VALUE); System.getProperties().put(STRING_PROPERTY_NAME, NON_STRING_PROPERTY_VALUE); @@ -464,7 +464,7 @@ public class StandardEnvironmentTests { } @Test - public void getSystemEnvironment_withAndWithoutSecurityManager() { + void getSystemEnvironment_withAndWithoutSecurityManager() { getModifiableSystemEnvironment().put(ALLOWED_PROPERTY_NAME, ALLOWED_PROPERTY_VALUE); getModifiableSystemEnvironment().put(DISALLOWED_PROPERTY_NAME, DISALLOWED_PROPERTY_VALUE); diff --git a/spring-core/src/test/java/org/springframework/core/env/SystemEnvironmentPropertySourceTests.java b/spring-core/src/test/java/org/springframework/core/env/SystemEnvironmentPropertySourceTests.java index 598027ac3f..daca3a7013 100644 --- a/spring-core/src/test/java/org/springframework/core/env/SystemEnvironmentPropertySourceTests.java +++ b/spring-core/src/test/java/org/springframework/core/env/SystemEnvironmentPropertySourceTests.java @@ -34,7 +34,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Juergen Hoeller * @since 3.1 */ -public class SystemEnvironmentPropertySourceTests { +class SystemEnvironmentPropertySourceTests { private Map envMap; @@ -42,20 +42,20 @@ public class SystemEnvironmentPropertySourceTests { @BeforeEach - public void setUp() { + void setUp() { envMap = new HashMap<>(); ps = new SystemEnvironmentPropertySource("sysEnv", envMap); } @Test - public void none() { + void none() { assertThat(ps.containsProperty("a.key")).isEqualTo(false); assertThat(ps.getProperty("a.key")).isNull(); } @Test - public void normalWithoutPeriod() { + void normalWithoutPeriod() { envMap.put("akey", "avalue"); assertThat(ps.containsProperty("akey")).isEqualTo(true); @@ -63,7 +63,7 @@ public class SystemEnvironmentPropertySourceTests { } @Test - public void normalWithPeriod() { + void normalWithPeriod() { envMap.put("a.key", "a.value"); assertThat(ps.containsProperty("a.key")).isEqualTo(true); @@ -71,7 +71,7 @@ public class SystemEnvironmentPropertySourceTests { } @Test - public void withUnderscore() { + void withUnderscore() { envMap.put("a_key", "a_value"); assertThat(ps.containsProperty("a_key")).isEqualTo(true); @@ -82,7 +82,7 @@ public class SystemEnvironmentPropertySourceTests { } @Test - public void withBothPeriodAndUnderscore() { + void withBothPeriodAndUnderscore() { envMap.put("a_key", "a_value"); envMap.put("a.key", "a.value"); @@ -91,7 +91,7 @@ public class SystemEnvironmentPropertySourceTests { } @Test - public void withUppercase() { + void withUppercase() { envMap.put("A_KEY", "a_value"); envMap.put("A_LONG_KEY", "a_long_value"); envMap.put("A_DOT.KEY", "a_dot_value"); @@ -150,7 +150,7 @@ public class SystemEnvironmentPropertySourceTests { @Test @SuppressWarnings("serial") - public void withSecurityConstraints() throws Exception { + void withSecurityConstraints() throws Exception { envMap = new HashMap() { @Override public boolean containsKey(Object key) { diff --git a/spring-core/src/test/java/org/springframework/core/io/ClassPathResourceTests.java b/spring-core/src/test/java/org/springframework/core/io/ClassPathResourceTests.java index 8678178ad8..630a551e6c 100644 --- a/spring-core/src/test/java/org/springframework/core/io/ClassPathResourceTests.java +++ b/spring-core/src/test/java/org/springframework/core/io/ClassPathResourceTests.java @@ -32,7 +32,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; * @author Chris Beams * @author Sam Brannen */ -public class ClassPathResourceTests { +class ClassPathResourceTests { private static final String PACKAGE_PATH = "org/springframework/core/io"; private static final String NONEXISTENT_RESOURCE_NAME = "nonexistent.xml"; @@ -47,69 +47,69 @@ public class ClassPathResourceTests { @Test - public void stringConstructorRaisesExceptionWithFullyQualifiedPath() { + void stringConstructorRaisesExceptionWithFullyQualifiedPath() { assertExceptionContainsFullyQualifiedPath(new ClassPathResource(FQ_RESOURCE_PATH)); } @Test - public void classLiteralConstructorRaisesExceptionWithFullyQualifiedPath() { + void classLiteralConstructorRaisesExceptionWithFullyQualifiedPath() { assertExceptionContainsFullyQualifiedPath(new ClassPathResource(NONEXISTENT_RESOURCE_NAME, getClass())); } @Test - public void classLoaderConstructorRaisesExceptionWithFullyQualifiedPath() { + void classLoaderConstructorRaisesExceptionWithFullyQualifiedPath() { assertExceptionContainsFullyQualifiedPath(new ClassPathResource(FQ_RESOURCE_PATH, getClass().getClassLoader())); } @Test - public void getDescriptionWithStringConstructor() { + void getDescriptionWithStringConstructor() { assertDescriptionContainsExpectedPath(new ClassPathResource(FQ_RESOURCE_PATH), FQ_RESOURCE_PATH); } @Test - public void getDescriptionWithStringConstructorAndLeadingSlash() { + void getDescriptionWithStringConstructorAndLeadingSlash() { assertDescriptionContainsExpectedPath(new ClassPathResource(FQ_RESOURCE_PATH_WITH_LEADING_SLASH), FQ_RESOURCE_PATH); } @Test - public void getDescriptionWithClassLiteralConstructor() { + void getDescriptionWithClassLiteralConstructor() { assertDescriptionContainsExpectedPath(new ClassPathResource(NONEXISTENT_RESOURCE_NAME, getClass()), FQ_RESOURCE_PATH); } @Test - public void getDescriptionWithClassLiteralConstructorAndLeadingSlash() { + void getDescriptionWithClassLiteralConstructorAndLeadingSlash() { assertDescriptionContainsExpectedPath( new ClassPathResource(FQ_RESOURCE_PATH_WITH_LEADING_SLASH, getClass()), FQ_RESOURCE_PATH); } @Test - public void getDescriptionWithClassLoaderConstructor() { + void getDescriptionWithClassLoaderConstructor() { assertDescriptionContainsExpectedPath( new ClassPathResource(FQ_RESOURCE_PATH, getClass().getClassLoader()), FQ_RESOURCE_PATH); } @Test - public void getDescriptionWithClassLoaderConstructorAndLeadingSlash() { + void getDescriptionWithClassLoaderConstructorAndLeadingSlash() { assertDescriptionContainsExpectedPath( new ClassPathResource(FQ_RESOURCE_PATH_WITH_LEADING_SLASH, getClass().getClassLoader()), FQ_RESOURCE_PATH); } @Test - public void dropLeadingSlashForClassLoaderAccess() { + void dropLeadingSlashForClassLoaderAccess() { assertThat(new ClassPathResource("/test.html").getPath()).isEqualTo("test.html"); assertThat(((ClassPathResource) new ClassPathResource("").createRelative("/test.html")).getPath()).isEqualTo("test.html"); } @Test - public void preserveLeadingSlashForClassRelativeAccess() { + void preserveLeadingSlashForClassRelativeAccess() { assertThat(new ClassPathResource("/test.html", getClass()).getPath()).isEqualTo("/test.html"); assertThat(((ClassPathResource) new ClassPathResource("", getClass()).createRelative("/test.html")).getPath()).isEqualTo("/test.html"); } @Test - public void directoryNotReadable() { + void directoryNotReadable() { Resource fileDir = new ClassPathResource("org/springframework/core"); assertThat(fileDir.exists()).isTrue(); assertThat(fileDir.isReadable()).isFalse(); diff --git a/spring-core/src/test/java/org/springframework/core/io/PathResourceTests.java b/spring-core/src/test/java/org/springframework/core/io/PathResourceTests.java index 2c31872725..7ef32706ee 100644 --- a/spring-core/src/test/java/org/springframework/core/io/PathResourceTests.java +++ b/spring-core/src/test/java/org/springframework/core/io/PathResourceTests.java @@ -51,7 +51,7 @@ import static org.mockito.Mockito.mock; * @author Arjen Poutsma */ @Deprecated -public class PathResourceTests { +class PathResourceTests { private static final String TEST_DIR = platformPath("src/test/resources/org/springframework/core/io"); @@ -69,136 +69,136 @@ public class PathResourceTests { @Test - public void nullPath() { + void nullPath() { assertThatIllegalArgumentException().isThrownBy(() -> new PathResource((Path) null)) .withMessageContaining("Path must not be null"); } @Test - public void nullPathString() { + void nullPathString() { assertThatIllegalArgumentException().isThrownBy(() -> new PathResource((String) null)) .withMessageContaining("Path must not be null"); } @Test - public void nullUri() { + void nullUri() { assertThatIllegalArgumentException().isThrownBy(() -> new PathResource((URI) null)) .withMessageContaining("URI must not be null"); } @Test - public void createFromPath() { + void createFromPath() { Path path = Paths.get(TEST_FILE); PathResource resource = new PathResource(path); assertThat(resource.getPath()).isEqualTo(TEST_FILE); } @Test - public void createFromString() { + void createFromString() { PathResource resource = new PathResource(TEST_FILE); assertThat(resource.getPath()).isEqualTo(TEST_FILE); } @Test - public void createFromUri() { + void createFromUri() { File file = new File(TEST_FILE); PathResource resource = new PathResource(file.toURI()); assertThat(resource.getPath()).isEqualTo(file.getAbsoluteFile().toString()); } @Test - public void getPathForFile() { + void getPathForFile() { PathResource resource = new PathResource(TEST_FILE); assertThat(resource.getPath()).isEqualTo(TEST_FILE); } @Test - public void getPathForDir() { + void getPathForDir() { PathResource resource = new PathResource(TEST_DIR); assertThat(resource.getPath()).isEqualTo(TEST_DIR); } @Test - public void fileExists() { + void fileExists() { PathResource resource = new PathResource(TEST_FILE); assertThat(resource.exists()).isEqualTo(true); } @Test - public void dirExists() { + void dirExists() { PathResource resource = new PathResource(TEST_DIR); assertThat(resource.exists()).isEqualTo(true); } @Test - public void fileDoesNotExist() { + void fileDoesNotExist() { PathResource resource = new PathResource(NON_EXISTING_FILE); assertThat(resource.exists()).isEqualTo(false); } @Test - public void fileIsReadable() { + void fileIsReadable() { PathResource resource = new PathResource(TEST_FILE); assertThat(resource.isReadable()).isEqualTo(true); } @Test - public void doesNotExistIsNotReadable() { + void doesNotExistIsNotReadable() { PathResource resource = new PathResource(NON_EXISTING_FILE); assertThat(resource.isReadable()).isEqualTo(false); } @Test - public void directoryIsNotReadable() { + void directoryIsNotReadable() { PathResource resource = new PathResource(TEST_DIR); assertThat(resource.isReadable()).isEqualTo(false); } @Test - public void getInputStream() throws IOException { + void getInputStream() throws IOException { PathResource resource = new PathResource(TEST_FILE); byte[] bytes = FileCopyUtils.copyToByteArray(resource.getInputStream()); assertThat(bytes.length).isGreaterThan(0); } @Test - public void getInputStreamForDir() throws IOException { + void getInputStreamForDir() throws IOException { PathResource resource = new PathResource(TEST_DIR); assertThatExceptionOfType(FileNotFoundException.class).isThrownBy( resource::getInputStream); } @Test - public void getInputStreamDoesNotExist() throws IOException { + void getInputStreamDoesNotExist() throws IOException { PathResource resource = new PathResource(NON_EXISTING_FILE); assertThatExceptionOfType(FileNotFoundException.class).isThrownBy( resource::getInputStream); } @Test - public void getUrl() throws IOException { + void getUrl() throws IOException { PathResource resource = new PathResource(TEST_FILE); assertThat(resource.getURL().toString()).endsWith("core/io/example.properties"); } @Test - public void getUri() throws IOException { + void getUri() throws IOException { PathResource resource = new PathResource(TEST_FILE); assertThat(resource.getURI().toString()).endsWith("core/io/example.properties"); } @Test - public void getFile() throws IOException { + void getFile() throws IOException { PathResource resource = new PathResource(TEST_FILE); File file = new File(TEST_FILE); assertThat(resource.getFile().getAbsoluteFile()).isEqualTo(file.getAbsoluteFile()); } @Test - public void getFileUnsupported() throws IOException { + void getFileUnsupported() throws IOException { Path path = mock(Path.class); given(path.normalize()).willReturn(path); given(path.toFile()).willThrow(new UnsupportedOperationException()); @@ -208,72 +208,72 @@ public class PathResourceTests { } @Test - public void contentLength() throws IOException { + void contentLength() throws IOException { PathResource resource = new PathResource(TEST_FILE); File file = new File(TEST_FILE); assertThat(resource.contentLength()).isEqualTo(file.length()); } @Test - public void contentLengthForDirectory() throws IOException { + void contentLengthForDirectory() throws IOException { PathResource resource = new PathResource(TEST_DIR); File file = new File(TEST_DIR); assertThat(resource.contentLength()).isEqualTo(file.length()); } @Test - public void lastModified() throws IOException { + void lastModified() throws IOException { PathResource resource = new PathResource(TEST_FILE); File file = new File(TEST_FILE); assertThat(resource.lastModified() / 1000).isEqualTo(file.lastModified() / 1000); } @Test - public void createRelativeFromDir() throws IOException { + void createRelativeFromDir() throws IOException { Resource resource = new PathResource(TEST_DIR).createRelative("example.properties"); assertThat(resource).isEqualTo(new PathResource(TEST_FILE)); } @Test - public void createRelativeFromFile() throws IOException { + void createRelativeFromFile() throws IOException { Resource resource = new PathResource(TEST_FILE).createRelative("../example.properties"); assertThat(resource).isEqualTo(new PathResource(TEST_FILE)); } @Test - public void filename() { + void filename() { Resource resource = new PathResource(TEST_FILE); assertThat(resource.getFilename()).isEqualTo("example.properties"); } @Test - public void description() { + void description() { Resource resource = new PathResource(TEST_FILE); assertThat(resource.getDescription()).contains("path ["); assertThat(resource.getDescription()).contains(TEST_FILE); } @Test - public void fileIsWritable() { + void fileIsWritable() { PathResource resource = new PathResource(TEST_FILE); assertThat(resource.isWritable()).isEqualTo(true); } @Test - public void directoryIsNotWritable() { + void directoryIsNotWritable() { PathResource resource = new PathResource(TEST_DIR); assertThat(resource.isWritable()).isEqualTo(false); } @Test - public void outputStream(@TempDir Path temporaryFolder) throws IOException { + void outputStream(@TempDir Path temporaryFolder) throws IOException { PathResource resource = new PathResource(temporaryFolder.resolve("test")); FileCopyUtils.copy("test".getBytes(StandardCharsets.UTF_8), resource.getOutputStream()); assertThat(resource.contentLength()).isEqualTo(4L); } @Test - public void doesNotExistOutputStream(@TempDir Path temporaryFolder) throws IOException { + void doesNotExistOutputStream(@TempDir Path temporaryFolder) throws IOException { File file = temporaryFolder.resolve("test").toFile(); file.delete(); PathResource resource = new PathResource(file.toPath()); @@ -282,14 +282,14 @@ public class PathResourceTests { } @Test - public void directoryOutputStream() throws IOException { + void directoryOutputStream() throws IOException { PathResource resource = new PathResource(TEST_DIR); assertThatExceptionOfType(FileNotFoundException.class).isThrownBy( resource::getOutputStream); } @Test - public void getReadableByteChannel() throws IOException { + void getReadableByteChannel() throws IOException { PathResource resource = new PathResource(TEST_FILE); ReadableByteChannel channel = null; try { @@ -307,7 +307,7 @@ public class PathResourceTests { } @Test - public void getReadableByteChannelForDir() throws IOException { + void getReadableByteChannelForDir() throws IOException { PathResource resource = new PathResource(TEST_DIR); try { resource.readableChannel(); @@ -318,14 +318,14 @@ public class PathResourceTests { } @Test - public void getReadableByteChannelDoesNotExist() throws IOException { + void getReadableByteChannelDoesNotExist() throws IOException { PathResource resource = new PathResource(NON_EXISTING_FILE); assertThatExceptionOfType(FileNotFoundException.class).isThrownBy( resource::readableChannel); } @Test - public void getWritableChannel(@TempDir Path temporaryFolder) throws IOException { + void getWritableChannel(@TempDir Path temporaryFolder) throws IOException { Path testPath = temporaryFolder.resolve("test"); Files.createFile(testPath); PathResource resource = new PathResource(testPath); diff --git a/spring-core/src/test/java/org/springframework/core/io/ResourceEditorTests.java b/spring-core/src/test/java/org/springframework/core/io/ResourceEditorTests.java index 22685539a8..92ac7600ef 100644 --- a/spring-core/src/test/java/org/springframework/core/io/ResourceEditorTests.java +++ b/spring-core/src/test/java/org/springframework/core/io/ResourceEditorTests.java @@ -32,10 +32,10 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException * @author Arjen Poutsma * @author Dave Syer */ -public class ResourceEditorTests { +class ResourceEditorTests { @Test - public void sunnyDay() { + void sunnyDay() { PropertyEditor editor = new ResourceEditor(); editor.setAsText("classpath:org/springframework/core/io/ResourceEditorTests.class"); Resource resource = (Resource) editor.getValue(); @@ -44,27 +44,27 @@ public class ResourceEditorTests { } @Test - public void ctorWithNullCtorArgs() { + void ctorWithNullCtorArgs() { assertThatIllegalArgumentException().isThrownBy(() -> new ResourceEditor(null, null)); } @Test - public void setAndGetAsTextWithNull() { + void setAndGetAsTextWithNull() { PropertyEditor editor = new ResourceEditor(); editor.setAsText(null); assertThat(editor.getAsText()).isEqualTo(""); } @Test - public void setAndGetAsTextWithWhitespaceResource() { + void setAndGetAsTextWithWhitespaceResource() { PropertyEditor editor = new ResourceEditor(); editor.setAsText(" "); assertThat(editor.getAsText()).isEqualTo(""); } @Test - public void testSystemPropertyReplacement() { + void systemPropertyReplacement() { PropertyEditor editor = new ResourceEditor(); System.setProperty("test.prop", "foo"); try { @@ -78,7 +78,7 @@ public class ResourceEditorTests { } @Test - public void testSystemPropertyReplacementWithUnresolvablePlaceholder() { + void systemPropertyReplacementWithUnresolvablePlaceholder() { PropertyEditor editor = new ResourceEditor(); System.setProperty("test.prop", "foo"); try { @@ -92,7 +92,7 @@ public class ResourceEditorTests { } @Test - public void testStrictSystemPropertyReplacementWithUnresolvablePlaceholder() { + void strictSystemPropertyReplacementWithUnresolvablePlaceholder() { PropertyEditor editor = new ResourceEditor(new DefaultResourceLoader(), new StandardEnvironment(), false); System.setProperty("test.prop", "foo"); try { diff --git a/spring-core/src/test/java/org/springframework/core/io/ResourceTests.java b/spring-core/src/test/java/org/springframework/core/io/ResourceTests.java index c3518ab9de..f1949548d3 100644 --- a/spring-core/src/test/java/org/springframework/core/io/ResourceTests.java +++ b/spring-core/src/test/java/org/springframework/core/io/ResourceTests.java @@ -43,10 +43,10 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; * @author Sam Brannen * @since 09.09.2004 */ -public class ResourceTests { +class ResourceTests { @Test - public void testByteArrayResource() throws IOException { + void byteArrayResource() throws IOException { Resource resource = new ByteArrayResource("testString".getBytes()); assertThat(resource.exists()).isTrue(); assertThat(resource.isOpen()).isFalse(); @@ -56,7 +56,7 @@ public class ResourceTests { } @Test - public void testByteArrayResourceWithDescription() throws IOException { + void byteArrayResourceWithDescription() throws IOException { Resource resource = new ByteArrayResource("testString".getBytes(), "my description"); assertThat(resource.exists()).isTrue(); assertThat(resource.isOpen()).isFalse(); @@ -67,7 +67,7 @@ public class ResourceTests { } @Test - public void testInputStreamResource() throws IOException { + void inputStreamResource() throws IOException { InputStream is = new ByteArrayInputStream("testString".getBytes()); Resource resource = new InputStreamResource(is); assertThat(resource.exists()).isTrue(); @@ -78,7 +78,7 @@ public class ResourceTests { } @Test - public void testInputStreamResourceWithDescription() throws IOException { + void inputStreamResourceWithDescription() throws IOException { InputStream is = new ByteArrayInputStream("testString".getBytes()); Resource resource = new InputStreamResource(is, "my description"); assertThat(resource.exists()).isTrue(); @@ -90,7 +90,7 @@ public class ResourceTests { } @Test - public void testClassPathResource() throws IOException { + void classPathResource() throws IOException { Resource resource = new ClassPathResource("org/springframework/core/io/Resource.class"); doTestResource(resource); Resource resource2 = new ClassPathResource("org/springframework/core/../core/io/./Resource.class"); @@ -106,7 +106,7 @@ public class ResourceTests { } @Test - public void testClassPathResourceWithClassLoader() throws IOException { + void classPathResourceWithClassLoader() throws IOException { Resource resource = new ClassPathResource("org/springframework/core/io/Resource.class", getClass().getClassLoader()); doTestResource(resource); @@ -114,14 +114,14 @@ public class ResourceTests { } @Test - public void testClassPathResourceWithClass() throws IOException { + void classPathResourceWithClass() throws IOException { Resource resource = new ClassPathResource("Resource.class", getClass()); doTestResource(resource); assertThat(new ClassPathResource("Resource.class", getClass())).isEqualTo(resource); } @Test - public void testFileSystemResource() throws IOException { + void fileSystemResource() throws IOException { String file = getClass().getResource("Resource.class").getFile(); Resource resource = new FileSystemResource(file); doTestResource(resource); @@ -129,7 +129,7 @@ public class ResourceTests { } @Test - public void testFileSystemResourceWithFilePath() throws Exception { + void fileSystemResourceWithFilePath() throws Exception { Path filePath = Paths.get(getClass().getResource("Resource.class").toURI()); Resource resource = new FileSystemResource(filePath); doTestResource(resource); @@ -137,13 +137,13 @@ public class ResourceTests { } @Test - public void testFileSystemResourceWithPlainPath() { + void fileSystemResourceWithPlainPath() { Resource resource = new FileSystemResource("core/io/Resource.class"); assertThat(new FileSystemResource("core/../core/io/./Resource.class")).isEqualTo(resource); } @Test - public void testUrlResource() throws IOException { + void urlResource() throws IOException { Resource resource = new UrlResource(getClass().getResource("Resource.class")); doTestResource(resource); assertThat(resource).isEqualTo(new UrlResource(getClass().getResource("Resource.class"))); @@ -198,21 +198,21 @@ public class ResourceTests { } @Test - public void testClassPathResourceWithRelativePath() throws IOException { + void classPathResourceWithRelativePath() throws IOException { Resource resource = new ClassPathResource("dir/"); Resource relative = resource.createRelative("subdir"); assertThat(relative).isEqualTo(new ClassPathResource("dir/subdir")); } @Test - public void testFileSystemResourceWithRelativePath() throws IOException { + void fileSystemResourceWithRelativePath() throws IOException { Resource resource = new FileSystemResource("dir/"); Resource relative = resource.createRelative("subdir"); assertThat(relative).isEqualTo(new FileSystemResource("dir/subdir")); } @Test - public void testUrlResourceWithRelativePath() throws IOException { + void urlResourceWithRelativePath() throws IOException { Resource resource = new UrlResource("file:dir/"); Resource relative = resource.createRelative("subdir"); assertThat(relative).isEqualTo(new UrlResource("file:dir/subdir")); @@ -220,13 +220,13 @@ public class ResourceTests { @Disabled @Test // this test is quite slow. TODO: re-enable with JUnit categories - public void testNonFileResourceExists() throws Exception { + void testNonFileResourceExists() throws Exception { Resource resource = new UrlResource("https://www.springframework.org"); assertThat(resource.exists()).isTrue(); } @Test - public void testAbstractResourceExceptions() throws Exception { + void abstractResourceExceptions() throws Exception { final String name = "test-resource"; Resource resource = new AbstractResource() { @@ -254,7 +254,7 @@ public class ResourceTests { } @Test - public void testContentLength() throws IOException { + void contentLength() throws IOException { AbstractResource resource = new AbstractResource() { @Override public InputStream getInputStream() { @@ -269,7 +269,7 @@ public class ResourceTests { } @Test - public void testReadableChannel() throws IOException { + void readableChannel() throws IOException { Resource resource = new FileSystemResource(getClass().getResource("Resource.class").getFile()); ReadableByteChannel channel = null; try { @@ -287,25 +287,25 @@ public class ResourceTests { } @Test - public void testInputStreamNotFoundOnFileSystemResource() throws IOException { + void inputStreamNotFoundOnFileSystemResource() throws IOException { assertThatExceptionOfType(FileNotFoundException.class).isThrownBy(() -> new FileSystemResource(getClass().getResource("Resource.class").getFile()).createRelative("X").getInputStream()); } @Test - public void testReadableChannelNotFoundOnFileSystemResource() throws IOException { + void readableChannelNotFoundOnFileSystemResource() throws IOException { assertThatExceptionOfType(FileNotFoundException.class).isThrownBy(() -> new FileSystemResource(getClass().getResource("Resource.class").getFile()).createRelative("X").readableChannel()); } @Test - public void testInputStreamNotFoundOnClassPathResource() throws IOException { + void inputStreamNotFoundOnClassPathResource() throws IOException { assertThatExceptionOfType(FileNotFoundException.class).isThrownBy(() -> new ClassPathResource("Resource.class", getClass()).createRelative("X").getInputStream()); } @Test - public void testReadableChannelNotFoundOnClassPathResource() throws IOException { + void readableChannelNotFoundOnClassPathResource() throws IOException { assertThatExceptionOfType(FileNotFoundException.class).isThrownBy(() -> new ClassPathResource("Resource.class", getClass()).createRelative("X").readableChannel()); } diff --git a/spring-core/src/test/java/org/springframework/core/io/buffer/AbstractLeakCheckingTestCase.java b/spring-core/src/test/java/org/springframework/core/io/buffer/AbstractLeakCheckingTestCase.java index 5af66bf269..1a467bd41c 100644 --- a/spring-core/src/test/java/org/springframework/core/io/buffer/AbstractLeakCheckingTestCase.java +++ b/spring-core/src/test/java/org/springframework/core/io/buffer/AbstractLeakCheckingTestCase.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,7 +40,7 @@ public abstract class AbstractLeakCheckingTestCase { * released, throwing an assertion error if so. */ @AfterEach - public final void checkForLeaks() { + final void checkForLeaks() { this.bufferFactory.checkForLeaks(); } diff --git a/spring-core/src/test/java/org/springframework/core/io/buffer/DataBufferTests.java b/spring-core/src/test/java/org/springframework/core/io/buffer/DataBufferTests.java index 71c221dba4..f39c87d445 100644 --- a/spring-core/src/test/java/org/springframework/core/io/buffer/DataBufferTests.java +++ b/spring-core/src/test/java/org/springframework/core/io/buffer/DataBufferTests.java @@ -33,7 +33,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException class DataBufferTests extends AbstractDataBufferAllocatingTests { @ParameterizedDataBufferAllocatingTest - public void byteCountsAndPositions(String displayName, DataBufferFactory bufferFactory) { + void byteCountsAndPositions(String displayName, DataBufferFactory bufferFactory) { super.bufferFactory = bufferFactory; DataBuffer buffer = createDataBuffer(2); @@ -76,7 +76,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void readPositionSmallerThanZero(String displayName, DataBufferFactory bufferFactory) { + void readPositionSmallerThanZero(String displayName, DataBufferFactory bufferFactory) { super.bufferFactory = bufferFactory; DataBuffer buffer = createDataBuffer(1); @@ -90,7 +90,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void readPositionGreaterThanWritePosition(String displayName, DataBufferFactory bufferFactory) { + void readPositionGreaterThanWritePosition(String displayName, DataBufferFactory bufferFactory) { super.bufferFactory = bufferFactory; DataBuffer buffer = createDataBuffer(1); @@ -104,7 +104,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void writePositionSmallerThanReadPosition(String displayName, DataBufferFactory bufferFactory) { + void writePositionSmallerThanReadPosition(String displayName, DataBufferFactory bufferFactory) { super.bufferFactory = bufferFactory; DataBuffer buffer = createDataBuffer(2); @@ -120,7 +120,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void writePositionGreaterThanCapacity(String displayName, DataBufferFactory bufferFactory) { + void writePositionGreaterThanCapacity(String displayName, DataBufferFactory bufferFactory) { super.bufferFactory = bufferFactory; DataBuffer buffer = createDataBuffer(1); @@ -134,7 +134,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void writeAndRead(String displayName, DataBufferFactory bufferFactory) { + void writeAndRead(String displayName, DataBufferFactory bufferFactory) { super.bufferFactory = bufferFactory; DataBuffer buffer = createDataBuffer(5); @@ -155,7 +155,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void writeNullString(String displayName, DataBufferFactory bufferFactory) { + void writeNullString(String displayName, DataBufferFactory bufferFactory) { super.bufferFactory = bufferFactory; DataBuffer buffer = createDataBuffer(1); @@ -169,7 +169,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void writeNullCharset(String displayName, DataBufferFactory bufferFactory) { + void writeNullCharset(String displayName, DataBufferFactory bufferFactory) { super.bufferFactory = bufferFactory; DataBuffer buffer = createDataBuffer(1); @@ -183,7 +183,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void writeEmptyString(String displayName, DataBufferFactory bufferFactory) { + void writeEmptyString(String displayName, DataBufferFactory bufferFactory) { super.bufferFactory = bufferFactory; DataBuffer buffer = createDataBuffer(1); @@ -195,7 +195,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void writeUtf8String(String displayName, DataBufferFactory bufferFactory) { + void writeUtf8String(String displayName, DataBufferFactory bufferFactory) { super.bufferFactory = bufferFactory; DataBuffer buffer = createDataBuffer(6); @@ -209,7 +209,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void writeUtf8StringOutGrowsCapacity(String displayName, DataBufferFactory bufferFactory) { + void writeUtf8StringOutGrowsCapacity(String displayName, DataBufferFactory bufferFactory) { super.bufferFactory = bufferFactory; DataBuffer buffer = createDataBuffer(5); @@ -223,7 +223,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void writeIsoString(String displayName, DataBufferFactory bufferFactory) { + void writeIsoString(String displayName, DataBufferFactory bufferFactory) { super.bufferFactory = bufferFactory; DataBuffer buffer = createDataBuffer(3); @@ -237,7 +237,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void writeMultipleUtf8String(String displayName, DataBufferFactory bufferFactory) { + void writeMultipleUtf8String(String displayName, DataBufferFactory bufferFactory) { super.bufferFactory = bufferFactory; DataBuffer buffer = createDataBuffer(1); @@ -259,7 +259,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void toStringNullCharset(String displayName, DataBufferFactory bufferFactory) { + void toStringNullCharset(String displayName, DataBufferFactory bufferFactory) { super.bufferFactory = bufferFactory; DataBuffer buffer = createDataBuffer(1); @@ -273,7 +273,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void toStringUtf8(String displayName, DataBufferFactory bufferFactory) { + void toStringUtf8(String displayName, DataBufferFactory bufferFactory) { super.bufferFactory = bufferFactory; String spring = "Spring"; @@ -288,7 +288,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void toStringSection(String displayName, DataBufferFactory bufferFactory) { + void toStringSection(String displayName, DataBufferFactory bufferFactory) { super.bufferFactory = bufferFactory; String spring = "Spring"; @@ -303,7 +303,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void inputStream(String displayName, DataBufferFactory bufferFactory) throws Exception { + void inputStream(String displayName, DataBufferFactory bufferFactory) throws Exception { super.bufferFactory = bufferFactory; DataBuffer buffer = createDataBuffer(4); @@ -337,7 +337,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void inputStreamReleaseOnClose(String displayName, DataBufferFactory bufferFactory) throws Exception { + void inputStreamReleaseOnClose(String displayName, DataBufferFactory bufferFactory) throws Exception { super.bufferFactory = bufferFactory; DataBuffer buffer = createDataBuffer(3); @@ -360,7 +360,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void outputStream(String displayName, DataBufferFactory bufferFactory) throws Exception { + void outputStream(String displayName, DataBufferFactory bufferFactory) throws Exception { super.bufferFactory = bufferFactory; DataBuffer buffer = createDataBuffer(4); @@ -380,7 +380,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void expand(String displayName, DataBufferFactory bufferFactory) { + void expand(String displayName, DataBufferFactory bufferFactory) { super.bufferFactory = bufferFactory; DataBuffer buffer = createDataBuffer(1); @@ -394,7 +394,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void increaseCapacity(String displayName, DataBufferFactory bufferFactory) { + void increaseCapacity(String displayName, DataBufferFactory bufferFactory) { super.bufferFactory = bufferFactory; DataBuffer buffer = createDataBuffer(1); @@ -407,7 +407,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void decreaseCapacityLowReadPosition(String displayName, DataBufferFactory bufferFactory) { + void decreaseCapacityLowReadPosition(String displayName, DataBufferFactory bufferFactory) { super.bufferFactory = bufferFactory; DataBuffer buffer = createDataBuffer(2); @@ -419,7 +419,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void decreaseCapacityHighReadPosition(String displayName, DataBufferFactory bufferFactory) { + void decreaseCapacityHighReadPosition(String displayName, DataBufferFactory bufferFactory) { super.bufferFactory = bufferFactory; DataBuffer buffer = createDataBuffer(2); @@ -432,7 +432,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void capacityLessThanZero(String displayName, DataBufferFactory bufferFactory) { + void capacityLessThanZero(String displayName, DataBufferFactory bufferFactory) { super.bufferFactory = bufferFactory; DataBuffer buffer = createDataBuffer(1); @@ -446,7 +446,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void writeByteBuffer(String displayName, DataBufferFactory bufferFactory) { + void writeByteBuffer(String displayName, DataBufferFactory bufferFactory) { super.bufferFactory = bufferFactory; DataBuffer buffer1 = createDataBuffer(1); @@ -475,7 +475,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void writeDataBuffer(String displayName, DataBufferFactory bufferFactory) { + void writeDataBuffer(String displayName, DataBufferFactory bufferFactory) { super.bufferFactory = bufferFactory; DataBuffer buffer1 = createDataBuffer(1); @@ -498,7 +498,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void asByteBuffer(String displayName, DataBufferFactory bufferFactory) { + void asByteBuffer(String displayName, DataBufferFactory bufferFactory) { super.bufferFactory = bufferFactory; DataBuffer buffer = createDataBuffer(4); @@ -519,7 +519,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void asByteBufferIndexLength(String displayName, DataBufferFactory bufferFactory) { + void asByteBufferIndexLength(String displayName, DataBufferFactory bufferFactory) { super.bufferFactory = bufferFactory; DataBuffer buffer = createDataBuffer(3); @@ -539,7 +539,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void byteBufferContainsDataBufferChanges(String displayName, DataBufferFactory bufferFactory) { + void byteBufferContainsDataBufferChanges(String displayName, DataBufferFactory bufferFactory) { super.bufferFactory = bufferFactory; DataBuffer dataBuffer = createDataBuffer(1); @@ -555,7 +555,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void dataBufferContainsByteBufferChanges(String displayName, DataBufferFactory bufferFactory) { + void dataBufferContainsByteBufferChanges(String displayName, DataBufferFactory bufferFactory) { super.bufferFactory = bufferFactory; DataBuffer dataBuffer = createDataBuffer(1); @@ -571,7 +571,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void emptyAsByteBuffer(String displayName, DataBufferFactory bufferFactory) { + void emptyAsByteBuffer(String displayName, DataBufferFactory bufferFactory) { super.bufferFactory = bufferFactory; DataBuffer buffer = createDataBuffer(1); @@ -583,7 +583,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void indexOf(String displayName, DataBufferFactory bufferFactory) { + void indexOf(String displayName, DataBufferFactory bufferFactory) { super.bufferFactory = bufferFactory; DataBuffer buffer = createDataBuffer(3); @@ -605,7 +605,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void lastIndexOf(String displayName, DataBufferFactory bufferFactory) { + void lastIndexOf(String displayName, DataBufferFactory bufferFactory) { super.bufferFactory = bufferFactory; DataBuffer buffer = createDataBuffer(3); @@ -636,7 +636,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void slice(String displayName, DataBufferFactory bufferFactory) { + void slice(String displayName, DataBufferFactory bufferFactory) { super.bufferFactory = bufferFactory; DataBuffer buffer = createDataBuffer(3); @@ -665,7 +665,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void retainedSlice(String displayName, DataBufferFactory bufferFactory) { + void retainedSlice(String displayName, DataBufferFactory bufferFactory) { super.bufferFactory = bufferFactory; DataBuffer buffer = createDataBuffer(3); @@ -694,7 +694,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void spr16351(String displayName, DataBufferFactory bufferFactory) { + void spr16351(String displayName, DataBufferFactory bufferFactory) { super.bufferFactory = bufferFactory; DataBuffer buffer = createDataBuffer(6); @@ -714,7 +714,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void join(String displayName, DataBufferFactory bufferFactory) { + void join(String displayName, DataBufferFactory bufferFactory) { super.bufferFactory = bufferFactory; DataBuffer composite = this.bufferFactory.join(Arrays.asList(stringBuffer("a"), @@ -729,7 +729,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void getByte(String displayName, DataBufferFactory bufferFactory) { + void getByte(String displayName, DataBufferFactory bufferFactory) { super.bufferFactory = bufferFactory; DataBuffer buffer = stringBuffer("abc"); diff --git a/spring-core/src/test/java/org/springframework/core/io/buffer/DataBufferUtilsTests.java b/spring-core/src/test/java/org/springframework/core/io/buffer/DataBufferUtilsTests.java index 836074b5e8..07671ba9c9 100644 --- a/spring-core/src/test/java/org/springframework/core/io/buffer/DataBufferUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/core/io/buffer/DataBufferUtilsTests.java @@ -72,7 +72,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests { @ParameterizedDataBufferAllocatingTest - public void readInputStream(String displayName, DataBufferFactory bufferFactory) { + void readInputStream(String displayName, DataBufferFactory bufferFactory) { super.bufferFactory = bufferFactory; Flux flux = DataBufferUtils.readInputStream( @@ -82,7 +82,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void readByteChannel(String displayName, DataBufferFactory bufferFactory) throws Exception { + void readByteChannel(String displayName, DataBufferFactory bufferFactory) throws Exception { super.bufferFactory = bufferFactory; URI uri = this.resource.getURI(); @@ -94,7 +94,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void readByteChannelError(String displayName, DataBufferFactory bufferFactory) throws Exception { + void readByteChannelError(String displayName, DataBufferFactory bufferFactory) throws Exception { super.bufferFactory = bufferFactory; ReadableByteChannel channel = mock(ReadableByteChannel.class); @@ -117,7 +117,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void readByteChannelCancel(String displayName, DataBufferFactory bufferFactory) throws Exception { + void readByteChannelCancel(String displayName, DataBufferFactory bufferFactory) throws Exception { super.bufferFactory = bufferFactory; URI uri = this.resource.getURI(); @@ -132,7 +132,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void readAsynchronousFileChannel(String displayName, DataBufferFactory bufferFactory) throws Exception { + void readAsynchronousFileChannel(String displayName, DataBufferFactory bufferFactory) throws Exception { super.bufferFactory = bufferFactory; URI uri = this.resource.getURI(); @@ -144,7 +144,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void readAsynchronousFileChannelPosition(String displayName, DataBufferFactory bufferFactory) throws Exception { + void readAsynchronousFileChannelPosition(String displayName, DataBufferFactory bufferFactory) throws Exception { super.bufferFactory = bufferFactory; URI uri = this.resource.getURI(); @@ -159,7 +159,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void readAsynchronousFileChannelError(String displayName, DataBufferFactory bufferFactory) throws Exception { + void readAsynchronousFileChannelError(String displayName, DataBufferFactory bufferFactory) throws Exception { super.bufferFactory = bufferFactory; AsynchronousFileChannel channel = mock(AsynchronousFileChannel.class); @@ -191,7 +191,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void readAsynchronousFileChannelCancel(String displayName, DataBufferFactory bufferFactory) throws Exception { + void readAsynchronousFileChannelCancel(String displayName, DataBufferFactory bufferFactory) throws Exception { super.bufferFactory = bufferFactory; URI uri = this.resource.getURI(); @@ -206,7 +206,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest // gh-22107 - public void readAsynchronousFileChannelCancelWithoutDemand(String displayName, DataBufferFactory bufferFactory) throws Exception { + void readAsynchronousFileChannelCancelWithoutDemand(String displayName, DataBufferFactory bufferFactory) throws Exception { super.bufferFactory = bufferFactory; URI uri = this.resource.getURI(); @@ -220,7 +220,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void readPath(String displayName, DataBufferFactory bufferFactory) throws Exception { + void readPath(String displayName, DataBufferFactory bufferFactory) throws Exception { super.bufferFactory = bufferFactory; Flux flux = DataBufferUtils.read(this.resource.getFile().toPath(), super.bufferFactory, 3); @@ -229,7 +229,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void readResource(String displayName, DataBufferFactory bufferFactory) throws Exception { + void readResource(String displayName, DataBufferFactory bufferFactory) throws Exception { super.bufferFactory = bufferFactory; Flux flux = DataBufferUtils.read(this.resource, super.bufferFactory, 3); @@ -238,7 +238,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void readResourcePosition(String displayName, DataBufferFactory bufferFactory) throws Exception { + void readResourcePosition(String displayName, DataBufferFactory bufferFactory) throws Exception { super.bufferFactory = bufferFactory; Flux flux = DataBufferUtils.read(this.resource, 9, super.bufferFactory, 3); @@ -260,7 +260,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void readResourcePositionAndTakeUntil(String displayName, DataBufferFactory bufferFactory) throws Exception { + void readResourcePositionAndTakeUntil(String displayName, DataBufferFactory bufferFactory) throws Exception { super.bufferFactory = bufferFactory; Resource resource = new ClassPathResource("DataBufferUtilsTests.txt", getClass()); @@ -277,7 +277,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void readByteArrayResourcePositionAndTakeUntil(String displayName, DataBufferFactory bufferFactory) throws Exception { + void readByteArrayResourcePositionAndTakeUntil(String displayName, DataBufferFactory bufferFactory) throws Exception { super.bufferFactory = bufferFactory; Resource resource = new ByteArrayResource("foobarbazqux" .getBytes()); @@ -294,7 +294,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void writeOutputStream(String displayName, DataBufferFactory bufferFactory) throws Exception { + void writeOutputStream(String displayName, DataBufferFactory bufferFactory) throws Exception { super.bufferFactory = bufferFactory; DataBuffer foo = stringBuffer("foo"); @@ -311,7 +311,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void writeWritableByteChannel(String displayName, DataBufferFactory bufferFactory) throws Exception { + void writeWritableByteChannel(String displayName, DataBufferFactory bufferFactory) throws Exception { super.bufferFactory = bufferFactory; DataBuffer foo = stringBuffer("foo"); @@ -328,7 +328,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void writeWritableByteChannelErrorInFlux(String displayName, DataBufferFactory bufferFactory) throws Exception { + void writeWritableByteChannelErrorInFlux(String displayName, DataBufferFactory bufferFactory) throws Exception { super.bufferFactory = bufferFactory; DataBuffer foo = stringBuffer("foo"); @@ -351,7 +351,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void writeWritableByteChannelErrorInWrite(String displayName, DataBufferFactory bufferFactory) throws Exception { + void writeWritableByteChannelErrorInWrite(String displayName, DataBufferFactory bufferFactory) throws Exception { super.bufferFactory = bufferFactory; DataBuffer foo = stringBuffer("foo"); @@ -379,7 +379,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void writeWritableByteChannelCancel(String displayName, DataBufferFactory bufferFactory) throws Exception { + void writeWritableByteChannelCancel(String displayName, DataBufferFactory bufferFactory) throws Exception { super.bufferFactory = bufferFactory; DataBuffer foo = stringBuffer("foo"); @@ -403,7 +403,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void writeAsynchronousFileChannel(String displayName, DataBufferFactory bufferFactory) throws Exception { + void writeAsynchronousFileChannel(String displayName, DataBufferFactory bufferFactory) throws Exception { super.bufferFactory = bufferFactory; DataBuffer foo = stringBuffer("foo"); @@ -435,7 +435,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void writeAsynchronousFileChannelErrorInFlux(String displayName, DataBufferFactory bufferFactory) throws Exception { + void writeAsynchronousFileChannelErrorInFlux(String displayName, DataBufferFactory bufferFactory) throws Exception { super.bufferFactory = bufferFactory; DataBuffer foo = stringBuffer("foo"); @@ -461,7 +461,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests { @ParameterizedDataBufferAllocatingTest @SuppressWarnings("unchecked") - public void writeAsynchronousFileChannelErrorInWrite(String displayName, DataBufferFactory bufferFactory) throws Exception { + void writeAsynchronousFileChannelErrorInWrite(String displayName, DataBufferFactory bufferFactory) throws Exception { super.bufferFactory = bufferFactory; DataBuffer foo = stringBuffer("foo"); @@ -502,7 +502,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void writeAsynchronousFileChannelCanceled(String displayName, DataBufferFactory bufferFactory) throws Exception { + void writeAsynchronousFileChannelCanceled(String displayName, DataBufferFactory bufferFactory) throws Exception { super.bufferFactory = bufferFactory; DataBuffer foo = stringBuffer("foo"); @@ -527,7 +527,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void writePath(String displayName, DataBufferFactory bufferFactory) throws Exception { + void writePath(String displayName, DataBufferFactory bufferFactory) throws Exception { super.bufferFactory = bufferFactory; DataBuffer foo = stringBuffer("foo"); @@ -544,7 +544,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void readAndWriteByteChannel(String displayName, DataBufferFactory bufferFactory) throws Exception { + void readAndWriteByteChannel(String displayName, DataBufferFactory bufferFactory) throws Exception { super.bufferFactory = bufferFactory; Path source = Paths.get( @@ -578,7 +578,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void readAndWriteAsynchronousFileChannel(String displayName, DataBufferFactory bufferFactory) throws Exception { + void readAndWriteAsynchronousFileChannel(String displayName, DataBufferFactory bufferFactory) throws Exception { super.bufferFactory = bufferFactory; Path source = Paths.get( @@ -619,7 +619,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void takeUntilByteCount(String displayName, DataBufferFactory bufferFactory) { + void takeUntilByteCount(String displayName, DataBufferFactory bufferFactory) { super.bufferFactory = bufferFactory; Flux result = DataBufferUtils.takeUntilByteCount( @@ -633,7 +633,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void takeUntilByteCountCanceled(String displayName, DataBufferFactory bufferFactory) { + void takeUntilByteCountCanceled(String displayName, DataBufferFactory bufferFactory) { super.bufferFactory = bufferFactory; Flux source = Flux.concat( @@ -650,7 +650,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void takeUntilByteCountError(String displayName, DataBufferFactory bufferFactory) { + void takeUntilByteCountError(String displayName, DataBufferFactory bufferFactory) { super.bufferFactory = bufferFactory; Flux source = Flux.concat( @@ -667,7 +667,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void takeUntilByteCountExact(String displayName, DataBufferFactory bufferFactory) { + void takeUntilByteCountExact(String displayName, DataBufferFactory bufferFactory) { super.bufferFactory = bufferFactory; Flux source = Flux.concat( @@ -686,7 +686,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void skipUntilByteCount(String displayName, DataBufferFactory bufferFactory) { + void skipUntilByteCount(String displayName, DataBufferFactory bufferFactory) { super.bufferFactory = bufferFactory; Flux source = Flux.concat( @@ -704,7 +704,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void skipUntilByteCountCancelled(String displayName, DataBufferFactory bufferFactory) { + void skipUntilByteCountCancelled(String displayName, DataBufferFactory bufferFactory) { super.bufferFactory = bufferFactory; Flux source = Flux.concat( @@ -720,7 +720,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void skipUntilByteCountErrorInFlux(String displayName, DataBufferFactory bufferFactory) { + void skipUntilByteCountErrorInFlux(String displayName, DataBufferFactory bufferFactory) { super.bufferFactory = bufferFactory; DataBuffer foo = stringBuffer("foo"); @@ -734,7 +734,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void skipUntilByteCountShouldSkipAll(String displayName, DataBufferFactory bufferFactory) { + void skipUntilByteCountShouldSkipAll(String displayName, DataBufferFactory bufferFactory) { super.bufferFactory = bufferFactory; DataBuffer foo = stringBuffer("foo"); @@ -749,7 +749,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void releaseConsumer(String displayName, DataBufferFactory bufferFactory) { + void releaseConsumer(String displayName, DataBufferFactory bufferFactory) { super.bufferFactory = bufferFactory; DataBuffer foo = stringBuffer("foo"); @@ -772,7 +772,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void SPR16070(String displayName, DataBufferFactory bufferFactory) throws Exception { + void SPR16070(String displayName, DataBufferFactory bufferFactory) throws Exception { super.bufferFactory = bufferFactory; ReadableByteChannel channel = mock(ReadableByteChannel.class); @@ -803,7 +803,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void join(String displayName, DataBufferFactory bufferFactory) { + void join(String displayName, DataBufferFactory bufferFactory) { super.bufferFactory = bufferFactory; DataBuffer foo = stringBuffer("foo"); @@ -821,7 +821,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void joinErrors(String displayName, DataBufferFactory bufferFactory) { + void joinErrors(String displayName, DataBufferFactory bufferFactory) { super.bufferFactory = bufferFactory; DataBuffer foo = stringBuffer("foo"); @@ -835,7 +835,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void joinCanceled(String displayName, DataBufferFactory bufferFactory) { + void joinCanceled(String displayName, DataBufferFactory bufferFactory) { super.bufferFactory = bufferFactory; Flux source = Flux.concat( @@ -851,7 +851,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void matcher(String displayName, DataBufferFactory bufferFactory) { + void matcher(String displayName, DataBufferFactory bufferFactory) { super.bufferFactory = bufferFactory; DataBuffer foo = stringBuffer("foo"); @@ -869,7 +869,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void matcher2(String displayName, DataBufferFactory bufferFactory) { + void matcher2(String displayName, DataBufferFactory bufferFactory) { super.bufferFactory = bufferFactory; DataBuffer foo = stringBuffer("fooobar"); diff --git a/spring-core/src/test/java/org/springframework/core/io/buffer/LeakAwareDataBufferFactoryTests.java b/spring-core/src/test/java/org/springframework/core/io/buffer/LeakAwareDataBufferFactoryTests.java index 4e1d5f27de..ef329ea62b 100644 --- a/spring-core/src/test/java/org/springframework/core/io/buffer/LeakAwareDataBufferFactoryTests.java +++ b/spring-core/src/test/java/org/springframework/core/io/buffer/LeakAwareDataBufferFactoryTests.java @@ -30,7 +30,7 @@ class LeakAwareDataBufferFactoryTests { @Test - public void leak() { + void leak() { DataBuffer dataBuffer = this.bufferFactory.allocateBuffer(); try { assertThatExceptionOfType(AssertionError.class).isThrownBy( @@ -42,7 +42,7 @@ class LeakAwareDataBufferFactoryTests { } @Test - public void noLeak() { + void noLeak() { DataBuffer dataBuffer = this.bufferFactory.allocateBuffer(); release(dataBuffer); this.bufferFactory.checkForLeaks(); diff --git a/spring-core/src/test/java/org/springframework/core/io/buffer/support/DataBufferTestUtilsTests.java b/spring-core/src/test/java/org/springframework/core/io/buffer/support/DataBufferTestUtilsTests.java index b39b820dd8..5100feb3ff 100644 --- a/spring-core/src/test/java/org/springframework/core/io/buffer/support/DataBufferTestUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/core/io/buffer/support/DataBufferTestUtilsTests.java @@ -31,7 +31,7 @@ import static org.assertj.core.api.Assertions.assertThat; class DataBufferTestUtilsTests extends AbstractDataBufferAllocatingTests { @ParameterizedDataBufferAllocatingTest - public void dumpBytes(String displayName, DataBufferFactory bufferFactory) { + void dumpBytes(String displayName, DataBufferFactory bufferFactory) { this.bufferFactory = bufferFactory; DataBuffer buffer = this.bufferFactory.allocateBuffer(4); @@ -46,7 +46,7 @@ class DataBufferTestUtilsTests extends AbstractDataBufferAllocatingTests { } @ParameterizedDataBufferAllocatingTest - public void dumpString(String displayName, DataBufferFactory bufferFactory) { + void dumpString(String displayName, DataBufferFactory bufferFactory) { this.bufferFactory = bufferFactory; DataBuffer buffer = this.bufferFactory.allocateBuffer(4); diff --git a/spring-core/src/test/java/org/springframework/core/io/support/EncodedResourceTests.java b/spring-core/src/test/java/org/springframework/core/io/support/EncodedResourceTests.java index 55fe80121a..76eae72684 100644 --- a/spring-core/src/test/java/org/springframework/core/io/support/EncodedResourceTests.java +++ b/spring-core/src/test/java/org/springframework/core/io/support/EncodedResourceTests.java @@ -31,7 +31,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Sam Brannen * @since 3.2.14 */ -public class EncodedResourceTests { +class EncodedResourceTests { private static final String UTF8 = "UTF-8"; private static final String UTF16 = "UTF-16"; @@ -42,40 +42,40 @@ public class EncodedResourceTests { @Test - public void equalsWithNullOtherObject() { + void equalsWithNullOtherObject() { assertThat(new EncodedResource(resource).equals(null)).isFalse(); } @Test - public void equalsWithSameEncoding() { + void equalsWithSameEncoding() { EncodedResource er1 = new EncodedResource(resource, UTF8); EncodedResource er2 = new EncodedResource(resource, UTF8); assertThat(er2).isEqualTo(er1); } @Test - public void equalsWithDifferentEncoding() { + void equalsWithDifferentEncoding() { EncodedResource er1 = new EncodedResource(resource, UTF8); EncodedResource er2 = new EncodedResource(resource, UTF16); assertThat(er2).isNotEqualTo(er1); } @Test - public void equalsWithSameCharset() { + void equalsWithSameCharset() { EncodedResource er1 = new EncodedResource(resource, UTF8_CS); EncodedResource er2 = new EncodedResource(resource, UTF8_CS); assertThat(er2).isEqualTo(er1); } @Test - public void equalsWithDifferentCharset() { + void equalsWithDifferentCharset() { EncodedResource er1 = new EncodedResource(resource, UTF8_CS); EncodedResource er2 = new EncodedResource(resource, UTF16_CS); assertThat(er2).isNotEqualTo(er1); } @Test - public void equalsWithEncodingAndCharset() { + void equalsWithEncodingAndCharset() { EncodedResource er1 = new EncodedResource(resource, UTF8); EncodedResource er2 = new EncodedResource(resource, UTF8_CS); assertThat(er2).isNotEqualTo(er1); diff --git a/spring-core/src/test/java/org/springframework/core/io/support/PathMatchingResourcePatternResolverTests.java b/spring-core/src/test/java/org/springframework/core/io/support/PathMatchingResourcePatternResolverTests.java index 3b0cfd5cca..ade5a96559 100644 --- a/spring-core/src/test/java/org/springframework/core/io/support/PathMatchingResourcePatternResolverTests.java +++ b/spring-core/src/test/java/org/springframework/core/io/support/PathMatchingResourcePatternResolverTests.java @@ -41,7 +41,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; * @author Sam Brannen * @since 17.11.2004 */ -public class PathMatchingResourcePatternResolverTests { +class PathMatchingResourcePatternResolverTests { private static final String[] CLASSES_IN_CORE_IO_SUPPORT = new String[] {"EncodedResource.class", "LocalizedResourceHelper.class", @@ -59,13 +59,13 @@ public class PathMatchingResourcePatternResolverTests { @Test - public void invalidPrefixWithPatternElementInIt() throws IOException { + void invalidPrefixWithPatternElementInIt() throws IOException { assertThatExceptionOfType(FileNotFoundException.class).isThrownBy(() -> resolver.getResources("xx**:**/*.xy")); } @Test - public void singleResourceOnFileSystem() throws IOException { + void singleResourceOnFileSystem() throws IOException { Resource[] resources = resolver.getResources("org/springframework/core/io/support/PathMatchingResourcePatternResolverTests.class"); assertThat(resources.length).isEqualTo(1); @@ -73,7 +73,7 @@ public class PathMatchingResourcePatternResolverTests { } @Test - public void singleResourceInJar() throws IOException { + void singleResourceInJar() throws IOException { Resource[] resources = resolver.getResources("org/reactivestreams/Publisher.class"); assertThat(resources.length).isEqualTo(1); assertProtocolAndFilenames(resources, "jar", "Publisher.class"); @@ -81,7 +81,7 @@ public class PathMatchingResourcePatternResolverTests { @Disabled @Test - public void classpathStarWithPatternOnFileSystem() throws IOException { + void classpathStarWithPatternOnFileSystem() throws IOException { Resource[] resources = resolver.getResources("classpath*:org/springframework/core/io/sup*/*.class"); // Have to exclude Clover-generated class files here, // as we might be running as part of a Clover test run. @@ -97,19 +97,19 @@ public class PathMatchingResourcePatternResolverTests { } @Test - public void classpathWithPatternInJar() throws IOException { + void classpathWithPatternInJar() throws IOException { Resource[] resources = resolver.getResources("classpath:org/reactivestreams/*.class"); assertProtocolAndFilenames(resources, "jar", CLASSES_IN_REACTIVESTREAMS); } @Test - public void classpathStarWithPatternInJar() throws IOException { + void classpathStarWithPatternInJar() throws IOException { Resource[] resources = resolver.getResources("classpath*:org/reactivestreams/*.class"); assertProtocolAndFilenames(resources, "jar", CLASSES_IN_REACTIVESTREAMS); } @Test - public void rootPatternRetrievalInJarFiles() throws IOException { + void rootPatternRetrievalInJarFiles() throws IOException { Resource[] resources = resolver.getResources("classpath*:*.dtd"); boolean found = false; for (Resource resource : resources) { diff --git a/spring-core/src/test/java/org/springframework/core/io/support/ResourceArrayPropertyEditorTests.java b/spring-core/src/test/java/org/springframework/core/io/support/ResourceArrayPropertyEditorTests.java index e72759f08d..4bb19cdc33 100644 --- a/spring-core/src/test/java/org/springframework/core/io/support/ResourceArrayPropertyEditorTests.java +++ b/spring-core/src/test/java/org/springframework/core/io/support/ResourceArrayPropertyEditorTests.java @@ -30,10 +30,10 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException * @author Dave Syer * @author Juergen Hoeller */ -public class ResourceArrayPropertyEditorTests { +class ResourceArrayPropertyEditorTests { @Test - public void testVanillaResource() { + void vanillaResource() { PropertyEditor editor = new ResourceArrayPropertyEditor(); editor.setAsText("classpath:org/springframework/core/io/support/ResourceArrayPropertyEditor.class"); Resource[] resources = (Resource[]) editor.getValue(); @@ -42,7 +42,7 @@ public class ResourceArrayPropertyEditorTests { } @Test - public void testPatternResource() { + void patternResource() { // N.B. this will sometimes fail if you use classpath: instead of classpath*:. // The result depends on the classpath - if test-classes are segregated from classes // and they come first on the classpath (like in Maven) then it breaks, if classes @@ -55,7 +55,7 @@ public class ResourceArrayPropertyEditorTests { } @Test - public void testSystemPropertyReplacement() { + void systemPropertyReplacement() { PropertyEditor editor = new ResourceArrayPropertyEditor(); System.setProperty("test.prop", "foo"); try { @@ -69,7 +69,7 @@ public class ResourceArrayPropertyEditorTests { } @Test - public void testStrictSystemPropertyReplacementWithUnresolvablePlaceholder() { + void strictSystemPropertyReplacementWithUnresolvablePlaceholder() { PropertyEditor editor = new ResourceArrayPropertyEditor( new PathMatchingResourcePatternResolver(), new StandardEnvironment(), false); diff --git a/spring-core/src/test/java/org/springframework/core/io/support/ResourcePropertySourceTests.java b/spring-core/src/test/java/org/springframework/core/io/support/ResourcePropertySourceTests.java index 6f12bc1546..df4a13c4ee 100644 --- a/spring-core/src/test/java/org/springframework/core/io/support/ResourcePropertySourceTests.java +++ b/spring-core/src/test/java/org/springframework/core/io/support/ResourcePropertySourceTests.java @@ -33,7 +33,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Sam Brannen * @since 3.1 */ -public class ResourcePropertySourceTests { +class ResourcePropertySourceTests { private static final String PROPERTIES_PATH = "org/springframework/core/io/example.properties"; private static final String PROPERTIES_LOCATION = "classpath:" + PROPERTIES_PATH; @@ -44,56 +44,56 @@ public class ResourcePropertySourceTests { private static final String XML_PROPERTIES_RESOURCE_DESCRIPTION = "class path resource [" + XML_PROPERTIES_PATH + "]"; @Test - public void withLocationAndGeneratedName() throws IOException { + void withLocationAndGeneratedName() throws IOException { PropertySource ps = new ResourcePropertySource(PROPERTIES_LOCATION); assertThat(ps.getProperty("foo")).isEqualTo("bar"); assertThat(ps.getName()).isEqualTo(PROPERTIES_RESOURCE_DESCRIPTION); } @Test - public void xmlWithLocationAndGeneratedName() throws IOException { + void xmlWithLocationAndGeneratedName() throws IOException { PropertySource ps = new ResourcePropertySource(XML_PROPERTIES_LOCATION); assertThat(ps.getProperty("foo")).isEqualTo("bar"); assertThat(ps.getName()).isEqualTo(XML_PROPERTIES_RESOURCE_DESCRIPTION); } @Test - public void withLocationAndExplicitName() throws IOException { + void withLocationAndExplicitName() throws IOException { PropertySource ps = new ResourcePropertySource("ps1", PROPERTIES_LOCATION); assertThat(ps.getProperty("foo")).isEqualTo("bar"); assertThat(ps.getName()).isEqualTo("ps1"); } @Test - public void withLocationAndExplicitNameAndExplicitClassLoader() throws IOException { + void withLocationAndExplicitNameAndExplicitClassLoader() throws IOException { PropertySource ps = new ResourcePropertySource("ps1", PROPERTIES_LOCATION, getClass().getClassLoader()); assertThat(ps.getProperty("foo")).isEqualTo("bar"); assertThat(ps.getName()).isEqualTo("ps1"); } @Test - public void withLocationAndGeneratedNameAndExplicitClassLoader() throws IOException { + void withLocationAndGeneratedNameAndExplicitClassLoader() throws IOException { PropertySource ps = new ResourcePropertySource(PROPERTIES_LOCATION, getClass().getClassLoader()); assertThat(ps.getProperty("foo")).isEqualTo("bar"); assertThat(ps.getName()).isEqualTo(PROPERTIES_RESOURCE_DESCRIPTION); } @Test - public void withResourceAndGeneratedName() throws IOException { + void withResourceAndGeneratedName() throws IOException { PropertySource ps = new ResourcePropertySource(new ClassPathResource(PROPERTIES_PATH)); assertThat(ps.getProperty("foo")).isEqualTo("bar"); assertThat(ps.getName()).isEqualTo(PROPERTIES_RESOURCE_DESCRIPTION); } @Test - public void withResourceAndExplicitName() throws IOException { + void withResourceAndExplicitName() throws IOException { PropertySource ps = new ResourcePropertySource("ps1", new ClassPathResource(PROPERTIES_PATH)); assertThat(ps.getProperty("foo")).isEqualTo("bar"); assertThat(ps.getName()).isEqualTo("ps1"); } @Test - public void withResourceHavingNoDescription() throws IOException { + void withResourceHavingNoDescription() throws IOException { PropertySource ps = new ResourcePropertySource(new ByteArrayResource("foo=bar".getBytes(), "")); assertThat(ps.getProperty("foo")).isEqualTo("bar"); assertThat(ps.getName()).isEqualTo("Byte array resource []"); diff --git a/spring-core/src/test/java/org/springframework/core/io/support/ResourceRegionTests.java b/spring-core/src/test/java/org/springframework/core/io/support/ResourceRegionTests.java index 2529d4fba0..d7d00bea0d 100644 --- a/spring-core/src/test/java/org/springframework/core/io/support/ResourceRegionTests.java +++ b/spring-core/src/test/java/org/springframework/core/io/support/ResourceRegionTests.java @@ -28,22 +28,22 @@ import static org.mockito.Mockito.mock; * * @author Brian Clozel */ -public class ResourceRegionTests { +class ResourceRegionTests { @Test - public void shouldThrowExceptionWithNullResource() { + void shouldThrowExceptionWithNullResource() { assertThatIllegalArgumentException().isThrownBy(() -> new ResourceRegion(null, 0, 1)); } @Test - public void shouldThrowExceptionForNegativePosition() { + void shouldThrowExceptionForNegativePosition() { assertThatIllegalArgumentException().isThrownBy(() -> new ResourceRegion(mock(Resource.class), -1, 1)); } @Test - public void shouldThrowExceptionForNegativeCount() { + void shouldThrowExceptionForNegativeCount() { assertThatIllegalArgumentException().isThrownBy(() -> new ResourceRegion(mock(Resource.class), 0, -1)); } diff --git a/spring-core/src/test/java/org/springframework/core/io/support/SpringFactoriesLoaderTests.java b/spring-core/src/test/java/org/springframework/core/io/support/SpringFactoriesLoaderTests.java index 85a0e0eff9..f874096641 100644 --- a/spring-core/src/test/java/org/springframework/core/io/support/SpringFactoriesLoaderTests.java +++ b/spring-core/src/test/java/org/springframework/core/io/support/SpringFactoriesLoaderTests.java @@ -31,10 +31,10 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException * @author Phillip Webb * @author Sam Brannen */ -public class SpringFactoriesLoaderTests { +class SpringFactoriesLoaderTests { @Test - public void loadFactoriesInCorrectOrder() { + void loadFactoriesInCorrectOrder() { List factories = SpringFactoriesLoader.loadFactories(DummyFactory.class, null); assertThat(factories.size()).isEqualTo(2); boolean condition1 = factories.get(0) instanceof MyDummyFactory1; @@ -44,7 +44,7 @@ public class SpringFactoriesLoaderTests { } @Test - public void loadPackagePrivateFactory() { + void loadPackagePrivateFactory() { List factories = SpringFactoriesLoader.loadFactories(DummyPackagePrivateFactory.class, null); assertThat(factories.size()).isEqualTo(1); @@ -52,7 +52,7 @@ public class SpringFactoriesLoaderTests { } @Test - public void attemptToLoadFactoryOfIncompatibleType() { + void attemptToLoadFactoryOfIncompatibleType() { assertThatIllegalArgumentException().isThrownBy(() -> SpringFactoriesLoader.loadFactories(String.class, null)) .withMessageContaining("Unable to instantiate factory class " diff --git a/spring-core/src/test/java/org/springframework/core/log/LogSupportTests.java b/spring-core/src/test/java/org/springframework/core/log/LogSupportTests.java index 05e3f93d27..f4387542fc 100644 --- a/spring-core/src/test/java/org/springframework/core/log/LogSupportTests.java +++ b/spring-core/src/test/java/org/springframework/core/log/LogSupportTests.java @@ -24,45 +24,45 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Juergen Hoeller * @since 5.2 */ -public class LogSupportTests { +class LogSupportTests { @Test - public void testLogMessageWithSupplier() { + void logMessageWithSupplier() { LogMessage msg = LogMessage.of(() -> new StringBuilder("a").append(" b")); assertThat(msg.toString()).isEqualTo("a b"); assertThat(msg.toString()).isSameAs(msg.toString()); } @Test - public void testLogMessageWithFormat1() { + void logMessageWithFormat1() { LogMessage msg = LogMessage.format("a %s", "b"); assertThat(msg.toString()).isEqualTo("a b"); assertThat(msg.toString()).isSameAs(msg.toString()); } @Test - public void testLogMessageWithFormat2() { + void logMessageWithFormat2() { LogMessage msg = LogMessage.format("a %s %s", "b", "c"); assertThat(msg.toString()).isEqualTo("a b c"); assertThat(msg.toString()).isSameAs(msg.toString()); } @Test - public void testLogMessageWithFormat3() { + void logMessageWithFormat3() { LogMessage msg = LogMessage.format("a %s %s %s", "b", "c", "d"); assertThat(msg.toString()).isEqualTo("a b c d"); assertThat(msg.toString()).isSameAs(msg.toString()); } @Test - public void testLogMessageWithFormat4() { + void logMessageWithFormat4() { LogMessage msg = LogMessage.format("a %s %s %s %s", "b", "c", "d", "e"); assertThat(msg.toString()).isEqualTo("a b c d e"); assertThat(msg.toString()).isSameAs(msg.toString()); } @Test - public void testLogMessageWithFormatX() { + void logMessageWithFormatX() { LogMessage msg = LogMessage.format("a %s %s %s %s %s", "b", "c", "d", "e", "f"); assertThat(msg.toString()).isEqualTo("a b c d e f"); assertThat(msg.toString()).isSameAs(msg.toString()); diff --git a/spring-core/src/test/java/org/springframework/core/serializer/SerializationConverterTests.java b/spring-core/src/test/java/org/springframework/core/serializer/SerializationConverterTests.java index e993a0459c..c383732ae0 100644 --- a/spring-core/src/test/java/org/springframework/core/serializer/SerializationConverterTests.java +++ b/spring-core/src/test/java/org/springframework/core/serializer/SerializationConverterTests.java @@ -33,10 +33,10 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; * @author Mark Fisher * @since 3.0.5 */ -public class SerializationConverterTests { +class SerializationConverterTests { @Test - public void serializeAndDeserializeString() { + void serializeAndDeserializeString() { SerializingConverter toBytes = new SerializingConverter(); byte[] bytes = toBytes.convert("Testing"); DeserializingConverter fromBytes = new DeserializingConverter(); @@ -44,7 +44,7 @@ public class SerializationConverterTests { } @Test - public void nonSerializableObject() { + void nonSerializableObject() { SerializingConverter toBytes = new SerializingConverter(); assertThatExceptionOfType(SerializationFailedException.class).isThrownBy(() -> toBytes.convert(new Object())) @@ -52,7 +52,7 @@ public class SerializationConverterTests { } @Test - public void nonSerializableField() { + void nonSerializableField() { SerializingConverter toBytes = new SerializingConverter(); assertThatExceptionOfType(SerializationFailedException.class).isThrownBy(() -> toBytes.convert(new UnSerializable())) @@ -60,7 +60,7 @@ public class SerializationConverterTests { } @Test - public void deserializationFailure() { + void deserializationFailure() { DeserializingConverter fromBytes = new DeserializingConverter(); assertThatExceptionOfType(SerializationFailedException.class).isThrownBy(() -> fromBytes.convert("Junk".getBytes())); diff --git a/spring-core/src/test/java/org/springframework/core/style/DefaultValueStylerTests.java b/spring-core/src/test/java/org/springframework/core/style/DefaultValueStylerTests.java index d62db65605..c2450c4a02 100644 --- a/spring-core/src/test/java/org/springframework/core/style/DefaultValueStylerTests.java +++ b/spring-core/src/test/java/org/springframework/core/style/DefaultValueStylerTests.java @@ -33,13 +33,13 @@ import static org.assertj.core.api.Assertions.assertThat; * * @since 5.2 */ -public class DefaultValueStylerTests { +class DefaultValueStylerTests { private final DefaultValueStyler styler = new DefaultValueStyler(); @Test - public void styleBasics() throws NoSuchMethodException { + void styleBasics() throws NoSuchMethodException { assertThat(styler.style(null)).isEqualTo("[null]"); assertThat(styler.style("str")).isEqualTo("'str'"); assertThat(styler.style(String.class)).isEqualTo("String"); @@ -47,14 +47,14 @@ public class DefaultValueStylerTests { } @Test - public void stylePlainObject() { + void stylePlainObject() { Object obj = new Object(); assertThat(styler.style(obj)).isEqualTo(String.valueOf(obj)); } @Test - public void styleMaps() { + void styleMaps() { Map map = Collections.emptyMap(); assertThat(styler.style(map)).isEqualTo("map[[empty]]"); @@ -68,7 +68,7 @@ public class DefaultValueStylerTests { } @Test - public void styleMapEntries() { + void styleMapEntries() { Map map = new LinkedHashMap<>(); map.put("key1", 1); map.put("key2", 2); @@ -80,7 +80,7 @@ public class DefaultValueStylerTests { } @Test - public void styleCollections() { + void styleCollections() { List list = Collections.emptyList(); assertThat(styler.style(list)).isEqualTo("list[[empty]]"); @@ -92,7 +92,7 @@ public class DefaultValueStylerTests { } @Test - public void stylePrimitiveArrays() { + void stylePrimitiveArrays() { int[] array = new int[0]; assertThat(styler.style(array)).isEqualTo("array[[empty]]"); @@ -104,7 +104,7 @@ public class DefaultValueStylerTests { } @Test - public void styleObjectArrays() { + void styleObjectArrays() { String[] array = new String[0]; assertThat(styler.style(array)).isEqualTo("array[[empty]]"); diff --git a/spring-core/src/test/java/org/springframework/core/style/ToStringCreatorTests.java b/spring-core/src/test/java/org/springframework/core/style/ToStringCreatorTests.java index 782e6227fd..ef7d971ebf 100644 --- a/spring-core/src/test/java/org/springframework/core/style/ToStringCreatorTests.java +++ b/spring-core/src/test/java/org/springframework/core/style/ToStringCreatorTests.java @@ -33,13 +33,13 @@ import static org.assertj.core.api.Assertions.assertThat; /** * @author Keith Donald */ -public class ToStringCreatorTests { +class ToStringCreatorTests { private SomeObject s1, s2, s3; @BeforeEach - public void setUp() throws Exception { + void setUp() throws Exception { s1 = new SomeObject() { @Override public String toString() { @@ -61,7 +61,7 @@ public class ToStringCreatorTests { } @Test - public void defaultStyleMap() { + void defaultStyleMap() { final Map map = getMap(); Object stringy = new Object() { @Override @@ -82,7 +82,7 @@ public class ToStringCreatorTests { } @Test - public void defaultStyleArray() { + void defaultStyleArray() { SomeObject[] array = new SomeObject[] {s1, s2, s3}; String str = new ToStringCreator(array).toString(); assertThat(str).isEqualTo(("[@" + ObjectUtils.getIdentityHexString(array) + @@ -90,14 +90,14 @@ public class ToStringCreatorTests { } @Test - public void primitiveArrays() { + void primitiveArrays() { int[] integers = new int[] {0, 1, 2, 3, 4}; String str = new ToStringCreator(integers).toString(); assertThat(str).isEqualTo(("[@" + ObjectUtils.getIdentityHexString(integers) + " array[0, 1, 2, 3, 4]]")); } @Test - public void appendList() { + void appendList() { List list = new ArrayList<>(); list.add(s1); list.add(s2); @@ -107,7 +107,7 @@ public class ToStringCreatorTests { } @Test - public void appendSet() { + void appendSet() { Set set = new LinkedHashSet<>(); set.add(s1); set.add(s2); @@ -117,15 +117,15 @@ public class ToStringCreatorTests { } @Test - public void appendClass() { + void appendClass() { String str = new ToStringCreator(this).append("myClass", this.getClass()).toString(); assertThat(str).isEqualTo(("[ToStringCreatorTests@" + ObjectUtils.getIdentityHexString(this) + " myClass = ToStringCreatorTests]")); } @Test - public void appendMethod() throws Exception { - String str = new ToStringCreator(this).append("myMethod", this.getClass().getMethod("appendMethod")).toString(); + void appendMethod() throws Exception { + String str = new ToStringCreator(this).append("myMethod", this.getClass().getDeclaredMethod("appendMethod")).toString(); assertThat(str).isEqualTo(("[ToStringCreatorTests@" + ObjectUtils.getIdentityHexString(this) + " myMethod = appendMethod@ToStringCreatorTests]")); } diff --git a/spring-core/src/test/java/org/springframework/core/task/SimpleAsyncTaskExecutorTests.java b/spring-core/src/test/java/org/springframework/core/task/SimpleAsyncTaskExecutorTests.java index fcd6fa7d48..c78f9a95f5 100644 --- a/spring-core/src/test/java/org/springframework/core/task/SimpleAsyncTaskExecutorTests.java +++ b/spring-core/src/test/java/org/springframework/core/task/SimpleAsyncTaskExecutorTests.java @@ -31,10 +31,10 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException; * @author Juergen Hoeller * @author Sam Brannen */ -public class SimpleAsyncTaskExecutorTests { +class SimpleAsyncTaskExecutorTests { @Test - public void cannotExecuteWhenConcurrencyIsSwitchedOff() throws Exception { + void cannotExecuteWhenConcurrencyIsSwitchedOff() throws Exception { SimpleAsyncTaskExecutor executor = new SimpleAsyncTaskExecutor(); executor.setConcurrencyLimit(ConcurrencyThrottleSupport.NO_CONCURRENCY); assertThat(executor.isThrottleActive()).isTrue(); @@ -43,13 +43,13 @@ public class SimpleAsyncTaskExecutorTests { } @Test - public void throttleIsNotActiveByDefault() throws Exception { + void throttleIsNotActiveByDefault() throws Exception { SimpleAsyncTaskExecutor executor = new SimpleAsyncTaskExecutor(); assertThat(executor.isThrottleActive()).as("Concurrency throttle must not default to being active (on)").isFalse(); } @Test - public void threadNameGetsSetCorrectly() throws Exception { + void threadNameGetsSetCorrectly() throws Exception { final String customPrefix = "chankPop#"; final Object monitor = new Object(); SimpleAsyncTaskExecutor executor = new SimpleAsyncTaskExecutor(customPrefix); @@ -59,7 +59,7 @@ public class SimpleAsyncTaskExecutorTests { } @Test - public void threadFactoryOverridesDefaults() throws Exception { + void threadFactoryOverridesDefaults() throws Exception { final Object monitor = new Object(); SimpleAsyncTaskExecutor executor = new SimpleAsyncTaskExecutor(new ThreadFactory() { @Override @@ -73,7 +73,7 @@ public class SimpleAsyncTaskExecutorTests { } @Test - public void throwsExceptionWhenSuppliedWithNullRunnable() throws Exception { + void throwsExceptionWhenSuppliedWithNullRunnable() throws Exception { assertThatIllegalArgumentException().isThrownBy(() -> new SimpleAsyncTaskExecutor().execute(null)); } diff --git a/spring-core/src/test/java/org/springframework/core/type/AbstractClassMetadataMemberClassTests.java b/spring-core/src/test/java/org/springframework/core/type/AbstractClassMetadataMemberClassTests.java index b3b9a80695..7c520f9db9 100644 --- a/spring-core/src/test/java/org/springframework/core/type/AbstractClassMetadataMemberClassTests.java +++ b/spring-core/src/test/java/org/springframework/core/type/AbstractClassMetadataMemberClassTests.java @@ -33,7 +33,7 @@ public abstract class AbstractClassMetadataMemberClassTests { public abstract ClassMetadata getClassMetadataFor(Class clazz); @Test - public void withNoMemberClasses() { + void withNoMemberClasses() { ClassMetadata metadata = getClassMetadataFor(L0_a.class); String[] nestedClasses = metadata.getMemberClassNames(); assertThat(nestedClasses).isEqualTo(new String[]{}); @@ -44,7 +44,7 @@ public abstract class AbstractClassMetadataMemberClassTests { @Test - public void withPublicMemberClasses() { + void withPublicMemberClasses() { ClassMetadata metadata = getClassMetadataFor(L0_b.class); String[] nestedClasses = metadata.getMemberClassNames(); assertThat(nestedClasses).isEqualTo(new String[]{L0_b.L1.class.getName()}); @@ -56,7 +56,7 @@ public abstract class AbstractClassMetadataMemberClassTests { @Test - public void withNonPublicMemberClasses() { + void withNonPublicMemberClasses() { ClassMetadata metadata = getClassMetadataFor(L0_c.class); String[] nestedClasses = metadata.getMemberClassNames(); assertThat(nestedClasses).isEqualTo(new String[]{L0_c.L1.class.getName()}); @@ -68,7 +68,7 @@ public abstract class AbstractClassMetadataMemberClassTests { @Test - public void againstMemberClass() { + void againstMemberClass() { ClassMetadata metadata = getClassMetadataFor(L0_b.L1.class); String[] nestedClasses = metadata.getMemberClassNames(); assertThat(nestedClasses).isEqualTo(new String[]{}); diff --git a/spring-core/src/test/java/org/springframework/core/type/AbstractMethodMetadataTests.java b/spring-core/src/test/java/org/springframework/core/type/AbstractMethodMetadataTests.java index 52cf875eb5..e1190866a9 100644 --- a/spring-core/src/test/java/org/springframework/core/type/AbstractMethodMetadataTests.java +++ b/spring-core/src/test/java/org/springframework/core/type/AbstractMethodMetadataTests.java @@ -260,4 +260,5 @@ public abstract class AbstractMethodMetadataTests { int size(); } + } diff --git a/spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java b/spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java index 9944af3d73..e269a37a7b 100644 --- a/spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java +++ b/spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java @@ -49,17 +49,17 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Phillip Webb * @author Sam Brannen */ -public class AnnotationMetadataTests { +class AnnotationMetadataTests { @Test - public void standardAnnotationMetadata() { + void standardAnnotationMetadata() { AnnotationMetadata metadata = AnnotationMetadata.introspect(AnnotatedComponent.class); doTestAnnotationInfo(metadata); doTestMethodAnnotationInfo(metadata); } @Test - public void asmAnnotationMetadata() throws Exception { + void asmAnnotationMetadata() throws Exception { MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory(); MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(AnnotatedComponent.class.getName()); AnnotationMetadata metadata = metadataReader.getAnnotationMetadata(); @@ -68,13 +68,13 @@ public class AnnotationMetadataTests { } @Test - public void standardAnnotationMetadataForSubclass() { + void standardAnnotationMetadataForSubclass() { AnnotationMetadata metadata = AnnotationMetadata.introspect(AnnotatedComponentSubClass.class); doTestSubClassAnnotationInfo(metadata); } @Test - public void asmAnnotationMetadataForSubclass() throws Exception { + void asmAnnotationMetadataForSubclass() throws Exception { MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory(); MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(AnnotatedComponentSubClass.class.getName()); AnnotationMetadata metadata = metadataReader.getAnnotationMetadata(); @@ -104,13 +104,13 @@ public class AnnotationMetadataTests { } @Test - public void standardAnnotationMetadataForInterface() { + void standardAnnotationMetadataForInterface() { AnnotationMetadata metadata = AnnotationMetadata.introspect(AnnotationMetadata.class); doTestMetadataForInterfaceClass(metadata); } @Test - public void asmAnnotationMetadataForInterface() throws Exception { + void asmAnnotationMetadataForInterface() throws Exception { MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory(); MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(AnnotationMetadata.class.getName()); AnnotationMetadata metadata = metadataReader.getAnnotationMetadata(); @@ -132,13 +132,13 @@ public class AnnotationMetadataTests { } @Test - public void standardAnnotationMetadataForAnnotation() { + void standardAnnotationMetadataForAnnotation() { AnnotationMetadata metadata = AnnotationMetadata.introspect(Component.class); doTestMetadataForAnnotationClass(metadata); } @Test - public void asmAnnotationMetadataForAnnotation() throws Exception { + void asmAnnotationMetadataForAnnotation() throws Exception { MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory(); MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(Component.class.getName()); AnnotationMetadata metadata = metadataReader.getAnnotationMetadata(); @@ -173,7 +173,7 @@ public class AnnotationMetadataTests { */ @Test @Deprecated - public void standardAnnotationMetadata_nestedAnnotationsAsMap_false() { + void standardAnnotationMetadata_nestedAnnotationsAsMap_false() { AnnotationMetadata metadata = new StandardAnnotationMetadata(AnnotatedComponent.class); AnnotationAttributes specialAttrs = (AnnotationAttributes) metadata.getAnnotationAttributes(SpecialAttr.class.getName()); Annotation[] nestedAnnoArray = (Annotation[]) specialAttrs.get("nestedAnnoArray"); @@ -182,13 +182,13 @@ public class AnnotationMetadataTests { @Test @Deprecated - public void metaAnnotationOverridesUsingStandardAnnotationMetadata() { + void metaAnnotationOverridesUsingStandardAnnotationMetadata() { AnnotationMetadata metadata = new StandardAnnotationMetadata(ComposedConfigurationWithAttributeOverridesClass.class); assertMetaAnnotationOverrides(metadata); } @Test - public void metaAnnotationOverridesUsingAnnotationMetadataReadingVisitor() throws Exception { + void metaAnnotationOverridesUsingAnnotationMetadataReadingVisitor() throws Exception { MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory(); MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(ComposedConfigurationWithAttributeOverridesClass.class.getName()); AnnotationMetadata metadata = metadataReader.getAnnotationMetadata(); @@ -204,13 +204,13 @@ public class AnnotationMetadataTests { } @Test // SPR-11649 - public void multipleAnnotationsWithIdenticalAttributeNamesUsingStandardAnnotationMetadata() { + void multipleAnnotationsWithIdenticalAttributeNamesUsingStandardAnnotationMetadata() { AnnotationMetadata metadata = AnnotationMetadata.introspect(NamedAnnotationsClass.class); assertMultipleAnnotationsWithIdenticalAttributeNames(metadata); } @Test // SPR-11649 - public void multipleAnnotationsWithIdenticalAttributeNamesUsingAnnotationMetadataReadingVisitor() throws Exception { + void multipleAnnotationsWithIdenticalAttributeNamesUsingAnnotationMetadataReadingVisitor() throws Exception { MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory(); MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(NamedAnnotationsClass.class.getName()); AnnotationMetadata metadata = metadataReader.getAnnotationMetadata(); @@ -218,13 +218,13 @@ public class AnnotationMetadataTests { } @Test // SPR-11649 - public void composedAnnotationWithMetaAnnotationsWithIdenticalAttributeNamesUsingStandardAnnotationMetadata() { + void composedAnnotationWithMetaAnnotationsWithIdenticalAttributeNamesUsingStandardAnnotationMetadata() { AnnotationMetadata metadata = AnnotationMetadata.introspect(NamedComposedAnnotationClass.class); assertMultipleAnnotationsWithIdenticalAttributeNames(metadata); } @Test // SPR-11649 - public void composedAnnotationWithMetaAnnotationsWithIdenticalAttributeNamesUsingAnnotationMetadataReadingVisitor() throws Exception { + void composedAnnotationWithMetaAnnotationsWithIdenticalAttributeNamesUsingAnnotationMetadataReadingVisitor() throws Exception { MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory(); MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(NamedComposedAnnotationClass.class.getName()); AnnotationMetadata metadata = metadataReader.getAnnotationMetadata(); @@ -232,13 +232,13 @@ public class AnnotationMetadataTests { } @Test - public void inheritedAnnotationWithMetaAnnotationsWithIdenticalAttributeNamesUsingStandardAnnotationMetadata() { + void inheritedAnnotationWithMetaAnnotationsWithIdenticalAttributeNamesUsingStandardAnnotationMetadata() { AnnotationMetadata metadata = AnnotationMetadata.introspect(NamedComposedAnnotationExtended.class); assertThat(metadata.hasAnnotation(NamedComposedAnnotation.class.getName())).isFalse(); } @Test - public void inheritedAnnotationWithMetaAnnotationsWithIdenticalAttributeNamesUsingAnnotationMetadataReadingVisitor() throws Exception { + void inheritedAnnotationWithMetaAnnotationsWithIdenticalAttributeNamesUsingAnnotationMetadataReadingVisitor() throws Exception { MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory(); MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(NamedComposedAnnotationExtended.class.getName()); AnnotationMetadata metadata = metadataReader.getAnnotationMetadata(); diff --git a/spring-core/src/test/java/org/springframework/core/type/AnnotationTypeFilterTests.java b/spring-core/src/test/java/org/springframework/core/type/AnnotationTypeFilterTests.java index a6f0715191..ca5af691a5 100644 --- a/spring-core/src/test/java/org/springframework/core/type/AnnotationTypeFilterTests.java +++ b/spring-core/src/test/java/org/springframework/core/type/AnnotationTypeFilterTests.java @@ -16,10 +16,8 @@ package org.springframework.core.type; -import java.lang.annotation.Inherited; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - +import example.type.InheritedAnnotation; +import example.type.NonInheritedAnnotation; import org.junit.jupiter.api.Test; import org.springframework.core.type.classreading.MetadataReader; @@ -37,12 +35,12 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Sam Brannen * @see AnnotationTypeFilterTestsTypes */ -public class AnnotationTypeFilterTests { +class AnnotationTypeFilterTests { @Test - public void testDirectAnnotationMatch() throws Exception { + void directAnnotationMatch() throws Exception { MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory(); - String classUnderTest = "org.springframework.core.type.AnnotationTypeFilterTestsTypes$SomeComponent"; + String classUnderTest = "example.type.AnnotationTypeFilterTestsTypes$SomeComponent"; MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(classUnderTest); AnnotationTypeFilter filter = new AnnotationTypeFilter(InheritedAnnotation.class); @@ -51,9 +49,9 @@ public class AnnotationTypeFilterTests { } @Test - public void testInheritedAnnotationFromInterfaceDoesNotMatch() throws Exception { + void inheritedAnnotationFromInterfaceDoesNotMatch() throws Exception { MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory(); - String classUnderTest = "org.springframework.core.type.AnnotationTypeFilterTestsTypes$SomeClassWithSomeComponentInterface"; + String classUnderTest = "example.type.AnnotationTypeFilterTestsTypes$SomeClassWithSomeComponentInterface"; MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(classUnderTest); AnnotationTypeFilter filter = new AnnotationTypeFilter(InheritedAnnotation.class); @@ -63,9 +61,9 @@ public class AnnotationTypeFilterTests { } @Test - public void testInheritedAnnotationFromBaseClassDoesMatch() throws Exception { + void inheritedAnnotationFromBaseClassDoesMatch() throws Exception { MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory(); - String classUnderTest = "org.springframework.core.type.AnnotationTypeFilterTestsTypes$SomeSubclassOfSomeComponent"; + String classUnderTest = "example.type.AnnotationTypeFilterTestsTypes$SomeSubclassOfSomeComponent"; MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(classUnderTest); AnnotationTypeFilter filter = new AnnotationTypeFilter(InheritedAnnotation.class); @@ -74,9 +72,9 @@ public class AnnotationTypeFilterTests { } @Test - public void testNonInheritedAnnotationDoesNotMatch() throws Exception { + void nonInheritedAnnotationDoesNotMatch() throws Exception { MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory(); - String classUnderTest = "org.springframework.core.type.AnnotationTypeFilterTestsTypes$SomeSubclassOfSomeClassMarkedWithNonInheritedAnnotation"; + String classUnderTest = "example.type.AnnotationTypeFilterTestsTypes$SomeSubclassOfSomeClassMarkedWithNonInheritedAnnotation"; MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(classUnderTest); AnnotationTypeFilter filter = new AnnotationTypeFilter(NonInheritedAnnotation.class); @@ -86,9 +84,9 @@ public class AnnotationTypeFilterTests { } @Test - public void testNonAnnotatedClassDoesntMatch() throws Exception { + void nonAnnotatedClassDoesntMatch() throws Exception { MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory(); - String classUnderTest = "org.springframework.core.type.AnnotationTypeFilterTestsTypes$SomeNonCandidateClass"; + String classUnderTest = "example.type.AnnotationTypeFilterTestsTypes$SomeNonCandidateClass"; MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(classUnderTest); AnnotationTypeFilter filter = new AnnotationTypeFilter(Component.class); @@ -97,9 +95,9 @@ public class AnnotationTypeFilterTests { } @Test - public void testMatchesInterfacesIfConfigured() throws Exception { + void matchesInterfacesIfConfigured() throws Exception { MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory(); - String classUnderTest = "org.springframework.core.type.AnnotationTypeFilterTestsTypes$SomeClassWithSomeComponentInterface"; + String classUnderTest = "example.type.AnnotationTypeFilterTestsTypes$SomeClassWithSomeComponentInterface"; MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(classUnderTest); AnnotationTypeFilter filter = new AnnotationTypeFilter(InheritedAnnotation.class, false, true); @@ -107,13 +105,4 @@ public class AnnotationTypeFilterTests { ClassloadingAssertions.assertClassNotLoaded(classUnderTest); } - @Inherited - @Retention(RetentionPolicy.RUNTIME) - @interface InheritedAnnotation { - } - - @Retention(RetentionPolicy.RUNTIME) - @interface NonInheritedAnnotation { - } - } diff --git a/spring-core/src/test/java/org/springframework/core/type/AspectJTypeFilterTests.java b/spring-core/src/test/java/org/springframework/core/type/AspectJTypeFilterTests.java index 2184f9f2e7..7dccb11e10 100644 --- a/spring-core/src/test/java/org/springframework/core/type/AspectJTypeFilterTests.java +++ b/spring-core/src/test/java/org/springframework/core/type/AspectJTypeFilterTests.java @@ -30,100 +30,100 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Sam Brannen * @see AspectJTypeFilterTestsTypes */ -public class AspectJTypeFilterTests { +class AspectJTypeFilterTests { @Test - public void namePatternMatches() throws Exception { - assertMatch("org.springframework.core.type.AspectJTypeFilterTestsTypes$SomeClass", - "org.springframework.core.type.AspectJTypeFilterTestsTypes.SomeClass"); - assertMatch("org.springframework.core.type.AspectJTypeFilterTestsTypes$SomeClass", + void namePatternMatches() throws Exception { + assertMatch("example.type.AspectJTypeFilterTestsTypes$SomeClass", + "example.type.AspectJTypeFilterTestsTypes.SomeClass"); + assertMatch("example.type.AspectJTypeFilterTestsTypes$SomeClass", "*"); - assertMatch("org.springframework.core.type.AspectJTypeFilterTestsTypes$SomeClass", + assertMatch("example.type.AspectJTypeFilterTestsTypes$SomeClass", "*..SomeClass"); - assertMatch("org.springframework.core.type.AspectJTypeFilterTestsTypes$SomeClass", - "org..SomeClass"); + assertMatch("example.type.AspectJTypeFilterTestsTypes$SomeClass", + "example..SomeClass"); } @Test - public void namePatternNoMatches() throws Exception { - assertNoMatch("org.springframework.core.type.AspectJTypeFilterTestsTypes$SomeClass", - "org.springframework.core.type.AspectJTypeFilterTestsTypes.SomeClassX"); + void namePatternNoMatches() throws Exception { + assertNoMatch("example.type.AspectJTypeFilterTestsTypes$SomeClass", + "example.type.AspectJTypeFilterTestsTypes.SomeClassX"); } @Test - public void subclassPatternMatches() throws Exception { - assertMatch("org.springframework.core.type.AspectJTypeFilterTestsTypes$SomeClassExtendingSomeClass", - "org.springframework.core.type.AspectJTypeFilterTestsTypes.SomeClass+"); - assertMatch("org.springframework.core.type.AspectJTypeFilterTestsTypes$SomeClassExtendingSomeClass", + void subclassPatternMatches() throws Exception { + assertMatch("example.type.AspectJTypeFilterTestsTypes$SomeClassExtendingSomeClass", + "example.type.AspectJTypeFilterTestsTypes.SomeClass+"); + assertMatch("example.type.AspectJTypeFilterTestsTypes$SomeClassExtendingSomeClass", "*+"); - assertMatch("org.springframework.core.type.AspectJTypeFilterTestsTypes$SomeClassExtendingSomeClass", + assertMatch("example.type.AspectJTypeFilterTestsTypes$SomeClassExtendingSomeClass", "java.lang.Object+"); - assertMatch("org.springframework.core.type.AspectJTypeFilterTestsTypes$SomeClassImplementingSomeInterface", - "org.springframework.core.type.AspectJTypeFilterTestsTypes.SomeInterface+"); - assertMatch("org.springframework.core.type.AspectJTypeFilterTestsTypes$SomeClassImplementingSomeInterface", + assertMatch("example.type.AspectJTypeFilterTestsTypes$SomeClassImplementingSomeInterface", + "example.type.AspectJTypeFilterTestsTypes.SomeInterface+"); + assertMatch("example.type.AspectJTypeFilterTestsTypes$SomeClassImplementingSomeInterface", "*+"); - assertMatch("org.springframework.core.type.AspectJTypeFilterTestsTypes$SomeClassImplementingSomeInterface", + assertMatch("example.type.AspectJTypeFilterTestsTypes$SomeClassImplementingSomeInterface", "java.lang.Object+"); - assertMatch("org.springframework.core.type.AspectJTypeFilterTestsTypes$SomeClassExtendingSomeClassExtendingSomeClassAndImplementingSomeInterface", - "org.springframework.core.type.AspectJTypeFilterTestsTypes.SomeInterface+"); - assertMatch("org.springframework.core.type.AspectJTypeFilterTestsTypes$SomeClassExtendingSomeClassExtendingSomeClassAndImplementingSomeInterface", - "org.springframework.core.type.AspectJTypeFilterTestsTypes.SomeClassExtendingSomeClass+"); - assertMatch("org.springframework.core.type.AspectJTypeFilterTestsTypes$SomeClassExtendingSomeClassExtendingSomeClassAndImplementingSomeInterface", - "org.springframework.core.type.AspectJTypeFilterTestsTypes.SomeClass+"); - assertMatch("org.springframework.core.type.AspectJTypeFilterTestsTypes$SomeClassExtendingSomeClassExtendingSomeClassAndImplementingSomeInterface", + assertMatch("example.type.AspectJTypeFilterTestsTypes$SomeClassExtendingSomeClassExtendingSomeClassAndImplementingSomeInterface", + "example.type.AspectJTypeFilterTestsTypes.SomeInterface+"); + assertMatch("example.type.AspectJTypeFilterTestsTypes$SomeClassExtendingSomeClassExtendingSomeClassAndImplementingSomeInterface", + "example.type.AspectJTypeFilterTestsTypes.SomeClassExtendingSomeClass+"); + assertMatch("example.type.AspectJTypeFilterTestsTypes$SomeClassExtendingSomeClassExtendingSomeClassAndImplementingSomeInterface", + "example.type.AspectJTypeFilterTestsTypes.SomeClass+"); + assertMatch("example.type.AspectJTypeFilterTestsTypes$SomeClassExtendingSomeClassExtendingSomeClassAndImplementingSomeInterface", "*+"); - assertMatch("org.springframework.core.type.AspectJTypeFilterTestsTypes$SomeClassExtendingSomeClassExtendingSomeClassAndImplementingSomeInterface", + assertMatch("example.type.AspectJTypeFilterTestsTypes$SomeClassExtendingSomeClassExtendingSomeClassAndImplementingSomeInterface", "java.lang.Object+"); } @Test - public void subclassPatternNoMatches() throws Exception { - assertNoMatch("org.springframework.core.type.AspectJTypeFilterTestsTypes$SomeClassExtendingSomeClass", + void subclassPatternNoMatches() throws Exception { + assertNoMatch("example.type.AspectJTypeFilterTestsTypes$SomeClassExtendingSomeClass", "java.lang.String+"); } @Test - public void annotationPatternMatches() throws Exception { - assertMatch("org.springframework.core.type.AspectJTypeFilterTestsTypes$SomeClassAnnotatedWithComponent", + void annotationPatternMatches() throws Exception { + assertMatch("example.type.AspectJTypeFilterTestsTypes$SomeClassAnnotatedWithComponent", "@org.springframework.stereotype.Component *..*"); - assertMatch("org.springframework.core.type.AspectJTypeFilterTestsTypes$SomeClassAnnotatedWithComponent", + assertMatch("example.type.AspectJTypeFilterTestsTypes$SomeClassAnnotatedWithComponent", "@* *..*"); - assertMatch("org.springframework.core.type.AspectJTypeFilterTestsTypes$SomeClassAnnotatedWithComponent", + assertMatch("example.type.AspectJTypeFilterTestsTypes$SomeClassAnnotatedWithComponent", "@*..* *..*"); - assertMatch("org.springframework.core.type.AspectJTypeFilterTestsTypes$SomeClassAnnotatedWithComponent", + assertMatch("example.type.AspectJTypeFilterTestsTypes$SomeClassAnnotatedWithComponent", "@*..*Component *..*"); - assertMatch("org.springframework.core.type.AspectJTypeFilterTestsTypes$SomeClassAnnotatedWithComponent", + assertMatch("example.type.AspectJTypeFilterTestsTypes$SomeClassAnnotatedWithComponent", "@org.springframework.stereotype.Component *..*Component"); - assertMatch("org.springframework.core.type.AspectJTypeFilterTestsTypes$SomeClassAnnotatedWithComponent", + assertMatch("example.type.AspectJTypeFilterTestsTypes$SomeClassAnnotatedWithComponent", "@org.springframework.stereotype.Component *"); } @Test - public void annotationPatternNoMatches() throws Exception { - assertNoMatch("org.springframework.core.type.AspectJTypeFilterTestsTypes$SomeClassAnnotatedWithComponent", + void annotationPatternNoMatches() throws Exception { + assertNoMatch("example.type.AspectJTypeFilterTestsTypes$SomeClassAnnotatedWithComponent", "@org.springframework.stereotype.Repository *..*"); } @Test - public void compositionPatternMatches() throws Exception { - assertMatch("org.springframework.core.type.AspectJTypeFilterTestsTypes$SomeClass", + void compositionPatternMatches() throws Exception { + assertMatch("example.type.AspectJTypeFilterTestsTypes$SomeClass", "!*..SomeOtherClass"); - assertMatch("org.springframework.core.type.AspectJTypeFilterTestsTypes$SomeClassExtendingSomeClassExtendingSomeClassAndImplementingSomeInterface", - "org.springframework.core.type.AspectJTypeFilterTestsTypes.SomeInterface+ " + - "&& org.springframework.core.type.AspectJTypeFilterTestsTypes.SomeClass+ " + - "&& org.springframework.core.type.AspectJTypeFilterTestsTypes.SomeClassExtendingSomeClass+"); - assertMatch("org.springframework.core.type.AspectJTypeFilterTestsTypes$SomeClassExtendingSomeClassExtendingSomeClassAndImplementingSomeInterface", - "org.springframework.core.type.AspectJTypeFilterTestsTypes.SomeInterface+ " + - "|| org.springframework.core.type.AspectJTypeFilterTestsTypes.SomeClass+ " + - "|| org.springframework.core.type.AspectJTypeFilterTestsTypes.SomeClassExtendingSomeClass+"); + assertMatch("example.type.AspectJTypeFilterTestsTypes$SomeClassExtendingSomeClassExtendingSomeClassAndImplementingSomeInterface", + "example.type.AspectJTypeFilterTestsTypes.SomeInterface+ " + + "&& example.type.AspectJTypeFilterTestsTypes.SomeClass+ " + + "&& example.type.AspectJTypeFilterTestsTypes.SomeClassExtendingSomeClass+"); + assertMatch("example.type.AspectJTypeFilterTestsTypes$SomeClassExtendingSomeClassExtendingSomeClassAndImplementingSomeInterface", + "example.type.AspectJTypeFilterTestsTypes.SomeInterface+ " + + "|| example.type.AspectJTypeFilterTestsTypes.SomeClass+ " + + "|| example.type.AspectJTypeFilterTestsTypes.SomeClassExtendingSomeClass+"); } @Test - public void compositionPatternNoMatches() throws Exception { - assertNoMatch("org.springframework.core.type.AspectJTypeFilterTestsTypes$SomeClass", - "*..Bogus && org.springframework.core.type.AspectJTypeFilterTestsTypes.SomeClass"); + void compositionPatternNoMatches() throws Exception { + assertNoMatch("example.type.AspectJTypeFilterTestsTypes$SomeClass", + "*..Bogus && example.type.AspectJTypeFilterTestsTypes.SomeClass"); } private void assertMatch(String type, String typePattern) throws Exception { diff --git a/spring-core/src/test/java/org/springframework/core/type/AssignableTypeFilterTests.java b/spring-core/src/test/java/org/springframework/core/type/AssignableTypeFilterTests.java index cb131d92e3..757371a615 100644 --- a/spring-core/src/test/java/org/springframework/core/type/AssignableTypeFilterTests.java +++ b/spring-core/src/test/java/org/springframework/core/type/AssignableTypeFilterTests.java @@ -28,51 +28,50 @@ import static org.assertj.core.api.Assertions.assertThat; /** * @author Ramnivas Laddad * @author Juergen Hoeller - * @see AssignableTypeFilterTestsTypes */ -public class AssignableTypeFilterTests { +class AssignableTypeFilterTests { @Test - public void directMatch() throws Exception { + void directMatch() throws Exception { MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory(); - String classUnderTest = "org.springframework.core.type.AssignableTypeFilterTestsTypes$TestNonInheritingClass"; + String classUnderTest = "example.type.AssignableTypeFilterTestsTypes$TestNonInheritingClass"; MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(classUnderTest); - AssignableTypeFilter matchingFilter = new AssignableTypeFilter(AssignableTypeFilterTestsTypes.TestNonInheritingClass.class); - AssignableTypeFilter notMatchingFilter = new AssignableTypeFilter(AssignableTypeFilterTestsTypes.TestInterface.class); + AssignableTypeFilter matchingFilter = new AssignableTypeFilter(example.type.AssignableTypeFilterTestsTypes.TestNonInheritingClass.class); + AssignableTypeFilter notMatchingFilter = new AssignableTypeFilter(example.type.AssignableTypeFilterTestsTypes.TestInterface.class); assertThat(notMatchingFilter.match(metadataReader, metadataReaderFactory)).isFalse(); assertThat(matchingFilter.match(metadataReader, metadataReaderFactory)).isTrue(); } @Test - public void interfaceMatch() throws Exception { + void interfaceMatch() throws Exception { MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory(); - String classUnderTest = "org.springframework.core.type.AssignableTypeFilterTestsTypes$TestInterfaceImpl"; + String classUnderTest = "example.type.AssignableTypeFilterTestsTypes$TestInterfaceImpl"; MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(classUnderTest); - AssignableTypeFilter filter = new AssignableTypeFilter(AssignableTypeFilterTestsTypes.TestInterface.class); + AssignableTypeFilter filter = new AssignableTypeFilter(example.type.AssignableTypeFilterTestsTypes.TestInterface.class); assertThat(filter.match(metadataReader, metadataReaderFactory)).isTrue(); ClassloadingAssertions.assertClassNotLoaded(classUnderTest); } @Test - public void superClassMatch() throws Exception { + void superClassMatch() throws Exception { MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory(); - String classUnderTest = "org.springframework.core.type.AssignableTypeFilterTestsTypes$SomeDaoLikeImpl"; + String classUnderTest = "example.type.AssignableTypeFilterTestsTypes$SomeDaoLikeImpl"; MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(classUnderTest); - AssignableTypeFilter filter = new AssignableTypeFilter(AssignableTypeFilterTestsTypes.SimpleJdbcDaoSupport.class); + AssignableTypeFilter filter = new AssignableTypeFilter(example.type.AssignableTypeFilterTestsTypes.SimpleJdbcDaoSupport.class); assertThat(filter.match(metadataReader, metadataReaderFactory)).isTrue(); ClassloadingAssertions.assertClassNotLoaded(classUnderTest); } @Test - public void interfaceThroughSuperClassMatch() throws Exception { + void interfaceThroughSuperClassMatch() throws Exception { MetadataReaderFactory metadataReaderFactory = new SimpleMetadataReaderFactory(); - String classUnderTest = "org.springframework.core.type.AssignableTypeFilterTestsTypes$SomeDaoLikeImpl"; + String classUnderTest = "example.type.AssignableTypeFilterTestsTypes$SomeDaoLikeImpl"; MetadataReader metadataReader = metadataReaderFactory.getMetadataReader(classUnderTest); - AssignableTypeFilter filter = new AssignableTypeFilter(AssignableTypeFilterTestsTypes.JdbcDaoSupport.class); + AssignableTypeFilter filter = new AssignableTypeFilter(example.type.AssignableTypeFilterTestsTypes.JdbcDaoSupport.class); assertThat(filter.match(metadataReader, metadataReaderFactory)).isTrue(); ClassloadingAssertions.assertClassNotLoaded(classUnderTest); } diff --git a/spring-core/src/test/java/org/springframework/core/type/CachingMetadataReaderLeakTests.java b/spring-core/src/test/java/org/springframework/core/type/CachingMetadataReaderLeakTests.java index 2b45d5d6ec..9f61f13282 100644 --- a/spring-core/src/test/java/org/springframework/core/type/CachingMetadataReaderLeakTests.java +++ b/spring-core/src/test/java/org/springframework/core/type/CachingMetadataReaderLeakTests.java @@ -39,14 +39,14 @@ import static org.springframework.tests.TestGroup.LONG_RUNNING; * @author Sam Brannen */ @EnabledForTestGroups(LONG_RUNNING) -public class CachingMetadataReaderLeakTests { +class CachingMetadataReaderLeakTests { private static final int ITEMS_TO_LOAD = 9999; private final MetadataReaderFactory mrf = new CachingMetadataReaderFactory(); @Test - public void testSignificantLoad() throws Exception { + void significantLoad() throws Exception { // the biggest public class in the JDK (>60k) URL url = getClass().getResource("/java/awt/Component.class"); assertThat(url).isNotNull(); diff --git a/spring-core/src/test/java/org/springframework/core/type/StandardAnnotationMetadataTests.java b/spring-core/src/test/java/org/springframework/core/type/StandardAnnotationMetadataTests.java index 49413a0af0..e545ac768e 100644 --- a/spring-core/src/test/java/org/springframework/core/type/StandardAnnotationMetadataTests.java +++ b/spring-core/src/test/java/org/springframework/core/type/StandardAnnotationMetadataTests.java @@ -21,7 +21,7 @@ package org.springframework.core.type; * * @author Phillip Webb */ -public class StandardAnnotationMetadataTests extends AbstractAnnotationMetadataTests { +class StandardAnnotationMetadataTests extends AbstractAnnotationMetadataTests { @Override @SuppressWarnings("deprecation") diff --git a/spring-core/src/test/java/org/springframework/core/type/StandardClassMetadataMemberClassTests.java b/spring-core/src/test/java/org/springframework/core/type/StandardClassMetadataMemberClassTests.java index 3e6260b47a..b8fd64ac01 100644 --- a/spring-core/src/test/java/org/springframework/core/type/StandardClassMetadataMemberClassTests.java +++ b/spring-core/src/test/java/org/springframework/core/type/StandardClassMetadataMemberClassTests.java @@ -21,8 +21,7 @@ package org.springframework.core.type; * @since 3.1 * @see AbstractClassMetadataMemberClassTests */ -public class StandardClassMetadataMemberClassTests - extends AbstractClassMetadataMemberClassTests { +class StandardClassMetadataMemberClassTests extends AbstractClassMetadataMemberClassTests { @Override @SuppressWarnings("deprecation") diff --git a/spring-core/src/test/java/org/springframework/core/type/StandardMethodMetadataTests.java b/spring-core/src/test/java/org/springframework/core/type/StandardMethodMetadataTests.java index 397e239aa9..950d6a408f 100644 --- a/spring-core/src/test/java/org/springframework/core/type/StandardMethodMetadataTests.java +++ b/spring-core/src/test/java/org/springframework/core/type/StandardMethodMetadataTests.java @@ -21,7 +21,7 @@ package org.springframework.core.type; * * @author Phillip Webb */ -public class StandardMethodMetadataTests extends AbstractMethodMetadataTests { +class StandardMethodMetadataTests extends AbstractMethodMetadataTests { @Override protected AnnotationMetadata get(Class source) { diff --git a/spring-core/src/test/java/org/springframework/core/type/classreading/AnnotationMetadataReadingVisitorTests.java b/spring-core/src/test/java/org/springframework/core/type/classreading/AnnotationMetadataReadingVisitorTests.java index 552e0540a4..341698da78 100644 --- a/spring-core/src/test/java/org/springframework/core/type/classreading/AnnotationMetadataReadingVisitorTests.java +++ b/spring-core/src/test/java/org/springframework/core/type/classreading/AnnotationMetadataReadingVisitorTests.java @@ -35,8 +35,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; * @author Phillip Webb */ @SuppressWarnings("deprecation") -public class AnnotationMetadataReadingVisitorTests - extends AbstractAnnotationMetadataTests { +class AnnotationMetadataReadingVisitorTests extends AbstractAnnotationMetadataTests { @Override protected AnnotationMetadata get(Class source) { diff --git a/spring-core/src/test/java/org/springframework/core/type/classreading/ClassMetadataReadingVisitorMemberClassTests.java b/spring-core/src/test/java/org/springframework/core/type/classreading/ClassMetadataReadingVisitorMemberClassTests.java index 69643b371b..cdb594fc9d 100644 --- a/spring-core/src/test/java/org/springframework/core/type/classreading/ClassMetadataReadingVisitorMemberClassTests.java +++ b/spring-core/src/test/java/org/springframework/core/type/classreading/ClassMetadataReadingVisitorMemberClassTests.java @@ -26,8 +26,7 @@ import org.springframework.core.type.ClassMetadata; * @since 3.1 * @see AbstractClassMetadataMemberClassTests */ -public class ClassMetadataReadingVisitorMemberClassTests - extends AbstractClassMetadataMemberClassTests { +class ClassMetadataReadingVisitorMemberClassTests extends AbstractClassMetadataMemberClassTests { @Override public ClassMetadata getClassMetadataFor(Class clazz) { diff --git a/spring-core/src/test/java/org/springframework/core/type/classreading/MergedAnnotationMetadataVisitorTests.java b/spring-core/src/test/java/org/springframework/core/type/classreading/MergedAnnotationMetadataVisitorTests.java index 6fe33d1a66..9c68a8cd2a 100644 --- a/spring-core/src/test/java/org/springframework/core/type/classreading/MergedAnnotationMetadataVisitorTests.java +++ b/spring-core/src/test/java/org/springframework/core/type/classreading/MergedAnnotationMetadataVisitorTests.java @@ -37,12 +37,12 @@ import static org.assertj.core.api.Assertions.assertThat; * * @author Phillip Webb */ -public class MergedAnnotationMetadataVisitorTests { +class MergedAnnotationMetadataVisitorTests { private MergedAnnotation annotation; @Test - public void visitWhenHasSimpleTypesCreatesAnnotation() { + void visitWhenHasSimpleTypesCreatesAnnotation() { loadFrom(WithSimpleTypesAnnotation.class); assertThat(this.annotation.getType()).isEqualTo(SimpleTypesAnnotation.class); assertThat(this.annotation.getValue("stringValue")).contains("string"); @@ -57,7 +57,7 @@ public class MergedAnnotationMetadataVisitorTests { } @Test - public void visitWhenHasSimpleArrayTypesCreatesAnnotation() { + void visitWhenHasSimpleArrayTypesCreatesAnnotation() { loadFrom(WithSimpleArrayTypesAnnotation.class); assertThat(this.annotation.getType()).isEqualTo(SimpleArrayTypesAnnotation.class); assertThat(this.annotation.getValue("stringValue")).contains( @@ -75,7 +75,7 @@ public class MergedAnnotationMetadataVisitorTests { } @Test - public void visitWhenHasEmptySimpleArrayTypesCreatesAnnotation() { + void visitWhenHasEmptySimpleArrayTypesCreatesAnnotation() { loadFrom(WithSimpleEmptyArrayTypesAnnotation.class); assertThat(this.annotation.getType()).isEqualTo(SimpleArrayTypesAnnotation.class); assertThat(this.annotation.getValue("stringValue")).contains(new String[] {}); @@ -90,7 +90,7 @@ public class MergedAnnotationMetadataVisitorTests { } @Test - public void visitWhenHasEnumAttributesCreatesAnnotation() { + void visitWhenHasEnumAttributesCreatesAnnotation() { loadFrom(WithEnumAnnotation.class); assertThat(this.annotation.getType()).isEqualTo(EnumAnnotation.class); assertThat(this.annotation.getValue("enumValue")).contains(ExampleEnum.ONE); @@ -99,7 +99,7 @@ public class MergedAnnotationMetadataVisitorTests { } @Test - public void visitWhenHasAnnotationAttributesCreatesAnnotation() { + void visitWhenHasAnnotationAttributesCreatesAnnotation() { loadFrom(WithAnnotationAnnotation.class); assertThat(this.annotation.getType()).isEqualTo(AnnotationAnnotation.class); MergedAnnotation value = this.annotation.getAnnotation( @@ -114,7 +114,7 @@ public class MergedAnnotationMetadataVisitorTests { } @Test - public void visitWhenHasClassAttributesCreatesAnnotation() { + void visitWhenHasClassAttributesCreatesAnnotation() { loadFrom(WithClassAnnotation.class); assertThat(this.annotation.getType()).isEqualTo(ClassAnnotation.class); assertThat(this.annotation.getString("classValue")).isEqualTo(InputStream.class.getName()); diff --git a/spring-core/src/test/java/org/springframework/core/type/classreading/MethodMetadataReadingVisitorTests.java b/spring-core/src/test/java/org/springframework/core/type/classreading/MethodMetadataReadingVisitorTests.java index dc0858ba36..c3cd1456a0 100644 --- a/spring-core/src/test/java/org/springframework/core/type/classreading/MethodMetadataReadingVisitorTests.java +++ b/spring-core/src/test/java/org/springframework/core/type/classreading/MethodMetadataReadingVisitorTests.java @@ -35,7 +35,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; * @author Phillip Webb */ @SuppressWarnings("deprecation") -public class MethodMetadataReadingVisitorTests extends AbstractMethodMetadataTests { +class MethodMetadataReadingVisitorTests extends AbstractMethodMetadataTests { @Override protected AnnotationMetadata get(Class source) { diff --git a/spring-core/src/test/java/org/springframework/core/type/classreading/SimpleAnnotationMetadataTests.java b/spring-core/src/test/java/org/springframework/core/type/classreading/SimpleAnnotationMetadataTests.java index 96d920825f..f66c81bc35 100644 --- a/spring-core/src/test/java/org/springframework/core/type/classreading/SimpleAnnotationMetadataTests.java +++ b/spring-core/src/test/java/org/springframework/core/type/classreading/SimpleAnnotationMetadataTests.java @@ -25,7 +25,7 @@ import org.springframework.core.type.AnnotationMetadata; * * @author Phillip Webb */ -public class SimpleAnnotationMetadataTests extends AbstractAnnotationMetadataTests { +class SimpleAnnotationMetadataTests extends AbstractAnnotationMetadataTests { @Override protected AnnotationMetadata get(Class source) { diff --git a/spring-core/src/test/java/org/springframework/core/type/classreading/SimpleMethodMetadataTests.java b/spring-core/src/test/java/org/springframework/core/type/classreading/SimpleMethodMetadataTests.java index 0ca9bbc75b..4afd423497 100644 --- a/spring-core/src/test/java/org/springframework/core/type/classreading/SimpleMethodMetadataTests.java +++ b/spring-core/src/test/java/org/springframework/core/type/classreading/SimpleMethodMetadataTests.java @@ -25,7 +25,7 @@ import org.springframework.core.type.AnnotationMetadata; * * @author Phillip Webb */ -public class SimpleMethodMetadataTests extends AbstractMethodMetadataTests { +class SimpleMethodMetadataTests extends AbstractMethodMetadataTests { @Override protected AnnotationMetadata get(Class source) { diff --git a/spring-core/src/test/java/org/springframework/tests/MockitoUtils.java b/spring-core/src/test/java/org/springframework/tests/MockitoUtils.java index 7c8d27b03f..60df908e60 100644 --- a/spring-core/src/test/java/org/springframework/tests/MockitoUtils.java +++ b/spring-core/src/test/java/org/springframework/tests/MockitoUtils.java @@ -25,9 +25,6 @@ import org.mockito.invocation.Invocation; import static org.assertj.core.api.Assertions.assertThat; - - - /** * General test utilities for use with {@link Mockito}. * diff --git a/spring-core/src/test/java/org/springframework/util/AntPathMatcherTests.java b/spring-core/src/test/java/org/springframework/util/AntPathMatcherTests.java index e3ebf950ab..a67ebf3796 100644 --- a/spring-core/src/test/java/org/springframework/util/AntPathMatcherTests.java +++ b/spring-core/src/test/java/org/springframework/util/AntPathMatcherTests.java @@ -38,13 +38,13 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException * @author Rossen Stoyanchev * @author Sam Brannen */ -public class AntPathMatcherTests { +class AntPathMatcherTests { private final AntPathMatcher pathMatcher = new AntPathMatcher(); @Test - public void match() { + void match() { // test exact matching assertThat(pathMatcher.match("test", "test")).isTrue(); assertThat(pathMatcher.match("/test", "/test")).isTrue(); @@ -133,7 +133,7 @@ public class AntPathMatcherTests { } @Test - public void matchWithNullPath() { + void matchWithNullPath() { assertThat(pathMatcher.match("/test", null)).isFalse(); assertThat(pathMatcher.match("/", null)).isFalse(); assertThat(pathMatcher.match(null, null)).isFalse(); @@ -141,14 +141,14 @@ public class AntPathMatcherTests { // SPR-14247 @Test - public void matchWithTrimTokensEnabled() throws Exception { + void matchWithTrimTokensEnabled() throws Exception { pathMatcher.setTrimTokens(true); assertThat(pathMatcher.match("/foo/bar", "/foo /bar")).isTrue(); } @Test - public void matchStart() { + void matchStart() { // test exact matching assertThat(pathMatcher.matchStart("test", "test")).isTrue(); assertThat(pathMatcher.matchStart("/test", "/test")).isTrue(); @@ -235,7 +235,7 @@ public class AntPathMatcherTests { } @Test - public void uniqueDeliminator() { + void uniqueDeliminator() { pathMatcher.setPathSeparator("."); // test exact matching @@ -297,7 +297,7 @@ public class AntPathMatcherTests { } @Test - public void extractPathWithinPattern() throws Exception { + void extractPathWithinPattern() throws Exception { assertThat(pathMatcher.extractPathWithinPattern("/docs/commit.html", "/docs/commit.html")).isEqualTo(""); assertThat(pathMatcher.extractPathWithinPattern("/docs/*", "/docs/cvs/commit")).isEqualTo("cvs/commit"); @@ -323,7 +323,7 @@ public class AntPathMatcherTests { } @Test - public void extractUriTemplateVariables() throws Exception { + void extractUriTemplateVariables() throws Exception { Map result = pathMatcher.extractUriTemplateVariables("/hotels/{hotel}", "/hotels/1"); assertThat(result).isEqualTo(Collections.singletonMap("hotel", "1")); @@ -356,7 +356,7 @@ public class AntPathMatcherTests { } @Test - public void extractUriTemplateVariablesRegex() { + void extractUriTemplateVariablesRegex() { Map result = pathMatcher .extractUriTemplateVariables("{symbolicName:[\\w\\.]+}-{version:[\\w\\.]+}.jar", "com.example-1.0.0.jar"); @@ -373,7 +373,7 @@ public class AntPathMatcherTests { * SPR-7787 */ @Test - public void extractUriTemplateVarsRegexQualifiers() { + void extractUriTemplateVarsRegexQualifiers() { Map result = pathMatcher.extractUriTemplateVariables( "{symbolicName:[\\p{L}\\.]+}-sources-{version:[\\p{N}\\.]+}.jar", "com.example-sources-1.0.0.jar"); @@ -400,14 +400,14 @@ public class AntPathMatcherTests { * SPR-8455 */ @Test - public void extractUriTemplateVarsRegexCapturingGroups() { + void extractUriTemplateVarsRegexCapturingGroups() { assertThatIllegalArgumentException().isThrownBy(() -> pathMatcher.extractUriTemplateVariables("/web/{id:foo(bar)?}", "/web/foobar")) .withMessageContaining("The number of capturing groups in the pattern"); } @Test - public void combine() { + void combine() { assertThat(pathMatcher.combine(null, null)).isEqualTo(""); assertThat(pathMatcher.combine("/hotels", null)).isEqualTo("/hotels"); assertThat(pathMatcher.combine(null, "/hotels")).isEqualTo("/hotels"); @@ -444,13 +444,13 @@ public class AntPathMatcherTests { } @Test - public void combineWithTwoFileExtensionPatterns() { + void combineWithTwoFileExtensionPatterns() { assertThatIllegalArgumentException().isThrownBy(() -> pathMatcher.combine("/*.html", "/*.txt")); } @Test - public void patternComparator() { + void patternComparator() { Comparator comparator = pathMatcher.getPatternComparator("/hotels/new"); assertThat(comparator.compare(null, null)).isEqualTo(0); @@ -504,7 +504,7 @@ public class AntPathMatcherTests { } @Test - public void patternComparatorSort() { + void patternComparatorSort() { Comparator comparator = pathMatcher.getPatternComparator("/hotels/new"); List paths = new ArrayList<>(3); @@ -600,7 +600,7 @@ public class AntPathMatcherTests { } @Test // SPR-8687 - public void trimTokensOff() { + void trimTokensOff() { pathMatcher.setTrimTokens(false); assertThat(pathMatcher.match("/group/{groupName}/members", "/group/sales/members")).isTrue(); @@ -609,7 +609,7 @@ public class AntPathMatcherTests { } @Test // SPR-13286 - public void caseInsensitive() { + void caseInsensitive() { pathMatcher.setCaseSensitive(false); assertThat(pathMatcher.match("/group/{groupName}/members", "/group/sales/members")).isTrue(); @@ -618,7 +618,7 @@ public class AntPathMatcherTests { } @Test - public void defaultCacheSetting() { + void defaultCacheSetting() { match(); assertThat(pathMatcher.stringMatcherCache.size() > 20).isTrue(); @@ -630,7 +630,7 @@ public class AntPathMatcherTests { } @Test - public void cachePatternsSetToTrue() { + void cachePatternsSetToTrue() { pathMatcher.setCachePatterns(true); match(); assertThat(pathMatcher.stringMatcherCache.size() > 20).isTrue(); @@ -643,7 +643,7 @@ public class AntPathMatcherTests { } @Test - public void preventCreatingStringMatchersIfPathDoesNotStartsWithPatternPrefix() { + void preventCreatingStringMatchersIfPathDoesNotStartsWithPatternPrefix() { pathMatcher.setCachePatterns(true); assertThat(pathMatcher.stringMatcherCache.size()).isEqualTo(0); @@ -658,7 +658,7 @@ public class AntPathMatcherTests { } @Test - public void creatingStringMatchersIfPatternPrefixCannotDetermineIfPathMatch() { + void creatingStringMatchersIfPatternPrefixCannotDetermineIfPathMatch() { pathMatcher.setCachePatterns(true); assertThat(pathMatcher.stringMatcherCache.size()).isEqualTo(0); @@ -675,20 +675,20 @@ public class AntPathMatcherTests { } @Test - public void cachePatternsSetToFalse() { + void cachePatternsSetToFalse() { pathMatcher.setCachePatterns(false); match(); assertThat(pathMatcher.stringMatcherCache.isEmpty()).isTrue(); } @Test - public void extensionMappingWithDotPathSeparator() { + void extensionMappingWithDotPathSeparator() { pathMatcher.setPathSeparator("."); assertThat(pathMatcher.combine("/*.html", "hotel.*")).as("Extension mapping should be disabled with \".\" as path separator").isEqualTo("/*.html.hotel.*"); } @Test // gh-22959 - public void isPattern() { + void isPattern() { assertThat(pathMatcher.isPattern("/test/*")).isTrue(); assertThat(pathMatcher.isPattern("/test/**/name")).isTrue(); assertThat(pathMatcher.isPattern("/test?")).isTrue(); @@ -699,7 +699,7 @@ public class AntPathMatcherTests { } @Test // gh-23297 - public void isPatternWithNullPath() { + void isPatternWithNullPath() { assertThat(pathMatcher.isPattern(null)).isFalse(); } diff --git a/spring-core/src/test/java/org/springframework/util/AssertTests.java b/spring-core/src/test/java/org/springframework/util/AssertTests.java index 5d9efa67d9..db47df0d56 100644 --- a/spring-core/src/test/java/org/springframework/util/AssertTests.java +++ b/spring-core/src/test/java/org/springframework/util/AssertTests.java @@ -39,626 +39,625 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException; * @author Sam Brannen * @author Juergen Hoeller */ -public class AssertTests { - +class AssertTests { @Test - public void stateWithMessage() { + void stateWithMessage() { Assert.state(true, "enigma"); } @Test - public void stateWithFalseExpressionAndMessage() { + void stateWithFalseExpressionAndMessage() { assertThatIllegalStateException().isThrownBy(() -> Assert.state(false, "enigma")).withMessageContaining("enigma"); } @Test - public void stateWithMessageSupplier() { + void stateWithMessageSupplier() { Assert.state(true, () -> "enigma"); } @Test - public void stateWithFalseExpressionAndMessageSupplier() { + void stateWithFalseExpressionAndMessageSupplier() { assertThatIllegalStateException().isThrownBy(() -> Assert.state(false, () -> "enigma")) .withMessageContaining("enigma"); } @Test - public void stateWithFalseExpressionAndNullMessageSupplier() { + void stateWithFalseExpressionAndNullMessageSupplier() { assertThatIllegalStateException().isThrownBy(() -> Assert.state(false, (Supplier) null)) .withMessage(null); } @Test - public void isTrueWithMessage() { + void isTrueWithMessage() { Assert.isTrue(true, "enigma"); } @Test - public void isTrueWithFalse() { + void isTrueWithFalse() { assertThatIllegalArgumentException().isThrownBy(() -> Assert.isTrue(false, "enigma")) .withMessageContaining("enigma"); } @Test - public void isTrueWithMessageSupplier() { + void isTrueWithMessageSupplier() { Assert.isTrue(true, () -> "enigma"); } @Test - public void isTrueWithFalseAndMessageSupplier() { + void isTrueWithFalseAndMessageSupplier() { assertThatIllegalArgumentException().isThrownBy(() -> Assert.isTrue(false, () -> "enigma")) .withMessageContaining("enigma"); } @Test - public void isTrueWithFalseAndNullMessageSupplier() { + void isTrueWithFalseAndNullMessageSupplier() { assertThatIllegalArgumentException().isThrownBy(() -> Assert.isTrue(false, (Supplier) null)) .withMessage(null); } @Test - public void isNullWithMessage() { + void isNullWithMessage() { Assert.isNull(null, "Bla"); } @Test - public void isNullWithMessageSupplier() { + void isNullWithMessageSupplier() { Assert.isNull(null, () -> "enigma"); } @Test - public void isNullWithNonNullObjectAndMessageSupplier() { + void isNullWithNonNullObjectAndMessageSupplier() { assertThatIllegalArgumentException().isThrownBy(() -> Assert.isNull("foo", () -> "enigma")) .withMessageContaining("enigma"); } @Test - public void isNullWithNonNullObjectAndNullMessageSupplier() { + void isNullWithNonNullObjectAndNullMessageSupplier() { assertThatIllegalArgumentException().isThrownBy(() -> Assert.isNull("foo", (Supplier) null)) .withMessage(null); } @Test - public void notNullWithMessage() { + void notNullWithMessage() { Assert.notNull("foo", "enigma"); } @Test - public void notNullWithMessageSupplier() { + void notNullWithMessageSupplier() { Assert.notNull("foo", () -> "enigma"); } @Test - public void notNullWithNullAndMessageSupplier() { + void notNullWithNullAndMessageSupplier() { assertThatIllegalArgumentException().isThrownBy(() -> Assert.notNull(null, () -> "enigma")) .withMessageContaining("enigma"); } @Test - public void notNullWithNullAndNullMessageSupplier() { + void notNullWithNullAndNullMessageSupplier() { assertThatIllegalArgumentException().isThrownBy(() -> Assert.notNull(null, (Supplier) null)) .withMessage(null); } @Test - public void hasLength() { + void hasLength() { Assert.hasLength("I Heart ...", "enigma"); } @Test - public void hasLengthWithWhitespaceOnly() { + void hasLengthWithWhitespaceOnly() { Assert.hasLength("\t ", "enigma"); } @Test - public void hasLengthWithEmptyString() { + void hasLengthWithEmptyString() { assertThatIllegalArgumentException().isThrownBy(() -> Assert.hasLength("", "enigma")) .withMessageContaining("enigma"); } @Test - public void hasLengthWithNull() { + void hasLengthWithNull() { assertThatIllegalArgumentException().isThrownBy(() -> Assert.hasLength(null, "enigma")) .withMessageContaining("enigma"); } @Test - public void hasLengthWithMessageSupplier() { + void hasLengthWithMessageSupplier() { Assert.hasLength("foo", () -> "enigma"); } @Test - public void hasLengthWithWhitespaceOnlyAndMessageSupplier() { + void hasLengthWithWhitespaceOnlyAndMessageSupplier() { Assert.hasLength("\t", () -> "enigma"); } @Test - public void hasLengthWithEmptyStringAndMessageSupplier() { + void hasLengthWithEmptyStringAndMessageSupplier() { assertThatIllegalArgumentException().isThrownBy(() -> Assert.hasLength("", () -> "enigma")) .withMessageContaining("enigma"); } @Test - public void hasLengthWithNullAndMessageSupplier() { + void hasLengthWithNullAndMessageSupplier() { assertThatIllegalArgumentException().isThrownBy(() -> Assert.hasLength(null, () -> "enigma")) .withMessageContaining("enigma"); } @Test - public void hasLengthWithNullAndNullMessageSupplier() { + void hasLengthWithNullAndNullMessageSupplier() { assertThatIllegalArgumentException().isThrownBy(() -> Assert.hasLength(null, (Supplier) null)) .withMessage(null); } @Test - public void hasText() { + void hasText() { Assert.hasText("foo", "enigma"); } @Test - public void hasTextWithWhitespaceOnly() { + void hasTextWithWhitespaceOnly() { assertThatIllegalArgumentException().isThrownBy(() -> Assert.hasText("\t ", "enigma")) .withMessageContaining("enigma"); } @Test - public void hasTextWithEmptyString() { + void hasTextWithEmptyString() { assertThatIllegalArgumentException().isThrownBy(() -> Assert.hasText("", "enigma")) .withMessageContaining("enigma"); } @Test - public void hasTextWithNull() { + void hasTextWithNull() { assertThatIllegalArgumentException().isThrownBy(() -> Assert.hasText(null, "enigma")) .withMessageContaining("enigma"); } @Test - public void hasTextWithMessageSupplier() { + void hasTextWithMessageSupplier() { Assert.hasText("foo", () -> "enigma"); } @Test - public void hasTextWithWhitespaceOnlyAndMessageSupplier() { + void hasTextWithWhitespaceOnlyAndMessageSupplier() { assertThatIllegalArgumentException().isThrownBy(() -> Assert.hasText("\t ", () -> "enigma")) .withMessageContaining("enigma"); } @Test - public void hasTextWithEmptyStringAndMessageSupplier() { + void hasTextWithEmptyStringAndMessageSupplier() { assertThatIllegalArgumentException().isThrownBy(() -> Assert.hasText("", () -> "enigma")).withMessageContaining("enigma"); } @Test - public void hasTextWithNullAndMessageSupplier() { + void hasTextWithNullAndMessageSupplier() { assertThatIllegalArgumentException().isThrownBy(() -> Assert.hasText(null, () -> "enigma")) .withMessageContaining("enigma"); } @Test - public void hasTextWithNullAndNullMessageSupplier() { + void hasTextWithNullAndNullMessageSupplier() { assertThatIllegalArgumentException().isThrownBy(() -> Assert.hasText(null, (Supplier) null)) .withMessage(null); } @Test - public void doesNotContainWithNullSearchString() { + void doesNotContainWithNullSearchString() { Assert.doesNotContain(null, "rod", "enigma"); } @Test - public void doesNotContainWithNullSubstring() { + void doesNotContainWithNullSubstring() { Assert.doesNotContain("A cool chick's name is Brod.", null, "enigma"); } @Test - public void doesNotContainWithEmptySubstring() { + void doesNotContainWithEmptySubstring() { Assert.doesNotContain("A cool chick's name is Brod.", "", "enigma"); } @Test - public void doesNotContainWithNullSearchStringAndNullSubstring() { + void doesNotContainWithNullSearchStringAndNullSubstring() { Assert.doesNotContain(null, null, "enigma"); } @Test - public void doesNotContainWithMessageSupplier() { + void doesNotContainWithMessageSupplier() { Assert.doesNotContain("foo", "bar", () -> "enigma"); } @Test - public void doesNotContainWithNullSearchStringAndMessageSupplier() { + void doesNotContainWithNullSearchStringAndMessageSupplier() { Assert.doesNotContain(null, "bar", () -> "enigma"); } @Test - public void doesNotContainWithNullSubstringAndMessageSupplier() { + void doesNotContainWithNullSubstringAndMessageSupplier() { Assert.doesNotContain("foo", null, () -> "enigma"); } @Test - public void doesNotContainWithNullSearchStringAndNullSubstringAndMessageSupplier() { + void doesNotContainWithNullSearchStringAndNullSubstringAndMessageSupplier() { Assert.doesNotContain(null, null, () -> "enigma"); } @Test - public void doesNotContainWithSubstringPresentInSearchStringAndMessageSupplier() { + void doesNotContainWithSubstringPresentInSearchStringAndMessageSupplier() { assertThatIllegalArgumentException().isThrownBy(() -> Assert.doesNotContain("1234", "23", () -> "enigma")) .withMessageContaining("enigma"); } @Test - public void doesNotContainWithNullMessageSupplier() { + void doesNotContainWithNullMessageSupplier() { assertThatIllegalArgumentException().isThrownBy(() -> Assert.doesNotContain("1234", "23", (Supplier) null)) .withMessage(null); } @Test - public void notEmptyArray() { + void notEmptyArray() { Assert.notEmpty(new String[] {"1234"}, "enigma"); } @Test - public void notEmptyArrayWithEmptyArray() { + void notEmptyArrayWithEmptyArray() { assertThatIllegalArgumentException().isThrownBy(() -> Assert.notEmpty(new String[] {}, "enigma")) .withMessageContaining("enigma"); } @Test - public void notEmptyArrayWithNullArray() { + void notEmptyArrayWithNullArray() { assertThatIllegalArgumentException().isThrownBy(() -> Assert.notEmpty((Object[]) null, "enigma")) .withMessageContaining("enigma"); } @Test - public void notEmptyArrayWithMessageSupplier() { + void notEmptyArrayWithMessageSupplier() { Assert.notEmpty(new String[] {"1234"}, () -> "enigma"); } @Test - public void notEmptyArrayWithEmptyArrayAndMessageSupplier() { + void notEmptyArrayWithEmptyArrayAndMessageSupplier() { assertThatIllegalArgumentException().isThrownBy(() -> Assert.notEmpty(new String[] {}, () -> "enigma")) .withMessageContaining("enigma"); } @Test - public void notEmptyArrayWithNullArrayAndMessageSupplier() { + void notEmptyArrayWithNullArrayAndMessageSupplier() { assertThatIllegalArgumentException().isThrownBy(() -> Assert.notEmpty((Object[]) null, () -> "enigma")) .withMessageContaining("enigma"); } @Test - public void notEmptyArrayWithEmptyArrayAndNullMessageSupplier() { + void notEmptyArrayWithEmptyArrayAndNullMessageSupplier() { assertThatIllegalArgumentException().isThrownBy(() -> Assert.notEmpty(new String[] {}, (Supplier) null)) .withMessage(null); } @Test - public void noNullElements() { + void noNullElements() { Assert.noNullElements(new String[] { "1234" }, "enigma"); } @Test - public void noNullElementsWithEmptyArray() { + void noNullElementsWithEmptyArray() { Assert.noNullElements(new String[] {}, "enigma"); } @Test - public void noNullElementsWithMessageSupplier() { + void noNullElementsWithMessageSupplier() { Assert.noNullElements(new String[] { "1234" }, () -> "enigma"); } @Test - public void noNullElementsWithEmptyArrayAndMessageSupplier() { + void noNullElementsWithEmptyArrayAndMessageSupplier() { Assert.noNullElements(new String[] {}, () -> "enigma"); } @Test - public void noNullElementsWithNullArrayAndMessageSupplier() { + void noNullElementsWithNullArrayAndMessageSupplier() { Assert.noNullElements((Object[]) null, () -> "enigma"); } @Test - public void noNullElementsWithNullElementsAndMessageSupplier() { + void noNullElementsWithNullElementsAndMessageSupplier() { assertThatIllegalArgumentException().isThrownBy(() -> Assert.noNullElements(new String[] { "foo", null, "bar" }, () -> "enigma")) .withMessageContaining("enigma"); } @Test - public void noNullElementsWithNullElementsAndNullMessageSupplier() { + void noNullElementsWithNullElementsAndNullMessageSupplier() { assertThatIllegalArgumentException().isThrownBy(() -> Assert.noNullElements(new String[] { "foo", null, "bar" }, (Supplier) null)) .withMessage(null); } @Test - public void notEmptyCollection() { + void notEmptyCollection() { Assert.notEmpty(singletonList("foo"), "enigma"); } @Test - public void notEmptyCollectionWithEmptyCollection() { + void notEmptyCollectionWithEmptyCollection() { assertThatIllegalArgumentException().isThrownBy(() -> Assert.notEmpty(emptyList(), "enigma")) .withMessageContaining("enigma"); } @Test - public void notEmptyCollectionWithNullCollection() { + void notEmptyCollectionWithNullCollection() { assertThatIllegalArgumentException().isThrownBy(() -> Assert.notEmpty((Collection) null, "enigma")) .withMessageContaining("enigma"); } @Test - public void notEmptyCollectionWithMessageSupplier() { + void notEmptyCollectionWithMessageSupplier() { Assert.notEmpty(singletonList("foo"), () -> "enigma"); } @Test - public void notEmptyCollectionWithEmptyCollectionAndMessageSupplier() { + void notEmptyCollectionWithEmptyCollectionAndMessageSupplier() { assertThatIllegalArgumentException().isThrownBy(() -> Assert.notEmpty(emptyList(), () -> "enigma")) .withMessageContaining("enigma"); } @Test - public void notEmptyCollectionWithNullCollectionAndMessageSupplier() { + void notEmptyCollectionWithNullCollectionAndMessageSupplier() { assertThatIllegalArgumentException().isThrownBy(() -> Assert.notEmpty((Collection) null, () -> "enigma")) .withMessageContaining("enigma"); } @Test - public void notEmptyCollectionWithEmptyCollectionAndNullMessageSupplier() { + void notEmptyCollectionWithEmptyCollectionAndNullMessageSupplier() { assertThatIllegalArgumentException().isThrownBy(() -> Assert.notEmpty(emptyList(), (Supplier) null)) .withMessage(null); } @Test - public void notEmptyMap() { + void notEmptyMap() { Assert.notEmpty(singletonMap("foo", "bar"), "enigma"); } @Test - public void notEmptyMapWithNullMap() { + void notEmptyMapWithNullMap() { assertThatIllegalArgumentException().isThrownBy(() -> Assert.notEmpty((Map) null, "enigma")) .withMessageContaining("enigma"); } @Test - public void notEmptyMapWithEmptyMap() { + void notEmptyMapWithEmptyMap() { assertThatIllegalArgumentException().isThrownBy(() -> Assert.notEmpty(emptyMap(), "enigma")) .withMessageContaining("enigma"); } @Test - public void notEmptyMapWithMessageSupplier() { + void notEmptyMapWithMessageSupplier() { Assert.notEmpty(singletonMap("foo", "bar"), () -> "enigma"); } @Test - public void notEmptyMapWithEmptyMapAndMessageSupplier() { + void notEmptyMapWithEmptyMapAndMessageSupplier() { assertThatIllegalArgumentException().isThrownBy(() -> Assert.notEmpty(emptyMap(), () -> "enigma")) .withMessageContaining("enigma"); } @Test - public void notEmptyMapWithNullMapAndMessageSupplier() { + void notEmptyMapWithNullMapAndMessageSupplier() { assertThatIllegalArgumentException().isThrownBy(() -> Assert.notEmpty((Map) null, () -> "enigma")) .withMessageContaining("enigma"); } @Test - public void notEmptyMapWithEmptyMapAndNullMessageSupplier() { + void notEmptyMapWithEmptyMapAndNullMessageSupplier() { assertThatIllegalArgumentException().isThrownBy(() -> Assert.notEmpty(emptyMap(), (Supplier) null)) .withMessage(null); } @Test - public void isInstanceOf() { + void isInstanceOf() { Assert.isInstanceOf(String.class, "foo", "enigma"); } @Test - public void isInstanceOfWithNullType() { + void isInstanceOfWithNullType() { assertThatIllegalArgumentException().isThrownBy(() -> Assert.isInstanceOf(null, "foo", "enigma")) .withMessageContaining("Type to check against must not be null"); } @Test - public void isInstanceOfWithNullInstance() { + void isInstanceOfWithNullInstance() { assertThatIllegalArgumentException().isThrownBy(() -> Assert.isInstanceOf(String.class, null, "enigma")) .withMessageContaining("enigma: null"); } @Test - public void isInstanceOfWithTypeMismatchAndNullMessage() { + void isInstanceOfWithTypeMismatchAndNullMessage() { assertThatIllegalArgumentException().isThrownBy(() -> Assert.isInstanceOf(String.class, 42L, (String) null)) .withMessageContaining("Object of class [java.lang.Long] must be an instance of class java.lang.String"); } @Test - public void isInstanceOfWithTypeMismatchAndCustomMessage() { + void isInstanceOfWithTypeMismatchAndCustomMessage() { assertThatIllegalArgumentException().isThrownBy(() -> Assert.isInstanceOf(String.class, 42L, "Custom message")) .withMessageContaining("Custom message: java.lang.Long"); } @Test - public void isInstanceOfWithTypeMismatchAndCustomMessageWithSeparator() { + void isInstanceOfWithTypeMismatchAndCustomMessageWithSeparator() { assertThatIllegalArgumentException().isThrownBy(() -> Assert.isInstanceOf(String.class, 42L, "Custom message:")) .withMessageContaining("Custom message: Object of class [java.lang.Long] must be an instance of class java.lang.String"); } @Test - public void isInstanceOfWithTypeMismatchAndCustomMessageWithSpace() { + void isInstanceOfWithTypeMismatchAndCustomMessageWithSpace() { assertThatIllegalArgumentException().isThrownBy(() -> Assert.isInstanceOf(String.class, 42L, "Custom message for ")) .withMessageContaining("Custom message for java.lang.Long"); } @Test - public void isInstanceOfWithMessageSupplier() { + void isInstanceOfWithMessageSupplier() { Assert.isInstanceOf(String.class, "foo", () -> "enigma"); } @Test - public void isInstanceOfWithNullTypeAndMessageSupplier() { + void isInstanceOfWithNullTypeAndMessageSupplier() { assertThatIllegalArgumentException().isThrownBy(() -> Assert.isInstanceOf(null, "foo", () -> "enigma")) .withMessageContaining("Type to check against must not be null"); } @Test - public void isInstanceOfWithNullInstanceAndMessageSupplier() { + void isInstanceOfWithNullInstanceAndMessageSupplier() { assertThatIllegalArgumentException().isThrownBy(() -> Assert.isInstanceOf(String.class, null, () -> "enigma")) .withMessageContaining("enigma: null"); } @Test - public void isInstanceOfWithTypeMismatchAndNullMessageSupplier() { + void isInstanceOfWithTypeMismatchAndNullMessageSupplier() { assertThatIllegalArgumentException().isThrownBy(() -> Assert.isInstanceOf(String.class, 42L, (Supplier) null)) .withMessageContaining("Object of class [java.lang.Long] must be an instance of class java.lang.String"); } @Test - public void isInstanceOfWithTypeMismatchAndMessageSupplier() { + void isInstanceOfWithTypeMismatchAndMessageSupplier() { assertThatIllegalArgumentException().isThrownBy(() -> Assert.isInstanceOf(String.class, 42L, () -> "enigma")) .withMessageContaining("enigma: java.lang.Long"); } @Test - public void isAssignable() { + void isAssignable() { Assert.isAssignable(Number.class, Integer.class, "enigma"); } @Test - public void isAssignableWithNullSupertype() { + void isAssignableWithNullSupertype() { assertThatIllegalArgumentException().isThrownBy(() -> Assert.isAssignable(null, Integer.class, "enigma")) .withMessageContaining("Super type to check against must not be null"); } @Test - public void isAssignableWithNullSubtype() { + void isAssignableWithNullSubtype() { assertThatIllegalArgumentException().isThrownBy(() -> Assert.isAssignable(Integer.class, null, "enigma")) .withMessageContaining("enigma: null"); } @Test - public void isAssignableWithTypeMismatchAndNullMessage() { + void isAssignableWithTypeMismatchAndNullMessage() { assertThatIllegalArgumentException().isThrownBy(() -> Assert.isAssignable(String.class, Integer.class, (String) null)) .withMessageContaining("class java.lang.Integer is not assignable to class java.lang.String"); } @Test - public void isAssignableWithTypeMismatchAndCustomMessage() { + void isAssignableWithTypeMismatchAndCustomMessage() { assertThatIllegalArgumentException().isThrownBy(() -> Assert.isAssignable(String.class, Integer.class, "Custom message")) .withMessageContaining("Custom message: class java.lang.Integer"); } @Test - public void isAssignableWithTypeMismatchAndCustomMessageWithSeparator() { + void isAssignableWithTypeMismatchAndCustomMessageWithSeparator() { assertThatIllegalArgumentException().isThrownBy(() -> Assert.isAssignable(String.class, Integer.class, "Custom message:")) .withMessageContaining("Custom message: class java.lang.Integer is not assignable to class java.lang.String"); } @Test - public void isAssignableWithTypeMismatchAndCustomMessageWithSpace() { + void isAssignableWithTypeMismatchAndCustomMessageWithSpace() { assertThatIllegalArgumentException().isThrownBy(() -> Assert.isAssignable(String.class, Integer.class, "Custom message for ")) .withMessageContaining("Custom message for class java.lang.Integer"); } @Test - public void isAssignableWithMessageSupplier() { + void isAssignableWithMessageSupplier() { Assert.isAssignable(Number.class, Integer.class, () -> "enigma"); } @Test - public void isAssignableWithNullSupertypeAndMessageSupplier() { + void isAssignableWithNullSupertypeAndMessageSupplier() { assertThatIllegalArgumentException().isThrownBy(() -> Assert.isAssignable(null, Integer.class, () -> "enigma")) .withMessageContaining("Super type to check against must not be null"); } @Test - public void isAssignableWithNullSubtypeAndMessageSupplier() { + void isAssignableWithNullSubtypeAndMessageSupplier() { assertThatIllegalArgumentException().isThrownBy(() -> Assert.isAssignable(Integer.class, null, () -> "enigma")) .withMessageContaining("enigma: null"); } @Test - public void isAssignableWithTypeMismatchAndNullMessageSupplier() { + void isAssignableWithTypeMismatchAndNullMessageSupplier() { assertThatIllegalArgumentException().isThrownBy(() -> Assert.isAssignable(String.class, Integer.class, (Supplier) null)) .withMessageContaining("class java.lang.Integer is not assignable to class java.lang.String"); } @Test - public void isAssignableWithTypeMismatchAndMessageSupplier() { + void isAssignableWithTypeMismatchAndMessageSupplier() { assertThatIllegalArgumentException().isThrownBy(() -> Assert.isAssignable(String.class, Integer.class, () -> "enigma")) .withMessageContaining("enigma: class java.lang.Integer"); } @Test - public void state() { + void state() { Assert.state(true, "enigma"); } @Test - public void stateWithFalseExpression() { + void stateWithFalseExpression() { assertThatIllegalStateException().isThrownBy(() -> Assert.state(false, "enigma")) .withMessageContaining("enigma"); diff --git a/spring-core/src/test/java/org/springframework/util/AutoPopulatingListTests.java b/spring-core/src/test/java/org/springframework/util/AutoPopulatingListTests.java index 3e5868d665..4401096721 100644 --- a/spring-core/src/test/java/org/springframework/util/AutoPopulatingListTests.java +++ b/spring-core/src/test/java/org/springframework/util/AutoPopulatingListTests.java @@ -28,25 +28,25 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Rob Harrop * @author Juergen Hoeller */ -public class AutoPopulatingListTests { +class AutoPopulatingListTests { @Test - public void withClass() throws Exception { + void withClass() throws Exception { doTestWithClass(new AutoPopulatingList<>(TestObject.class)); } @Test - public void withClassAndUserSuppliedBackingList() throws Exception { + void withClassAndUserSuppliedBackingList() throws Exception { doTestWithClass(new AutoPopulatingList(new LinkedList<>(), TestObject.class)); } @Test - public void withElementFactory() throws Exception { + void withElementFactory() throws Exception { doTestWithElementFactory(new AutoPopulatingList<>(new MockElementFactory())); } @Test - public void withElementFactoryAndUserSuppliedBackingList() throws Exception { + void withElementFactoryAndUserSuppliedBackingList() throws Exception { doTestWithElementFactory(new AutoPopulatingList(new LinkedList<>(), new MockElementFactory())); } @@ -88,7 +88,7 @@ public class AutoPopulatingListTests { } @Test - public void serialization() throws Exception { + void serialization() throws Exception { AutoPopulatingList list = new AutoPopulatingList(TestObject.class); assertThat(SerializationTestUtils.serializeAndDeserialize(list)).isEqualTo(list); } diff --git a/spring-core/src/test/java/org/springframework/util/Base64UtilsTests.java b/spring-core/src/test/java/org/springframework/util/Base64UtilsTests.java index 09ff68e1ef..c7ec8c80e6 100644 --- a/spring-core/src/test/java/org/springframework/util/Base64UtilsTests.java +++ b/spring-core/src/test/java/org/springframework/util/Base64UtilsTests.java @@ -27,10 +27,10 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Juergen Hoeller * @since 4.2 */ -public class Base64UtilsTests { +class Base64UtilsTests { @Test - public void encode() throws UnsupportedEncodingException { + void encode() throws UnsupportedEncodingException { byte[] bytes = new byte[] {-0x4f, 0xa, -0x73, -0x4f, 0x64, -0x20, 0x75, 0x41, 0x5, -0x49, -0x57, -0x65, -0x19, 0x2e, 0x3f, -0x1b}; assertThat(Base64Utils.decode(Base64Utils.encode(bytes))).isEqualTo(bytes); @@ -53,7 +53,7 @@ public class Base64UtilsTests { } @Test - public void encodeToStringWithJdk8VsJaxb() throws UnsupportedEncodingException { + void encodeToStringWithJdk8VsJaxb() throws UnsupportedEncodingException { byte[] bytes = new byte[] {-0x4f, 0xa, -0x73, -0x4f, 0x64, -0x20, 0x75, 0x41, 0x5, -0x49, -0x57, -0x65, -0x19, 0x2e, 0x3f, -0x1b}; assertThat(DatatypeConverter.printBase64Binary(bytes)).isEqualTo(Base64Utils.encodeToString(bytes)); @@ -77,7 +77,7 @@ public class Base64UtilsTests { } @Test - public void encodeDecodeUrlSafe() { + void encodeDecodeUrlSafe() { byte[] bytes = new byte[] { (byte) 0xfb, (byte) 0xf0 }; assertThat(Base64Utils.encodeUrlSafe(bytes)).isEqualTo("-_A=".getBytes()); assertThat(Base64Utils.decodeUrlSafe(Base64Utils.encodeUrlSafe(bytes))).isEqualTo(bytes); diff --git a/spring-core/src/test/java/org/springframework/util/ClassUtilsTests.java b/spring-core/src/test/java/org/springframework/util/ClassUtilsTests.java index 2208e3aca7..2b58da23b6 100644 --- a/spring-core/src/test/java/org/springframework/util/ClassUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/util/ClassUtilsTests.java @@ -45,13 +45,13 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Rob Harrop * @author Rick Evans */ -public class ClassUtilsTests { +class ClassUtilsTests { private ClassLoader classLoader = getClass().getClassLoader(); @BeforeEach - public void clearStatics() { + void clearStatics() { InnerClass.noArgCalled = false; InnerClass.argCalled = false; InnerClass.overloadedCalled = false; @@ -59,13 +59,13 @@ public class ClassUtilsTests { @Test - public void testIsPresent() { + void isPresent() { assertThat(ClassUtils.isPresent("java.lang.String", classLoader)).isTrue(); assertThat(ClassUtils.isPresent("java.lang.MySpecialString", classLoader)).isFalse(); } @Test - public void testForName() throws ClassNotFoundException { + void forName() throws ClassNotFoundException { assertThat(ClassUtils.forName("java.lang.String", classLoader)).isEqualTo(String.class); assertThat(ClassUtils.forName("java.lang.String[]", classLoader)).isEqualTo(String[].class); assertThat(ClassUtils.forName(String[].class.getName(), classLoader)).isEqualTo(String[].class); @@ -80,7 +80,7 @@ public class ClassUtilsTests { } @Test - public void testForNameWithPrimitiveClasses() throws ClassNotFoundException { + void forNameWithPrimitiveClasses() throws ClassNotFoundException { assertThat(ClassUtils.forName("boolean", classLoader)).isEqualTo(boolean.class); assertThat(ClassUtils.forName("byte", classLoader)).isEqualTo(byte.class); assertThat(ClassUtils.forName("char", classLoader)).isEqualTo(char.class); @@ -93,7 +93,7 @@ public class ClassUtilsTests { } @Test - public void testForNameWithPrimitiveArrays() throws ClassNotFoundException { + void forNameWithPrimitiveArrays() throws ClassNotFoundException { assertThat(ClassUtils.forName("boolean[]", classLoader)).isEqualTo(boolean[].class); assertThat(ClassUtils.forName("byte[]", classLoader)).isEqualTo(byte[].class); assertThat(ClassUtils.forName("char[]", classLoader)).isEqualTo(char[].class); @@ -105,7 +105,7 @@ public class ClassUtilsTests { } @Test - public void testForNameWithPrimitiveArraysInternalName() throws ClassNotFoundException { + void forNameWithPrimitiveArraysInternalName() throws ClassNotFoundException { assertThat(ClassUtils.forName(boolean[].class.getName(), classLoader)).isEqualTo(boolean[].class); assertThat(ClassUtils.forName(byte[].class.getName(), classLoader)).isEqualTo(byte[].class); assertThat(ClassUtils.forName(char[].class.getName(), classLoader)).isEqualTo(char[].class); @@ -117,7 +117,7 @@ public class ClassUtilsTests { } @Test - public void testIsCacheSafe() { + void isCacheSafe() { ClassLoader childLoader1 = new ClassLoader(classLoader) {}; ClassLoader childLoader2 = new ClassLoader(classLoader) {}; ClassLoader childLoader3 = new ClassLoader(classLoader) { @@ -147,91 +147,91 @@ public class ClassUtilsTests { } @Test - public void testGetShortName() { + void getShortName() { String className = ClassUtils.getShortName(getClass()); assertThat(className).as("Class name did not match").isEqualTo("ClassUtilsTests"); } @Test - public void testGetShortNameForObjectArrayClass() { + void getShortNameForObjectArrayClass() { String className = ClassUtils.getShortName(Object[].class); assertThat(className).as("Class name did not match").isEqualTo("Object[]"); } @Test - public void testGetShortNameForMultiDimensionalObjectArrayClass() { + void getShortNameForMultiDimensionalObjectArrayClass() { String className = ClassUtils.getShortName(Object[][].class); assertThat(className).as("Class name did not match").isEqualTo("Object[][]"); } @Test - public void testGetShortNameForPrimitiveArrayClass() { + void getShortNameForPrimitiveArrayClass() { String className = ClassUtils.getShortName(byte[].class); assertThat(className).as("Class name did not match").isEqualTo("byte[]"); } @Test - public void testGetShortNameForMultiDimensionalPrimitiveArrayClass() { + void getShortNameForMultiDimensionalPrimitiveArrayClass() { String className = ClassUtils.getShortName(byte[][][].class); assertThat(className).as("Class name did not match").isEqualTo("byte[][][]"); } @Test - public void testGetShortNameForInnerClass() { + void getShortNameForInnerClass() { String className = ClassUtils.getShortName(InnerClass.class); assertThat(className).as("Class name did not match").isEqualTo("ClassUtilsTests.InnerClass"); } @Test - public void testGetShortNameAsProperty() { + void getShortNameAsProperty() { String shortName = ClassUtils.getShortNameAsProperty(this.getClass()); assertThat(shortName).as("Class name did not match").isEqualTo("classUtilsTests"); } @Test - public void testGetClassFileName() { + void getClassFileName() { assertThat(ClassUtils.getClassFileName(String.class)).isEqualTo("String.class"); assertThat(ClassUtils.getClassFileName(getClass())).isEqualTo("ClassUtilsTests.class"); } @Test - public void testGetPackageName() { + void getPackageName() { assertThat(ClassUtils.getPackageName(String.class)).isEqualTo("java.lang"); assertThat(ClassUtils.getPackageName(getClass())).isEqualTo(getClass().getPackage().getName()); } @Test - public void testGetQualifiedName() { + void getQualifiedName() { String className = ClassUtils.getQualifiedName(getClass()); assertThat(className).as("Class name did not match").isEqualTo("org.springframework.util.ClassUtilsTests"); } @Test - public void testGetQualifiedNameForObjectArrayClass() { + void getQualifiedNameForObjectArrayClass() { String className = ClassUtils.getQualifiedName(Object[].class); assertThat(className).as("Class name did not match").isEqualTo("java.lang.Object[]"); } @Test - public void testGetQualifiedNameForMultiDimensionalObjectArrayClass() { + void getQualifiedNameForMultiDimensionalObjectArrayClass() { String className = ClassUtils.getQualifiedName(Object[][].class); assertThat(className).as("Class name did not match").isEqualTo("java.lang.Object[][]"); } @Test - public void testGetQualifiedNameForPrimitiveArrayClass() { + void getQualifiedNameForPrimitiveArrayClass() { String className = ClassUtils.getQualifiedName(byte[].class); assertThat(className).as("Class name did not match").isEqualTo("byte[]"); } @Test - public void testGetQualifiedNameForMultiDimensionalPrimitiveArrayClass() { + void getQualifiedNameForMultiDimensionalPrimitiveArrayClass() { String className = ClassUtils.getQualifiedName(byte[][].class); assertThat(className).as("Class name did not match").isEqualTo("byte[][]"); } @Test - public void testHasMethod() { + void hasMethod() { assertThat(ClassUtils.hasMethod(Collection.class, "size")).isTrue(); assertThat(ClassUtils.hasMethod(Collection.class, "remove", Object.class)).isTrue(); assertThat(ClassUtils.hasMethod(Collection.class, "remove")).isFalse(); @@ -239,7 +239,7 @@ public class ClassUtilsTests { } @Test - public void testGetMethodIfAvailable() { + void getMethodIfAvailable() { Method method = ClassUtils.getMethodIfAvailable(Collection.class, "size"); assertThat(method).isNotNull(); assertThat(method.getName()).isEqualTo("size"); @@ -253,13 +253,13 @@ public class ClassUtilsTests { } @Test - public void testGetMethodCountForName() { + void getMethodCountForName() { assertThat(ClassUtils.getMethodCountForName(OverloadedMethodsClass.class, "print")).as("Verifying number of overloaded 'print' methods for OverloadedMethodsClass.").isEqualTo(2); assertThat(ClassUtils.getMethodCountForName(SubOverloadedMethodsClass.class, "print")).as("Verifying number of overloaded 'print' methods for SubOverloadedMethodsClass.").isEqualTo(4); } @Test - public void testCountOverloadedMethods() { + void countOverloadedMethods() { assertThat(ClassUtils.hasAtLeastOneMethodWithName(TestObject.class, "foobar")).isFalse(); // no args assertThat(ClassUtils.hasAtLeastOneMethodWithName(TestObject.class, "hashCode")).isTrue(); @@ -268,28 +268,28 @@ public class ClassUtilsTests { } @Test - public void testNoArgsStaticMethod() throws IllegalAccessException, InvocationTargetException { + void noArgsStaticMethod() throws IllegalAccessException, InvocationTargetException { Method method = ClassUtils.getStaticMethod(InnerClass.class, "staticMethod"); method.invoke(null, (Object[]) null); assertThat(InnerClass.noArgCalled).as("no argument method was not invoked.").isTrue(); } @Test - public void testArgsStaticMethod() throws IllegalAccessException, InvocationTargetException { + void argsStaticMethod() throws IllegalAccessException, InvocationTargetException { Method method = ClassUtils.getStaticMethod(InnerClass.class, "argStaticMethod", String.class); method.invoke(null, "test"); assertThat(InnerClass.argCalled).as("argument method was not invoked.").isTrue(); } @Test - public void testOverloadedStaticMethod() throws IllegalAccessException, InvocationTargetException { + void overloadedStaticMethod() throws IllegalAccessException, InvocationTargetException { Method method = ClassUtils.getStaticMethod(InnerClass.class, "staticMethod", String.class); method.invoke(null, "test"); assertThat(InnerClass.overloadedCalled).as("argument method was not invoked.").isTrue(); } @Test - public void testIsAssignable() { + void isAssignable() { assertThat(ClassUtils.isAssignable(Object.class, Object.class)).isTrue(); assertThat(ClassUtils.isAssignable(String.class, String.class)).isTrue(); assertThat(ClassUtils.isAssignable(Object.class, String.class)).isTrue(); @@ -305,13 +305,13 @@ public class ClassUtilsTests { } @Test - public void testClassPackageAsResourcePath() { + void classPackageAsResourcePath() { String result = ClassUtils.classPackageAsResourcePath(Proxy.class); assertThat(result).isEqualTo("java/lang/reflect"); } @Test - public void testAddResourcePathToPackagePath() { + void addResourcePathToPackagePath() { String result = "java/lang/reflect/xyzabc.xml"; assertThat(ClassUtils.addResourcePathToPackagePath(Proxy.class, "xyzabc.xml")).isEqualTo(result); assertThat(ClassUtils.addResourcePathToPackagePath(Proxy.class, "/xyzabc.xml")).isEqualTo(result); @@ -320,7 +320,7 @@ public class ClassUtilsTests { } @Test - public void testGetAllInterfaces() { + void getAllInterfaces() { DerivedTestObject testBean = new DerivedTestObject(); List> ifcs = Arrays.asList(ClassUtils.getAllInterfaces(testBean)); assertThat(ifcs.size()).as("Correct number of interfaces").isEqualTo(4); @@ -330,7 +330,7 @@ public class ClassUtilsTests { } @Test - public void testClassNamesToString() { + void classNamesToString() { List> ifcs = new LinkedList<>(); ifcs.add(Serializable.class); ifcs.add(Runnable.class); @@ -351,7 +351,7 @@ public class ClassUtilsTests { } @Test - public void testDetermineCommonAncestor() { + void determineCommonAncestor() { assertThat(ClassUtils.determineCommonAncestor(Integer.class, Number.class)).isEqualTo(Number.class); assertThat(ClassUtils.determineCommonAncestor(Number.class, Integer.class)).isEqualTo(Number.class); assertThat(ClassUtils.determineCommonAncestor(Number.class, null)).isEqualTo(Number.class); diff --git a/spring-core/src/test/java/org/springframework/util/CollectionUtilsTests.java b/spring-core/src/test/java/org/springframework/util/CollectionUtilsTests.java index 4f947dc38e..fa781881b0 100644 --- a/spring-core/src/test/java/org/springframework/util/CollectionUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/util/CollectionUtilsTests.java @@ -37,10 +37,10 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Juergen Hoeller * @author Rick Evans */ -public class CollectionUtilsTests { +class CollectionUtilsTests { @Test - public void testIsEmpty() { + void isEmpty() { assertThat(CollectionUtils.isEmpty((Set) null)).isTrue(); assertThat(CollectionUtils.isEmpty((Map) null)).isTrue(); assertThat(CollectionUtils.isEmpty(new HashMap())).isTrue(); @@ -56,7 +56,7 @@ public class CollectionUtilsTests { } @Test - public void testMergeArrayIntoCollection() { + void mergeArrayIntoCollection() { Object[] arr = new Object[] {"value1", "value2"}; List> list = new LinkedList<>(); list.add("value3"); @@ -68,7 +68,7 @@ public class CollectionUtilsTests { } @Test - public void testMergePrimitiveArrayIntoCollection() { + void mergePrimitiveArrayIntoCollection() { int[] arr = new int[] {1, 2}; List> list = new LinkedList<>(); list.add(Integer.valueOf(3)); @@ -80,7 +80,7 @@ public class CollectionUtilsTests { } @Test - public void testMergePropertiesIntoMap() { + void mergePropertiesIntoMap() { Properties defaults = new Properties(); defaults.setProperty("prop1", "value1"); Properties props = new Properties(defaults); @@ -98,7 +98,7 @@ public class CollectionUtilsTests { } @Test - public void testContains() { + void contains() { assertThat(CollectionUtils.contains((Iterator) null, "myElement")).isFalse(); assertThat(CollectionUtils.contains((Enumeration) null, "myElement")).isFalse(); assertThat(CollectionUtils.contains(new LinkedList().iterator(), "myElement")).isFalse(); @@ -114,7 +114,7 @@ public class CollectionUtilsTests { } @Test - public void testContainsAny() throws Exception { + void containsAny() throws Exception { List source = new ArrayList<>(); source.add("abc"); source.add("def"); @@ -133,19 +133,19 @@ public class CollectionUtilsTests { } @Test - public void testContainsInstanceWithNullCollection() throws Exception { + void containsInstanceWithNullCollection() throws Exception { assertThat(CollectionUtils.containsInstance(null, this)).as("Must return false if supplied Collection argument is null").isFalse(); } @Test - public void testContainsInstanceWithInstancesThatAreEqualButDistinct() throws Exception { + void containsInstanceWithInstancesThatAreEqualButDistinct() throws Exception { List list = new ArrayList<>(); list.add(new Instance("fiona")); assertThat(CollectionUtils.containsInstance(list, new Instance("fiona"))).as("Must return false if instance is not in the supplied Collection argument").isFalse(); } @Test - public void testContainsInstanceWithSameInstance() throws Exception { + void containsInstanceWithSameInstance() throws Exception { List list = new ArrayList<>(); list.add(new Instance("apple")); Instance instance = new Instance("fiona"); @@ -154,7 +154,7 @@ public class CollectionUtilsTests { } @Test - public void testContainsInstanceWithNullInstance() throws Exception { + void containsInstanceWithNullInstance() throws Exception { List list = new ArrayList<>(); list.add(new Instance("apple")); list.add(new Instance("fiona")); @@ -162,7 +162,7 @@ public class CollectionUtilsTests { } @Test - public void testFindFirstMatch() throws Exception { + void findFirstMatch() throws Exception { List source = new ArrayList<>(); source.add("abc"); source.add("def"); @@ -177,7 +177,7 @@ public class CollectionUtilsTests { } @Test - public void testHasUniqueObject() { + void hasUniqueObject() { List list = new LinkedList<>(); list.add("myElement"); list.add("myOtherElement"); diff --git a/spring-core/src/test/java/org/springframework/util/CompositeIteratorTests.java b/spring-core/src/test/java/org/springframework/util/CompositeIteratorTests.java index a56d4e3247..737e062c5e 100644 --- a/spring-core/src/test/java/org/springframework/util/CompositeIteratorTests.java +++ b/spring-core/src/test/java/org/springframework/util/CompositeIteratorTests.java @@ -28,17 +28,16 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.assertj.core.api.Assertions.assertThatIllegalStateException; - /** * Test case for {@link CompositeIterator}. * * @author Erwin Vervaet * @author Juergen Hoeller */ -public class CompositeIteratorTests { +class CompositeIteratorTests { @Test - public void testNoIterators() { + void noIterators() { CompositeIterator it = new CompositeIterator<>(); assertThat(it.hasNext()).isFalse(); assertThatExceptionOfType(NoSuchElementException.class).isThrownBy( @@ -46,7 +45,7 @@ public class CompositeIteratorTests { } @Test - public void testSingleIterator() { + void singleIterator() { CompositeIterator it = new CompositeIterator<>(); it.add(Arrays.asList("0", "1").iterator()); for (int i = 0; i < 2; i++) { @@ -59,7 +58,7 @@ public class CompositeIteratorTests { } @Test - public void testMultipleIterators() { + void multipleIterators() { CompositeIterator it = new CompositeIterator<>(); it.add(Arrays.asList("0", "1").iterator()); it.add(Arrays.asList("2").iterator()); @@ -75,7 +74,7 @@ public class CompositeIteratorTests { } @Test - public void testInUse() { + void inUse() { List list = Arrays.asList("0", "1"); CompositeIterator it = new CompositeIterator<>(); it.add(list.iterator()); @@ -90,7 +89,7 @@ public class CompositeIteratorTests { } @Test - public void testDuplicateIterators() { + void duplicateIterators() { List list = Arrays.asList("0", "1"); Iterator iterator = list.iterator(); CompositeIterator it = new CompositeIterator<>(); diff --git a/spring-core/src/test/java/org/springframework/util/ConcurrentReferenceHashMapTests.java b/spring-core/src/test/java/org/springframework/util/ConcurrentReferenceHashMapTests.java index d36447bcbd..230ac310e9 100644 --- a/spring-core/src/test/java/org/springframework/util/ConcurrentReferenceHashMapTests.java +++ b/spring-core/src/test/java/org/springframework/util/ConcurrentReferenceHashMapTests.java @@ -47,7 +47,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException * * @author Phillip Webb */ -public class ConcurrentReferenceHashMapTests { +class ConcurrentReferenceHashMapTests { private static final Comparator NULL_SAFE_STRING_SORT = new NullSafeComparator( new ComparableComparator(), true); @@ -56,7 +56,7 @@ public class ConcurrentReferenceHashMapTests { @Test - public void shouldCreateWithDefaults() { + void shouldCreateWithDefaults() { ConcurrentReferenceHashMap map = new ConcurrentReferenceHashMap<>(); assertThat(map.getSegmentsSize()).isEqualTo(16); assertThat(map.getSegment(0).getSize()).isEqualTo(1); @@ -64,7 +64,7 @@ public class ConcurrentReferenceHashMapTests { } @Test - public void shouldCreateWithInitialCapacity() { + void shouldCreateWithInitialCapacity() { ConcurrentReferenceHashMap map = new ConcurrentReferenceHashMap<>(32); assertThat(map.getSegmentsSize()).isEqualTo(16); assertThat(map.getSegment(0).getSize()).isEqualTo(2); @@ -72,7 +72,7 @@ public class ConcurrentReferenceHashMapTests { } @Test - public void shouldCreateWithInitialCapacityAndLoadFactor() { + void shouldCreateWithInitialCapacityAndLoadFactor() { ConcurrentReferenceHashMap map = new ConcurrentReferenceHashMap<>(32, 0.5f); assertThat(map.getSegmentsSize()).isEqualTo(16); assertThat(map.getSegment(0).getSize()).isEqualTo(2); @@ -80,7 +80,7 @@ public class ConcurrentReferenceHashMapTests { } @Test - public void shouldCreateWithInitialCapacityAndConcurrentLevel() { + void shouldCreateWithInitialCapacityAndConcurrentLevel() { ConcurrentReferenceHashMap map = new ConcurrentReferenceHashMap<>(16, 2); assertThat(map.getSegmentsSize()).isEqualTo(2); assertThat(map.getSegment(0).getSize()).isEqualTo(8); @@ -88,7 +88,7 @@ public class ConcurrentReferenceHashMapTests { } @Test - public void shouldCreateFullyCustom() { + void shouldCreateFullyCustom() { ConcurrentReferenceHashMap map = new ConcurrentReferenceHashMap<>(5, 0.5f, 3); // concurrencyLevel of 3 ends up as 4 (nearest power of 2) assertThat(map.getSegmentsSize()).isEqualTo(4); @@ -98,7 +98,7 @@ public class ConcurrentReferenceHashMapTests { } @Test - public void shouldNeedNonNegativeInitialCapacity() { + void shouldNeedNonNegativeInitialCapacity() { new ConcurrentReferenceHashMap(0, 1); assertThatIllegalArgumentException().isThrownBy(() -> new TestWeakConcurrentCache(-1, 1)) @@ -106,7 +106,7 @@ public class ConcurrentReferenceHashMapTests { } @Test - public void shouldNeedPositiveLoadFactor() { + void shouldNeedPositiveLoadFactor() { new ConcurrentReferenceHashMap(0, 0.1f, 1); assertThatIllegalArgumentException().isThrownBy(() -> new TestWeakConcurrentCache(0, 0.0f, 1)) @@ -114,7 +114,7 @@ public class ConcurrentReferenceHashMapTests { } @Test - public void shouldNeedPositiveConcurrencyLevel() { + void shouldNeedPositiveConcurrencyLevel() { new ConcurrentReferenceHashMap(1, 1); assertThatIllegalArgumentException().isThrownBy(() -> new TestWeakConcurrentCache(1, 0)) @@ -122,7 +122,7 @@ public class ConcurrentReferenceHashMapTests { } @Test - public void shouldPutAndGet() { + void shouldPutAndGet() { // NOTE we are using mock references so we don't need to worry about GC assertThat(this.map).hasSize(0); this.map.put(123, "123"); @@ -135,14 +135,14 @@ public class ConcurrentReferenceHashMapTests { } @Test - public void shouldReplaceOnDoublePut() { + void shouldReplaceOnDoublePut() { this.map.put(123, "321"); this.map.put(123, "123"); assertThat(this.map.get(123)).isEqualTo("123"); } @Test - public void shouldPutNullKey() { + void shouldPutNullKey() { assertThat(this.map.get(null)).isNull(); assertThat(this.map.getOrDefault(null, "456")).isEqualTo("456"); this.map.put(null, "123"); @@ -151,7 +151,7 @@ public class ConcurrentReferenceHashMapTests { } @Test - public void shouldPutNullValue() { + void shouldPutNullValue() { assertThat(this.map.get(123)).isNull(); assertThat(this.map.getOrDefault(123, "456")).isEqualTo("456"); this.map.put(123, "321"); @@ -163,12 +163,12 @@ public class ConcurrentReferenceHashMapTests { } @Test - public void shouldGetWithNoItems() { + void shouldGetWithNoItems() { assertThat(this.map.get(123)).isNull(); } @Test - public void shouldApplySupplementalHash() { + void shouldApplySupplementalHash() { Integer key = 123; this.map.put(key, "123"); assertThat(this.map.getSupplementalHash()).isNotEqualTo(key.hashCode()); @@ -176,7 +176,7 @@ public class ConcurrentReferenceHashMapTests { } @Test - public void shouldGetFollowingNexts() { + void shouldGetFollowingNexts() { // Use loadFactor to disable resize this.map = new TestWeakConcurrentCache<>(1, 10.0f, 1); this.map.put(1, "1"); @@ -190,7 +190,7 @@ public class ConcurrentReferenceHashMapTests { } @Test - public void shouldResize() { + void shouldResize() { this.map = new TestWeakConcurrentCache<>(1, 0.75f, 1); this.map.put(1, "1"); assertThat(this.map.getSegment(0).getSize()).isEqualTo(1); @@ -220,7 +220,7 @@ public class ConcurrentReferenceHashMapTests { } @Test - public void shouldPurgeOnGet() { + void shouldPurgeOnGet() { this.map = new TestWeakConcurrentCache<>(1, 0.75f, 1); for (int i = 1; i <= 5; i++) { this.map.put(i, String.valueOf(i)); @@ -235,7 +235,7 @@ public class ConcurrentReferenceHashMapTests { } @Test - public void shouldPurgeOnPut() { + void shouldPurgeOnPut() { this.map = new TestWeakConcurrentCache<>(1, 0.75f, 1); for (int i = 1; i <= 5; i++) { this.map.put(i, String.valueOf(i)); @@ -251,28 +251,28 @@ public class ConcurrentReferenceHashMapTests { } @Test - public void shouldPutIfAbsent() { + void shouldPutIfAbsent() { assertThat(this.map.putIfAbsent(123, "123")).isNull(); assertThat(this.map.putIfAbsent(123, "123b")).isEqualTo("123"); assertThat(this.map.get(123)).isEqualTo("123"); } @Test - public void shouldPutIfAbsentWithNullValue() { + void shouldPutIfAbsentWithNullValue() { assertThat(this.map.putIfAbsent(123, null)).isNull(); assertThat(this.map.putIfAbsent(123, "123")).isNull(); assertThat(this.map.get(123)).isNull(); } @Test - public void shouldPutIfAbsentWithNullKey() { + void shouldPutIfAbsentWithNullKey() { assertThat(this.map.putIfAbsent(null, "123")).isNull(); assertThat(this.map.putIfAbsent(null, "123b")).isEqualTo("123"); assertThat(this.map.get(null)).isEqualTo("123"); } @Test - public void shouldRemoveKeyAndValue() { + void shouldRemoveKeyAndValue() { this.map.put(123, "123"); assertThat(this.map.remove(123, "456")).isFalse(); assertThat(this.map.get(123)).isEqualTo("123"); @@ -282,7 +282,7 @@ public class ConcurrentReferenceHashMapTests { } @Test - public void shouldRemoveKeyAndValueWithExistingNull() { + void shouldRemoveKeyAndValueWithExistingNull() { this.map.put(123, null); assertThat(this.map.remove(123, "456")).isFalse(); assertThat(this.map.get(123)).isNull(); @@ -292,7 +292,7 @@ public class ConcurrentReferenceHashMapTests { } @Test - public void shouldReplaceOldValueWithNewValue() { + void shouldReplaceOldValueWithNewValue() { this.map.put(123, "123"); assertThat(this.map.replace(123, "456", "789")).isFalse(); assertThat(this.map.get(123)).isEqualTo("123"); @@ -301,7 +301,7 @@ public class ConcurrentReferenceHashMapTests { } @Test - public void shouldReplaceOldNullValueWithNewValue() { + void shouldReplaceOldNullValueWithNewValue() { this.map.put(123, null); assertThat(this.map.replace(123, "456", "789")).isFalse(); assertThat(this.map.get(123)).isNull(); @@ -310,21 +310,21 @@ public class ConcurrentReferenceHashMapTests { } @Test - public void shouldReplaceValue() { + void shouldReplaceValue() { this.map.put(123, "123"); assertThat(this.map.replace(123, "456")).isEqualTo("123"); assertThat(this.map.get(123)).isEqualTo("456"); } @Test - public void shouldReplaceNullValue() { + void shouldReplaceNullValue() { this.map.put(123, null); assertThat(this.map.replace(123, "456")).isNull(); assertThat(this.map.get(123)).isEqualTo("456"); } @Test - public void shouldGetSize() { + void shouldGetSize() { assertThat(this.map).hasSize(0); this.map.put(123, "123"); this.map.put(123, null); @@ -333,7 +333,7 @@ public class ConcurrentReferenceHashMapTests { } @Test - public void shouldSupportIsEmpty() { + void shouldSupportIsEmpty() { assertThat(this.map.isEmpty()).isTrue(); this.map.put(123, "123"); this.map.put(123, null); @@ -342,7 +342,7 @@ public class ConcurrentReferenceHashMapTests { } @Test - public void shouldContainKey() { + void shouldContainKey() { assertThat(this.map.containsKey(123)).isFalse(); assertThat(this.map.containsKey(456)).isFalse(); this.map.put(123, "123"); @@ -352,7 +352,7 @@ public class ConcurrentReferenceHashMapTests { } @Test - public void shouldContainValue() { + void shouldContainValue() { assertThat(this.map.containsValue("123")).isFalse(); assertThat(this.map.containsValue(null)).isFalse(); this.map.put(123, "123"); @@ -362,7 +362,7 @@ public class ConcurrentReferenceHashMapTests { } @Test - public void shouldRemoveWhenKeyIsInMap() { + void shouldRemoveWhenKeyIsInMap() { this.map.put(123, null); this.map.put(456, "456"); this.map.put(null, "789"); @@ -373,14 +373,14 @@ public class ConcurrentReferenceHashMapTests { } @Test - public void shouldRemoveWhenKeyIsNotInMap() { + void shouldRemoveWhenKeyIsNotInMap() { assertThat(this.map.remove(123)).isNull(); assertThat(this.map.remove(null)).isNull(); assertThat(this.map.isEmpty()).isTrue(); } @Test - public void shouldPutAll() { + void shouldPutAll() { Map m = new HashMap<>(); m.put(123, "123"); m.put(456, null); @@ -393,7 +393,7 @@ public class ConcurrentReferenceHashMapTests { } @Test - public void shouldClear() { + void shouldClear() { this.map.put(123, "123"); this.map.put(456, null); this.map.put(null, "789"); @@ -405,7 +405,7 @@ public class ConcurrentReferenceHashMapTests { } @Test - public void shouldGetKeySet() { + void shouldGetKeySet() { this.map.put(123, "123"); this.map.put(456, null); this.map.put(null, "789"); @@ -417,7 +417,7 @@ public class ConcurrentReferenceHashMapTests { } @Test - public void shouldGetValues() { + void shouldGetValues() { this.map.put(123, "123"); this.map.put(456, null); this.map.put(null, "789"); @@ -432,7 +432,7 @@ public class ConcurrentReferenceHashMapTests { } @Test - public void shouldGetEntrySet() { + void shouldGetEntrySet() { this.map.put(123, "123"); this.map.put(456, null); this.map.put(null, "789"); @@ -444,7 +444,7 @@ public class ConcurrentReferenceHashMapTests { } @Test - public void shouldGetEntrySetFollowingNext() { + void shouldGetEntrySetFollowingNext() { // Use loadFactor to disable resize this.map = new TestWeakConcurrentCache<>(1, 10.0f, 1); this.map.put(1, "1"); @@ -458,7 +458,7 @@ public class ConcurrentReferenceHashMapTests { } @Test - public void shouldRemoveViaEntrySet() { + void shouldRemoveViaEntrySet() { this.map.put(1, "1"); this.map.put(2, "2"); this.map.put(3, "3"); @@ -473,7 +473,7 @@ public class ConcurrentReferenceHashMapTests { } @Test - public void shouldSetViaEntrySet() { + void shouldSetViaEntrySet() { this.map.put(1, "1"); this.map.put(2, "2"); this.map.put(3, "3"); @@ -488,7 +488,7 @@ public class ConcurrentReferenceHashMapTests { @Test @Disabled("Intended for use during development only") - public void shouldBeFasterThanSynchronizedMap() throws InterruptedException { + void shouldBeFasterThanSynchronizedMap() throws InterruptedException { Map> synchronizedMap = Collections.synchronizedMap(new WeakHashMap>()); StopWatch mapTime = timeMultiThreaded("SynchronizedMap", synchronizedMap, v -> new WeakReference<>(String.valueOf(v))); System.out.println(mapTime.prettyPrint()); @@ -502,7 +502,7 @@ public class ConcurrentReferenceHashMapTests { } @Test - public void shouldSupportNullReference() { + void shouldSupportNullReference() { // GC could happen during restructure so we must be able to create a reference for a null entry map.createReferenceManager().createReference(null, 1234, null); } diff --git a/spring-core/src/test/java/org/springframework/util/DigestUtilsTests.java b/spring-core/src/test/java/org/springframework/util/DigestUtilsTests.java index 918e6a5cb8..2ba9c67240 100644 --- a/spring-core/src/test/java/org/springframework/util/DigestUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/util/DigestUtilsTests.java @@ -29,19 +29,19 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Arjen Poutsma * @author Juergen Hoeller */ -public class DigestUtilsTests { +class DigestUtilsTests { private byte[] bytes; @BeforeEach - public void createBytes() throws UnsupportedEncodingException { + void createBytes() throws UnsupportedEncodingException { bytes = "Hello World".getBytes("UTF-8"); } @Test - public void md5() throws IOException { + void md5() throws IOException { byte[] expected = new byte[] {-0x4f, 0xa, -0x73, -0x4f, 0x64, -0x20, 0x75, 0x41, 0x5, -0x49, -0x57, -0x65, -0x19, 0x2e, 0x3f, -0x1b}; @@ -53,7 +53,7 @@ public class DigestUtilsTests { } @Test - public void md5Hex() throws IOException { + void md5Hex() throws IOException { String expected = "b10a8db164e0754105b7a99be72e3fe5"; String hash = DigestUtils.md5DigestAsHex(bytes); @@ -64,7 +64,7 @@ public class DigestUtilsTests { } @Test - public void md5StringBuilder() throws IOException { + void md5StringBuilder() throws IOException { String expected = "b10a8db164e0754105b7a99be72e3fe5"; StringBuilder builder = new StringBuilder(); diff --git a/spring-core/src/test/java/org/springframework/util/ExceptionTypeFilterTests.java b/spring-core/src/test/java/org/springframework/util/ExceptionTypeFilterTests.java index 4c29f67cb9..b4d4d414ef 100644 --- a/spring-core/src/test/java/org/springframework/util/ExceptionTypeFilterTests.java +++ b/spring-core/src/test/java/org/springframework/util/ExceptionTypeFilterTests.java @@ -24,12 +24,11 @@ import static org.assertj.core.api.Assertions.assertThat; /** * @author Stephane Nicoll */ -public class ExceptionTypeFilterTests { +class ExceptionTypeFilterTests { @Test - public void subClassMatch() { - ExceptionTypeFilter filter = new ExceptionTypeFilter( - asList(RuntimeException.class), null, true); + void subClassMatch() { + ExceptionTypeFilter filter = new ExceptionTypeFilter(asList(RuntimeException.class), null, true); assertThat(filter.match(RuntimeException.class)).isTrue(); assertThat(filter.match(IllegalStateException.class)).isTrue(); } diff --git a/spring-core/src/test/java/org/springframework/util/ExponentialBackOffTests.java b/spring-core/src/test/java/org/springframework/util/ExponentialBackOffTests.java index b53a012004..8080f82fe0 100644 --- a/spring-core/src/test/java/org/springframework/util/ExponentialBackOffTests.java +++ b/spring-core/src/test/java/org/springframework/util/ExponentialBackOffTests.java @@ -25,13 +25,12 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; /** - * * @author Stephane Nicoll */ -public class ExponentialBackOffTests { +class ExponentialBackOffTests { @Test - public void defaultInstance() { + void defaultInstance() { ExponentialBackOff backOff = new ExponentialBackOff(); BackOffExecution execution = backOff.start(); assertThat(execution.nextBackOff()).isEqualTo(2000L); @@ -40,7 +39,7 @@ public class ExponentialBackOffTests { } @Test - public void simpleIncrease() { + void simpleIncrease() { ExponentialBackOff backOff = new ExponentialBackOff(100L, 2.0); BackOffExecution execution = backOff.start(); assertThat(execution.nextBackOff()).isEqualTo(100L); @@ -50,7 +49,7 @@ public class ExponentialBackOffTests { } @Test - public void fixedIncrease() { + void fixedIncrease() { ExponentialBackOff backOff = new ExponentialBackOff(100L, 1.0); backOff.setMaxElapsedTime(300L); @@ -62,7 +61,7 @@ public class ExponentialBackOffTests { } @Test - public void maxIntervalReached() { + void maxIntervalReached() { ExponentialBackOff backOff = new ExponentialBackOff(2000L, 2.0); backOff.setMaxInterval(4000L); @@ -75,7 +74,7 @@ public class ExponentialBackOffTests { } @Test - public void maxAttemptsReached() { + void maxAttemptsReached() { ExponentialBackOff backOff = new ExponentialBackOff(2000L, 2.0); backOff.setMaxElapsedTime(4000L); @@ -87,7 +86,7 @@ public class ExponentialBackOffTests { } @Test - public void startReturnDifferentInstances() { + void startReturnDifferentInstances() { ExponentialBackOff backOff = new ExponentialBackOff(); backOff.setInitialInterval(2000L); backOff.setMultiplier(2.0); @@ -105,14 +104,14 @@ public class ExponentialBackOffTests { } @Test - public void invalidInterval() { + void invalidInterval() { ExponentialBackOff backOff = new ExponentialBackOff(); assertThatIllegalArgumentException().isThrownBy(() -> backOff.setMultiplier(0.9)); } @Test - public void maxIntervalReachedImmediately() { + void maxIntervalReachedImmediately() { ExponentialBackOff backOff = new ExponentialBackOff(1000L, 2.0); backOff.setMaxInterval(50L); @@ -122,7 +121,7 @@ public class ExponentialBackOffTests { } @Test - public void toStringContent() { + void toStringContent() { ExponentialBackOff backOff = new ExponentialBackOff(2000L, 2.0); BackOffExecution execution = backOff.start(); assertThat(execution.toString()).isEqualTo("ExponentialBackOff{currentInterval=n/a, multiplier=2.0}"); diff --git a/spring-core/src/test/java/org/springframework/util/FastByteArrayOutputStreamTests.java b/spring-core/src/test/java/org/springframework/util/FastByteArrayOutputStreamTests.java index 31026fb31b..9831d5c07f 100644 --- a/spring-core/src/test/java/org/springframework/util/FastByteArrayOutputStreamTests.java +++ b/spring-core/src/test/java/org/springframework/util/FastByteArrayOutputStreamTests.java @@ -33,7 +33,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException * * @author Craig Andrews */ -public class FastByteArrayOutputStreamTests { +class FastByteArrayOutputStreamTests { private static final int INITIAL_CAPACITY = 256; @@ -43,13 +43,13 @@ public class FastByteArrayOutputStreamTests { @Test - public void size() throws Exception { + void size() throws Exception { this.os.write(this.helloBytes); assertThat(this.helloBytes.length).isEqualTo(this.os.size()); } @Test - public void resize() throws Exception { + void resize() throws Exception { this.os.write(this.helloBytes); int sizeBefore = this.os.size(); this.os.resize(64); @@ -58,7 +58,7 @@ public class FastByteArrayOutputStreamTests { } @Test - public void autoGrow() throws IOException { + void autoGrow() throws IOException { this.os.resize(1); for (int i = 0; i < 10; i++) { this.os.write(1); @@ -68,13 +68,13 @@ public class FastByteArrayOutputStreamTests { } @Test - public void write() throws Exception { + void write() throws Exception { this.os.write(this.helloBytes); assertByteArrayEqualsString(this.os); } @Test - public void reset() throws Exception { + void reset() throws Exception { this.os.write(this.helloBytes); assertByteArrayEqualsString(this.os); this.os.reset(); @@ -84,14 +84,14 @@ public class FastByteArrayOutputStreamTests { } @Test - public void close() throws Exception { + void close() throws Exception { this.os.close(); assertThatIOException().isThrownBy(() -> this.os.write(this.helloBytes)); } @Test - public void toByteArrayUnsafe() throws Exception { + void toByteArrayUnsafe() throws Exception { this.os.write(this.helloBytes); assertByteArrayEqualsString(this.os); assertThat(this.os.toByteArrayUnsafe()).isSameAs(this.os.toByteArrayUnsafe()); @@ -99,7 +99,7 @@ public class FastByteArrayOutputStreamTests { } @Test - public void writeTo() throws Exception { + void writeTo() throws Exception { this.os.write(this.helloBytes); assertByteArrayEqualsString(this.os); ByteArrayOutputStream baos = new ByteArrayOutputStream(); @@ -108,26 +108,26 @@ public class FastByteArrayOutputStreamTests { } @Test - public void failResize() throws Exception { + void failResize() throws Exception { this.os.write(this.helloBytes); assertThatIllegalArgumentException().isThrownBy(() -> this.os.resize(5)); } @Test - public void getInputStream() throws Exception { + void getInputStream() throws Exception { this.os.write(this.helloBytes); assertThat(this.os.getInputStream()).isNotNull(); } @Test - public void getInputStreamAvailable() throws Exception { + void getInputStreamAvailable() throws Exception { this.os.write(this.helloBytes); assertThat(this.helloBytes.length).isEqualTo(this.os.getInputStream().available()); } @Test - public void getInputStreamRead() throws Exception { + void getInputStreamRead() throws Exception { this.os.write(this.helloBytes); InputStream inputStream = this.os.getInputStream(); assertThat(this.helloBytes[0]).isEqualTo((byte) inputStream.read()); @@ -137,7 +137,7 @@ public class FastByteArrayOutputStreamTests { } @Test - public void getInputStreamReadBytePromotion() throws Exception { + void getInputStreamReadBytePromotion() throws Exception { byte[] bytes = new byte[] { -1 }; this.os.write(bytes); InputStream inputStream = this.os.getInputStream(); @@ -146,7 +146,7 @@ public class FastByteArrayOutputStreamTests { } @Test - public void getInputStreamReadAll() throws Exception { + void getInputStreamReadAll() throws Exception { this.os.write(this.helloBytes); InputStream inputStream = this.os.getInputStream(); byte[] actual = new byte[inputStream.available()]; @@ -157,7 +157,7 @@ public class FastByteArrayOutputStreamTests { } @Test - public void getInputStreamReadBeyondEndOfStream() throws Exception { + void getInputStreamReadBeyondEndOfStream() throws Exception { this.os.write(this.helloBytes); InputStream inputStream = os.getInputStream(); byte[] actual = new byte[inputStream.available() + 1]; @@ -171,7 +171,7 @@ public class FastByteArrayOutputStreamTests { } @Test - public void getInputStreamSkip() throws Exception { + void getInputStreamSkip() throws Exception { this.os.write(this.helloBytes); InputStream inputStream = this.os.getInputStream(); assertThat(this.helloBytes[0]).isEqualTo((byte) inputStream.read()); @@ -181,7 +181,7 @@ public class FastByteArrayOutputStreamTests { } @Test - public void getInputStreamSkipAll() throws Exception { + void getInputStreamSkipAll() throws Exception { this.os.write(this.helloBytes); InputStream inputStream = this.os.getInputStream(); assertThat(this.helloBytes.length).isEqualTo(inputStream.skip(1000)); @@ -189,7 +189,7 @@ public class FastByteArrayOutputStreamTests { } @Test - public void updateMessageDigest() throws Exception { + void updateMessageDigest() throws Exception { StringBuilder builder = new StringBuilder("\"0"); this.os.write(this.helloBytes); InputStream inputStream = this.os.getInputStream(); @@ -200,7 +200,7 @@ public class FastByteArrayOutputStreamTests { } @Test - public void updateMessageDigestManyBuffers() throws Exception { + void updateMessageDigestManyBuffers() throws Exception { StringBuilder builder = new StringBuilder("\"0"); // filling at least one 256 buffer for ( int i = 0; i < 30; i++) { diff --git a/spring-core/src/test/java/org/springframework/util/FileCopyUtilsTests.java b/spring-core/src/test/java/org/springframework/util/FileCopyUtilsTests.java index e141a85cf2..e0958a6051 100644 --- a/spring-core/src/test/java/org/springframework/util/FileCopyUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/util/FileCopyUtilsTests.java @@ -33,10 +33,10 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Juergen Hoeller * @since 12.03.2005 */ -public class FileCopyUtilsTests { +class FileCopyUtilsTests { @Test - public void copyFromInputStream() throws IOException { + void copyFromInputStream() throws IOException { byte[] content = "content".getBytes(); ByteArrayInputStream in = new ByteArrayInputStream(content); ByteArrayOutputStream out = new ByteArrayOutputStream(content.length); @@ -46,7 +46,7 @@ public class FileCopyUtilsTests { } @Test - public void copyFromByteArray() throws IOException { + void copyFromByteArray() throws IOException { byte[] content = "content".getBytes(); ByteArrayOutputStream out = new ByteArrayOutputStream(content.length); FileCopyUtils.copy(content, out); @@ -54,7 +54,7 @@ public class FileCopyUtilsTests { } @Test - public void copyToByteArray() throws IOException { + void copyToByteArray() throws IOException { byte[] content = "content".getBytes(); ByteArrayInputStream in = new ByteArrayInputStream(content); byte[] result = FileCopyUtils.copyToByteArray(in); @@ -62,7 +62,7 @@ public class FileCopyUtilsTests { } @Test - public void copyFromReader() throws IOException { + void copyFromReader() throws IOException { String content = "content"; StringReader in = new StringReader(content); StringWriter out = new StringWriter(); @@ -72,7 +72,7 @@ public class FileCopyUtilsTests { } @Test - public void copyFromString() throws IOException { + void copyFromString() throws IOException { String content = "content"; StringWriter out = new StringWriter(); FileCopyUtils.copy(content, out); @@ -80,7 +80,7 @@ public class FileCopyUtilsTests { } @Test - public void copyToString() throws IOException { + void copyToString() throws IOException { String content = "content"; StringReader in = new StringReader(content); String result = FileCopyUtils.copyToString(in); diff --git a/spring-core/src/test/java/org/springframework/util/FileSystemUtilsTests.java b/spring-core/src/test/java/org/springframework/util/FileSystemUtilsTests.java index 3a623ff94e..4f49f7610f 100644 --- a/spring-core/src/test/java/org/springframework/util/FileSystemUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/util/FileSystemUtilsTests.java @@ -26,10 +26,10 @@ import static org.assertj.core.api.Assertions.assertThat; /** * @author Rob Harrop */ -public class FileSystemUtilsTests { +class FileSystemUtilsTests { @Test - public void deleteRecursively() throws Exception { + void deleteRecursively() throws Exception { File root = new File("./tmp/root"); File child = new File(root, "child"); File grandchild = new File(child, "grandchild"); @@ -53,7 +53,7 @@ public class FileSystemUtilsTests { } @Test - public void copyRecursively() throws Exception { + void copyRecursively() throws Exception { File src = new File("./tmp/src"); File child = new File(src, "child"); File grandchild = new File(child, "grandchild"); @@ -80,7 +80,7 @@ public class FileSystemUtilsTests { @AfterEach - public void tearDown() throws Exception { + void tearDown() throws Exception { File tmp = new File("./tmp"); if (tmp.exists()) { FileSystemUtils.deleteRecursively(tmp); diff --git a/spring-core/src/test/java/org/springframework/util/FixedBackOffTests.java b/spring-core/src/test/java/org/springframework/util/FixedBackOffTests.java index 7fde180b16..764bb41e08 100644 --- a/spring-core/src/test/java/org/springframework/util/FixedBackOffTests.java +++ b/spring-core/src/test/java/org/springframework/util/FixedBackOffTests.java @@ -26,10 +26,10 @@ import static org.assertj.core.api.Assertions.assertThat; /** * @author Stephane Nicoll */ -public class FixedBackOffTests { +class FixedBackOffTests { @Test - public void defaultInstance() { + void defaultInstance() { FixedBackOff backOff = new FixedBackOff(); BackOffExecution execution = backOff.start(); for (int i = 0; i < 100; i++) { @@ -38,14 +38,14 @@ public class FixedBackOffTests { } @Test - public void noAttemptAtAll() { + void noAttemptAtAll() { FixedBackOff backOff = new FixedBackOff(100L, 0L); BackOffExecution execution = backOff.start(); assertThat(execution.nextBackOff()).isEqualTo(BackOffExecution.STOP); } @Test - public void maxAttemptsReached() { + void maxAttemptsReached() { FixedBackOff backOff = new FixedBackOff(200L, 2); BackOffExecution execution = backOff.start(); assertThat(execution.nextBackOff()).isEqualTo(200L); @@ -54,7 +54,7 @@ public class FixedBackOffTests { } @Test - public void startReturnDifferentInstances() { + void startReturnDifferentInstances() { FixedBackOff backOff = new FixedBackOff(100L, 1); BackOffExecution execution = backOff.start(); BackOffExecution execution2 = backOff.start(); @@ -66,7 +66,7 @@ public class FixedBackOffTests { } @Test - public void liveUpdate() { + void liveUpdate() { FixedBackOff backOff = new FixedBackOff(100L, 1); BackOffExecution execution = backOff.start(); assertThat(execution.nextBackOff()).isEqualTo(100L); @@ -79,7 +79,7 @@ public class FixedBackOffTests { } @Test - public void toStringContent() { + void toStringContent() { FixedBackOff backOff = new FixedBackOff(200L, 10); BackOffExecution execution = backOff.start(); assertThat(execution.toString()).isEqualTo("FixedBackOff{interval=200, currentAttempts=0, maxAttempts=10}"); diff --git a/spring-core/src/test/java/org/springframework/util/InstanceFilterTests.java b/spring-core/src/test/java/org/springframework/util/InstanceFilterTests.java index f8de4cb516..8e761b3693 100644 --- a/spring-core/src/test/java/org/springframework/util/InstanceFilterTests.java +++ b/spring-core/src/test/java/org/springframework/util/InstanceFilterTests.java @@ -24,17 +24,17 @@ import static org.assertj.core.api.Assertions.assertThat; /** * @author Stephane Nicoll */ -public class InstanceFilterTests { +class InstanceFilterTests { @Test - public void emptyFilterApplyMatchIfEmpty() { + void emptyFilterApplyMatchIfEmpty() { InstanceFilter filter = new InstanceFilter<>(null, null, true); match(filter, "foo"); match(filter, "bar"); } @Test - public void includesFilter() { + void includesFilter() { InstanceFilter filter = new InstanceFilter<>( asList("First", "Second"), null, true); match(filter, "Second"); @@ -42,7 +42,7 @@ public class InstanceFilterTests { } @Test - public void excludesFilter() { + void excludesFilter() { InstanceFilter filter = new InstanceFilter<>( null, asList("First", "Second"), true); doNotMatch(filter, "Second"); @@ -50,7 +50,7 @@ public class InstanceFilterTests { } @Test - public void includesAndExcludesFilters() { + void includesAndExcludesFilters() { InstanceFilter filter = new InstanceFilter<>( asList("foo", "Bar"), asList("First", "Second"), true); doNotMatch(filter, "Second"); @@ -58,7 +58,7 @@ public class InstanceFilterTests { } @Test - public void includesAndExcludesFiltersConflict() { + void includesAndExcludesFiltersConflict() { InstanceFilter filter = new InstanceFilter<>( asList("First"), asList("First"), true); doNotMatch(filter, "First"); diff --git a/spring-core/src/test/java/org/springframework/util/LinkedCaseInsensitiveMapTests.java b/spring-core/src/test/java/org/springframework/util/LinkedCaseInsensitiveMapTests.java index 65a20ad9f9..0a2f6df061 100644 --- a/spring-core/src/test/java/org/springframework/util/LinkedCaseInsensitiveMapTests.java +++ b/spring-core/src/test/java/org/springframework/util/LinkedCaseInsensitiveMapTests.java @@ -28,13 +28,13 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Juergen Hoeller * @author Phillip Webb */ -public class LinkedCaseInsensitiveMapTests { +class LinkedCaseInsensitiveMapTests { private final LinkedCaseInsensitiveMap map = new LinkedCaseInsensitiveMap<>(); @Test - public void putAndGet() { + void putAndGet() { assertThat(map.put("key", "value1")).isNull(); assertThat(map.put("key", "value2")).isEqualTo("value1"); assertThat(map.put("key", "value3")).isEqualTo("value2"); @@ -51,7 +51,7 @@ public class LinkedCaseInsensitiveMapTests { } @Test - public void putWithOverlappingKeys() { + void putWithOverlappingKeys() { assertThat(map.put("key", "value1")).isNull(); assertThat(map.put("KEY", "value2")).isEqualTo("value1"); assertThat(map.put("Key", "value3")).isEqualTo("value2"); @@ -68,7 +68,7 @@ public class LinkedCaseInsensitiveMapTests { } @Test - public void getOrDefault() { + void getOrDefault() { assertThat(map.put("key", "value1")).isNull(); assertThat(map.put("KEY", "value2")).isEqualTo("value1"); assertThat(map.put("Key", "value3")).isEqualTo("value2"); @@ -80,7 +80,7 @@ public class LinkedCaseInsensitiveMapTests { } @Test - public void getOrDefaultWithNullValue() { + void getOrDefaultWithNullValue() { assertThat(map.put("key", null)).isNull(); assertThat(map.put("KEY", null)).isNull(); assertThat(map.put("Key", null)).isNull(); @@ -92,7 +92,7 @@ public class LinkedCaseInsensitiveMapTests { } @Test - public void computeIfAbsentWithExistingValue() { + void computeIfAbsentWithExistingValue() { assertThat(map.putIfAbsent("key", "value1")).isNull(); assertThat(map.putIfAbsent("KEY", "value2")).isEqualTo("value1"); assertThat(map.put("Key", "value3")).isEqualTo("value1"); @@ -102,14 +102,14 @@ public class LinkedCaseInsensitiveMapTests { } @Test - public void computeIfAbsentWithComputedValue() { + void computeIfAbsentWithComputedValue() { assertThat(map.computeIfAbsent("key", key2 -> "value1")).isEqualTo("value1"); assertThat(map.computeIfAbsent("KEY", key1 -> "value2")).isEqualTo("value1"); assertThat(map.computeIfAbsent("Key", key -> "value3")).isEqualTo("value1"); } @Test - public void mapClone() { + void mapClone() { assertThat(map.put("key", "value1")).isNull(); LinkedCaseInsensitiveMap copy = map.clone(); @@ -134,7 +134,7 @@ public class LinkedCaseInsensitiveMapTests { @Test - public void clearFromKeySet() { + void clearFromKeySet() { map.put("key", "value"); map.keySet().clear(); map.computeIfAbsent("key", k -> "newvalue"); @@ -142,7 +142,7 @@ public class LinkedCaseInsensitiveMapTests { } @Test - public void removeFromKeySet() { + void removeFromKeySet() { map.put("key", "value"); map.keySet().remove("key"); map.computeIfAbsent("key", k -> "newvalue"); @@ -150,7 +150,7 @@ public class LinkedCaseInsensitiveMapTests { } @Test - public void removeFromKeySetViaIterator() { + void removeFromKeySetViaIterator() { map.put("key", "value"); nextAndRemove(map.keySet().iterator()); assertThat(map.size()).isEqualTo(0); @@ -159,7 +159,7 @@ public class LinkedCaseInsensitiveMapTests { } @Test - public void clearFromValues() { + void clearFromValues() { map.put("key", "value"); map.values().clear(); assertThat(map.size()).isEqualTo(0); @@ -168,7 +168,7 @@ public class LinkedCaseInsensitiveMapTests { } @Test - public void removeFromValues() { + void removeFromValues() { map.put("key", "value"); map.values().remove("value"); assertThat(map.size()).isEqualTo(0); @@ -177,7 +177,7 @@ public class LinkedCaseInsensitiveMapTests { } @Test - public void removeFromValuesViaIterator() { + void removeFromValuesViaIterator() { map.put("key", "value"); nextAndRemove(map.values().iterator()); assertThat(map.size()).isEqualTo(0); @@ -186,7 +186,7 @@ public class LinkedCaseInsensitiveMapTests { } @Test - public void clearFromEntrySet() { + void clearFromEntrySet() { map.put("key", "value"); map.entrySet().clear(); assertThat(map.size()).isEqualTo(0); @@ -195,7 +195,7 @@ public class LinkedCaseInsensitiveMapTests { } @Test - public void removeFromEntrySet() { + void removeFromEntrySet() { map.put("key", "value"); map.entrySet().remove(map.entrySet().iterator().next()); assertThat(map.size()).isEqualTo(0); @@ -204,7 +204,7 @@ public class LinkedCaseInsensitiveMapTests { } @Test - public void removeFromEntrySetViaIterator() { + void removeFromEntrySetViaIterator() { map.put("key", "value"); nextAndRemove(map.entrySet().iterator()); assertThat(map.size()).isEqualTo(0); diff --git a/spring-core/src/test/java/org/springframework/util/LinkedMultiValueMapTests.java b/spring-core/src/test/java/org/springframework/util/LinkedMultiValueMapTests.java index 1197dd56c2..e8a4bba787 100644 --- a/spring-core/src/test/java/org/springframework/util/LinkedMultiValueMapTests.java +++ b/spring-core/src/test/java/org/springframework/util/LinkedMultiValueMapTests.java @@ -31,13 +31,13 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Arjen Poutsma * @author Juergen Hoeller */ -public class LinkedMultiValueMapTests { +class LinkedMultiValueMapTests { private final LinkedMultiValueMap map = new LinkedMultiValueMap<>(); @Test - public void add() { + void add() { map.add("key", "value1"); map.add("key", "value2"); assertThat(map).hasSize(1); @@ -45,27 +45,27 @@ public class LinkedMultiValueMapTests { } @Test - public void addIfAbsentWhenAbsent() { + void addIfAbsentWhenAbsent() { map.addIfAbsent("key", "value1"); assertThat(map.get("key")).containsExactly("value1"); } @Test - public void addIfAbsentWhenPresent() { + void addIfAbsentWhenPresent() { map.add("key", "value1"); map.addIfAbsent("key", "value2"); assertThat(map.get("key")).containsExactly("value1"); } @Test - public void set() { + void set() { map.set("key", "value1"); map.set("key", "value2"); assertThat(map.get("key")).containsExactly("value2"); } @Test - public void addAll() { + void addAll() { map.add("key", "value1"); map.addAll("key", Arrays.asList("value2", "value3")); assertThat(map).hasSize(1); @@ -73,7 +73,7 @@ public class LinkedMultiValueMapTests { } @Test - public void addAllWithEmptyList() { + void addAllWithEmptyList() { map.addAll("key", Collections.emptyList()); assertThat(map).hasSize(1); assertThat(map.get("key")).isEmpty(); @@ -81,7 +81,7 @@ public class LinkedMultiValueMapTests { } @Test - public void getFirst() { + void getFirst() { List values = new ArrayList<>(2); values.add("value1"); values.add("value2"); @@ -91,14 +91,14 @@ public class LinkedMultiValueMapTests { } @Test - public void getFirstWithEmptyList() { + void getFirstWithEmptyList() { map.put("key", Collections.emptyList()); assertThat(map.getFirst("key")).isNull(); assertThat(map.getFirst("other")).isNull(); } @Test - public void toSingleValueMap() { + void toSingleValueMap() { List values = new ArrayList<>(2); values.add("value1"); values.add("value2"); @@ -109,7 +109,7 @@ public class LinkedMultiValueMapTests { } @Test - public void toSingleValueMapWithEmptyList() { + void toSingleValueMapWithEmptyList() { map.put("key", Collections.emptyList()); Map singleValueMap = map.toSingleValueMap(); assertThat(singleValueMap).isEmpty(); @@ -117,7 +117,7 @@ public class LinkedMultiValueMapTests { } @Test - public void equals() { + void equals() { map.set("key1", "value1"); assertThat(map).isEqualTo(map); MultiValueMap o1 = new LinkedMultiValueMap<>(); diff --git a/spring-core/src/test/java/org/springframework/util/MethodInvokerTests.java b/spring-core/src/test/java/org/springframework/util/MethodInvokerTests.java index 93e8fbd03c..13fa3454e8 100644 --- a/spring-core/src/test/java/org/springframework/util/MethodInvokerTests.java +++ b/spring-core/src/test/java/org/springframework/util/MethodInvokerTests.java @@ -31,10 +31,10 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; * @author Sam Brannen * @since 21.11.2003 */ -public class MethodInvokerTests { +class MethodInvokerTests { @Test - public void plainMethodInvoker() throws Exception { + void plainMethodInvoker() throws Exception { // sanity check: singleton, non-static should work TestClass1 tc1 = new TestClass1(); MethodInvoker mi = new MethodInvoker(); @@ -80,7 +80,7 @@ public class MethodInvokerTests { } @Test - public void stringWithMethodInvoker() throws Exception { + void stringWithMethodInvoker() throws Exception { MethodInvoker methodInvoker = new MethodInvoker(); methodInvoker.setTargetObject(new Greeter()); methodInvoker.setTargetMethod("greet"); @@ -91,7 +91,7 @@ public class MethodInvokerTests { } @Test - public void purchaserWithMethodInvoker() throws Exception { + void purchaserWithMethodInvoker() throws Exception { MethodInvoker methodInvoker = new MethodInvoker(); methodInvoker.setTargetObject(new Greeter()); methodInvoker.setTargetMethod("greet"); @@ -102,7 +102,7 @@ public class MethodInvokerTests { } @Test - public void shopperWithMethodInvoker() throws Exception { + void shopperWithMethodInvoker() throws Exception { MethodInvoker methodInvoker = new MethodInvoker(); methodInvoker.setTargetObject(new Greeter()); methodInvoker.setTargetMethod("greet"); @@ -113,7 +113,7 @@ public class MethodInvokerTests { } @Test - public void salesmanWithMethodInvoker() throws Exception { + void salesmanWithMethodInvoker() throws Exception { MethodInvoker methodInvoker = new MethodInvoker(); methodInvoker.setTargetObject(new Greeter()); methodInvoker.setTargetMethod("greet"); @@ -124,7 +124,7 @@ public class MethodInvokerTests { } @Test - public void customerWithMethodInvoker() throws Exception { + void customerWithMethodInvoker() throws Exception { MethodInvoker methodInvoker = new MethodInvoker(); methodInvoker.setTargetObject(new Greeter()); methodInvoker.setTargetMethod("greet"); @@ -135,7 +135,7 @@ public class MethodInvokerTests { } @Test - public void regularWithMethodInvoker() throws Exception { + void regularWithMethodInvoker() throws Exception { MethodInvoker methodInvoker = new MethodInvoker(); methodInvoker.setTargetObject(new Greeter()); methodInvoker.setTargetMethod("greet"); @@ -146,7 +146,7 @@ public class MethodInvokerTests { } @Test - public void vipWithMethodInvoker() throws Exception { + void vipWithMethodInvoker() throws Exception { MethodInvoker methodInvoker = new MethodInvoker(); methodInvoker.setTargetObject(new Greeter()); methodInvoker.setTargetMethod("greet"); diff --git a/spring-core/src/test/java/org/springframework/util/MimeTypeTests.java b/spring-core/src/test/java/org/springframework/util/MimeTypeTests.java index ef5db1253e..aa5fefc2e3 100644 --- a/spring-core/src/test/java/org/springframework/util/MimeTypeTests.java +++ b/spring-core/src/test/java/org/springframework/util/MimeTypeTests.java @@ -40,46 +40,46 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException * @author Sam Brannen * @author Dimitrios Liapis */ -public class MimeTypeTests { +class MimeTypeTests { @Test - public void slashInSubtype() { + void slashInSubtype() { assertThatIllegalArgumentException().isThrownBy(() -> new MimeType("text", "/")); } @Test - public void valueOfNoSubtype() { + void valueOfNoSubtype() { assertThatExceptionOfType(InvalidMimeTypeException.class).isThrownBy(() -> MimeType.valueOf("audio")); } @Test - public void valueOfNoSubtypeSlash() { + void valueOfNoSubtypeSlash() { assertThatExceptionOfType(InvalidMimeTypeException.class).isThrownBy(() -> MimeType.valueOf("audio/")); } @Test - public void valueOfIllegalType() { + void valueOfIllegalType() { assertThatExceptionOfType(InvalidMimeTypeException.class).isThrownBy(() -> MimeType.valueOf("audio(/basic")); } @Test - public void valueOfIllegalSubtype() { + void valueOfIllegalSubtype() { assertThatExceptionOfType(InvalidMimeTypeException.class).isThrownBy(() -> MimeType.valueOf("audio/basic)")); } @Test - public void valueOfIllegalCharset() { + void valueOfIllegalCharset() { assertThatExceptionOfType(InvalidMimeTypeException.class).isThrownBy(() -> MimeType.valueOf("text/html; charset=foo-bar")); } @Test - public void parseCharset() { + void parseCharset() { String s = "text/html; charset=iso-8859-1"; MimeType mimeType = MimeType.valueOf(s); assertThat(mimeType.getType()).as("Invalid type").isEqualTo("text"); @@ -88,7 +88,7 @@ public class MimeTypeTests { } @Test - public void parseQuotedCharset() { + void parseQuotedCharset() { String s = "application/xml;charset=\"utf-8\""; MimeType mimeType = MimeType.valueOf(s); assertThat(mimeType.getType()).as("Invalid type").isEqualTo("application"); @@ -97,7 +97,7 @@ public class MimeTypeTests { } @Test - public void parseQuotedSeparator() { + void parseQuotedSeparator() { String s = "application/xop+xml;charset=utf-8;type=\"application/soap+xml;action=\\\"https://x.y.z\\\"\""; MimeType mimeType = MimeType.valueOf(s); assertThat(mimeType.getType()).as("Invalid type").isEqualTo("application"); @@ -107,7 +107,7 @@ public class MimeTypeTests { } @Test - public void withConversionService() { + void withConversionService() { ConversionService conversionService = new DefaultConversionService(); assertThat(conversionService.canConvert(String.class, MimeType.class)).isTrue(); MimeType mimeType = MimeType.valueOf("application/xml"); @@ -115,7 +115,7 @@ public class MimeTypeTests { } @Test - public void includes() { + void includes() { MimeType textPlain = MimeTypeUtils.TEXT_PLAIN; assertThat(textPlain.includes(textPlain)).as("Equal types is not inclusive").isTrue(); MimeType allText = new MimeType("text"); @@ -145,7 +145,7 @@ public class MimeTypeTests { } @Test - public void isCompatible() { + void isCompatible() { MimeType textPlain = MimeTypeUtils.TEXT_PLAIN; assertThat(textPlain.isCompatibleWith(textPlain)).as("Equal types is not compatible").isTrue(); MimeType allText = new MimeType("text"); @@ -175,14 +175,14 @@ public class MimeTypeTests { } @Test - public void testToString() { + void testToString() { MimeType mimeType = new MimeType("text", "plain"); String result = mimeType.toString(); assertThat(result).as("Invalid toString() returned").isEqualTo("text/plain"); } @Test - public void parseMimeType() { + void parseMimeType() { String s = "audio/*"; MimeType mimeType = MimeTypeUtils.parseMimeType(s); assertThat(mimeType.getType()).as("Invalid type").isEqualTo("audio"); @@ -190,109 +190,109 @@ public class MimeTypeTests { } @Test - public void parseMimeTypeNoSubtype() { + void parseMimeTypeNoSubtype() { assertThatExceptionOfType(InvalidMimeTypeException.class).isThrownBy(() -> MimeTypeUtils.parseMimeType("audio")); } @Test - public void parseMimeTypeNoSubtypeSlash() { + void parseMimeTypeNoSubtypeSlash() { assertThatExceptionOfType(InvalidMimeTypeException.class).isThrownBy(() -> MimeTypeUtils.parseMimeType("audio/")); } @Test - public void parseMimeTypeTypeRange() { + void parseMimeTypeTypeRange() { assertThatExceptionOfType(InvalidMimeTypeException.class).isThrownBy(() -> MimeTypeUtils.parseMimeType("*/json")); } @Test - public void parseMimeTypeIllegalType() { + void parseMimeTypeIllegalType() { assertThatExceptionOfType(InvalidMimeTypeException.class).isThrownBy(() -> MimeTypeUtils.parseMimeType("audio(/basic")); } @Test - public void parseMimeTypeIllegalSubtype() { + void parseMimeTypeIllegalSubtype() { assertThatExceptionOfType(InvalidMimeTypeException.class).isThrownBy(() -> MimeTypeUtils.parseMimeType("audio/basic)")); } @Test - public void parseMimeTypeMissingTypeAndSubtype() { + void parseMimeTypeMissingTypeAndSubtype() { assertThatExceptionOfType(InvalidMimeTypeException.class).isThrownBy(() -> MimeTypeUtils.parseMimeType(" ;a=b")); } @Test - public void parseMimeTypeEmptyParameterAttribute() { + void parseMimeTypeEmptyParameterAttribute() { assertThatExceptionOfType(InvalidMimeTypeException.class).isThrownBy(() -> MimeTypeUtils.parseMimeType("audio/*;=value")); } @Test - public void parseMimeTypeEmptyParameterValue() { + void parseMimeTypeEmptyParameterValue() { assertThatExceptionOfType(InvalidMimeTypeException.class).isThrownBy(() -> MimeTypeUtils.parseMimeType("audio/*;attr=")); } @Test - public void parseMimeTypeIllegalParameterAttribute() { + void parseMimeTypeIllegalParameterAttribute() { assertThatExceptionOfType(InvalidMimeTypeException.class).isThrownBy(() -> MimeTypeUtils.parseMimeType("audio/*;attr<=value")); } @Test - public void parseMimeTypeIllegalParameterValue() { + void parseMimeTypeIllegalParameterValue() { assertThatExceptionOfType(InvalidMimeTypeException.class).isThrownBy(() -> MimeTypeUtils.parseMimeType("audio/*;attr=v>alue")); } @Test - public void parseMimeTypeIllegalCharset() { + void parseMimeTypeIllegalCharset() { assertThatExceptionOfType(InvalidMimeTypeException.class).isThrownBy(() -> MimeTypeUtils.parseMimeType("text/html; charset=foo-bar")); } @Test // SPR-8917 - public void parseMimeTypeQuotedParameterValue() { + void parseMimeTypeQuotedParameterValue() { MimeType mimeType = MimeTypeUtils.parseMimeType("audio/*;attr=\"v>alue\""); assertThat(mimeType.getParameter("attr")).isEqualTo("\"v>alue\""); } @Test // SPR-8917 - public void parseMimeTypeSingleQuotedParameterValue() { + void parseMimeTypeSingleQuotedParameterValue() { MimeType mimeType = MimeTypeUtils.parseMimeType("audio/*;attr='v>alue'"); assertThat(mimeType.getParameter("attr")).isEqualTo("'v>alue'"); } @Test // SPR-16630 - public void parseMimeTypeWithSpacesAroundEquals() { + void parseMimeTypeWithSpacesAroundEquals() { MimeType mimeType = MimeTypeUtils.parseMimeType("multipart/x-mixed-replace;boundary = --myboundary"); assertThat(mimeType.getParameter("boundary")).isEqualTo("--myboundary"); } @Test // SPR-16630 - public void parseMimeTypeWithSpacesAroundEqualsAndQuotedValue() { + void parseMimeTypeWithSpacesAroundEqualsAndQuotedValue() { MimeType mimeType = MimeTypeUtils.parseMimeType("text/plain; foo = \" bar \" "); assertThat(mimeType.getParameter("foo")).isEqualTo("\" bar \""); } @Test - public void parseMimeTypeIllegalQuotedParameterValue() { + void parseMimeTypeIllegalQuotedParameterValue() { assertThatExceptionOfType(InvalidMimeTypeException.class).isThrownBy(() -> MimeTypeUtils.parseMimeType("audio/*;attr=\"")); } @Test - public void parseMimeTypeNull() { + void parseMimeTypeNull() { assertThatExceptionOfType(InvalidMimeTypeException.class).isThrownBy(() -> MimeTypeUtils.parseMimeType(null)); } @Test - public void parseMimeTypes() { + void parseMimeTypes() { String s = "text/plain, text/html, text/x-dvi, text/x-c"; List mimeTypes = MimeTypeUtils.parseMimeTypes(s); assertThat(mimeTypes).as("No mime types returned").isNotNull(); @@ -304,14 +304,14 @@ public class MimeTypeTests { } @Test // gh-23241 - public void parseMimeTypesWithTrailingComma() { + void parseMimeTypesWithTrailingComma() { List mimeTypes = MimeTypeUtils.parseMimeTypes("text/plain, text/html,"); assertThat(mimeTypes).as("No mime types returned").isNotNull(); assertThat(mimeTypes.size()).as("Incorrect number of mime types").isEqualTo(2); } @Test // SPR-17459 - public void parseMimeTypesWithQuotedParameters() { + void parseMimeTypesWithQuotedParameters() { testWithQuotedParameters("foo/bar;param=\",\""); testWithQuotedParameters("foo/bar;param=\"s,a,\""); testWithQuotedParameters("foo/bar;param=\"s,\"", "text/x-c"); @@ -330,7 +330,7 @@ public class MimeTypeTests { } @Test - public void compareTo() { + void compareTo() { MimeType audioBasic = new MimeType("audio", "basic"); MimeType audio = new MimeType("audio"); MimeType audioWave = new MimeType("audio", "wave"); @@ -363,7 +363,7 @@ public class MimeTypeTests { } @Test - public void compareToCaseSensitivity() { + void compareToCaseSensitivity() { MimeType m1 = new MimeType("audio", "basic"); MimeType m2 = new MimeType("Audio", "Basic"); assertThat(m1.compareTo(m2)).as("Invalid comparison result").isEqualTo(0); @@ -385,7 +385,7 @@ public class MimeTypeTests { * @since 4.2 */ @Test - public void equalsIsCaseInsensitiveForCharsets() { + void equalsIsCaseInsensitiveForCharsets() { MimeType m1 = new MimeType("text", "plain", singletonMap("charset", "UTF-8")); MimeType m2 = new MimeType("text", "plain", singletonMap("charset", "utf-8")); assertThat(m2).isEqualTo(m1); diff --git a/spring-core/src/test/java/org/springframework/util/NumberUtilsTests.java b/spring-core/src/test/java/org/springframework/util/NumberUtilsTests.java index 341581302e..58581114e3 100644 --- a/spring-core/src/test/java/org/springframework/util/NumberUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/util/NumberUtilsTests.java @@ -30,10 +30,10 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException * @author Rob Harrop * @author Juergen Hoeller */ -public class NumberUtilsTests { +class NumberUtilsTests { @Test - public void parseNumber() { + void parseNumber() { String aByte = "" + Byte.MAX_VALUE; String aShort = "" + Short.MAX_VALUE; String anInteger = "" + Integer.MAX_VALUE; @@ -50,7 +50,7 @@ public class NumberUtilsTests { } @Test - public void parseNumberUsingNumberFormat() { + void parseNumberUsingNumberFormat() { NumberFormat nf = NumberFormat.getNumberInstance(Locale.US); String aByte = "" + Byte.MAX_VALUE; String aShort = "" + Short.MAX_VALUE; @@ -68,7 +68,7 @@ public class NumberUtilsTests { } @Test - public void parseNumberRequiringTrim() { + void parseNumberRequiringTrim() { String aByte = " " + Byte.MAX_VALUE + " "; String aShort = " " + Short.MAX_VALUE + " "; String anInteger = " " + Integer.MAX_VALUE + " "; @@ -85,7 +85,7 @@ public class NumberUtilsTests { } @Test - public void parseNumberRequiringTrimUsingNumberFormat() { + void parseNumberRequiringTrimUsingNumberFormat() { NumberFormat nf = NumberFormat.getNumberInstance(Locale.US); String aByte = " " + Byte.MAX_VALUE + " "; String aShort = " " + Short.MAX_VALUE + " "; @@ -103,7 +103,7 @@ public class NumberUtilsTests { } @Test - public void parseNumberAsHex() { + void parseNumberAsHex() { String aByte = "0x" + Integer.toHexString(Byte.valueOf(Byte.MAX_VALUE).intValue()); String aShort = "0x" + Integer.toHexString(Short.valueOf(Short.MAX_VALUE).intValue()); String anInteger = "0x" + Integer.toHexString(Integer.MAX_VALUE); @@ -118,7 +118,7 @@ public class NumberUtilsTests { } @Test - public void parseNumberAsNegativeHex() { + void parseNumberAsNegativeHex() { String aByte = "-0x80"; String aShort = "-0x8000"; String anInteger = "-0x80000000"; @@ -133,47 +133,47 @@ public class NumberUtilsTests { } @Test - public void convertDoubleToBigInteger() { + void convertDoubleToBigInteger() { Double decimal = Double.valueOf(3.14d); assertThat(NumberUtils.convertNumberToTargetClass(decimal, BigInteger.class)).isEqualTo(new BigInteger("3")); } @Test - public void convertBigDecimalToBigInteger() { + void convertBigDecimalToBigInteger() { String number = "987459837583750387355346"; BigDecimal decimal = new BigDecimal(number); assertThat(NumberUtils.convertNumberToTargetClass(decimal, BigInteger.class)).isEqualTo(new BigInteger(number)); } @Test - public void convertNonExactBigDecimalToBigInteger() { + void convertNonExactBigDecimalToBigInteger() { BigDecimal decimal = new BigDecimal("987459837583750387355346.14"); assertThat(NumberUtils.convertNumberToTargetClass(decimal, BigInteger.class)).isEqualTo(new BigInteger("987459837583750387355346")); } @Test - public void parseBigDecimalNumber1() { + void parseBigDecimalNumber1() { String bigDecimalAsString = "0.10"; Number bigDecimal = NumberUtils.parseNumber(bigDecimalAsString, BigDecimal.class); assertThat(bigDecimal).isEqualTo(new BigDecimal(bigDecimalAsString)); } @Test - public void parseBigDecimalNumber2() { + void parseBigDecimalNumber2() { String bigDecimalAsString = "0.001"; Number bigDecimal = NumberUtils.parseNumber(bigDecimalAsString, BigDecimal.class); assertThat(bigDecimal).isEqualTo(new BigDecimal(bigDecimalAsString)); } @Test - public void parseBigDecimalNumber3() { + void parseBigDecimalNumber3() { String bigDecimalAsString = "3.14159265358979323846"; Number bigDecimal = NumberUtils.parseNumber(bigDecimalAsString, BigDecimal.class); assertThat(bigDecimal).isEqualTo(new BigDecimal(bigDecimalAsString)); } @Test - public void parseLocalizedBigDecimalNumber1() { + void parseLocalizedBigDecimalNumber1() { String bigDecimalAsString = "0.10"; NumberFormat numberFormat = NumberFormat.getInstance(Locale.ENGLISH); Number bigDecimal = NumberUtils.parseNumber(bigDecimalAsString, BigDecimal.class, numberFormat); @@ -181,7 +181,7 @@ public class NumberUtilsTests { } @Test - public void parseLocalizedBigDecimalNumber2() { + void parseLocalizedBigDecimalNumber2() { String bigDecimalAsString = "0.001"; NumberFormat numberFormat = NumberFormat.getInstance(Locale.ENGLISH); Number bigDecimal = NumberUtils.parseNumber(bigDecimalAsString, BigDecimal.class, numberFormat); @@ -189,7 +189,7 @@ public class NumberUtilsTests { } @Test - public void parseLocalizedBigDecimalNumber3() { + void parseLocalizedBigDecimalNumber3() { String bigDecimalAsString = "3.14159265358979323846"; NumberFormat numberFormat = NumberFormat.getInstance(Locale.ENGLISH); Number bigDecimal = NumberUtils.parseNumber(bigDecimalAsString, BigDecimal.class, numberFormat); @@ -197,7 +197,7 @@ public class NumberUtilsTests { } @Test - public void parseOverflow() { + void parseOverflow() { String aLong = "" + Long.MAX_VALUE; String aDouble = "" + Double.MAX_VALUE; @@ -215,7 +215,7 @@ public class NumberUtilsTests { } @Test - public void parseNegativeOverflow() { + void parseNegativeOverflow() { String aLong = "" + Long.MIN_VALUE; String aDouble = "" + Double.MIN_VALUE; @@ -233,7 +233,7 @@ public class NumberUtilsTests { } @Test - public void parseOverflowUsingNumberFormat() { + void parseOverflowUsingNumberFormat() { NumberFormat nf = NumberFormat.getNumberInstance(Locale.US); String aLong = "" + Long.MAX_VALUE; String aDouble = "" + Double.MAX_VALUE; @@ -252,7 +252,7 @@ public class NumberUtilsTests { } @Test - public void parseNegativeOverflowUsingNumberFormat() { + void parseNegativeOverflowUsingNumberFormat() { NumberFormat nf = NumberFormat.getNumberInstance(Locale.US); String aLong = "" + Long.MIN_VALUE; String aDouble = "" + Double.MIN_VALUE; @@ -271,7 +271,7 @@ public class NumberUtilsTests { } @Test - public void convertToInteger() { + void convertToInteger() { assertThat(NumberUtils.convertNumberToTargetClass(BigInteger.valueOf(-1), Integer.class)).isEqualTo(Integer.valueOf(Integer.valueOf(-1))); assertThat(NumberUtils.convertNumberToTargetClass(BigInteger.valueOf(0), Integer.class)).isEqualTo(Integer.valueOf(Integer.valueOf(0))); assertThat(NumberUtils.convertNumberToTargetClass(BigInteger.valueOf(1), Integer.class)).isEqualTo(Integer.valueOf(Integer.valueOf(1))); @@ -320,7 +320,7 @@ public class NumberUtilsTests { } @Test - public void convertToLong() { + void convertToLong() { assertThat(NumberUtils.convertNumberToTargetClass(BigInteger.valueOf(-1), Long.class)).isEqualTo(Long.valueOf(Long.valueOf(-1))); assertThat(NumberUtils.convertNumberToTargetClass(BigInteger.valueOf(0), Long.class)).isEqualTo(Long.valueOf(Long.valueOf(0))); assertThat(NumberUtils.convertNumberToTargetClass(BigInteger.valueOf(1), Long.class)).isEqualTo(Long.valueOf(Long.valueOf(1))); diff --git a/spring-core/src/test/java/org/springframework/util/ObjectUtilsTests.java b/spring-core/src/test/java/org/springframework/util/ObjectUtilsTests.java index 401099ab2a..b07a5558c2 100644 --- a/spring-core/src/test/java/org/springframework/util/ObjectUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/util/ObjectUtilsTests.java @@ -38,10 +38,10 @@ import static org.springframework.util.ObjectUtils.isEmpty; * @author Rick Evans * @author Sam Brannen */ -public class ObjectUtilsTests { +class ObjectUtilsTests { @Test - public void isCheckedException() { + void isCheckedException() { assertThat(ObjectUtils.isCheckedException(new Exception())).isTrue(); assertThat(ObjectUtils.isCheckedException(new SQLException())).isTrue(); @@ -54,7 +54,7 @@ public class ObjectUtilsTests { } @Test - public void isCompatibleWithThrowsClause() { + void isCompatibleWithThrowsClause() { Class[] empty = new Class[0]; Class[] exception = new Class[] {Exception.class}; Class[] sqlAndIO = new Class[] {SQLException.class, IOException.class}; @@ -86,12 +86,12 @@ public class ObjectUtilsTests { } @Test - public void isEmptyNull() { + void isEmptyNull() { assertThat(isEmpty(null)).isTrue(); } @Test - public void isEmptyArray() { + void isEmptyArray() { assertThat(isEmpty(new char[0])).isTrue(); assertThat(isEmpty(new Object[0])).isTrue(); assertThat(isEmpty(new Integer[0])).isTrue(); @@ -101,7 +101,7 @@ public class ObjectUtilsTests { } @Test - public void isEmptyCollection() { + void isEmptyCollection() { assertThat(isEmpty(Collections.emptyList())).isTrue(); assertThat(isEmpty(Collections.emptySet())).isTrue(); @@ -112,7 +112,7 @@ public class ObjectUtilsTests { } @Test - public void isEmptyMap() { + void isEmptyMap() { assertThat(isEmpty(Collections.emptyMap())).isTrue(); HashMap map = new HashMap<>(); @@ -121,7 +121,7 @@ public class ObjectUtilsTests { } @Test - public void isEmptyCharSequence() { + void isEmptyCharSequence() { assertThat(isEmpty(new StringBuilder())).isTrue(); assertThat(isEmpty("")).isTrue(); @@ -132,13 +132,13 @@ public class ObjectUtilsTests { } @Test - public void isEmptyUnsupportedObjectType() { + void isEmptyUnsupportedObjectType() { assertThat(isEmpty(42L)).isFalse(); assertThat(isEmpty(new Object())).isFalse(); } @Test - public void toObjectArray() { + void toObjectArray() { int[] a = new int[] {1, 2, 3, 4, 5}; Integer[] wrapper = (Integer[]) ObjectUtils.toObjectArray(a); assertThat(wrapper.length == 5).isTrue(); @@ -148,33 +148,33 @@ public class ObjectUtilsTests { } @Test - public void toObjectArrayWithNull() { + void toObjectArrayWithNull() { Object[] objects = ObjectUtils.toObjectArray(null); assertThat(objects).isNotNull(); assertThat(objects.length).isEqualTo(0); } @Test - public void toObjectArrayWithEmptyPrimitiveArray() { + void toObjectArrayWithEmptyPrimitiveArray() { Object[] objects = ObjectUtils.toObjectArray(new byte[] {}); assertThat(objects).isNotNull(); assertThat(objects.length).isEqualTo(0); } @Test - public void toObjectArrayWithNonArrayType() { + void toObjectArrayWithNonArrayType() { assertThatIllegalArgumentException().isThrownBy(() -> ObjectUtils.toObjectArray("Not an []")); } @Test - public void toObjectArrayWithNonPrimitiveArray() { + void toObjectArrayWithNonPrimitiveArray() { String[] source = new String[] {"Bingo"}; assertThat(ObjectUtils.toObjectArray(source)).isEqualTo(source); } @Test - public void addObjectToArraySunnyDay() { + void addObjectToArraySunnyDay() { String[] array = new String[] {"foo", "bar"}; String newElement = "baz"; Object[] newArray = ObjectUtils.addObjectToArray(array, newElement); @@ -183,7 +183,7 @@ public class ObjectUtilsTests { } @Test - public void addObjectToArrayWhenEmpty() { + void addObjectToArrayWhenEmpty() { String[] array = new String[0]; String newElement = "foo"; String[] newArray = ObjectUtils.addObjectToArray(array, newElement); @@ -192,7 +192,7 @@ public class ObjectUtilsTests { } @Test - public void addObjectToSingleNonNullElementArray() { + void addObjectToSingleNonNullElementArray() { String existingElement = "foo"; String[] array = new String[] {existingElement}; String newElement = "bar"; @@ -203,7 +203,7 @@ public class ObjectUtilsTests { } @Test - public void addObjectToSingleNullElementArray() { + void addObjectToSingleNullElementArray() { String[] array = new String[] {null}; String newElement = "bar"; String[] newArray = ObjectUtils.addObjectToArray(array, newElement); @@ -213,7 +213,7 @@ public class ObjectUtilsTests { } @Test - public void addObjectToNullArray() throws Exception { + void addObjectToNullArray() throws Exception { String newElement = "foo"; String[] newArray = ObjectUtils.addObjectToArray(null, newElement); assertThat(newArray.length).isEqualTo(1); @@ -221,35 +221,35 @@ public class ObjectUtilsTests { } @Test - public void addNullObjectToNullArray() throws Exception { + void addNullObjectToNullArray() throws Exception { Object[] newArray = ObjectUtils.addObjectToArray(null, null); assertThat(newArray.length).isEqualTo(1); assertThat(newArray[0]).isEqualTo(null); } @Test - public void nullSafeEqualsWithArrays() throws Exception { + void nullSafeEqualsWithArrays() throws Exception { assertThat(ObjectUtils.nullSafeEquals(new String[] {"a", "b", "c"}, new String[] {"a", "b", "c"})).isTrue(); assertThat(ObjectUtils.nullSafeEquals(new int[] {1, 2, 3}, new int[] {1, 2, 3})).isTrue(); } @Test @Deprecated - public void hashCodeWithBooleanFalse() { + void hashCodeWithBooleanFalse() { int expected = Boolean.FALSE.hashCode(); assertThat(ObjectUtils.hashCode(false)).isEqualTo(expected); } @Test @Deprecated - public void hashCodeWithBooleanTrue() { + void hashCodeWithBooleanTrue() { int expected = Boolean.TRUE.hashCode(); assertThat(ObjectUtils.hashCode(true)).isEqualTo(expected); } @Test @Deprecated - public void hashCodeWithDouble() { + void hashCodeWithDouble() { double dbl = 9830.43; int expected = (new Double(dbl)).hashCode(); assertThat(ObjectUtils.hashCode(dbl)).isEqualTo(expected); @@ -257,7 +257,7 @@ public class ObjectUtilsTests { @Test @Deprecated - public void hashCodeWithFloat() { + void hashCodeWithFloat() { float flt = 34.8f; int expected = (new Float(flt)).hashCode(); assertThat(ObjectUtils.hashCode(flt)).isEqualTo(expected); @@ -265,14 +265,14 @@ public class ObjectUtilsTests { @Test @Deprecated - public void hashCodeWithLong() { + void hashCodeWithLong() { long lng = 883L; int expected = (new Long(lng)).hashCode(); assertThat(ObjectUtils.hashCode(lng)).isEqualTo(expected); } @Test - public void identityToString() { + void identityToString() { Object obj = new Object(); String expected = obj.getClass().getName() + "@" + ObjectUtils.getIdentityHexString(obj); String actual = ObjectUtils.identityToString(obj); @@ -280,112 +280,112 @@ public class ObjectUtilsTests { } @Test - public void identityToStringWithNullObject() { + void identityToStringWithNullObject() { assertThat(ObjectUtils.identityToString(null)).isEqualTo(""); } @Test - public void isArrayOfPrimitivesWithBooleanArray() { + void isArrayOfPrimitivesWithBooleanArray() { assertThat(ClassUtils.isPrimitiveArray(boolean[].class)).isTrue(); } @Test - public void isArrayOfPrimitivesWithObjectArray() { + void isArrayOfPrimitivesWithObjectArray() { assertThat(ClassUtils.isPrimitiveArray(Object[].class)).isFalse(); } @Test - public void isArrayOfPrimitivesWithNonArray() { + void isArrayOfPrimitivesWithNonArray() { assertThat(ClassUtils.isPrimitiveArray(String.class)).isFalse(); } @Test - public void isPrimitiveOrWrapperWithBooleanPrimitiveClass() { + void isPrimitiveOrWrapperWithBooleanPrimitiveClass() { assertThat(ClassUtils.isPrimitiveOrWrapper(boolean.class)).isTrue(); } @Test - public void isPrimitiveOrWrapperWithBooleanWrapperClass() { + void isPrimitiveOrWrapperWithBooleanWrapperClass() { assertThat(ClassUtils.isPrimitiveOrWrapper(Boolean.class)).isTrue(); } @Test - public void isPrimitiveOrWrapperWithBytePrimitiveClass() { + void isPrimitiveOrWrapperWithBytePrimitiveClass() { assertThat(ClassUtils.isPrimitiveOrWrapper(byte.class)).isTrue(); } @Test - public void isPrimitiveOrWrapperWithByteWrapperClass() { + void isPrimitiveOrWrapperWithByteWrapperClass() { assertThat(ClassUtils.isPrimitiveOrWrapper(Byte.class)).isTrue(); } @Test - public void isPrimitiveOrWrapperWithCharacterClass() { + void isPrimitiveOrWrapperWithCharacterClass() { assertThat(ClassUtils.isPrimitiveOrWrapper(Character.class)).isTrue(); } @Test - public void isPrimitiveOrWrapperWithCharClass() { + void isPrimitiveOrWrapperWithCharClass() { assertThat(ClassUtils.isPrimitiveOrWrapper(char.class)).isTrue(); } @Test - public void isPrimitiveOrWrapperWithDoublePrimitiveClass() { + void isPrimitiveOrWrapperWithDoublePrimitiveClass() { assertThat(ClassUtils.isPrimitiveOrWrapper(double.class)).isTrue(); } @Test - public void isPrimitiveOrWrapperWithDoubleWrapperClass() { + void isPrimitiveOrWrapperWithDoubleWrapperClass() { assertThat(ClassUtils.isPrimitiveOrWrapper(Double.class)).isTrue(); } @Test - public void isPrimitiveOrWrapperWithFloatPrimitiveClass() { + void isPrimitiveOrWrapperWithFloatPrimitiveClass() { assertThat(ClassUtils.isPrimitiveOrWrapper(float.class)).isTrue(); } @Test - public void isPrimitiveOrWrapperWithFloatWrapperClass() { + void isPrimitiveOrWrapperWithFloatWrapperClass() { assertThat(ClassUtils.isPrimitiveOrWrapper(Float.class)).isTrue(); } @Test - public void isPrimitiveOrWrapperWithIntClass() { + void isPrimitiveOrWrapperWithIntClass() { assertThat(ClassUtils.isPrimitiveOrWrapper(int.class)).isTrue(); } @Test - public void isPrimitiveOrWrapperWithIntegerClass() { + void isPrimitiveOrWrapperWithIntegerClass() { assertThat(ClassUtils.isPrimitiveOrWrapper(Integer.class)).isTrue(); } @Test - public void isPrimitiveOrWrapperWithLongPrimitiveClass() { + void isPrimitiveOrWrapperWithLongPrimitiveClass() { assertThat(ClassUtils.isPrimitiveOrWrapper(long.class)).isTrue(); } @Test - public void isPrimitiveOrWrapperWithLongWrapperClass() { + void isPrimitiveOrWrapperWithLongWrapperClass() { assertThat(ClassUtils.isPrimitiveOrWrapper(Long.class)).isTrue(); } @Test - public void isPrimitiveOrWrapperWithNonPrimitiveOrWrapperClass() { + void isPrimitiveOrWrapperWithNonPrimitiveOrWrapperClass() { assertThat(ClassUtils.isPrimitiveOrWrapper(Object.class)).isFalse(); } @Test - public void isPrimitiveOrWrapperWithShortPrimitiveClass() { + void isPrimitiveOrWrapperWithShortPrimitiveClass() { assertThat(ClassUtils.isPrimitiveOrWrapper(short.class)).isTrue(); } @Test - public void isPrimitiveOrWrapperWithShortWrapperClass() { + void isPrimitiveOrWrapperWithShortWrapperClass() { assertThat(ClassUtils.isPrimitiveOrWrapper(Short.class)).isTrue(); } @Test - public void nullSafeHashCodeWithBooleanArray() { + void nullSafeHashCodeWithBooleanArray() { int expected = 31 * 7 + Boolean.TRUE.hashCode(); expected = 31 * expected + Boolean.FALSE.hashCode(); @@ -396,12 +396,12 @@ public class ObjectUtilsTests { } @Test - public void nullSafeHashCodeWithBooleanArrayEqualToNull() { + void nullSafeHashCodeWithBooleanArrayEqualToNull() { assertThat(ObjectUtils.nullSafeHashCode((boolean[]) null)).isEqualTo(0); } @Test - public void nullSafeHashCodeWithByteArray() { + void nullSafeHashCodeWithByteArray() { int expected = 31 * 7 + 8; expected = 31 * expected + 10; @@ -412,12 +412,12 @@ public class ObjectUtilsTests { } @Test - public void nullSafeHashCodeWithByteArrayEqualToNull() { + void nullSafeHashCodeWithByteArrayEqualToNull() { assertThat(ObjectUtils.nullSafeHashCode((byte[]) null)).isEqualTo(0); } @Test - public void nullSafeHashCodeWithCharArray() { + void nullSafeHashCodeWithCharArray() { int expected = 31 * 7 + 'a'; expected = 31 * expected + 'E'; @@ -428,12 +428,12 @@ public class ObjectUtilsTests { } @Test - public void nullSafeHashCodeWithCharArrayEqualToNull() { + void nullSafeHashCodeWithCharArrayEqualToNull() { assertThat(ObjectUtils.nullSafeHashCode((char[]) null)).isEqualTo(0); } @Test - public void nullSafeHashCodeWithDoubleArray() { + void nullSafeHashCodeWithDoubleArray() { long bits = Double.doubleToLongBits(8449.65); int expected = 31 * 7 + (int) (bits ^ (bits >>> 32)); bits = Double.doubleToLongBits(9944.923); @@ -446,12 +446,12 @@ public class ObjectUtilsTests { } @Test - public void nullSafeHashCodeWithDoubleArrayEqualToNull() { + void nullSafeHashCodeWithDoubleArrayEqualToNull() { assertThat(ObjectUtils.nullSafeHashCode((double[]) null)).isEqualTo(0); } @Test - public void nullSafeHashCodeWithFloatArray() { + void nullSafeHashCodeWithFloatArray() { int expected = 31 * 7 + Float.floatToIntBits(9.6f); expected = 31 * expected + Float.floatToIntBits(7.4f); @@ -462,12 +462,12 @@ public class ObjectUtilsTests { } @Test - public void nullSafeHashCodeWithFloatArrayEqualToNull() { + void nullSafeHashCodeWithFloatArrayEqualToNull() { assertThat(ObjectUtils.nullSafeHashCode((float[]) null)).isEqualTo(0); } @Test - public void nullSafeHashCodeWithIntArray() { + void nullSafeHashCodeWithIntArray() { int expected = 31 * 7 + 884; expected = 31 * expected + 340; @@ -478,12 +478,12 @@ public class ObjectUtilsTests { } @Test - public void nullSafeHashCodeWithIntArrayEqualToNull() { + void nullSafeHashCodeWithIntArrayEqualToNull() { assertThat(ObjectUtils.nullSafeHashCode((int[]) null)).isEqualTo(0); } @Test - public void nullSafeHashCodeWithLongArray() { + void nullSafeHashCodeWithLongArray() { long lng = 7993L; int expected = 31 * 7 + (int) (lng ^ (lng >>> 32)); lng = 84320L; @@ -496,18 +496,18 @@ public class ObjectUtilsTests { } @Test - public void nullSafeHashCodeWithLongArrayEqualToNull() { + void nullSafeHashCodeWithLongArrayEqualToNull() { assertThat(ObjectUtils.nullSafeHashCode((long[]) null)).isEqualTo(0); } @Test - public void nullSafeHashCodeWithObject() { + void nullSafeHashCodeWithObject() { String str = "Luke"; assertThat(ObjectUtils.nullSafeHashCode(str)).isEqualTo(str.hashCode()); } @Test - public void nullSafeHashCodeWithObjectArray() { + void nullSafeHashCodeWithObjectArray() { int expected = 31 * 7 + "Leia".hashCode(); expected = 31 * expected + "Han".hashCode(); @@ -518,80 +518,80 @@ public class ObjectUtilsTests { } @Test - public void nullSafeHashCodeWithObjectArrayEqualToNull() { + void nullSafeHashCodeWithObjectArrayEqualToNull() { assertThat(ObjectUtils.nullSafeHashCode((Object[]) null)).isEqualTo(0); } @Test - public void nullSafeHashCodeWithObjectBeingBooleanArray() { + void nullSafeHashCodeWithObjectBeingBooleanArray() { Object array = new boolean[] {true, false}; int expected = ObjectUtils.nullSafeHashCode((boolean[]) array); assertEqualHashCodes(expected, array); } @Test - public void nullSafeHashCodeWithObjectBeingByteArray() { + void nullSafeHashCodeWithObjectBeingByteArray() { Object array = new byte[] {6, 39}; int expected = ObjectUtils.nullSafeHashCode((byte[]) array); assertEqualHashCodes(expected, array); } @Test - public void nullSafeHashCodeWithObjectBeingCharArray() { + void nullSafeHashCodeWithObjectBeingCharArray() { Object array = new char[] {'l', 'M'}; int expected = ObjectUtils.nullSafeHashCode((char[]) array); assertEqualHashCodes(expected, array); } @Test - public void nullSafeHashCodeWithObjectBeingDoubleArray() { + void nullSafeHashCodeWithObjectBeingDoubleArray() { Object array = new double[] {68930.993, 9022.009}; int expected = ObjectUtils.nullSafeHashCode((double[]) array); assertEqualHashCodes(expected, array); } @Test - public void nullSafeHashCodeWithObjectBeingFloatArray() { + void nullSafeHashCodeWithObjectBeingFloatArray() { Object array = new float[] {9.9f, 9.54f}; int expected = ObjectUtils.nullSafeHashCode((float[]) array); assertEqualHashCodes(expected, array); } @Test - public void nullSafeHashCodeWithObjectBeingIntArray() { + void nullSafeHashCodeWithObjectBeingIntArray() { Object array = new int[] {89, 32}; int expected = ObjectUtils.nullSafeHashCode((int[]) array); assertEqualHashCodes(expected, array); } @Test - public void nullSafeHashCodeWithObjectBeingLongArray() { + void nullSafeHashCodeWithObjectBeingLongArray() { Object array = new long[] {4389, 320}; int expected = ObjectUtils.nullSafeHashCode((long[]) array); assertEqualHashCodes(expected, array); } @Test - public void nullSafeHashCodeWithObjectBeingObjectArray() { + void nullSafeHashCodeWithObjectBeingObjectArray() { Object array = new Object[] {"Luke", "Anakin"}; int expected = ObjectUtils.nullSafeHashCode((Object[]) array); assertEqualHashCodes(expected, array); } @Test - public void nullSafeHashCodeWithObjectBeingShortArray() { + void nullSafeHashCodeWithObjectBeingShortArray() { Object array = new short[] {5, 3}; int expected = ObjectUtils.nullSafeHashCode((short[]) array); assertEqualHashCodes(expected, array); } @Test - public void nullSafeHashCodeWithObjectEqualToNull() { + void nullSafeHashCodeWithObjectEqualToNull() { assertThat(ObjectUtils.nullSafeHashCode((Object) null)).isEqualTo(0); } @Test - public void nullSafeHashCodeWithShortArray() { + void nullSafeHashCodeWithShortArray() { int expected = 31 * 7 + 70; expected = 31 * expected + 8; @@ -602,187 +602,187 @@ public class ObjectUtilsTests { } @Test - public void nullSafeHashCodeWithShortArrayEqualToNull() { + void nullSafeHashCodeWithShortArrayEqualToNull() { assertThat(ObjectUtils.nullSafeHashCode((short[]) null)).isEqualTo(0); } @Test - public void nullSafeToStringWithBooleanArray() { + void nullSafeToStringWithBooleanArray() { boolean[] array = {true, false}; assertThat(ObjectUtils.nullSafeToString(array)).isEqualTo("{true, false}"); } @Test - public void nullSafeToStringWithBooleanArrayBeingEmpty() { + void nullSafeToStringWithBooleanArrayBeingEmpty() { boolean[] array = {}; assertThat(ObjectUtils.nullSafeToString(array)).isEqualTo("{}"); } @Test - public void nullSafeToStringWithBooleanArrayEqualToNull() { + void nullSafeToStringWithBooleanArrayEqualToNull() { assertThat(ObjectUtils.nullSafeToString((boolean[]) null)).isEqualTo("null"); } @Test - public void nullSafeToStringWithByteArray() { + void nullSafeToStringWithByteArray() { byte[] array = {5, 8}; assertThat(ObjectUtils.nullSafeToString(array)).isEqualTo("{5, 8}"); } @Test - public void nullSafeToStringWithByteArrayBeingEmpty() { + void nullSafeToStringWithByteArrayBeingEmpty() { byte[] array = {}; assertThat(ObjectUtils.nullSafeToString(array)).isEqualTo("{}"); } @Test - public void nullSafeToStringWithByteArrayEqualToNull() { + void nullSafeToStringWithByteArrayEqualToNull() { assertThat(ObjectUtils.nullSafeToString((byte[]) null)).isEqualTo("null"); } @Test - public void nullSafeToStringWithCharArray() { + void nullSafeToStringWithCharArray() { char[] array = {'A', 'B'}; assertThat(ObjectUtils.nullSafeToString(array)).isEqualTo("{'A', 'B'}"); } @Test - public void nullSafeToStringWithCharArrayBeingEmpty() { + void nullSafeToStringWithCharArrayBeingEmpty() { char[] array = {}; assertThat(ObjectUtils.nullSafeToString(array)).isEqualTo("{}"); } @Test - public void nullSafeToStringWithCharArrayEqualToNull() { + void nullSafeToStringWithCharArrayEqualToNull() { assertThat(ObjectUtils.nullSafeToString((char[]) null)).isEqualTo("null"); } @Test - public void nullSafeToStringWithDoubleArray() { + void nullSafeToStringWithDoubleArray() { double[] array = {8594.93, 8594023.95}; assertThat(ObjectUtils.nullSafeToString(array)).isEqualTo("{8594.93, 8594023.95}"); } @Test - public void nullSafeToStringWithDoubleArrayBeingEmpty() { + void nullSafeToStringWithDoubleArrayBeingEmpty() { double[] array = {}; assertThat(ObjectUtils.nullSafeToString(array)).isEqualTo("{}"); } @Test - public void nullSafeToStringWithDoubleArrayEqualToNull() { + void nullSafeToStringWithDoubleArrayEqualToNull() { assertThat(ObjectUtils.nullSafeToString((double[]) null)).isEqualTo("null"); } @Test - public void nullSafeToStringWithFloatArray() { + void nullSafeToStringWithFloatArray() { float[] array = {8.6f, 43.8f}; assertThat(ObjectUtils.nullSafeToString(array)).isEqualTo("{8.6, 43.8}"); } @Test - public void nullSafeToStringWithFloatArrayBeingEmpty() { + void nullSafeToStringWithFloatArrayBeingEmpty() { float[] array = {}; assertThat(ObjectUtils.nullSafeToString(array)).isEqualTo("{}"); } @Test - public void nullSafeToStringWithFloatArrayEqualToNull() { + void nullSafeToStringWithFloatArrayEqualToNull() { assertThat(ObjectUtils.nullSafeToString((float[]) null)).isEqualTo("null"); } @Test - public void nullSafeToStringWithIntArray() { + void nullSafeToStringWithIntArray() { int[] array = {9, 64}; assertThat(ObjectUtils.nullSafeToString(array)).isEqualTo("{9, 64}"); } @Test - public void nullSafeToStringWithIntArrayBeingEmpty() { + void nullSafeToStringWithIntArrayBeingEmpty() { int[] array = {}; assertThat(ObjectUtils.nullSafeToString(array)).isEqualTo("{}"); } @Test - public void nullSafeToStringWithIntArrayEqualToNull() { + void nullSafeToStringWithIntArrayEqualToNull() { assertThat(ObjectUtils.nullSafeToString((int[]) null)).isEqualTo("null"); } @Test - public void nullSafeToStringWithLongArray() { + void nullSafeToStringWithLongArray() { long[] array = {434L, 23423L}; assertThat(ObjectUtils.nullSafeToString(array)).isEqualTo("{434, 23423}"); } @Test - public void nullSafeToStringWithLongArrayBeingEmpty() { + void nullSafeToStringWithLongArrayBeingEmpty() { long[] array = {}; assertThat(ObjectUtils.nullSafeToString(array)).isEqualTo("{}"); } @Test - public void nullSafeToStringWithLongArrayEqualToNull() { + void nullSafeToStringWithLongArrayEqualToNull() { assertThat(ObjectUtils.nullSafeToString((long[]) null)).isEqualTo("null"); } @Test - public void nullSafeToStringWithPlainOldString() { + void nullSafeToStringWithPlainOldString() { assertThat(ObjectUtils.nullSafeToString("I shoh love tha taste of mangoes")).isEqualTo("I shoh love tha taste of mangoes"); } @Test - public void nullSafeToStringWithObjectArray() { + void nullSafeToStringWithObjectArray() { Object[] array = {"Han", Long.valueOf(43)}; assertThat(ObjectUtils.nullSafeToString(array)).isEqualTo("{Han, 43}"); } @Test - public void nullSafeToStringWithObjectArrayBeingEmpty() { + void nullSafeToStringWithObjectArrayBeingEmpty() { Object[] array = {}; assertThat(ObjectUtils.nullSafeToString(array)).isEqualTo("{}"); } @Test - public void nullSafeToStringWithObjectArrayEqualToNull() { + void nullSafeToStringWithObjectArrayEqualToNull() { assertThat(ObjectUtils.nullSafeToString((Object[]) null)).isEqualTo("null"); } @Test - public void nullSafeToStringWithShortArray() { + void nullSafeToStringWithShortArray() { short[] array = {7, 9}; assertThat(ObjectUtils.nullSafeToString(array)).isEqualTo("{7, 9}"); } @Test - public void nullSafeToStringWithShortArrayBeingEmpty() { + void nullSafeToStringWithShortArrayBeingEmpty() { short[] array = {}; assertThat(ObjectUtils.nullSafeToString(array)).isEqualTo("{}"); } @Test - public void nullSafeToStringWithShortArrayEqualToNull() { + void nullSafeToStringWithShortArrayEqualToNull() { assertThat(ObjectUtils.nullSafeToString((short[]) null)).isEqualTo("null"); } @Test - public void nullSafeToStringWithStringArray() { + void nullSafeToStringWithStringArray() { String[] array = {"Luke", "Anakin"}; assertThat(ObjectUtils.nullSafeToString(array)).isEqualTo("{Luke, Anakin}"); } @Test - public void nullSafeToStringWithStringArrayBeingEmpty() { + void nullSafeToStringWithStringArrayBeingEmpty() { String[] array = {}; assertThat(ObjectUtils.nullSafeToString(array)).isEqualTo("{}"); } @Test - public void nullSafeToStringWithStringArrayEqualToNull() { + void nullSafeToStringWithStringArrayEqualToNull() { assertThat(ObjectUtils.nullSafeToString((String[]) null)).isEqualTo("null"); } @Test - public void containsConstant() { + void containsConstant() { assertThat(ObjectUtils.containsConstant(Tropes.values(), "FOO")).isTrue(); assertThat(ObjectUtils.containsConstant(Tropes.values(), "foo")).isTrue(); assertThat(ObjectUtils.containsConstant(Tropes.values(), "BaR")).isTrue(); @@ -797,7 +797,7 @@ public class ObjectUtilsTests { } @Test - public void caseInsensitiveValueOf() { + void caseInsensitiveValueOf() { assertThat(ObjectUtils.caseInsensitiveValueOf(Tropes.values(), "foo")).isEqualTo(Tropes.FOO); assertThat(ObjectUtils.caseInsensitiveValueOf(Tropes.values(), "BAR")).isEqualTo(Tropes.BAR); diff --git a/spring-core/src/test/java/org/springframework/util/PatternMatchUtilsTests.java b/spring-core/src/test/java/org/springframework/util/PatternMatchUtilsTests.java index fad6016cb4..7a42db56fe 100644 --- a/spring-core/src/test/java/org/springframework/util/PatternMatchUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/util/PatternMatchUtilsTests.java @@ -24,10 +24,10 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Juergen Hoeller * @author Johan Gorter */ -public class PatternMatchUtilsTests { +class PatternMatchUtilsTests { @Test - public void testTrivial() { + void trivial() { assertThat(PatternMatchUtils.simpleMatch((String) null, "")).isEqualTo(false); assertThat(PatternMatchUtils.simpleMatch("1", null)).isEqualTo(false); doTest("*", "123", true); @@ -35,19 +35,19 @@ public class PatternMatchUtilsTests { } @Test - public void testStartsWith() { + void startsWith() { doTest("get*", "getMe", true); doTest("get*", "setMe", false); } @Test - public void testEndsWith() { + void endsWith() { doTest("*Test", "getMeTest", true); doTest("*Test", "setMe", false); } @Test - public void testBetween() { + void between() { doTest("*stuff*", "getMeTest", false); doTest("*stuff*", "getstuffTest", true); doTest("*stuff*", "stuffTest", true); @@ -56,7 +56,7 @@ public class PatternMatchUtilsTests { } @Test - public void testStartsEnds() { + void startsEnds() { doTest("on*Event", "onMyEvent", true); doTest("on*Event", "onEvent", true); doTest("3*3", "3", false); @@ -64,7 +64,7 @@ public class PatternMatchUtilsTests { } @Test - public void testStartsEndsBetween() { + void startsEndsBetween() { doTest("12*45*78", "12345678", true); doTest("12*45*78", "123456789", false); doTest("12*45*78", "012345678", false); @@ -75,7 +75,7 @@ public class PatternMatchUtilsTests { } @Test - public void testRidiculous() { + void ridiculous() { doTest("*1*2*3*", "0011002001010030020201030", true); doTest("1*2*3*4", "10300204", false); doTest("1*2*3*3", "10300203", false); @@ -84,7 +84,7 @@ public class PatternMatchUtilsTests { } @Test - public void testPatternVariants() { + void patternVariants() { doTest("*a", "*", false); doTest("*a", "a", true); doTest("*a", "b", false); diff --git a/spring-core/src/test/java/org/springframework/util/PropertiesPersisterTests.java b/spring-core/src/test/java/org/springframework/util/PropertiesPersisterTests.java index e5a00bb7ba..f24acf3562 100644 --- a/spring-core/src/test/java/org/springframework/util/PropertiesPersisterTests.java +++ b/spring-core/src/test/java/org/springframework/util/PropertiesPersisterTests.java @@ -31,10 +31,10 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Juergen Hoeller * @since 11.01.2005 */ -public class PropertiesPersisterTests { +class PropertiesPersisterTests { @Test - public void propertiesPersister() throws IOException { + void propertiesPersister() throws IOException { String propString = "code1=message1\ncode2:message2"; Properties props = loadProperties(propString, false); String propCopy = storeProperties(props, null, false); @@ -42,7 +42,7 @@ public class PropertiesPersisterTests { } @Test - public void propertiesPersisterWithWhitespace() throws IOException { + void propertiesPersisterWithWhitespace() throws IOException { String propString = " code1\t= \tmessage1\n code2 \t :\t mess\\\n \t age2"; Properties props = loadProperties(propString, false); String propCopy = storeProperties(props, null, false); @@ -50,7 +50,7 @@ public class PropertiesPersisterTests { } @Test - public void propertiesPersisterWithHeader() throws IOException { + void propertiesPersisterWithHeader() throws IOException { String propString = "code1=message1\ncode2:message2"; Properties props = loadProperties(propString, false); String propCopy = storeProperties(props, "myHeader", false); @@ -58,7 +58,7 @@ public class PropertiesPersisterTests { } @Test - public void propertiesPersisterWithEmptyValue() throws IOException { + void propertiesPersisterWithEmptyValue() throws IOException { String propString = "code1=message1\ncode2:message2\ncode3="; Properties props = loadProperties(propString, false); String propCopy = storeProperties(props, null, false); @@ -66,7 +66,7 @@ public class PropertiesPersisterTests { } @Test - public void propertiesPersisterWithReader() throws IOException { + void propertiesPersisterWithReader() throws IOException { String propString = "code1=message1\ncode2:message2"; Properties props = loadProperties(propString, true); String propCopy = storeProperties(props, null, true); @@ -74,7 +74,7 @@ public class PropertiesPersisterTests { } @Test - public void propertiesPersisterWithReaderAndWhitespace() throws IOException { + void propertiesPersisterWithReaderAndWhitespace() throws IOException { String propString = " code1\t= \tmessage1\n code2 \t :\t mess\\\n \t age2"; Properties props = loadProperties(propString, true); String propCopy = storeProperties(props, null, true); @@ -82,7 +82,7 @@ public class PropertiesPersisterTests { } @Test - public void propertiesPersisterWithReaderAndHeader() throws IOException { + void propertiesPersisterWithReaderAndHeader() throws IOException { String propString = "code1\t=\tmessage1\n code2 \t : \t message2"; Properties props = loadProperties(propString, true); String propCopy = storeProperties(props, "myHeader", true); @@ -90,7 +90,7 @@ public class PropertiesPersisterTests { } @Test - public void propertiesPersisterWithReaderAndEmptyValue() throws IOException { + void propertiesPersisterWithReaderAndEmptyValue() throws IOException { String propString = "code1=message1\ncode2:message2\ncode3="; Properties props = loadProperties(propString, true); String propCopy = storeProperties(props, null, true); diff --git a/spring-core/src/test/java/org/springframework/util/PropertyPlaceholderHelperTests.java b/spring-core/src/test/java/org/springframework/util/PropertyPlaceholderHelperTests.java index 99fb8bdab2..92c1595b57 100644 --- a/spring-core/src/test/java/org/springframework/util/PropertyPlaceholderHelperTests.java +++ b/spring-core/src/test/java/org/springframework/util/PropertyPlaceholderHelperTests.java @@ -28,12 +28,12 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException /** * @author Rob Harrop */ -public class PropertyPlaceholderHelperTests { +class PropertyPlaceholderHelperTests { private final PropertyPlaceholderHelper helper = new PropertyPlaceholderHelper("${", "}"); @Test - public void testWithProperties() { + void withProperties() { String text = "foo=${foo}"; Properties props = new Properties(); props.setProperty("foo", "bar"); @@ -42,7 +42,7 @@ public class PropertyPlaceholderHelperTests { } @Test - public void testWithMultipleProperties() { + void withMultipleProperties() { String text = "foo=${foo},bar=${bar}"; Properties props = new Properties(); props.setProperty("foo", "bar"); @@ -52,7 +52,7 @@ public class PropertyPlaceholderHelperTests { } @Test - public void testRecurseInProperty() { + void recurseInProperty() { String text = "foo=${bar}"; Properties props = new Properties(); props.setProperty("bar", "${baz}"); @@ -62,7 +62,7 @@ public class PropertyPlaceholderHelperTests { } @Test - public void testRecurseInPlaceholder() { + void recurseInPlaceholder() { String text = "foo=${b${inner}}"; Properties props = new Properties(); props.setProperty("bar", "bar"); @@ -81,21 +81,15 @@ public class PropertyPlaceholderHelperTests { } @Test - public void testWithResolver() { + void withResolver() { String text = "foo=${foo}"; - PlaceholderResolver resolver = new PlaceholderResolver() { + PlaceholderResolver resolver = placeholderName -> "foo".equals(placeholderName) ? "bar" : null; - @Override - public String resolvePlaceholder(String placeholderName) { - return "foo".equals(placeholderName) ? "bar" : null; - } - - }; assertThat(this.helper.replacePlaceholders(text, resolver)).isEqualTo("foo=bar"); } @Test - public void testUnresolvedPlaceholderIsIgnored() { + void unresolvedPlaceholderIsIgnored() { String text = "foo=${foo},bar=${bar}"; Properties props = new Properties(); props.setProperty("foo", "bar"); @@ -104,7 +98,7 @@ public class PropertyPlaceholderHelperTests { } @Test - public void testUnresolvedPlaceholderAsError() { + void unresolvedPlaceholderAsError() { String text = "foo=${foo},bar=${bar}"; Properties props = new Properties(); props.setProperty("foo", "bar"); diff --git a/spring-core/src/test/java/org/springframework/util/ReflectionUtilsTests.java b/spring-core/src/test/java/org/springframework/util/ReflectionUtilsTests.java index f8f0f92021..cf8629948d 100644 --- a/spring-core/src/test/java/org/springframework/util/ReflectionUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/util/ReflectionUtilsTests.java @@ -40,10 +40,10 @@ import static org.springframework.tests.TestGroup.PERFORMANCE; * @author Sam Brannen * @author Arjen Poutsma */ -public class ReflectionUtilsTests { +class ReflectionUtilsTests { @Test - public void findField() { + void findField() { Field field = ReflectionUtils.findField(TestObjectSubclassWithPublicField.class, "publicField", String.class); assertThat(field).isNotNull(); assertThat(field.getName()).isEqualTo("publicField"); @@ -64,7 +64,7 @@ public class ReflectionUtilsTests { } @Test - public void setField() { + void setField() { TestObjectSubclassWithNewField testBean = new TestObjectSubclassWithNewField(); Field field = ReflectionUtils.findField(TestObjectSubclassWithNewField.class, "name", String.class); @@ -79,7 +79,7 @@ public class ReflectionUtilsTests { } @Test - public void invokeMethod() throws Exception { + void invokeMethod() throws Exception { String rob = "Rob Harrop"; TestObject bean = new TestObject(); @@ -97,7 +97,7 @@ public class ReflectionUtilsTests { } @Test - public void declaresException() throws Exception { + void declaresException() throws Exception { Method remoteExMethod = A.class.getDeclaredMethod("foo", Integer.class); assertThat(ReflectionUtils.declaresException(remoteExMethod, RemoteException.class)).isTrue(); assertThat(ReflectionUtils.declaresException(remoteExMethod, ConnectException.class)).isTrue(); @@ -112,7 +112,7 @@ public class ReflectionUtilsTests { } @Test - public void copySrcToDestinationOfIncorrectClass() { + void copySrcToDestinationOfIncorrectClass() { TestObject src = new TestObject(); String dest = new String(); assertThatIllegalArgumentException().isThrownBy(() -> @@ -120,7 +120,7 @@ public class ReflectionUtilsTests { } @Test - public void rejectsNullSrc() { + void rejectsNullSrc() { TestObject src = null; String dest = new String(); assertThatIllegalArgumentException().isThrownBy(() -> @@ -128,7 +128,7 @@ public class ReflectionUtilsTests { } @Test - public void rejectsNullDest() { + void rejectsNullDest() { TestObject src = new TestObject(); String dest = null; assertThatIllegalArgumentException().isThrownBy(() -> @@ -136,14 +136,14 @@ public class ReflectionUtilsTests { } @Test - public void validCopy() { + void validCopy() { TestObject src = new TestObject(); TestObject dest = new TestObject(); testValidCopy(src, dest); } @Test - public void validCopyOnSubTypeWithNewField() { + void validCopyOnSubTypeWithNewField() { TestObjectSubclassWithNewField src = new TestObjectSubclassWithNewField(); TestObjectSubclassWithNewField dest = new TestObjectSubclassWithNewField(); src.magic = 11; @@ -157,7 +157,7 @@ public class ReflectionUtilsTests { } @Test - public void validCopyToSubType() { + void validCopyToSubType() { TestObject src = new TestObject(); TestObjectSubclassWithNewField dest = new TestObjectSubclassWithNewField(); dest.magic = 11; @@ -167,7 +167,7 @@ public class ReflectionUtilsTests { } @Test - public void validCopyToSubTypeWithFinalField() { + void validCopyToSubTypeWithFinalField() { TestObjectSubclassWithFinalField src = new TestObjectSubclassWithFinalField(); TestObjectSubclassWithFinalField dest = new TestObjectSubclassWithFinalField(); // Check that this doesn't fail due to attempt to assign final @@ -186,7 +186,7 @@ public class ReflectionUtilsTests { } @Test - public void doWithProtectedMethods() { + void doWithProtectedMethods() { ListSavingMethodCallback mc = new ListSavingMethodCallback(); ReflectionUtils.doWithMethods(TestObject.class, mc, new ReflectionUtils.MethodFilter() { @Override @@ -202,7 +202,7 @@ public class ReflectionUtilsTests { } @Test - public void duplicatesFound() { + void duplicatesFound() { ListSavingMethodCallback mc = new ListSavingMethodCallback(); ReflectionUtils.doWithMethods(TestObjectSubclass.class, mc); int absquatulateCount = 0; @@ -215,7 +215,7 @@ public class ReflectionUtilsTests { } @Test - public void findMethod() throws Exception { + void findMethod() throws Exception { assertThat(ReflectionUtils.findMethod(B.class, "bar", String.class)).isNotNull(); assertThat(ReflectionUtils.findMethod(B.class, "foo", Integer.class)).isNotNull(); assertThat(ReflectionUtils.findMethod(B.class, "getClass")).isNotNull(); @@ -223,12 +223,12 @@ public class ReflectionUtilsTests { @Disabled("[SPR-8644] findMethod() does not currently support var-args") @Test - public void findMethodWithVarArgs() throws Exception { + void findMethodWithVarArgs() throws Exception { assertThat(ReflectionUtils.findMethod(B.class, "add", int.class, int.class, int.class)).isNotNull(); } @Test - public void isCglibRenamedMethod() throws SecurityException, NoSuchMethodException { + void isCglibRenamedMethod() throws SecurityException, NoSuchMethodException { @SuppressWarnings("unused") class C { public void CGLIB$m1$123() { @@ -266,7 +266,7 @@ public class ReflectionUtilsTests { } @Test - public void getAllDeclaredMethods() throws Exception { + void getAllDeclaredMethods() throws Exception { class Foo { @Override public String toString() { @@ -283,7 +283,7 @@ public class ReflectionUtilsTests { } @Test - public void getUniqueDeclaredMethods() throws Exception { + void getUniqueDeclaredMethods() throws Exception { class Foo { @Override public String toString() { @@ -300,7 +300,7 @@ public class ReflectionUtilsTests { } @Test - public void getUniqueDeclaredMethods_withCovariantReturnType() throws Exception { + void getUniqueDeclaredMethods_withCovariantReturnType() throws Exception { class Parent { @SuppressWarnings("unused") public Number m1() { @@ -327,7 +327,7 @@ public class ReflectionUtilsTests { @Test @EnabledForTestGroups(PERFORMANCE) - public void getUniqueDeclaredMethods_isFastEnough() { + void getUniqueDeclaredMethods_isFastEnough() { @SuppressWarnings("unused") class C { void m00() { } void m01() { } void m02() { } void m03() { } void m04() { } @@ -362,7 +362,7 @@ public class ReflectionUtilsTests { } @Test - public void getDecalredMethodsReturnsCopy() { + void getDecalredMethodsReturnsCopy() { Method[] m1 = ReflectionUtils.getDeclaredMethods(A.class); Method[] m2 = ReflectionUtils.getDeclaredMethods(A.class); assertThat(m1). isNotSameAs(m2); diff --git a/spring-core/src/test/java/org/springframework/util/ResizableByteArrayOutputStreamTests.java b/spring-core/src/test/java/org/springframework/util/ResizableByteArrayOutputStreamTests.java index 64c9f14973..8646aba648 100644 --- a/spring-core/src/test/java/org/springframework/util/ResizableByteArrayOutputStreamTests.java +++ b/spring-core/src/test/java/org/springframework/util/ResizableByteArrayOutputStreamTests.java @@ -26,7 +26,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException * @author Brian Clozel * @author Juergen Hoeller */ -public class ResizableByteArrayOutputStreamTests { +class ResizableByteArrayOutputStreamTests { private static final int INITIAL_CAPACITY = 256; @@ -36,14 +36,14 @@ public class ResizableByteArrayOutputStreamTests { @BeforeEach - public void setUp() throws Exception { + void setUp() throws Exception { this.baos = new ResizableByteArrayOutputStream(INITIAL_CAPACITY); this.helloBytes = "Hello World".getBytes("UTF-8"); } @Test - public void resize() throws Exception { + void resize() throws Exception { assertThat(this.baos.capacity()).isEqualTo(INITIAL_CAPACITY); this.baos.write(helloBytes); int size = 64; @@ -53,7 +53,7 @@ public class ResizableByteArrayOutputStreamTests { } @Test - public void autoGrow() { + void autoGrow() { assertThat(this.baos.capacity()).isEqualTo(INITIAL_CAPACITY); for (int i = 0; i < 129; i++) { this.baos.write(0); @@ -62,7 +62,7 @@ public class ResizableByteArrayOutputStreamTests { } @Test - public void grow() throws Exception { + void grow() throws Exception { assertThat(this.baos.capacity()).isEqualTo(INITIAL_CAPACITY); this.baos.write(helloBytes); this.baos.grow(1000); @@ -71,13 +71,13 @@ public class ResizableByteArrayOutputStreamTests { } @Test - public void write() throws Exception{ + void write() throws Exception{ this.baos.write(helloBytes); assertByteArrayEqualsString(this.baos); } @Test - public void failResize() throws Exception{ + void failResize() throws Exception{ this.baos.write(helloBytes); assertThatIllegalArgumentException().isThrownBy(() -> this.baos.resize(5)); diff --git a/spring-core/src/test/java/org/springframework/util/ResourceUtilsTests.java b/spring-core/src/test/java/org/springframework/util/ResourceUtilsTests.java index b65a160865..dc7b8339ac 100644 --- a/spring-core/src/test/java/org/springframework/util/ResourceUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/util/ResourceUtilsTests.java @@ -28,10 +28,10 @@ import static org.assertj.core.api.Assertions.assertThat; /** * @author Juergen Hoeller */ -public class ResourceUtilsTests { +class ResourceUtilsTests { @Test - public void isJarURL() throws Exception { + void isJarURL() throws Exception { assertThat(ResourceUtils.isJarURL(new URL("jar:file:myjar.jar!/mypath"))).isTrue(); assertThat(ResourceUtils.isJarURL(new URL(null, "zip:file:myjar.jar!/mypath", new DummyURLStreamHandler()))).isTrue(); assertThat(ResourceUtils.isJarURL(new URL(null, "wsjar:file:myjar.jar!/mypath", new DummyURLStreamHandler()))).isTrue(); @@ -41,7 +41,7 @@ public class ResourceUtilsTests { } @Test - public void extractJarFileURL() throws Exception { + void extractJarFileURL() throws Exception { assertThat(ResourceUtils.extractJarFileURL(new URL("jar:file:myjar.jar!/mypath"))).isEqualTo(new URL("file:myjar.jar")); assertThat(ResourceUtils.extractJarFileURL(new URL(null, "jar:myjar.jar!/mypath", new DummyURLStreamHandler()))).isEqualTo(new URL("file:/myjar.jar")); assertThat(ResourceUtils.extractJarFileURL(new URL(null, "zip:file:myjar.jar!/mypath", new DummyURLStreamHandler()))).isEqualTo(new URL("file:myjar.jar")); @@ -54,7 +54,7 @@ public class ResourceUtilsTests { } @Test - public void extractArchiveURL() throws Exception { + void extractArchiveURL() throws Exception { assertThat(ResourceUtils.extractArchiveURL(new URL("jar:file:myjar.jar!/mypath"))).isEqualTo(new URL("file:myjar.jar")); assertThat(ResourceUtils.extractArchiveURL(new URL(null, "jar:myjar.jar!/mypath", new DummyURLStreamHandler()))).isEqualTo(new URL("file:/myjar.jar")); assertThat(ResourceUtils.extractArchiveURL(new URL(null, "zip:file:myjar.jar!/mypath", new DummyURLStreamHandler()))).isEqualTo(new URL("file:myjar.jar")); diff --git a/spring-core/src/test/java/org/springframework/util/SerializationUtilsTests.java b/spring-core/src/test/java/org/springframework/util/SerializationUtilsTests.java index 049c462595..98abc6b718 100644 --- a/spring-core/src/test/java/org/springframework/util/SerializationUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/util/SerializationUtilsTests.java @@ -30,7 +30,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException; * @author Dave Syer * @since 3.0.5 */ -public class SerializationUtilsTests { +class SerializationUtilsTests { private static BigInteger FOO = new BigInteger( "-9702942423549012526722364838327831379660941553432801565505143675386108883970811292563757558516603356009681061" + @@ -38,36 +38,36 @@ public class SerializationUtilsTests { @Test - public void serializeCycleSunnyDay() throws Exception { + void serializeCycleSunnyDay() throws Exception { assertThat(SerializationUtils.deserialize(SerializationUtils.serialize("foo"))).isEqualTo("foo"); } @Test - public void deserializeUndefined() throws Exception { + void deserializeUndefined() throws Exception { byte[] bytes = FOO.toByteArray(); assertThatIllegalStateException().isThrownBy(() -> SerializationUtils.deserialize(bytes)); } @Test - public void serializeNonSerializable() throws Exception { + void serializeNonSerializable() throws Exception { assertThatIllegalArgumentException().isThrownBy(() -> SerializationUtils.serialize(new Object())); } @Test - public void deserializeNonSerializable() throws Exception { + void deserializeNonSerializable() throws Exception { assertThatIllegalArgumentException().isThrownBy(() -> SerializationUtils.deserialize("foo".getBytes())); } @Test - public void serializeNull() throws Exception { + void serializeNull() throws Exception { assertThat(SerializationUtils.serialize(null)).isNull(); } @Test - public void deserializeNull() throws Exception { + void deserializeNull() throws Exception { assertThat(SerializationUtils.deserialize(null)).isNull(); } diff --git a/spring-core/src/test/java/org/springframework/util/SocketUtilsTests.java b/spring-core/src/test/java/org/springframework/util/SocketUtilsTests.java index 7319d63460..fd99de863d 100644 --- a/spring-core/src/test/java/org/springframework/util/SocketUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/util/SocketUtilsTests.java @@ -36,10 +36,10 @@ import static org.springframework.util.SocketUtils.PORT_RANGE_MIN; * @author Sam Brannen * @author Gary Russell */ -public class SocketUtilsTests { +class SocketUtilsTests { @Test - public void canBeInstantiated() { + void canBeInstantiated() { // Just making sure somebody doesn't try to make SocketUtils abstract, // since that would be a breaking change due to the intentional public // constructor. @@ -49,32 +49,32 @@ public class SocketUtilsTests { // TCP @Test - public void findAvailableTcpPortWithZeroMinPort() { + void findAvailableTcpPortWithZeroMinPort() { assertThatIllegalArgumentException().isThrownBy(() -> SocketUtils.findAvailableTcpPort(0)); } @Test - public void findAvailableTcpPortWithNegativeMinPort() { + void findAvailableTcpPortWithNegativeMinPort() { assertThatIllegalArgumentException().isThrownBy(() -> SocketUtils.findAvailableTcpPort(-500)); } @Test - public void findAvailableTcpPort() { + void findAvailableTcpPort() { int port = SocketUtils.findAvailableTcpPort(); assertPortInRange(port, PORT_RANGE_MIN, PORT_RANGE_MAX); } @Test - public void findAvailableTcpPortWithMinPortEqualToMaxPort() { + void findAvailableTcpPortWithMinPortEqualToMaxPort() { int minMaxPort = SocketUtils.findAvailableTcpPort(); int port = SocketUtils.findAvailableTcpPort(minMaxPort, minMaxPort); assertThat(port).isEqualTo(minMaxPort); } @Test - public void findAvailableTcpPortWhenPortOnLoopbackInterfaceIsNotAvailable() throws Exception { + void findAvailableTcpPortWhenPortOnLoopbackInterfaceIsNotAvailable() throws Exception { int port = SocketUtils.findAvailableTcpPort(); ServerSocket socket = ServerSocketFactory.getDefault().createServerSocket(port, 1, InetAddress.getByName("localhost")); try { @@ -90,13 +90,13 @@ public class SocketUtilsTests { } @Test - public void findAvailableTcpPortWithMin() { + void findAvailableTcpPortWithMin() { int port = SocketUtils.findAvailableTcpPort(50000); assertPortInRange(port, 50000, PORT_RANGE_MAX); } @Test - public void findAvailableTcpPortInRange() { + void findAvailableTcpPortInRange() { int minPort = 20000; int maxPort = minPort + 1000; int port = SocketUtils.findAvailableTcpPort(minPort, maxPort); @@ -104,27 +104,27 @@ public class SocketUtilsTests { } @Test - public void find4AvailableTcpPorts() { + void find4AvailableTcpPorts() { findAvailableTcpPorts(4); } @Test - public void find50AvailableTcpPorts() { + void find50AvailableTcpPorts() { findAvailableTcpPorts(50); } @Test - public void find4AvailableTcpPortsInRange() { + void find4AvailableTcpPortsInRange() { findAvailableTcpPorts(4, 30000, 35000); } @Test - public void find50AvailableTcpPortsInRange() { + void find50AvailableTcpPortsInRange() { findAvailableTcpPorts(50, 40000, 45000); } @Test - public void findAvailableTcpPortsWithRequestedNumberGreaterThanSizeOfRange() { + void findAvailableTcpPortsWithRequestedNumberGreaterThanSizeOfRange() { assertThatIllegalArgumentException().isThrownBy(() -> findAvailableTcpPorts(50, 45000, 45010)); } @@ -133,25 +133,25 @@ public class SocketUtilsTests { // UDP @Test - public void findAvailableUdpPortWithZeroMinPort() { + void findAvailableUdpPortWithZeroMinPort() { assertThatIllegalArgumentException().isThrownBy(() -> SocketUtils.findAvailableUdpPort(0)); } @Test - public void findAvailableUdpPortWithNegativeMinPort() { + void findAvailableUdpPortWithNegativeMinPort() { assertThatIllegalArgumentException().isThrownBy(() -> SocketUtils.findAvailableUdpPort(-500)); } @Test - public void findAvailableUdpPort() { + void findAvailableUdpPort() { int port = SocketUtils.findAvailableUdpPort(); assertPortInRange(port, PORT_RANGE_MIN, PORT_RANGE_MAX); } @Test - public void findAvailableUdpPortWhenPortOnLoopbackInterfaceIsNotAvailable() throws Exception { + void findAvailableUdpPortWhenPortOnLoopbackInterfaceIsNotAvailable() throws Exception { int port = SocketUtils.findAvailableUdpPort(); DatagramSocket socket = new DatagramSocket(port, InetAddress.getByName("localhost")); try { @@ -167,13 +167,13 @@ public class SocketUtilsTests { } @Test - public void findAvailableUdpPortWithMin() { + void findAvailableUdpPortWithMin() { int port = SocketUtils.findAvailableUdpPort(50000); assertPortInRange(port, 50000, PORT_RANGE_MAX); } @Test - public void findAvailableUdpPortInRange() { + void findAvailableUdpPortInRange() { int minPort = 20000; int maxPort = minPort + 1000; int port = SocketUtils.findAvailableUdpPort(minPort, maxPort); @@ -181,27 +181,27 @@ public class SocketUtilsTests { } @Test - public void find4AvailableUdpPorts() { + void find4AvailableUdpPorts() { findAvailableUdpPorts(4); } @Test - public void find50AvailableUdpPorts() { + void find50AvailableUdpPorts() { findAvailableUdpPorts(50); } @Test - public void find4AvailableUdpPortsInRange() { + void find4AvailableUdpPortsInRange() { findAvailableUdpPorts(4, 30000, 35000); } @Test - public void find50AvailableUdpPortsInRange() { + void find50AvailableUdpPortsInRange() { findAvailableUdpPorts(50, 40000, 45000); } @Test - public void findAvailableUdpPortsWithRequestedNumberGreaterThanSizeOfRange() { + void findAvailableUdpPortsWithRequestedNumberGreaterThanSizeOfRange() { assertThatIllegalArgumentException().isThrownBy(() -> findAvailableUdpPorts(50, 45000, 45010)); } diff --git a/spring-core/src/test/java/org/springframework/util/StopWatchTests.java b/spring-core/src/test/java/org/springframework/util/StopWatchTests.java index 025e72fc34..1edffd05b4 100644 --- a/spring-core/src/test/java/org/springframework/util/StopWatchTests.java +++ b/spring-core/src/test/java/org/springframework/util/StopWatchTests.java @@ -32,7 +32,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException; * @author Juergen Hoeller * @author Sam Brannen */ -public class StopWatchTests { +class StopWatchTests { private static final String ID = "myId"; @@ -47,17 +47,17 @@ public class StopWatchTests { @Test - public void failureToStartBeforeGettingTimings() { + void failureToStartBeforeGettingTimings() { assertThatIllegalStateException().isThrownBy(stopWatch::getLastTaskTimeMillis); } @Test - public void failureToStartBeforeStop() { + void failureToStartBeforeStop() { assertThatIllegalStateException().isThrownBy(stopWatch::stop); } @Test - public void rejectsStartTwice() { + void rejectsStartTwice() { stopWatch.start(); assertThat(stopWatch.isRunning()).isTrue(); stopWatch.stop(); @@ -69,7 +69,7 @@ public class StopWatchTests { } @Test - public void validUsage() throws Exception { + void validUsage() throws Exception { assertThat(stopWatch.isRunning()).isFalse(); stopWatch.start(name1); @@ -118,7 +118,7 @@ public class StopWatchTests { } @Test - public void validUsageDoesNotKeepTaskList() throws Exception { + void validUsageDoesNotKeepTaskList() throws Exception { stopWatch.setKeepTaskList(false); stopWatch.start(name1); diff --git a/spring-core/src/test/java/org/springframework/util/StreamUtilsTests.java b/spring-core/src/test/java/org/springframework/util/StreamUtilsTests.java index 7f057d2cb0..21f0829457 100644 --- a/spring-core/src/test/java/org/springframework/util/StreamUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/util/StreamUtilsTests.java @@ -41,14 +41,14 @@ import static org.mockito.Mockito.verify; * * @author Phillip Webb */ -public class StreamUtilsTests { +class StreamUtilsTests { private byte[] bytes = new byte[StreamUtils.BUFFER_SIZE + 10]; private String string = ""; @BeforeEach - public void setup() { + void setup() { new Random().nextBytes(bytes); while (string.length() < StreamUtils.BUFFER_SIZE + 10) { string += UUID.randomUUID().toString(); @@ -56,7 +56,7 @@ public class StreamUtilsTests { } @Test - public void copyToByteArray() throws Exception { + void copyToByteArray() throws Exception { InputStream inputStream = spy(new ByteArrayInputStream(bytes)); byte[] actual = StreamUtils.copyToByteArray(inputStream); assertThat(actual).isEqualTo(bytes); @@ -64,7 +64,7 @@ public class StreamUtilsTests { } @Test - public void copyToString() throws Exception { + void copyToString() throws Exception { Charset charset = Charset.defaultCharset(); InputStream inputStream = spy(new ByteArrayInputStream(string.getBytes(charset))); String actual = StreamUtils.copyToString(inputStream, charset); @@ -73,7 +73,7 @@ public class StreamUtilsTests { } @Test - public void copyBytes() throws Exception { + void copyBytes() throws Exception { ByteArrayOutputStream out = spy(new ByteArrayOutputStream()); StreamUtils.copy(bytes, out); assertThat(out.toByteArray()).isEqualTo(bytes); @@ -81,7 +81,7 @@ public class StreamUtilsTests { } @Test - public void copyString() throws Exception { + void copyString() throws Exception { Charset charset = Charset.defaultCharset(); ByteArrayOutputStream out = spy(new ByteArrayOutputStream()); StreamUtils.copy(string, charset, out); @@ -90,7 +90,7 @@ public class StreamUtilsTests { } @Test - public void copyStream() throws Exception { + void copyStream() throws Exception { ByteArrayOutputStream out = spy(new ByteArrayOutputStream()); StreamUtils.copy(new ByteArrayInputStream(bytes), out); assertThat(out.toByteArray()).isEqualTo(bytes); @@ -98,7 +98,7 @@ public class StreamUtilsTests { } @Test - public void copyRange() throws Exception { + void copyRange() throws Exception { ByteArrayOutputStream out = spy(new ByteArrayOutputStream()); StreamUtils.copyRange(new ByteArrayInputStream(bytes), out, 0, 100); byte[] range = Arrays.copyOfRange(bytes, 0, 101); @@ -107,7 +107,7 @@ public class StreamUtilsTests { } @Test - public void nonClosingInputStream() throws Exception { + void nonClosingInputStream() throws Exception { InputStream source = mock(InputStream.class); InputStream nonClosing = StreamUtils.nonClosing(source); nonClosing.read(); @@ -122,7 +122,7 @@ public class StreamUtilsTests { } @Test - public void nonClosingOutputStream() throws Exception { + void nonClosingOutputStream() throws Exception { OutputStream source = mock(OutputStream.class); OutputStream nonClosing = StreamUtils.nonClosing(source); nonClosing.write(1); diff --git a/spring-core/src/test/java/org/springframework/util/StringUtilsTests.java b/spring-core/src/test/java/org/springframework/util/StringUtilsTests.java index 695e4015bb..701eee3f96 100644 --- a/spring-core/src/test/java/org/springframework/util/StringUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/util/StringUtilsTests.java @@ -30,27 +30,27 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException * @author Juergen Hoeller * @author Rick Evans */ -public class StringUtilsTests { +class StringUtilsTests { @Test - public void testHasTextBlank() { + void hasTextBlank() { String blank = " "; assertThat(StringUtils.hasText(blank)).isEqualTo(false); } @Test - public void testHasTextNullEmpty() { + void hasTextNullEmpty() { assertThat(StringUtils.hasText(null)).isEqualTo(false); assertThat(StringUtils.hasText("")).isEqualTo(false); } @Test - public void testHasTextValid() { + void hasTextValid() { assertThat(StringUtils.hasText("t")).isEqualTo(true); } @Test - public void testContainsWhitespace() { + void containsWhitespace() { assertThat(StringUtils.containsWhitespace(null)).isFalse(); assertThat(StringUtils.containsWhitespace("")).isFalse(); assertThat(StringUtils.containsWhitespace("a")).isFalse(); @@ -63,7 +63,7 @@ public class StringUtilsTests { } @Test - public void testTrimWhitespace() { + void trimWhitespace() { assertThat(StringUtils.trimWhitespace(null)).isEqualTo(null); assertThat(StringUtils.trimWhitespace("")).isEqualTo(""); assertThat(StringUtils.trimWhitespace(" ")).isEqualTo(""); @@ -76,7 +76,7 @@ public class StringUtilsTests { } @Test - public void testTrimAllWhitespace() { + void trimAllWhitespace() { assertThat(StringUtils.trimAllWhitespace("")).isEqualTo(""); assertThat(StringUtils.trimAllWhitespace(" ")).isEqualTo(""); assertThat(StringUtils.trimAllWhitespace("\t")).isEqualTo(""); @@ -88,7 +88,7 @@ public class StringUtilsTests { } @Test - public void testTrimLeadingWhitespace() { + void trimLeadingWhitespace() { assertThat(StringUtils.trimLeadingWhitespace(null)).isEqualTo(null); assertThat(StringUtils.trimLeadingWhitespace("")).isEqualTo(""); assertThat(StringUtils.trimLeadingWhitespace(" ")).isEqualTo(""); @@ -101,7 +101,7 @@ public class StringUtilsTests { } @Test - public void testTrimTrailingWhitespace() { + void trimTrailingWhitespace() { assertThat(StringUtils.trimTrailingWhitespace(null)).isEqualTo(null); assertThat(StringUtils.trimTrailingWhitespace("")).isEqualTo(""); assertThat(StringUtils.trimTrailingWhitespace(" ")).isEqualTo(""); @@ -114,7 +114,7 @@ public class StringUtilsTests { } @Test - public void testTrimLeadingCharacter() { + void trimLeadingCharacter() { assertThat(StringUtils.trimLeadingCharacter(null, ' ')).isEqualTo(null); assertThat(StringUtils.trimLeadingCharacter("", ' ')).isEqualTo(""); assertThat(StringUtils.trimLeadingCharacter(" ", ' ')).isEqualTo(""); @@ -127,7 +127,7 @@ public class StringUtilsTests { } @Test - public void testTrimTrailingCharacter() { + void trimTrailingCharacter() { assertThat(StringUtils.trimTrailingCharacter(null, ' ')).isEqualTo(null); assertThat(StringUtils.trimTrailingCharacter("", ' ')).isEqualTo(""); assertThat(StringUtils.trimTrailingCharacter(" ", ' ')).isEqualTo(""); @@ -140,7 +140,7 @@ public class StringUtilsTests { } @Test - public void testStartsWithIgnoreCase() { + void startsWithIgnoreCase() { String prefix = "fOo"; assertThat(StringUtils.startsWithIgnoreCase("foo", prefix)).isTrue(); assertThat(StringUtils.startsWithIgnoreCase("Foo", prefix)).isTrue(); @@ -159,7 +159,7 @@ public class StringUtilsTests { } @Test - public void testEndsWithIgnoreCase() { + void endsWithIgnoreCase() { String suffix = "fOo"; assertThat(StringUtils.endsWithIgnoreCase("foo", suffix)).isTrue(); assertThat(StringUtils.endsWithIgnoreCase("Foo", suffix)).isTrue(); @@ -178,7 +178,7 @@ public class StringUtilsTests { } @Test - public void testSubstringMatch() { + void substringMatch() { assertThat(StringUtils.substringMatch("foo", 0, "foo")).isTrue(); assertThat(StringUtils.substringMatch("foo", 1, "oo")).isTrue(); assertThat(StringUtils.substringMatch("foo", 2, "o")).isTrue(); @@ -194,7 +194,7 @@ public class StringUtilsTests { } @Test - public void testCountOccurrencesOf() { + void countOccurrencesOf() { assertThat(StringUtils.countOccurrencesOf(null, null) == 0).as("nullx2 = 0").isTrue(); assertThat(StringUtils.countOccurrencesOf("s", null) == 0).as("null string = 0").isTrue(); assertThat(StringUtils.countOccurrencesOf(null, "s") == 0).as("null substring = 0").isTrue(); @@ -211,7 +211,7 @@ public class StringUtilsTests { } @Test - public void testReplace() { + void replace() { String inString = "a6AazAaa77abaa"; String oldPattern = "aa"; String newPattern = "foo"; @@ -234,7 +234,7 @@ public class StringUtilsTests { } @Test - public void testDelete() { + void delete() { String inString = "The quick brown fox jumped over the lazy dog"; String noThe = StringUtils.delete(inString, "the"); @@ -257,7 +257,7 @@ public class StringUtilsTests { } @Test - public void testDeleteAny() { + void deleteAny() { String inString = "Able was I ere I saw Elba"; String res = StringUtils.deleteAny(inString, "I"); @@ -285,14 +285,14 @@ public class StringUtilsTests { @Test - public void testQuote() { + void quote() { assertThat(StringUtils.quote("myString")).isEqualTo("'myString'"); assertThat(StringUtils.quote("")).isEqualTo("''"); assertThat(StringUtils.quote(null)).isNull(); } @Test - public void testQuoteIfString() { + void quoteIfString() { assertThat(StringUtils.quoteIfString("myString")).isEqualTo("'myString'"); assertThat(StringUtils.quoteIfString("")).isEqualTo("''"); assertThat(StringUtils.quoteIfString(5)).isEqualTo(Integer.valueOf(5)); @@ -300,25 +300,25 @@ public class StringUtilsTests { } @Test - public void testUnqualify() { + void unqualify() { String qualified = "i.am.not.unqualified"; assertThat(StringUtils.unqualify(qualified)).isEqualTo("unqualified"); } @Test - public void testCapitalize() { + void capitalize() { String capitalized = "i am not capitalized"; assertThat(StringUtils.capitalize(capitalized)).isEqualTo("I am not capitalized"); } @Test - public void testUncapitalize() { + void uncapitalize() { String capitalized = "I am capitalized"; assertThat(StringUtils.uncapitalize(capitalized)).isEqualTo("i am capitalized"); } @Test - public void testGetFilename() { + void getFilename() { assertThat(StringUtils.getFilename(null)).isEqualTo(null); assertThat(StringUtils.getFilename("")).isEqualTo(""); assertThat(StringUtils.getFilename("myfile")).isEqualTo("myfile"); @@ -330,7 +330,7 @@ public class StringUtilsTests { } @Test - public void testGetFilenameExtension() { + void getFilenameExtension() { assertThat(StringUtils.getFilenameExtension(null)).isEqualTo(null); assertThat(StringUtils.getFilenameExtension("")).isEqualTo(null); assertThat(StringUtils.getFilenameExtension("myfile")).isEqualTo(null); @@ -344,7 +344,7 @@ public class StringUtilsTests { } @Test - public void testStripFilenameExtension() { + void stripFilenameExtension() { assertThat(StringUtils.stripFilenameExtension("")).isEqualTo(""); assertThat(StringUtils.stripFilenameExtension("myfile")).isEqualTo("myfile"); assertThat(StringUtils.stripFilenameExtension("myfile.")).isEqualTo("myfile"); @@ -358,7 +358,7 @@ public class StringUtilsTests { } @Test - public void testCleanPath() { + void cleanPath() { assertThat(StringUtils.cleanPath("mypath/myfile")).isEqualTo("mypath/myfile"); assertThat(StringUtils.cleanPath("mypath\\myfile")).isEqualTo("mypath/myfile"); assertThat(StringUtils.cleanPath("mypath/../mypath/myfile")).isEqualTo("mypath/myfile"); @@ -392,7 +392,7 @@ public class StringUtilsTests { } @Test - public void testPathEquals() { + void pathEquals() { assertThat(StringUtils.pathEquals("/dummy1/dummy2/dummy3", "/dummy1/dummy2/dummy3")).as("Must be true for the same strings").isTrue(); assertThat(StringUtils.pathEquals("C:\\dummy1\\dummy2\\dummy3", "C:\\dummy1\\dummy2\\dummy3")).as("Must be true for the same win strings").isTrue(); assertThat(StringUtils.pathEquals("/dummy1/bin/../dummy2/dummy3", "/dummy1/dummy2/dummy3")).as("Must be true for one top path on 1").isTrue(); @@ -410,7 +410,7 @@ public class StringUtilsTests { } @Test - public void testConcatenateStringArrays() { + void concatenateStringArrays() { String[] input1 = new String[] {"myString2"}; String[] input2 = new String[] {"myString1", "myString2"}; String[] result = StringUtils.concatenateStringArrays(input1, input2); @@ -426,7 +426,7 @@ public class StringUtilsTests { @Test @Deprecated - public void testMergeStringArrays() { + void mergeStringArrays() { String[] input1 = new String[] {"myString2"}; String[] input2 = new String[] {"myString1", "myString2"}; String[] result = StringUtils.mergeStringArrays(input1, input2); @@ -440,7 +440,7 @@ public class StringUtilsTests { } @Test - public void testSortStringArray() { + void sortStringArray() { String[] input = new String[] {"myString2"}; input = StringUtils.addStringToArray(input, "myString1"); assertThat(input[0]).isEqualTo("myString2"); @@ -452,7 +452,7 @@ public class StringUtilsTests { } @Test - public void testRemoveDuplicateStrings() { + void removeDuplicateStrings() { String[] input = new String[] {"myString2", "myString1", "myString2"}; input = StringUtils.removeDuplicateStrings(input); assertThat(input[0]).isEqualTo("myString2"); @@ -460,7 +460,7 @@ public class StringUtilsTests { } @Test - public void testSplitArrayElementsIntoProperties() { + void splitArrayElementsIntoProperties() { String[] input = new String[] {"key1=value1 ", "key2 =\"value2\""}; Properties result = StringUtils.splitArrayElementsIntoProperties(input, "="); assertThat(result.getProperty("key1")).isEqualTo("value1"); @@ -468,7 +468,7 @@ public class StringUtilsTests { } @Test - public void testSplitArrayElementsIntoPropertiesAndDeletedChars() { + void splitArrayElementsIntoPropertiesAndDeletedChars() { String[] input = new String[] {"key1=value1 ", "key2 =\"value2\""}; Properties result = StringUtils.splitArrayElementsIntoProperties(input, "=", "\""); assertThat(result.getProperty("key1")).isEqualTo("value1"); @@ -476,42 +476,42 @@ public class StringUtilsTests { } @Test - public void testTokenizeToStringArray() { + void tokenizeToStringArray() { String[] sa = StringUtils.tokenizeToStringArray("a,b , ,c", ","); assertThat(sa.length).isEqualTo(3); assertThat(sa[0].equals("a") && sa[1].equals("b") && sa[2].equals("c")).as("components are correct").isTrue(); } @Test - public void testTokenizeToStringArrayWithNotIgnoreEmptyTokens() { + void tokenizeToStringArrayWithNotIgnoreEmptyTokens() { String[] sa = StringUtils.tokenizeToStringArray("a,b , ,c", ",", true, false); assertThat(sa.length).isEqualTo(4); assertThat(sa[0].equals("a") && sa[1].equals("b") && sa[2].equals("") && sa[3].equals("c")).as("components are correct").isTrue(); } @Test - public void testTokenizeToStringArrayWithNotTrimTokens() { + void tokenizeToStringArrayWithNotTrimTokens() { String[] sa = StringUtils.tokenizeToStringArray("a,b ,c", ",", false, true); assertThat(sa.length).isEqualTo(3); assertThat(sa[0].equals("a") && sa[1].equals("b ") && sa[2].equals("c")).as("components are correct").isTrue(); } @Test - public void testCommaDelimitedListToStringArrayWithNullProducesEmptyArray() { + void commaDelimitedListToStringArrayWithNullProducesEmptyArray() { String[] sa = StringUtils.commaDelimitedListToStringArray(null); assertThat(sa != null).as("String array isn't null with null input").isTrue(); assertThat(sa.length == 0).as("String array length == 0 with null input").isTrue(); } @Test - public void testCommaDelimitedListToStringArrayWithEmptyStringProducesEmptyArray() { + void commaDelimitedListToStringArrayWithEmptyStringProducesEmptyArray() { String[] sa = StringUtils.commaDelimitedListToStringArray(""); assertThat(sa != null).as("String array isn't null with null input").isTrue(); assertThat(sa.length == 0).as("String array length == 0 with null input").isTrue(); } @Test - public void testDelimitedListToStringArrayWithComma() { + void delimitedListToStringArrayWithComma() { String[] sa = StringUtils.delimitedListToStringArray("a,b", ","); assertThat(sa.length).isEqualTo(2); assertThat(sa[0]).isEqualTo("a"); @@ -519,7 +519,7 @@ public class StringUtilsTests { } @Test - public void testDelimitedListToStringArrayWithSemicolon() { + void delimitedListToStringArrayWithSemicolon() { String[] sa = StringUtils.delimitedListToStringArray("a;b", ";"); assertThat(sa.length).isEqualTo(2); assertThat(sa[0]).isEqualTo("a"); @@ -527,7 +527,7 @@ public class StringUtilsTests { } @Test - public void testDelimitedListToStringArrayWithEmptyString() { + void delimitedListToStringArrayWithEmptyString() { String[] sa = StringUtils.delimitedListToStringArray("a,b", ""); assertThat(sa.length).isEqualTo(3); assertThat(sa[0]).isEqualTo("a"); @@ -536,14 +536,14 @@ public class StringUtilsTests { } @Test - public void testDelimitedListToStringArrayWithNullDelimiter() { + void delimitedListToStringArrayWithNullDelimiter() { String[] sa = StringUtils.delimitedListToStringArray("a,b", null); assertThat(sa.length).isEqualTo(1); assertThat(sa[0]).isEqualTo("a,b"); } @Test - public void testCommaDelimitedListToStringArrayMatchWords() { + void commaDelimitedListToStringArrayMatchWords() { // Could read these from files String[] sa = new String[] {"foo", "bar", "big"}; doTestCommaDelimitedListToStringArrayLegalMatch(sa); @@ -566,7 +566,7 @@ public class StringUtilsTests { } @Test - public void testCommaDelimitedListToStringArraySingleString() { + void commaDelimitedListToStringArraySingleString() { // Could read these from files String s = "woeirqupoiewuropqiewuorpqiwueopriquwopeiurqopwieur"; String[] sa = StringUtils.commaDelimitedListToStringArray(s); @@ -575,7 +575,7 @@ public class StringUtilsTests { } @Test - public void testCommaDelimitedListToStringArrayWithOtherPunctuation() { + void commaDelimitedListToStringArrayWithOtherPunctuation() { // Could read these from files String[] sa = new String[] {"xcvwert4456346&*.", "///", ".!", ".", ";"}; doTestCommaDelimitedListToStringArrayLegalMatch(sa); @@ -585,7 +585,7 @@ public class StringUtilsTests { * We expect to see the empty Strings in the output. */ @Test - public void testCommaDelimitedListToStringArrayEmptyStrings() { + void commaDelimitedListToStringArrayEmptyStrings() { // Could read these from files String[] sa = StringUtils.commaDelimitedListToStringArray("a,,b"); assertThat(sa.length).as("a,,b produces array length 3").isEqualTo(3); @@ -611,7 +611,7 @@ public class StringUtilsTests { @Test - public void testParseLocaleStringSunnyDay() { + void parseLocaleStringSunnyDay() { Locale expectedLocale = Locale.UK; Locale locale = StringUtils.parseLocaleString(expectedLocale.toString()); assertThat(locale).as("When given a bona-fide Locale string, must not return null.").isNotNull(); @@ -619,19 +619,19 @@ public class StringUtilsTests { } @Test - public void testParseLocaleStringWithMalformedLocaleString() { + void parseLocaleStringWithMalformedLocaleString() { Locale locale = StringUtils.parseLocaleString("_banjo_on_my_knee"); assertThat(locale).as("When given a malformed Locale string, must not return null.").isNotNull(); } @Test - public void testParseLocaleStringWithEmptyLocaleStringYieldsNullLocale() { + void parseLocaleStringWithEmptyLocaleStringYieldsNullLocale() { Locale locale = StringUtils.parseLocaleString(""); assertThat(locale).as("When given an empty Locale string, must return null.").isNull(); } @Test // SPR-8637 - public void testParseLocaleWithMultiSpecialCharactersInVariant() { + void parseLocaleWithMultiSpecialCharactersInVariant() { String variant = "proper-northern"; String localeString = "en_GB_" + variant; Locale locale = StringUtils.parseLocaleString(localeString); @@ -639,7 +639,7 @@ public class StringUtilsTests { } @Test // SPR-3671 - public void testParseLocaleWithMultiValuedVariant() { + void parseLocaleWithMultiValuedVariant() { String variant = "proper_northern"; String localeString = "en_GB_" + variant; Locale locale = StringUtils.parseLocaleString(localeString); @@ -647,7 +647,7 @@ public class StringUtilsTests { } @Test // SPR-3671 - public void testParseLocaleWithMultiValuedVariantUsingSpacesAsSeparators() { + void parseLocaleWithMultiValuedVariantUsingSpacesAsSeparators() { String variant = "proper northern"; String localeString = "en GB " + variant; Locale locale = StringUtils.parseLocaleString(localeString); @@ -655,7 +655,7 @@ public class StringUtilsTests { } @Test // SPR-3671 - public void testParseLocaleWithMultiValuedVariantUsingMixtureOfUnderscoresAndSpacesAsSeparators() { + void parseLocaleWithMultiValuedVariantUsingMixtureOfUnderscoresAndSpacesAsSeparators() { String variant = "proper northern"; String localeString = "en_GB_" + variant; Locale locale = StringUtils.parseLocaleString(localeString); @@ -663,7 +663,7 @@ public class StringUtilsTests { } @Test // SPR-3671 - public void testParseLocaleWithMultiValuedVariantUsingSpacesAsSeparatorsWithLotsOfLeadingWhitespace() { + void parseLocaleWithMultiValuedVariantUsingSpacesAsSeparatorsWithLotsOfLeadingWhitespace() { String variant = "proper northern"; String localeString = "en GB " + variant; // lots of whitespace Locale locale = StringUtils.parseLocaleString(localeString); @@ -671,7 +671,7 @@ public class StringUtilsTests { } @Test // SPR-3671 - public void testParseLocaleWithMultiValuedVariantUsingUnderscoresAsSeparatorsWithLotsOfLeadingWhitespace() { + void parseLocaleWithMultiValuedVariantUsingUnderscoresAsSeparatorsWithLotsOfLeadingWhitespace() { String variant = "proper_northern"; String localeString = "en_GB_____" + variant; // lots of underscores Locale locale = StringUtils.parseLocaleString(localeString); @@ -679,19 +679,19 @@ public class StringUtilsTests { } @Test // SPR-7779 - public void testParseLocaleWithInvalidCharacters() { + void parseLocaleWithInvalidCharacters() { assertThatIllegalArgumentException().isThrownBy(() -> StringUtils.parseLocaleString("%0D%0AContent-length:30%0D%0A%0D%0A%3Cscript%3Ealert%28123%29%3C/script%3E")); } @Test // SPR-9420 - public void testParseLocaleWithSameLowercaseTokenForLanguageAndCountry() { + void parseLocaleWithSameLowercaseTokenForLanguageAndCountry() { assertThat(StringUtils.parseLocaleString("tr_tr").toString()).isEqualTo("tr_TR"); assertThat(StringUtils.parseLocaleString("bg_bg_vnt").toString()).isEqualTo("bg_BG_vnt"); } @Test // SPR-11806 - public void testParseLocaleWithVariantContainingCountryCode() { + void parseLocaleWithVariantContainingCountryCode() { String variant = "GBtest"; String localeString = "en_GB_" + variant; Locale locale = StringUtils.parseLocaleString(localeString); @@ -699,12 +699,12 @@ public class StringUtilsTests { } @Test // SPR-14718, SPR-7598 - public void testParseJava7Variant() { + void parseJava7Variant() { assertThat(StringUtils.parseLocaleString("sr__#LATN").toString()).isEqualTo("sr__#LATN"); } @Test // SPR-16651 - public void testAvailableLocalesWithLocaleString() { + void availableLocalesWithLocaleString() { for (Locale locale : Locale.getAvailableLocales()) { Locale parsedLocale = StringUtils.parseLocaleString(locale.toString()); if (parsedLocale == null) { @@ -717,7 +717,7 @@ public class StringUtilsTests { } @Test // SPR-16651 - public void testAvailableLocalesWithLanguageTag() { + void availableLocalesWithLanguageTag() { for (Locale locale : Locale.getAvailableLocales()) { Locale parsedLocale = StringUtils.parseLocale(locale.toLanguageTag()); if (parsedLocale == null) { @@ -730,7 +730,7 @@ public class StringUtilsTests { } @Test - public void testInvalidLocaleWithLocaleString() { + void invalidLocaleWithLocaleString() { assertThat(StringUtils.parseLocaleString("invalid")).isEqualTo(new Locale("invalid")); assertThat(StringUtils.parseLocaleString("invalidvalue")).isEqualTo(new Locale("invalidvalue")); assertThat(StringUtils.parseLocaleString("invalidvalue_foo")).isEqualTo(new Locale("invalidvalue", "foo")); @@ -738,7 +738,7 @@ public class StringUtilsTests { } @Test - public void testInvalidLocaleWithLanguageTag() { + void invalidLocaleWithLanguageTag() { assertThat(StringUtils.parseLocale("invalid")).isEqualTo(new Locale("invalid")); assertThat(StringUtils.parseLocale("invalidvalue")).isEqualTo(new Locale("invalidvalue")); assertThat(StringUtils.parseLocale("invalidvalue_foo")).isEqualTo(new Locale("invalidvalue", "foo")); diff --git a/spring-core/src/test/java/org/springframework/util/SystemPropertyUtilsTests.java b/spring-core/src/test/java/org/springframework/util/SystemPropertyUtilsTests.java index 28cc1bef1e..ce4cf4210a 100644 --- a/spring-core/src/test/java/org/springframework/util/SystemPropertyUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/util/SystemPropertyUtilsTests.java @@ -27,10 +27,10 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException * @author Rob Harrop * @author Juergen Hoeller */ -public class SystemPropertyUtilsTests { +class SystemPropertyUtilsTests { @Test - public void testReplaceFromSystemProperty() { + void replaceFromSystemProperty() { System.setProperty("test.prop", "bar"); try { String resolved = SystemPropertyUtils.resolvePlaceholders("${test.prop}"); @@ -42,7 +42,7 @@ public class SystemPropertyUtilsTests { } @Test - public void testReplaceFromSystemPropertyWithDefault() { + void replaceFromSystemPropertyWithDefault() { System.setProperty("test.prop", "bar"); try { String resolved = SystemPropertyUtils.resolvePlaceholders("${test.prop:foo}"); @@ -54,7 +54,7 @@ public class SystemPropertyUtilsTests { } @Test - public void testReplaceFromSystemPropertyWithExpressionDefault() { + void replaceFromSystemPropertyWithExpressionDefault() { System.setProperty("test.prop", "bar"); try { String resolved = SystemPropertyUtils.resolvePlaceholders("${test.prop:#{foo.bar}}"); @@ -66,7 +66,7 @@ public class SystemPropertyUtilsTests { } @Test - public void testReplaceFromSystemPropertyWithExpressionContainingDefault() { + void replaceFromSystemPropertyWithExpressionContainingDefault() { System.setProperty("test.prop", "bar"); try { String resolved = SystemPropertyUtils.resolvePlaceholders("${test.prop:Y#{foo.bar}X}"); @@ -78,43 +78,43 @@ public class SystemPropertyUtilsTests { } @Test - public void testReplaceWithDefault() { + void replaceWithDefault() { String resolved = SystemPropertyUtils.resolvePlaceholders("${test.prop:foo}"); assertThat(resolved).isEqualTo("foo"); } @Test - public void testReplaceWithExpressionDefault() { + void replaceWithExpressionDefault() { String resolved = SystemPropertyUtils.resolvePlaceholders("${test.prop:#{foo.bar}}"); assertThat(resolved).isEqualTo("#{foo.bar}"); } @Test - public void testReplaceWithExpressionContainingDefault() { + void replaceWithExpressionContainingDefault() { String resolved = SystemPropertyUtils.resolvePlaceholders("${test.prop:Y#{foo.bar}X}"); assertThat(resolved).isEqualTo("Y#{foo.bar}X"); } @Test - public void testReplaceWithNoDefault() { + void replaceWithNoDefault() { assertThatIllegalArgumentException().isThrownBy(() -> SystemPropertyUtils.resolvePlaceholders("${test.prop}")); } @Test - public void testReplaceWithNoDefaultIgnored() { + void replaceWithNoDefaultIgnored() { String resolved = SystemPropertyUtils.resolvePlaceholders("${test.prop}", true); assertThat(resolved).isEqualTo("${test.prop}"); } @Test - public void testReplaceWithEmptyDefault() { + void replaceWithEmptyDefault() { String resolved = SystemPropertyUtils.resolvePlaceholders("${test.prop:}"); assertThat(resolved).isEqualTo(""); } @Test - public void testRecursiveFromSystemProperty() { + void recursiveFromSystemProperty() { System.setProperty("test.prop", "foo=${bar}"); System.setProperty("bar", "baz"); try { @@ -128,7 +128,7 @@ public class SystemPropertyUtilsTests { } @Test - public void testReplaceFromEnv() { + void replaceFromEnv() { Map env = System.getenv(); if (env.containsKey("PATH")) { String text = "${PATH}"; diff --git a/spring-core/src/test/java/org/springframework/util/TypeUtilsTests.java b/spring-core/src/test/java/org/springframework/util/TypeUtilsTests.java index df25e318e6..221f26428e 100644 --- a/spring-core/src/test/java/org/springframework/util/TypeUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/util/TypeUtilsTests.java @@ -33,7 +33,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Juergen Hoeller * @author Chris Beams */ -public class TypeUtilsTests { +class TypeUtilsTests { public static Object object; @@ -57,7 +57,7 @@ public class TypeUtilsTests { @Test - public void withClasses() { + void withClasses() { assertThat(TypeUtils.isAssignable(Object.class, Object.class)).isTrue(); assertThat(TypeUtils.isAssignable(Object.class, String.class)).isTrue(); assertThat(TypeUtils.isAssignable(String.class, Object.class)).isFalse(); @@ -68,7 +68,7 @@ public class TypeUtilsTests { } @Test - public void withParameterizedTypes() throws Exception { + void withParameterizedTypes() throws Exception { Type objectsType = getClass().getField("objects").getGenericType(); Type openObjectsType = getClass().getField("openObjects").getGenericType(); Type stringsType = getClass().getField("strings").getGenericType(); @@ -91,7 +91,7 @@ public class TypeUtilsTests { } @Test - public void withWildcardTypes() throws Exception { + void withWildcardTypes() throws Exception { ParameterizedType openObjectsType = (ParameterizedType) getClass().getField("openObjects").getGenericType(); ParameterizedType openNumbersType = (ParameterizedType) getClass().getField("openNumbers").getGenericType(); Type storableObjectListType = getClass().getField("storableObjectList").getGenericType(); @@ -110,7 +110,7 @@ public class TypeUtilsTests { } @Test - public void withGenericArrayTypes() throws Exception { + void withGenericArrayTypes() throws Exception { Type arrayType = getClass().getField("array").getGenericType(); Type openArrayType = getClass().getField("openArray").getGenericType(); assertThat(TypeUtils.isAssignable(Object.class, arrayType)).isTrue(); diff --git a/spring-core/src/test/java/org/springframework/util/comparator/BooleanComparatorTests.java b/spring-core/src/test/java/org/springframework/util/comparator/BooleanComparatorTests.java index 24299107ca..ae003d52c1 100644 --- a/spring-core/src/test/java/org/springframework/util/comparator/BooleanComparatorTests.java +++ b/spring-core/src/test/java/org/springframework/util/comparator/BooleanComparatorTests.java @@ -30,31 +30,31 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Chris Beams * @author Phillip Webb */ -public class BooleanComparatorTests { +class BooleanComparatorTests { @Test - public void shouldCompareWithTrueLow() { + void shouldCompareWithTrueLow() { Comparator c = new BooleanComparator(true); assertThat(c.compare(true, false)).isEqualTo(-1); assertThat(c.compare(Boolean.TRUE, Boolean.TRUE)).isEqualTo(0); } @Test - public void shouldCompareWithTrueHigh() { + void shouldCompareWithTrueHigh() { Comparator c = new BooleanComparator(false); assertThat(c.compare(true, false)).isEqualTo(1); assertThat(c.compare(Boolean.TRUE, Boolean.TRUE)).isEqualTo(0); } @Test - public void shouldCompareFromTrueLow() { + void shouldCompareFromTrueLow() { Comparator c = BooleanComparator.TRUE_LOW; assertThat(c.compare(true, false)).isEqualTo(-1); assertThat(c.compare(Boolean.TRUE, Boolean.TRUE)).isEqualTo(0); } @Test - public void shouldCompareFromTrueHigh() { + void shouldCompareFromTrueHigh() { Comparator c = BooleanComparator.TRUE_HIGH; assertThat(c.compare(true, false)).isEqualTo(1); assertThat(c.compare(Boolean.TRUE, Boolean.TRUE)).isEqualTo(0); diff --git a/spring-core/src/test/java/org/springframework/util/comparator/ComparableComparatorTests.java b/spring-core/src/test/java/org/springframework/util/comparator/ComparableComparatorTests.java index 7d3046242d..2a4ef7ea64 100644 --- a/spring-core/src/test/java/org/springframework/util/comparator/ComparableComparatorTests.java +++ b/spring-core/src/test/java/org/springframework/util/comparator/ComparableComparatorTests.java @@ -30,10 +30,10 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; * @author Chris Beams * @author Phillip Webb */ -public class ComparableComparatorTests { +class ComparableComparatorTests { @Test - public void testComparableComparator() { + void comparableComparator() { Comparator c = new ComparableComparator<>(); String s1 = "abc"; String s2 = "cde"; @@ -42,7 +42,7 @@ public class ComparableComparatorTests { @SuppressWarnings({ "unchecked", "rawtypes" }) @Test - public void shouldNeedComparable() { + void shouldNeedComparable() { Comparator c = new ComparableComparator(); Object o1 = new Object(); Object o2 = new Object(); diff --git a/spring-core/src/test/java/org/springframework/util/comparator/CompoundComparatorTests.java b/spring-core/src/test/java/org/springframework/util/comparator/CompoundComparatorTests.java index 231dfc0232..bf60e2d81f 100644 --- a/spring-core/src/test/java/org/springframework/util/comparator/CompoundComparatorTests.java +++ b/spring-core/src/test/java/org/springframework/util/comparator/CompoundComparatorTests.java @@ -30,10 +30,10 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException; * @author Phillip Webb */ @Deprecated -public class CompoundComparatorTests { +class CompoundComparatorTests { @Test - public void shouldNeedAtLeastOneComparator() { + void shouldNeedAtLeastOneComparator() { Comparator c = new CompoundComparator<>(); assertThatIllegalStateException().isThrownBy(() -> c.compare("foo", "bar")); diff --git a/spring-core/src/test/java/org/springframework/util/comparator/InstanceComparatorTests.java b/spring-core/src/test/java/org/springframework/util/comparator/InstanceComparatorTests.java index 9647025b57..fc0f5e2165 100644 --- a/spring-core/src/test/java/org/springframework/util/comparator/InstanceComparatorTests.java +++ b/spring-core/src/test/java/org/springframework/util/comparator/InstanceComparatorTests.java @@ -28,7 +28,7 @@ import static org.assertj.core.api.Assertions.assertThat; * * @author Phillip Webb */ -public class InstanceComparatorTests { +class InstanceComparatorTests { private C1 c1 = new C1(); @@ -39,7 +39,7 @@ public class InstanceComparatorTests { private C4 c4 = new C4(); @Test - public void shouldCompareClasses() throws Exception { + void shouldCompareClasses() throws Exception { Comparator comparator = new InstanceComparator<>(C1.class, C2.class); assertThat(comparator.compare(c1, c1)).isEqualTo(0); assertThat(comparator.compare(c1, c2)).isEqualTo(-1); @@ -50,7 +50,7 @@ public class InstanceComparatorTests { } @Test - public void shouldCompareInterfaces() throws Exception { + void shouldCompareInterfaces() throws Exception { Comparator comparator = new InstanceComparator<>(I1.class, I2.class); assertThat(comparator.compare(c1, c1)).isEqualTo(0); assertThat(comparator.compare(c1, c2)).isEqualTo(0); @@ -61,7 +61,7 @@ public class InstanceComparatorTests { } @Test - public void shouldCompareMix() throws Exception { + void shouldCompareMix() throws Exception { Comparator comparator = new InstanceComparator<>(I1.class, C3.class); assertThat(comparator.compare(c1, c1)).isEqualTo(0); assertThat(comparator.compare(c3, c4)).isEqualTo(-1); diff --git a/spring-core/src/test/java/org/springframework/util/comparator/InvertibleComparatorTests.java b/spring-core/src/test/java/org/springframework/util/comparator/InvertibleComparatorTests.java index 0cfcad79e6..df3f1a25e6 100644 --- a/spring-core/src/test/java/org/springframework/util/comparator/InvertibleComparatorTests.java +++ b/spring-core/src/test/java/org/springframework/util/comparator/InvertibleComparatorTests.java @@ -32,32 +32,32 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException * @author Phillip Webb */ @Deprecated -public class InvertibleComparatorTests { +class InvertibleComparatorTests { private final Comparator comparator = new ComparableComparator<>(); @Test - public void shouldNeedComparator() throws Exception { + void shouldNeedComparator() throws Exception { assertThatIllegalArgumentException().isThrownBy(() -> new InvertibleComparator<>(null)); } @Test - public void shouldNeedComparatorWithAscending() throws Exception { + void shouldNeedComparatorWithAscending() throws Exception { assertThatIllegalArgumentException().isThrownBy(() -> new InvertibleComparator<>(null, true)); } @Test - public void shouldDefaultToAscending() throws Exception { + void shouldDefaultToAscending() throws Exception { InvertibleComparator invertibleComparator = new InvertibleComparator<>(comparator); assertThat(invertibleComparator.isAscending()).isTrue(); assertThat(invertibleComparator.compare(1, 2)).isEqualTo(-1); } @Test - public void shouldInvert() throws Exception { + void shouldInvert() throws Exception { InvertibleComparator invertibleComparator = new InvertibleComparator<>(comparator); assertThat(invertibleComparator.isAscending()).isTrue(); assertThat(invertibleComparator.compare(1, 2)).isEqualTo(-1); @@ -67,13 +67,13 @@ public class InvertibleComparatorTests { } @Test - public void shouldCompareAscending() throws Exception { + void shouldCompareAscending() throws Exception { InvertibleComparator invertibleComparator = new InvertibleComparator<>(comparator, true); assertThat(invertibleComparator.compare(1, 2)).isEqualTo(-1); } @Test - public void shouldCompareDescending() throws Exception { + void shouldCompareDescending() throws Exception { InvertibleComparator invertibleComparator = new InvertibleComparator<>(comparator, false); assertThat(invertibleComparator.compare(1, 2)).isEqualTo(1); } diff --git a/spring-core/src/test/java/org/springframework/util/comparator/NullSafeComparatorTests.java b/spring-core/src/test/java/org/springframework/util/comparator/NullSafeComparatorTests.java index ab8aa34a64..e20f4f509a 100644 --- a/spring-core/src/test/java/org/springframework/util/comparator/NullSafeComparatorTests.java +++ b/spring-core/src/test/java/org/springframework/util/comparator/NullSafeComparatorTests.java @@ -29,18 +29,18 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Chris Beams * @author Phillip Webb */ -public class NullSafeComparatorTests { +class NullSafeComparatorTests { @SuppressWarnings("unchecked") @Test - public void shouldCompareWithNullsLow() { + void shouldCompareWithNullsLow() { Comparator c = NullSafeComparator.NULLS_LOW; assertThat(c.compare(null, "boo") < 0).isTrue(); } @SuppressWarnings("unchecked") @Test - public void shouldCompareWithNullsHigh() { + void shouldCompareWithNullsHigh() { Comparator c = NullSafeComparator.NULLS_HIGH; assertThat(c.compare(null, "boo") > 0).isTrue(); assertThat(c.compare(null, null) == 0).isTrue(); diff --git a/spring-core/src/test/java/org/springframework/util/concurrent/FutureAdapterTests.java b/spring-core/src/test/java/org/springframework/util/concurrent/FutureAdapterTests.java index edb58e0c61..c192888517 100644 --- a/spring-core/src/test/java/org/springframework/util/concurrent/FutureAdapterTests.java +++ b/spring-core/src/test/java/org/springframework/util/concurrent/FutureAdapterTests.java @@ -30,7 +30,7 @@ import static org.mockito.Mockito.mock; /** * @author Arjen Poutsma */ -public class FutureAdapterTests { +class FutureAdapterTests { private FutureAdapter adapter; @@ -39,7 +39,7 @@ public class FutureAdapterTests { @BeforeEach @SuppressWarnings("unchecked") - public void setUp() { + void setUp() { adaptee = mock(Future.class); adapter = new FutureAdapter(adaptee) { @Override @@ -50,35 +50,35 @@ public class FutureAdapterTests { } @Test - public void cancel() throws Exception { + void cancel() throws Exception { given(adaptee.cancel(true)).willReturn(true); boolean result = adapter.cancel(true); assertThat(result).isTrue(); } @Test - public void isCancelled() { + void isCancelled() { given(adaptee.isCancelled()).willReturn(true); boolean result = adapter.isCancelled(); assertThat(result).isTrue(); } @Test - public void isDone() { + void isDone() { given(adaptee.isDone()).willReturn(true); boolean result = adapter.isDone(); assertThat(result).isTrue(); } @Test - public void get() throws Exception { + void get() throws Exception { given(adaptee.get()).willReturn(42); String result = adapter.get(); assertThat(result).isEqualTo("42"); } @Test - public void getTimeOut() throws Exception { + void getTimeOut() throws Exception { given(adaptee.get(1, TimeUnit.SECONDS)).willReturn(42); String result = adapter.get(1, TimeUnit.SECONDS); assertThat(result).isEqualTo("42"); diff --git a/spring-core/src/test/java/org/springframework/util/concurrent/ListenableFutureTaskTests.java b/spring-core/src/test/java/org/springframework/util/concurrent/ListenableFutureTaskTests.java index 036b59cd20..aea5cbf1ff 100644 --- a/spring-core/src/test/java/org/springframework/util/concurrent/ListenableFutureTaskTests.java +++ b/spring-core/src/test/java/org/springframework/util/concurrent/ListenableFutureTaskTests.java @@ -34,10 +34,10 @@ import static org.mockito.Mockito.verifyZeroInteractions; * @author Sebastien Deleuze */ @SuppressWarnings("unchecked") -public class ListenableFutureTaskTests { +class ListenableFutureTaskTests { @Test - public void success() throws Exception { + void success() throws Exception { final String s = "Hello World"; Callable callable = () -> s; @@ -60,7 +60,7 @@ public class ListenableFutureTaskTests { } @Test - public void failure() throws Exception { + void failure() throws Exception { final String s = "Hello World"; Callable callable = () -> { throw new IOException(s); @@ -88,7 +88,7 @@ public class ListenableFutureTaskTests { } @Test - public void successWithLambdas() throws Exception { + void successWithLambdas() throws Exception { final String s = "Hello World"; Callable callable = () -> s; @@ -106,7 +106,7 @@ public class ListenableFutureTaskTests { } @Test - public void failureWithLambdas() throws Exception { + void failureWithLambdas() throws Exception { final String s = "Hello World"; IOException ex = new IOException(s); Callable callable = () -> { diff --git a/spring-core/src/test/java/org/springframework/util/concurrent/MonoToListenableFutureAdapterTests.java b/spring-core/src/test/java/org/springframework/util/concurrent/MonoToListenableFutureAdapterTests.java index b58db02e22..bea1a0dac0 100644 --- a/spring-core/src/test/java/org/springframework/util/concurrent/MonoToListenableFutureAdapterTests.java +++ b/spring-core/src/test/java/org/springframework/util/concurrent/MonoToListenableFutureAdapterTests.java @@ -28,10 +28,10 @@ import static org.assertj.core.api.Assertions.assertThat; * Unit tests for {@link MonoToListenableFutureAdapter}. * @author Rossen Stoyanchev */ -public class MonoToListenableFutureAdapterTests { +class MonoToListenableFutureAdapterTests { @Test - public void success() { + void success() { String expected = "one"; AtomicReference actual = new AtomicReference<>(); ListenableFuture future = new MonoToListenableFutureAdapter<>(Mono.just(expected)); @@ -41,7 +41,7 @@ public class MonoToListenableFutureAdapterTests { } @Test - public void failure() { + void failure() { Throwable expected = new IllegalStateException("oops"); AtomicReference actual = new AtomicReference<>(); ListenableFuture future = new MonoToListenableFutureAdapter<>(Mono.error(expected)); @@ -51,7 +51,7 @@ public class MonoToListenableFutureAdapterTests { } @Test - public void cancellation() { + void cancellation() { Mono mono = Mono.delay(Duration.ofSeconds(60)); Future future = new MonoToListenableFutureAdapter<>(mono); @@ -60,7 +60,7 @@ public class MonoToListenableFutureAdapterTests { } @Test - public void cancellationAfterTerminated() { + void cancellationAfterTerminated() { Future future = new MonoToListenableFutureAdapter<>(Mono.empty()); assertThat(future.cancel(true)).as("Should return false if task already completed").isFalse(); diff --git a/spring-core/src/test/java/org/springframework/util/concurrent/SettableListenableFutureTests.java b/spring-core/src/test/java/org/springframework/util/concurrent/SettableListenableFutureTests.java index 1b789089c0..d89ea3a73a 100644 --- a/spring-core/src/test/java/org/springframework/util/concurrent/SettableListenableFutureTests.java +++ b/spring-core/src/test/java/org/springframework/util/concurrent/SettableListenableFutureTests.java @@ -36,19 +36,19 @@ import static org.mockito.Mockito.verifyNoMoreInteractions; * @author Mattias Severson * @author Juergen Hoeller */ -public class SettableListenableFutureTests { +class SettableListenableFutureTests { private final SettableListenableFuture settableListenableFuture = new SettableListenableFuture<>(); @Test - public void validateInitialValues() { + void validateInitialValues() { assertThat(settableListenableFuture.isCancelled()).isFalse(); assertThat(settableListenableFuture.isDone()).isFalse(); } @Test - public void returnsSetValue() throws ExecutionException, InterruptedException { + void returnsSetValue() throws ExecutionException, InterruptedException { String string = "hello"; assertThat(settableListenableFuture.set(string)).isTrue(); assertThat(settableListenableFuture.get()).isEqualTo(string); @@ -57,7 +57,7 @@ public class SettableListenableFutureTests { } @Test - public void returnsSetValueFromCompletable() throws ExecutionException, InterruptedException { + void returnsSetValueFromCompletable() throws ExecutionException, InterruptedException { String string = "hello"; assertThat(settableListenableFuture.set(string)).isTrue(); Future completable = settableListenableFuture.completable(); @@ -67,14 +67,14 @@ public class SettableListenableFutureTests { } @Test - public void setValueUpdatesDoneStatus() { + void setValueUpdatesDoneStatus() { settableListenableFuture.set("hello"); assertThat(settableListenableFuture.isCancelled()).isFalse(); assertThat(settableListenableFuture.isDone()).isTrue(); } @Test - public void throwsSetExceptionWrappedInExecutionException() throws Exception { + void throwsSetExceptionWrappedInExecutionException() throws Exception { Throwable exception = new RuntimeException(); assertThat(settableListenableFuture.setException(exception)).isTrue(); @@ -87,7 +87,7 @@ public class SettableListenableFutureTests { } @Test - public void throwsSetExceptionWrappedInExecutionExceptionFromCompletable() throws Exception { + void throwsSetExceptionWrappedInExecutionExceptionFromCompletable() throws Exception { Throwable exception = new RuntimeException(); assertThat(settableListenableFuture.setException(exception)).isTrue(); Future completable = settableListenableFuture.completable(); @@ -101,7 +101,7 @@ public class SettableListenableFutureTests { } @Test - public void throwsSetErrorWrappedInExecutionException() throws Exception { + void throwsSetErrorWrappedInExecutionException() throws Exception { Throwable exception = new OutOfMemoryError(); assertThat(settableListenableFuture.setException(exception)).isTrue(); @@ -114,7 +114,7 @@ public class SettableListenableFutureTests { } @Test - public void throwsSetErrorWrappedInExecutionExceptionFromCompletable() throws Exception { + void throwsSetErrorWrappedInExecutionExceptionFromCompletable() throws Exception { Throwable exception = new OutOfMemoryError(); assertThat(settableListenableFuture.setException(exception)).isTrue(); Future completable = settableListenableFuture.completable(); @@ -128,7 +128,7 @@ public class SettableListenableFutureTests { } @Test - public void setValueTriggersCallback() { + void setValueTriggersCallback() { String string = "hello"; final String[] callbackHolder = new String[1]; @@ -150,7 +150,7 @@ public class SettableListenableFutureTests { } @Test - public void setValueTriggersCallbackOnlyOnce() { + void setValueTriggersCallbackOnlyOnce() { String string = "hello"; final String[] callbackHolder = new String[1]; @@ -173,7 +173,7 @@ public class SettableListenableFutureTests { } @Test - public void setExceptionTriggersCallback() { + void setExceptionTriggersCallback() { Throwable exception = new RuntimeException(); final Throwable[] callbackHolder = new Throwable[1]; @@ -195,7 +195,7 @@ public class SettableListenableFutureTests { } @Test - public void setExceptionTriggersCallbackOnlyOnce() { + void setExceptionTriggersCallbackOnlyOnce() { Throwable exception = new RuntimeException(); final Throwable[] callbackHolder = new Throwable[1]; @@ -218,7 +218,7 @@ public class SettableListenableFutureTests { } @Test - public void nullIsAcceptedAsValueToSet() throws ExecutionException, InterruptedException { + void nullIsAcceptedAsValueToSet() throws ExecutionException, InterruptedException { settableListenableFuture.set(null); assertThat((Object) settableListenableFuture.get()).isNull(); assertThat(settableListenableFuture.isCancelled()).isFalse(); @@ -226,7 +226,7 @@ public class SettableListenableFutureTests { } @Test - public void getWaitsForCompletion() throws ExecutionException, InterruptedException { + void getWaitsForCompletion() throws ExecutionException, InterruptedException { final String string = "hello"; new Thread(new Runnable() { @@ -249,13 +249,13 @@ public class SettableListenableFutureTests { } @Test - public void getWithTimeoutThrowsTimeoutException() throws ExecutionException, InterruptedException { + void getWithTimeoutThrowsTimeoutException() throws ExecutionException, InterruptedException { assertThatExceptionOfType(TimeoutException.class).isThrownBy(() -> settableListenableFuture.get(1L, TimeUnit.MILLISECONDS)); } @Test - public void getWithTimeoutWaitsForCompletion() throws ExecutionException, InterruptedException, TimeoutException { + void getWithTimeoutWaitsForCompletion() throws ExecutionException, InterruptedException, TimeoutException { final String string = "hello"; new Thread(new Runnable() { @@ -278,7 +278,7 @@ public class SettableListenableFutureTests { } @Test - public void cancelPreventsValueFromBeingSet() { + void cancelPreventsValueFromBeingSet() { assertThat(settableListenableFuture.cancel(true)).isTrue(); assertThat(settableListenableFuture.set("hello")).isFalse(); assertThat(settableListenableFuture.isCancelled()).isTrue(); @@ -286,14 +286,14 @@ public class SettableListenableFutureTests { } @Test - public void cancelSetsFutureToDone() { + void cancelSetsFutureToDone() { settableListenableFuture.cancel(true); assertThat(settableListenableFuture.isCancelled()).isTrue(); assertThat(settableListenableFuture.isDone()).isTrue(); } @Test - public void cancelWithMayInterruptIfRunningTrueCallsOverriddenMethod() { + void cancelWithMayInterruptIfRunningTrueCallsOverriddenMethod() { InterruptibleSettableListenableFuture interruptibleFuture = new InterruptibleSettableListenableFuture(); assertThat(interruptibleFuture.cancel(true)).isTrue(); assertThat(interruptibleFuture.calledInterruptTask()).isTrue(); @@ -302,7 +302,7 @@ public class SettableListenableFutureTests { } @Test - public void cancelWithMayInterruptIfRunningFalseDoesNotCallOverriddenMethod() { + void cancelWithMayInterruptIfRunningFalseDoesNotCallOverriddenMethod() { InterruptibleSettableListenableFuture interruptibleFuture = new InterruptibleSettableListenableFuture(); assertThat(interruptibleFuture.cancel(false)).isTrue(); assertThat(interruptibleFuture.calledInterruptTask()).isFalse(); @@ -311,7 +311,7 @@ public class SettableListenableFutureTests { } @Test - public void setPreventsCancel() { + void setPreventsCancel() { assertThat(settableListenableFuture.set("hello")).isTrue(); assertThat(settableListenableFuture.cancel(true)).isFalse(); assertThat(settableListenableFuture.isCancelled()).isFalse(); @@ -319,7 +319,7 @@ public class SettableListenableFutureTests { } @Test - public void cancelPreventsExceptionFromBeingSet() { + void cancelPreventsExceptionFromBeingSet() { assertThat(settableListenableFuture.cancel(true)).isTrue(); assertThat(settableListenableFuture.setException(new RuntimeException())).isFalse(); assertThat(settableListenableFuture.isCancelled()).isTrue(); @@ -327,7 +327,7 @@ public class SettableListenableFutureTests { } @Test - public void setExceptionPreventsCancel() { + void setExceptionPreventsCancel() { assertThat(settableListenableFuture.setException(new RuntimeException())).isTrue(); assertThat(settableListenableFuture.cancel(true)).isFalse(); assertThat(settableListenableFuture.isCancelled()).isFalse(); @@ -335,7 +335,7 @@ public class SettableListenableFutureTests { } @Test - public void cancelStateThrowsExceptionWhenCallingGet() throws ExecutionException, InterruptedException { + void cancelStateThrowsExceptionWhenCallingGet() throws ExecutionException, InterruptedException { settableListenableFuture.cancel(true); assertThatExceptionOfType(CancellationException.class).isThrownBy(() -> @@ -346,7 +346,7 @@ public class SettableListenableFutureTests { } @Test - public void cancelStateThrowsExceptionWhenCallingGetWithTimeout() throws ExecutionException, TimeoutException, InterruptedException { + void cancelStateThrowsExceptionWhenCallingGetWithTimeout() throws ExecutionException, TimeoutException, InterruptedException { new Thread(new Runnable() { @Override public void run() { diff --git a/spring-core/src/test/java/org/springframework/util/unit/DataSizeTests.java b/spring-core/src/test/java/org/springframework/util/unit/DataSizeTests.java index 04cd154670..74e830c5f6 100644 --- a/spring-core/src/test/java/org/springframework/util/unit/DataSizeTests.java +++ b/spring-core/src/test/java/org/springframework/util/unit/DataSizeTests.java @@ -26,190 +26,190 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException * * @author Stephane Nicoll */ -public class DataSizeTests { +class DataSizeTests { @Test - public void ofBytesToBytes() { + void ofBytesToBytes() { assertThat(DataSize.ofBytes(1024).toBytes()).isEqualTo(1024); } @Test - public void ofBytesToKilobytes() { + void ofBytesToKilobytes() { assertThat(DataSize.ofBytes(1024).toKilobytes()).isEqualTo(1); } @Test - public void ofKilobytesToKilobytes() { + void ofKilobytesToKilobytes() { assertThat(DataSize.ofKilobytes(1024).toKilobytes()).isEqualTo(1024); } @Test - public void ofKilobytesToMegabytes() { + void ofKilobytesToMegabytes() { assertThat(DataSize.ofKilobytes(1024).toMegabytes()).isEqualTo(1); } @Test - public void ofMegabytesToMegabytes() { + void ofMegabytesToMegabytes() { assertThat(DataSize.ofMegabytes(1024).toMegabytes()).isEqualTo(1024); } @Test - public void ofMegabytesToGigabytes() { + void ofMegabytesToGigabytes() { assertThat(DataSize.ofMegabytes(2048).toGigabytes()).isEqualTo(2); } @Test - public void ofGigabytesToGigabytes() { + void ofGigabytesToGigabytes() { assertThat(DataSize.ofGigabytes(4096).toGigabytes()).isEqualTo(4096); } @Test - public void ofGigabytesToTerabytes() { + void ofGigabytesToTerabytes() { assertThat(DataSize.ofGigabytes(4096).toTerabytes()).isEqualTo(4); } @Test - public void ofTerabytesToGigabytes() { + void ofTerabytesToGigabytes() { assertThat(DataSize.ofTerabytes(1).toGigabytes()).isEqualTo(1024); } @Test - public void ofWithBytesUnit() { + void ofWithBytesUnit() { assertThat(DataSize.of(10, DataUnit.BYTES)).isEqualTo(DataSize.ofBytes(10)); } @Test - public void ofWithKilobytesUnit() { + void ofWithKilobytesUnit() { assertThat(DataSize.of(20, DataUnit.KILOBYTES)).isEqualTo(DataSize.ofKilobytes(20)); } @Test - public void ofWithMegabytesUnit() { + void ofWithMegabytesUnit() { assertThat(DataSize.of(30, DataUnit.MEGABYTES)).isEqualTo(DataSize.ofMegabytes(30)); } @Test - public void ofWithGigabytesUnit() { + void ofWithGigabytesUnit() { assertThat(DataSize.of(40, DataUnit.GIGABYTES)).isEqualTo(DataSize.ofGigabytes(40)); } @Test - public void ofWithTerabytesUnit() { + void ofWithTerabytesUnit() { assertThat(DataSize.of(50, DataUnit.TERABYTES)).isEqualTo(DataSize.ofTerabytes(50)); } @Test - public void parseWithDefaultUnitUsesBytes() { + void parseWithDefaultUnitUsesBytes() { assertThat(DataSize.parse("1024")).isEqualTo(DataSize.ofKilobytes(1)); } @Test - public void parseNegativeNumberWithDefaultUnitUsesBytes() { + void parseNegativeNumberWithDefaultUnitUsesBytes() { assertThat(DataSize.parse("-1")).isEqualTo(DataSize.ofBytes(-1)); } @Test - public void parseWithNullDefaultUnitUsesBytes() { + void parseWithNullDefaultUnitUsesBytes() { assertThat(DataSize.parse("1024", null)).isEqualTo(DataSize.ofKilobytes(1)); } @Test - public void parseNegativeNumberWithNullDefaultUnitUsesBytes() { + void parseNegativeNumberWithNullDefaultUnitUsesBytes() { assertThat(DataSize.parse("-1024", null)).isEqualTo(DataSize.ofKilobytes(-1)); } @Test - public void parseWithCustomDefaultUnit() { + void parseWithCustomDefaultUnit() { assertThat(DataSize.parse("1", DataUnit.KILOBYTES)).isEqualTo(DataSize.ofKilobytes(1)); } @Test - public void parseNegativeNumberWithCustomDefaultUnit() { + void parseNegativeNumberWithCustomDefaultUnit() { assertThat(DataSize.parse("-1", DataUnit.KILOBYTES)).isEqualTo(DataSize.ofKilobytes(-1)); } @Test - public void parseWithBytes() { + void parseWithBytes() { assertThat(DataSize.parse("1024B")).isEqualTo(DataSize.ofKilobytes(1)); } @Test - public void parseWithNegativeBytes() { + void parseWithNegativeBytes() { assertThat(DataSize.parse("-1024B")).isEqualTo(DataSize.ofKilobytes(-1)); } @Test - public void parseWithPositiveBytes() { + void parseWithPositiveBytes() { assertThat(DataSize.parse("+1024B")).isEqualTo(DataSize.ofKilobytes(1)); } @Test - public void parseWithKilobytes() { + void parseWithKilobytes() { assertThat(DataSize.parse("1KB")).isEqualTo(DataSize.ofBytes(1024)); } @Test - public void parseWithNegativeKilobytes() { + void parseWithNegativeKilobytes() { assertThat(DataSize.parse("-1KB")).isEqualTo(DataSize.ofBytes(-1024)); } @Test - public void parseWithMegabytes() { + void parseWithMegabytes() { assertThat(DataSize.parse("4MB")).isEqualTo(DataSize.ofMegabytes(4)); } @Test - public void parseWithNegativeMegabytes() { + void parseWithNegativeMegabytes() { assertThat(DataSize.parse("-4MB")).isEqualTo(DataSize.ofMegabytes(-4)); } @Test - public void parseWithGigabytes() { + void parseWithGigabytes() { assertThat(DataSize.parse("1GB")).isEqualTo(DataSize.ofMegabytes(1024)); } @Test - public void parseWithNegativeGigabytes() { + void parseWithNegativeGigabytes() { assertThat(DataSize.parse("-1GB")).isEqualTo(DataSize.ofMegabytes(-1024)); } @Test - public void parseWithTerabytes() { + void parseWithTerabytes() { assertThat(DataSize.parse("1TB")).isEqualTo(DataSize.ofTerabytes(1)); } @Test - public void parseWithNegativeTerabytes() { + void parseWithNegativeTerabytes() { assertThat(DataSize.parse("-1TB")).isEqualTo(DataSize.ofTerabytes(-1)); } @Test - public void isNegativeWithPositive() { + void isNegativeWithPositive() { assertThat(DataSize.ofBytes(50).isNegative()).isFalse(); } @Test - public void isNegativeWithZero() { + void isNegativeWithZero() { assertThat(DataSize.ofBytes(0).isNegative()).isFalse(); } @Test - public void isNegativeWithNegative() { + void isNegativeWithNegative() { assertThat(DataSize.ofBytes(-1).isNegative()).isTrue(); } @Test - public void toStringUsesBytes() { + void toStringUsesBytes() { assertThat(DataSize.ofKilobytes(1).toString()).isEqualTo("1024B"); } @Test - public void toStringWithNegativeBytes() { + void toStringWithNegativeBytes() { assertThat(DataSize.ofKilobytes(-1).toString()).isEqualTo("-1024B"); } @Test - public void parseWithUnsupportedUnit() { + void parseWithUnsupportedUnit() { assertThatIllegalArgumentException().isThrownBy(() -> DataSize.parse("3WB")) .withMessage("'3WB' is not a valid data size"); diff --git a/spring-core/src/test/java/org/springframework/util/xml/AbstractStaxHandlerTestCase.java b/spring-core/src/test/java/org/springframework/util/xml/AbstractStaxHandlerTestCase.java index 3c96fa2620..aa9a2b3584 100644 --- a/spring-core/src/test/java/org/springframework/util/xml/AbstractStaxHandlerTestCase.java +++ b/spring-core/src/test/java/org/springframework/util/xml/AbstractStaxHandlerTestCase.java @@ -41,7 +41,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Arjen Poutsma * @author Sam Brannen */ -public abstract class AbstractStaxHandlerTestCase { +abstract class AbstractStaxHandlerTestCase { private static final String COMPLEX_XML = "" + @@ -63,14 +63,14 @@ public abstract class AbstractStaxHandlerTestCase { @BeforeEach @SuppressWarnings("deprecation") // on JDK 9 - public void createXMLReader() throws Exception { + void createXMLReader() throws Exception { xmlReader = org.xml.sax.helpers.XMLReaderFactory.createXMLReader(); xmlReader.setEntityResolver((publicId, systemId) -> new InputSource(new StringReader(""))); } @Test - public void noNamespacePrefixes() throws Exception { + void noNamespacePrefixes() throws Exception { StringWriter stringWriter = new StringWriter(); AbstractStaxHandler handler = createStaxHandler(new StreamResult(stringWriter)); xmlReader.setContentHandler(handler); @@ -85,7 +85,7 @@ public abstract class AbstractStaxHandlerTestCase { } @Test - public void namespacePrefixes() throws Exception { + void namespacePrefixes() throws Exception { StringWriter stringWriter = new StringWriter(); AbstractStaxHandler handler = createStaxHandler(new StreamResult(stringWriter)); xmlReader.setContentHandler(handler); @@ -100,7 +100,7 @@ public abstract class AbstractStaxHandlerTestCase { } @Test - public void noNamespacePrefixesDom() throws Exception { + void noNamespacePrefixesDom() throws Exception { DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); documentBuilderFactory.setNamespaceAware(true); DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); @@ -121,7 +121,7 @@ public abstract class AbstractStaxHandlerTestCase { } @Test - public void namespacePrefixesDom() throws Exception { + void namespacePrefixesDom() throws Exception { DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); documentBuilderFactory.setNamespaceAware(true); DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); diff --git a/spring-core/src/test/java/org/springframework/util/xml/AbstractStaxXMLReaderTestCase.java b/spring-core/src/test/java/org/springframework/util/xml/AbstractStaxXMLReaderTestCase.java index 7f9f7994e5..0db830a6b0 100644 --- a/spring-core/src/test/java/org/springframework/util/xml/AbstractStaxXMLReaderTestCase.java +++ b/spring-core/src/test/java/org/springframework/util/xml/AbstractStaxXMLReaderTestCase.java @@ -53,7 +53,7 @@ import static org.mockito.Mockito.mock; /** * @author Arjen Poutsma */ -public abstract class AbstractStaxXMLReaderTestCase { +abstract class AbstractStaxXMLReaderTestCase { protected static XMLInputFactory inputFactory; @@ -64,7 +64,7 @@ public abstract class AbstractStaxXMLReaderTestCase { @BeforeEach @SuppressWarnings("deprecation") // on JDK 9 - public void setUp() throws Exception { + void setUp() throws Exception { inputFactory = XMLInputFactory.newInstance(); standardReader = org.xml.sax.helpers.XMLReaderFactory.createXMLReader(); standardContentHandler = mockContentHandler(); @@ -73,7 +73,7 @@ public abstract class AbstractStaxXMLReaderTestCase { @Test - public void contentHandlerNamespacesNoPrefixes() throws Exception { + void contentHandlerNamespacesNoPrefixes() throws Exception { standardReader.setFeature("http://xml.org/sax/features/namespaces", true); standardReader.setFeature("http://xml.org/sax/features/namespace-prefixes", false); standardReader.parse(new InputSource(createTestInputStream())); @@ -89,7 +89,7 @@ public abstract class AbstractStaxXMLReaderTestCase { } @Test - public void contentHandlerNamespacesPrefixes() throws Exception { + void contentHandlerNamespacesPrefixes() throws Exception { standardReader.setFeature("http://xml.org/sax/features/namespaces", true); standardReader.setFeature("http://xml.org/sax/features/namespace-prefixes", true); standardReader.parse(new InputSource(createTestInputStream())); @@ -105,7 +105,7 @@ public abstract class AbstractStaxXMLReaderTestCase { } @Test - public void contentHandlerNoNamespacesPrefixes() throws Exception { + void contentHandlerNoNamespacesPrefixes() throws Exception { standardReader.setFeature("http://xml.org/sax/features/namespaces", false); standardReader.setFeature("http://xml.org/sax/features/namespace-prefixes", true); standardReader.parse(new InputSource(createTestInputStream())); @@ -121,7 +121,7 @@ public abstract class AbstractStaxXMLReaderTestCase { } @Test - public void whitespace() throws Exception { + void whitespace() throws Exception { String xml = " Some text "; Transformer transformer = TransformerFactory.newInstance().newTransformer(); @@ -140,7 +140,7 @@ public abstract class AbstractStaxXMLReaderTestCase { } @Test - public void lexicalHandler() throws Exception { + void lexicalHandler() throws Exception { Resource testLexicalHandlerXml = new ClassPathResource("testLexicalHandler.xml", getClass()); LexicalHandler expectedLexicalHandler = mockLexicalHandler(); diff --git a/spring-core/src/test/java/org/springframework/util/xml/DomContentHandlerTests.java b/spring-core/src/test/java/org/springframework/util/xml/DomContentHandlerTests.java index eb877331cf..112762a861 100644 --- a/spring-core/src/test/java/org/springframework/util/xml/DomContentHandlerTests.java +++ b/spring-core/src/test/java/org/springframework/util/xml/DomContentHandlerTests.java @@ -34,7 +34,7 @@ import static org.assertj.core.api.Assertions.assertThat; /** * Unit tests for {@link DomContentHandler}. */ -public class DomContentHandlerTests { +class DomContentHandlerTests { private static final String XML_1 = "" + "" + "" + @@ -62,7 +62,7 @@ public class DomContentHandlerTests { @BeforeEach @SuppressWarnings("deprecation") // on JDK 9 - public void setUp() throws Exception { + void setUp() throws Exception { DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); documentBuilderFactory.setNamespaceAware(true); documentBuilder = documentBuilderFactory.newDocumentBuilder(); @@ -72,7 +72,7 @@ public class DomContentHandlerTests { @Test - public void contentHandlerDocumentNamespacePrefixes() throws Exception { + void contentHandlerDocumentNamespacePrefixes() throws Exception { xmlReader.setFeature("http://xml.org/sax/features/namespace-prefixes", true); handler = new DomContentHandler(result); expected = documentBuilder.parse(new InputSource(new StringReader(XML_1))); @@ -82,7 +82,7 @@ public class DomContentHandlerTests { } @Test - public void contentHandlerDocumentNoNamespacePrefixes() throws Exception { + void contentHandlerDocumentNoNamespacePrefixes() throws Exception { handler = new DomContentHandler(result); expected = documentBuilder.parse(new InputSource(new StringReader(XML_1))); xmlReader.setContentHandler(handler); @@ -91,7 +91,7 @@ public class DomContentHandlerTests { } @Test - public void contentHandlerElement() throws Exception { + void contentHandlerElement() throws Exception { Element rootElement = result.createElementNS("namespace", "root"); result.appendChild(rootElement); handler = new DomContentHandler(rootElement); diff --git a/spring-core/src/test/java/org/springframework/util/xml/ListBasedXMLEventReaderTests.java b/spring-core/src/test/java/org/springframework/util/xml/ListBasedXMLEventReaderTests.java index e95eb92eae..2b23a09a3d 100644 --- a/spring-core/src/test/java/org/springframework/util/xml/ListBasedXMLEventReaderTests.java +++ b/spring-core/src/test/java/org/springframework/util/xml/ListBasedXMLEventReaderTests.java @@ -42,7 +42,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; * @author Arjen Poutsma * @author Andrzej Hołowko */ -public class ListBasedXMLEventReaderTests { +class ListBasedXMLEventReaderTests { private final XMLInputFactory inputFactory = XMLInputFactory.newInstance(); @@ -50,7 +50,7 @@ public class ListBasedXMLEventReaderTests { @Test - public void standard() throws Exception { + void standard() throws Exception { String xml = "baz"; List events = readEvents(xml); @@ -64,7 +64,7 @@ public class ListBasedXMLEventReaderTests { } @Test - public void testGetElementText() throws Exception { + void getElementText() throws Exception { String xml = "baz"; List events = readEvents(xml); @@ -79,7 +79,7 @@ public class ListBasedXMLEventReaderTests { } @Test - public void testGetElementTextThrowsExceptionAtWrongPosition() throws Exception { + void getElementTextThrowsExceptionAtWrongPosition() throws Exception { String xml = "baz"; List events = readEvents(xml); diff --git a/spring-core/src/test/java/org/springframework/util/xml/SimpleNamespaceContextTests.java b/spring-core/src/test/java/org/springframework/util/xml/SimpleNamespaceContextTests.java index 2cb0c2efe0..4e9849e1f2 100644 --- a/spring-core/src/test/java/org/springframework/util/xml/SimpleNamespaceContextTests.java +++ b/spring-core/src/test/java/org/springframework/util/xml/SimpleNamespaceContextTests.java @@ -27,12 +27,11 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; - /** * @author Arjen Poutsma * @author Leo Arnold */ -public class SimpleNamespaceContextTests { +class SimpleNamespaceContextTests { private final String unboundPrefix = "unbound"; private final String prefix = "prefix"; @@ -45,13 +44,13 @@ public class SimpleNamespaceContextTests { @Test - public void getNamespaceURI_withNull() throws Exception { + void getNamespaceURI_withNull() throws Exception { assertThatIllegalArgumentException().isThrownBy(() -> context.getNamespaceURI(null)); } @Test - public void getNamespaceURI() { + void getNamespaceURI() { context.bindNamespaceUri(XMLConstants.XMLNS_ATTRIBUTE, additionalNamespaceUri); assertThat(context.getNamespaceURI(XMLConstants.XMLNS_ATTRIBUTE)) .as("Always returns \"http://www.w3.org/2000/xmlns/\" for \"xmlns\"") @@ -79,13 +78,13 @@ public class SimpleNamespaceContextTests { } @Test - public void getPrefix_withNull() throws Exception { + void getPrefix_withNull() throws Exception { assertThatIllegalArgumentException().isThrownBy(() -> context.getPrefix(null)); } @Test - public void getPrefix() { + void getPrefix() { assertThat(context.getPrefix(XMLConstants.XMLNS_ATTRIBUTE_NS_URI)) .as("Always returns \"xmlns\" for \"http://www.w3.org/2000/xmlns/\"") .isEqualTo(XMLConstants.XMLNS_ATTRIBUTE); @@ -102,13 +101,13 @@ public class SimpleNamespaceContextTests { } @Test - public void getPrefixes_withNull() throws Exception { + void getPrefixes_withNull() throws Exception { assertThatIllegalArgumentException().isThrownBy(() -> context.getPrefixes(null)); } @Test - public void getPrefixes_IteratorIsNotModifiable() throws Exception { + void getPrefixes_IteratorIsNotModifiable() throws Exception { context.bindNamespaceUri(prefix, namespaceUri); Iterator iterator = context.getPrefixes(namespaceUri); assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy( @@ -116,7 +115,7 @@ public class SimpleNamespaceContextTests { } @Test - public void getPrefixes() { + void getPrefixes() { assertThat(getItemSet(context.getPrefixes(XMLConstants.XMLNS_ATTRIBUTE_NS_URI))) .as("Returns only \"xmlns\" for \"http://www.w3.org/2000/xmlns/\"") .containsExactly(XMLConstants.XMLNS_ATTRIBUTE); @@ -135,19 +134,19 @@ public class SimpleNamespaceContextTests { } @Test - public void bindNamespaceUri_withNullNamespaceUri() { + void bindNamespaceUri_withNullNamespaceUri() { assertThatIllegalArgumentException().isThrownBy(() -> context.bindNamespaceUri("prefix", null)); } @Test - public void bindNamespaceUri_withNullPrefix() { + void bindNamespaceUri_withNullPrefix() { assertThatIllegalArgumentException().isThrownBy(() -> context.bindNamespaceUri(null, namespaceUri)); } @Test - public void bindNamespaceUri() { + void bindNamespaceUri() { context.bindNamespaceUri(prefix, namespaceUri); assertThat(context.getNamespaceURI(prefix)) .as("The Namespace URI was bound to the prefix") @@ -158,7 +157,7 @@ public class SimpleNamespaceContextTests { } @Test - public void getBoundPrefixes() { + void getBoundPrefixes() { context.bindNamespaceUri("prefix1", namespaceUri); context.bindNamespaceUri("prefix2", namespaceUri); context.bindNamespaceUri("prefix3", additionalNamespaceUri); @@ -168,7 +167,7 @@ public class SimpleNamespaceContextTests { } @Test - public void clear() { + void clear() { context.bindNamespaceUri("prefix1", namespaceUri); context.bindNamespaceUri("prefix2", namespaceUri); context.bindNamespaceUri("prefix3", additionalNamespaceUri); @@ -178,7 +177,7 @@ public class SimpleNamespaceContextTests { } @Test - public void removeBinding() { + void removeBinding() { context.removeBinding(unboundPrefix); context.bindNamespaceUri(prefix, namespaceUri); diff --git a/spring-core/src/test/java/org/springframework/util/xml/StaxEventHandlerTests.java b/spring-core/src/test/java/org/springframework/util/xml/StaxEventHandlerTests.java index 62917390ff..04da747eec 100644 --- a/spring-core/src/test/java/org/springframework/util/xml/StaxEventHandlerTests.java +++ b/spring-core/src/test/java/org/springframework/util/xml/StaxEventHandlerTests.java @@ -24,7 +24,7 @@ import javax.xml.transform.Result; /** * @author Arjen Poutsma */ -public class StaxEventHandlerTests extends AbstractStaxHandlerTestCase { +class StaxEventHandlerTests extends AbstractStaxHandlerTestCase { @Override protected AbstractStaxHandler createStaxHandler(Result result) throws XMLStreamException { diff --git a/spring-core/src/test/java/org/springframework/util/xml/StaxEventXMLReaderTests.java b/spring-core/src/test/java/org/springframework/util/xml/StaxEventXMLReaderTests.java index 698e80df1a..7e0cc4dca7 100644 --- a/spring-core/src/test/java/org/springframework/util/xml/StaxEventXMLReaderTests.java +++ b/spring-core/src/test/java/org/springframework/util/xml/StaxEventXMLReaderTests.java @@ -32,7 +32,7 @@ import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -public class StaxEventXMLReaderTests extends AbstractStaxXMLReaderTestCase { +class StaxEventXMLReaderTests extends AbstractStaxXMLReaderTestCase { public static final String CONTENT = ""; @@ -42,7 +42,7 @@ public class StaxEventXMLReaderTests extends AbstractStaxXMLReaderTestCase { } @Test - public void partial() throws Exception { + void partial() throws Exception { XMLInputFactory inputFactory = XMLInputFactory.newInstance(); XMLEventReader eventReader = inputFactory.createXMLEventReader(new StringReader(CONTENT)); eventReader.nextTag(); // skip to root diff --git a/spring-core/src/test/java/org/springframework/util/xml/StaxResultTests.java b/spring-core/src/test/java/org/springframework/util/xml/StaxResultTests.java index 5d9ca7b074..8d01583811 100644 --- a/spring-core/src/test/java/org/springframework/util/xml/StaxResultTests.java +++ b/spring-core/src/test/java/org/springframework/util/xml/StaxResultTests.java @@ -37,7 +37,7 @@ import static org.assertj.core.api.Assertions.assertThat; /** * @author Arjen Poutsma */ -public class StaxResultTests { +class StaxResultTests { private static final String XML = ""; @@ -46,14 +46,14 @@ public class StaxResultTests { private XMLOutputFactory inputFactory; @BeforeEach - public void setUp() throws Exception { + void setUp() throws Exception { TransformerFactory transformerFactory = TransformerFactory.newInstance(); transformer = transformerFactory.newTransformer(); inputFactory = XMLOutputFactory.newInstance(); } @Test - public void streamWriterSource() throws Exception { + void streamWriterSource() throws Exception { StringWriter stringWriter = new StringWriter(); XMLStreamWriter streamWriter = inputFactory.createXMLStreamWriter(stringWriter); Reader reader = new StringReader(XML); @@ -66,7 +66,7 @@ public class StaxResultTests { } @Test - public void eventWriterSource() throws Exception { + void eventWriterSource() throws Exception { StringWriter stringWriter = new StringWriter(); XMLEventWriter eventWriter = inputFactory.createXMLEventWriter(stringWriter); Reader reader = new StringReader(XML); diff --git a/spring-core/src/test/java/org/springframework/util/xml/StaxSourceTests.java b/spring-core/src/test/java/org/springframework/util/xml/StaxSourceTests.java index 9847b15aca..e16277f797 100644 --- a/spring-core/src/test/java/org/springframework/util/xml/StaxSourceTests.java +++ b/spring-core/src/test/java/org/springframework/util/xml/StaxSourceTests.java @@ -40,7 +40,7 @@ import static org.assertj.core.api.Assertions.assertThat; /** * @author Arjen Poutsma */ -public class StaxSourceTests { +class StaxSourceTests { private static final String XML = ""; @@ -51,7 +51,7 @@ public class StaxSourceTests { private DocumentBuilder documentBuilder; @BeforeEach - public void setUp() throws Exception { + void setUp() throws Exception { TransformerFactory transformerFactory = TransformerFactory.newInstance(); transformer = transformerFactory.newTransformer(); inputFactory = XMLInputFactory.newInstance(); @@ -61,7 +61,7 @@ public class StaxSourceTests { } @Test - public void streamReaderSourceToStreamResult() throws Exception { + void streamReaderSourceToStreamResult() throws Exception { XMLStreamReader streamReader = inputFactory.createXMLStreamReader(new StringReader(XML)); StaxSource source = new StaxSource(streamReader); assertThat(source.getXMLStreamReader()).as("Invalid streamReader returned").isEqualTo(streamReader); @@ -72,7 +72,7 @@ public class StaxSourceTests { } @Test - public void streamReaderSourceToDOMResult() throws Exception { + void streamReaderSourceToDOMResult() throws Exception { XMLStreamReader streamReader = inputFactory.createXMLStreamReader(new StringReader(XML)); StaxSource source = new StaxSource(streamReader); assertThat(source.getXMLStreamReader()).as("Invalid streamReader returned").isEqualTo(streamReader); @@ -85,7 +85,7 @@ public class StaxSourceTests { } @Test - public void eventReaderSourceToStreamResult() throws Exception { + void eventReaderSourceToStreamResult() throws Exception { XMLEventReader eventReader = inputFactory.createXMLEventReader(new StringReader(XML)); StaxSource source = new StaxSource(eventReader); assertThat((Object) source.getXMLEventReader()).as("Invalid eventReader returned").isEqualTo(eventReader); @@ -96,7 +96,7 @@ public class StaxSourceTests { } @Test - public void eventReaderSourceToDOMResult() throws Exception { + void eventReaderSourceToDOMResult() throws Exception { XMLEventReader eventReader = inputFactory.createXMLEventReader(new StringReader(XML)); StaxSource source = new StaxSource(eventReader); assertThat((Object) source.getXMLEventReader()).as("Invalid eventReader returned").isEqualTo(eventReader); diff --git a/spring-core/src/test/java/org/springframework/util/xml/StaxStreamHandlerTests.java b/spring-core/src/test/java/org/springframework/util/xml/StaxStreamHandlerTests.java index 43ef806eb7..75640c522d 100644 --- a/spring-core/src/test/java/org/springframework/util/xml/StaxStreamHandlerTests.java +++ b/spring-core/src/test/java/org/springframework/util/xml/StaxStreamHandlerTests.java @@ -24,7 +24,7 @@ import javax.xml.transform.Result; /** * @author Arjen Poutsma */ -public class StaxStreamHandlerTests extends AbstractStaxHandlerTestCase { +class StaxStreamHandlerTests extends AbstractStaxHandlerTestCase { @Override protected AbstractStaxHandler createStaxHandler(Result result) throws XMLStreamException { diff --git a/spring-core/src/test/java/org/springframework/util/xml/StaxStreamXMLReaderTests.java b/spring-core/src/test/java/org/springframework/util/xml/StaxStreamXMLReaderTests.java index 6d33ae8b4b..404bef5ae8 100644 --- a/spring-core/src/test/java/org/springframework/util/xml/StaxStreamXMLReaderTests.java +++ b/spring-core/src/test/java/org/springframework/util/xml/StaxStreamXMLReaderTests.java @@ -35,7 +35,7 @@ import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -public class StaxStreamXMLReaderTests extends AbstractStaxXMLReaderTestCase { +class StaxStreamXMLReaderTests extends AbstractStaxXMLReaderTestCase { public static final String CONTENT = ""; @@ -45,7 +45,7 @@ public class StaxStreamXMLReaderTests extends AbstractStaxXMLReaderTestCase { } @Test - public void partial() throws Exception { + void partial() throws Exception { XMLInputFactory inputFactory = XMLInputFactory.newInstance(); XMLStreamReader streamReader = inputFactory.createXMLStreamReader(new StringReader(CONTENT)); streamReader.nextTag(); // skip to root diff --git a/spring-core/src/test/java/org/springframework/util/xml/StaxUtilsTests.java b/spring-core/src/test/java/org/springframework/util/xml/StaxUtilsTests.java index d4306bcc38..ea98d2bbf3 100644 --- a/spring-core/src/test/java/org/springframework/util/xml/StaxUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/util/xml/StaxUtilsTests.java @@ -40,17 +40,17 @@ import static org.assertj.core.api.Assertions.assertThat; /** * @author Arjen Poutsma */ -public class StaxUtilsTests { +class StaxUtilsTests { @Test - public void isStaxSourceInvalid() throws Exception { + void isStaxSourceInvalid() throws Exception { assertThat(StaxUtils.isStaxSource(new DOMSource())).as("A StAX Source").isFalse(); assertThat(StaxUtils.isStaxSource(new SAXSource())).as("A StAX Source").isFalse(); assertThat(StaxUtils.isStaxSource(new StreamSource())).as("A StAX Source").isFalse(); } @Test - public void isStaxSource() throws Exception { + void isStaxSource() throws Exception { XMLInputFactory inputFactory = XMLInputFactory.newInstance(); String expected = ""; XMLStreamReader streamReader = inputFactory.createXMLStreamReader(new StringReader(expected)); @@ -60,7 +60,7 @@ public class StaxUtilsTests { } @Test - public void isStaxSourceJaxp14() throws Exception { + void isStaxSourceJaxp14() throws Exception { XMLInputFactory inputFactory = XMLInputFactory.newInstance(); String expected = ""; XMLStreamReader streamReader = inputFactory.createXMLStreamReader(new StringReader(expected)); @@ -70,14 +70,14 @@ public class StaxUtilsTests { } @Test - public void isStaxResultInvalid() throws Exception { + void isStaxResultInvalid() throws Exception { assertThat(StaxUtils.isStaxResult(new DOMResult())).as("A StAX Result").isFalse(); assertThat(StaxUtils.isStaxResult(new SAXResult())).as("A StAX Result").isFalse(); assertThat(StaxUtils.isStaxResult(new StreamResult())).as("A StAX Result").isFalse(); } @Test - public void isStaxResult() throws Exception { + void isStaxResult() throws Exception { XMLOutputFactory outputFactory = XMLOutputFactory.newInstance(); XMLStreamWriter streamWriter = outputFactory.createXMLStreamWriter(new StringWriter()); Result result = StaxUtils.createCustomStaxResult(streamWriter); @@ -86,7 +86,7 @@ public class StaxUtilsTests { } @Test - public void isStaxResultJaxp14() throws Exception { + void isStaxResultJaxp14() throws Exception { XMLOutputFactory outputFactory = XMLOutputFactory.newInstance(); XMLStreamWriter streamWriter = outputFactory.createXMLStreamWriter(new StringWriter()); StAXResult result = new StAXResult(streamWriter); diff --git a/spring-core/src/test/java/org/springframework/util/xml/TransformerUtilsTests.java b/spring-core/src/test/java/org/springframework/util/xml/TransformerUtilsTests.java index 05c66a86b6..564579da7e 100644 --- a/spring-core/src/test/java/org/springframework/util/xml/TransformerUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/util/xml/TransformerUtilsTests.java @@ -36,10 +36,10 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException * @author Rick Evans * @author Arjen Poutsma */ -public class TransformerUtilsTests { +class TransformerUtilsTests { @Test - public void enableIndentingSunnyDay() throws Exception { + void enableIndentingSunnyDay() throws Exception { Transformer transformer = new StubTransformer(); TransformerUtils.enableIndenting(transformer); String indent = transformer.getOutputProperty(OutputKeys.INDENT); @@ -51,7 +51,7 @@ public class TransformerUtilsTests { } @Test - public void enableIndentingSunnyDayWithCustomKosherIndentAmount() throws Exception { + void enableIndentingSunnyDayWithCustomKosherIndentAmount() throws Exception { final String indentAmountProperty = "10"; Transformer transformer = new StubTransformer(); TransformerUtils.enableIndenting(transformer, Integer.valueOf(indentAmountProperty)); @@ -64,7 +64,7 @@ public class TransformerUtilsTests { } @Test - public void disableIndentingSunnyDay() throws Exception { + void disableIndentingSunnyDay() throws Exception { Transformer transformer = new StubTransformer(); TransformerUtils.disableIndenting(transformer); String indent = transformer.getOutputProperty(OutputKeys.INDENT); @@ -73,25 +73,25 @@ public class TransformerUtilsTests { } @Test - public void enableIndentingWithNullTransformer() throws Exception { + void enableIndentingWithNullTransformer() throws Exception { assertThatIllegalArgumentException().isThrownBy(() -> TransformerUtils.enableIndenting(null)); } @Test - public void disableIndentingWithNullTransformer() throws Exception { + void disableIndentingWithNullTransformer() throws Exception { assertThatIllegalArgumentException().isThrownBy(() -> TransformerUtils.disableIndenting(null)); } @Test - public void enableIndentingWithNegativeIndentAmount() throws Exception { + void enableIndentingWithNegativeIndentAmount() throws Exception { assertThatIllegalArgumentException().isThrownBy(() -> TransformerUtils.enableIndenting(new StubTransformer(), -21938)); } @Test - public void enableIndentingWithZeroIndentAmount() throws Exception { + void enableIndentingWithZeroIndentAmount() throws Exception { TransformerUtils.enableIndenting(new StubTransformer(), 0); } diff --git a/spring-core/src/test/java/org/springframework/util/xml/XMLEventStreamReaderTests.java b/spring-core/src/test/java/org/springframework/util/xml/XMLEventStreamReaderTests.java index 733fcfa7f8..27fe8a17c4 100644 --- a/spring-core/src/test/java/org/springframework/util/xml/XMLEventStreamReaderTests.java +++ b/spring-core/src/test/java/org/springframework/util/xml/XMLEventStreamReaderTests.java @@ -34,7 +34,7 @@ import org.springframework.tests.XmlContent; import static org.assertj.core.api.Assertions.assertThat; -public class XMLEventStreamReaderTests { +class XMLEventStreamReaderTests { private static final String XML = "content" @@ -43,21 +43,21 @@ public class XMLEventStreamReaderTests { private XMLEventStreamReader streamReader; @BeforeEach - public void createStreamReader() throws Exception { + void createStreamReader() throws Exception { XMLInputFactory inputFactory = XMLInputFactory.newInstance(); XMLEventReader eventReader = inputFactory.createXMLEventReader(new StringReader(XML)); streamReader = new XMLEventStreamReader(eventReader); } @Test - public void readAll() throws Exception { + void readAll() throws Exception { while (streamReader.hasNext()) { streamReader.next(); } } @Test - public void readCorrect() throws Exception { + void readCorrect() throws Exception { Transformer transformer = TransformerFactory.newInstance().newTransformer(); StAXSource source = new StAXSource(streamReader); StringWriter writer = new StringWriter(); diff --git a/spring-core/src/test/java/org/springframework/util/xml/XMLEventStreamWriterTests.java b/spring-core/src/test/java/org/springframework/util/xml/XMLEventStreamWriterTests.java index af6a3c2716..efa07d1996 100644 --- a/spring-core/src/test/java/org/springframework/util/xml/XMLEventStreamWriterTests.java +++ b/spring-core/src/test/java/org/springframework/util/xml/XMLEventStreamWriterTests.java @@ -30,7 +30,7 @@ import org.springframework.tests.XmlContent; import static org.assertj.core.api.Assertions.assertThat; -public class XMLEventStreamWriterTests { +class XMLEventStreamWriterTests { private static final String XML = "content"; @@ -40,7 +40,7 @@ public class XMLEventStreamWriterTests { private StringWriter stringWriter; @BeforeEach - public void createStreamReader() throws Exception { + void createStreamReader() throws Exception { stringWriter = new StringWriter(); XMLOutputFactory outputFactory = XMLOutputFactory.newInstance(); XMLEventWriter eventWriter = outputFactory.createXMLEventWriter(stringWriter); @@ -48,7 +48,7 @@ public class XMLEventStreamWriterTests { } @Test - public void write() throws Exception { + void write() throws Exception { streamWriter.writeStartDocument(); streamWriter.writeProcessingInstruction("pi", "content"); streamWriter.writeStartElement("namespace", "root");