From 05ebca8677c264ff78dfed45171859427d992212 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Nicoll?= Date: Wed, 3 Jan 2024 16:34:07 +0100 Subject: [PATCH] Polish --- .../aop/aspectj/AfterAdviceBindingTests.java | 4 +- .../AfterThrowingAdviceBindingTests.java | 16 +- .../AspectAndAdvicePrecedenceTests.java | 5 +- .../aop/aspectj/BeanNamePointcutTests.java | 4 +- ...tSelectionOnlyPointcutsAtAspectJTests.java | 4 +- ...sAndTargetSelectionOnlyPointcutsTests.java | 4 +- .../AnnotationBindingTestAspect.java | 4 +- .../autoproxy/AnnotationPointcutTests.java | 4 +- .../AspectImplementingInterfaceTests.java | 4 +- .../autoproxy/benchmark/BenchmarkTests.java | 6 +- .../autoproxy/spr3064/SPR3064Tests.java | 4 +- .../aop/config/AopNamespaceHandlerTests.java | 6 +- .../aop/framework/AbstractAopProxyTests.java | 137 +++++++++--------- .../aop/framework/CglibProxyTests.java | 8 +- .../aop/framework/JdkDynamicProxyTests.java | 4 +- .../aop/framework/ProxyFactoryBeanTests.java | 11 +- .../AdvisorAdapterRegistrationTests.java | 6 +- .../AdvisorAutoProxyCreatorTests.java | 6 +- .../BeanNameAutoProxyCreatorInitTests.java | 4 +- .../BeanNameAutoProxyCreatorTests.java | 4 +- .../target/CommonsPool2TargetSourceTests.java | 4 +- .../InjectAnnotationAutowireContextTests.java | 48 +++--- ...alifierAnnotationAutowireContextTests.java | 54 +++---- .../LookupMethodWrappedByCglibProxyTests.java | 10 +- .../factory/xml/QualifierAnnotationTests.java | 30 ++-- .../factory/xml/XmlBeanFactoryTestTypes.java | 6 +- .../factory/xml/XmlBeanFactoryTests.java | 6 +- .../support/CustomNamespaceHandlerTests.java | 24 +-- .../cache/NoOpCacheManagerTests.java | 14 +- .../AnnotationCacheOperationSourceTests.java | 60 ++++---- .../ConcurrentMapCacheManagerTests.java | 10 +- .../concurrent/ConcurrentMapCacheTests.java | 16 +- .../AnnotationDrivenCacheConfigTests.java | 4 +- .../AnnotationNamespaceDrivenTests.java | 12 +- .../config/CacheAdviceNamespaceTests.java | 6 +- .../cache/config/CustomInterceptorTests.java | 6 +- .../ExpressionCachingIntegrationTests.java | 4 +- .../CacheProxyFactoryBeanTests.java | 6 +- .../interceptor/CachePutEvaluationTests.java | 12 +- .../interceptor/CacheSyncFailureTests.java | 18 +-- .../interceptor/ExpressionEvaluatorTests.java | 18 +-- .../interceptor/SimpleKeyGeneratorTests.java | 20 +-- .../AbstractCircularImportDetectionTests.java | 8 +- ...gressiveFactoryBeanInstantiationTests.java | 10 +- ...notationConfigApplicationContextTests.java | 6 +- .../AnnotationScopeMetadataResolverTests.java | 22 +-- .../AsmCircularImportDetectionTests.java | 6 +- .../annotation/BeanMethodMetadataTests.java | 4 +- .../BeanMethodPolymorphismTests.java | 28 ++-- .../ClassPathBeanDefinitionScannerTests.java | 60 ++++---- ...PathFactoryBeanDefinitionScannerTests.java | 6 +- ...ommonAnnotationBeanPostProcessorTests.java | 48 +++--- ...ScanParserBeanDefinitionDefaultsTests.java | 30 ++-- .../ComponentScanParserScopedProxyTests.java | 14 +- .../annotation/ComponentScanParserTests.java | 20 +-- ...nClassPostConstructAndAutowiringTests.java | 8 +- ...lassPostProcessorAotContributionTests.java | 4 +- .../ConfigurationClassPostProcessorTests.java | 10 +- .../ConfigurationClassWithConditionTests.java | 30 ++-- ...tionWithFactoryBeanAndAutowiringTests.java | 8 +- ...ithFactoryBeanBeanEarlyDeductionTests.java | 26 ++-- .../DeferredImportSelectorTests.java | 12 +- .../DestroyMethodInferenceTests.java | 8 +- .../context/annotation/DoubleScanTests.java | 4 +- .../annotation/ImportSelectorTests.java | 18 +-- .../ImportVersusDirectRegistrationTests.java | 10 +- ...alidConfigurationClassDefinitionTests.java | 6 +- .../annotation/ParserStrategyUtilsTests.java | 22 +-- .../ReflectionUtilsIntegrationTests.java | 6 +- .../context/annotation/SimpleConfigTests.java | 6 +- .../context/annotation/SimpleScanTests.java | 6 +- .../context/annotation/Spr11202Tests.java | 10 +- .../context/annotation/Spr12278Tests.java | 12 +- .../context/annotation/Spr12636Tests.java | 18 +-- .../context/annotation/Spr15275Tests.java | 4 +- .../context/annotation/Spr16217Tests.java | 19 +-- .../context/annotation/Spr6602Tests.java | 14 +- .../context/annotation/Spr8954Tests.java | 6 +- .../AutowiredConfigurationTests.java | 4 +- ...anAnnotationAttributePropagationTests.java | 26 ++-- ...assWithPlaceholderConfigurerBeanTests.java | 4 +- .../ImportAnnotationDetectionTests.java | 10 +- .../configuration/ImportResourceTests.java | 20 +-- .../ImportWithConditionTests.java | 8 +- .../configuration/ScopingTests.java | 22 +-- .../configuration/Spr10668Tests.java | 6 +- .../configuration/Spr10744Tests.java | 6 +- .../jsr330/SpringAtInjectTckTests.java | 4 +- .../annotation/spr10546/Spr10546Tests.java | 26 ++-- .../annotation/spr12233/Spr12233Tests.java | 6 +- .../AnnotationDrivenEventListenerTests.java | 11 +- .../event/ApplicationContextEventTests.java | 66 ++++----- ...ApplicationListenerMethodAdapterTests.java | 70 ++++----- ...enericApplicationListenerAdapterTests.java | 26 ++-- .../context/event/LifecycleEventTests.java | 8 +- .../event/PayloadApplicationEventTests.java | 6 +- .../CachedExpressionEvaluatorTests.java | 10 +- .../EnvironmentAccessorIntegrationTests.java | 6 +- .../expression/FactoryBeanAccessTests.java | 10 +- .../context/expression/MapAccessorTests.java | 6 +- .../MethodBasedEvaluationContextTests.java | 16 +- .../GroovyBeanDefinitionReaderTests.java | 4 +- .../i18n/LocaleContextHolderTests.java | 14 +- .../CandidateComponentsIndexLoaderTests.java | 18 +-- .../index/CandidateComponentsIndexTests.java | 12 +- .../ClassPathXmlApplicationContextTests.java | 6 +- .../ConversionServiceFactoryBeanTests.java | 3 +- .../DefaultLifecycleProcessorTests.java | 5 +- .../support/EnvironmentIntegrationTests.java | 6 +- .../FactoryBeanAndApplicationListener.java | 4 +- .../GenericApplicationContextTests.java | 10 +- .../context/support/NoOpAdvice.java | 4 +- ...ertySourcesPlaceholderConfigurerTests.java | 38 ++--- .../ResourceBundleMessageSourceTests.java | 22 +-- ...erializableBeanFactoryMemoryLeakTests.java | 12 +- .../context/support/Service.java | 27 ++-- .../support/SimpleThreadScopeTests.java | 6 +- ...ticApplicationContextMulticasterTests.java | 6 +- .../StaticApplicationContextTests.java | 6 +- .../support/StaticMessageSourceTests.java | 22 +-- .../config/JeeNamespaceHandlerEventTests.java | 12 +- .../ejb/config/JeeNamespaceHandlerTests.java | 24 +-- .../format/datetime/DateFormatterTests.java | 26 ++-- .../format/datetime/DateFormattingTests.java | 4 +- .../DateTimeFormatterFactoryBeanTests.java | 12 +- .../DateTimeFormatterFactoryTests.java | 16 +- .../standard/DateTimeFormattingTests.java | 6 +- .../standard/InstantFormatterTests.java | 6 +- .../number/CurrencyStyleFormatterTests.java | 16 +- .../format/number/NumberFormattingTests.java | 26 ++-- .../number/NumberStyleFormatterTests.java | 12 +- .../number/PercentStyleFormatterTests.java | 12 +- .../number/money/MoneyFormattingTests.java | 20 +-- ...tingConversionServiceFactoryBeanTests.java | 19 ++- .../InstrumentableClassLoaderTests.java | 6 +- .../ReflectiveLoadTimeWeaverTests.java | 16 +- ...ceOverridingShadowingClassLoaderTests.java | 16 +- .../springframework/jmx/AbstractJmxTests.java | 6 +- .../jmx/AbstractMBeanServerTests.java | 8 +- .../access/MBeanClientInterceptorTests.java | 4 +- .../RemoteMBeanClientInterceptorTests.java | 4 +- .../jmx/export/LazyInitMBeanTests.java | 15 +- .../jmx/export/MBeanExporterTests.java | 37 +---- .../jmx/export/NotificationListenerTests.java | 33 ++--- .../export/NotificationPublisherTests.java | 27 ++-- .../AnnotationMetadataAssemblerTests.java | 12 +- .../annotation/AnnotationTestBeanFactory.java | 4 +- .../EnableMBeanExportConfigurationTests.java | 24 +-- .../annotation/JmxUtilsAnnotationTests.java | 8 +- .../assembler/AbstractJmxAssemblerTests.java | 33 ++--- .../AbstractMetadataAssemblerTests.java | 32 ++-- ...aceBasedMBeanInfoAssemblerCustomTests.java | 6 +- ...aceBasedMBeanInfoAssemblerMappedTests.java | 16 +- ...InterfaceBasedMBeanInfoAssemblerTests.java | 4 +- ...ExclusionMBeanInfoAssemblerComboTests.java | 10 +- ...xclusionMBeanInfoAssemblerMappedTests.java | 10 +- ...usionMBeanInfoAssemblerNotMappedTests.java | 10 +- ...ethodExclusionMBeanInfoAssemblerTests.java | 8 +- ...ameBasedMBeanInfoAssemblerMappedTests.java | 12 +- ...ethodNameBasedMBeanInfoAssemblerTests.java | 8 +- .../assembler/ReflectiveAssemblerTests.java | 4 +- .../naming/AbstractNamingStrategyTests.java | 6 +- .../naming/IdentityNamingStrategyTests.java | 6 +- .../export/naming/KeyNamingStrategyTests.java | 6 +- .../PropertiesFileNamingStrategyTests.java | 4 +- .../naming/PropertiesNamingStrategyTests.java | 4 +- .../ModelMBeanNotificationPublisherTests.java | 18 +-- .../ConnectorServerFactoryBeanTests.java | 6 +- ...MBeanServerConnectionFactoryBeanTests.java | 4 +- .../support/MBeanServerFactoryBeanTests.java | 8 +- .../jndi/JndiObjectFactoryBeanTests.java | 54 +++---- .../jndi/JndiPropertySourceTests.java | 23 ++- .../jndi/JndiTemplateEditorTests.java | 10 +- .../jndi/JndiTemplateTests.java | 18 +-- ...otationAsyncExecutionInterceptorTests.java | 4 +- ...AsyncAnnotationBeanPostProcessorTests.java | 22 +-- .../annotation/AsyncExecutionTests.java | 8 +- .../annotation/AsyncResultTests.java | 12 +- .../annotation/EnableAsyncTests.java | 34 ++--- .../annotation/EnableSchedulingTests.java | 12 +- ...onBeanPostProcessorObservabilityTests.java | 4 +- .../AbstractSchedulingTaskExecutorTests.java | 4 +- .../ScheduledExecutorFactoryBeanTests.java | 4 +- .../ThreadPoolTaskSchedulerTests.java | 4 +- ...tationDrivenBeanDefinitionParserTests.java | 16 +- .../ExecutorBeanDefinitionParserTests.java | 28 ++-- ...heduledTasksBeanDefinitionParserTests.java | 16 +- .../SchedulerBeanDefinitionParserTests.java | 12 +- .../support/CronExpressionTests.java | 16 +- .../bsh/BshScriptEvaluatorTests.java | 10 +- .../config/ScriptingDefaultsTests.java | 14 +- .../scripting/groovy/GroovyAspectTests.java | 17 +-- .../groovy/GroovyClassLoadingTests.java | 4 +- .../groovy/GroovyScriptEvaluatorTests.java | 20 +-- .../groovy/GroovyScriptFactoryTests.java | 78 +++++----- .../scripting/groovy/LogUserAdvice.java | 4 +- .../scripting/groovy/TestService.java | 4 +- .../RefreshableScriptTargetSourceTests.java | 6 +- .../support/ResourceScriptSourceTests.java | 12 +- .../ScriptFactoryPostProcessorTests.java | 20 +-- .../support/StaticScriptSourceTests.java | 20 +-- .../org/springframework/ui/ModelMapTests.java | 54 +++---- .../springframework/util/MBeanTestUtils.java | 4 +- .../validation/DataBinderConstructTests.java | 4 +- .../DataBinderFieldAccessTests.java | 10 +- .../validation/DataBinderTests.java | 18 +-- .../DefaultMessageCodesResolverTests.java | 24 +-- .../validation/ValidationUtilsTests.java | 22 +-- .../validation/ValidatorTests.java | 6 +- .../BeanValidationPostProcessorTests.java | 16 +- ...hodValidationAdapterPropertyPathTests.java | 4 +- .../MethodValidationAdapterTests.java | 4 +- .../MethodValidationProxyTests.java | 12 +- .../SpringValidatorAdapterTests.java | 10 +- .../jmx/export/annotation/lazyAssembling.xml | 2 +- .../jmx/export/autodetectLazyMBeans.xml | 2 +- .../testfixture/jmx/export/Person.java | 32 ++++ .../testfixture/jmx/export/PersonMBean.java | 23 +++ 218 files changed, 1576 insertions(+), 1591 deletions(-) create mode 100644 spring-context/src/testFixtures/java/org/springframework/context/testfixture/jmx/export/Person.java create mode 100644 spring-context/src/testFixtures/java/org/springframework/context/testfixture/jmx/export/PersonMBean.java diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/AfterAdviceBindingTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/AfterAdviceBindingTests.java index 92eecf43e4f..db658977159 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/AfterAdviceBindingTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/AfterAdviceBindingTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -64,7 +64,7 @@ class AfterAdviceBindingTests { } @AfterEach - void tearDown() throws Exception { + void tearDown() { this.ctx.close(); } diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/AfterThrowingAdviceBindingTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/AfterThrowingAdviceBindingTests.java index 7efa9b07ce9..f447f7d7869 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/AfterThrowingAdviceBindingTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/AfterThrowingAdviceBindingTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -62,14 +62,14 @@ class AfterThrowingAdviceBindingTests { @Test - void simpleAfterThrowing() throws Throwable { + void simpleAfterThrowing() { assertThatExceptionOfType(Throwable.class).isThrownBy(() -> this.testBean.exceptional(new Throwable())); verify(mockCollaborator).noArgs(); } @Test - void afterThrowingWithBinding() throws Throwable { + void afterThrowingWithBinding() { Throwable t = new Throwable(); assertThatExceptionOfType(Throwable.class).isThrownBy(() -> this.testBean.exceptional(t)); @@ -77,7 +77,7 @@ class AfterThrowingAdviceBindingTests { } @Test - void afterThrowingWithNamedTypeRestriction() throws Throwable { + void afterThrowingWithNamedTypeRestriction() { Throwable t = new Throwable(); assertThatExceptionOfType(Throwable.class).isThrownBy(() -> this.testBean.exceptional(t)); @@ -87,7 +87,7 @@ class AfterThrowingAdviceBindingTests { } @Test - void afterThrowingWithRuntimeExceptionBinding() throws Throwable { + void afterThrowingWithRuntimeExceptionBinding() { RuntimeException ex = new RuntimeException(); assertThatExceptionOfType(Throwable.class).isThrownBy(() -> this.testBean.exceptional(ex)); @@ -95,14 +95,14 @@ class AfterThrowingAdviceBindingTests { } @Test - void afterThrowingWithTypeSpecified() throws Throwable { + void afterThrowingWithTypeSpecified() { assertThatExceptionOfType(Throwable.class).isThrownBy(() -> this.testBean.exceptional(new Throwable())); verify(mockCollaborator).noArgsOnThrowableMatch(); } @Test - void afterThrowingWithRuntimeTypeSpecified() throws Throwable { + void afterThrowingWithRuntimeTypeSpecified() { assertThatExceptionOfType(Throwable.class).isThrownBy(() -> this.testBean.exceptional(new RuntimeException())); verify(mockCollaborator).noArgsOnRuntimeExceptionMatch(); @@ -123,7 +123,7 @@ final class AfterThrowingAdviceBindingTestAspect { void noArgsOnRuntimeExceptionMatch(); } - protected AfterThrowingAdviceBindingCollaborator collaborator = null; + AfterThrowingAdviceBindingCollaborator collaborator = null; public void setCollaborator(AfterThrowingAdviceBindingCollaborator aCollaborator) { this.collaborator = aCollaborator; diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/AspectAndAdvicePrecedenceTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/AspectAndAdvicePrecedenceTests.java index fddb34c3c68..c7f56212bc4 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/AspectAndAdvicePrecedenceTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/AspectAndAdvicePrecedenceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -242,8 +242,7 @@ class SimpleSpringBeforeAdvice implements MethodBeforeAdvice, BeanNameAware { * @see org.springframework.aop.MethodBeforeAdvice#before(java.lang.reflect.Method, java.lang.Object[], java.lang.Object) */ @Override - public void before(Method method, Object[] args, @Nullable Object target) - throws Throwable { + public void before(Method method, Object[] args, @Nullable Object target) { this.collaborator.beforeAdviceOne(this.name); } diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/BeanNamePointcutTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/BeanNamePointcutTests.java index b959233270b..ed740ab88ce 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/BeanNamePointcutTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/BeanNamePointcutTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -139,7 +139,7 @@ class BeanNamePointcutTests { private int interceptionCount; @Override - public void before(Method method, Object[] args, @Nullable Object target) throws Throwable { + public void before(Method method, Object[] args, @Nullable Object target) { interceptionCount++; } } diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/ThisAndTargetSelectionOnlyPointcutsAtAspectJTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/ThisAndTargetSelectionOnlyPointcutsAtAspectJTests.java index 7bc9ca4de0c..9a07f3f5e1c 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/ThisAndTargetSelectionOnlyPointcutsAtAspectJTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/ThisAndTargetSelectionOnlyPointcutsAtAspectJTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -119,7 +119,7 @@ class ThisAndTargetSelectionOnlyPointcutsAtAspectJTests { } interface TestInterface { - public void doIt(); + void doIt(); } static class TestImpl implements TestInterface { diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/ThisAndTargetSelectionOnlyPointcutsTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/ThisAndTargetSelectionOnlyPointcutsTests.java index 413929b9772..ae3c314aa1b 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/ThisAndTargetSelectionOnlyPointcutsTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/ThisAndTargetSelectionOnlyPointcutsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -107,7 +107,7 @@ class ThisAndTargetSelectionOnlyPointcutsTests { interface TestInterface { - public void doIt(); + void doIt(); } diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AnnotationBindingTestAspect.java b/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AnnotationBindingTestAspect.java index 6fd601db7bc..b4bb26d719a 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AnnotationBindingTestAspect.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AnnotationBindingTestAspect.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +23,7 @@ import org.aspectj.lang.ProceedingJoinPoint; */ class AnnotationBindingTestAspect { - public String doWithAnnotation(ProceedingJoinPoint pjp, TestAnnotation testAnnotation) throws Throwable { + public String doWithAnnotation(ProceedingJoinPoint pjp, TestAnnotation testAnnotation) { return testAnnotation.value(); } diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AnnotationPointcutTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AnnotationPointcutTests.java index 21fc29ebdad..82cd932a2bc 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AnnotationPointcutTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AnnotationPointcutTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -65,7 +65,7 @@ class AnnotationPointcutTests { class TestMethodInterceptor implements MethodInterceptor { @Override - public Object invoke(MethodInvocation methodInvocation) throws Throwable { + public Object invoke(MethodInvocation methodInvocation) { return "this value"; } } diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectImplementingInterfaceTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectImplementingInterfaceTests.java index 613848e8a3f..8a3738ba91b 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectImplementingInterfaceTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectImplementingInterfaceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -51,7 +51,7 @@ class AspectImplementingInterfaceTests { interface AnInterface { - public void interfaceMethod(); + void interfaceMethod(); } diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/benchmark/BenchmarkTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/benchmark/BenchmarkTests.java index 563d2cd1461..69793e8ee3c 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/benchmark/BenchmarkTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/benchmark/BenchmarkTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -226,7 +226,7 @@ class TraceAfterReturningAdvice implements AfterReturningAdvice { public int afterTakesInt; @Override - public void afterReturning(Object returnValue, Method method, Object[] args, Object target) throws Throwable { + public void afterReturning(Object returnValue, Method method, Object[] args, Object target) { ++afterTakesInt; } @@ -270,7 +270,7 @@ class TraceBeforeAdvice implements MethodBeforeAdvice { public int beforeStringReturn; @Override - public void before(Method method, Object[] args, Object target) throws Throwable { + public void before(Method method, Object[] args, Object target) { ++beforeStringReturn; } diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/spr3064/SPR3064Tests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/spr3064/SPR3064Tests.java index f59c5c1af0c..9da8d7ed3b0 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/spr3064/SPR3064Tests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/spr3064/SPR3064Tests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -59,7 +59,7 @@ class SPR3064Tests { class TransactionInterceptor { @Around(value="execution(* *..Service.*(..)) && @annotation(transaction)") - public Object around(ProceedingJoinPoint pjp, Transaction transaction) throws Throwable { + public Object around(ProceedingJoinPoint pjp, Transaction transaction) { throw new RuntimeException("advice invoked"); //return pjp.proceed(); } diff --git a/spring-context/src/test/java/org/springframework/aop/config/AopNamespaceHandlerTests.java b/spring-context/src/test/java/org/springframework/aop/config/AopNamespaceHandlerTests.java index 64b2c09cd78..5120394b63b 100644 --- a/spring-context/src/test/java/org/springframework/aop/config/AopNamespaceHandlerTests.java +++ b/spring-context/src/test/java/org/springframework/aop/config/AopNamespaceHandlerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -157,11 +157,11 @@ class CountingAspectJAdvice { private int aroundCount; - public void myBeforeAdvice() throws Throwable { + public void myBeforeAdvice() { this.beforeCount++; } - public void myAfterAdvice() throws Throwable { + public void myAfterAdvice() { this.afterCount++; } diff --git a/spring-context/src/test/java/org/springframework/aop/framework/AbstractAopProxyTests.java b/spring-context/src/test/java/org/springframework/aop/framework/AbstractAopProxyTests.java index c2cb067fb36..75b564c2d30 100644 --- a/spring-context/src/test/java/org/springframework/aop/framework/AbstractAopProxyTests.java +++ b/spring-context/src/test/java/org/springframework/aop/framework/AbstractAopProxyTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -96,12 +96,12 @@ public abstract class AbstractAopProxyTests { * to ensure that it was used appropriately by code. */ @BeforeEach - public void reset() { + void reset() { mockTargetSource.reset(); } @AfterEach - public void verify() { + void verify() { mockTargetSource.verify(); } @@ -125,7 +125,7 @@ public abstract class AbstractAopProxyTests { * Simple test that if we set values we can get them out again. */ @Test - public void testValuesStick() { + void testValuesStick() { int age1 = 33; int age2 = 37; String name = "tony"; @@ -146,7 +146,7 @@ public abstract class AbstractAopProxyTests { } @Test - public void testSerializationAdviceAndTargetNotSerializable() throws Exception { + void testSerializationAdviceAndTargetNotSerializable() throws Exception { TestBean tb = new TestBean(); assertThat(SerializationTestUtils.isSerializable(tb)).isFalse(); @@ -159,7 +159,7 @@ public abstract class AbstractAopProxyTests { } @Test - public void testSerializationAdviceNotSerializable() throws Exception { + void testSerializationAdviceNotSerializable() throws Exception { SerializablePerson sp = new SerializablePerson(); assertThat(SerializationTestUtils.isSerializable(sp)).isTrue(); @@ -175,7 +175,7 @@ public abstract class AbstractAopProxyTests { } @Test - public void testSerializableTargetAndAdvice() throws Throwable { + void testSerializableTargetAndAdvice() throws Throwable { SerializablePerson personTarget = new SerializablePerson(); personTarget.setName("jim"); personTarget.setAge(26); @@ -245,7 +245,7 @@ public abstract class AbstractAopProxyTests { * Check also proxy exposure. */ @Test - public void testOneAdvisedObjectCallsAnother() { + void testOneAdvisedObjectCallsAnother() { int age1 = 33; int age2 = 37; @@ -290,7 +290,7 @@ public abstract class AbstractAopProxyTests { @Test - public void testReentrance() { + void testReentrance() { int age1 = 33; TestBean target1 = new TestBean(); @@ -314,7 +314,7 @@ public abstract class AbstractAopProxyTests { } @Test - public void testTargetCanGetProxy() { + void testTargetCanGetProxy() { NopInterceptor di = new NopInterceptor(); INeedsToSeeProxy target = new TargetChecker(); ProxyFactory proxyFactory = new ProxyFactory(target); @@ -343,24 +343,23 @@ public abstract class AbstractAopProxyTests { ProxyFactory pf1 = new ProxyFactory(et); assertThat(pf1.isExposeProxy()).isFalse(); INeedsToSeeProxy proxied = (INeedsToSeeProxy) createProxy(pf1); - assertThatIllegalStateException().isThrownBy(() -> - proxied.incrementViaProxy()); + assertThatIllegalStateException().isThrownBy(proxied::incrementViaProxy); } @Test - public void testContext() throws Throwable { + void testContext() { testContext(true); } @Test - public void testNoContext() throws Throwable { + void testNoContext() { testContext(false); } /** * @param context if true, want context */ - private void testContext(final boolean context) throws Throwable { + private void testContext(final boolean context) { final String s = "foo"; // Test return value MethodInterceptor mi = invocation -> { @@ -394,7 +393,7 @@ public abstract class AbstractAopProxyTests { * target returns {@code this} */ @Test - public void testTargetReturnsThis() throws Throwable { + void testTargetReturnsThis() { // Test return value TestBean raw = new OwnSpouse(); @@ -407,7 +406,7 @@ public abstract class AbstractAopProxyTests { } @Test - public void testDeclaredException() throws Throwable { + void testDeclaredException() { final Exception expectedException = new Exception(); // Test return value MethodInterceptor mi = invocation -> { @@ -435,7 +434,7 @@ public abstract class AbstractAopProxyTests { * org.springframework.cglib UndeclaredThrowableException */ @Test - public void testUndeclaredCheckedException() throws Throwable { + void testUndeclaredCheckedException() { final Exception unexpectedException = new Exception(); // Test return value MethodInterceptor mi = invocation -> { @@ -455,7 +454,7 @@ public abstract class AbstractAopProxyTests { } @Test - public void testUndeclaredUncheckedException() throws Throwable { + void testUndeclaredUncheckedException() { final RuntimeException unexpectedException = new RuntimeException(); // Test return value MethodInterceptor mi = invocation -> { @@ -481,7 +480,7 @@ public abstract class AbstractAopProxyTests { * so as to guarantee a consistent programming model. */ @Test - public void testTargetCanGetInvocationEvenIfNoAdviceChain() throws Throwable { + void testTargetCanGetInvocationEvenIfNoAdviceChain() { NeedsToSeeProxy target = new NeedsToSeeProxy(); AdvisedSupport pc = new AdvisedSupport(INeedsToSeeProxy.class); pc.setTarget(target); @@ -495,7 +494,7 @@ public abstract class AbstractAopProxyTests { } @Test - public void testTargetCanGetInvocation() throws Throwable { + void testTargetCanGetInvocation() { final InvocationCheckExposedInvocationTestBean expectedTarget = new InvocationCheckExposedInvocationTestBean(); AdvisedSupport pc = new AdvisedSupport(ITestBean.class, IOther.class); @@ -528,7 +527,7 @@ public abstract class AbstractAopProxyTests { * Test stateful interceptor */ @Test - public void testMixinWithIntroductionAdvisor() throws Throwable { + void testMixinWithIntroductionAdvisor() { TestBean tb = new TestBean(); ProxyFactory pc = new ProxyFactory(); pc.addInterface(ITestBean.class); @@ -539,7 +538,7 @@ public abstract class AbstractAopProxyTests { } @Test - public void testMixinWithIntroductionInfo() throws Throwable { + void testMixinWithIntroductionInfo() { TestBean tb = new TestBean(); ProxyFactory pc = new ProxyFactory(); pc.addInterface(ITestBean.class); @@ -572,7 +571,7 @@ public abstract class AbstractAopProxyTests { } @Test - public void testReplaceArgument() throws Throwable { + void testReplaceArgument() { TestBean tb = new TestBean(); ProxyFactory pc = new ProxyFactory(); pc.addInterface(ITestBean.class); @@ -593,7 +592,7 @@ public abstract class AbstractAopProxyTests { } @Test - public void testCanCastProxyToProxyConfig() throws Throwable { + void testCanCastProxyToProxyConfig() { TestBean tb = new TestBean(); ProxyFactory pc = new ProxyFactory(tb); NopInterceptor di = new NopInterceptor(); @@ -629,7 +628,7 @@ public abstract class AbstractAopProxyTests { } @Test - public void testAdviceImplementsIntroductionInfo() throws Throwable { + void testAdviceImplementsIntroductionInfo() { TestBean tb = new TestBean(); String name = "tony"; tb.setName(name); @@ -646,7 +645,7 @@ public abstract class AbstractAopProxyTests { } @Test - public void testCannotAddDynamicIntroductionAdviceExceptInIntroductionAdvice() throws Throwable { + void testCannotAddDynamicIntroductionAdviceExceptInIntroductionAdvice() { TestBean target = new TestBean(); target.setAge(21); ProxyFactory pc = new ProxyFactory(target); @@ -659,7 +658,7 @@ public abstract class AbstractAopProxyTests { } @Test - public void testRejectsBogusDynamicIntroductionAdviceWithNoAdapter() throws Throwable { + void testRejectsBogusDynamicIntroductionAdviceWithNoAdapter() { TestBean target = new TestBean(); target.setAge(21); ProxyFactory pc = new ProxyFactory(target); @@ -680,7 +679,7 @@ public abstract class AbstractAopProxyTests { * that are unsupported by the IntroductionInterceptor. */ @Test - public void testCannotAddIntroductionAdviceWithUnimplementedInterface() throws Throwable { + void testCannotAddIntroductionAdviceWithUnimplementedInterface() { TestBean target = new TestBean(); target.setAge(21); ProxyFactory pc = new ProxyFactory(target); @@ -696,7 +695,7 @@ public abstract class AbstractAopProxyTests { * as it's constrained by the interface. */ @Test - public void testIntroductionThrowsUncheckedException() throws Throwable { + void testIntroductionThrowsUncheckedException() { TestBean target = new TestBean(); target.setAge(21); ProxyFactory pc = new ProxyFactory(target); @@ -721,7 +720,7 @@ public abstract class AbstractAopProxyTests { * Should only be able to introduce interfaces, not classes. */ @Test - public void testCannotAddIntroductionAdviceToIntroduceClass() throws Throwable { + void testCannotAddIntroductionAdviceToIntroduceClass() { TestBean target = new TestBean(); target.setAge(21); ProxyFactory pc = new ProxyFactory(target); @@ -734,7 +733,7 @@ public abstract class AbstractAopProxyTests { } @Test - public void testCannotAddInterceptorWhenFrozen() throws Throwable { + void testCannotAddInterceptorWhenFrozen() { TestBean target = new TestBean(); target.setAge(21); ProxyFactory pc = new ProxyFactory(target); @@ -754,7 +753,7 @@ public abstract class AbstractAopProxyTests { * Check that casting to Advised can't get around advice freeze. */ @Test - public void testCannotAddAdvisorWhenFrozenUsingCast() throws Throwable { + void testCannotAddAdvisorWhenFrozenUsingCast() { TestBean target = new TestBean(); target.setAge(21); ProxyFactory pc = new ProxyFactory(target); @@ -774,7 +773,7 @@ public abstract class AbstractAopProxyTests { } @Test - public void testCannotRemoveAdvisorWhenFrozen() throws Throwable { + void testCannotRemoveAdvisorWhenFrozen() { TestBean target = new TestBean(); target.setAge(21); ProxyFactory pc = new ProxyFactory(target); @@ -799,7 +798,7 @@ public abstract class AbstractAopProxyTests { } @Test - public void testUseAsHashKey() { + void testUseAsHashKey() { TestBean target1 = new TestBean(); ProxyFactory pf1 = new ProxyFactory(target1); pf1.addAdvice(new NopInterceptor()); @@ -824,7 +823,7 @@ public abstract class AbstractAopProxyTests { * Check that the string is informative. */ @Test - public void testProxyConfigString() { + void testProxyConfigString() { TestBean target = new TestBean(); ProxyFactory pc = new ProxyFactory(target); pc.setInterfaces(ITestBean.class); @@ -840,7 +839,7 @@ public abstract class AbstractAopProxyTests { } @Test - public void testCanPreventCastToAdvisedUsingOpaque() { + void testCanPreventCastToAdvisedUsingOpaque() { TestBean target = new TestBean(); ProxyFactory pc = new ProxyFactory(target); pc.setInterfaces(ITestBean.class); @@ -861,7 +860,7 @@ public abstract class AbstractAopProxyTests { } @Test - public void testAdviceSupportListeners() throws Throwable { + void testAdviceSupportListeners() { TestBean target = new TestBean(); target.setAge(21); @@ -900,7 +899,7 @@ public abstract class AbstractAopProxyTests { } @Test - public void testExistingProxyChangesTarget() throws Throwable { + void testExistingProxyChangesTarget() { TestBean tb1 = new TestBean(); tb1.setAge(33); @@ -943,7 +942,7 @@ public abstract class AbstractAopProxyTests { } @Test - public void testDynamicMethodPointcutThatAlwaysAppliesStatically() throws Throwable { + void testDynamicMethodPointcutThatAlwaysAppliesStatically() { TestBean tb = new TestBean(); ProxyFactory pc = new ProxyFactory(); pc.addInterface(ITestBean.class); @@ -960,7 +959,7 @@ public abstract class AbstractAopProxyTests { } @Test - public void testDynamicMethodPointcutThatAppliesStaticallyOnlyToSetters() throws Throwable { + void testDynamicMethodPointcutThatAppliesStaticallyOnlyToSetters() { TestBean tb = new TestBean(); ProxyFactory pc = new ProxyFactory(); pc.addInterface(ITestBean.class); @@ -983,7 +982,7 @@ public abstract class AbstractAopProxyTests { } @Test - public void testStaticMethodPointcut() throws Throwable { + void testStaticMethodPointcut() { TestBean tb = new TestBean(); ProxyFactory pc = new ProxyFactory(); pc.addInterface(ITestBean.class); @@ -1005,7 +1004,7 @@ public abstract class AbstractAopProxyTests { * We can do this if we clone the invocation. */ @Test - public void testCloneInvocationToProceedThreeTimes() throws Throwable { + void testCloneInvocationToProceedThreeTimes() { TestBean tb = new TestBean(); ProxyFactory pc = new ProxyFactory(tb); pc.addInterface(ITestBean.class); @@ -1042,14 +1041,11 @@ public abstract class AbstractAopProxyTests { * We want to change the arguments on a clone: it shouldn't affect the original. */ @Test - public void testCanChangeArgumentsIndependentlyOnClonedInvocation() throws Throwable { + void testCanChangeArgumentsIndependentlyOnClonedInvocation() { TestBean tb = new TestBean(); ProxyFactory pc = new ProxyFactory(tb); pc.addInterface(ITestBean.class); - /** - * Changes the name, then changes it back. - */ MethodInterceptor nameReverter = mi -> { MethodInvocation clone = ((ReflectiveMethodInvocation) mi).invocableClone(); String oldName = ((ITestBean) mi.getThis()).getName(); @@ -1084,14 +1080,12 @@ public abstract class AbstractAopProxyTests { it.setName(name2); // NameReverter saved it back assertThat(it.getName()).isEqualTo(name1); - assertThat(saver.names).hasSize(2); - assertThat(saver.names).element(0).isEqualTo(name2); - assertThat(saver.names).element(1).isEqualTo(name1); + assertThat(saver.names).containsExactly(name2, name1); } @SuppressWarnings("serial") @Test - public void testOverloadedMethodsWithDifferentAdvice() throws Throwable { + void testOverloadedMethodsWithDifferentAdvice() { Overloads target = new Overloads(); ProxyFactory pc = new ProxyFactory(target); @@ -1127,7 +1121,7 @@ public abstract class AbstractAopProxyTests { } @Test - public void testProxyIsBoundBeforeTargetSourceInvoked() { + void testProxyIsBoundBeforeTargetSourceInvoked() { final TestBean target = new TestBean(); ProxyFactory pf = new ProxyFactory(target); pf.addAdvice(new DebugInterceptor()); @@ -1142,7 +1136,7 @@ public abstract class AbstractAopProxyTests { return TestBean.class; } @Override - public Object getTarget() throws Exception { + public Object getTarget() { assertThat(AopContext.currentProxy()).isEqualTo(proxy); return target; } @@ -1153,7 +1147,7 @@ public abstract class AbstractAopProxyTests { } @Test - public void testEquals() { + void testEquals() { IOther a = new AllInstancesAreEqual(); IOther b = new AllInstancesAreEqual(); NopInterceptor i1 = new NopInterceptor(); @@ -1183,7 +1177,7 @@ public abstract class AbstractAopProxyTests { } @Test - public void testBeforeAdvisorIsInvoked() { + void testBeforeAdvisorIsInvoked() { CountingBeforeAdvice cba = new CountingBeforeAdvice(); @SuppressWarnings("serial") Advisor matchesNoArgs = new StaticMethodMatcherPointcutAdvisor(cba) { @@ -1212,7 +1206,7 @@ public abstract class AbstractAopProxyTests { } @Test - public void testUserAttributes() throws Throwable { + void testUserAttributes() { class MapAwareMethodInterceptor implements MethodInterceptor { private final Map expectedValues; private final Map valuesToAdd; @@ -1263,7 +1257,7 @@ public abstract class AbstractAopProxyTests { } @Test - public void testMultiAdvice() throws Throwable { + void testMultiAdvice() { CountingMultiAdvice cca = new CountingMultiAdvice(); @SuppressWarnings("serial") Advisor matchesNoArgs = new StaticMethodMatcherPointcutAdvisor(cca) { @@ -1297,7 +1291,7 @@ public abstract class AbstractAopProxyTests { } @Test - public void testBeforeAdviceThrowsException() { + void testBeforeAdviceThrowsException() { final RuntimeException rex = new RuntimeException(); @SuppressWarnings("serial") CountingBeforeAdvice ba = new CountingBeforeAdvice() { @@ -1339,11 +1333,11 @@ public abstract class AbstractAopProxyTests { @Test - public void testAfterReturningAdvisorIsInvoked() { + void testAfterReturningAdvisorIsInvoked() { class SummingAfterAdvice implements AfterReturningAdvice { public int sum; @Override - public void afterReturning(@Nullable Object returnValue, Method m, Object[] args, @Nullable Object target) throws Throwable { + public void afterReturning(@Nullable Object returnValue, Method m, Object[] args, @Nullable Object target) { sum += (Integer) returnValue; } } @@ -1376,7 +1370,7 @@ public abstract class AbstractAopProxyTests { } @Test - public void testAfterReturningAdvisorIsNotInvokedOnException() { + void testAfterReturningAdvisorIsNotInvokedOnException() { CountingAfterReturningAdvice car = new CountingAfterReturningAdvice(); TestBean target = new TestBean(); ProxyFactory pf = new ProxyFactory(target); @@ -1398,7 +1392,7 @@ public abstract class AbstractAopProxyTests { @Test - public void testThrowsAdvisorIsInvoked() throws Throwable { + void testThrowsAdvisorIsInvoked() { // Reacts to ServletException and RemoteException MyThrowsHandler th = new MyThrowsHandler(); @SuppressWarnings("serial") @@ -1431,7 +1425,7 @@ public abstract class AbstractAopProxyTests { } @Test - public void testAddThrowsAdviceWithoutAdvisor() throws Throwable { + void testAddThrowsAdviceWithoutAdvisor() { // Reacts to ServletException and RemoteException MyThrowsHandler th = new MyThrowsHandler(); @@ -1790,21 +1784,20 @@ public abstract class AbstractAopProxyTests { AfterReturningAdvice, ThrowsAdvice { @Override - public void before(Method m, Object[] args, @Nullable Object target) throws Throwable { + public void before(Method m, Object[] args, @Nullable Object target) { count(m); } @Override - public void afterReturning(@Nullable Object o, Method m, Object[] args, @Nullable Object target) - throws Throwable { + public void afterReturning(@Nullable Object o, Method m, Object[] args, @Nullable Object target) { count(m); } - public void afterThrowing(IOException ex) throws Throwable { + public void afterThrowing(IOException ex) { count(IOException.class.getName()); } - public void afterThrowing(UncheckedException ex) throws Throwable { + public void afterThrowing(UncheckedException ex) { count(UncheckedException.class.getName()); } @@ -1814,11 +1807,11 @@ public abstract class AbstractAopProxyTests { @SuppressWarnings("serial") public static class CountingThrowsAdvice extends MethodCounter implements ThrowsAdvice { - public void afterThrowing(IOException ex) throws Throwable { + public void afterThrowing(IOException ex) { count(IOException.class.getName()); } - public void afterThrowing(UncheckedException ex) throws Throwable { + public void afterThrowing(UncheckedException ex) { count(UncheckedException.class.getName()); } @@ -1869,7 +1862,7 @@ public abstract class AbstractAopProxyTests { * @see org.springframework.aop.TargetSource#getTarget() */ @Override - public Object getTarget() throws Exception { + public Object getTarget() { ++gets; return target; } @@ -1878,7 +1871,7 @@ public abstract class AbstractAopProxyTests { * @see org.springframework.aop.TargetSource#releaseTarget(java.lang.Object) */ @Override - public void releaseTarget(Object pTarget) throws Exception { + public void releaseTarget(Object pTarget) { if (pTarget != this.target) { throw new RuntimeException("Released wrong target"); } diff --git a/spring-context/src/test/java/org/springframework/aop/framework/CglibProxyTests.java b/spring-context/src/test/java/org/springframework/aop/framework/CglibProxyTests.java index 91f366127f9..cf466b2095b 100644 --- a/spring-context/src/test/java/org/springframework/aop/framework/CglibProxyTests.java +++ b/spring-context/src/test/java/org/springframework/aop/framework/CglibProxyTests.java @@ -458,13 +458,13 @@ class CglibProxyTests extends AbstractAopProxyTests { public enum MyEnum implements MyInterface { - A, B; + A, B } public enum MyOtherEnum implements MyInterface { - C, D; + C, D } @@ -482,7 +482,7 @@ class CglibProxyTests extends AbstractAopProxyTests { return finallyInvoked; } - public void doTest() throws Exception { + public void doTest() { try { throw new ApplicationContextException("foo"); } @@ -586,7 +586,7 @@ class CglibTestBean { class UnsupportedInterceptor implements MethodInterceptor { @Override - public Object invoke(MethodInvocation mi) throws Throwable { + public Object invoke(MethodInvocation mi) { throw new UnsupportedOperationException(mi.getMethod().getName()); } } diff --git a/spring-context/src/test/java/org/springframework/aop/framework/JdkDynamicProxyTests.java b/spring-context/src/test/java/org/springframework/aop/framework/JdkDynamicProxyTests.java index ff860ff62c3..a577598bd5c 100644 --- a/spring-context/src/test/java/org/springframework/aop/framework/JdkDynamicProxyTests.java +++ b/spring-context/src/test/java/org/springframework/aop/framework/JdkDynamicProxyTests.java @@ -239,13 +239,13 @@ class JdkDynamicProxyTests extends AbstractAopProxyTests { public enum MyEnum implements MyInterface { - A, B; + A, B } public enum MyOtherEnum implements MyInterface { - C, D; + C, D } } diff --git a/spring-context/src/test/java/org/springframework/aop/framework/ProxyFactoryBeanTests.java b/spring-context/src/test/java/org/springframework/aop/framework/ProxyFactoryBeanTests.java index 9a120a0415c..bf02628d6d5 100644 --- a/spring-context/src/test/java/org/springframework/aop/framework/ProxyFactoryBeanTests.java +++ b/spring-context/src/test/java/org/springframework/aop/framework/ProxyFactoryBeanTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -92,7 +92,7 @@ class ProxyFactoryBeanTests { @BeforeEach - void setup() throws Exception { + void setup() { DefaultListableBeanFactory parent = new DefaultListableBeanFactory(); parent.registerBeanDefinition("target2", new RootBeanDefinition(TestApplicationListener.class)); this.factory = new DefaultListableBeanFactory(parent); @@ -425,13 +425,12 @@ class ProxyFactoryBeanTests { tb.getAge(); tb.setName("Tristan"); tb.toString(); - assertThat(PointcutForVoid.methodNames).as("Recorded wrong number of invocations").hasSize(2); - assertThat(PointcutForVoid.methodNames).element(0).isEqualTo("setAge"); - assertThat(PointcutForVoid.methodNames).element(1).isEqualTo("setName"); + assertThat(PointcutForVoid.methodNames).as("Recorded wrong number of invocations") + .containsExactly("setAge", "setName"); } @Test - void testCanAddThrowsAdviceWithoutAdvisor() throws Throwable { + void testCanAddThrowsAdviceWithoutAdvisor() { DefaultListableBeanFactory f = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(f).loadBeanDefinitions(new ClassPathResource(THROWS_ADVICE_CONTEXT, CLASS)); MyThrowsHandler th = (MyThrowsHandler) f.getBean("throwsAdvice"); diff --git a/spring-context/src/test/java/org/springframework/aop/framework/adapter/AdvisorAdapterRegistrationTests.java b/spring-context/src/test/java/org/springframework/aop/framework/adapter/AdvisorAdapterRegistrationTests.java index 4fb3d1c930c..30a45d913bd 100644 --- a/spring-context/src/test/java/org/springframework/aop/framework/adapter/AdvisorAdapterRegistrationTests.java +++ b/spring-context/src/test/java/org/springframework/aop/framework/adapter/AdvisorAdapterRegistrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -81,7 +81,7 @@ class AdvisorAdapterRegistrationTests { interface SimpleBeforeAdvice extends BeforeAdvice { - void before() throws Throwable; + void before(); } @@ -108,7 +108,7 @@ class SimpleBeforeAdviceImpl implements SimpleBeforeAdvice { private int invocationCounter; @Override - public void before() throws Throwable { + public void before() { ++invocationCounter; } diff --git a/spring-context/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests.java b/spring-context/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests.java index 212299cdef0..9afebac85f6 100644 --- a/spring-context/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests.java +++ b/spring-context/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,8 +16,6 @@ package org.springframework.aop.framework.autoproxy; -import java.io.IOException; - import org.junit.jupiter.api.Test; import org.springframework.aop.Advisor; @@ -63,7 +61,7 @@ class AdvisorAutoProxyCreatorTests { /** * Return a bean factory with attributes and EnterpriseServices configured. */ - protected BeanFactory getBeanFactory() throws IOException { + protected BeanFactory getBeanFactory() { return new ClassPathXmlApplicationContext(DEFAULT_CONTEXT, CLASS); } diff --git a/spring-context/src/test/java/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorInitTests.java b/spring-context/src/test/java/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorInitTests.java index 786c22e1e2b..a378790b27d 100644 --- a/spring-context/src/test/java/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorInitTests.java +++ b/spring-context/src/test/java/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorInitTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -57,7 +57,7 @@ class BeanNameAutoProxyCreatorInitTests { class NullChecker implements MethodBeforeAdvice { @Override - public void before(Method method, Object[] args, @Nullable Object target) throws Throwable { + public void before(Method method, Object[] args, @Nullable Object target) { check(args); } diff --git a/spring-context/src/test/java/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorTests.java b/spring-context/src/test/java/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorTests.java index c4e40482537..b43084809ec 100644 --- a/spring-context/src/test/java/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorTests.java +++ b/spring-context/src/test/java/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -198,7 +198,7 @@ class BeanNameAutoProxyCreatorTests { class CreatesTestBean implements FactoryBean { @Override - public Object getObject() throws Exception { + public Object getObject() { return new TestBean(); } diff --git a/spring-context/src/test/java/org/springframework/aop/target/CommonsPool2TargetSourceTests.java b/spring-context/src/test/java/org/springframework/aop/target/CommonsPool2TargetSourceTests.java index 4b158ba5bc8..18dbf63832d 100644 --- a/spring-context/src/test/java/org/springframework/aop/target/CommonsPool2TargetSourceTests.java +++ b/spring-context/src/test/java/org/springframework/aop/target/CommonsPool2TargetSourceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -56,7 +56,7 @@ class CommonsPool2TargetSourceTests { private DefaultListableBeanFactory beanFactory; @BeforeEach - void setUp() throws Exception { + void setUp() { this.beanFactory = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(this.beanFactory).loadBeanDefinitions( new ClassPathResource(getClass().getSimpleName() + "-context.xml", getClass())); diff --git a/spring-context/src/test/java/org/springframework/beans/factory/support/InjectAnnotationAutowireContextTests.java b/spring-context/src/test/java/org/springframework/beans/factory/support/InjectAnnotationAutowireContextTests.java index f2f3e2af9e1..54dc5370f2d 100644 --- a/spring-context/src/test/java/org/springframework/beans/factory/support/InjectAnnotationAutowireContextTests.java +++ b/spring-context/src/test/java/org/springframework/beans/factory/support/InjectAnnotationAutowireContextTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,7 +44,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; * @author Juergen Hoeller * @since 3.0 */ -public class InjectAnnotationAutowireContextTests { +class InjectAnnotationAutowireContextTests { private static final String JUERGEN = "juergen"; @@ -52,7 +52,7 @@ public class InjectAnnotationAutowireContextTests { @Test - public void testAutowiredFieldWithSingleNonQualifiedCandidate() { + void testAutowiredFieldWithSingleNonQualifiedCandidate() { GenericApplicationContext context = new GenericApplicationContext(); ConstructorArgumentValues cavs = new ConstructorArgumentValues(); cavs.addGenericArgumentValue(JUERGEN); @@ -70,7 +70,7 @@ public class InjectAnnotationAutowireContextTests { } @Test - public void testAutowiredMethodParameterWithSingleNonQualifiedCandidate() { + void testAutowiredMethodParameterWithSingleNonQualifiedCandidate() { GenericApplicationContext context = new GenericApplicationContext(); ConstructorArgumentValues cavs = new ConstructorArgumentValues(); cavs.addGenericArgumentValue(JUERGEN); @@ -88,7 +88,7 @@ public class InjectAnnotationAutowireContextTests { } @Test - public void testAutowiredConstructorArgumentWithSingleNonQualifiedCandidate() { + void testAutowiredConstructorArgumentWithSingleNonQualifiedCandidate() { GenericApplicationContext context = new GenericApplicationContext(); ConstructorArgumentValues cavs = new ConstructorArgumentValues(); cavs.addGenericArgumentValue(JUERGEN); @@ -103,7 +103,7 @@ public class InjectAnnotationAutowireContextTests { } @Test - public void testAutowiredFieldWithSingleQualifiedCandidate() { + void testAutowiredFieldWithSingleQualifiedCandidate() { GenericApplicationContext context = new GenericApplicationContext(); ConstructorArgumentValues cavs = new ConstructorArgumentValues(); cavs.addGenericArgumentValue(JUERGEN); @@ -118,7 +118,7 @@ public class InjectAnnotationAutowireContextTests { } @Test - public void testAutowiredMethodParameterWithSingleQualifiedCandidate() { + void testAutowiredMethodParameterWithSingleQualifiedCandidate() { GenericApplicationContext context = new GenericApplicationContext(); ConstructorArgumentValues cavs = new ConstructorArgumentValues(); cavs.addGenericArgumentValue(JUERGEN); @@ -135,7 +135,7 @@ public class InjectAnnotationAutowireContextTests { } @Test - public void testAutowiredMethodParameterWithStaticallyQualifiedCandidate() { + void testAutowiredMethodParameterWithStaticallyQualifiedCandidate() { GenericApplicationContext context = new GenericApplicationContext(); ConstructorArgumentValues cavs = new ConstructorArgumentValues(); cavs.addGenericArgumentValue(JUERGEN); @@ -152,7 +152,7 @@ public class InjectAnnotationAutowireContextTests { } @Test - public void testAutowiredMethodParameterWithStaticallyQualifiedCandidateAmongOthers() { + void testAutowiredMethodParameterWithStaticallyQualifiedCandidateAmongOthers() { GenericApplicationContext context = new GenericApplicationContext(); ConstructorArgumentValues cavs = new ConstructorArgumentValues(); cavs.addGenericArgumentValue(JUERGEN); @@ -172,7 +172,7 @@ public class InjectAnnotationAutowireContextTests { } @Test - public void testAutowiredConstructorArgumentWithSingleQualifiedCandidate() { + void testAutowiredConstructorArgumentWithSingleQualifiedCandidate() { GenericApplicationContext context = new GenericApplicationContext(); ConstructorArgumentValues cavs = new ConstructorArgumentValues(); cavs.addGenericArgumentValue(JUERGEN); @@ -189,7 +189,7 @@ public class InjectAnnotationAutowireContextTests { } @Test - public void testAutowiredFieldWithMultipleNonQualifiedCandidates() { + void testAutowiredFieldWithMultipleNonQualifiedCandidates() { GenericApplicationContext context = new GenericApplicationContext(); ConstructorArgumentValues cavs1 = new ConstructorArgumentValues(); cavs1.addGenericArgumentValue(JUERGEN); @@ -211,7 +211,7 @@ public class InjectAnnotationAutowireContextTests { } @Test - public void testAutowiredMethodParameterWithMultipleNonQualifiedCandidates() { + void testAutowiredMethodParameterWithMultipleNonQualifiedCandidates() { GenericApplicationContext context = new GenericApplicationContext(); ConstructorArgumentValues cavs1 = new ConstructorArgumentValues(); cavs1.addGenericArgumentValue(JUERGEN); @@ -233,7 +233,7 @@ public class InjectAnnotationAutowireContextTests { } @Test - public void testAutowiredConstructorArgumentWithMultipleNonQualifiedCandidates() { + void testAutowiredConstructorArgumentWithMultipleNonQualifiedCandidates() { GenericApplicationContext context = new GenericApplicationContext(); ConstructorArgumentValues cavs1 = new ConstructorArgumentValues(); cavs1.addGenericArgumentValue(JUERGEN); @@ -252,7 +252,7 @@ public class InjectAnnotationAutowireContextTests { } @Test - public void testAutowiredFieldResolvesQualifiedCandidate() { + void testAutowiredFieldResolvesQualifiedCandidate() { GenericApplicationContext context = new GenericApplicationContext(); ConstructorArgumentValues cavs1 = new ConstructorArgumentValues(); cavs1.addGenericArgumentValue(JUERGEN); @@ -272,7 +272,7 @@ public class InjectAnnotationAutowireContextTests { } @Test - public void testAutowiredMethodParameterResolvesQualifiedCandidate() { + void testAutowiredMethodParameterResolvesQualifiedCandidate() { GenericApplicationContext context = new GenericApplicationContext(); ConstructorArgumentValues cavs1 = new ConstructorArgumentValues(); cavs1.addGenericArgumentValue(JUERGEN); @@ -293,7 +293,7 @@ public class InjectAnnotationAutowireContextTests { } @Test - public void testAutowiredConstructorArgumentResolvesQualifiedCandidate() { + void testAutowiredConstructorArgumentResolvesQualifiedCandidate() { GenericApplicationContext context = new GenericApplicationContext(); ConstructorArgumentValues cavs1 = new ConstructorArgumentValues(); cavs1.addGenericArgumentValue(JUERGEN); @@ -314,7 +314,7 @@ public class InjectAnnotationAutowireContextTests { } @Test - public void testAutowiredFieldResolvesQualifiedCandidateWithDefaultValueAndNoValueOnBeanDefinition() { + void testAutowiredFieldResolvesQualifiedCandidateWithDefaultValueAndNoValueOnBeanDefinition() { GenericApplicationContext context = new GenericApplicationContext(); ConstructorArgumentValues cavs1 = new ConstructorArgumentValues(); cavs1.addGenericArgumentValue(JUERGEN); @@ -336,7 +336,7 @@ public class InjectAnnotationAutowireContextTests { } @Test - public void testAutowiredFieldDoesNotResolveCandidateWithDefaultValueAndConflictingValueOnBeanDefinition() { + void testAutowiredFieldDoesNotResolveCandidateWithDefaultValueAndConflictingValueOnBeanDefinition() { GenericApplicationContext context = new GenericApplicationContext(); ConstructorArgumentValues cavs1 = new ConstructorArgumentValues(); cavs1.addGenericArgumentValue(JUERGEN); @@ -360,7 +360,7 @@ public class InjectAnnotationAutowireContextTests { } @Test - public void testAutowiredFieldResolvesWithDefaultValueAndExplicitDefaultValueOnBeanDefinition() { + void testAutowiredFieldResolvesWithDefaultValueAndExplicitDefaultValueOnBeanDefinition() { GenericApplicationContext context = new GenericApplicationContext(); ConstructorArgumentValues cavs1 = new ConstructorArgumentValues(); cavs1.addGenericArgumentValue(JUERGEN); @@ -382,7 +382,7 @@ public class InjectAnnotationAutowireContextTests { } @Test - public void testAutowiredFieldResolvesWithMultipleQualifierValues() { + void testAutowiredFieldResolvesWithMultipleQualifierValues() { GenericApplicationContext context = new GenericApplicationContext(); ConstructorArgumentValues cavs1 = new ConstructorArgumentValues(); cavs1.addGenericArgumentValue(JUERGEN); @@ -408,7 +408,7 @@ public class InjectAnnotationAutowireContextTests { } @Test - public void testAutowiredFieldDoesNotResolveWithMultipleQualifierValuesAndConflictingDefaultValue() { + void testAutowiredFieldDoesNotResolveWithMultipleQualifierValuesAndConflictingDefaultValue() { GenericApplicationContext context = new GenericApplicationContext(); ConstructorArgumentValues cavs1 = new ConstructorArgumentValues(); cavs1.addGenericArgumentValue(JUERGEN); @@ -437,7 +437,7 @@ public class InjectAnnotationAutowireContextTests { } @Test - public void testAutowiredFieldResolvesWithMultipleQualifierValuesAndExplicitDefaultValue() { + void testAutowiredFieldResolvesWithMultipleQualifierValuesAndExplicitDefaultValue() { GenericApplicationContext context = new GenericApplicationContext(); ConstructorArgumentValues cavs1 = new ConstructorArgumentValues(); cavs1.addGenericArgumentValue(JUERGEN); @@ -464,7 +464,7 @@ public class InjectAnnotationAutowireContextTests { } @Test - public void testAutowiredFieldDoesNotResolveWithMultipleQualifierValuesAndMultipleMatchingCandidates() { + void testAutowiredFieldDoesNotResolveWithMultipleQualifierValuesAndMultipleMatchingCandidates() { GenericApplicationContext context = new GenericApplicationContext(); ConstructorArgumentValues cavs1 = new ConstructorArgumentValues(); cavs1.addGenericArgumentValue(JUERGEN); @@ -493,7 +493,7 @@ public class InjectAnnotationAutowireContextTests { } @Test - public void testAutowiredFieldDoesNotResolveWithBaseQualifierAndNonDefaultValueAndMultipleMatchingCandidates() { + void testAutowiredFieldDoesNotResolveWithBaseQualifierAndNonDefaultValueAndMultipleMatchingCandidates() { GenericApplicationContext context = new GenericApplicationContext(); ConstructorArgumentValues cavs1 = new ConstructorArgumentValues(); cavs1.addGenericArgumentValue("the real juergen"); diff --git a/spring-context/src/test/java/org/springframework/beans/factory/support/QualifierAnnotationAutowireContextTests.java b/spring-context/src/test/java/org/springframework/beans/factory/support/QualifierAnnotationAutowireContextTests.java index f126d20473f..a741ceb4843 100644 --- a/spring-context/src/test/java/org/springframework/beans/factory/support/QualifierAnnotationAutowireContextTests.java +++ b/spring-context/src/test/java/org/springframework/beans/factory/support/QualifierAnnotationAutowireContextTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,7 +45,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; * @author Chris Beams * @author Sam Brannen */ -public class QualifierAnnotationAutowireContextTests { +class QualifierAnnotationAutowireContextTests { private static final String JUERGEN = "juergen"; @@ -53,7 +53,7 @@ public class QualifierAnnotationAutowireContextTests { @Test - public void autowiredFieldWithSingleNonQualifiedCandidate() { + void autowiredFieldWithSingleNonQualifiedCandidate() { GenericApplicationContext context = new GenericApplicationContext(); ConstructorArgumentValues cavs = new ConstructorArgumentValues(); cavs.addGenericArgumentValue(JUERGEN); @@ -72,7 +72,7 @@ public class QualifierAnnotationAutowireContextTests { } @Test - public void autowiredMethodParameterWithSingleNonQualifiedCandidate() { + void autowiredMethodParameterWithSingleNonQualifiedCandidate() { GenericApplicationContext context = new GenericApplicationContext(); ConstructorArgumentValues cavs = new ConstructorArgumentValues(); cavs.addGenericArgumentValue(JUERGEN); @@ -91,7 +91,7 @@ public class QualifierAnnotationAutowireContextTests { } @Test - public void autowiredConstructorArgumentWithSingleNonQualifiedCandidate() { + void autowiredConstructorArgumentWithSingleNonQualifiedCandidate() { GenericApplicationContext context = new GenericApplicationContext(); ConstructorArgumentValues cavs = new ConstructorArgumentValues(); cavs.addGenericArgumentValue(JUERGEN); @@ -106,7 +106,7 @@ public class QualifierAnnotationAutowireContextTests { } @Test - public void autowiredFieldWithSingleQualifiedCandidate() { + void autowiredFieldWithSingleQualifiedCandidate() { GenericApplicationContext context = new GenericApplicationContext(); ConstructorArgumentValues cavs = new ConstructorArgumentValues(); cavs.addGenericArgumentValue(JUERGEN); @@ -121,7 +121,7 @@ public class QualifierAnnotationAutowireContextTests { } @Test - public void autowiredMethodParameterWithSingleQualifiedCandidate() { + void autowiredMethodParameterWithSingleQualifiedCandidate() { GenericApplicationContext context = new GenericApplicationContext(); ConstructorArgumentValues cavs = new ConstructorArgumentValues(); cavs.addGenericArgumentValue(JUERGEN); @@ -138,7 +138,7 @@ public class QualifierAnnotationAutowireContextTests { } @Test - public void autowiredMethodParameterWithStaticallyQualifiedCandidate() { + void autowiredMethodParameterWithStaticallyQualifiedCandidate() { GenericApplicationContext context = new GenericApplicationContext(); ConstructorArgumentValues cavs = new ConstructorArgumentValues(); cavs.addGenericArgumentValue(JUERGEN); @@ -155,7 +155,7 @@ public class QualifierAnnotationAutowireContextTests { } @Test - public void autowiredMethodParameterWithStaticallyQualifiedCandidateAmongOthers() { + void autowiredMethodParameterWithStaticallyQualifiedCandidateAmongOthers() { GenericApplicationContext context = new GenericApplicationContext(); ConstructorArgumentValues cavs = new ConstructorArgumentValues(); cavs.addGenericArgumentValue(JUERGEN); @@ -175,7 +175,7 @@ public class QualifierAnnotationAutowireContextTests { } @Test - public void autowiredConstructorArgumentWithSingleQualifiedCandidate() { + void autowiredConstructorArgumentWithSingleQualifiedCandidate() { GenericApplicationContext context = new GenericApplicationContext(); ConstructorArgumentValues cavs = new ConstructorArgumentValues(); cavs.addGenericArgumentValue(JUERGEN); @@ -192,7 +192,7 @@ public class QualifierAnnotationAutowireContextTests { } @Test - public void autowiredFieldWithMultipleNonQualifiedCandidates() { + void autowiredFieldWithMultipleNonQualifiedCandidates() { GenericApplicationContext context = new GenericApplicationContext(); ConstructorArgumentValues cavs1 = new ConstructorArgumentValues(); cavs1.addGenericArgumentValue(JUERGEN); @@ -214,7 +214,7 @@ public class QualifierAnnotationAutowireContextTests { } @Test - public void autowiredMethodParameterWithMultipleNonQualifiedCandidates() { + void autowiredMethodParameterWithMultipleNonQualifiedCandidates() { GenericApplicationContext context = new GenericApplicationContext(); ConstructorArgumentValues cavs1 = new ConstructorArgumentValues(); cavs1.addGenericArgumentValue(JUERGEN); @@ -236,7 +236,7 @@ public class QualifierAnnotationAutowireContextTests { } @Test - public void autowiredConstructorArgumentWithMultipleNonQualifiedCandidates() { + void autowiredConstructorArgumentWithMultipleNonQualifiedCandidates() { GenericApplicationContext context = new GenericApplicationContext(); ConstructorArgumentValues cavs1 = new ConstructorArgumentValues(); cavs1.addGenericArgumentValue(JUERGEN); @@ -255,7 +255,7 @@ public class QualifierAnnotationAutowireContextTests { } @Test - public void autowiredFieldResolvesQualifiedCandidate() { + void autowiredFieldResolvesQualifiedCandidate() { GenericApplicationContext context = new GenericApplicationContext(); ConstructorArgumentValues cavs1 = new ConstructorArgumentValues(); cavs1.addGenericArgumentValue(JUERGEN); @@ -275,7 +275,7 @@ public class QualifierAnnotationAutowireContextTests { } @Test - public void autowiredFieldResolvesMetaQualifiedCandidate() { + void autowiredFieldResolvesMetaQualifiedCandidate() { GenericApplicationContext context = new GenericApplicationContext(); ConstructorArgumentValues cavs1 = new ConstructorArgumentValues(); cavs1.addGenericArgumentValue(JUERGEN); @@ -295,7 +295,7 @@ public class QualifierAnnotationAutowireContextTests { } @Test - public void autowiredMethodParameterResolvesQualifiedCandidate() { + void autowiredMethodParameterResolvesQualifiedCandidate() { GenericApplicationContext context = new GenericApplicationContext(); ConstructorArgumentValues cavs1 = new ConstructorArgumentValues(); cavs1.addGenericArgumentValue(JUERGEN); @@ -316,7 +316,7 @@ public class QualifierAnnotationAutowireContextTests { } @Test - public void autowiredConstructorArgumentResolvesQualifiedCandidate() { + void autowiredConstructorArgumentResolvesQualifiedCandidate() { GenericApplicationContext context = new GenericApplicationContext(); ConstructorArgumentValues cavs1 = new ConstructorArgumentValues(); cavs1.addGenericArgumentValue(JUERGEN); @@ -337,7 +337,7 @@ public class QualifierAnnotationAutowireContextTests { } @Test - public void autowiredFieldResolvesQualifiedCandidateWithDefaultValueAndNoValueOnBeanDefinition() { + void autowiredFieldResolvesQualifiedCandidateWithDefaultValueAndNoValueOnBeanDefinition() { GenericApplicationContext context = new GenericApplicationContext(); ConstructorArgumentValues cavs1 = new ConstructorArgumentValues(); cavs1.addGenericArgumentValue(JUERGEN); @@ -359,7 +359,7 @@ public class QualifierAnnotationAutowireContextTests { } @Test - public void autowiredFieldDoesNotResolveCandidateWithDefaultValueAndConflictingValueOnBeanDefinition() { + void autowiredFieldDoesNotResolveCandidateWithDefaultValueAndConflictingValueOnBeanDefinition() { GenericApplicationContext context = new GenericApplicationContext(); ConstructorArgumentValues cavs1 = new ConstructorArgumentValues(); cavs1.addGenericArgumentValue(JUERGEN); @@ -383,7 +383,7 @@ public class QualifierAnnotationAutowireContextTests { } @Test - public void autowiredFieldResolvesWithDefaultValueAndExplicitDefaultValueOnBeanDefinition() { + void autowiredFieldResolvesWithDefaultValueAndExplicitDefaultValueOnBeanDefinition() { GenericApplicationContext context = new GenericApplicationContext(); ConstructorArgumentValues cavs1 = new ConstructorArgumentValues(); cavs1.addGenericArgumentValue(JUERGEN); @@ -405,7 +405,7 @@ public class QualifierAnnotationAutowireContextTests { } @Test - public void autowiredFieldResolvesWithMultipleQualifierValues() { + void autowiredFieldResolvesWithMultipleQualifierValues() { GenericApplicationContext context = new GenericApplicationContext(); ConstructorArgumentValues cavs1 = new ConstructorArgumentValues(); cavs1.addGenericArgumentValue(JUERGEN); @@ -431,7 +431,7 @@ public class QualifierAnnotationAutowireContextTests { } @Test - public void autowiredFieldDoesNotResolveWithMultipleQualifierValuesAndConflictingDefaultValue() { + void autowiredFieldDoesNotResolveWithMultipleQualifierValuesAndConflictingDefaultValue() { GenericApplicationContext context = new GenericApplicationContext(); ConstructorArgumentValues cavs1 = new ConstructorArgumentValues(); cavs1.addGenericArgumentValue(JUERGEN); @@ -460,7 +460,7 @@ public class QualifierAnnotationAutowireContextTests { } @Test - public void autowiredFieldResolvesWithMultipleQualifierValuesAndExplicitDefaultValue() { + void autowiredFieldResolvesWithMultipleQualifierValuesAndExplicitDefaultValue() { GenericApplicationContext context = new GenericApplicationContext(); ConstructorArgumentValues cavs1 = new ConstructorArgumentValues(); cavs1.addGenericArgumentValue(JUERGEN); @@ -487,7 +487,7 @@ public class QualifierAnnotationAutowireContextTests { } @Test - public void autowiredFieldDoesNotResolveWithMultipleQualifierValuesAndMultipleMatchingCandidates() { + void autowiredFieldDoesNotResolveWithMultipleQualifierValuesAndMultipleMatchingCandidates() { GenericApplicationContext context = new GenericApplicationContext(); ConstructorArgumentValues cavs1 = new ConstructorArgumentValues(); cavs1.addGenericArgumentValue(JUERGEN); @@ -516,7 +516,7 @@ public class QualifierAnnotationAutowireContextTests { } @Test - public void autowiredFieldResolvesWithBaseQualifierAndDefaultValue() { + void autowiredFieldResolvesWithBaseQualifierAndDefaultValue() { GenericApplicationContext context = new GenericApplicationContext(); ConstructorArgumentValues cavs1 = new ConstructorArgumentValues(); cavs1.addGenericArgumentValue(JUERGEN); @@ -537,7 +537,7 @@ public class QualifierAnnotationAutowireContextTests { } @Test - public void autowiredFieldResolvesWithBaseQualifierAndNonDefaultValue() { + void autowiredFieldResolvesWithBaseQualifierAndNonDefaultValue() { GenericApplicationContext context = new GenericApplicationContext(); ConstructorArgumentValues cavs1 = new ConstructorArgumentValues(); cavs1.addGenericArgumentValue("the real juergen"); @@ -559,7 +559,7 @@ public class QualifierAnnotationAutowireContextTests { } @Test - public void autowiredFieldDoesNotResolveWithBaseQualifierAndNonDefaultValueAndMultipleMatchingCandidates() { + void autowiredFieldDoesNotResolveWithBaseQualifierAndNonDefaultValueAndMultipleMatchingCandidates() { GenericApplicationContext context = new GenericApplicationContext(); ConstructorArgumentValues cavs1 = new ConstructorArgumentValues(); cavs1.addGenericArgumentValue("the real juergen"); diff --git a/spring-context/src/test/java/org/springframework/beans/factory/xml/LookupMethodWrappedByCglibProxyTests.java b/spring-context/src/test/java/org/springframework/beans/factory/xml/LookupMethodWrappedByCglibProxyTests.java index e65b730e693..153f0f515a0 100644 --- a/spring-context/src/test/java/org/springframework/beans/factory/xml/LookupMethodWrappedByCglibProxyTests.java +++ b/spring-context/src/test/java/org/springframework/beans/factory/xml/LookupMethodWrappedByCglibProxyTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,7 +33,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Juergen Hoeller * @author Chris Beams */ -public class LookupMethodWrappedByCglibProxyTests { +class LookupMethodWrappedByCglibProxyTests { private static final Class CLASS = LookupMethodWrappedByCglibProxyTests.class; private static final String CLASSNAME = CLASS.getSimpleName(); @@ -43,13 +43,13 @@ public class LookupMethodWrappedByCglibProxyTests { private ApplicationContext applicationContext; @BeforeEach - public void setUp() { + void setUp() { this.applicationContext = new ClassPathXmlApplicationContext(CONTEXT, CLASS); resetInterceptor(); } @Test - public void testAutoProxiedLookup() { + void testAutoProxiedLookup() { OverloadLookup olup = (OverloadLookup) applicationContext.getBean("autoProxiedOverload"); ITestBean jenny = olup.newTestBean(); assertThat(jenny.getName()).isEqualTo("Jenny"); @@ -58,7 +58,7 @@ public class LookupMethodWrappedByCglibProxyTests { } @Test - public void testRegularlyProxiedLookup() { + void testRegularlyProxiedLookup() { OverloadLookup olup = (OverloadLookup) applicationContext.getBean("regularlyProxiedOverload"); ITestBean jenny = olup.newTestBean(); assertThat(jenny.getName()).isEqualTo("Jenny"); diff --git a/spring-context/src/test/java/org/springframework/beans/factory/xml/QualifierAnnotationTests.java b/spring-context/src/test/java/org/springframework/beans/factory/xml/QualifierAnnotationTests.java index cce2ced3c62..fe93522bd64 100644 --- a/spring-context/src/test/java/org/springframework/beans/factory/xml/QualifierAnnotationTests.java +++ b/spring-context/src/test/java/org/springframework/beans/factory/xml/QualifierAnnotationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,7 +44,7 @@ import static org.springframework.util.ClassUtils.convertClassNameToResourcePath * @author Juergen Hoeller * @author Chris Beams */ -public class QualifierAnnotationTests { +class QualifierAnnotationTests { private static final String CLASSNAME = QualifierAnnotationTests.class.getName(); @@ -53,7 +53,7 @@ public class QualifierAnnotationTests { @Test - public void testNonQualifiedFieldFails() { + void testNonQualifiedFieldFails() { StaticApplicationContext context = new StaticApplicationContext(); BeanDefinitionReader reader = new XmlBeanDefinitionReader(context); reader.loadBeanDefinitions(CONFIG_LOCATION); @@ -64,7 +64,7 @@ public class QualifierAnnotationTests { } @Test - public void testQualifiedByValue() { + void testQualifiedByValue() { StaticApplicationContext context = new StaticApplicationContext(); BeanDefinitionReader reader = new XmlBeanDefinitionReader(context); reader.loadBeanDefinitions(CONFIG_LOCATION); @@ -76,7 +76,7 @@ public class QualifierAnnotationTests { } @Test - public void testQualifiedByParentValue() { + void testQualifiedByParentValue() { StaticApplicationContext parent = new StaticApplicationContext(); GenericBeanDefinition parentLarry = new GenericBeanDefinition(); parentLarry.setBeanClass(Person.class); @@ -101,7 +101,7 @@ public class QualifierAnnotationTests { } @Test - public void testQualifiedByBeanName() { + void testQualifiedByBeanName() { StaticApplicationContext context = new StaticApplicationContext(); BeanDefinitionReader reader = new XmlBeanDefinitionReader(context); reader.loadBeanDefinitions(CONFIG_LOCATION); @@ -115,7 +115,7 @@ public class QualifierAnnotationTests { } @Test - public void testQualifiedByFieldName() { + void testQualifiedByFieldName() { StaticApplicationContext context = new StaticApplicationContext(); BeanDefinitionReader reader = new XmlBeanDefinitionReader(context); reader.loadBeanDefinitions(CONFIG_LOCATION); @@ -127,7 +127,7 @@ public class QualifierAnnotationTests { } @Test - public void testQualifiedByParameterName() { + void testQualifiedByParameterName() { StaticApplicationContext context = new StaticApplicationContext(); BeanDefinitionReader reader = new XmlBeanDefinitionReader(context); reader.loadBeanDefinitions(CONFIG_LOCATION); @@ -139,7 +139,7 @@ public class QualifierAnnotationTests { } @Test - public void testQualifiedByAlias() { + void testQualifiedByAlias() { StaticApplicationContext context = new StaticApplicationContext(); BeanDefinitionReader reader = new XmlBeanDefinitionReader(context); reader.loadBeanDefinitions(CONFIG_LOCATION); @@ -151,7 +151,7 @@ public class QualifierAnnotationTests { } @Test - public void testQualifiedByAnnotation() { + void testQualifiedByAnnotation() { StaticApplicationContext context = new StaticApplicationContext(); BeanDefinitionReader reader = new XmlBeanDefinitionReader(context); reader.loadBeanDefinitions(CONFIG_LOCATION); @@ -163,7 +163,7 @@ public class QualifierAnnotationTests { } @Test - public void testQualifiedByCustomValue() { + void testQualifiedByCustomValue() { StaticApplicationContext context = new StaticApplicationContext(); BeanDefinitionReader reader = new XmlBeanDefinitionReader(context); reader.loadBeanDefinitions(CONFIG_LOCATION); @@ -175,7 +175,7 @@ public class QualifierAnnotationTests { } @Test - public void testQualifiedByAnnotationValue() { + void testQualifiedByAnnotationValue() { StaticApplicationContext context = new StaticApplicationContext(); BeanDefinitionReader reader = new XmlBeanDefinitionReader(context); reader.loadBeanDefinitions(CONFIG_LOCATION); @@ -187,7 +187,7 @@ public class QualifierAnnotationTests { } @Test - public void testQualifiedByAttributesFailsWithoutCustomQualifierRegistered() { + void testQualifiedByAttributesFailsWithoutCustomQualifierRegistered() { StaticApplicationContext context = new StaticApplicationContext(); BeanDefinitionReader reader = new XmlBeanDefinitionReader(context); reader.loadBeanDefinitions(CONFIG_LOCATION); @@ -198,7 +198,7 @@ public class QualifierAnnotationTests { } @Test - public void testQualifiedByAttributesWithCustomQualifierRegistered() { + void testQualifiedByAttributesWithCustomQualifierRegistered() { StaticApplicationContext context = new StaticApplicationContext(); BeanDefinitionReader reader = new XmlBeanDefinitionReader(context); reader.loadBeanDefinitions(CONFIG_LOCATION); @@ -215,7 +215,7 @@ public class QualifierAnnotationTests { } @Test - public void testInterfaceWithOneQualifiedFactoryAndOneQualifiedBean() { + void testInterfaceWithOneQualifiedFactoryAndOneQualifiedBean() { StaticApplicationContext context = new StaticApplicationContext(); BeanDefinitionReader reader = new XmlBeanDefinitionReader(context); reader.loadBeanDefinitions(CONFIG_LOCATION); diff --git a/spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTestTypes.java b/spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTestTypes.java index 258cdc3bd9b..06345c821fc 100644 --- a/spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTestTypes.java +++ b/spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTestTypes.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -313,7 +313,7 @@ class FixedMethodReplacer implements MethodReplacer { public static final String VALUE = "fixedMethodReplacer"; @Override - public Object reimplement(Object obj, Method method, Object[] args) throws Throwable { + public Object reimplement(Object obj, Method method, Object[] args) { return VALUE; } } @@ -587,7 +587,7 @@ class ProtectedLifecycleBean implements BeanNameAware, BeanFactoryAware, Initial class ReverseMethodReplacer implements MethodReplacer, Serializable { @Override - public Object reimplement(Object obj, Method method, Object[] args) throws Throwable { + public Object reimplement(Object obj, Method method, Object[] args) { String s = (String) args[0]; return new StringBuilder(s).reverse().toString(); } diff --git a/spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTests.java b/spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTests.java index 42106fcf161..689a0949094 100644 --- a/spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTests.java +++ b/spring-context/src/test/java/org/springframework/beans/factory/xml/XmlBeanFactoryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -1611,7 +1611,7 @@ class XmlBeanFactoryTests { public Object lastArg; @Override - public Object reimplement(Object obj, Method method, Object[] args) throws Throwable { + public Object reimplement(Object obj, Method method, Object[] args) { assertThat(args).hasSize(1); assertThat(method.getName()).isEqualTo("doSomething"); lastArg = args[0]; @@ -1668,7 +1668,7 @@ class XmlBeanFactoryTests { } /** Init method */ - public void customInit() throws IOException { + public void customInit() { assertThat(this.afterPropertiesSetInvoked).isTrue(); if (this.initMethodInvoked) { throw new IllegalStateException("Already customInitialized"); diff --git a/spring-context/src/test/java/org/springframework/beans/factory/xml/support/CustomNamespaceHandlerTests.java b/spring-context/src/test/java/org/springframework/beans/factory/xml/support/CustomNamespaceHandlerTests.java index 4a34f37bbb1..27f75176bd8 100644 --- a/spring-context/src/test/java/org/springframework/beans/factory/xml/support/CustomNamespaceHandlerTests.java +++ b/spring-context/src/test/java/org/springframework/beans/factory/xml/support/CustomNamespaceHandlerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -71,7 +71,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; * @author Chris Beams * @author Juergen Hoeller */ -public class CustomNamespaceHandlerTests { +class CustomNamespaceHandlerTests { private static final Class CLASS = CustomNamespaceHandlerTests.class; private static final String CLASSNAME = CLASS.getSimpleName(); @@ -85,7 +85,7 @@ public class CustomNamespaceHandlerTests { @BeforeEach - public void setUp() throws Exception { + void setUp() { NamespaceHandlerResolver resolver = new DefaultNamespaceHandlerResolver(CLASS.getClassLoader(), NS_PROPS); this.beanFactory = new GenericApplicationContext(); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(this.beanFactory); @@ -98,19 +98,19 @@ public class CustomNamespaceHandlerTests { @Test - public void testSimpleParser() throws Exception { + void testSimpleParser() { TestBean bean = (TestBean) this.beanFactory.getBean("testBean"); assertTestBean(bean); } @Test - public void testSimpleDecorator() throws Exception { + void testSimpleDecorator() { TestBean bean = (TestBean) this.beanFactory.getBean("customisedTestBean"); assertTestBean(bean); } @Test - public void testProxyingDecorator() throws Exception { + void testProxyingDecorator() { ITestBean bean = (ITestBean) this.beanFactory.getBean("debuggingTestBean"); assertTestBean(bean); assertThat(AopUtils.isAopProxy(bean)).isTrue(); @@ -120,7 +120,7 @@ public class CustomNamespaceHandlerTests { } @Test - public void testProxyingDecoratorNoInstance() throws Exception { + void testProxyingDecoratorNoInstance() { String[] beanNames = this.beanFactory.getBeanNamesForType(ApplicationListener.class); assertThat(Arrays.asList(beanNames)).contains("debuggingTestBeanNoInstance"); assertThat(this.beanFactory.getType("debuggingTestBeanNoInstance")).isEqualTo(ApplicationListener.class); @@ -131,7 +131,7 @@ public class CustomNamespaceHandlerTests { } @Test - public void testChainedDecorators() throws Exception { + void testChainedDecorators() { ITestBean bean = (ITestBean) this.beanFactory.getBean("chainedTestBean"); assertTestBean(bean); assertThat(AopUtils.isAopProxy(bean)).isTrue(); @@ -142,27 +142,27 @@ public class CustomNamespaceHandlerTests { } @Test - public void testDecorationViaAttribute() throws Exception { + void testDecorationViaAttribute() { BeanDefinition beanDefinition = this.beanFactory.getBeanDefinition("decorateWithAttribute"); assertThat(beanDefinition.getAttribute("objectName")).isEqualTo("foo"); } @Test // SPR-2728 - public void testCustomElementNestedWithinUtilList() throws Exception { + public void testCustomElementNestedWithinUtilList() { List things = (List) this.beanFactory.getBean("list.of.things"); assertThat(things).isNotNull(); assertThat(things).hasSize(2); } @Test // SPR-2728 - public void testCustomElementNestedWithinUtilSet() throws Exception { + public void testCustomElementNestedWithinUtilSet() { Set things = (Set) this.beanFactory.getBean("set.of.things"); assertThat(things).isNotNull(); assertThat(things).hasSize(2); } @Test // SPR-2728 - public void testCustomElementNestedWithinUtilMap() throws Exception { + public void testCustomElementNestedWithinUtilMap() { Map things = (Map) this.beanFactory.getBean("map.of.things"); assertThat(things).isNotNull(); assertThat(things).hasSize(2); diff --git a/spring-context/src/test/java/org/springframework/cache/NoOpCacheManagerTests.java b/spring-context/src/test/java/org/springframework/cache/NoOpCacheManagerTests.java index e61fa362a34..b511b2de05a 100644 --- a/spring-context/src/test/java/org/springframework/cache/NoOpCacheManagerTests.java +++ b/spring-context/src/test/java/org/springframework/cache/NoOpCacheManagerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2019 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,19 +30,19 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Costin Leau * @author Stephane Nicoll */ -public class NoOpCacheManagerTests { +class NoOpCacheManagerTests { private final CacheManager manager = new NoOpCacheManager(); @Test - public void testGetCache() throws Exception { + void testGetCache() { Cache cache = this.manager.getCache("bucket"); assertThat(cache).isNotNull(); assertThat(this.manager.getCache("bucket")).isSameAs(cache); } @Test - public void testNoOpCache() throws Exception { + void testNoOpCache() { String name = createRandomKey(); Cache cache = this.manager.getCache(name); assertThat(cache.getName()).isEqualTo(name); @@ -54,7 +54,7 @@ public class NoOpCacheManagerTests { } @Test - public void testCacheName() throws Exception { + void testCacheName() { String name = "bucket"; assertThat(this.manager.getCacheNames()).doesNotContain(name); this.manager.getCache(name); @@ -62,7 +62,7 @@ public class NoOpCacheManagerTests { } @Test - public void testCacheCallable() throws Exception { + void testCacheCallable() { String name = createRandomKey(); Cache cache = this.manager.getCache(name); Object returnValue = new Object(); @@ -71,7 +71,7 @@ public class NoOpCacheManagerTests { } @Test - public void testCacheGetCallableFail() { + void testCacheGetCallableFail() { Cache cache = this.manager.getCache(createRandomKey()); String key = createRandomKey(); try { diff --git a/spring-context/src/test/java/org/springframework/cache/annotation/AnnotationCacheOperationSourceTests.java b/spring-context/src/test/java/org/springframework/cache/annotation/AnnotationCacheOperationSourceTests.java index da8ebd4ae2e..6d4c20afe62 100644 --- a/spring-context/src/test/java/org/springframework/cache/annotation/AnnotationCacheOperationSourceTests.java +++ b/spring-context/src/test/java/org/springframework/cache/annotation/AnnotationCacheOperationSourceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,19 +41,19 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException; * @author Stephane Nicoll * @author Sam Brannen */ -public class AnnotationCacheOperationSourceTests { +class AnnotationCacheOperationSourceTests { private final AnnotationCacheOperationSource source = new AnnotationCacheOperationSource(); @Test - public void singularAnnotation() { + void singularAnnotation() { Collection ops = getOps(AnnotatedClass.class, "singular", 1); assertThat(ops).element(0).isInstanceOf(CacheableOperation.class); } @Test - public void multipleAnnotation() { + void multipleAnnotation() { Collection ops = getOps(AnnotatedClass.class, "multiple", 2); Iterator it = ops.iterator(); assertThat(it.next()).isInstanceOf(CacheableOperation.class); @@ -61,7 +61,7 @@ public class AnnotationCacheOperationSourceTests { } @Test - public void caching() { + void caching() { Collection ops = getOps(AnnotatedClass.class, "caching", 2); Iterator it = ops.iterator(); assertThat(it.next()).isInstanceOf(CacheableOperation.class); @@ -69,18 +69,18 @@ public class AnnotationCacheOperationSourceTests { } @Test - public void emptyCaching() { + void emptyCaching() { getOps(AnnotatedClass.class, "emptyCaching", 0); } @Test - public void singularStereotype() { + void singularStereotype() { Collection ops = getOps(AnnotatedClass.class, "singleStereotype", 1); assertThat(ops).element(0).isInstanceOf(CacheEvictOperation.class); } @Test - public void multipleStereotypes() { + void multipleStereotypes() { Collection ops = getOps(AnnotatedClass.class, "multipleStereotype", 3); Iterator it = ops.iterator(); assertThat(it.next()).isInstanceOf(CacheableOperation.class); @@ -93,7 +93,7 @@ public class AnnotationCacheOperationSourceTests { } @Test - public void singleComposedAnnotation() { + void singleComposedAnnotation() { Collection ops = getOps(AnnotatedClass.class, "singleComposed", 2); Iterator it = ops.iterator(); @@ -109,7 +109,7 @@ public class AnnotationCacheOperationSourceTests { } @Test - public void multipleComposedAnnotations() { + void multipleComposedAnnotations() { Collection ops = getOps(AnnotatedClass.class, "multipleComposed", 4); Iterator it = ops.iterator(); @@ -135,89 +135,89 @@ public class AnnotationCacheOperationSourceTests { } @Test - public void customKeyGenerator() { + void customKeyGenerator() { Collection ops = getOps(AnnotatedClass.class, "customKeyGenerator", 1); CacheOperation cacheOperation = ops.iterator().next(); assertThat(cacheOperation.getKeyGenerator()).as("Custom key generator not set").isEqualTo("custom"); } @Test - public void customKeyGeneratorInherited() { + void customKeyGeneratorInherited() { Collection ops = getOps(AnnotatedClass.class, "customKeyGeneratorInherited", 1); CacheOperation cacheOperation = ops.iterator().next(); assertThat(cacheOperation.getKeyGenerator()).as("Custom key generator not set").isEqualTo("custom"); } @Test - public void keyAndKeyGeneratorCannotBeSetTogether() { + void keyAndKeyGeneratorCannotBeSetTogether() { assertThatIllegalStateException().isThrownBy(() -> getOps(AnnotatedClass.class, "invalidKeyAndKeyGeneratorSet")); } @Test - public void customCacheManager() { + void customCacheManager() { Collection ops = getOps(AnnotatedClass.class, "customCacheManager", 1); CacheOperation cacheOperation = ops.iterator().next(); assertThat(cacheOperation.getCacheManager()).as("Custom cache manager not set").isEqualTo("custom"); } @Test - public void customCacheManagerInherited() { + void customCacheManagerInherited() { Collection ops = getOps(AnnotatedClass.class, "customCacheManagerInherited", 1); CacheOperation cacheOperation = ops.iterator().next(); assertThat(cacheOperation.getCacheManager()).as("Custom cache manager not set").isEqualTo("custom"); } @Test - public void customCacheResolver() { + void customCacheResolver() { Collection ops = getOps(AnnotatedClass.class, "customCacheResolver", 1); CacheOperation cacheOperation = ops.iterator().next(); assertThat(cacheOperation.getCacheResolver()).as("Custom cache resolver not set").isEqualTo("custom"); } @Test - public void customCacheResolverInherited() { + void customCacheResolverInherited() { Collection ops = getOps(AnnotatedClass.class, "customCacheResolverInherited", 1); CacheOperation cacheOperation = ops.iterator().next(); assertThat(cacheOperation.getCacheResolver()).as("Custom cache resolver not set").isEqualTo("custom"); } @Test - public void cacheResolverAndCacheManagerCannotBeSetTogether() { + void cacheResolverAndCacheManagerCannotBeSetTogether() { assertThatIllegalStateException().isThrownBy(() -> getOps(AnnotatedClass.class, "invalidCacheResolverAndCacheManagerSet")); } @Test - public void fullClassLevelWithCustomCacheName() { + void fullClassLevelWithCustomCacheName() { Collection ops = getOps(AnnotatedClassWithFullDefault.class, "methodLevelCacheName", 1); CacheOperation cacheOperation = ops.iterator().next(); assertSharedConfig(cacheOperation, "classKeyGenerator", "", "classCacheResolver", "custom"); } @Test - public void fullClassLevelWithCustomKeyManager() { + void fullClassLevelWithCustomKeyManager() { Collection ops = getOps(AnnotatedClassWithFullDefault.class, "methodLevelKeyGenerator", 1); CacheOperation cacheOperation = ops.iterator().next(); assertSharedConfig(cacheOperation, "custom", "", "classCacheResolver" , "classCacheName"); } @Test - public void fullClassLevelWithCustomCacheManager() { + void fullClassLevelWithCustomCacheManager() { Collection ops = getOps(AnnotatedClassWithFullDefault.class, "methodLevelCacheManager", 1); CacheOperation cacheOperation = ops.iterator().next(); assertSharedConfig(cacheOperation, "classKeyGenerator", "custom", "", "classCacheName"); } @Test - public void fullClassLevelWithCustomCacheResolver() { + void fullClassLevelWithCustomCacheResolver() { Collection ops = getOps(AnnotatedClassWithFullDefault.class, "methodLevelCacheResolver", 1); CacheOperation cacheOperation = ops.iterator().next(); assertSharedConfig(cacheOperation, "classKeyGenerator", "", "custom" , "classCacheName"); } @Test - public void validateNoCacheIsValid() { + void validateNoCacheIsValid() { // Valid as a CacheResolver might return the cache names to use with other info Collection ops = getOps(AnnotatedClass.class, "noCacheNameSpecified"); CacheOperation cacheOperation = ops.iterator().next(); @@ -226,28 +226,28 @@ public class AnnotationCacheOperationSourceTests { } @Test - public void customClassLevelWithCustomCacheName() { + void customClassLevelWithCustomCacheName() { Collection ops = getOps(AnnotatedClassWithCustomDefault.class, "methodLevelCacheName", 1); CacheOperation cacheOperation = ops.iterator().next(); assertSharedConfig(cacheOperation, "classKeyGenerator", "", "classCacheResolver", "custom"); } @Test - public void severalCacheConfigUseClosest() { + void severalCacheConfigUseClosest() { Collection ops = getOps(MultipleCacheConfig.class, "multipleCacheConfig"); CacheOperation cacheOperation = ops.iterator().next(); assertSharedConfig(cacheOperation, "", "", "", "myCache"); } @Test - public void cacheConfigFromInterface() { + void cacheConfigFromInterface() { Collection ops = getOps(InterfaceCacheConfig.class, "interfaceCacheConfig"); CacheOperation cacheOperation = ops.iterator().next(); assertSharedConfig(cacheOperation, "", "", "", "myCache"); } @Test - public void cacheAnnotationOverride() { + void cacheAnnotationOverride() { Collection ops = getOps(InterfaceCacheConfig.class, "interfaceCacheableOverride"); assertThat(ops.size()).isSameAs(1); CacheOperation cacheOperation = ops.iterator().next(); @@ -255,21 +255,21 @@ public class AnnotationCacheOperationSourceTests { } @Test - public void partialClassLevelWithCustomCacheManager() { + void partialClassLevelWithCustomCacheManager() { Collection ops = getOps(AnnotatedClassWithSomeDefault.class, "methodLevelCacheManager", 1); CacheOperation cacheOperation = ops.iterator().next(); assertSharedConfig(cacheOperation, "classKeyGenerator", "custom", "", "classCacheName"); } @Test - public void partialClassLevelWithCustomCacheResolver() { + void partialClassLevelWithCustomCacheResolver() { Collection ops = getOps(AnnotatedClassWithSomeDefault.class, "methodLevelCacheResolver", 1); CacheOperation cacheOperation = ops.iterator().next(); assertSharedConfig(cacheOperation, "classKeyGenerator", "", "custom", "classCacheName"); } @Test - public void partialClassLevelWithNoCustomization() { + void partialClassLevelWithNoCustomization() { Collection ops = getOps(AnnotatedClassWithSomeDefault.class, "noCustomization", 1); CacheOperation cacheOperation = ops.iterator().next(); assertSharedConfig(cacheOperation, "classKeyGenerator", "classCacheManager", "", "classCacheName"); diff --git a/spring-context/src/test/java/org/springframework/cache/concurrent/ConcurrentMapCacheManagerTests.java b/spring-context/src/test/java/org/springframework/cache/concurrent/ConcurrentMapCacheManagerTests.java index 70d9254dcc3..5a8baa9eb64 100644 --- a/spring-context/src/test/java/org/springframework/cache/concurrent/ConcurrentMapCacheManagerTests.java +++ b/spring-context/src/test/java/org/springframework/cache/concurrent/ConcurrentMapCacheManagerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,10 +27,10 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Juergen Hoeller * @author Stephane Nicoll */ -public class ConcurrentMapCacheManagerTests { +class ConcurrentMapCacheManagerTests { @Test - public void testDynamicMode() { + void testDynamicMode() { CacheManager cm = new ConcurrentMapCacheManager(); Cache cache1 = cm.getCache("c1"); assertThat(cache1).isInstanceOf(ConcurrentMapCache.class); @@ -68,7 +68,7 @@ public class ConcurrentMapCacheManagerTests { } @Test - public void testStaticMode() { + void testStaticMode() { ConcurrentMapCacheManager cm = new ConcurrentMapCacheManager("c1", "c2"); Cache cache1 = cm.getCache("c1"); assertThat(cache1).isInstanceOf(ConcurrentMapCache.class); @@ -115,7 +115,7 @@ public class ConcurrentMapCacheManagerTests { } @Test - public void testChangeStoreByValue() { + void testChangeStoreByValue() { ConcurrentMapCacheManager cm = new ConcurrentMapCacheManager("c1", "c2"); assertThat(cm.isStoreByValue()).isFalse(); Cache cache1 = cm.getCache("c1"); diff --git a/spring-context/src/test/java/org/springframework/cache/concurrent/ConcurrentMapCacheTests.java b/spring-context/src/test/java/org/springframework/cache/concurrent/ConcurrentMapCacheTests.java index cef22ab424f..533423e50ea 100644 --- a/spring-context/src/test/java/org/springframework/cache/concurrent/ConcurrentMapCacheTests.java +++ b/spring-context/src/test/java/org/springframework/cache/concurrent/ConcurrentMapCacheTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,7 +36,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException * @author Juergen Hoeller * @author Stephane Nicoll */ -public class ConcurrentMapCacheTests extends AbstractValueAdaptingCacheTests { +class ConcurrentMapCacheTests extends AbstractValueAdaptingCacheTests { protected ConcurrentMap nativeCache; @@ -48,7 +48,7 @@ public class ConcurrentMapCacheTests extends AbstractValueAdaptingCacheTests(); this.cache = new ConcurrentMapCache(CACHE_NAME, this.nativeCache, true); this.nativeCacheNoNull = new ConcurrentHashMap<>(); @@ -73,13 +73,13 @@ public class ConcurrentMapCacheTests extends AbstractValueAdaptingCacheTests entry = (List) serializeCache.get(key).get(); assertThat(entry).hasSize(3); - assertThat(entry).element(0).isEqualTo("one"); + assertThat(entry.get(0)).isEqualTo("one"); } @Test - public void testNonSerializableContent() { + void testNonSerializableContent() { ConcurrentMapCache serializeCache = createCacheWithStoreByValue(); assertThatIllegalArgumentException().isThrownBy(() -> @@ -104,7 +104,7 @@ public class ConcurrentMapCacheTests extends AbstractValueAdaptingCacheTests cs; @BeforeEach - public void setup() { + void setup() { this.ctx = new AnnotationConfigApplicationContext(EnableCachingConfig.class); this.cs = ctx.getBean("service", CacheableService.class); } @AfterEach - public void tearDown() { + void tearDown() { this.ctx.close(); } diff --git a/spring-context/src/test/java/org/springframework/cache/config/ExpressionCachingIntegrationTests.java b/spring-context/src/test/java/org/springframework/cache/config/ExpressionCachingIntegrationTests.java index 5ba071381fc..0489d30ba69 100644 --- a/spring-context/src/test/java/org/springframework/cache/config/ExpressionCachingIntegrationTests.java +++ b/spring-context/src/test/java/org/springframework/cache/config/ExpressionCachingIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,7 +31,7 @@ import org.springframework.context.annotation.Configuration; /** * @author Stephane Nicoll */ -public class ExpressionCachingIntegrationTests { +class ExpressionCachingIntegrationTests { @Test // SPR-11692 @SuppressWarnings("unchecked") diff --git a/spring-context/src/test/java/org/springframework/cache/interceptor/CacheProxyFactoryBeanTests.java b/spring-context/src/test/java/org/springframework/cache/interceptor/CacheProxyFactoryBeanTests.java index a76ec69e8db..9c2b5c1ba3c 100644 --- a/spring-context/src/test/java/org/springframework/cache/interceptor/CacheProxyFactoryBeanTests.java +++ b/spring-context/src/test/java/org/springframework/cache/interceptor/CacheProxyFactoryBeanTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,10 +35,10 @@ import static org.assertj.core.api.Assertions.assertThat; * @author John Blum * @author Juergen Hoeller */ -public class CacheProxyFactoryBeanTests { +class CacheProxyFactoryBeanTests { @Test - public void configurationClassWithCacheProxyFactoryBean() { + void configurationClassWithCacheProxyFactoryBean() { try (AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(CacheProxyFactoryBeanConfiguration.class)) { Greeter greeter = applicationContext.getBean("greeter", Greeter.class); diff --git a/spring-context/src/test/java/org/springframework/cache/interceptor/CachePutEvaluationTests.java b/spring-context/src/test/java/org/springframework/cache/interceptor/CachePutEvaluationTests.java index 3bc0eacdd89..c47526d3033 100644 --- a/spring-context/src/test/java/org/springframework/cache/interceptor/CachePutEvaluationTests.java +++ b/spring-context/src/test/java/org/springframework/cache/interceptor/CachePutEvaluationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,7 +43,7 @@ import static org.assertj.core.api.Assertions.assertThat; * * @author Stephane Nicoll */ -public class CachePutEvaluationTests { +class CachePutEvaluationTests { private ConfigurableApplicationContext context; @@ -53,20 +53,20 @@ public class CachePutEvaluationTests { @BeforeEach - public void setup() { + void setup() { this.context = new AnnotationConfigApplicationContext(Config.class); this.cache = this.context.getBean(CacheManager.class).getCache("test"); this.service = this.context.getBean(SimpleService.class); } @AfterEach - public void closeContext() { + void closeContext() { this.context.close(); } @Test - public void mutualGetPutExclusion() { + void mutualGetPutExclusion() { String key = "1"; Long first = this.service.getOrPut(key, true); @@ -83,7 +83,7 @@ public class CachePutEvaluationTests { } @Test - public void getAndPut() { + void getAndPut() { this.cache.clear(); long key = 1; diff --git a/spring-context/src/test/java/org/springframework/cache/interceptor/CacheSyncFailureTests.java b/spring-context/src/test/java/org/springframework/cache/interceptor/CacheSyncFailureTests.java index 56b22970d1a..187379b3975 100644 --- a/spring-context/src/test/java/org/springframework/cache/interceptor/CacheSyncFailureTests.java +++ b/spring-context/src/test/java/org/springframework/cache/interceptor/CacheSyncFailureTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,7 +42,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException; * @author Stephane Nicoll * @since 4.3 */ -public class CacheSyncFailureTests { +class CacheSyncFailureTests { private ConfigurableApplicationContext context; @@ -50,13 +50,13 @@ public class CacheSyncFailureTests { @BeforeEach - public void setup() { + void setup() { this.context = new AnnotationConfigApplicationContext(Config.class); this.simpleService = this.context.getBean(SimpleService.class); } @AfterEach - public void closeContext() { + void closeContext() { if (this.context != null) { this.context.close(); } @@ -64,35 +64,35 @@ public class CacheSyncFailureTests { @Test - public void unlessSync() { + void unlessSync() { assertThatIllegalStateException() .isThrownBy(() -> this.simpleService.unlessSync("key")) .withMessageContaining("A sync=true operation does not support the unless attribute"); } @Test - public void severalCachesSync() { + void severalCachesSync() { assertThatIllegalStateException() .isThrownBy(() -> this.simpleService.severalCachesSync("key")) .withMessageContaining("A sync=true operation is restricted to a single cache"); } @Test - public void severalCachesWithResolvedSync() { + void severalCachesWithResolvedSync() { assertThatIllegalStateException() .isThrownBy(() -> this.simpleService.severalCachesWithResolvedSync("key")) .withMessageContaining("A sync=true operation is restricted to a single cache"); } @Test - public void syncWithAnotherOperation() { + void syncWithAnotherOperation() { assertThatIllegalStateException() .isThrownBy(() -> this.simpleService.syncWithAnotherOperation("key")) .withMessageContaining("A sync=true operation cannot be combined with other cache operations"); } @Test - public void syncWithTwoGetOperations() { + void syncWithTwoGetOperations() { assertThatIllegalStateException() .isThrownBy(() -> this.simpleService.syncWithTwoGetOperations("key")) .withMessageContaining("Only one sync=true operation is allowed"); diff --git a/spring-context/src/test/java/org/springframework/cache/interceptor/ExpressionEvaluatorTests.java b/spring-context/src/test/java/org/springframework/cache/interceptor/ExpressionEvaluatorTests.java index c061cacfe52..dadfe64eda3 100644 --- a/spring-context/src/test/java/org/springframework/cache/interceptor/ExpressionEvaluatorTests.java +++ b/spring-context/src/test/java/org/springframework/cache/interceptor/ExpressionEvaluatorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,7 +48,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; * @author Sam Brannen * @author Stephane Nicoll */ -public class ExpressionEvaluatorTests { +class ExpressionEvaluatorTests { private final StandardEvaluationContext originalEvaluationContext = new StandardEvaluationContext(); @@ -65,7 +65,7 @@ public class ExpressionEvaluatorTests { @Test - public void testMultipleCachingSource() { + void testMultipleCachingSource() { Collection ops = getOps("multipleCaching"); assertThat(ops).hasSize(2); Iterator it = ops.iterator(); @@ -80,7 +80,7 @@ public class ExpressionEvaluatorTests { } @Test - public void testMultipleCachingEval() { + void testMultipleCachingEval() { AnnotatedClass target = new AnnotatedClass(); Method method = ReflectionUtils.findMethod( AnnotatedClass.class, "multipleCaching", Object.class, Object.class); @@ -102,28 +102,28 @@ public class ExpressionEvaluatorTests { } @Test - public void withReturnValue() { + void withReturnValue() { EvaluationContext context = createEvaluationContext("theResult"); Object value = new SpelExpressionParser().parseExpression("#result").getValue(context); assertThat(value).isEqualTo("theResult"); } @Test - public void withNullReturn() { + void withNullReturn() { EvaluationContext context = createEvaluationContext(null); Object value = new SpelExpressionParser().parseExpression("#result").getValue(context); assertThat(value).isNull(); } @Test - public void withoutReturnValue() { + void withoutReturnValue() { EvaluationContext context = createEvaluationContext(CacheOperationExpressionEvaluator.NO_RESULT); Object value = new SpelExpressionParser().parseExpression("#result").getValue(context); assertThat(value).isNull(); } @Test - public void unavailableReturnValue() { + void unavailableReturnValue() { EvaluationContext context = createEvaluationContext(CacheOperationExpressionEvaluator.RESULT_UNAVAILABLE); assertThatExceptionOfType(VariableNotAvailableException.class).isThrownBy(() -> new SpelExpressionParser().parseExpression("#result").getValue(context)) @@ -131,7 +131,7 @@ public class ExpressionEvaluatorTests { } @Test - public void resolveBeanReference() { + void resolveBeanReference() { StaticApplicationContext applicationContext = new StaticApplicationContext(); BeanDefinition beanDefinition = new RootBeanDefinition(String.class); applicationContext.registerBeanDefinition("myBean", beanDefinition); diff --git a/spring-context/src/test/java/org/springframework/cache/interceptor/SimpleKeyGeneratorTests.java b/spring-context/src/test/java/org/springframework/cache/interceptor/SimpleKeyGeneratorTests.java index c29ecbcd8ad..06ff77d58a4 100644 --- a/spring-context/src/test/java/org/springframework/cache/interceptor/SimpleKeyGeneratorTests.java +++ b/spring-context/src/test/java/org/springframework/cache/interceptor/SimpleKeyGeneratorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,13 +33,13 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Juergen Hoeller * @author Sebastien Deleuze */ -public class SimpleKeyGeneratorTests { +class SimpleKeyGeneratorTests { private final SimpleKeyGenerator generator = new SimpleKeyGenerator(); @Test - public void noValues() { + void noValues() { Object k1 = generateKey(new Object[] {}); Object k2 = generateKey(new Object[] {}); Object k3 = generateKey(new Object[] { "different" }); @@ -50,7 +50,7 @@ public class SimpleKeyGeneratorTests { } @Test - public void singleValue() { + void singleValue() { Object k1 = generateKey(new Object[] { "a" }); Object k2 = generateKey(new Object[] { "a" }); Object k3 = generateKey(new Object[] { "different" }); @@ -62,7 +62,7 @@ public class SimpleKeyGeneratorTests { } @Test - public void multipleValues() { + void multipleValues() { Object k1 = generateKey(new Object[] { "a", 1, "b" }); Object k2 = generateKey(new Object[] { "a", 1, "b" }); Object k3 = generateKey(new Object[] { "b", 1, "a" }); @@ -73,7 +73,7 @@ public class SimpleKeyGeneratorTests { } @Test - public void singleNullValue() { + void singleNullValue() { Object k1 = generateKey(new Object[] { null }); Object k2 = generateKey(new Object[] { null }); Object k3 = generateKey(new Object[] { "different" }); @@ -85,7 +85,7 @@ public class SimpleKeyGeneratorTests { } @Test - public void multipleNullValues() { + void multipleNullValues() { Object k1 = generateKey(new Object[] { "a", null, "b", null }); Object k2 = generateKey(new Object[] { "a", null, "b", null }); Object k3 = generateKey(new Object[] { "a", null, "b" }); @@ -96,7 +96,7 @@ public class SimpleKeyGeneratorTests { } @Test - public void plainArray() { + void plainArray() { Object k1 = generateKey(new Object[] { new String[]{"a", "b"} }); Object k2 = generateKey(new Object[] { new String[]{"a", "b"} }); Object k3 = generateKey(new Object[] { new String[]{"b", "a"} }); @@ -107,7 +107,7 @@ public class SimpleKeyGeneratorTests { } @Test - public void arrayWithExtraParameter() { + void arrayWithExtraParameter() { Object k1 = generateKey(new Object[] { new String[]{"a", "b"}, "c" }); Object k2 = generateKey(new Object[] { new String[]{"a", "b"}, "c" }); Object k3 = generateKey(new Object[] { new String[]{"b", "a"}, "c" }); @@ -118,7 +118,7 @@ public class SimpleKeyGeneratorTests { } @Test - public void serializedKeys() throws Exception { + void serializedKeys() throws Exception { Object k1 = SerializationTestUtils.serializeAndDeserialize(generateKey(new Object[] { "a", 1, "b" })); Object k2 = SerializationTestUtils.serializeAndDeserialize(generateKey(new Object[] { "a", 1, "b" })); Object k3 = SerializationTestUtils.serializeAndDeserialize(generateKey(new Object[] { "b", 1, "a" })); diff --git a/spring-context/src/test/java/org/springframework/context/annotation/AbstractCircularImportDetectionTests.java b/spring-context/src/test/java/org/springframework/context/annotation/AbstractCircularImportDetectionTests.java index cdc746be3fb..5fe8db87134 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/AbstractCircularImportDetectionTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/AbstractCircularImportDetectionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,11 +33,11 @@ public abstract class AbstractCircularImportDetectionTests { protected abstract ConfigurationClassParser newParser(); - protected abstract String loadAsConfigurationSource(Class clazz) throws Exception; + protected abstract String loadAsConfigurationSource(Class clazz); @Test - public void simpleCircularImportIsDetected() throws Exception { + void simpleCircularImportIsDetected() throws Exception { boolean threw = false; try { newParser().parse(loadAsConfigurationSource(A.class), "A"); @@ -52,7 +52,7 @@ public abstract class AbstractCircularImportDetectionTests { } @Test - public void complexCircularImportIsDetected() throws Exception { + void complexCircularImportIsDetected() throws Exception { boolean threw = false; try { newParser().parse(loadAsConfigurationSource(X.class), "X"); diff --git a/spring-context/src/test/java/org/springframework/context/annotation/AggressiveFactoryBeanInstantiationTests.java b/spring-context/src/test/java/org/springframework/context/annotation/AggressiveFactoryBeanInstantiationTests.java index 1acfc113d1d..46750e613fe 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/AggressiveFactoryBeanInstantiationTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/AggressiveFactoryBeanInstantiationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,10 +34,10 @@ import static org.assertj.core.api.Assertions.fail; * @author Andy Wilkinson * @author Liu Dongmiao */ -public class AggressiveFactoryBeanInstantiationTests { +class AggressiveFactoryBeanInstantiationTests { @Test - public void directlyRegisteredFactoryBean() { + void directlyRegisteredFactoryBean() { try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext()) { context.register(SimpleFactoryBean.class); context.addBeanFactoryPostProcessor(factory -> @@ -48,7 +48,7 @@ public class AggressiveFactoryBeanInstantiationTests { } @Test - public void beanMethodFactoryBean() { + void beanMethodFactoryBean() { try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext()) { context.register(BeanMethodConfiguration.class); context.addBeanFactoryPostProcessor(factory -> @@ -59,7 +59,7 @@ public class AggressiveFactoryBeanInstantiationTests { } @Test - public void checkLinkageError() { + void checkLinkageError() { try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext()) { context.register(BeanMethodConfigurationWithExceptionInInitializer.class); context.refresh(); diff --git a/spring-context/src/test/java/org/springframework/context/annotation/AnnotationConfigApplicationContextTests.java b/spring-context/src/test/java/org/springframework/context/annotation/AnnotationConfigApplicationContextTests.java index 0ef65fc49ee..564acf1ca40 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/AnnotationConfigApplicationContextTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/AnnotationConfigApplicationContextTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -307,8 +307,8 @@ class AnnotationConfigApplicationContextTests { assertThat(ObjectUtils.containsElement(context.getBeanNamesForType(BeanC.class), "c")).isTrue(); assertThat(context.getBeansOfType(BeanA.class)).isEmpty(); - assertThat(context.getBeansOfType(BeanB.class).values()).element(0).isSameAs(context.getBean(BeanB.class)); - assertThat(context.getBeansOfType(BeanC.class).values()).element(0).isSameAs(context.getBean(BeanC.class)); + assertThat(context.getBeansOfType(BeanB.class).values()).singleElement().isSameAs(context.getBean(BeanB.class)); + assertThat(context.getBeansOfType(BeanC.class).values()).singleElement().isSameAs(context.getBean(BeanC.class)); assertThatExceptionOfType(NoSuchBeanDefinitionException.class) .isThrownBy(() -> context.getBeanFactory().resolveNamedBean(BeanA.class)); diff --git a/spring-context/src/test/java/org/springframework/context/annotation/AnnotationScopeMetadataResolverTests.java b/spring-context/src/test/java/org/springframework/context/annotation/AnnotationScopeMetadataResolverTests.java index 68137b61ca5..2f3e12f24d3 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/AnnotationScopeMetadataResolverTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/AnnotationScopeMetadataResolverTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,13 +44,13 @@ import static org.springframework.context.annotation.ScopedProxyMode.TARGET_CLAS * @author Juergen Hoeller * @author Sam Brannen */ -public class AnnotationScopeMetadataResolverTests { +class AnnotationScopeMetadataResolverTests { private AnnotationScopeMetadataResolver scopeMetadataResolver = new AnnotationScopeMetadataResolver(); @Test - public void resolveScopeMetadataShouldNotApplyScopedProxyModeToSingleton() { + void resolveScopeMetadataShouldNotApplyScopedProxyModeToSingleton() { AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(AnnotatedWithSingletonScope.class); ScopeMetadata scopeMetadata = this.scopeMetadataResolver.resolveScopeMetadata(bd); assertThat(scopeMetadata).as("resolveScopeMetadata(..) must *never* return null.").isNotNull(); @@ -59,7 +59,7 @@ public class AnnotationScopeMetadataResolverTests { } @Test - public void resolveScopeMetadataShouldApplyScopedProxyModeToPrototype() { + void resolveScopeMetadataShouldApplyScopedProxyModeToPrototype() { this.scopeMetadataResolver = new AnnotationScopeMetadataResolver(INTERFACES); AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(AnnotatedWithPrototypeScope.class); ScopeMetadata scopeMetadata = this.scopeMetadataResolver.resolveScopeMetadata(bd); @@ -69,7 +69,7 @@ public class AnnotationScopeMetadataResolverTests { } @Test - public void resolveScopeMetadataShouldReadScopedProxyModeFromAnnotation() { + void resolveScopeMetadataShouldReadScopedProxyModeFromAnnotation() { AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(AnnotatedWithScopedProxy.class); ScopeMetadata scopeMetadata = this.scopeMetadataResolver.resolveScopeMetadata(bd); assertThat(scopeMetadata).as("resolveScopeMetadata(..) must *never* return null.").isNotNull(); @@ -78,7 +78,7 @@ public class AnnotationScopeMetadataResolverTests { } @Test - public void customRequestScope() { + void customRequestScope() { AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(AnnotatedWithCustomRequestScope.class); ScopeMetadata scopeMetadata = this.scopeMetadataResolver.resolveScopeMetadata(bd); assertThat(scopeMetadata).as("resolveScopeMetadata(..) must *never* return null.").isNotNull(); @@ -87,7 +87,7 @@ public class AnnotationScopeMetadataResolverTests { } @Test - public void customRequestScopeViaAsm() throws IOException { + void customRequestScopeViaAsm() throws IOException { MetadataReaderFactory readerFactory = new SimpleMetadataReaderFactory(); MetadataReader reader = readerFactory.getMetadataReader(AnnotatedWithCustomRequestScope.class.getName()); AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(reader.getAnnotationMetadata()); @@ -98,7 +98,7 @@ public class AnnotationScopeMetadataResolverTests { } @Test - public void customRequestScopeWithAttribute() { + void customRequestScopeWithAttribute() { AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition( AnnotatedWithCustomRequestScopeWithAttributeOverride.class); ScopeMetadata scopeMetadata = this.scopeMetadataResolver.resolveScopeMetadata(bd); @@ -108,7 +108,7 @@ public class AnnotationScopeMetadataResolverTests { } @Test - public void customRequestScopeWithAttributeViaAsm() throws IOException { + void customRequestScopeWithAttributeViaAsm() throws IOException { MetadataReaderFactory readerFactory = new SimpleMetadataReaderFactory(); MetadataReader reader = readerFactory.getMetadataReader(AnnotatedWithCustomRequestScopeWithAttributeOverride.class.getName()); AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(reader.getAnnotationMetadata()); @@ -119,13 +119,13 @@ public class AnnotationScopeMetadataResolverTests { } @Test - public void ctorWithNullScopedProxyMode() { + void ctorWithNullScopedProxyMode() { assertThatIllegalArgumentException().isThrownBy(() -> new AnnotationScopeMetadataResolver(null)); } @Test - public void setScopeAnnotationTypeWithNullType() { + void setScopeAnnotationTypeWithNullType() { assertThatIllegalArgumentException().isThrownBy(() -> scopeMetadataResolver.setScopeAnnotationType(null)); } diff --git a/spring-context/src/test/java/org/springframework/context/annotation/AsmCircularImportDetectionTests.java b/spring-context/src/test/java/org/springframework/context/annotation/AsmCircularImportDetectionTests.java index a6ad85b8651..a71cff29eb2 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/AsmCircularImportDetectionTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/AsmCircularImportDetectionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,7 +28,7 @@ import org.springframework.core.type.classreading.CachingMetadataReaderFactory; * * @author Chris Beams */ -public class AsmCircularImportDetectionTests extends AbstractCircularImportDetectionTests { +class AsmCircularImportDetectionTests extends AbstractCircularImportDetectionTests { @Override protected ConfigurationClassParser newParser() { @@ -42,7 +42,7 @@ public class AsmCircularImportDetectionTests extends AbstractCircularImportDetec } @Override - protected String loadAsConfigurationSource(Class clazz) throws Exception { + protected String loadAsConfigurationSource(Class clazz) { return clazz.getName(); } diff --git a/spring-context/src/test/java/org/springframework/context/annotation/BeanMethodMetadataTests.java b/spring-context/src/test/java/org/springframework/context/annotation/BeanMethodMetadataTests.java index 4127bb93eb0..4090d428878 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/BeanMethodMetadataTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/BeanMethodMetadataTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,7 +34,7 @@ import static org.assertj.core.api.Assertions.assertThat; class BeanMethodMetadataTests { @Test - void providesBeanMethodBeanDefinition() throws Exception { + void providesBeanMethodBeanDefinition() { AnnotationConfigApplicationContext context= new AnnotationConfigApplicationContext(Conf.class); BeanDefinition beanDefinition = context.getBeanDefinition("myBean"); assertThat(beanDefinition).as("should provide AnnotatedBeanDefinition").isInstanceOf(AnnotatedBeanDefinition.class); diff --git a/spring-context/src/test/java/org/springframework/context/annotation/BeanMethodPolymorphismTests.java b/spring-context/src/test/java/org/springframework/context/annotation/BeanMethodPolymorphismTests.java index 4e62e4212c5..773b2345fdd 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/BeanMethodPolymorphismTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/BeanMethodPolymorphismTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,13 +39,13 @@ import static org.assertj.core.api.Assertions.assertThat; public class BeanMethodPolymorphismTests { @Test - public void beanMethodDetectedOnSuperClass() { + void beanMethodDetectedOnSuperClass() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(Config.class); assertThat(ctx.getBean("testBean", BaseTestBean.class)).isNotNull(); } @Test - public void beanMethodOverriding() { + void beanMethodOverriding() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(OverridingConfig.class); ctx.setAllowBeanDefinitionOverriding(false); @@ -56,7 +56,7 @@ public class BeanMethodPolymorphismTests { } @Test - public void beanMethodOverridingOnASM() { + void beanMethodOverridingOnASM() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.registerBeanDefinition("config", new RootBeanDefinition(OverridingConfig.class.getName())); ctx.setAllowBeanDefinitionOverriding(false); @@ -67,7 +67,7 @@ public class BeanMethodPolymorphismTests { } @Test - public void beanMethodOverridingWithNarrowedReturnType() { + void beanMethodOverridingWithNarrowedReturnType() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(NarrowedOverridingConfig.class); ctx.setAllowBeanDefinitionOverriding(false); @@ -78,7 +78,7 @@ public class BeanMethodPolymorphismTests { } @Test - public void beanMethodOverridingWithNarrowedReturnTypeOnASM() { + void beanMethodOverridingWithNarrowedReturnTypeOnASM() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.registerBeanDefinition("config", new RootBeanDefinition(NarrowedOverridingConfig.class.getName())); ctx.setAllowBeanDefinitionOverriding(false); @@ -89,7 +89,7 @@ public class BeanMethodPolymorphismTests { } @Test - public void beanMethodOverloadingWithoutInheritance() { + void beanMethodOverloadingWithoutInheritance() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(ConfigWithOverloading.class); ctx.setAllowBeanDefinitionOverriding(false); @@ -98,7 +98,7 @@ public class BeanMethodPolymorphismTests { } @Test - public void beanMethodOverloadingWithoutInheritanceAndExtraDependency() { + void beanMethodOverloadingWithoutInheritanceAndExtraDependency() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(ConfigWithOverloading.class); ctx.getDefaultListableBeanFactory().registerSingleton("anInt", 5); @@ -108,7 +108,7 @@ public class BeanMethodPolymorphismTests { } @Test - public void beanMethodOverloadingWithAdditionalMetadata() { + void beanMethodOverloadingWithAdditionalMetadata() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(ConfigWithOverloadingAndAdditionalMetadata.class); ctx.setAllowBeanDefinitionOverriding(false); @@ -119,7 +119,7 @@ public class BeanMethodPolymorphismTests { } @Test - public void beanMethodOverloadingWithAdditionalMetadataButOtherMethodExecuted() { + void beanMethodOverloadingWithAdditionalMetadataButOtherMethodExecuted() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(ConfigWithOverloadingAndAdditionalMetadata.class); ctx.getDefaultListableBeanFactory().registerSingleton("anInt", 5); @@ -131,7 +131,7 @@ public class BeanMethodPolymorphismTests { } @Test - public void beanMethodOverloadingWithInheritance() { + void beanMethodOverloadingWithInheritance() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(SubConfig.class); ctx.setAllowBeanDefinitionOverriding(false); @@ -143,7 +143,7 @@ public class BeanMethodPolymorphismTests { // SPR-11025 @Test - public void beanMethodOverloadingWithInheritanceAndList() { + void beanMethodOverloadingWithInheritanceAndList() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(SubConfigWithList.class); ctx.setAllowBeanDefinitionOverriding(false); @@ -159,13 +159,13 @@ public class BeanMethodPolymorphismTests { * so it's referred to here as 'shadowing' to distinguish the difference. */ @Test - public void beanMethodShadowing() { + void beanMethodShadowing() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(ShadowConfig.class); assertThat(ctx.getBean(String.class)).isEqualTo("shadow"); } @Test - public void beanMethodThroughAopProxy() { + void beanMethodThroughAopProxy() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(Config.class); ctx.register(AnnotationAwareAspectJAutoProxyCreator.class); diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ClassPathBeanDefinitionScannerTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ClassPathBeanDefinitionScannerTests.java index bcd6c33214a..23b7be713c4 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ClassPathBeanDefinitionScannerTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ClassPathBeanDefinitionScannerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -51,13 +51,13 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException; * @author Juergen Hoeller * @author Chris Beams */ -public class ClassPathBeanDefinitionScannerTests { +class ClassPathBeanDefinitionScannerTests { private static final String BASE_PACKAGE = "example.scannable"; @Test - public void testSimpleScanWithDefaultFiltersAndPostProcessors() { + void testSimpleScanWithDefaultFiltersAndPostProcessors() { GenericApplicationContext context = new GenericApplicationContext(); ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context); int beanCount = scanner.scan(BASE_PACKAGE); @@ -83,7 +83,7 @@ public class ClassPathBeanDefinitionScannerTests { } @Test - public void testSimpleScanWithDefaultFiltersAndPrimaryLazyBean() { + void testSimpleScanWithDefaultFiltersAndPrimaryLazyBean() { GenericApplicationContext context = new GenericApplicationContext(); ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context); scanner.scan(BASE_PACKAGE); @@ -105,7 +105,7 @@ public class ClassPathBeanDefinitionScannerTests { } @Test - public void testDoubleScan() { + void testDoubleScan() { GenericApplicationContext context = new GenericApplicationContext(); ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context); @@ -130,7 +130,7 @@ public class ClassPathBeanDefinitionScannerTests { } @Test - public void testWithIndex() { + void testWithIndex() { GenericApplicationContext context = new GenericApplicationContext(); context.setClassLoader(CandidateComponentsTestClassLoader.index( ClassPathScanningCandidateComponentProviderTests.class.getClassLoader(), @@ -149,7 +149,7 @@ public class ClassPathBeanDefinitionScannerTests { } @Test - public void testDoubleScanWithIndex() { + void testDoubleScanWithIndex() { GenericApplicationContext context = new GenericApplicationContext(); context.setClassLoader(CandidateComponentsTestClassLoader.index( ClassPathScanningCandidateComponentProviderTests.class.getClassLoader(), @@ -177,7 +177,7 @@ public class ClassPathBeanDefinitionScannerTests { } @Test - public void testSimpleScanWithDefaultFiltersAndNoPostProcessors() { + void testSimpleScanWithDefaultFiltersAndNoPostProcessors() { GenericApplicationContext context = new GenericApplicationContext(); ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context); scanner.setIncludeAnnotationConfig(false); @@ -192,7 +192,7 @@ public class ClassPathBeanDefinitionScannerTests { } @Test - public void testSimpleScanWithDefaultFiltersAndOverridingBean() { + void testSimpleScanWithDefaultFiltersAndOverridingBean() { GenericApplicationContext context = new GenericApplicationContext(); context.registerBeanDefinition("stubFooDao", new RootBeanDefinition(TestBean.class)); ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context); @@ -203,7 +203,7 @@ public class ClassPathBeanDefinitionScannerTests { } @Test - public void testSimpleScanWithDefaultFiltersAndOverridingBeanNotAllowed() { + void testSimpleScanWithDefaultFiltersAndOverridingBeanNotAllowed() { GenericApplicationContext context = new GenericApplicationContext(); context.getDefaultListableBeanFactory().setAllowBeanDefinitionOverriding(false); context.registerBeanDefinition("stubFooDao", new RootBeanDefinition(TestBean.class)); @@ -216,7 +216,7 @@ public class ClassPathBeanDefinitionScannerTests { } @Test - public void testSimpleScanWithDefaultFiltersAndOverridingBeanAcceptedForSameBeanClass() { + void testSimpleScanWithDefaultFiltersAndOverridingBeanAcceptedForSameBeanClass() { GenericApplicationContext context = new GenericApplicationContext(); context.getDefaultListableBeanFactory().setAllowBeanDefinitionOverriding(false); context.registerBeanDefinition("stubFooDao", new RootBeanDefinition(StubFooDao.class)); @@ -228,7 +228,7 @@ public class ClassPathBeanDefinitionScannerTests { } @Test - public void testSimpleScanWithDefaultFiltersAndDefaultBeanNameClash() { + void testSimpleScanWithDefaultFiltersAndDefaultBeanNameClash() { GenericApplicationContext context = new GenericApplicationContext(); ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context); scanner.setIncludeAnnotationConfig(false); @@ -240,7 +240,7 @@ public class ClassPathBeanDefinitionScannerTests { } @Test - public void testSimpleScanWithDefaultFiltersAndOverriddenEqualNamedBean() { + void testSimpleScanWithDefaultFiltersAndOverriddenEqualNamedBean() { GenericApplicationContext context = new GenericApplicationContext(); context.registerBeanDefinition("myNamedDao", new RootBeanDefinition(NamedStubDao.class)); int initialBeanCount = context.getBeanDefinitionCount(); @@ -258,7 +258,7 @@ public class ClassPathBeanDefinitionScannerTests { } @Test - public void testSimpleScanWithDefaultFiltersAndOverriddenCompatibleNamedBean() { + void testSimpleScanWithDefaultFiltersAndOverriddenCompatibleNamedBean() { GenericApplicationContext context = new GenericApplicationContext(); RootBeanDefinition bd = new RootBeanDefinition(NamedStubDao.class); bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); @@ -278,7 +278,7 @@ public class ClassPathBeanDefinitionScannerTests { } @Test - public void testSimpleScanWithDefaultFiltersAndSameBeanTwice() { + void testSimpleScanWithDefaultFiltersAndSameBeanTwice() { GenericApplicationContext context = new GenericApplicationContext(); ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context); scanner.setIncludeAnnotationConfig(false); @@ -288,7 +288,7 @@ public class ClassPathBeanDefinitionScannerTests { } @Test - public void testSimpleScanWithDefaultFiltersAndSpecifiedBeanNameClash() { + void testSimpleScanWithDefaultFiltersAndSpecifiedBeanNameClash() { GenericApplicationContext context = new GenericApplicationContext(); ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context); scanner.setIncludeAnnotationConfig(false); @@ -300,7 +300,7 @@ public class ClassPathBeanDefinitionScannerTests { } @Test - public void testCustomIncludeFilterWithoutDefaultsButIncludingPostProcessors() { + void testCustomIncludeFilterWithoutDefaultsButIncludingPostProcessors() { GenericApplicationContext context = new GenericApplicationContext(); ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context, false); scanner.addIncludeFilter(new AnnotationTypeFilter(CustomComponent.class)); @@ -315,7 +315,7 @@ public class ClassPathBeanDefinitionScannerTests { } @Test - public void testCustomIncludeFilterWithoutDefaultsAndNoPostProcessors() { + void testCustomIncludeFilterWithoutDefaultsAndNoPostProcessors() { GenericApplicationContext context = new GenericApplicationContext(); ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context, false); scanner.addIncludeFilter(new AnnotationTypeFilter(CustomComponent.class)); @@ -335,7 +335,7 @@ public class ClassPathBeanDefinitionScannerTests { } @Test - public void testCustomIncludeFilterAndDefaults() { + void testCustomIncludeFilterAndDefaults() { GenericApplicationContext context = new GenericApplicationContext(); ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context, true); scanner.addIncludeFilter(new AnnotationTypeFilter(CustomComponent.class)); @@ -355,7 +355,7 @@ public class ClassPathBeanDefinitionScannerTests { } @Test - public void testCustomAnnotationExcludeFilterAndDefaults() { + void testCustomAnnotationExcludeFilterAndDefaults() { GenericApplicationContext context = new GenericApplicationContext(); ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context, true); scanner.addExcludeFilter(new AnnotationTypeFilter(Aspect.class)); @@ -373,7 +373,7 @@ public class ClassPathBeanDefinitionScannerTests { } @Test - public void testCustomAssignableTypeExcludeFilterAndDefaults() { + void testCustomAssignableTypeExcludeFilterAndDefaults() { GenericApplicationContext context = new GenericApplicationContext(); ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context, true); scanner.addExcludeFilter(new AssignableTypeFilter(FooService.class)); @@ -392,7 +392,7 @@ public class ClassPathBeanDefinitionScannerTests { } @Test - public void testCustomAssignableTypeExcludeFilterAndDefaultsWithoutPostProcessors() { + void testCustomAssignableTypeExcludeFilterAndDefaultsWithoutPostProcessors() { GenericApplicationContext context = new GenericApplicationContext(); ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context, true); scanner.setIncludeAnnotationConfig(false); @@ -410,7 +410,7 @@ public class ClassPathBeanDefinitionScannerTests { } @Test - public void testMultipleCustomExcludeFiltersAndDefaults() { + void testMultipleCustomExcludeFiltersAndDefaults() { GenericApplicationContext context = new GenericApplicationContext(); ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context, true); scanner.addExcludeFilter(new AssignableTypeFilter(FooService.class)); @@ -430,7 +430,7 @@ public class ClassPathBeanDefinitionScannerTests { } @Test - public void testCustomBeanNameGenerator() { + void testCustomBeanNameGenerator() { GenericApplicationContext context = new GenericApplicationContext(); ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context); scanner.setBeanNameGenerator(new TestBeanNameGenerator()); @@ -450,7 +450,7 @@ public class ClassPathBeanDefinitionScannerTests { } @Test - public void testMultipleBasePackagesWithDefaultsOnly() { + void testMultipleBasePackagesWithDefaultsOnly() { GenericApplicationContext singlePackageContext = new GenericApplicationContext(); ClassPathBeanDefinitionScanner singlePackageScanner = new ClassPathBeanDefinitionScanner(singlePackageContext); GenericApplicationContext multiPackageContext = new GenericApplicationContext(); @@ -462,7 +462,7 @@ public class ClassPathBeanDefinitionScannerTests { } @Test - public void testMultipleScanCalls() { + void testMultipleScanCalls() { GenericApplicationContext context = new GenericApplicationContext(); ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context); int initialBeanCount = context.getBeanDefinitionCount(); @@ -474,7 +474,7 @@ public class ClassPathBeanDefinitionScannerTests { } @Test - public void testBeanAutowiredWithAnnotationConfigEnabled() { + void testBeanAutowiredWithAnnotationConfigEnabled() { GenericApplicationContext context = new GenericApplicationContext(); context.registerBeanDefinition("myBf", new RootBeanDefinition(StaticListableBeanFactory.class)); ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context); @@ -504,7 +504,7 @@ public class ClassPathBeanDefinitionScannerTests { } @Test - public void testBeanNotAutowiredWithAnnotationConfigDisabled() { + void testBeanNotAutowiredWithAnnotationConfigDisabled() { GenericApplicationContext context = new GenericApplicationContext(); ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context); scanner.setIncludeAnnotationConfig(false); @@ -523,7 +523,7 @@ public class ClassPathBeanDefinitionScannerTests { } @Test - public void testAutowireCandidatePatternMatches() { + void testAutowireCandidatePatternMatches() { GenericApplicationContext context = new GenericApplicationContext(); ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context); scanner.setIncludeAnnotationConfig(true); @@ -538,7 +538,7 @@ public class ClassPathBeanDefinitionScannerTests { } @Test - public void testAutowireCandidatePatternDoesNotMatch() { + void testAutowireCandidatePatternDoesNotMatch() { GenericApplicationContext context = new GenericApplicationContext(); ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context); scanner.setIncludeAnnotationConfig(true); diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ClassPathFactoryBeanDefinitionScannerTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ClassPathFactoryBeanDefinitionScannerTests.java index 5e79ff768b1..0f540b8615c 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ClassPathFactoryBeanDefinitionScannerTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ClassPathFactoryBeanDefinitionScannerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,13 +37,13 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Mark Pollack * @author Juergen Hoeller */ -public class ClassPathFactoryBeanDefinitionScannerTests { +class ClassPathFactoryBeanDefinitionScannerTests { private static final String BASE_PACKAGE = FactoryMethodComponent.class.getPackage().getName(); @Test - public void testSingletonScopedFactoryMethod() { + void testSingletonScopedFactoryMethod() { GenericApplicationContext context = new GenericApplicationContext(); ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context); diff --git a/spring-context/src/test/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessorTests.java b/spring-context/src/test/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessorTests.java index daf59a936bf..ba4c7d7e46d 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessorTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -49,10 +49,10 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Juergen Hoeller * @author Chris Beams */ -public class CommonAnnotationBeanPostProcessorTests { +class CommonAnnotationBeanPostProcessorTests { @Test - public void testPostConstructAndPreDestroy() { + void testPostConstructAndPreDestroy() { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); bf.addBeanPostProcessor(new CommonAnnotationBeanPostProcessor()); bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(AnnotatedInitDestroyBean.class)); @@ -64,7 +64,7 @@ public class CommonAnnotationBeanPostProcessorTests { } @Test - public void testPostConstructAndPreDestroyWithPostProcessor() { + void testPostConstructAndPreDestroyWithPostProcessor() { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); bf.addBeanPostProcessor(new InitDestroyBeanPostProcessor()); bf.addBeanPostProcessor(new CommonAnnotationBeanPostProcessor()); @@ -77,7 +77,7 @@ public class CommonAnnotationBeanPostProcessorTests { } @Test - public void testPostConstructAndPreDestroyWithApplicationContextAndPostProcessor() { + void testPostConstructAndPreDestroyWithApplicationContextAndPostProcessor() { GenericApplicationContext ctx = new GenericApplicationContext(); ctx.registerBeanDefinition("bpp1", new RootBeanDefinition(InitDestroyBeanPostProcessor.class)); ctx.registerBeanDefinition("bpp2", new RootBeanDefinition(CommonAnnotationBeanPostProcessor.class)); @@ -91,7 +91,7 @@ public class CommonAnnotationBeanPostProcessorTests { } @Test - public void testPostConstructAndPreDestroyWithLegacyAnnotations() { + void testPostConstructAndPreDestroyWithLegacyAnnotations() { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); bf.addBeanPostProcessor(new CommonAnnotationBeanPostProcessor()); bf.registerBeanDefinition("annotatedBean", new RootBeanDefinition(LegacyAnnotatedInitDestroyBean.class)); @@ -103,7 +103,7 @@ public class CommonAnnotationBeanPostProcessorTests { } @Test - public void testPostConstructAndPreDestroyWithManualConfiguration() { + void testPostConstructAndPreDestroyWithManualConfiguration() { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); InitDestroyAnnotationBeanPostProcessor bpp = new InitDestroyAnnotationBeanPostProcessor(); bpp.setInitAnnotationType(PostConstruct.class); @@ -118,7 +118,7 @@ public class CommonAnnotationBeanPostProcessorTests { } @Test - public void testPostProcessorWithNullBean() { + void testPostProcessorWithNullBean() { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); bf.addBeanPostProcessor(new CommonAnnotationBeanPostProcessor()); RootBeanDefinition rbd = new RootBeanDefinition(NullFactory.class); @@ -130,7 +130,7 @@ public class CommonAnnotationBeanPostProcessorTests { } @Test - public void testSerialization() throws Exception { + void testSerialization() throws Exception { CommonAnnotationBeanPostProcessor bpp = new CommonAnnotationBeanPostProcessor(); CommonAnnotationBeanPostProcessor bpp2 = SerializationTestUtils.serializeAndDeserialize(bpp); @@ -140,7 +140,7 @@ public class CommonAnnotationBeanPostProcessorTests { } @Test - public void testSerializationWithManualConfiguration() throws Exception { + void testSerializationWithManualConfiguration() throws Exception { InitDestroyAnnotationBeanPostProcessor bpp = new InitDestroyAnnotationBeanPostProcessor(); bpp.setInitAnnotationType(PostConstruct.class); bpp.setDestroyAnnotationType(PreDestroy.class); @@ -152,7 +152,7 @@ public class CommonAnnotationBeanPostProcessorTests { } @Test - public void testResourceInjection() { + void testResourceInjection() { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); CommonAnnotationBeanPostProcessor bpp = new CommonAnnotationBeanPostProcessor(); bpp.setResourceFactory(bf); @@ -176,7 +176,7 @@ public class CommonAnnotationBeanPostProcessorTests { } @Test - public void testResourceInjectionWithPrototypes() { + void testResourceInjectionWithPrototypes() { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); CommonAnnotationBeanPostProcessor bpp = new CommonAnnotationBeanPostProcessor(); bpp.setResourceFactory(bf); @@ -213,7 +213,7 @@ public class CommonAnnotationBeanPostProcessorTests { } @Test - public void testResourceInjectionWithLegacyAnnotations() { + void testResourceInjectionWithLegacyAnnotations() { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); CommonAnnotationBeanPostProcessor bpp = new CommonAnnotationBeanPostProcessor(); bpp.setResourceFactory(bf); @@ -237,7 +237,7 @@ public class CommonAnnotationBeanPostProcessorTests { } @Test - public void testResourceInjectionWithResolvableDependencyType() { + void testResourceInjectionWithResolvableDependencyType() { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); CommonAnnotationBeanPostProcessor bpp = new CommonAnnotationBeanPostProcessor(); bpp.setBeanFactory(bf); @@ -273,7 +273,7 @@ public class CommonAnnotationBeanPostProcessorTests { } @Test - public void testResourceInjectionWithDefaultMethod() { + void testResourceInjectionWithDefaultMethod() { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); CommonAnnotationBeanPostProcessor bpp = new CommonAnnotationBeanPostProcessor(); bpp.setBeanFactory(bf); @@ -293,7 +293,7 @@ public class CommonAnnotationBeanPostProcessorTests { } @Test - public void testResourceInjectionWithTwoProcessors() { + void testResourceInjectionWithTwoProcessors() { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); CommonAnnotationBeanPostProcessor bpp = new CommonAnnotationBeanPostProcessor(); bpp.setResourceFactory(bf); @@ -318,7 +318,7 @@ public class CommonAnnotationBeanPostProcessorTests { } @Test - public void testResourceInjectionFromJndi() { + void testResourceInjectionFromJndi() { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); CommonAnnotationBeanPostProcessor bpp = new CommonAnnotationBeanPostProcessor(); SimpleJndiBeanFactory resourceFactory = new SimpleJndiBeanFactory(); @@ -343,7 +343,7 @@ public class CommonAnnotationBeanPostProcessorTests { } @Test - public void testExtendedResourceInjection() { + void testExtendedResourceInjection() { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); CommonAnnotationBeanPostProcessor bpp = new CommonAnnotationBeanPostProcessor(); bpp.setBeanFactory(bf); @@ -396,7 +396,7 @@ public class CommonAnnotationBeanPostProcessorTests { } @Test - public void testExtendedResourceInjectionWithOverriding() { + void testExtendedResourceInjectionWithOverriding() { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); CommonAnnotationBeanPostProcessor bpp = new CommonAnnotationBeanPostProcessor(); bpp.setBeanFactory(bf); @@ -453,7 +453,7 @@ public class CommonAnnotationBeanPostProcessorTests { } @Test - public void testExtendedEjbInjection() { + void testExtendedEjbInjection() { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); CommonAnnotationBeanPostProcessor bpp = new CommonAnnotationBeanPostProcessor(); bpp.setBeanFactory(bf); @@ -490,7 +490,7 @@ public class CommonAnnotationBeanPostProcessorTests { } @Test - public void testLazyResolutionWithResourceField() { + void testLazyResolutionWithResourceField() { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); CommonAnnotationBeanPostProcessor bpp = new CommonAnnotationBeanPostProcessor(); bpp.setBeanFactory(bf); @@ -508,7 +508,7 @@ public class CommonAnnotationBeanPostProcessorTests { } @Test - public void testLazyResolutionWithResourceMethod() { + void testLazyResolutionWithResourceMethod() { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); CommonAnnotationBeanPostProcessor bpp = new CommonAnnotationBeanPostProcessor(); bpp.setBeanFactory(bf); @@ -526,7 +526,7 @@ public class CommonAnnotationBeanPostProcessorTests { } @Test - public void testLazyResolutionWithCglibProxy() { + void testLazyResolutionWithCglibProxy() { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); CommonAnnotationBeanPostProcessor bpp = new CommonAnnotationBeanPostProcessor(); bpp.setBeanFactory(bf); @@ -544,7 +544,7 @@ public class CommonAnnotationBeanPostProcessorTests { } @Test - public void testLazyResolutionWithFallbackTypeMatch() { + void testLazyResolutionWithFallbackTypeMatch() { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); bf.setAutowireCandidateResolver(new ContextAnnotationAutowireCandidateResolver()); CommonAnnotationBeanPostProcessor bpp = new CommonAnnotationBeanPostProcessor(); diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanParserBeanDefinitionDefaultsTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanParserBeanDefinitionDefaultsTests.java index cbd1b5ca4f5..84deb54af23 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanParserBeanDefinitionDefaultsTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanParserBeanDefinitionDefaultsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,7 +30,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; * @author Mark Fisher * @author Chris Beams */ -public class ComponentScanParserBeanDefinitionDefaultsTests { +class ComponentScanParserBeanDefinitionDefaultsTests { private static final String TEST_BEAN_NAME = "componentScanParserBeanDefinitionDefaultsTests.DefaultsTestBean"; @@ -38,12 +38,12 @@ public class ComponentScanParserBeanDefinitionDefaultsTests { @BeforeEach - public void setUp() { + void setUp() { DefaultsTestBean.INIT_COUNT = 0; } @Test - public void testDefaultLazyInit() { + void testDefaultLazyInit() { GenericApplicationContext context = new GenericApplicationContext(); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context); reader.loadBeanDefinitions(LOCATION_PREFIX + "defaultWithNoOverridesTests.xml"); @@ -54,7 +54,7 @@ public class ComponentScanParserBeanDefinitionDefaultsTests { } @Test - public void testLazyInitTrue() { + void testLazyInitTrue() { GenericApplicationContext context = new GenericApplicationContext(); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context); reader.loadBeanDefinitions(LOCATION_PREFIX + "defaultLazyInitTrueTests.xml"); @@ -67,7 +67,7 @@ public class ComponentScanParserBeanDefinitionDefaultsTests { } @Test - public void testLazyInitFalse() { + void testLazyInitFalse() { GenericApplicationContext context = new GenericApplicationContext(); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context); reader.loadBeanDefinitions(LOCATION_PREFIX + "defaultLazyInitFalseTests.xml"); @@ -78,7 +78,7 @@ public class ComponentScanParserBeanDefinitionDefaultsTests { } @Test - public void testDefaultAutowire() { + void testDefaultAutowire() { GenericApplicationContext context = new GenericApplicationContext(); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context); reader.loadBeanDefinitions(LOCATION_PREFIX + "defaultWithNoOverridesTests.xml"); @@ -90,7 +90,7 @@ public class ComponentScanParserBeanDefinitionDefaultsTests { } @Test - public void testAutowireNo() { + void testAutowireNo() { GenericApplicationContext context = new GenericApplicationContext(); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context); reader.loadBeanDefinitions(LOCATION_PREFIX + "defaultAutowireNoTests.xml"); @@ -102,7 +102,7 @@ public class ComponentScanParserBeanDefinitionDefaultsTests { } @Test - public void testAutowireConstructor() { + void testAutowireConstructor() { GenericApplicationContext context = new GenericApplicationContext(); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context); reader.loadBeanDefinitions(LOCATION_PREFIX + "defaultAutowireConstructorTests.xml"); @@ -115,7 +115,7 @@ public class ComponentScanParserBeanDefinitionDefaultsTests { } @Test - public void testAutowireByType() { + void testAutowireByType() { GenericApplicationContext context = new GenericApplicationContext(); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context); reader.loadBeanDefinitions(LOCATION_PREFIX + "defaultAutowireByTypeTests.xml"); @@ -124,7 +124,7 @@ public class ComponentScanParserBeanDefinitionDefaultsTests { } @Test - public void testAutowireByName() { + void testAutowireByName() { GenericApplicationContext context = new GenericApplicationContext(); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context); reader.loadBeanDefinitions(LOCATION_PREFIX + "defaultAutowireByNameTests.xml"); @@ -137,7 +137,7 @@ public class ComponentScanParserBeanDefinitionDefaultsTests { } @Test - public void testDefaultDependencyCheck() { + void testDefaultDependencyCheck() { GenericApplicationContext context = new GenericApplicationContext(); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context); reader.loadBeanDefinitions(LOCATION_PREFIX + "defaultWithNoOverridesTests.xml"); @@ -149,7 +149,7 @@ public class ComponentScanParserBeanDefinitionDefaultsTests { } @Test - public void testDefaultInitAndDestroyMethodsNotDefined() { + void testDefaultInitAndDestroyMethodsNotDefined() { GenericApplicationContext context = new GenericApplicationContext(); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context); reader.loadBeanDefinitions(LOCATION_PREFIX + "defaultWithNoOverridesTests.xml"); @@ -161,7 +161,7 @@ public class ComponentScanParserBeanDefinitionDefaultsTests { } @Test - public void testDefaultInitAndDestroyMethodsDefined() { + void testDefaultInitAndDestroyMethodsDefined() { GenericApplicationContext context = new GenericApplicationContext(); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context); reader.loadBeanDefinitions(LOCATION_PREFIX + "defaultInitAndDestroyMethodsTests.xml"); @@ -173,7 +173,7 @@ public class ComponentScanParserBeanDefinitionDefaultsTests { } @Test - public void testDefaultNonExistingInitAndDestroyMethodsDefined() { + void testDefaultNonExistingInitAndDestroyMethodsDefined() { GenericApplicationContext context = new GenericApplicationContext(); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(context); reader.loadBeanDefinitions(LOCATION_PREFIX + "defaultNonExistingInitAndDestroyMethodsTests.xml"); diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanParserScopedProxyTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanParserScopedProxyTests.java index e498e947035..39603286200 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanParserScopedProxyTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanParserScopedProxyTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,10 +34,10 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; * @author Juergen Hoeller * @author Sam Brannen */ -public class ComponentScanParserScopedProxyTests { +class ComponentScanParserScopedProxyTests { @Test - public void testDefaultScopedProxy() { + void testDefaultScopedProxy() { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "org/springframework/context/annotation/scopedProxyDefaultTests.xml"); context.getBeanFactory().registerScope("myScope", new SimpleMapScope()); @@ -49,7 +49,7 @@ public class ComponentScanParserScopedProxyTests { } @Test - public void testNoScopedProxy() { + void testNoScopedProxy() { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "org/springframework/context/annotation/scopedProxyNoTests.xml"); context.getBeanFactory().registerScope("myScope", new SimpleMapScope()); @@ -61,7 +61,7 @@ public class ComponentScanParserScopedProxyTests { } @Test - public void testInterfacesScopedProxy() throws Exception { + void testInterfacesScopedProxy() throws Exception { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "org/springframework/context/annotation/scopedProxyInterfacesTests.xml"); context.getBeanFactory().registerScope("myScope", new SimpleMapScope()); @@ -79,7 +79,7 @@ public class ComponentScanParserScopedProxyTests { } @Test - public void testTargetClassScopedProxy() throws Exception { + void testTargetClassScopedProxy() throws Exception { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "org/springframework/context/annotation/scopedProxyTargetClassTests.xml"); context.getBeanFactory().registerScope("myScope", new SimpleMapScope()); @@ -97,7 +97,7 @@ public class ComponentScanParserScopedProxyTests { @Test @SuppressWarnings("resource") - public void testInvalidConfigScopedProxy() throws Exception { + public void testInvalidConfigScopedProxy() { assertThatExceptionOfType(BeanDefinitionParsingException.class).isThrownBy(() -> new ClassPathXmlApplicationContext("org/springframework/context/annotation/scopedProxyInvalidConfigTests.xml")) .withMessageContaining("Cannot define both 'scope-resolver' and 'scoped-proxy' on tag") diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanParserTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanParserTests.java index 9bacf084663..22e9fd690b5 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanParserTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,7 +41,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Chris Beams * @author Sam Brannen */ -public class ComponentScanParserTests { +class ComponentScanParserTests { private ClassPathXmlApplicationContext loadContext(String path) { return new ClassPathXmlApplicationContext(path, getClass()); @@ -49,7 +49,7 @@ public class ComponentScanParserTests { @Test - public void aspectjTypeFilter() { + void aspectjTypeFilter() { ClassPathXmlApplicationContext context = loadContext("aspectjTypeFilterTests.xml"); assertThat(context.containsBean("fooServiceImpl")).isTrue(); assertThat(context.containsBean("stubFooDao")).isTrue(); @@ -58,7 +58,7 @@ public class ComponentScanParserTests { } @Test - public void aspectjTypeFilterWithPlaceholders() { + void aspectjTypeFilterWithPlaceholders() { System.setProperty("basePackage", "example.scannable, test"); System.setProperty("scanInclude", "example.scannable.FooService+"); System.setProperty("scanExclude", "example..Scoped*Test*"); @@ -77,21 +77,21 @@ public class ComponentScanParserTests { } @Test - public void nonMatchingResourcePattern() { + void nonMatchingResourcePattern() { ClassPathXmlApplicationContext context = loadContext("nonMatchingResourcePatternTests.xml"); assertThat(context.containsBean("fooServiceImpl")).isFalse(); context.close(); } @Test - public void matchingResourcePattern() { + void matchingResourcePattern() { ClassPathXmlApplicationContext context = loadContext("matchingResourcePatternTests.xml"); assertThat(context.containsBean("fooServiceImpl")).isTrue(); context.close(); } @Test - public void componentScanWithAutowiredQualifier() { + void componentScanWithAutowiredQualifier() { ClassPathXmlApplicationContext context = loadContext("componentScanWithAutowiredQualifierTests.xml"); AutowiredQualifierFooService fooService = (AutowiredQualifierFooService) context.getBean("fooService"); assertThat(fooService.isInitCalled()).isTrue(); @@ -100,7 +100,7 @@ public class ComponentScanParserTests { } @Test - public void customAnnotationUsedForBothComponentScanAndQualifier() { + void customAnnotationUsedForBothComponentScanAndQualifier() { ClassPathXmlApplicationContext context = loadContext("customAnnotationUsedForBothComponentScanAndQualifierTests.xml"); KustomAnnotationAutowiredBean testBean = (KustomAnnotationAutowiredBean) context.getBean("testBean"); assertThat(testBean.getDependency()).isNotNull(); @@ -108,7 +108,7 @@ public class ComponentScanParserTests { } @Test - public void customTypeFilter() { + void customTypeFilter() { ClassPathXmlApplicationContext context = loadContext("customTypeFilterTests.xml"); KustomAnnotationAutowiredBean testBean = (KustomAnnotationAutowiredBean) context.getBean("testBean"); assertThat(testBean.getDependency()).isNotNull(); @@ -116,7 +116,7 @@ public class ComponentScanParserTests { } @Test - public void componentScanRespectsProfileAnnotation() { + void componentScanRespectsProfileAnnotation() { String xmlLocation = "org/springframework/context/annotation/componentScanRespectsProfileAnnotationTests.xml"; { // should exclude the profile-annotated bean if active profiles remains unset GenericXmlApplicationContext context = new GenericXmlApplicationContext(); diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostConstructAndAutowiringTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostConstructAndAutowiringTests.java index 0f6c5b0640f..8c91db3cd5f 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostConstructAndAutowiringTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostConstructAndAutowiringTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,14 +39,14 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Chris Beams * @since 3.1 */ -public class ConfigurationClassPostConstructAndAutowiringTests { +class ConfigurationClassPostConstructAndAutowiringTests { /** * Prior to the fix for SPR-8080, this method would succeed due to ordering of * configuration class registration. */ @Test - public void control() { + void control() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(Config1.class, Config2.class); ctx.refresh(); @@ -62,7 +62,7 @@ public class ConfigurationClassPostConstructAndAutowiringTests { * configuration class registration. */ @Test - public void originalReproCase() { + void originalReproCase() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(Config2.class, Config1.class); ctx.refresh(); diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostProcessorAotContributionTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostProcessorAotContributionTests.java index 2a0a2c3112d..92c82717ac1 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostProcessorAotContributionTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostProcessorAotContributionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -238,7 +238,7 @@ class ConfigurationClassPostProcessorAotContributionTests { } @Override - public void afterPropertiesSet() throws Exception { + public void afterPropertiesSet() { Assert.notNull(this.metadata, "Metadata was not injected"); } diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostProcessorTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostProcessorTests.java index 54bb585e75a..94e51ef2ebe 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostProcessorTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostProcessorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -1155,11 +1155,13 @@ class ConfigurationClassPostProcessorTests { @Configuration static class StaticSingletonBeanConfig { - public static @Bean Foo foo() { + @Bean + public static Foo foo() { return new Foo(); } - public static @Bean Bar bar() { + @Bean + public static Bar bar() { return new Bar(foo()); } } @@ -1598,7 +1600,7 @@ class ConfigurationClassPostProcessorTests { public static class WildcardWithGenericExtendsConfiguration { @Bean - public Repository genericRepo() { + public Repository genericRepo() { return new Repository(); } diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassWithConditionTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassWithConditionTests.java index e4e6f1bd913..ee89a8fa433 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassWithConditionTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassWithConditionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,7 +43,7 @@ import static org.assertj.core.api.Assertions.assertThat; public class ConfigurationClassWithConditionTests { @Test - public void conditionalOnMissingBeanMatch() throws Exception { + void conditionalOnMissingBeanMatch() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(BeanOneConfiguration.class, BeanTwoConfiguration.class); ctx.refresh(); @@ -53,7 +53,7 @@ public class ConfigurationClassWithConditionTests { } @Test - public void conditionalOnMissingBeanNoMatch() throws Exception { + void conditionalOnMissingBeanNoMatch() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(BeanTwoConfiguration.class); ctx.refresh(); @@ -63,7 +63,7 @@ public class ConfigurationClassWithConditionTests { } @Test - public void conditionalOnBeanMatch() throws Exception { + void conditionalOnBeanMatch() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(BeanOneConfiguration.class, BeanThreeConfiguration.class); ctx.refresh(); @@ -72,7 +72,7 @@ public class ConfigurationClassWithConditionTests { } @Test - public void conditionalOnBeanNoMatch() throws Exception { + void conditionalOnBeanNoMatch() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(BeanThreeConfiguration.class); ctx.refresh(); @@ -81,7 +81,7 @@ public class ConfigurationClassWithConditionTests { } @Test - public void metaConditional() throws Exception { + void metaConditional() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(ConfigurationWithMetaCondition.class); ctx.refresh(); @@ -89,7 +89,7 @@ public class ConfigurationClassWithConditionTests { } @Test - public void metaConditionalWithAsm() throws Exception { + void metaConditionalWithAsm() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.registerBeanDefinition("config", new RootBeanDefinition(ConfigurationWithMetaCondition.class.getName())); ctx.refresh(); @@ -97,7 +97,7 @@ public class ConfigurationClassWithConditionTests { } @Test - public void nonConfigurationClass() throws Exception { + void nonConfigurationClass() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(NonConfigurationClass.class); ctx.refresh(); @@ -105,7 +105,7 @@ public class ConfigurationClassWithConditionTests { } @Test - public void nonConfigurationClassWithAsm() throws Exception { + void nonConfigurationClassWithAsm() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.registerBeanDefinition("config", new RootBeanDefinition(NonConfigurationClass.class.getName())); ctx.refresh(); @@ -113,7 +113,7 @@ public class ConfigurationClassWithConditionTests { } @Test - public void methodConditional() throws Exception { + void methodConditional() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(ConditionOnMethodConfiguration.class); ctx.refresh(); @@ -121,7 +121,7 @@ public class ConfigurationClassWithConditionTests { } @Test - public void methodConditionalWithAsm() throws Exception { + void methodConditionalWithAsm() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.registerBeanDefinition("config", new RootBeanDefinition(ConditionOnMethodConfiguration.class.getName())); ctx.refresh(); @@ -129,27 +129,27 @@ public class ConfigurationClassWithConditionTests { } @Test - public void importsNotCreated() throws Exception { + void importsNotCreated() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(ImportsNotCreated.class); ctx.refresh(); } @Test - public void conditionOnOverriddenMethodHonored() { + void conditionOnOverriddenMethodHonored() { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ConfigWithBeanSkipped.class); assertThat(context.getBeansOfType(ExampleBean.class)).isEmpty(); } @Test - public void noConditionOnOverriddenMethodHonored() { + void noConditionOnOverriddenMethodHonored() { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ConfigWithBeanReactivated.class); Map beans = context.getBeansOfType(ExampleBean.class); assertThat(beans).containsOnlyKeys("baz"); } @Test - public void configWithAlternativeBeans() { + void configWithAlternativeBeans() { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ConfigWithAlternativeBeans.class); Map beans = context.getBeansOfType(ExampleBean.class); assertThat(beans).containsOnlyKeys("baz"); diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationWithFactoryBeanAndAutowiringTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationWithFactoryBeanAndAutowiringTests.java index 0cbdbe839a1..5176eed7fba 100755 --- a/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationWithFactoryBeanAndAutowiringTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationWithFactoryBeanAndAutowiringTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -108,12 +108,12 @@ class ConfigurationWithFactoryBeanAndAutowiringTests { private boolean initialized = false; @Override - public void afterPropertiesSet() throws Exception { + public void afterPropertiesSet() { this.initialized = true; } @Override - public String getObject() throws Exception { + public String getObject() { return "foo"; } @@ -142,7 +142,7 @@ class ConfigurationWithFactoryBeanAndAutowiringTests { } @Override - public T getObject() throws Exception { + public T getObject() { return obj; } diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationWithFactoryBeanBeanEarlyDeductionTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationWithFactoryBeanBeanEarlyDeductionTests.java index 74688cd5d81..1c5a4bb146f 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationWithFactoryBeanBeanEarlyDeductionTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationWithFactoryBeanBeanEarlyDeductionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,50 +40,50 @@ import static org.assertj.core.api.Assertions.assertThat; * * @author Phillip Webb */ -public class ConfigurationWithFactoryBeanBeanEarlyDeductionTests { +class ConfigurationWithFactoryBeanBeanEarlyDeductionTests { @Test - public void preFreezeDirect() { + void preFreezeDirect() { assertPreFreeze(DirectConfiguration.class); } @Test - public void postFreezeDirect() { + void postFreezeDirect() { assertPostFreeze(DirectConfiguration.class); } @Test - public void preFreezeGenericMethod() { + void preFreezeGenericMethod() { assertPreFreeze(GenericMethodConfiguration.class); } @Test - public void postFreezeGenericMethod() { + void postFreezeGenericMethod() { assertPostFreeze(GenericMethodConfiguration.class); } @Test - public void preFreezeGenericClass() { + void preFreezeGenericClass() { assertPreFreeze(GenericClassConfiguration.class); } @Test - public void postFreezeGenericClass() { + void postFreezeGenericClass() { assertPostFreeze(GenericClassConfiguration.class); } @Test - public void preFreezeAttribute() { + void preFreezeAttribute() { assertPreFreeze(AttributeClassConfiguration.class); } @Test - public void postFreezeAttribute() { + void postFreezeAttribute() { assertPostFreeze(AttributeClassConfiguration.class); } @Test - public void preFreezeUnresolvedGenericFactoryBean() { + void preFreezeUnresolvedGenericFactoryBean() { // Covers the case where a @Configuration is picked up via component scanning // and its bean definition only has a String bean class. In such cases // beanDefinition.hasBeanClass() returns false so we need to actually @@ -212,7 +212,7 @@ public class ConfigurationWithFactoryBeanBeanEarlyDeductionTests { } @Override - public T getObject() throws Exception { + public T getObject() { return this.instance; } @@ -236,7 +236,7 @@ public class ConfigurationWithFactoryBeanBeanEarlyDeductionTests { private final Object object = new MyBean(); @Override - public Object getObject() throws Exception { + public Object getObject() { return object; } diff --git a/spring-context/src/test/java/org/springframework/context/annotation/DeferredImportSelectorTests.java b/spring-context/src/test/java/org/springframework/context/annotation/DeferredImportSelectorTests.java index e5735e72f91..9efc276b496 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/DeferredImportSelectorTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/DeferredImportSelectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,28 +29,28 @@ import static org.mockito.Mockito.mock; * * @author Stephane Nicoll */ -public class DeferredImportSelectorTests { +class DeferredImportSelectorTests { @Test - public void entryEqualsSameInstance() { + void entryEqualsSameInstance() { AnnotationMetadata metadata = mock(); Group.Entry entry = new Group.Entry(metadata, "com.example.Test"); assertThat(entry).isEqualTo(entry); } @Test - public void entryEqualsSameMetadataAndClassName() { + void entryEqualsSameMetadataAndClassName() { AnnotationMetadata metadata = mock(); assertThat(new Group.Entry(metadata, "com.example.Test")).isEqualTo(new Group.Entry(metadata, "com.example.Test")); } @Test - public void entryEqualDifferentMetadataAndSameClassName() { + void entryEqualDifferentMetadataAndSameClassName() { assertThat(new Group.Entry(mock(), "com.example.Test")).isNotEqualTo(new Group.Entry(mock(), "com.example.Test")); } @Test - public void entryEqualSameMetadataAnDifferentClassName() { + void entryEqualSameMetadataAnDifferentClassName() { AnnotationMetadata metadata = mock(); assertThat(new Group.Entry(metadata, "com.example.AnotherTest")).isNotEqualTo(new Group.Entry(metadata, "com.example.Test")); } diff --git a/spring-context/src/test/java/org/springframework/context/annotation/DestroyMethodInferenceTests.java b/spring-context/src/test/java/org/springframework/context/annotation/DestroyMethodInferenceTests.java index 3fa5b05c6bf..57e19faf923 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/DestroyMethodInferenceTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/DestroyMethodInferenceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,10 +33,10 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Juergen Hoeller * @author Stephane Nicoll */ -public class DestroyMethodInferenceTests { +class DestroyMethodInferenceTests { @Test - public void beanMethods() { + void beanMethods() { ConfigurableApplicationContext ctx = new AnnotationConfigApplicationContext(Config.class); WithExplicitDestroyMethod c0 = ctx.getBean(WithExplicitDestroyMethod.class); WithLocalCloseMethod c1 = ctx.getBean("c1", WithLocalCloseMethod.class); @@ -83,7 +83,7 @@ public class DestroyMethodInferenceTests { } @Test - public void xml() { + void xml() { ConfigurableApplicationContext ctx = new GenericXmlApplicationContext( getClass(), "DestroyMethodInferenceTests-context.xml"); WithLocalCloseMethod x1 = ctx.getBean("x1", WithLocalCloseMethod.class); diff --git a/spring-context/src/test/java/org/springframework/context/annotation/DoubleScanTests.java b/spring-context/src/test/java/org/springframework/context/annotation/DoubleScanTests.java index 50b51ae7e7a..c540d08116c 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/DoubleScanTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/DoubleScanTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ package org.springframework.context.annotation; * @author Juergen Hoeller * @author Chris Beams */ -public class DoubleScanTests extends SimpleScanTests { +class DoubleScanTests extends SimpleScanTests { @Override protected String[] getConfigLocations() { diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ImportSelectorTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ImportSelectorTests.java index dcfcec7ded0..3f2e21a19e7 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ImportSelectorTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ImportSelectorTests.java @@ -70,7 +70,7 @@ public class ImportSelectorTests { @BeforeEach - public void cleanup() { + void cleanup() { ImportSelectorTests.importFrom.clear(); SampleImportSelector.cleanup(); TestImportGroup.cleanup(); @@ -78,7 +78,7 @@ public class ImportSelectorTests { @Test - public void importSelectors() { + void importSelectors() { DefaultListableBeanFactory beanFactory = spy(new DefaultListableBeanFactory()); AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(beanFactory); context.register(Config.class); @@ -92,7 +92,7 @@ public class ImportSelectorTests { } @Test - public void invokeAwareMethodsInImportSelector() { + void invokeAwareMethodsInImportSelector() { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(AwareConfig.class); assertThat(SampleImportSelector.beanFactory).isEqualTo(context.getBeanFactory()); assertThat(SampleImportSelector.classLoader).isEqualTo(context.getBeanFactory().getBeanClassLoader()); @@ -101,7 +101,7 @@ public class ImportSelectorTests { } @Test - public void correctMetadataOnIndirectImports() { + void correctMetadataOnIndirectImports() { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(IndirectConfig.class); String indirectImport = IndirectImport.class.getName(); assertThat(importFrom.get(ImportSelector1.class)).isEqualTo(indirectImport); @@ -115,7 +115,7 @@ public class ImportSelectorTests { } @Test - public void importSelectorsWithGroup() { + void importSelectorsWithGroup() { DefaultListableBeanFactory beanFactory = spy(new DefaultListableBeanFactory()); AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(beanFactory); context.register(GroupedConfig.class); @@ -131,7 +131,7 @@ public class ImportSelectorTests { } @Test - public void importSelectorsSeparateWithGroup() { + void importSelectorsSeparateWithGroup() { DefaultListableBeanFactory beanFactory = spy(new DefaultListableBeanFactory()); AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(beanFactory); context.register(GroupedConfig1.class); @@ -146,7 +146,7 @@ public class ImportSelectorTests { } @Test - public void importSelectorsWithNestedGroup() { + void importSelectorsWithNestedGroup() { DefaultListableBeanFactory beanFactory = spy(new DefaultListableBeanFactory()); AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(beanFactory); context.register(ParentConfiguration1.class); @@ -166,7 +166,7 @@ public class ImportSelectorTests { } @Test - public void importSelectorsWithNestedGroupSameDeferredImport() { + void importSelectorsWithNestedGroupSameDeferredImport() { DefaultListableBeanFactory beanFactory = spy(new DefaultListableBeanFactory()); AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(beanFactory); context.register(ParentConfiguration2.class); @@ -185,7 +185,7 @@ public class ImportSelectorTests { } @Test - public void invokeAwareMethodsInImportGroup() { + void invokeAwareMethodsInImportGroup() { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(GroupedConfig1.class); assertThat(TestImportGroup.beanFactory).isEqualTo(context.getBeanFactory()); assertThat(TestImportGroup.classLoader).isEqualTo(context.getBeanFactory().getBeanClassLoader()); diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ImportVersusDirectRegistrationTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ImportVersusDirectRegistrationTests.java index db22532e1bd..9325ec7412c 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ImportVersusDirectRegistrationTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ImportVersusDirectRegistrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,10 +26,10 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; /** * @author Andy Wilkinson */ -public class ImportVersusDirectRegistrationTests { +class ImportVersusDirectRegistrationTests { @Test - public void thingIsNotAvailableWhenOuterConfigurationIsRegisteredDirectly() { + void thingIsNotAvailableWhenOuterConfigurationIsRegisteredDirectly() { try (AnnotationConfigApplicationContext directRegistration = new AnnotationConfigApplicationContext()) { directRegistration.register(AccidentalLiteConfiguration.class); directRegistration.refresh(); @@ -39,7 +39,7 @@ public class ImportVersusDirectRegistrationTests { } @Test - public void thingIsNotAvailableWhenOuterConfigurationIsRegisteredWithClassName() { + void thingIsNotAvailableWhenOuterConfigurationIsRegisteredWithClassName() { try (AnnotationConfigApplicationContext directRegistration = new AnnotationConfigApplicationContext()) { directRegistration.registerBeanDefinition("config", new RootBeanDefinition(AccidentalLiteConfiguration.class.getName())); @@ -50,7 +50,7 @@ public class ImportVersusDirectRegistrationTests { } @Test - public void thingIsNotAvailableWhenOuterConfigurationIsImported() { + void thingIsNotAvailableWhenOuterConfigurationIsImported() { try (AnnotationConfigApplicationContext viaImport = new AnnotationConfigApplicationContext()) { viaImport.register(Importer.class); viaImport.refresh(); diff --git a/spring-context/src/test/java/org/springframework/context/annotation/InvalidConfigurationClassDefinitionTests.java b/spring-context/src/test/java/org/springframework/context/annotation/InvalidConfigurationClassDefinitionTests.java index 2885637b060..bd2bb4a4102 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/InvalidConfigurationClassDefinitionTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/InvalidConfigurationClassDefinitionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,10 +32,10 @@ import static org.springframework.beans.factory.support.BeanDefinitionBuilder.ro * * @author Chris Beams */ -public class InvalidConfigurationClassDefinitionTests { +class InvalidConfigurationClassDefinitionTests { @Test - public void configurationClassesMayNotBeFinal() { + void configurationClassesMayNotBeFinal() { @Configuration final class Config { } diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ParserStrategyUtilsTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ParserStrategyUtilsTests.java index 7acc0c7d201..2a191022084 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ParserStrategyUtilsTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ParserStrategyUtilsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,7 +45,7 @@ import static org.mockito.Mockito.reset; * * @author Phillip Webb */ -public class ParserStrategyUtilsTests { +class ParserStrategyUtilsTests { @Mock private Environment environment; @@ -66,7 +66,7 @@ public class ParserStrategyUtilsTests { } @Test - public void instantiateClassWhenHasNoArgsConstructorCallsAware() { + void instantiateClassWhenHasNoArgsConstructorCallsAware() { NoArgsConstructor instance = instantiateClass(NoArgsConstructor.class); assertThat(instance.setEnvironment).isSameAs(this.environment); assertThat(instance.setBeanFactory).isSameAs(this.registry); @@ -75,7 +75,7 @@ public class ParserStrategyUtilsTests { } @Test - public void instantiateClassWhenHasSingleConstructorInjectsParams() { + void instantiateClassWhenHasSingleConstructorInjectsParams() { ArgsConstructor instance = instantiateClass(ArgsConstructor.class); assertThat(instance.environment).isSameAs(this.environment); assertThat(instance.beanFactory).isSameAs(this.registry); @@ -84,7 +84,7 @@ public class ParserStrategyUtilsTests { } @Test - public void instantiateClassWhenHasSingleConstructorAndAwareInjectsParamsAndCallsAware() { + void instantiateClassWhenHasSingleConstructorAndAwareInjectsParamsAndCallsAware() { ArgsConstructorAndAware instance = instantiateClass(ArgsConstructorAndAware.class); assertThat(instance.environment).isSameAs(this.environment); assertThat(instance.setEnvironment).isSameAs(this.environment); @@ -97,20 +97,20 @@ public class ParserStrategyUtilsTests { } @Test - public void instantiateClassWhenHasMultipleConstructorsUsesNoArgsConstructor() { + void instantiateClassWhenHasMultipleConstructorsUsesNoArgsConstructor() { // Remain back-compatible by using the default constructor if there's more than one MultipleConstructors instance = instantiateClass(MultipleConstructors.class); assertThat(instance.usedDefaultConstructor).isTrue(); } @Test - public void instantiateClassWhenHasMultipleConstructorsAndNotDefaultThrowsException() { + void instantiateClassWhenHasMultipleConstructorsAndNotDefaultThrowsException() { assertThatExceptionOfType(BeanInstantiationException.class).isThrownBy(() -> instantiateClass(MultipleConstructorsWithNoDefault.class)); } @Test - public void instantiateClassWhenHasUnsupportedParameterThrowsException() { + void instantiateClassWhenHasUnsupportedParameterThrowsException() { assertThatExceptionOfType(BeanInstantiationException.class).isThrownBy(() -> instantiateClass(InvalidConstructorParameterType.class)) .withCauseInstanceOf(IllegalStateException.class) @@ -118,7 +118,7 @@ public class ParserStrategyUtilsTests { } @Test - public void instantiateClassHasSubclassParameterThrowsException() { + void instantiateClassHasSubclassParameterThrowsException() { // To keep the algorithm simple we don't support subtypes assertThatExceptionOfType(BeanInstantiationException.class).isThrownBy(() -> instantiateClass(InvalidConstructorParameterSubType.class)) @@ -127,14 +127,14 @@ public class ParserStrategyUtilsTests { } @Test - public void instantiateClassWhenHasNoBeanClassLoaderInjectsNull() { + void instantiateClassWhenHasNoBeanClassLoaderInjectsNull() { reset(this.resourceLoader); ArgsConstructor instance = instantiateClass(ArgsConstructor.class); assertThat(instance.beanClassLoader).isNull(); } @Test - public void instantiateClassWhenHasNoBeanClassLoaderDoesNotCallAware() { + void instantiateClassWhenHasNoBeanClassLoaderDoesNotCallAware() { reset(this.resourceLoader); NoArgsConstructor instance = instantiateClass(NoArgsConstructor.class); assertThat(instance.setBeanClassLoader).isNull(); diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ReflectionUtilsIntegrationTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ReflectionUtilsIntegrationTests.java index 0e94c25d361..6a31d3bbc22 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ReflectionUtilsIntegrationTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ReflectionUtilsIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,10 +32,10 @@ import static org.assertj.core.api.Assertions.assertThat; * @since 3.1 * @see org.springframework.util.ReflectionUtilsTests */ -public class ReflectionUtilsIntegrationTests { +class ReflectionUtilsIntegrationTests { @Test - public void getUniqueDeclaredMethods_withCovariantReturnType_andCglibRewrittenMethodNames() throws Exception { + void getUniqueDeclaredMethods_withCovariantReturnType_andCglibRewrittenMethodNames() { Class cglibLeaf = new ConfigurationClassEnhancer().enhance(Leaf.class, null); int m1MethodCount = 0; Method[] methods = ReflectionUtils.getUniqueDeclaredMethods(cglibLeaf); diff --git a/spring-context/src/test/java/org/springframework/context/annotation/SimpleConfigTests.java b/spring-context/src/test/java/org/springframework/context/annotation/SimpleConfigTests.java index 9d7be1a225a..8331d931c7d 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/SimpleConfigTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/SimpleConfigTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,10 +31,10 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Mark Fisher * @author Juergen Hoeller */ -public class SimpleConfigTests { +class SimpleConfigTests { @Test - public void testFooService() throws Exception { + void testFooService() throws Exception { ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(getConfigLocations(), getClass()); FooService fooService = ctx.getBean("fooServiceImpl", FooService.class); diff --git a/spring-context/src/test/java/org/springframework/context/annotation/SimpleScanTests.java b/spring-context/src/test/java/org/springframework/context/annotation/SimpleScanTests.java index ee4f47429c9..846a5e5e7f8 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/SimpleScanTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/SimpleScanTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,14 +29,14 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Juergen Hoeller * @author Chris Beams */ -public class SimpleScanTests { +class SimpleScanTests { protected String[] getConfigLocations() { return new String[] {"simpleScanTests.xml"}; } @Test - public void testFooService() throws Exception { + void testFooService() { ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(getConfigLocations(), getClass()); FooService fooService = (FooService) ctx.getBean("fooServiceImpl"); diff --git a/spring-context/src/test/java/org/springframework/context/annotation/Spr11202Tests.java b/spring-context/src/test/java/org/springframework/context/annotation/Spr11202Tests.java index a6002b4ffdc..48cf378bf7a 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/Spr11202Tests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/Spr11202Tests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -77,7 +77,7 @@ class Spr11202Tests { } @Bean - public String value() throws Exception { + public String value() { String name = foo().getObject().getName(); Assert.state(name != null, "Name cannot be null"); return name; @@ -85,7 +85,7 @@ class Spr11202Tests { @Bean @Conditional(NoBarCondition.class) - public String bar() throws Exception { + public String bar() { return "bar"; } } @@ -115,7 +115,7 @@ class Spr11202Tests { private Foo foo = new Foo(); @Override - public Foo getObject() throws Exception { + public Foo getObject() { return foo; } @@ -130,7 +130,7 @@ class Spr11202Tests { } @Override - public void afterPropertiesSet() throws Exception { + public void afterPropertiesSet() { this.foo.name = "foo"; } } diff --git a/spring-context/src/test/java/org/springframework/context/annotation/Spr12278Tests.java b/spring-context/src/test/java/org/springframework/context/annotation/Spr12278Tests.java index c56c347b8cc..f74a5fc0246 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/Spr12278Tests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/Spr12278Tests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,33 +27,33 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; /** * @author Stephane Nicoll */ -public class Spr12278Tests { +class Spr12278Tests { private AnnotationConfigApplicationContext context; @AfterEach - public void close() { + void close() { if (context != null) { context.close(); } } @Test - public void componentSingleConstructor() { + void componentSingleConstructor() { this.context = new AnnotationConfigApplicationContext(BaseConfiguration.class, SingleConstructorComponent.class); assertThat(this.context.getBean(SingleConstructorComponent.class).autowiredName).isEqualTo("foo"); } @Test - public void componentTwoConstructorsNoHint() { + void componentTwoConstructorsNoHint() { this.context = new AnnotationConfigApplicationContext(BaseConfiguration.class, TwoConstructorsComponent.class); assertThat(this.context.getBean(TwoConstructorsComponent.class).name).isEqualTo("fallback"); } @Test - public void componentTwoSpecificConstructorsNoHint() { + void componentTwoSpecificConstructorsNoHint() { assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() -> new AnnotationConfigApplicationContext(BaseConfiguration.class, TwoSpecificConstructorsComponent.class)) .withMessageContaining("No default constructor found"); diff --git a/spring-context/src/test/java/org/springframework/context/annotation/Spr12636Tests.java b/spring-context/src/test/java/org/springframework/context/annotation/Spr12636Tests.java index f11e9af5556..19d2ae6e3e3 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/Spr12636Tests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/Spr12636Tests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,29 +34,30 @@ import static org.assertj.core.api.Assertions.assertThat; /** * @author Stephane Nicoll */ -public class Spr12636Tests { +class Spr12636Tests { private ConfigurableApplicationContext context; @AfterEach - public void closeContext() { + void closeContext() { if (this.context != null) { this.context.close(); } } @Test - public void orderOnImplementation() { + void orderOnImplementation() { this.context = new AnnotationConfigApplicationContext( UserServiceTwo.class, UserServiceOne.class, UserServiceCollector.class); UserServiceCollector bean = this.context.getBean(UserServiceCollector.class); - assertThat(bean.userServices).element(0).isSameAs(context.getBean("serviceOne", UserService.class)); - assertThat(bean.userServices).element(1).isSameAs(context.getBean("serviceTwo", UserService.class)); + assertThat(bean.userServices).containsExactly( + context.getBean("serviceOne", UserService.class), + context.getBean("serviceTwo", UserService.class)); } @Test - public void orderOnImplementationWithProxy() { + void orderOnImplementationWithProxy() { this.context = new AnnotationConfigApplicationContext( UserServiceTwo.class, UserServiceOne.class, UserServiceCollector.class, AsyncConfig.class); @@ -67,8 +68,7 @@ public class Spr12636Tests { assertThat(AopUtils.isAopProxy(serviceTwo)).isTrue(); UserServiceCollector bean = this.context.getBean(UserServiceCollector.class); - assertThat(bean.userServices).element(0).isSameAs(serviceOne); - assertThat(bean.userServices).element(1).isSameAs(serviceTwo); + assertThat(bean.userServices).containsExactly(serviceOne, serviceTwo); } @Configuration diff --git a/spring-context/src/test/java/org/springframework/context/annotation/Spr15275Tests.java b/spring-context/src/test/java/org/springframework/context/annotation/Spr15275Tests.java index b93d226e61a..b7041709b14 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/Spr15275Tests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/Spr15275Tests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -204,7 +204,7 @@ class Spr15275Tests { } @Bean - public Bar bar() throws Exception { + public Bar bar() { assertThat(foo().isSingleton()).isTrue(); return new Bar(foo().getObject()); } diff --git a/spring-context/src/test/java/org/springframework/context/annotation/Spr16217Tests.java b/spring-context/src/test/java/org/springframework/context/annotation/Spr16217Tests.java index 056f8faa8ee..06e2c87eb31 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/Spr16217Tests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/Spr16217Tests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,7 +25,7 @@ import org.springframework.core.type.AnnotatedTypeMetadata; * @author Andy Wilkinson * @author Juergen Hoeller */ -public class Spr16217Tests { +class Spr16217Tests { @Test @Disabled("TODO") @@ -37,7 +37,7 @@ public class Spr16217Tests { } @Test - public void baseConfigurationIsIncludedWhenFirstSuperclassReferenceIsSkippedInParseConfigurationPhase() { + void baseConfigurationIsIncludedWhenFirstSuperclassReferenceIsSkippedInParseConfigurationPhase() { try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ParseConfigurationPhaseImportingConfiguration.class)) { context.getBean("someBean"); @@ -45,17 +45,14 @@ public class Spr16217Tests { } @Test - public void baseConfigurationIsIncludedOnceWhenBothConfigurationClassesAreActive() { + void baseConfigurationIsIncludedOnceWhenBothConfigurationClassesAreActive() { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); - context.setAllowBeanDefinitionOverriding(false); - context.register(UnconditionalImportingConfiguration.class); - context.refresh(); - try { + try (context) { + context.setAllowBeanDefinitionOverriding(false); + context.register(UnconditionalImportingConfiguration.class); + context.refresh(); context.getBean("someBean"); } - finally { - context.close(); - } } diff --git a/spring-context/src/test/java/org/springframework/context/annotation/Spr6602Tests.java b/spring-context/src/test/java/org/springframework/context/annotation/Spr6602Tests.java index faf5579aac2..93cf350fca7 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/Spr6602Tests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/Spr6602Tests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,19 +31,19 @@ import static org.assertj.core.api.Assertions.assertThat; * * @author Chris Beams */ -public class Spr6602Tests { +class Spr6602Tests { @Test - public void testXmlBehavior() throws Exception { + void testXmlBehavior() throws Exception { doAssertions(new ClassPathXmlApplicationContext("Spr6602Tests-context.xml", Spr6602Tests.class)); } @Test - public void testConfigurationClassBehavior() throws Exception { + void testConfigurationClassBehavior() throws Exception { doAssertions(new AnnotationConfigApplicationContext(FooConfig.class)); } - private void doAssertions(ApplicationContext ctx) throws Exception { + private void doAssertions(ApplicationContext ctx) { Foo foo = ctx.getBean(Foo.class); Bar bar1 = ctx.getBean(Bar.class); @@ -65,7 +65,7 @@ public class Spr6602Tests { public static class FooConfig { @Bean - public Foo foo() throws Exception { + public Foo foo() { return new Foo(barFactory().getObject()); } @@ -93,7 +93,7 @@ public class Spr6602Tests { public static class BarFactory implements FactoryBean { @Override - public Bar getObject() throws Exception { + public Bar getObject() { return new Bar(); } diff --git a/spring-context/src/test/java/org/springframework/context/annotation/Spr8954Tests.java b/spring-context/src/test/java/org/springframework/context/annotation/Spr8954Tests.java index 4f892e08094..0c326d46be2 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/Spr8954Tests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/Spr8954Tests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,7 +44,7 @@ import static org.assertj.core.api.Assertions.assertThat; public class Spr8954Tests { @Test - public void repro() { + void repro() { AnnotationConfigApplicationContext bf = new AnnotationConfigApplicationContext(); bf.registerBeanDefinition("fooConfig", new RootBeanDefinition(FooConfig.class)); bf.getBeanFactory().addBeanPostProcessor(new PredictingBPP()); @@ -64,7 +64,7 @@ public class Spr8954Tests { } @Test - public void findsBeansByTypeIfNotInstantiated() { + void findsBeansByTypeIfNotInstantiated() { AnnotationConfigApplicationContext bf = new AnnotationConfigApplicationContext(); bf.registerBeanDefinition("fooConfig", new RootBeanDefinition(FooConfig.class)); bf.getBeanFactory().addBeanPostProcessor(new PredictingBPP()); diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/AutowiredConfigurationTests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/AutowiredConfigurationTests.java index 781aadb9e0c..9b9a6e5e374 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/AutowiredConfigurationTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/AutowiredConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -281,7 +281,7 @@ class AutowiredConfigurationTests { return new TestBean(""); } else { - return new TestBean(colour.get().toString() + "-" + colours.get().get(0).toString()); + return new TestBean(colour.get() + "-" + colours.get().get(0).toString()); } } } diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/BeanAnnotationAttributePropagationTests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/BeanAnnotationAttributePropagationTests.java index e334bddff55..fe3f8b4a69d 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/BeanAnnotationAttributePropagationTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/BeanAnnotationAttributePropagationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,10 +43,10 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Chris Beams * @author Juergen Hoeller */ -public class BeanAnnotationAttributePropagationTests { +class BeanAnnotationAttributePropagationTests { @Test - public void autowireCandidateMetadataIsPropagated() { + void autowireCandidateMetadataIsPropagated() { @Configuration class Config { @Bean(autowireCandidate=false) Object foo() { return null; } } @@ -55,7 +55,7 @@ public class BeanAnnotationAttributePropagationTests { } @Test - public void initMethodMetadataIsPropagated() { + void initMethodMetadataIsPropagated() { @Configuration class Config { @Bean(initMethod="start") Object foo() { return null; } } @@ -64,7 +64,7 @@ public class BeanAnnotationAttributePropagationTests { } @Test - public void destroyMethodMetadataIsPropagated() { + void destroyMethodMetadataIsPropagated() { @Configuration class Config { @Bean(destroyMethod="destroy") Object foo() { return null; } } @@ -73,7 +73,7 @@ public class BeanAnnotationAttributePropagationTests { } @Test - public void dependsOnMetadataIsPropagated() { + void dependsOnMetadataIsPropagated() { @Configuration class Config { @Bean() @DependsOn({"bar", "baz"}) Object foo() { return null; } } @@ -82,7 +82,7 @@ public class BeanAnnotationAttributePropagationTests { } @Test - public void primaryMetadataIsPropagated() { + void primaryMetadataIsPropagated() { @Configuration class Config { @Primary @Bean Object foo() { return null; } @@ -92,7 +92,7 @@ public class BeanAnnotationAttributePropagationTests { } @Test - public void primaryMetadataIsFalseByDefault() { + void primaryMetadataIsFalseByDefault() { @Configuration class Config { @Bean Object foo() { return null; } } @@ -101,7 +101,7 @@ public class BeanAnnotationAttributePropagationTests { } @Test - public void lazyMetadataIsPropagated() { + void lazyMetadataIsPropagated() { @Configuration class Config { @Lazy @Bean Object foo() { return null; } @@ -111,7 +111,7 @@ public class BeanAnnotationAttributePropagationTests { } @Test - public void lazyMetadataIsFalseByDefault() { + void lazyMetadataIsFalseByDefault() { @Configuration class Config { @Bean Object foo() { return null; } } @@ -120,7 +120,7 @@ public class BeanAnnotationAttributePropagationTests { } @Test - public void defaultLazyConfigurationPropagatesToIndividualBeans() { + void defaultLazyConfigurationPropagatesToIndividualBeans() { @Lazy @Configuration class Config { @Bean Object foo() { return null; } } @@ -129,7 +129,7 @@ public class BeanAnnotationAttributePropagationTests { } @Test - public void eagerBeanOverridesDefaultLazyConfiguration() { + void eagerBeanOverridesDefaultLazyConfiguration() { @Lazy @Configuration class Config { @Lazy(false) @Bean Object foo() { return null; } } @@ -138,7 +138,7 @@ public class BeanAnnotationAttributePropagationTests { } @Test - public void eagerConfigurationProducesEagerBeanDefinitions() { + void eagerConfigurationProducesEagerBeanDefinitions() { @Lazy(false) @Configuration class Config { // will probably never happen, doesn't make much sense @Bean Object foo() { return null; } } diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationClassWithPlaceholderConfigurerBeanTests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationClassWithPlaceholderConfigurerBeanTests.java index 0dfcb05c2f9..30c2eb5d1be 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationClassWithPlaceholderConfigurerBeanTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationClassWithPlaceholderConfigurerBeanTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,7 +45,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Juergen Hoeller * @author Sam Brannen */ -public class ConfigurationClassWithPlaceholderConfigurerBeanTests { +class ConfigurationClassWithPlaceholderConfigurerBeanTests { /** * Test which proves that a non-static property placeholder bean cannot be declared diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportAnnotationDetectionTests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportAnnotationDetectionTests.java index 240640c6864..861754de3a0 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportAnnotationDetectionTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportAnnotationDetectionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,7 +44,7 @@ import static org.assertj.core.api.Assertions.assertThat; public class ImportAnnotationDetectionTests { @Test - public void multipleMetaImportsAreProcessed() { + void multipleMetaImportsAreProcessed() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(MultiMetaImportConfig.class); ctx.refresh(); @@ -53,7 +53,7 @@ public class ImportAnnotationDetectionTests { } @Test - public void localAndMetaImportsAreProcessed() { + void localAndMetaImportsAreProcessed() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(MultiMetaImportConfigWithLocalImport.class); ctx.refresh(); @@ -63,7 +63,7 @@ public class ImportAnnotationDetectionTests { } @Test - public void localImportIsProcessedLast() { + void localImportIsProcessedLast() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(MultiMetaImportConfigWithLocalImportWithBeanOverride.class); ctx.refresh(); @@ -73,7 +73,7 @@ public class ImportAnnotationDetectionTests { } @Test - public void importFromBean() throws Exception { + void importFromBean() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(ImportFromBean.class); ctx.refresh(); diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportResourceTests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportResourceTests.java index bdef654d545..565b58e9d80 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportResourceTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportResourceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,10 +42,10 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Juergen Hoeller * @author Sam Brannen */ -public class ImportResourceTests { +class ImportResourceTests { @Test - public void importXml() { + void importXml() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(ImportXmlConfig.class); assertThat(ctx.containsBean("javaDeclaredBean")).as("did not contain java-declared bean").isTrue(); assertThat(ctx.containsBean("xmlDeclaredBean")).as("did not contain xml-declared bean").isTrue(); @@ -55,14 +55,14 @@ public class ImportResourceTests { } @Test - public void importXmlIsInheritedFromSuperclassDeclarations() { + void importXmlIsInheritedFromSuperclassDeclarations() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(FirstLevelSubConfig.class); assertThat(ctx.containsBean("xmlDeclaredBean")).isTrue(); ctx.close(); } @Test - public void importXmlIsMergedFromSuperclassDeclarations() { + void importXmlIsMergedFromSuperclassDeclarations() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(SecondLevelSubConfig.class); assertThat(ctx.containsBean("secondLevelXmlDeclaredBean")).as("failed to pick up second-level-declared XML bean").isTrue(); assertThat(ctx.containsBean("xmlDeclaredBean")).as("failed to pick up parent-declared XML bean").isTrue(); @@ -70,7 +70,7 @@ public class ImportResourceTests { } @Test - public void importXmlWithNamespaceConfig() { + void importXmlWithNamespaceConfig() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(ImportXmlWithAopNamespaceConfig.class); Object bean = ctx.getBean("proxiedXmlBean"); assertThat(AopUtils.isAopProxy(bean)).isTrue(); @@ -78,7 +78,7 @@ public class ImportResourceTests { } @Test - public void importXmlWithOtherConfigurationClass() { + void importXmlWithOtherConfigurationClass() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(ImportXmlWithConfigurationClass.class); assertThat(ctx.containsBean("javaDeclaredBean")).as("did not contain java-declared bean").isTrue(); assertThat(ctx.containsBean("xmlDeclaredBean")).as("did not contain xml-declared bean").isTrue(); @@ -88,7 +88,7 @@ public class ImportResourceTests { } @Test - public void importWithPlaceholder() throws Exception { + void importWithPlaceholder() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); PropertySource propertySource = new MapPropertySource("test", Collections. singletonMap("test", "springframework")); @@ -100,7 +100,7 @@ public class ImportResourceTests { } @Test - public void importXmlWithAutowiredConfig() { + void importXmlWithAutowiredConfig() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(ImportXmlAutowiredConfig.class); String name = ctx.getBean("xmlBeanName", String.class); assertThat(name).isEqualTo("xml.declared"); @@ -108,7 +108,7 @@ public class ImportResourceTests { } @Test - public void importNonXmlResource() { + void importNonXmlResource() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(ImportNonXmlResourceConfig.class); assertThat(ctx.containsBean("propertiesDeclaredBean")).isTrue(); ctx.close(); diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportWithConditionTests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportWithConditionTests.java index 52755bd7e5f..0c54aabd753 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportWithConditionTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportWithConditionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,12 +33,12 @@ import static org.assertj.core.api.Assertions.assertThat; /** * @author Andy Wilkinson */ -public class ImportWithConditionTests { +class ImportWithConditionTests { private AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); @Test - public void conditionalThenUnconditional() throws Exception { + void conditionalThenUnconditional() { this.context.register(ConditionalThenUnconditional.class); this.context.refresh(); assertThat(this.context.containsBean("beanTwo")).isFalse(); @@ -46,7 +46,7 @@ public class ImportWithConditionTests { } @Test - public void unconditionalThenConditional() throws Exception { + void unconditionalThenConditional() { this.context.register(UnconditionalThenConditional.class); this.context.refresh(); assertThat(this.context.containsBean("beanTwo")).isFalse(); diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ScopingTests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ScopingTests.java index d407d046b5e..7c82bcc0e23 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ScopingTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ScopingTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -49,7 +49,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Costin Leau * @author Chris Beams */ -public class ScopingTests { +class ScopingTests { public static String flag = "1"; @@ -61,13 +61,13 @@ public class ScopingTests { @BeforeEach - public void setUp() throws Exception { + void setUp() { customScope = new CustomScope(); ctx = createContext(ScopedConfigurationClass.class); } @AfterEach - public void tearDown() throws Exception { + void tearDown() { if (ctx != null) { ctx.close(); } @@ -86,16 +86,16 @@ public class ScopingTests { @Test - public void testScopeOnClasses() throws Exception { + void testScopeOnClasses() { genericTestScope("scopedClass"); } @Test - public void testScopeOnInterfaces() throws Exception { + void testScopeOnInterfaces() { genericTestScope("scopedInterface"); } - private void genericTestScope(String beanName) throws Exception { + private void genericTestScope(String beanName) { String message = "scope is ignored"; Object bean1 = ctx.getBean(beanName); Object bean2 = ctx.getBean(beanName); @@ -130,7 +130,7 @@ public class ScopingTests { } @Test - public void testSameScopeOnDifferentBeans() throws Exception { + void testSameScopeOnDifferentBeans() { Object beanAInScope = ctx.getBean("scopedClass"); Object beanBInScope = ctx.getBean("scopedInterface"); @@ -147,7 +147,7 @@ public class ScopingTests { } @Test - public void testRawScopes() throws Exception { + void testRawScopes() { String beanName = "scopedProxyInterface"; // get hidden bean @@ -158,7 +158,7 @@ public class ScopingTests { } @Test - public void testScopedProxyConfiguration() throws Exception { + void testScopedProxyConfiguration() { TestBean singleton = (TestBean) ctx.getBean("singletonWithScopedInterfaceDep"); ITestBean spouse = singleton.getSpouse(); boolean condition = spouse instanceof ScopedObject; @@ -191,7 +191,7 @@ public class ScopingTests { } @Test - public void testScopedProxyConfigurationWithClasses() throws Exception { + void testScopedProxyConfigurationWithClasses() { TestBean singleton = (TestBean) ctx.getBean("singletonWithScopedClassDep"); ITestBean spouse = singleton.getSpouse(); boolean condition = spouse instanceof ScopedObject; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/Spr10668Tests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/Spr10668Tests.java index a8237a1e132..2e57c5ebb5d 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/Spr10668Tests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/Spr10668Tests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,10 +31,10 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Oliver Gierke * @author Phillip Webb */ -public class Spr10668Tests { +class Spr10668Tests { @Test - public void testSelfInjectHierarchy() throws Exception { + void testSelfInjectHierarchy() { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ChildConfig.class); assertThat(context.getBean(MyComponent.class)).isNotNull(); context.close(); diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/Spr10744Tests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/Spr10744Tests.java index 49fccb9a241..1907f3ccec1 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/Spr10744Tests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/Spr10744Tests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,7 +33,7 @@ import static org.assertj.core.api.Assertions.assertThat; /** * @author Phillip Webb */ -public class Spr10744Tests { +class Spr10744Tests { private static int createCount = 0; @@ -41,7 +41,7 @@ public class Spr10744Tests { @Test - public void testSpr10744() throws Exception { + void testSpr10744() { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); context.getBeanFactory().registerScope("myTestScope", new MyTestScope()); context.register(MyTestConfiguration.class); diff --git a/spring-context/src/test/java/org/springframework/context/annotation/jsr330/SpringAtInjectTckTests.java b/spring-context/src/test/java/org/springframework/context/annotation/jsr330/SpringAtInjectTckTests.java index 4a8ff2b57e6..f9d0574d552 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/jsr330/SpringAtInjectTckTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/jsr330/SpringAtInjectTckTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,7 +38,7 @@ import org.springframework.context.support.GenericApplicationContext; * @author Juergen Hoeller * @since 3.0 */ -public class SpringAtInjectTckTests { +class SpringAtInjectTckTests { @SuppressWarnings("unchecked") public static Test suite() { diff --git a/spring-context/src/test/java/org/springframework/context/annotation/spr10546/Spr10546Tests.java b/spring-context/src/test/java/org/springframework/context/annotation/spr10546/Spr10546Tests.java index c7a32b22b6e..ad7245354f2 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/spr10546/Spr10546Tests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/spr10546/Spr10546Tests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,11 +31,11 @@ import static org.assertj.core.api.Assertions.assertThat; /** * @author Rob Winch */ -public class Spr10546Tests { +class Spr10546Tests { private ConfigurableApplicationContext context; @AfterEach - public void closeContext() { + void closeContext() { if (context != null) { context.close(); } @@ -44,7 +44,7 @@ public class Spr10546Tests { // These fail prior to fixing SPR-10546 @Test - public void enclosingConfigFirstParentDefinesBean() { + void enclosingConfigFirstParentDefinesBean() { assertLoadsMyBean(AEnclosingConfig.class,AEnclosingConfig.ChildConfig.class); } @@ -59,7 +59,7 @@ public class Spr10546Tests { * classpath scanning implementation being used by the author of this test. */ @Test - public void enclosingConfigFirstParentDefinesBeanWithScanning() { + void enclosingConfigFirstParentDefinesBeanWithScanning() { AnnotationConfigApplicationContext ctx= new AnnotationConfigApplicationContext(); context = ctx; ctx.scan(AEnclosingConfig.class.getPackage().getName()); @@ -68,7 +68,7 @@ public class Spr10546Tests { } @Test - public void enclosingConfigFirstParentDefinesBeanWithImportResource() { + void enclosingConfigFirstParentDefinesBeanWithImportResource() { assertLoadsMyBean(AEnclosingWithImportResourceConfig.class,AEnclosingWithImportResourceConfig.ChildConfig.class); } @@ -79,7 +79,7 @@ public class Spr10546Tests { } @Test - public void enclosingConfigFirstParentDefinesBeanWithComponentScan() { + void enclosingConfigFirstParentDefinesBeanWithComponentScan() { assertLoadsMyBean(AEnclosingWithComponentScanConfig.class,AEnclosingWithComponentScanConfig.ChildConfig.class); } @@ -90,7 +90,7 @@ public class Spr10546Tests { } @Test - public void enclosingConfigFirstParentWithParentDefinesBean() { + void enclosingConfigFirstParentWithParentDefinesBean() { assertLoadsMyBean(AEnclosingWithGrandparentConfig.class,AEnclosingWithGrandparentConfig.ChildConfig.class); } @@ -101,7 +101,7 @@ public class Spr10546Tests { } @Test - public void importChildConfigThenChildConfig() { + void importChildConfigThenChildConfig() { assertLoadsMyBean(ImportChildConfig.class,ChildConfig.class); } @@ -116,7 +116,7 @@ public class Spr10546Tests { // These worked prior, but validating they continue to work @Test - public void enclosingConfigFirstParentDefinesBeanWithImport() { + void enclosingConfigFirstParentDefinesBeanWithImport() { assertLoadsMyBean(AEnclosingWithImportConfig.class,AEnclosingWithImportConfig.ChildConfig.class); } @@ -127,17 +127,17 @@ public class Spr10546Tests { } @Test - public void childConfigFirst() { + void childConfigFirst() { assertLoadsMyBean(AEnclosingConfig.ChildConfig.class, AEnclosingConfig.class); } @Test - public void enclosingConfigOnly() { + void enclosingConfigOnly() { assertLoadsMyBean(AEnclosingConfig.class); } @Test - public void childConfigOnly() { + void childConfigOnly() { assertLoadsMyBean(AEnclosingConfig.ChildConfig.class); } diff --git a/spring-context/src/test/java/org/springframework/context/annotation/spr12233/Spr12233Tests.java b/spring-context/src/test/java/org/springframework/context/annotation/spr12233/Spr12233Tests.java index d9b8044b3fd..49f965c7993 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/spr12233/Spr12233Tests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/spr12233/Spr12233Tests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,10 +35,10 @@ import org.springframework.core.type.AnnotatedTypeMetadata; * * @author Phillip Webb */ -public class Spr12233Tests { +class Spr12233Tests { @Test - public void spr12233() throws Exception { + void spr12233() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(PropertySourcesPlaceholderConfigurer.class); ctx.register(ImportConfiguration.class); diff --git a/spring-context/src/test/java/org/springframework/context/event/AnnotationDrivenEventListenerTests.java b/spring-context/src/test/java/org/springframework/context/event/AnnotationDrivenEventListenerTests.java index 1d19dba6061..91a750956aa 100644 --- a/spring-context/src/test/java/org/springframework/context/event/AnnotationDrivenEventListenerTests.java +++ b/spring-context/src/test/java/org/springframework/context/event/AnnotationDrivenEventListenerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -87,7 +87,7 @@ class AnnotationDrivenEventListenerTests { @AfterEach - public void closeContext() { + void closeContext() { if (this.context != null) { this.context.close(); } @@ -196,8 +196,7 @@ class AnnotationDrivenEventListenerTests { failingContext.register(BasicConfiguration.class, InvalidMethodSignatureEventListener.class); - assertThatExceptionOfType(BeanInitializationException.class).isThrownBy(() -> - failingContext.refresh()) + assertThatExceptionOfType(BeanInitializationException.class).isThrownBy(failingContext::refresh) .withMessageContaining(InvalidMethodSignatureEventListener.class.getName()) .withMessageContaining("cannotBeCalled"); } @@ -680,14 +679,14 @@ class AnnotationDrivenEventListenerTests { List> allClasses = new ArrayList<>(); allClasses.add(BasicConfiguration.class); allClasses.addAll(Arrays.asList(classes)); - doLoad(allClasses.toArray(new Class[allClasses.size()])); + doLoad(allClasses.toArray(new Class[0])); } private void loadAsync(Class... classes) { List> allClasses = new ArrayList<>(); allClasses.add(AsyncConfiguration.class); allClasses.addAll(Arrays.asList(classes)); - doLoad(allClasses.toArray(new Class[allClasses.size()])); + doLoad(allClasses.toArray(new Class[0])); } private void doLoad(Class... classes) { diff --git a/spring-context/src/test/java/org/springframework/context/event/ApplicationContextEventTests.java b/spring-context/src/test/java/org/springframework/context/event/ApplicationContextEventTests.java index 19b44968fbd..cc26a34e560 100644 --- a/spring-context/src/test/java/org/springframework/context/event/ApplicationContextEventTests.java +++ b/spring-context/src/test/java/org/springframework/context/event/ApplicationContextEventTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -78,10 +78,10 @@ import static org.springframework.context.support.AbstractApplicationContext.APP * @author Stephane Nicoll * @author Juergen Hoeller */ -public class ApplicationContextEventTests extends AbstractApplicationEventListenerTests { +class ApplicationContextEventTests extends AbstractApplicationEventListenerTests { @Test - public void multicastSimpleEvent() { + void multicastSimpleEvent() { multicastEvent(true, ApplicationListener.class, new ContextRefreshedEvent(new StaticApplicationContext()), null); multicastEvent(true, ApplicationListener.class, @@ -89,40 +89,40 @@ public class ApplicationContextEventTests extends AbstractApplicationEventListen } @Test - public void multicastGenericEvent() { + void multicastGenericEvent() { multicastEvent(true, StringEventListener.class, createGenericTestEvent("test"), ResolvableType.forClassWithGenerics(GenericTestEvent.class, String.class)); } @Test - public void multicastGenericEventWrongType() { + void multicastGenericEventWrongType() { multicastEvent(false, StringEventListener.class, createGenericTestEvent(123L), ResolvableType.forClassWithGenerics(GenericTestEvent.class, Long.class)); } @Test - public void multicastGenericEventWildcardSubType() { + void multicastGenericEventWildcardSubType() { multicastEvent(false, StringEventListener.class, createGenericTestEvent("test"), getGenericApplicationEventType("wildcardEvent")); } @Test - public void multicastConcreteTypeGenericListener() { + void multicastConcreteTypeGenericListener() { multicastEvent(true, StringEventListener.class, new StringEvent(this, "test"), null); } @Test - public void multicastConcreteWrongTypeGenericListener() { + void multicastConcreteWrongTypeGenericListener() { multicastEvent(false, StringEventListener.class, new LongEvent(this, 123L), null); } @Test - public void multicastSmartGenericTypeGenericListener() { + void multicastSmartGenericTypeGenericListener() { multicastEvent(true, StringEventListener.class, new SmartGenericTestEvent<>(this, "test"), null); } @Test - public void multicastSmartGenericWrongTypeGenericListener() { + void multicastSmartGenericWrongTypeGenericListener() { multicastEvent(false, StringEventListener.class, new SmartGenericTestEvent<>(this, 123L), null); } @@ -144,7 +144,7 @@ public class ApplicationContextEventTests extends AbstractApplicationEventListen } @Test - public void simpleApplicationEventMulticasterWithTaskExecutor() { + void simpleApplicationEventMulticasterWithTaskExecutor() { @SuppressWarnings("unchecked") ApplicationListener listener = mock(); willReturn(true).given(listener).supportsAsyncExecution(); @@ -165,7 +165,7 @@ public class ApplicationContextEventTests extends AbstractApplicationEventListen } @Test - public void simpleApplicationEventMulticasterWithTaskExecutorAndNonAsyncListener() { + void simpleApplicationEventMulticasterWithTaskExecutorAndNonAsyncListener() { @SuppressWarnings("unchecked") ApplicationListener listener = mock(); willReturn(false).given(listener).supportsAsyncExecution(); @@ -186,7 +186,7 @@ public class ApplicationContextEventTests extends AbstractApplicationEventListen } @Test - public void simpleApplicationEventMulticasterWithException() { + void simpleApplicationEventMulticasterWithException() { @SuppressWarnings("unchecked") ApplicationListener listener = mock(); ApplicationEvent evt = new ContextClosedEvent(new StaticApplicationContext()); @@ -202,7 +202,7 @@ public class ApplicationContextEventTests extends AbstractApplicationEventListen } @Test - public void simpleApplicationEventMulticasterWithErrorHandler() { + void simpleApplicationEventMulticasterWithErrorHandler() { @SuppressWarnings("unchecked") ApplicationListener listener = mock(); ApplicationEvent evt = new ContextClosedEvent(new StaticApplicationContext()); @@ -216,7 +216,7 @@ public class ApplicationContextEventTests extends AbstractApplicationEventListen } @Test - public void orderedListeners() { + void orderedListeners() { MyOrderedListener1 listener1 = new MyOrderedListener1(); MyOrderedListener2 listener2 = new MyOrderedListener2(listener1); @@ -230,7 +230,7 @@ public class ApplicationContextEventTests extends AbstractApplicationEventListen } @Test - public void orderedListenersWithAnnotation() { + void orderedListenersWithAnnotation() { MyOrderedListener3 listener1 = new MyOrderedListener3(); MyOrderedListener4 listener2 = new MyOrderedListener4(listener1); @@ -289,7 +289,7 @@ public class ApplicationContextEventTests extends AbstractApplicationEventListen * were added to the list of application listener beans twice (both proxy and unwrapped target). */ @Test - public void eventForSelfInjectedProxiedListenerFiredOnlyOnce() { + void eventForSelfInjectedProxiedListenerFiredOnlyOnce() { AbstractApplicationContext context = new AnnotationConfigApplicationContext( MyAspect.class, MyEventListener.class, MyEventPublisher.class); context.getBean(MyEventPublisher.class).publishMyEvent("hello"); @@ -298,7 +298,7 @@ public class ApplicationContextEventTests extends AbstractApplicationEventListen } @Test - public void testEventPublicationInterceptor() throws Throwable { + void testEventPublicationInterceptor() throws Throwable { MethodInvocation invocation = mock(); ApplicationContext ctx = mock(); @@ -314,7 +314,7 @@ public class ApplicationContextEventTests extends AbstractApplicationEventListen } @Test - public void listenersInApplicationContext() { + void listenersInApplicationContext() { StaticApplicationContext context = new StaticApplicationContext(); context.registerBeanDefinition("listener1", new RootBeanDefinition(MyOrderedListener1.class)); RootBeanDefinition listener2 = new RootBeanDefinition(MyOrderedListener2.class); @@ -351,7 +351,7 @@ public class ApplicationContextEventTests extends AbstractApplicationEventListen } @Test - public void listenersInApplicationContextWithPayloadEvents() { + void listenersInApplicationContextWithPayloadEvents() { StaticApplicationContext context = new StaticApplicationContext(); context.registerBeanDefinition("listener", new RootBeanDefinition(MyPayloadListener.class)); context.refresh(); @@ -370,7 +370,7 @@ public class ApplicationContextEventTests extends AbstractApplicationEventListen } @Test - public void listenersInApplicationContextWithNestedChild() { + void listenersInApplicationContextWithNestedChild() { StaticApplicationContext context = new StaticApplicationContext(); RootBeanDefinition nestedChild = new RootBeanDefinition(StaticApplicationContext.class); nestedChild.getPropertyValues().add("parent", context); @@ -394,7 +394,7 @@ public class ApplicationContextEventTests extends AbstractApplicationEventListen } @Test - public void nonSingletonListenerInApplicationContext() { + void nonSingletonListenerInApplicationContext() { StaticApplicationContext context = new StaticApplicationContext(); RootBeanDefinition listener = new RootBeanDefinition(MyNonSingletonListener.class); listener.setScope(BeanDefinition.SCOPE_PROTOTYPE); @@ -426,7 +426,7 @@ public class ApplicationContextEventTests extends AbstractApplicationEventListen } @Test - public void listenerAndBroadcasterWithCircularReference() { + void listenerAndBroadcasterWithCircularReference() { StaticApplicationContext context = new StaticApplicationContext(); context.registerBeanDefinition("broadcaster", new RootBeanDefinition(BeanThatBroadcasts.class)); RootBeanDefinition listenerDef = new RootBeanDefinition(BeanThatListens.class); @@ -442,7 +442,7 @@ public class ApplicationContextEventTests extends AbstractApplicationEventListen } @Test - public void innerBeanAsListener() { + void innerBeanAsListener() { StaticApplicationContext context = new StaticApplicationContext(); RootBeanDefinition listenerDef = new RootBeanDefinition(TestBean.class); listenerDef.getPropertyValues().add("friends", new RootBeanDefinition(BeanThatListens.class)); @@ -458,7 +458,7 @@ public class ApplicationContextEventTests extends AbstractApplicationEventListen } @Test - public void anonymousClassAsListener() { + void anonymousClassAsListener() { final Set seenEvents = new HashSet<>(); StaticApplicationContext context = new StaticApplicationContext(); context.addApplicationListener((MyEvent event) -> seenEvents.add(event)); @@ -475,7 +475,7 @@ public class ApplicationContextEventTests extends AbstractApplicationEventListen } @Test - public void lambdaAsListener() { + void lambdaAsListener() { final Set seenEvents = new HashSet<>(); StaticApplicationContext context = new StaticApplicationContext(); ApplicationListener listener = seenEvents::add; @@ -493,7 +493,7 @@ public class ApplicationContextEventTests extends AbstractApplicationEventListen } @Test - public void lambdaAsListenerWithErrorHandler() { + void lambdaAsListenerWithErrorHandler() { final Set seenEvents = new HashSet<>(); StaticApplicationContext context = new StaticApplicationContext(); SimpleApplicationEventMulticaster multicaster = new SimpleApplicationEventMulticaster(); @@ -514,7 +514,7 @@ public class ApplicationContextEventTests extends AbstractApplicationEventListen } @Test - public void lambdaAsListenerWithJava8StyleClassCastMessage() { + void lambdaAsListenerWithJava8StyleClassCastMessage() { StaticApplicationContext context = new StaticApplicationContext(); ApplicationListener listener = event -> { throw new ClassCastException(event.getClass().getName()); }; @@ -526,7 +526,7 @@ public class ApplicationContextEventTests extends AbstractApplicationEventListen } @Test - public void lambdaAsListenerWithJava9StyleClassCastMessage() { + void lambdaAsListenerWithJava9StyleClassCastMessage() { StaticApplicationContext context = new StaticApplicationContext(); ApplicationListener listener = event -> { throw new ClassCastException("spring.context/" + event.getClass().getName()); }; @@ -552,7 +552,7 @@ public class ApplicationContextEventTests extends AbstractApplicationEventListen } @Test - public void beanPostProcessorPublishesEvents() { + void beanPostProcessorPublishesEvents() { GenericApplicationContext context = new GenericApplicationContext(); context.registerBeanDefinition("listener", new RootBeanDefinition(BeanThatListens.class)); context.registerBeanDefinition("messageSource", new RootBeanDefinition(StaticMessageSource.class)); @@ -567,7 +567,7 @@ public class ApplicationContextEventTests extends AbstractApplicationEventListen } @Test - public void initMethodPublishesEvent() { + void initMethodPublishesEvent() { GenericApplicationContext context = new GenericApplicationContext(); context.registerBeanDefinition("listener", new RootBeanDefinition(BeanThatListens.class)); context.registerBeanDefinition("messageSource", new RootBeanDefinition(StaticMessageSource.class)); @@ -582,7 +582,7 @@ public class ApplicationContextEventTests extends AbstractApplicationEventListen } @Test - public void initMethodPublishesAsyncEvent() { + void initMethodPublishesAsyncEvent() { GenericApplicationContext context = new GenericApplicationContext(); context.registerBeanDefinition("listener", new RootBeanDefinition(BeanThatListens.class)); context.registerBeanDefinition("messageSource", new RootBeanDefinition(StaticMessageSource.class)); @@ -743,7 +743,7 @@ public class ApplicationContextEventTests extends AbstractApplicationEventListen } @Override - public void afterPropertiesSet() throws Exception { + public void afterPropertiesSet() { this.publisher.publishEvent(new MyEvent(this)); } } diff --git a/spring-context/src/test/java/org/springframework/context/event/ApplicationListenerMethodAdapterTests.java b/spring-context/src/test/java/org/springframework/context/event/ApplicationListenerMethodAdapterTests.java index 1c50a9801a7..fbafc8e0f20 100644 --- a/spring-context/src/test/java/org/springframework/context/event/ApplicationListenerMethodAdapterTests.java +++ b/spring-context/src/test/java/org/springframework/context/event/ApplicationListenerMethodAdapterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -51,7 +51,7 @@ import static org.mockito.Mockito.verify; * @author Juergen Hoeller * @author Simon Baslé */ -public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEventListenerTests { +class ApplicationListenerMethodAdapterTests extends AbstractApplicationEventListenerTests { private final SampleEvents sampleEvents = spy(new SampleEvents()); @@ -59,89 +59,89 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv @Test - public void rawListener() { + void rawListener() { Method method = ReflectionUtils.findMethod(SampleEvents.class, "handleRaw", ApplicationEvent.class); supportsEventType(true, method, ResolvableType.forClass(ApplicationEvent.class)); } @Test - public void rawListenerWithGenericEvent() { + void rawListenerWithGenericEvent() { Method method = ReflectionUtils.findMethod(SampleEvents.class, "handleRaw", ApplicationEvent.class); supportsEventType(true, method, ResolvableType.forClassWithGenerics(GenericTestEvent.class, String.class)); } @Test - public void genericListener() { + void genericListener() { Method method = ReflectionUtils.findMethod( SampleEvents.class, "handleGenericString", GenericTestEvent.class); supportsEventType(true, method, ResolvableType.forClassWithGenerics(GenericTestEvent.class, String.class)); } @Test - public void genericListenerWrongParameterizedType() { + void genericListenerWrongParameterizedType() { Method method = ReflectionUtils.findMethod( SampleEvents.class, "handleGenericString", GenericTestEvent.class); supportsEventType(false, method, ResolvableType.forClassWithGenerics(GenericTestEvent.class, Long.class)); } @Test - public void genericListenerWithUnresolvedGenerics() { + void genericListenerWithUnresolvedGenerics() { Method method = ReflectionUtils.findMethod( SampleEvents.class, "handleGenericString", GenericTestEvent.class); supportsEventType(true, method, ResolvableType.forClass(GenericTestEvent.class)); } @Test - public void listenerWithPayloadAndGenericInformation() { + void listenerWithPayloadAndGenericInformation() { Method method = ReflectionUtils.findMethod(SampleEvents.class, "handleString", String.class); supportsEventType(true, method, createPayloadEventType(String.class)); } @Test - public void listenerWithInvalidPayloadAndGenericInformation() { + void listenerWithInvalidPayloadAndGenericInformation() { Method method = ReflectionUtils.findMethod(SampleEvents.class, "handleString", String.class); supportsEventType(false, method, createPayloadEventType(Integer.class)); } @Test - public void listenerWithPayloadTypeErasure() { // Always accept such event when the type is unknown + void listenerWithPayloadTypeErasure() { // Always accept such event when the type is unknown Method method = ReflectionUtils.findMethod(SampleEvents.class, "handleString", String.class); supportsEventType(true, method, ResolvableType.forClass(PayloadApplicationEvent.class)); } @Test - public void listenerWithSubTypeSeveralGenerics() { + void listenerWithSubTypeSeveralGenerics() { Method method = ReflectionUtils.findMethod(SampleEvents.class, "handleString", String.class); supportsEventType(true, method, ResolvableType.forClass(PayloadTestEvent.class)); } @Test - public void listenerWithSubTypeSeveralGenericsResolved() { + void listenerWithSubTypeSeveralGenericsResolved() { Method method = ReflectionUtils.findMethod(SampleEvents.class, "handleString", String.class); supportsEventType(true, method, ResolvableType.forClass(PayloadStringTestEvent.class)); } @Test - public void listenerWithAnnotationValue() { + void listenerWithAnnotationValue() { Method method = ReflectionUtils.findMethod(SampleEvents.class, "handleStringAnnotationValue"); supportsEventType(true, method, createPayloadEventType(String.class)); } @Test - public void listenerWithAnnotationClasses() { + void listenerWithAnnotationClasses() { Method method = ReflectionUtils.findMethod(SampleEvents.class, "handleStringAnnotationClasses"); supportsEventType(true, method, createPayloadEventType(String.class)); } @Test - public void listenerWithAnnotationValueAndParameter() { + void listenerWithAnnotationValueAndParameter() { Method method = ReflectionUtils.findMethod( SampleEvents.class, "handleStringAnnotationValueAndParameter", String.class); supportsEventType(true, method, createPayloadEventType(String.class)); } @Test - public void listenerWithSeveralTypes() { + void listenerWithSeveralTypes() { Method method = ReflectionUtils.findMethod(SampleEvents.class, "handleStringOrInteger"); supportsEventType(true, method, createPayloadEventType(String.class)); supportsEventType(true, method, createPayloadEventType(Integer.class)); @@ -149,27 +149,27 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv } @Test - public void listenerWithTooManyParameters() { + void listenerWithTooManyParameters() { Method method = ReflectionUtils.findMethod( SampleEvents.class, "tooManyParameters", String.class, String.class); assertThatIllegalStateException().isThrownBy(() -> createTestInstance(method)); } @Test - public void listenerWithNoParameter() { + void listenerWithNoParameter() { Method method = ReflectionUtils.findMethod(SampleEvents.class, "noParameter"); assertThatIllegalStateException().isThrownBy(() -> createTestInstance(method)); } @Test - public void listenerWithMoreThanOneParameter() { + void listenerWithMoreThanOneParameter() { Method method = ReflectionUtils.findMethod( SampleEvents.class, "moreThanOneParameter", String.class, Integer.class); assertThatIllegalStateException().isThrownBy(() -> createTestInstance(method)); } @Test - public void defaultOrder() { + void defaultOrder() { Method method = ReflectionUtils.findMethod( SampleEvents.class, "handleGenericString", GenericTestEvent.class); ApplicationListenerMethodAdapter adapter = createTestInstance(method); @@ -177,7 +177,7 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv } @Test - public void specifiedOrder() { + void specifiedOrder() { Method method = ReflectionUtils.findMethod( SampleEvents.class, "handleRaw", ApplicationEvent.class); ApplicationListenerMethodAdapter adapter = createTestInstance(method); @@ -185,7 +185,7 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv } @Test - public void invokeListener() { + void invokeListener() { Method method = ReflectionUtils.findMethod( SampleEvents.class, "handleGenericString", GenericTestEvent.class); GenericTestEvent event = createGenericTestEvent("test"); @@ -194,7 +194,7 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv } @Test - public void invokeListenerWithGenericEvent() { + void invokeListenerWithGenericEvent() { Method method = ReflectionUtils.findMethod( SampleEvents.class, "handleGenericString", GenericTestEvent.class); GenericTestEvent event = new SmartGenericTestEvent<>(this, "test"); @@ -203,7 +203,7 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv } @Test - public void invokeListenerWithGenericPayload() { + void invokeListenerWithGenericPayload() { Method method = ReflectionUtils.findMethod( SampleEvents.class, "handleGenericStringPayload", EntityWrapper.class); EntityWrapper payload = new EntityWrapper<>("test"); @@ -212,7 +212,7 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv } @Test - public void invokeListenerWithWrongGenericPayload() { + void invokeListenerWithWrongGenericPayload() { Method method = ReflectionUtils.findMethod (SampleEvents.class, "handleGenericStringPayload", EntityWrapper.class); EntityWrapper payload = new EntityWrapper<>(123); @@ -221,7 +221,7 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv } @Test - public void invokeListenerWithAnyGenericPayload() { + void invokeListenerWithAnyGenericPayload() { Method method = ReflectionUtils.findMethod( SampleEvents.class, "handleGenericAnyPayload", EntityWrapper.class); EntityWrapper payload = new EntityWrapper<>("test"); @@ -230,7 +230,7 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv } @Test - public void invokeListenerRuntimeException() { + void invokeListenerRuntimeException() { Method method = ReflectionUtils.findMethod( SampleEvents.class, "generateRuntimeException", GenericTestEvent.class); GenericTestEvent event = createGenericTestEvent("fail"); @@ -242,7 +242,7 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv } @Test - public void invokeListenerCheckedException() { + void invokeListenerCheckedException() { Method method = ReflectionUtils.findMethod( SampleEvents.class, "generateCheckedException", GenericTestEvent.class); GenericTestEvent event = createGenericTestEvent("fail"); @@ -253,7 +253,7 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv } @Test - public void invokeListenerInvalidProxy() { + void invokeListenerInvalidProxy() { Object target = new InvalidProxyTestBean(); ProxyFactory proxyFactory = new ProxyFactory(); proxyFactory.setTarget(target); @@ -270,7 +270,7 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv } @Test - public void invokeListenerWithPayload() { + void invokeListenerWithPayload() { Method method = ReflectionUtils.findMethod(SampleEvents.class, "handleString", String.class); PayloadApplicationEvent event = new PayloadApplicationEvent<>(this, "test"); invokeListener(method, event); @@ -278,7 +278,7 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv } @Test - public void invokeListenerWithPayloadWrongType() { + void invokeListenerWithPayloadWrongType() { Method method = ReflectionUtils.findMethod(SampleEvents.class, "handleString", String.class); PayloadApplicationEvent event = new PayloadApplicationEvent<>(this, 123L); invokeListener(method, event); @@ -286,7 +286,7 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv } @Test - public void invokeListenerWithAnnotationValue() { + void invokeListenerWithAnnotationValue() { Method method = ReflectionUtils.findMethod(SampleEvents.class, "handleStringAnnotationClasses"); PayloadApplicationEvent event = new PayloadApplicationEvent<>(this, "test"); invokeListener(method, event); @@ -294,7 +294,7 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv } @Test - public void invokeListenerWithAnnotationValueAndParameter() { + void invokeListenerWithAnnotationValueAndParameter() { Method method = ReflectionUtils.findMethod( SampleEvents.class, "handleStringAnnotationValueAndParameter", String.class); PayloadApplicationEvent event = new PayloadApplicationEvent<>(this, "test"); @@ -303,7 +303,7 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv } @Test - public void invokeListenerWithSeveralTypes() { + void invokeListenerWithSeveralTypes() { Method method = ReflectionUtils.findMethod(SampleEvents.class, "handleStringOrInteger"); PayloadApplicationEvent event = new PayloadApplicationEvent<>(this, "test"); invokeListener(method, event); @@ -317,7 +317,7 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv } @Test - public void beanInstanceRetrievedAtEveryInvocation() { + void beanInstanceRetrievedAtEveryInvocation() { Method method = ReflectionUtils.findMethod( SampleEvents.class, "handleGenericString", GenericTestEvent.class); given(this.context.getBean("testBean")).willReturn(this.sampleEvents); diff --git a/spring-context/src/test/java/org/springframework/context/event/GenericApplicationListenerAdapterTests.java b/spring-context/src/test/java/org/springframework/context/event/GenericApplicationListenerAdapterTests.java index 6fdb68bb0af..fe0dc36be82 100644 --- a/spring-context/src/test/java/org/springframework/context/event/GenericApplicationListenerAdapterTests.java +++ b/spring-context/src/test/java/org/springframework/context/event/GenericApplicationListenerAdapterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,10 +32,10 @@ import static org.mockito.Mockito.verify; /** * @author Stephane Nicoll */ -public class GenericApplicationListenerAdapterTests extends AbstractApplicationEventListenerTests { +class GenericApplicationListenerAdapterTests extends AbstractApplicationEventListenerTests { @Test - public void supportsEventTypeWithSmartApplicationListener() { + void supportsEventTypeWithSmartApplicationListener() { SmartApplicationListener smartListener = mock(); GenericApplicationListenerAdapter listener = new GenericApplicationListenerAdapter(smartListener); ResolvableType type = ResolvableType.forClass(ApplicationEvent.class); @@ -44,7 +44,7 @@ public class GenericApplicationListenerAdapterTests extends AbstractApplicationE } @Test - public void supportsSourceTypeWithSmartApplicationListener() { + void supportsSourceTypeWithSmartApplicationListener() { SmartApplicationListener smartListener = mock(); GenericApplicationListenerAdapter listener = new GenericApplicationListenerAdapter(smartListener); listener.supportsSourceType(Object.class); @@ -52,7 +52,7 @@ public class GenericApplicationListenerAdapterTests extends AbstractApplicationE } @Test - public void genericListenerStrictType() { + void genericListenerStrictType() { supportsEventType(true, StringEventListener.class, ResolvableType.forClassWithGenerics(GenericTestEvent.class, String.class)); } @@ -84,44 +84,44 @@ public class GenericApplicationListenerAdapterTests extends AbstractApplicationE } @Test - public void genericListenerStrictTypeNotMatching() { + void genericListenerStrictTypeNotMatching() { supportsEventType(false, StringEventListener.class, ResolvableType.forClassWithGenerics(GenericTestEvent.class, Long.class)); } @Test - public void genericListenerStrictTypeEventSubTypeNotMatching() { + void genericListenerStrictTypeEventSubTypeNotMatching() { LongEvent stringEvent = new LongEvent(this, 123L); ResolvableType eventType = ResolvableType.forType(stringEvent.getClass()); supportsEventType(false, StringEventListener.class, eventType); } @Test - public void genericListenerStrictTypeNotMatchTypeErasure() { + void genericListenerStrictTypeNotMatchTypeErasure() { GenericTestEvent longEvent = createGenericTestEvent(123L); ResolvableType eventType = ResolvableType.forType(longEvent.getClass()); supportsEventType(false, StringEventListener.class, eventType); } @Test - public void genericListenerStrictTypeSubClass() { + void genericListenerStrictTypeSubClass() { supportsEventType(false, ObjectEventListener.class, ResolvableType.forClassWithGenerics(GenericTestEvent.class, Long.class)); } @Test - public void genericListenerUpperBoundType() { + void genericListenerUpperBoundType() { supportsEventType(true, UpperBoundEventListener.class, ResolvableType.forClassWithGenerics(GenericTestEvent.class, IllegalStateException.class)); } @Test - public void genericListenerUpperBoundTypeNotMatching() { + void genericListenerUpperBoundTypeNotMatching() { supportsEventType(false, UpperBoundEventListener.class, ResolvableType.forClassWithGenerics(GenericTestEvent.class, IOException.class)); } @Test - public void genericListenerWildcardType() { + void genericListenerWildcardType() { supportsEventType(true, GenericEventListener.class, ResolvableType.forClassWithGenerics(GenericTestEvent.class, String.class)); } @@ -134,7 +134,7 @@ public class GenericApplicationListenerAdapterTests extends AbstractApplicationE } @Test - public void genericListenerRawType() { + void genericListenerRawType() { supportsEventType(true, RawApplicationListener.class, ResolvableType.forClassWithGenerics(GenericTestEvent.class, String.class)); } diff --git a/spring-context/src/test/java/org/springframework/context/event/LifecycleEventTests.java b/spring-context/src/test/java/org/springframework/context/event/LifecycleEventTests.java index 5c4917c7fda..a3e4bc820b2 100644 --- a/spring-context/src/test/java/org/springframework/context/event/LifecycleEventTests.java +++ b/spring-context/src/test/java/org/springframework/context/event/LifecycleEventTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,10 +30,10 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Mark Fisher * @author Juergen Hoeller */ -public class LifecycleEventTests { +class LifecycleEventTests { @Test - public void contextStartedEvent() { + void contextStartedEvent() { StaticApplicationContext context = new StaticApplicationContext(); context.registerSingleton("lifecycle", LifecycleTestBean.class); context.registerSingleton("listener", LifecycleListener.class); @@ -49,7 +49,7 @@ public class LifecycleEventTests { } @Test - public void contextStoppedEvent() { + void contextStoppedEvent() { StaticApplicationContext context = new StaticApplicationContext(); context.registerSingleton("lifecycle", LifecycleTestBean.class); context.registerSingleton("listener", LifecycleListener.class); diff --git a/spring-context/src/test/java/org/springframework/context/event/PayloadApplicationEventTests.java b/spring-context/src/test/java/org/springframework/context/event/PayloadApplicationEventTests.java index 1f67a81dc7f..8c437c6d850 100644 --- a/spring-context/src/test/java/org/springframework/context/event/PayloadApplicationEventTests.java +++ b/spring-context/src/test/java/org/springframework/context/event/PayloadApplicationEventTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -165,7 +165,7 @@ class PayloadApplicationEventTests { void testProgrammaticEventListener() { List events = new ArrayList<>(); ApplicationListener> listener = events::add; - ApplicationListener> mismatch = (event -> event.getPayload()); + ApplicationListener> mismatch = (PayloadApplicationEvent::getPayload); ConfigurableApplicationContext ac = new GenericApplicationContext(); ac.addApplicationListener(listener); @@ -183,7 +183,7 @@ class PayloadApplicationEventTests { void testProgrammaticEventListenerOnParentContext() { List events = new ArrayList<>(); ApplicationListener> listener = events::add; - ApplicationListener> mismatch = (event -> event.getPayload()); + ApplicationListener> mismatch = (PayloadApplicationEvent::getPayload); ConfigurableApplicationContext parent = new GenericApplicationContext(); parent.addApplicationListener(listener); diff --git a/spring-context/src/test/java/org/springframework/context/expression/CachedExpressionEvaluatorTests.java b/spring-context/src/test/java/org/springframework/context/expression/CachedExpressionEvaluatorTests.java index ceb8da3c98a..aa1764d5b27 100644 --- a/spring-context/src/test/java/org/springframework/context/expression/CachedExpressionEvaluatorTests.java +++ b/spring-context/src/test/java/org/springframework/context/expression/CachedExpressionEvaluatorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,12 +35,12 @@ import static org.mockito.Mockito.verify; /** * @author Stephane Nicoll */ -public class CachedExpressionEvaluatorTests { +class CachedExpressionEvaluatorTests { private final TestExpressionEvaluator expressionEvaluator = new TestExpressionEvaluator(); @Test - public void parseNewExpression() { + void parseNewExpression() { Method method = ReflectionUtils.findMethod(getClass(), "toString"); Expression expression = expressionEvaluator.getTestExpression("true", method, getClass()); hasParsedExpression("true"); @@ -49,7 +49,7 @@ public class CachedExpressionEvaluatorTests { } @Test - public void cacheExpression() { + void cacheExpression() { Method method = ReflectionUtils.findMethod(getClass(), "toString"); expressionEvaluator.getTestExpression("true", method, getClass()); @@ -60,7 +60,7 @@ public class CachedExpressionEvaluatorTests { } @Test - public void cacheExpressionBasedOnConcreteType() { + void cacheExpressionBasedOnConcreteType() { Method method = ReflectionUtils.findMethod(getClass(), "toString"); expressionEvaluator.getTestExpression("true", method, getClass()); expressionEvaluator.getTestExpression("true", method, Object.class); diff --git a/spring-context/src/test/java/org/springframework/context/expression/EnvironmentAccessorIntegrationTests.java b/spring-context/src/test/java/org/springframework/context/expression/EnvironmentAccessorIntegrationTests.java index 93bd12add15..189e20feda5 100644 --- a/spring-context/src/test/java/org/springframework/context/expression/EnvironmentAccessorIntegrationTests.java +++ b/spring-context/src/test/java/org/springframework/context/expression/EnvironmentAccessorIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,10 +34,10 @@ import static org.springframework.beans.factory.support.BeanDefinitionBuilder.ge * * @author Chris Beams */ -public class EnvironmentAccessorIntegrationTests { +class EnvironmentAccessorIntegrationTests { @Test - public void braceAccess() { + void braceAccess() { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); bf.registerBeanDefinition("testBean", genericBeanDefinition(TestBean.class) diff --git a/spring-context/src/test/java/org/springframework/context/expression/FactoryBeanAccessTests.java b/spring-context/src/test/java/org/springframework/context/expression/FactoryBeanAccessTests.java index d184a07710f..8aefc9b6058 100644 --- a/spring-context/src/test/java/org/springframework/context/expression/FactoryBeanAccessTests.java +++ b/spring-context/src/test/java/org/springframework/context/expression/FactoryBeanAccessTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +23,6 @@ import org.springframework.beans.factory.FactoryBean; import org.springframework.beans.factory.NoSuchBeanDefinitionException; import org.springframework.context.expression.FactoryBeanAccessTests.SimpleBeanResolver.CarFactoryBean; import org.springframework.context.support.StaticApplicationContext; -import org.springframework.expression.AccessException; import org.springframework.expression.EvaluationContext; import org.springframework.expression.Expression; import org.springframework.expression.spel.standard.SpelExpressionParser; @@ -37,10 +36,10 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; * * @author Andy Clement */ -public class FactoryBeanAccessTests { +class FactoryBeanAccessTests { @Test - public void factoryBeanAccess() { // SPR9511 + void factoryBeanAccess() { // SPR9511 StandardEvaluationContext context = new StandardEvaluationContext(); context.setBeanResolver(new SimpleBeanResolver()); Expression expr = new SpelExpressionParser().parseRaw("@car.colour"); @@ -110,8 +109,7 @@ public class FactoryBeanAccessTests { } @Override - public Object resolve(EvaluationContext context, String beanName) - throws AccessException { + public Object resolve(EvaluationContext context, String beanName) { return ac.getBean(beanName); } } diff --git a/spring-context/src/test/java/org/springframework/context/expression/MapAccessorTests.java b/spring-context/src/test/java/org/springframework/context/expression/MapAccessorTests.java index 8fd4d2fb9a9..c3e78b687d5 100644 --- a/spring-context/src/test/java/org/springframework/context/expression/MapAccessorTests.java +++ b/spring-context/src/test/java/org/springframework/context/expression/MapAccessorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,10 +33,10 @@ import static org.assertj.core.api.Assertions.assertThat; * * @author Andy Clement */ -public class MapAccessorTests { +class MapAccessorTests { @Test - public void mapAccessorCompilable() { + void mapAccessorCompilable() { Map testMap = getSimpleTestMap(); StandardEvaluationContext sec = new StandardEvaluationContext(); sec.addPropertyAccessor(new MapAccessor()); diff --git a/spring-context/src/test/java/org/springframework/context/expression/MethodBasedEvaluationContextTests.java b/spring-context/src/test/java/org/springframework/context/expression/MethodBasedEvaluationContextTests.java index f2f3b151de6..b3265ccfd21 100644 --- a/spring-context/src/test/java/org/springframework/context/expression/MethodBasedEvaluationContextTests.java +++ b/spring-context/src/test/java/org/springframework/context/expression/MethodBasedEvaluationContextTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,13 +34,13 @@ import static org.assertj.core.api.InstanceOfAssertFactories.BOOLEAN; * @author Juergen Hoeller * @author Sergey Podgurskiy */ -public class MethodBasedEvaluationContextTests { +class MethodBasedEvaluationContextTests { private final ParameterNameDiscoverer paramDiscover = new DefaultParameterNameDiscoverer(); @Test - public void simpleArguments() { + void simpleArguments() { Method method = ReflectionUtils.findMethod(SampleMethods.class, "hello", String.class, Boolean.class); MethodBasedEvaluationContext context = createEvaluationContext(method, "test", true); @@ -57,7 +57,7 @@ public class MethodBasedEvaluationContextTests { } @Test - public void nullArgument() { + void nullArgument() { Method method = ReflectionUtils.findMethod(SampleMethods.class, "hello", String.class, Boolean.class); MethodBasedEvaluationContext context = createEvaluationContext(method, null, null); @@ -71,7 +71,7 @@ public class MethodBasedEvaluationContextTests { } @Test - public void varArgEmpty() { + void varArgEmpty() { Method method = ReflectionUtils.findMethod(SampleMethods.class, "hello", Boolean.class, String[].class); MethodBasedEvaluationContext context = createEvaluationContext(method, new Object[] {null}); @@ -85,7 +85,7 @@ public class MethodBasedEvaluationContextTests { } @Test - public void varArgNull() { + void varArgNull() { Method method = ReflectionUtils.findMethod(SampleMethods.class, "hello", Boolean.class, String[].class); MethodBasedEvaluationContext context = createEvaluationContext(method, null, null); @@ -99,7 +99,7 @@ public class MethodBasedEvaluationContextTests { } @Test - public void varArgSingle() { + void varArgSingle() { Method method = ReflectionUtils.findMethod(SampleMethods.class, "hello", Boolean.class, String[].class); MethodBasedEvaluationContext context = createEvaluationContext(method, null, "hello"); @@ -113,7 +113,7 @@ public class MethodBasedEvaluationContextTests { } @Test - public void varArgMultiple() { + void varArgMultiple() { Method method = ReflectionUtils.findMethod(SampleMethods.class, "hello", Boolean.class, String[].class); MethodBasedEvaluationContext context = createEvaluationContext(method, null, "hello", "hi"); diff --git a/spring-context/src/test/java/org/springframework/context/groovy/GroovyBeanDefinitionReaderTests.java b/spring-context/src/test/java/org/springframework/context/groovy/GroovyBeanDefinitionReaderTests.java index 61db547400f..d1b3fb380fb 100644 --- a/spring-context/src/test/java/org/springframework/context/groovy/GroovyBeanDefinitionReaderTests.java +++ b/spring-context/src/test/java/org/springframework/context/groovy/GroovyBeanDefinitionReaderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -817,7 +817,7 @@ class GroovyBeanDefinitionReaderTests { } @Test - void groovyBeanDefinitionReaderWithScript() throws Exception { + void groovyBeanDefinitionReaderWithScript() { String script = """ def appCtx = new org.springframework.context.support.GenericGroovyApplicationContext() appCtx.reader.beans { diff --git a/spring-context/src/test/java/org/springframework/context/i18n/LocaleContextHolderTests.java b/spring-context/src/test/java/org/springframework/context/i18n/LocaleContextHolderTests.java index 2355c8c2786..ff9947480a0 100644 --- a/spring-context/src/test/java/org/springframework/context/i18n/LocaleContextHolderTests.java +++ b/spring-context/src/test/java/org/springframework/context/i18n/LocaleContextHolderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,10 +26,10 @@ import static org.assertj.core.api.Assertions.assertThat; /** * @author Juergen Hoeller */ -public class LocaleContextHolderTests { +class LocaleContextHolderTests { @Test - public void testSetLocaleContext() { + void testSetLocaleContext() { LocaleContext lc = new SimpleLocaleContext(Locale.GERMAN); LocaleContextHolder.setLocaleContext(lc); assertThat(LocaleContextHolder.getLocaleContext()).isSameAs(lc); @@ -49,7 +49,7 @@ public class LocaleContextHolderTests { } @Test - public void testSetTimeZoneAwareLocaleContext() { + void testSetTimeZoneAwareLocaleContext() { LocaleContext lc = new SimpleTimeZoneAwareLocaleContext(Locale.GERMANY, TimeZone.getTimeZone("GMT+1")); LocaleContextHolder.setLocaleContext(lc); assertThat(LocaleContextHolder.getLocaleContext()).isSameAs(lc); @@ -63,7 +63,7 @@ public class LocaleContextHolderTests { } @Test - public void testSetLocale() { + void testSetLocale() { LocaleContextHolder.setLocale(Locale.GERMAN); assertThat(LocaleContextHolder.getLocale()).isEqualTo(Locale.GERMAN); assertThat(LocaleContextHolder.getTimeZone()).isEqualTo(TimeZone.getDefault()); @@ -90,7 +90,7 @@ public class LocaleContextHolderTests { } @Test - public void testSetTimeZone() { + void testSetTimeZone() { LocaleContextHolder.setTimeZone(TimeZone.getTimeZone("GMT+1")); assertThat(LocaleContextHolder.getLocale()).isEqualTo(Locale.getDefault()); assertThat(LocaleContextHolder.getTimeZone()).isEqualTo(TimeZone.getTimeZone("GMT+1")); @@ -119,7 +119,7 @@ public class LocaleContextHolderTests { } @Test - public void testSetLocaleAndSetTimeZoneMixed() { + void testSetLocaleAndSetTimeZoneMixed() { LocaleContextHolder.setLocale(Locale.GERMANY); assertThat(LocaleContextHolder.getLocale()).isEqualTo(Locale.GERMANY); assertThat(LocaleContextHolder.getTimeZone()).isEqualTo(TimeZone.getDefault()); diff --git a/spring-context/src/test/java/org/springframework/context/index/CandidateComponentsIndexLoaderTests.java b/spring-context/src/test/java/org/springframework/context/index/CandidateComponentsIndexLoaderTests.java index cdf78ef8436..3434075395a 100644 --- a/spring-context/src/test/java/org/springframework/context/index/CandidateComponentsIndexLoaderTests.java +++ b/spring-context/src/test/java/org/springframework/context/index/CandidateComponentsIndexLoaderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,13 +37,13 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException; public class CandidateComponentsIndexLoaderTests { @Test - public void validateIndexIsDisabledByDefault() { + void validateIndexIsDisabledByDefault() { CandidateComponentsIndex index = CandidateComponentsIndexLoader.loadIndex(null); assertThat(index).as("No spring.components should be available at the default location").isNull(); } @Test - public void loadIndexSeveralMatches() { + void loadIndexSeveralMatches() { CandidateComponentsIndex index = CandidateComponentsIndexLoader.loadIndex( CandidateComponentsTestClassLoader.index(getClass().getClassLoader(), new ClassPathResource("spring.components", getClass()))); @@ -54,7 +54,7 @@ public class CandidateComponentsIndexLoaderTests { } @Test - public void loadIndexSingleMatch() { + void loadIndexSingleMatch() { CandidateComponentsIndex index = CandidateComponentsIndexLoader.loadIndex( CandidateComponentsTestClassLoader.index(getClass().getClassLoader(), new ClassPathResource("spring.components", getClass()))); @@ -64,7 +64,7 @@ public class CandidateComponentsIndexLoaderTests { } @Test - public void loadIndexNoMatch() { + void loadIndexNoMatch() { CandidateComponentsIndex index = CandidateComponentsIndexLoader.loadIndex( CandidateComponentsTestClassLoader.index(getClass().getClassLoader(), new ClassPathResource("spring.components", getClass()))); @@ -73,7 +73,7 @@ public class CandidateComponentsIndexLoaderTests { } @Test - public void loadIndexNoPackage() { + void loadIndexNoPackage() { CandidateComponentsIndex index = CandidateComponentsIndexLoader.loadIndex( CandidateComponentsTestClassLoader.index(getClass().getClassLoader(), new ClassPathResource("spring.components", getClass()))); @@ -82,14 +82,14 @@ public class CandidateComponentsIndexLoaderTests { } @Test - public void loadIndexNoSpringComponentsResource() { + void loadIndexNoSpringComponentsResource() { CandidateComponentsIndex index = CandidateComponentsIndexLoader.loadIndex( CandidateComponentsTestClassLoader.disableIndex(getClass().getClassLoader())); assertThat(index).isNull(); } @Test - public void loadIndexNoEntry() { + void loadIndexNoEntry() { CandidateComponentsIndex index = CandidateComponentsIndexLoader.loadIndex( CandidateComponentsTestClassLoader.index(getClass().getClassLoader(), new ClassPathResource("empty-spring.components", getClass()))); @@ -97,7 +97,7 @@ public class CandidateComponentsIndexLoaderTests { } @Test - public void loadIndexWithException() { + void loadIndexWithException() { final IOException cause = new IOException("test exception"); assertThatIllegalStateException().isThrownBy(() -> { CandidateComponentsTestClassLoader classLoader = new CandidateComponentsTestClassLoader(getClass().getClassLoader(), cause); diff --git a/spring-context/src/test/java/org/springframework/context/index/CandidateComponentsIndexTests.java b/spring-context/src/test/java/org/springframework/context/index/CandidateComponentsIndexTests.java index 80396786800..0b0b7c55675 100644 --- a/spring-context/src/test/java/org/springframework/context/index/CandidateComponentsIndexTests.java +++ b/spring-context/src/test/java/org/springframework/context/index/CandidateComponentsIndexTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,7 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat; public class CandidateComponentsIndexTests { @Test - public void getCandidateTypes() { + void getCandidateTypes() { CandidateComponentsIndex index = new CandidateComponentsIndex( Collections.singletonList(createSampleProperties())); Set actual = index.getCandidateTypes("com.example.service", "service"); @@ -44,7 +44,7 @@ public class CandidateComponentsIndexTests { } @Test - public void getCandidateTypesSubPackage() { + void getCandidateTypesSubPackage() { CandidateComponentsIndex index = new CandidateComponentsIndex( Collections.singletonList(createSampleProperties())); Set actual = index.getCandidateTypes("com.example.service.sub", "service"); @@ -52,7 +52,7 @@ public class CandidateComponentsIndexTests { } @Test - public void getCandidateTypesSubPackageNoMatch() { + void getCandidateTypesSubPackageNoMatch() { CandidateComponentsIndex index = new CandidateComponentsIndex( Collections.singletonList(createSampleProperties())); Set actual = index.getCandidateTypes("com.example.service.none", "service"); @@ -60,7 +60,7 @@ public class CandidateComponentsIndexTests { } @Test - public void getCandidateTypesNoMatch() { + void getCandidateTypesNoMatch() { CandidateComponentsIndex index = new CandidateComponentsIndex( Collections.singletonList(createSampleProperties())); Set actual = index.getCandidateTypes("com.example.service", "entity"); @@ -68,7 +68,7 @@ public class CandidateComponentsIndexTests { } @Test - public void mergeCandidateStereotypes() { + void mergeCandidateStereotypes() { CandidateComponentsIndex index = new CandidateComponentsIndex(Arrays.asList( createProperties("com.example.Foo", "service"), createProperties("com.example.Foo", "entity"))); diff --git a/spring-context/src/test/java/org/springframework/context/support/ClassPathXmlApplicationContextTests.java b/spring-context/src/test/java/org/springframework/context/support/ClassPathXmlApplicationContextTests.java index 43ec218373d..8334b28a1c5 100644 --- a/spring-context/src/test/java/org/springframework/context/support/ClassPathXmlApplicationContextTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/ClassPathXmlApplicationContextTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,7 +50,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; * @author Sam Brannen * @author Yanming Zhou */ -public class ClassPathXmlApplicationContextTests { +class ClassPathXmlApplicationContextTests { private static final String PATH = "/org/springframework/context/support/"; private static final String RESOURCE_CONTEXT = PATH + "ClassPathXmlApplicationContextTests-resource.xml"; @@ -135,7 +135,7 @@ public class ClassPathXmlApplicationContextTests { } @Test - void contextWithInvalidValueType() throws IOException { + void contextWithInvalidValueType() { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( new String[] {INVALID_VALUE_TYPE_CONTEXT}, false); assertThatExceptionOfType(BeanCreationException.class) diff --git a/spring-context/src/test/java/org/springframework/context/support/ConversionServiceFactoryBeanTests.java b/spring-context/src/test/java/org/springframework/context/support/ConversionServiceFactoryBeanTests.java index 434873ca388..90e3ccba604 100644 --- a/spring-context/src/test/java/org/springframework/context/support/ConversionServiceFactoryBeanTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/ConversionServiceFactoryBeanTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -52,6 +52,7 @@ class ConversionServiceFactoryBeanTests { } @Test + @SuppressWarnings("Convert2Lambda") void createDefaultConversionServiceWithSupplements() { ConversionServiceFactoryBean factory = new ConversionServiceFactoryBean(); Set converters = new HashSet<>(); diff --git a/spring-context/src/test/java/org/springframework/context/support/DefaultLifecycleProcessorTests.java b/spring-context/src/test/java/org/springframework/context/support/DefaultLifecycleProcessorTests.java index ad830159db0..aafabee20b0 100644 --- a/spring-context/src/test/java/org/springframework/context/support/DefaultLifecycleProcessorTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/DefaultLifecycleProcessorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -374,9 +374,8 @@ class DefaultLifecycleProcessorTests { context.refresh(); assertThat(bean.isRunning()).isTrue(); context.stop(); - assertThat(stoppedBeans).hasSize(1); assertThat(bean.isRunning()).isFalse(); - assertThat(stoppedBeans).element(0).isEqualTo(bean); + assertThat(stoppedBeans).containsExactly(bean); context.close(); } diff --git a/spring-context/src/test/java/org/springframework/context/support/EnvironmentIntegrationTests.java b/spring-context/src/test/java/org/springframework/context/support/EnvironmentIntegrationTests.java index b0c344f6f40..7bebf8838cb 100644 --- a/spring-context/src/test/java/org/springframework/context/support/EnvironmentIntegrationTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/EnvironmentIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,10 +34,10 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Chris Beams * @see org.springframework.core.env.EnvironmentSystemIntegrationTests */ -public class EnvironmentIntegrationTests { +class EnvironmentIntegrationTests { @Test - public void repro() { + void repro() { ConfigurableApplicationContext parent = new GenericApplicationContext(); parent.refresh(); diff --git a/spring-context/src/test/java/org/springframework/context/support/FactoryBeanAndApplicationListener.java b/spring-context/src/test/java/org/springframework/context/support/FactoryBeanAndApplicationListener.java index c392ed73e7d..86b14ee276a 100644 --- a/spring-context/src/test/java/org/springframework/context/support/FactoryBeanAndApplicationListener.java +++ b/spring-context/src/test/java/org/springframework/context/support/FactoryBeanAndApplicationListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,7 +27,7 @@ import org.springframework.context.ApplicationListener; public class FactoryBeanAndApplicationListener implements FactoryBean, ApplicationListener { @Override - public String getObject() throws Exception { + public String getObject() { return ""; } diff --git a/spring-context/src/test/java/org/springframework/context/support/GenericApplicationContextTests.java b/spring-context/src/test/java/org/springframework/context/support/GenericApplicationContextTests.java index 34dd2402faf..c96b05b3b1a 100644 --- a/spring-context/src/test/java/org/springframework/context/support/GenericApplicationContextTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/GenericApplicationContextTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -242,9 +242,9 @@ class GenericApplicationContextTests { assertThat(context.getBeanNamesForType(BeanB.class)).containsExactly("b"); assertThat(context.getBeanNamesForType(BeanC.class)).containsExactly("c"); assertThat(context.getBeansOfType(BeanA.class)).isEmpty(); - assertThat(context.getBeansOfType(BeanB.class).values()).element(0) + assertThat(context.getBeansOfType(BeanB.class).values()).singleElement() .isSameAs(context.getBean(BeanB.class)); - assertThat(context.getBeansOfType(BeanC.class).values()).element(0) + assertThat(context.getBeansOfType(BeanC.class).values()).singleElement() .isSameAs(context.getBean(BeanC.class)); } @@ -691,7 +691,7 @@ class GenericApplicationContextTests { private boolean destroyed; @Override - public void afterPropertiesSet() throws Exception { + public void afterPropertiesSet() { if (initialized) { throw new IllegalStateException("AfterPropertiesSet called twice"); } @@ -699,7 +699,7 @@ class GenericApplicationContextTests { } @Override - public void destroy() throws Exception { + public void destroy() { if (destroyed) { throw new IllegalStateException("Destroy called twice"); } diff --git a/spring-context/src/test/java/org/springframework/context/support/NoOpAdvice.java b/spring-context/src/test/java/org/springframework/context/support/NoOpAdvice.java index 0ade47c074d..a8822483170 100644 --- a/spring-context/src/test/java/org/springframework/context/support/NoOpAdvice.java +++ b/spring-context/src/test/java/org/springframework/context/support/NoOpAdvice.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,7 +25,7 @@ import org.springframework.aop.ThrowsAdvice; */ public class NoOpAdvice implements ThrowsAdvice { - public void afterThrowing(Exception ex) throws Throwable { + public void afterThrowing(Exception ex) { // no-op } diff --git a/spring-context/src/test/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurerTests.java b/spring-context/src/test/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurerTests.java index 89a818a5701..45bddd43461 100644 --- a/spring-context/src/test/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurerTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -52,10 +52,10 @@ import static org.springframework.beans.factory.support.BeanDefinitionBuilder.ro * @author Sam Brannen * @since 3.1 */ -public class PropertySourcesPlaceholderConfigurerTests { +class PropertySourcesPlaceholderConfigurerTests { @Test - public void replacementFromEnvironmentProperties() { + void replacementFromEnvironmentProperties() { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); bf.registerBeanDefinition("testBean", genericBeanDefinition(TestBean.class) @@ -73,7 +73,7 @@ public class PropertySourcesPlaceholderConfigurerTests { } @Test - public void localPropertiesViaResource() { + void localPropertiesViaResource() { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); bf.registerBeanDefinition("testBean", genericBeanDefinition(TestBean.class) @@ -88,17 +88,17 @@ public class PropertySourcesPlaceholderConfigurerTests { } @Test - public void localPropertiesOverrideFalse() { + void localPropertiesOverrideFalse() { localPropertiesOverride(false); } @Test - public void localPropertiesOverrideTrue() { + void localPropertiesOverrideTrue() { localPropertiesOverride(true); } @Test - public void explicitPropertySources() { + void explicitPropertySources() { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); bf.registerBeanDefinition("testBean", genericBeanDefinition(TestBean.class) @@ -116,7 +116,7 @@ public class PropertySourcesPlaceholderConfigurerTests { } @Test - public void explicitPropertySourcesExcludesEnvironment() { + void explicitPropertySourcesExcludesEnvironment() { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); bf.registerBeanDefinition("testBean", genericBeanDefinition(TestBean.class) @@ -158,7 +158,7 @@ public class PropertySourcesPlaceholderConfigurerTests { } @Test - public void ignoreUnresolvablePlaceholders_falseIsDefault() { + void ignoreUnresolvablePlaceholders_falseIsDefault() { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); bf.registerBeanDefinition("testBean", genericBeanDefinition(TestBean.class) @@ -175,7 +175,7 @@ public class PropertySourcesPlaceholderConfigurerTests { } @Test - public void ignoreUnresolvablePlaceholders_true() { + void ignoreUnresolvablePlaceholders_true() { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); bf.registerBeanDefinition("testBean", genericBeanDefinition(TestBean.class) @@ -256,7 +256,7 @@ public class PropertySourcesPlaceholderConfigurerTests { } @Test - public void withNonEnumerablePropertySource() { + void withNonEnumerablePropertySource() { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); bf.registerBeanDefinition("testBean", genericBeanDefinition(TestBean.class) @@ -305,7 +305,7 @@ public class PropertySourcesPlaceholderConfigurerTests { } @Test - public void customPlaceholderPrefixAndSuffix() { + void customPlaceholderPrefixAndSuffix() { PropertySourcesPlaceholderConfigurer ppc = new PropertySourcesPlaceholderConfigurer(); ppc.setPlaceholderPrefix("@<"); ppc.setPlaceholderSuffix(">"); @@ -329,7 +329,7 @@ public class PropertySourcesPlaceholderConfigurerTests { } @Test - public void nullValueIsPreserved() { + void nullValueIsPreserved() { PropertySourcesPlaceholderConfigurer ppc = new PropertySourcesPlaceholderConfigurer(); ppc.setNullValue("customNull"); DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); @@ -342,7 +342,7 @@ public class PropertySourcesPlaceholderConfigurerTests { } @Test - public void trimValuesIsOffByDefault() { + void trimValuesIsOffByDefault() { PropertySourcesPlaceholderConfigurer ppc = new PropertySourcesPlaceholderConfigurer(); DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); bf.registerBeanDefinition("testBean", rootBeanDefinition(TestBean.class) @@ -354,7 +354,7 @@ public class PropertySourcesPlaceholderConfigurerTests { } @Test - public void trimValuesIsApplied() { + void trimValuesIsApplied() { PropertySourcesPlaceholderConfigurer ppc = new PropertySourcesPlaceholderConfigurer(); ppc.setTrimValues(true); DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); @@ -367,14 +367,14 @@ public class PropertySourcesPlaceholderConfigurerTests { } @Test - public void getAppliedPropertySourcesTooEarly() throws Exception { + void getAppliedPropertySourcesTooEarly() { PropertySourcesPlaceholderConfigurer ppc = new PropertySourcesPlaceholderConfigurer(); assertThatIllegalStateException().isThrownBy( ppc::getAppliedPropertySources); } @Test - public void multipleLocationsWithDefaultResolvedValue() throws Exception { + void multipleLocationsWithDefaultResolvedValue() { // SPR-10619 PropertySourcesPlaceholderConfigurer ppc = new PropertySourcesPlaceholderConfigurer(); ClassPathResource doesNotHave = new ClassPathResource("test.properties", getClass()); @@ -392,7 +392,7 @@ public class PropertySourcesPlaceholderConfigurerTests { } @Test - public void optionalPropertyWithValue() { + void optionalPropertyWithValue() { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); bf.setConversionService(new DefaultConversionService()); bf.registerBeanDefinition("testBean", @@ -411,7 +411,7 @@ public class PropertySourcesPlaceholderConfigurerTests { } @Test - public void optionalPropertyWithoutValue() { + void optionalPropertyWithoutValue() { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); bf.setConversionService(new DefaultConversionService()); bf.registerBeanDefinition("testBean", diff --git a/spring-context/src/test/java/org/springframework/context/support/ResourceBundleMessageSourceTests.java b/spring-context/src/test/java/org/springframework/context/support/ResourceBundleMessageSourceTests.java index 103a7a314b3..514356b3bbf 100644 --- a/spring-context/src/test/java/org/springframework/context/support/ResourceBundleMessageSourceTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/ResourceBundleMessageSourceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -401,29 +401,19 @@ class ResourceBundleMessageSourceTests { ReloadableResourceBundleMessageSource ms = new ReloadableResourceBundleMessageSource(); List filenames = ms.calculateFilenamesForLocale("messages", Locale.ENGLISH); - assertThat(filenames).hasSize(1); - assertThat(filenames).element(0).isEqualTo("messages_en"); + assertThat(filenames).containsExactly("messages_en"); filenames = ms.calculateFilenamesForLocale("messages", Locale.UK); - assertThat(filenames).hasSize(2); - assertThat(filenames).element(1).isEqualTo("messages_en"); - assertThat(filenames).element(0).isEqualTo("messages_en_GB"); + assertThat(filenames).containsExactly("messages_en_GB", "messages_en"); filenames = ms.calculateFilenamesForLocale("messages", new Locale("en", "GB", "POSIX")); - assertThat(filenames).hasSize(3); - assertThat(filenames).element(2).isEqualTo("messages_en"); - assertThat(filenames).element(1).isEqualTo("messages_en_GB"); - assertThat(filenames).element(0).isEqualTo("messages_en_GB_POSIX"); + assertThat(filenames).containsExactly("messages_en_GB_POSIX","messages_en_GB", "messages_en"); filenames = ms.calculateFilenamesForLocale("messages", new Locale("en", "", "POSIX")); - assertThat(filenames).hasSize(2); - assertThat(filenames).element(1).isEqualTo("messages_en"); - assertThat(filenames).element(0).isEqualTo("messages_en__POSIX"); + assertThat(filenames).containsExactly("messages_en__POSIX", "messages_en"); filenames = ms.calculateFilenamesForLocale("messages", new Locale("", "UK", "POSIX")); - assertThat(filenames).hasSize(2); - assertThat(filenames).element(1).isEqualTo("messages__UK"); - assertThat(filenames).element(0).isEqualTo("messages__UK_POSIX"); + assertThat(filenames).containsExactly("messages__UK_POSIX", "messages__UK"); filenames = ms.calculateFilenamesForLocale("messages", new Locale("", "", "POSIX")); assertThat(filenames).isEmpty(); diff --git a/spring-context/src/test/java/org/springframework/context/support/SerializableBeanFactoryMemoryLeakTests.java b/spring-context/src/test/java/org/springframework/context/support/SerializableBeanFactoryMemoryLeakTests.java index 45aaac584dd..7abb691ecad 100644 --- a/spring-context/src/test/java/org/springframework/context/support/SerializableBeanFactoryMemoryLeakTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/SerializableBeanFactoryMemoryLeakTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,7 +36,7 @@ import static org.springframework.beans.factory.support.BeanDefinitionBuilder.ro * * @author Chris Beams */ -public class SerializableBeanFactoryMemoryLeakTests { +class SerializableBeanFactoryMemoryLeakTests { /** * Defensively zero-out static factory count - other tests @@ -49,24 +49,24 @@ public class SerializableBeanFactoryMemoryLeakTests { } @Test - public void genericContext() throws Exception { + void genericContext() throws Exception { assertFactoryCountThroughoutLifecycle(new GenericApplicationContext()); } @Test - public void abstractRefreshableContext() throws Exception { + void abstractRefreshableContext() throws Exception { assertFactoryCountThroughoutLifecycle(new ClassPathXmlApplicationContext()); } @Test - public void genericContextWithMisconfiguredBean() throws Exception { + void genericContextWithMisconfiguredBean() throws Exception { GenericApplicationContext ctx = new GenericApplicationContext(); registerMisconfiguredBeanDefinition(ctx); assertFactoryCountThroughoutLifecycle(ctx); } @Test - public void abstractRefreshableContextWithMisconfiguredBean() throws Exception { + void abstractRefreshableContextWithMisconfiguredBean() throws Exception { ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext() { @Override protected void customizeBeanFactory(DefaultListableBeanFactory beanFactory) { diff --git a/spring-context/src/test/java/org/springframework/context/support/Service.java b/spring-context/src/test/java/org/springframework/context/support/Service.java index 3c9a99d95aa..0c177d36fe6 100644 --- a/spring-context/src/test/java/org/springframework/context/support/Service.java +++ b/spring-context/src/test/java/org/springframework/context/support/Service.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -81,21 +81,18 @@ public class Service implements ApplicationContextAware, MessageSourceAware, Dis @Override public void destroy() { this.properlyDestroyed = true; - Thread thread = new Thread() { - @Override - public void run() { - Assert.state(applicationContext.getBean("messageSource") instanceof StaticMessageSource, - "Invalid MessageSource bean"); - try { - applicationContext.getBean("service2"); - // Should have thrown BeanCreationNotAllowedException - properlyDestroyed = false; - } - catch (BeanCreationNotAllowedException ex) { - // expected - } + Thread thread = new Thread(() -> { + Assert.state(applicationContext.getBean("messageSource") instanceof StaticMessageSource, + "Invalid MessageSource bean"); + try { + applicationContext.getBean("service2"); + // Should have thrown BeanCreationNotAllowedException + properlyDestroyed = false; } - }; + catch (BeanCreationNotAllowedException ex) { + // expected + } + }); thread.start(); try { thread.join(); diff --git a/spring-context/src/test/java/org/springframework/context/support/SimpleThreadScopeTests.java b/spring-context/src/test/java/org/springframework/context/support/SimpleThreadScopeTests.java index 3119d051f49..64b21891655 100644 --- a/spring-context/src/test/java/org/springframework/context/support/SimpleThreadScopeTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/SimpleThreadScopeTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,7 +37,7 @@ class SimpleThreadScopeTests { @Test - void getFromScope() throws Exception { + void getFromScope() { String name = "removeNodeStatusScreen"; TestBean bean = this.applicationContext.getBean(name, TestBean.class); assertThat(bean).isNotNull(); @@ -47,7 +47,7 @@ class SimpleThreadScopeTests { } @Test - void getMultipleInstances() throws Exception { + void getMultipleInstances() { // Arrange TestBean[] beans = new TestBean[2]; Thread thread1 = new Thread(() -> beans[0] = applicationContext.getBean("removeNodeStatusScreen", TestBean.class)); diff --git a/spring-context/src/test/java/org/springframework/context/support/StaticApplicationContextMulticasterTests.java b/spring-context/src/test/java/org/springframework/context/support/StaticApplicationContextMulticasterTests.java index a4bff1100c9..62535c0d272 100644 --- a/spring-context/src/test/java/org/springframework/context/support/StaticApplicationContextMulticasterTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/StaticApplicationContextMulticasterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,13 +43,13 @@ import static org.assertj.core.api.Assertions.assertThat; * * @author Juergen Hoeller */ -public class StaticApplicationContextMulticasterTests extends AbstractApplicationContextTests { +class StaticApplicationContextMulticasterTests extends AbstractApplicationContextTests { protected StaticApplicationContext sac; @SuppressWarnings("deprecation") @Override - protected ConfigurableApplicationContext createContext() throws Exception { + protected ConfigurableApplicationContext createContext() { StaticApplicationContext parent = new StaticApplicationContext(); Map m = new HashMap<>(); m.put("name", "Roderick"); diff --git a/spring-context/src/test/java/org/springframework/context/support/StaticApplicationContextTests.java b/spring-context/src/test/java/org/springframework/context/support/StaticApplicationContextTests.java index 023efd449bb..a6e8e9acc11 100644 --- a/spring-context/src/test/java/org/springframework/context/support/StaticApplicationContextTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/StaticApplicationContextTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,13 +35,13 @@ import org.springframework.core.io.ClassPathResource; * * @author Rod Johnson */ -public class StaticApplicationContextTests extends AbstractApplicationContextTests { +class StaticApplicationContextTests extends AbstractApplicationContextTests { protected StaticApplicationContext sac; @SuppressWarnings("deprecation") @Override - protected ConfigurableApplicationContext createContext() throws Exception { + protected ConfigurableApplicationContext createContext() { StaticApplicationContext parent = new StaticApplicationContext(); Map m = new HashMap<>(); m.put("name", "Roderick"); diff --git a/spring-context/src/test/java/org/springframework/context/support/StaticMessageSourceTests.java b/spring-context/src/test/java/org/springframework/context/support/StaticMessageSourceTests.java index 8596f602be7..06a94f73a92 100644 --- a/spring-context/src/test/java/org/springframework/context/support/StaticMessageSourceTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/StaticMessageSourceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,7 +41,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; * @author Juergen Hoeller * @author Sam Brannen */ -public class StaticMessageSourceTests extends AbstractApplicationContextTests { +class StaticMessageSourceTests extends AbstractApplicationContextTests { protected static final String MSG_TXT1_US = "At '{1,time}' on \"{1,date}\", there was \"{2}\" on planet {0,number,integer}."; @@ -68,14 +68,14 @@ public class StaticMessageSourceTests extends AbstractApplicationContextTests { } @Test - public void getMessageWithDefaultPassedInAndFoundInMsgCatalog() { + void getMessageWithDefaultPassedInAndFoundInMsgCatalog() { // Try with Locale.US assertThat(sac.getMessage("message.format.example2", null, "This is a default msg if not found in MessageSource.", Locale.US)).as("valid msg from staticMsgSource with default msg passed in returned msg from msg catalog for Locale.US") .isEqualTo("This is a test message in the message catalog with no args."); } @Test - public void getMessageWithDefaultPassedInAndNotFoundInMsgCatalog() { + void getMessageWithDefaultPassedInAndNotFoundInMsgCatalog() { // Try with Locale.US assertThat(sac.getMessage("bogus.message", null, "This is a default msg if not found in MessageSource.", Locale.US)).as("bogus msg from staticMsgSource with default msg passed in returned default msg for Locale.US") .isEqualTo("This is a default msg if not found in MessageSource."); @@ -89,7 +89,7 @@ public class StaticMessageSourceTests extends AbstractApplicationContextTests { * @see org.springframework.context.support.AbstractMessageSource for more details. */ @Test - public void getMessageWithMessageAlreadyLookedFor() { + void getMessageWithMessageAlreadyLookedFor() { Object[] arguments = { 7, new Date(System.currentTimeMillis()), "a disturbance in the Force" @@ -117,7 +117,7 @@ public class StaticMessageSourceTests extends AbstractApplicationContextTests { * Example taken from the javadocs for the java.text.MessageFormat class */ @Test - public void getMessageWithNoDefaultPassedInAndFoundInMsgCatalog() { + void getMessageWithNoDefaultPassedInAndFoundInMsgCatalog() { Object[] arguments = { 7, new Date(System.currentTimeMillis()), "a disturbance in the Force" @@ -144,14 +144,14 @@ public class StaticMessageSourceTests extends AbstractApplicationContextTests { } @Test - public void getMessageWithNoDefaultPassedInAndNotFoundInMsgCatalog() { + void getMessageWithNoDefaultPassedInAndNotFoundInMsgCatalog() { // Try with Locale.US assertThatExceptionOfType(NoSuchMessageException.class).isThrownBy(() -> sac.getMessage("bogus.message", null, Locale.US)); } @Test - public void messageSourceResolvable() { + void messageSourceResolvable() { // first code valid String[] codes1 = new String[] {"message.format.example3", "message.format.example2"}; MessageSourceResolvable resolvable1 = new DefaultMessageSourceResolvable(codes1, null, "default"); @@ -177,7 +177,7 @@ public class StaticMessageSourceTests extends AbstractApplicationContextTests { @SuppressWarnings("deprecation") @Override - protected ConfigurableApplicationContext createContext() throws Exception { + protected ConfigurableApplicationContext createContext() { StaticApplicationContext parent = new StaticApplicationContext(); Map m = new HashMap<>(); @@ -215,7 +215,7 @@ public class StaticMessageSourceTests extends AbstractApplicationContextTests { } @Test - public void nestedMessageSourceWithParamInChild() { + void nestedMessageSourceWithParamInChild() { StaticMessageSource source = new StaticMessageSource(); StaticMessageSource parent = new StaticMessageSource(); source.setParentMessageSource(parent); @@ -230,7 +230,7 @@ public class StaticMessageSourceTests extends AbstractApplicationContextTests { } @Test - public void nestedMessageSourceWithParamInParent() { + void nestedMessageSourceWithParamInParent() { StaticMessageSource source = new StaticMessageSource(); StaticMessageSource parent = new StaticMessageSource(); source.setParentMessageSource(parent); diff --git a/spring-context/src/test/java/org/springframework/ejb/config/JeeNamespaceHandlerEventTests.java b/spring-context/src/test/java/org/springframework/ejb/config/JeeNamespaceHandlerEventTests.java index 71692278a41..1f02174dcb1 100644 --- a/spring-context/src/test/java/org/springframework/ejb/config/JeeNamespaceHandlerEventTests.java +++ b/spring-context/src/test/java/org/springframework/ejb/config/JeeNamespaceHandlerEventTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,7 +33,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Juergen Hoeller * @author Chris Beams */ -public class JeeNamespaceHandlerEventTests { +class JeeNamespaceHandlerEventTests { private final CollectingReaderEventListener eventListener = new CollectingReaderEventListener(); @@ -43,7 +43,7 @@ public class JeeNamespaceHandlerEventTests { @BeforeEach - public void setup() throws Exception { + void setup() { this.reader = new XmlBeanDefinitionReader(this.beanFactory); this.reader.setEventListener(this.eventListener); this.reader.loadBeanDefinitions(new ClassPathResource("jeeNamespaceHandlerTests.xml", getClass())); @@ -51,21 +51,21 @@ public class JeeNamespaceHandlerEventTests { @Test - public void testJndiLookupComponentEventReceived() { + void testJndiLookupComponentEventReceived() { ComponentDefinition component = this.eventListener.getComponentDefinition("simple"); boolean condition = component instanceof BeanComponentDefinition; assertThat(condition).isTrue(); } @Test - public void testLocalSlsbComponentEventReceived() { + void testLocalSlsbComponentEventReceived() { ComponentDefinition component = this.eventListener.getComponentDefinition("simpleLocalEjb"); boolean condition = component instanceof BeanComponentDefinition; assertThat(condition).isTrue(); } @Test - public void testRemoteSlsbComponentEventReceived() { + void testRemoteSlsbComponentEventReceived() { ComponentDefinition component = this.eventListener.getComponentDefinition("simpleRemoteEjb"); boolean condition = component instanceof BeanComponentDefinition; assertThat(condition).isTrue(); diff --git a/spring-context/src/test/java/org/springframework/ejb/config/JeeNamespaceHandlerTests.java b/spring-context/src/test/java/org/springframework/ejb/config/JeeNamespaceHandlerTests.java index 862484d7d8f..b2d3777b583 100644 --- a/spring-context/src/test/java/org/springframework/ejb/config/JeeNamespaceHandlerTests.java +++ b/spring-context/src/test/java/org/springframework/ejb/config/JeeNamespaceHandlerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,13 +40,13 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; * @author Chris Beams * @author Oliver Gierke */ -public class JeeNamespaceHandlerTests { +class JeeNamespaceHandlerTests { private ConfigurableListableBeanFactory beanFactory; @BeforeEach - public void setup() { + void setup() { GenericApplicationContext ctx = new GenericApplicationContext(); new XmlBeanDefinitionReader(ctx).loadBeanDefinitions( new ClassPathResource("jeeNamespaceHandlerTests.xml", getClass())); @@ -57,7 +57,7 @@ public class JeeNamespaceHandlerTests { @Test - public void testSimpleDefinition() { + void testSimpleDefinition() { BeanDefinition beanDefinition = this.beanFactory.getMergedBeanDefinition("simple"); assertThat(beanDefinition.getBeanClassName()).isEqualTo(JndiObjectFactoryBean.class.getName()); assertPropertyValue(beanDefinition, "jndiName", "jdbc/MyDataSource"); @@ -65,7 +65,7 @@ public class JeeNamespaceHandlerTests { } @Test - public void testComplexDefinition() { + void testComplexDefinition() { BeanDefinition beanDefinition = this.beanFactory.getMergedBeanDefinition("complex"); assertThat(beanDefinition.getBeanClassName()).isEqualTo(JndiObjectFactoryBean.class.getName()); assertPropertyValue(beanDefinition, "jndiName", "jdbc/MyDataSource"); @@ -79,21 +79,21 @@ public class JeeNamespaceHandlerTests { } @Test - public void testWithEnvironment() { + void testWithEnvironment() { BeanDefinition beanDefinition = this.beanFactory.getMergedBeanDefinition("withEnvironment"); assertPropertyValue(beanDefinition, "jndiEnvironment", "foo=bar"); assertPropertyValue(beanDefinition, "defaultObject", new RuntimeBeanReference("myBean")); } @Test - public void testWithReferencedEnvironment() { + void testWithReferencedEnvironment() { BeanDefinition beanDefinition = this.beanFactory.getMergedBeanDefinition("withReferencedEnvironment"); assertPropertyValue(beanDefinition, "jndiEnvironment", new RuntimeBeanReference("myEnvironment")); assertThat(beanDefinition.getPropertyValues().contains("environmentRef")).isFalse(); } @Test - public void testSimpleLocalSlsb() { + void testSimpleLocalSlsb() { BeanDefinition beanDefinition = this.beanFactory.getMergedBeanDefinition("simpleLocalEjb"); assertThat(beanDefinition.getBeanClassName()).isEqualTo(JndiObjectFactoryBean.class.getName()); assertPropertyValue(beanDefinition, "jndiName", "ejb/MyLocalBean"); @@ -104,7 +104,7 @@ public class JeeNamespaceHandlerTests { } @Test - public void testSimpleRemoteSlsb() { + void testSimpleRemoteSlsb() { BeanDefinition beanDefinition = this.beanFactory.getMergedBeanDefinition("simpleRemoteEjb"); assertThat(beanDefinition.getBeanClassName()).isEqualTo(JndiObjectFactoryBean.class.getName()); assertPropertyValue(beanDefinition, "jndiName", "ejb/MyRemoteBean"); @@ -115,7 +115,7 @@ public class JeeNamespaceHandlerTests { } @Test - public void testComplexLocalSlsb() { + void testComplexLocalSlsb() { BeanDefinition beanDefinition = this.beanFactory.getMergedBeanDefinition("complexLocalEjb"); assertThat(beanDefinition.getBeanClassName()).isEqualTo(JndiObjectFactoryBean.class.getName()); assertPropertyValue(beanDefinition, "jndiName", "ejb/MyLocalBean"); @@ -126,7 +126,7 @@ public class JeeNamespaceHandlerTests { } @Test - public void testComplexRemoteSlsb() { + void testComplexRemoteSlsb() { BeanDefinition beanDefinition = this.beanFactory.getMergedBeanDefinition("complexRemoteEjb"); assertThat(beanDefinition.getBeanClassName()).isEqualTo(JndiObjectFactoryBean.class.getName()); assertPropertyValue(beanDefinition, "jndiName", "ejb/MyRemoteBean"); @@ -137,7 +137,7 @@ public class JeeNamespaceHandlerTests { } @Test - public void testLazyInitJndiLookup() { + void testLazyInitJndiLookup() { BeanDefinition definition = this.beanFactory.getMergedBeanDefinition("lazyDataSource"); assertThat(definition.isLazyInit()).isTrue(); definition = this.beanFactory.getMergedBeanDefinition("lazyLocalBean"); diff --git a/spring-context/src/test/java/org/springframework/format/datetime/DateFormatterTests.java b/spring-context/src/test/java/org/springframework/format/datetime/DateFormatterTests.java index d085e4d622f..0335da8bb68 100644 --- a/spring-context/src/test/java/org/springframework/format/datetime/DateFormatterTests.java +++ b/spring-context/src/test/java/org/springframework/format/datetime/DateFormatterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,13 +36,13 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException; * @author Keith Donald * @author Phillip Webb */ -public class DateFormatterTests { +class DateFormatterTests { private static final TimeZone UTC = TimeZone.getTimeZone("UTC"); @Test - public void shouldPrintAndParseDefault() throws Exception { + void shouldPrintAndParseDefault() throws Exception { DateFormatter formatter = new DateFormatter(); formatter.setTimeZone(UTC); Date date = getDate(2009, Calendar.JUNE, 1); @@ -51,7 +51,7 @@ public class DateFormatterTests { } @Test - public void shouldPrintAndParseFromPattern() throws ParseException { + void shouldPrintAndParseFromPattern() throws ParseException { DateFormatter formatter = new DateFormatter("yyyy-MM-dd"); formatter.setTimeZone(UTC); Date date = getDate(2009, Calendar.JUNE, 1); @@ -60,7 +60,7 @@ public class DateFormatterTests { } @Test - public void shouldPrintAndParseShort() throws Exception { + void shouldPrintAndParseShort() throws Exception { DateFormatter formatter = new DateFormatter(); formatter.setTimeZone(UTC); formatter.setStyle(DateFormat.SHORT); @@ -70,7 +70,7 @@ public class DateFormatterTests { } @Test - public void shouldPrintAndParseMedium() throws Exception { + void shouldPrintAndParseMedium() throws Exception { DateFormatter formatter = new DateFormatter(); formatter.setTimeZone(UTC); formatter.setStyle(DateFormat.MEDIUM); @@ -80,7 +80,7 @@ public class DateFormatterTests { } @Test - public void shouldPrintAndParseLong() throws Exception { + void shouldPrintAndParseLong() throws Exception { DateFormatter formatter = new DateFormatter(); formatter.setTimeZone(UTC); formatter.setStyle(DateFormat.LONG); @@ -90,7 +90,7 @@ public class DateFormatterTests { } @Test - public void shouldPrintAndParseFull() throws Exception { + void shouldPrintAndParseFull() throws Exception { DateFormatter formatter = new DateFormatter(); formatter.setTimeZone(UTC); formatter.setStyle(DateFormat.FULL); @@ -100,7 +100,7 @@ public class DateFormatterTests { } @Test - public void shouldPrintAndParseISODate() throws Exception { + void shouldPrintAndParseISODate() throws Exception { DateFormatter formatter = new DateFormatter(); formatter.setTimeZone(UTC); formatter.setIso(ISO.DATE); @@ -111,7 +111,7 @@ public class DateFormatterTests { } @Test - public void shouldPrintAndParseISOTime() throws Exception { + void shouldPrintAndParseISOTime() throws Exception { DateFormatter formatter = new DateFormatter(); formatter.setTimeZone(UTC); formatter.setIso(ISO.TIME); @@ -122,7 +122,7 @@ public class DateFormatterTests { } @Test - public void shouldPrintAndParseISODateTime() throws Exception { + void shouldPrintAndParseISODateTime() throws Exception { DateFormatter formatter = new DateFormatter(); formatter.setTimeZone(UTC); formatter.setIso(ISO.DATE_TIME); @@ -132,7 +132,7 @@ public class DateFormatterTests { } @Test - public void shouldThrowOnUnsupportedStylePattern() throws Exception { + void shouldThrowOnUnsupportedStylePattern() { DateFormatter formatter = new DateFormatter(); formatter.setStylePattern("OO"); assertThatIllegalStateException().isThrownBy(() -> @@ -141,7 +141,7 @@ public class DateFormatterTests { } @Test - public void shouldUseCorrectOrder() throws Exception { + void shouldUseCorrectOrder() { DateFormatter formatter = new DateFormatter(); formatter.setTimeZone(UTC); formatter.setStyle(DateFormat.SHORT); diff --git a/spring-context/src/test/java/org/springframework/format/datetime/DateFormattingTests.java b/spring-context/src/test/java/org/springframework/format/datetime/DateFormattingTests.java index 2ea58f5e06a..6f7751545e3 100644 --- a/spring-context/src/test/java/org/springframework/format/datetime/DateFormattingTests.java +++ b/spring-context/src/test/java/org/springframework/format/datetime/DateFormattingTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -52,7 +52,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Juergen Hoeller * @author Sam Brannen */ -public class DateFormattingTests { +class DateFormattingTests { private final FormattingConversionService conversionService = new FormattingConversionService(); diff --git a/spring-context/src/test/java/org/springframework/format/datetime/standard/DateTimeFormatterFactoryBeanTests.java b/spring-context/src/test/java/org/springframework/format/datetime/standard/DateTimeFormatterFactoryBeanTests.java index eb3b3ea126d..0f1afed6aed 100644 --- a/spring-context/src/test/java/org/springframework/format/datetime/standard/DateTimeFormatterFactoryBeanTests.java +++ b/spring-context/src/test/java/org/springframework/format/datetime/standard/DateTimeFormatterFactoryBeanTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,29 +31,29 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Phillip Webb * @author Sam Brannen */ -public class DateTimeFormatterFactoryBeanTests { +class DateTimeFormatterFactoryBeanTests { private final DateTimeFormatterFactoryBean factory = new DateTimeFormatterFactoryBean(); @Test - public void isSingleton() { + void isSingleton() { assertThat(factory.isSingleton()).isTrue(); } @Test - public void getObjectType() { + void getObjectType() { assertThat(factory.getObjectType()).isEqualTo(DateTimeFormatter.class); } @Test - public void getObject() { + void getObject() { factory.afterPropertiesSet(); assertThat(factory.getObject().toString()).isEqualTo(DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM).toString()); } @Test - public void getObjectIsAlwaysSingleton() { + void getObjectIsAlwaysSingleton() { factory.afterPropertiesSet(); DateTimeFormatter formatter = factory.getObject(); assertThat(formatter.toString()).isEqualTo(DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM).toString()); diff --git a/spring-context/src/test/java/org/springframework/format/datetime/standard/DateTimeFormatterFactoryTests.java b/spring-context/src/test/java/org/springframework/format/datetime/standard/DateTimeFormatterFactoryTests.java index 4e98db21a5e..c2b44e3f3d3 100644 --- a/spring-context/src/test/java/org/springframework/format/datetime/standard/DateTimeFormatterFactoryTests.java +++ b/spring-context/src/test/java/org/springframework/format/datetime/standard/DateTimeFormatterFactoryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,7 +34,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Phillip Webb * @author Sam Brannen */ -public class DateTimeFormatterFactoryTests { +class DateTimeFormatterFactoryTests { // Potential test timezone, both have daylight savings on October 21st private static final TimeZone ZURICH = TimeZone.getTimeZone("Europe/Zurich"); @@ -50,32 +50,32 @@ public class DateTimeFormatterFactoryTests { @Test - public void createDateTimeFormatter() { + void createDateTimeFormatter() { assertThat(factory.createDateTimeFormatter().toString()).isEqualTo(DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM).toString()); } @Test - public void createDateTimeFormatterWithPattern() { + void createDateTimeFormatterWithPattern() { factory = new DateTimeFormatterFactory("yyyyMMddHHmmss"); DateTimeFormatter formatter = factory.createDateTimeFormatter(); assertThat(formatter.format(dateTime)).isEqualTo("20091021121000"); } @Test - public void createDateTimeFormatterWithNullFallback() { + void createDateTimeFormatterWithNullFallback() { DateTimeFormatter formatter = factory.createDateTimeFormatter(null); assertThat(formatter).isNull(); } @Test - public void createDateTimeFormatterWithFallback() { + void createDateTimeFormatterWithFallback() { DateTimeFormatter fallback = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.LONG); DateTimeFormatter formatter = factory.createDateTimeFormatter(fallback); assertThat(formatter).isSameAs(fallback); } @Test - public void createDateTimeFormatterInOrderOfPropertyPriority() { + void createDateTimeFormatterInOrderOfPropertyPriority() { factory.setStylePattern("SS"); String value = applyLocale(factory.createDateTimeFormatter()).format(dateTime); assertThat(value).startsWith("10/21/09"); @@ -89,7 +89,7 @@ public class DateTimeFormatterFactoryTests { } @Test - public void createDateTimeFormatterWithTimeZone() { + void createDateTimeFormatterWithTimeZone() { factory.setPattern("yyyyMMddHHmmss Z"); factory.setTimeZone(TEST_TIMEZONE); ZoneId dateTimeZone = TEST_TIMEZONE.toZoneId(); diff --git a/spring-context/src/test/java/org/springframework/format/datetime/standard/DateTimeFormattingTests.java b/spring-context/src/test/java/org/springframework/format/datetime/standard/DateTimeFormattingTests.java index 8d072dec857..3a2bd371c6c 100644 --- a/spring-context/src/test/java/org/springframework/format/datetime/standard/DateTimeFormattingTests.java +++ b/spring-context/src/test/java/org/springframework/format/datetime/standard/DateTimeFormattingTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -512,7 +512,7 @@ class DateTimeFormattingTests { } @Test - public void testBindYearMonthAnnotatedPattern() { + void testBindYearMonthAnnotatedPattern() { MutablePropertyValues propertyValues = new MutablePropertyValues(); propertyValues.add("yearMonthAnnotatedPattern", "12/2007"); binder.bind(propertyValues); @@ -531,7 +531,7 @@ class DateTimeFormattingTests { } @Test - public void testBindMonthDayAnnotatedPattern() { + void testBindMonthDayAnnotatedPattern() { MutablePropertyValues propertyValues = new MutablePropertyValues(); propertyValues.add("monthDayAnnotatedPattern", "1/3"); binder.bind(propertyValues); diff --git a/spring-context/src/test/java/org/springframework/format/datetime/standard/InstantFormatterTests.java b/spring-context/src/test/java/org/springframework/format/datetime/standard/InstantFormatterTests.java index 614cd2d97cb..4cc4e79d897 100644 --- a/spring-context/src/test/java/org/springframework/format/datetime/standard/InstantFormatterTests.java +++ b/spring-context/src/test/java/org/springframework/format/datetime/standard/InstantFormatterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -83,11 +83,9 @@ class InstantFormatterTests { @ParameterizedTest @ArgumentsSource(RandomEpochMillisProvider.class) void should_parse_into_an_Instant_from_epoch_milli(Instant input) throws ParseException { - Instant expected = input; - Instant actual = instantFormatter.parse(Long.toString(input.toEpochMilli()), null); - assertThat(actual).isEqualTo(expected); + assertThat(actual).isEqualTo(input); } private static class RandomInstantProvider implements ArgumentsProvider { diff --git a/spring-context/src/test/java/org/springframework/format/number/CurrencyStyleFormatterTests.java b/spring-context/src/test/java/org/springframework/format/number/CurrencyStyleFormatterTests.java index 2a8feb879ea..d6f5294e2f3 100644 --- a/spring-context/src/test/java/org/springframework/format/number/CurrencyStyleFormatterTests.java +++ b/spring-context/src/test/java/org/springframework/format/number/CurrencyStyleFormatterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,40 +29,40 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; /** * @author Keith Donald */ -public class CurrencyStyleFormatterTests { +class CurrencyStyleFormatterTests { private final CurrencyStyleFormatter formatter = new CurrencyStyleFormatter(); @Test - public void formatValue() { + void formatValue() { assertThat(formatter.print(new BigDecimal("23"), Locale.US)).isEqualTo("$23.00"); } @Test - public void parseValue() throws ParseException { + void parseValue() throws ParseException { assertThat(formatter.parse("$23.56", Locale.US)).isEqualTo(new BigDecimal("23.56")); } @Test - public void parseBogusValue() throws ParseException { + void parseBogusValue() { assertThatExceptionOfType(ParseException.class).isThrownBy(() -> formatter.parse("bogus", Locale.US)); } @Test - public void parseValueDefaultRoundDown() throws ParseException { + void parseValueDefaultRoundDown() throws ParseException { this.formatter.setRoundingMode(RoundingMode.DOWN); assertThat(formatter.parse("$23.567", Locale.US)).isEqualTo(new BigDecimal("23.56")); } @Test - public void parseWholeValue() throws ParseException { + void parseWholeValue() throws ParseException { assertThat(formatter.parse("$23", Locale.US)).isEqualTo(new BigDecimal("23.00")); } @Test - public void parseValueNotLenientFailure() throws ParseException { + void parseValueNotLenientFailure() { assertThatExceptionOfType(ParseException.class).isThrownBy(() -> formatter.parse("$23.56bogus", Locale.US)); } diff --git a/spring-context/src/test/java/org/springframework/format/number/NumberFormattingTests.java b/spring-context/src/test/java/org/springframework/format/number/NumberFormattingTests.java index 609927bdf05..a65d6dc9dcd 100644 --- a/spring-context/src/test/java/org/springframework/format/number/NumberFormattingTests.java +++ b/spring-context/src/test/java/org/springframework/format/number/NumberFormattingTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,7 +38,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Keith Donald * @author Juergen Hoeller */ -public class NumberFormattingTests { +class NumberFormattingTests { private final FormattingConversionService conversionService = new FormattingConversionService(); @@ -46,7 +46,7 @@ public class NumberFormattingTests { @BeforeEach - public void setUp() { + void setUp() { DefaultConversionService.addDefaultConverters(conversionService); conversionService.setEmbeddedValueResolver(strVal -> { if ("${pattern}".equals(strVal)) { @@ -64,13 +64,13 @@ public class NumberFormattingTests { } @AfterEach - public void tearDown() { + void tearDown() { LocaleContextHolder.setLocale(null); } @Test - public void testDefaultNumberFormatting() { + void testDefaultNumberFormatting() { MutablePropertyValues propertyValues = new MutablePropertyValues(); propertyValues.add("numberDefault", "3,339.12"); binder.bind(propertyValues); @@ -79,7 +79,7 @@ public class NumberFormattingTests { } @Test - public void testDefaultNumberFormattingAnnotated() { + void testDefaultNumberFormattingAnnotated() { MutablePropertyValues propertyValues = new MutablePropertyValues(); propertyValues.add("numberDefaultAnnotated", "3,339.12"); binder.bind(propertyValues); @@ -88,7 +88,7 @@ public class NumberFormattingTests { } @Test - public void testCurrencyFormatting() { + void testCurrencyFormatting() { MutablePropertyValues propertyValues = new MutablePropertyValues(); propertyValues.add("currency", "$3,339.12"); binder.bind(propertyValues); @@ -97,7 +97,7 @@ public class NumberFormattingTests { } @Test - public void testPercentFormatting() { + void testPercentFormatting() { MutablePropertyValues propertyValues = new MutablePropertyValues(); propertyValues.add("percent", "53%"); binder.bind(propertyValues); @@ -106,7 +106,7 @@ public class NumberFormattingTests { } @Test - public void testPatternFormatting() { + void testPatternFormatting() { MutablePropertyValues propertyValues = new MutablePropertyValues(); propertyValues.add("pattern", "1,25.00"); binder.bind(propertyValues); @@ -115,7 +115,7 @@ public class NumberFormattingTests { } @Test - public void testPatternArrayFormatting() { + void testPatternArrayFormatting() { MutablePropertyValues propertyValues = new MutablePropertyValues(); propertyValues.add("patternArray", new String[] { "1,25.00", "2,35.00" }); binder.bind(propertyValues); @@ -133,7 +133,7 @@ public class NumberFormattingTests { } @Test - public void testPatternListFormatting() { + void testPatternListFormatting() { MutablePropertyValues propertyValues = new MutablePropertyValues(); propertyValues.add("patternList", new String[] { "1,25.00", "2,35.00" }); binder.bind(propertyValues); @@ -151,7 +151,7 @@ public class NumberFormattingTests { } @Test - public void testPatternList2FormattingListElement() { + void testPatternList2FormattingListElement() { MutablePropertyValues propertyValues = new MutablePropertyValues(); propertyValues.add("patternList2[0]", "1,25.00"); propertyValues.add("patternList2[1]", "2,35.00"); @@ -162,7 +162,7 @@ public class NumberFormattingTests { } @Test - public void testPatternList2FormattingList() { + void testPatternList2FormattingList() { MutablePropertyValues propertyValues = new MutablePropertyValues(); propertyValues.add("patternList2[0]", "1,25.00"); propertyValues.add("patternList2[1]", "2,35.00"); diff --git a/spring-context/src/test/java/org/springframework/format/number/NumberStyleFormatterTests.java b/spring-context/src/test/java/org/springframework/format/number/NumberStyleFormatterTests.java index babd8a3267d..ff535886038 100644 --- a/spring-context/src/test/java/org/springframework/format/number/NumberStyleFormatterTests.java +++ b/spring-context/src/test/java/org/springframework/format/number/NumberStyleFormatterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,29 +28,29 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; /** * @author Keith Donald */ -public class NumberStyleFormatterTests { +class NumberStyleFormatterTests { private final NumberStyleFormatter formatter = new NumberStyleFormatter(); @Test - public void formatValue() { + void formatValue() { assertThat(formatter.print(new BigDecimal("23.56"), Locale.US)).isEqualTo("23.56"); } @Test - public void parseValue() throws ParseException { + void parseValue() throws ParseException { assertThat(formatter.parse("23.56", Locale.US)).isEqualTo(new BigDecimal("23.56")); } @Test - public void parseBogusValue() throws ParseException { + void parseBogusValue() { assertThatExceptionOfType(ParseException.class).isThrownBy(() -> formatter.parse("bogus", Locale.US)); } @Test - public void parsePercentValueNotLenientFailure() throws ParseException { + void parsePercentValueNotLenientFailure() { assertThatExceptionOfType(ParseException.class).isThrownBy(() -> formatter.parse("23.56bogus", Locale.US)); } diff --git a/spring-context/src/test/java/org/springframework/format/number/PercentStyleFormatterTests.java b/spring-context/src/test/java/org/springframework/format/number/PercentStyleFormatterTests.java index de9cbf227e3..0fb1855b9b0 100644 --- a/spring-context/src/test/java/org/springframework/format/number/PercentStyleFormatterTests.java +++ b/spring-context/src/test/java/org/springframework/format/number/PercentStyleFormatterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,29 +28,29 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; /** * @author Keith Donald */ -public class PercentStyleFormatterTests { +class PercentStyleFormatterTests { private final PercentStyleFormatter formatter = new PercentStyleFormatter(); @Test - public void formatValue() { + void formatValue() { assertThat(formatter.print(new BigDecimal(".23"), Locale.US)).isEqualTo("23%"); } @Test - public void parseValue() throws ParseException { + void parseValue() throws ParseException { assertThat(formatter.parse("23.56%", Locale.US)).isEqualTo(new BigDecimal(".2356")); } @Test - public void parseBogusValue() throws ParseException { + void parseBogusValue() { assertThatExceptionOfType(ParseException.class).isThrownBy(() -> formatter.parse("bogus", Locale.US)); } @Test - public void parsePercentValueNotLenientFailure() throws ParseException { + void parsePercentValueNotLenientFailure() { assertThatExceptionOfType(ParseException.class).isThrownBy(() -> formatter.parse("23.56%bogus", Locale.US)); } diff --git a/spring-context/src/test/java/org/springframework/format/number/money/MoneyFormattingTests.java b/spring-context/src/test/java/org/springframework/format/number/money/MoneyFormattingTests.java index c18a9f04df6..348171c77e3 100644 --- a/spring-context/src/test/java/org/springframework/format/number/money/MoneyFormattingTests.java +++ b/spring-context/src/test/java/org/springframework/format/number/money/MoneyFormattingTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,24 +38,24 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Juergen Hoeller * @since 4.2 */ -public class MoneyFormattingTests { +class MoneyFormattingTests { private final FormattingConversionService conversionService = new DefaultFormattingConversionService(); @BeforeEach - public void setUp() { + void setUp() { LocaleContextHolder.setLocale(Locale.US); } @AfterEach - public void tearDown() { + void tearDown() { LocaleContextHolder.setLocale(null); } @Test - public void testAmountAndUnit() { + void testAmountAndUnit() { MoneyHolder bean = new MoneyHolder(); DataBinder binder = new DataBinder(bean); binder.setConversionService(conversionService); @@ -81,7 +81,7 @@ public class MoneyFormattingTests { } @Test - public void testAmountWithNumberFormat1() { + void testAmountWithNumberFormat1() { FormattedMoneyHolder1 bean = new FormattedMoneyHolder1(); DataBinder binder = new DataBinder(bean); binder.setConversionService(conversionService); @@ -104,7 +104,7 @@ public class MoneyFormattingTests { } @Test - public void testAmountWithNumberFormat2() { + void testAmountWithNumberFormat2() { FormattedMoneyHolder2 bean = new FormattedMoneyHolder2(); DataBinder binder = new DataBinder(bean); binder.setConversionService(conversionService); @@ -119,7 +119,7 @@ public class MoneyFormattingTests { } @Test - public void testAmountWithNumberFormat3() { + void testAmountWithNumberFormat3() { FormattedMoneyHolder3 bean = new FormattedMoneyHolder3(); DataBinder binder = new DataBinder(bean); binder.setConversionService(conversionService); @@ -134,7 +134,7 @@ public class MoneyFormattingTests { } @Test - public void testAmountWithNumberFormat4() { + void testAmountWithNumberFormat4() { FormattedMoneyHolder4 bean = new FormattedMoneyHolder4(); DataBinder binder = new DataBinder(bean); binder.setConversionService(conversionService); @@ -149,7 +149,7 @@ public class MoneyFormattingTests { } @Test - public void testAmountWithNumberFormat5() { + void testAmountWithNumberFormat5() { FormattedMoneyHolder5 bean = new FormattedMoneyHolder5(); DataBinder binder = new DataBinder(bean); binder.setConversionService(conversionService); diff --git a/spring-context/src/test/java/org/springframework/format/support/FormattingConversionServiceFactoryBeanTests.java b/spring-context/src/test/java/org/springframework/format/support/FormattingConversionServiceFactoryBeanTests.java index 160c0fc4f02..8f473be3c24 100644 --- a/spring-context/src/test/java/org/springframework/format/support/FormattingConversionServiceFactoryBeanTests.java +++ b/spring-context/src/test/java/org/springframework/format/support/FormattingConversionServiceFactoryBeanTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,6 @@ import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import java.text.ParseException; import java.util.HashSet; import java.util.Locale; import java.util.Set; @@ -47,10 +46,10 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException * @author Rossen Stoyanchev * @author Juergen Hoeller */ -public class FormattingConversionServiceFactoryBeanTests { +class FormattingConversionServiceFactoryBeanTests { @Test - public void testDefaultFormattersOn() throws Exception { + void testDefaultFormattersOn() throws Exception { FormattingConversionServiceFactoryBean factory = new FormattingConversionServiceFactoryBean(); factory.afterPropertiesSet(); FormattingConversionService fcs = factory.getObject(); @@ -69,7 +68,7 @@ public class FormattingConversionServiceFactoryBeanTests { } @Test - public void testDefaultFormattersOff() throws Exception { + void testDefaultFormattersOff() throws Exception { FormattingConversionServiceFactoryBean factory = new FormattingConversionServiceFactoryBean(); factory.setRegisterDefaultFormatters(false); factory.afterPropertiesSet(); @@ -82,7 +81,7 @@ public class FormattingConversionServiceFactoryBeanTests { } @Test - public void testCustomFormatter() throws Exception { + void testCustomFormatter() throws Exception { FormattingConversionServiceFactoryBean factory = new FormattingConversionServiceFactoryBean(); Set formatters = new HashSet<>(); formatters.add(new TestBeanFormatter()); @@ -103,7 +102,7 @@ public class FormattingConversionServiceFactoryBeanTests { } @Test - public void testFormatterRegistrar() throws Exception { + void testFormatterRegistrar() { FormattingConversionServiceFactoryBean factory = new FormattingConversionServiceFactoryBean(); Set registrars = new HashSet<>(); registrars.add(new TestFormatterRegistrar()); @@ -117,7 +116,7 @@ public class FormattingConversionServiceFactoryBeanTests { } @Test - public void testInvalidFormatter() throws Exception { + void testInvalidFormatter() { FormattingConversionServiceFactoryBean factory = new FormattingConversionServiceFactoryBean(); Set formatters = new HashSet<>(); formatters.add(new Object()); @@ -164,7 +163,7 @@ public class FormattingConversionServiceFactoryBeanTests { } @Override - public TestBean parse(String text, Locale locale) throws ParseException { + public TestBean parse(String text, Locale locale) { TestBean object = new TestBean(); object.setSpecialInt(Integer.parseInt(text)); return object; @@ -189,7 +188,7 @@ public class FormattingConversionServiceFactoryBeanTests { public Printer getPrinter(SpecialInt annotation, Class fieldType) { assertThat(annotation.value()).isEqualTo("aliased"); assertThat(annotation.alias()).isEqualTo("aliased"); - return (object, locale) -> ":" + object.toString(); + return (object, locale) -> ":" + object; } @Override diff --git a/spring-context/src/test/java/org/springframework/instrument/classloading/InstrumentableClassLoaderTests.java b/spring-context/src/test/java/org/springframework/instrument/classloading/InstrumentableClassLoaderTests.java index b70628ea4e0..c896a92d943 100644 --- a/spring-context/src/test/java/org/springframework/instrument/classloading/InstrumentableClassLoaderTests.java +++ b/spring-context/src/test/java/org/springframework/instrument/classloading/InstrumentableClassLoaderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,10 +27,10 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Juergen Hoeller * @author Chris Beams */ -public class InstrumentableClassLoaderTests { +class InstrumentableClassLoaderTests { @Test - public void testDefaultLoadTimeWeaver() { + void testDefaultLoadTimeWeaver() { ClassLoader loader = new SimpleInstrumentableClassLoader(ClassUtils.getDefaultClassLoader()); ReflectiveLoadTimeWeaver handler = new ReflectiveLoadTimeWeaver(loader); assertThat(handler.getInstrumentableClassLoader()).isSameAs(loader); diff --git a/spring-context/src/test/java/org/springframework/instrument/classloading/ReflectiveLoadTimeWeaverTests.java b/spring-context/src/test/java/org/springframework/instrument/classloading/ReflectiveLoadTimeWeaverTests.java index 989b1e196de..197e5ed655d 100644 --- a/spring-context/src/test/java/org/springframework/instrument/classloading/ReflectiveLoadTimeWeaverTests.java +++ b/spring-context/src/test/java/org/springframework/instrument/classloading/ReflectiveLoadTimeWeaverTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,22 +31,22 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException; * @author Rick Evans * @author Chris Beams */ -public class ReflectiveLoadTimeWeaverTests { +class ReflectiveLoadTimeWeaverTests { @Test - public void testCtorWithNullClassLoader() { + void testCtorWithNullClassLoader() { assertThatIllegalArgumentException().isThrownBy(() -> new ReflectiveLoadTimeWeaver(null)); } @Test - public void testCtorWithClassLoaderThatDoesNotExposeAnAddTransformerMethod() { + void testCtorWithClassLoaderThatDoesNotExposeAnAddTransformerMethod() { assertThatIllegalStateException().isThrownBy(() -> new ReflectiveLoadTimeWeaver(getClass().getClassLoader())); } @Test - public void testCtorWithClassLoaderThatDoesNotExposeAGetThrowawayClassLoaderMethodIsOkay() { + void testCtorWithClassLoaderThatDoesNotExposeAGetThrowawayClassLoaderMethodIsOkay() { JustAddTransformerClassLoader classLoader = new JustAddTransformerClassLoader(); ReflectiveLoadTimeWeaver weaver = new ReflectiveLoadTimeWeaver(classLoader); weaver.addTransformer(new ClassFileTransformer() { @@ -59,20 +59,20 @@ public class ReflectiveLoadTimeWeaverTests { } @Test - public void testAddTransformerWithNullTransformer() { + void testAddTransformerWithNullTransformer() { assertThatIllegalArgumentException().isThrownBy(() -> new ReflectiveLoadTimeWeaver(new JustAddTransformerClassLoader()).addTransformer(null)); } @Test - public void testGetThrowawayClassLoaderWithClassLoaderThatDoesNotExposeAGetThrowawayClassLoaderMethodYieldsFallbackClassLoader() { + void testGetThrowawayClassLoaderWithClassLoaderThatDoesNotExposeAGetThrowawayClassLoaderMethodYieldsFallbackClassLoader() { ReflectiveLoadTimeWeaver weaver = new ReflectiveLoadTimeWeaver(new JustAddTransformerClassLoader()); ClassLoader throwawayClassLoader = weaver.getThrowawayClassLoader(); assertThat(throwawayClassLoader).isNotNull(); } @Test - public void testGetThrowawayClassLoaderWithTotallyCompliantClassLoader() { + void testGetThrowawayClassLoaderWithTotallyCompliantClassLoader() { TotallyCompliantClassLoader classLoader = new TotallyCompliantClassLoader(); ReflectiveLoadTimeWeaver weaver = new ReflectiveLoadTimeWeaver(classLoader); ClassLoader throwawayClassLoader = weaver.getThrowawayClassLoader(); diff --git a/spring-context/src/test/java/org/springframework/instrument/classloading/ResourceOverridingShadowingClassLoaderTests.java b/spring-context/src/test/java/org/springframework/instrument/classloading/ResourceOverridingShadowingClassLoaderTests.java index 86d5a692450..f464a60f395 100644 --- a/spring-context/src/test/java/org/springframework/instrument/classloading/ResourceOverridingShadowingClassLoaderTests.java +++ b/spring-context/src/test/java/org/springframework/instrument/classloading/ResourceOverridingShadowingClassLoaderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,7 +28,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Chris Beams * @since 2.0 */ -public class ResourceOverridingShadowingClassLoaderTests { +class ResourceOverridingShadowingClassLoaderTests { private static final String EXISTING_RESOURCE = "org/springframework/instrument/classloading/testResource.xml"; @@ -38,40 +38,40 @@ public class ResourceOverridingShadowingClassLoaderTests { @Test - public void testFindsExistingResourceWithGetResourceAndNoOverrides() { + void testFindsExistingResourceWithGetResourceAndNoOverrides() { assertThat(thisClassLoader.getResource(EXISTING_RESOURCE)).isNotNull(); assertThat(overridingLoader.getResource(EXISTING_RESOURCE)).isNotNull(); } @Test - public void testDoesNotFindExistingResourceWithGetResourceAndNullOverride() { + void testDoesNotFindExistingResourceWithGetResourceAndNullOverride() { assertThat(thisClassLoader.getResource(EXISTING_RESOURCE)).isNotNull(); overridingLoader.override(EXISTING_RESOURCE, null); assertThat(overridingLoader.getResource(EXISTING_RESOURCE)).isNull(); } @Test - public void testFindsExistingResourceWithGetResourceAsStreamAndNoOverrides() { + void testFindsExistingResourceWithGetResourceAsStreamAndNoOverrides() { assertThat(thisClassLoader.getResourceAsStream(EXISTING_RESOURCE)).isNotNull(); assertThat(overridingLoader.getResourceAsStream(EXISTING_RESOURCE)).isNotNull(); } @Test - public void testDoesNotFindExistingResourceWithGetResourceAsStreamAndNullOverride() { + void testDoesNotFindExistingResourceWithGetResourceAsStreamAndNullOverride() { assertThat(thisClassLoader.getResourceAsStream(EXISTING_RESOURCE)).isNotNull(); overridingLoader.override(EXISTING_RESOURCE, null); assertThat(overridingLoader.getResourceAsStream(EXISTING_RESOURCE)).isNull(); } @Test - public void testFindsExistingResourceWithGetResourcesAndNoOverrides() throws IOException { + void testFindsExistingResourceWithGetResourcesAndNoOverrides() throws IOException { assertThat(thisClassLoader.getResources(EXISTING_RESOURCE)).isNotNull(); assertThat(overridingLoader.getResources(EXISTING_RESOURCE)).isNotNull(); assertThat(countElements(overridingLoader.getResources(EXISTING_RESOURCE))).isEqualTo(1); } @Test - public void testDoesNotFindExistingResourceWithGetResourcesAndNullOverride() throws IOException { + void testDoesNotFindExistingResourceWithGetResourcesAndNullOverride() throws IOException { assertThat(thisClassLoader.getResources(EXISTING_RESOURCE)).isNotNull(); overridingLoader.override(EXISTING_RESOURCE, null); assertThat(countElements(overridingLoader.getResources(EXISTING_RESOURCE))).isEqualTo(0); diff --git a/spring-context/src/test/java/org/springframework/jmx/AbstractJmxTests.java b/spring-context/src/test/java/org/springframework/jmx/AbstractJmxTests.java index 7147ccc56dc..037747924f8 100644 --- a/spring-context/src/test/java/org/springframework/jmx/AbstractJmxTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/AbstractJmxTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,12 +32,12 @@ public abstract class AbstractJmxTests extends AbstractMBeanServerTests { @Override - protected final void onSetUp() throws Exception { + protected final void onSetUp() { ctx = loadContext(getApplicationContextPath()); } @Override - protected final void onTearDown() throws Exception { + protected final void onTearDown() { if (ctx != null) { ctx.close(); } diff --git a/spring-context/src/test/java/org/springframework/jmx/AbstractMBeanServerTests.java b/spring-context/src/test/java/org/springframework/jmx/AbstractMBeanServerTests.java index 6078982e138..a3c4cb43b1b 100644 --- a/spring-context/src/test/java/org/springframework/jmx/AbstractMBeanServerTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/AbstractMBeanServerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -73,12 +73,12 @@ public abstract class AbstractMBeanServerTests { } @AfterEach - public void tearDown() throws Exception { + protected void tearDown() throws Exception { releaseServer(); onTearDown(); } - private void releaseServer() throws Exception { + private void releaseServer() { try { MBeanServerFactory.releaseMBeanServer(getServer()); } @@ -101,7 +101,7 @@ public abstract class AbstractMBeanServerTests { protected void onSetUp() throws Exception { } - protected void onTearDown() throws Exception { + protected void onTearDown() { } protected final MBeanServer getServer() { diff --git a/spring-context/src/test/java/org/springframework/jmx/access/MBeanClientInterceptorTests.java b/spring-context/src/test/java/org/springframework/jmx/access/MBeanClientInterceptorTests.java index 8f62afb9463..5577fbd32af 100644 --- a/spring-context/src/test/java/org/springframework/jmx/access/MBeanClientInterceptorTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/access/MBeanClientInterceptorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -171,7 +171,7 @@ class MBeanClientInterceptorTests extends AbstractMBeanServerTests { void invokeUnexposedMethodWithException() throws Exception { assumeTrue(runTests); IJmxTestBean bean = getProxy(); - assertThatExceptionOfType(InvalidInvocationException.class).isThrownBy(() -> bean.dontExposeMe()); + assertThatExceptionOfType(InvalidInvocationException.class).isThrownBy(bean::dontExposeMe); } @Test diff --git a/spring-context/src/test/java/org/springframework/jmx/access/RemoteMBeanClientInterceptorTests.java b/spring-context/src/test/java/org/springframework/jmx/access/RemoteMBeanClientInterceptorTests.java index 336aaa7bff1..e1d0c8e0e5b 100644 --- a/spring-context/src/test/java/org/springframework/jmx/access/RemoteMBeanClientInterceptorTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/access/RemoteMBeanClientInterceptorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -75,7 +75,7 @@ class RemoteMBeanClientInterceptorTests extends MBeanClientInterceptorTests { @AfterEach @Override - public void tearDown() throws Exception { + protected void tearDown() throws Exception { if (this.connector != null) { this.connector.close(); } diff --git a/spring-context/src/test/java/org/springframework/jmx/export/LazyInitMBeanTests.java b/spring-context/src/test/java/org/springframework/jmx/export/LazyInitMBeanTests.java index 83335785232..b5a6c672e8d 100644 --- a/spring-context/src/test/java/org/springframework/jmx/export/LazyInitMBeanTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/export/LazyInitMBeanTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,22 +30,19 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Rob Harrop * @author Juergen Hoeller */ -public class LazyInitMBeanTests { +class LazyInitMBeanTests { @Test - public void invokeOnLazyInitBean() throws Exception { + void invokeOnLazyInitBean() throws Exception { ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("org/springframework/jmx/export/lazyInit.xml"); - assertThat(ctx.getBeanFactory().containsSingleton("testBean")).isFalse(); - assertThat(ctx.getBeanFactory().containsSingleton("testBean2")).isFalse(); - try { + try (ctx) { + assertThat(ctx.getBeanFactory().containsSingleton("testBean")).isFalse(); + assertThat(ctx.getBeanFactory().containsSingleton("testBean2")).isFalse(); MBeanServer server = (MBeanServer) ctx.getBean("server"); ObjectName oname = ObjectNameManager.getInstance("bean:name=testBean2"); String name = (String) server.getAttribute(oname, "Name"); assertThat(name).as("Invalid name returned").isEqualTo("foo"); } - finally { - ctx.close(); - } } } diff --git a/spring-context/src/test/java/org/springframework/jmx/export/MBeanExporterTests.java b/spring-context/src/test/java/org/springframework/jmx/export/MBeanExporterTests.java index ce836740afd..e64676290f8 100644 --- a/spring-context/src/test/java/org/springframework/jmx/export/MBeanExporterTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/export/MBeanExporterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,7 +28,6 @@ import java.util.stream.Stream; import javax.management.Attribute; import javax.management.InstanceNotFoundException; -import javax.management.JMException; import javax.management.MBeanServer; import javax.management.MalformedObjectNameException; import javax.management.Notification; @@ -48,6 +47,7 @@ import org.springframework.beans.factory.support.RootBeanDefinition; import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; +import org.springframework.context.testfixture.jmx.export.Person; import org.springframework.jmx.AbstractMBeanServerTests; import org.springframework.jmx.IJmxTestBean; import org.springframework.jmx.JmxTestBean; @@ -76,7 +76,7 @@ import static org.assertj.core.api.Assertions.assertThatRuntimeException; * @author Sam Brannen * @author Stephane Nicoll */ -public class MBeanExporterTests extends AbstractMBeanServerTests { +class MBeanExporterTests extends AbstractMBeanServerTests { private static final String OBJECT_NAME = "spring:test=jmxMBeanAdaptor"; @@ -84,7 +84,7 @@ public class MBeanExporterTests extends AbstractMBeanServerTests { @Test - void registerNullNotificationListenerType() throws Exception { + void registerNullNotificationListenerType() { Map listeners = new HashMap<>(); // put null in as a value... listeners.put("*", null); @@ -95,7 +95,7 @@ public class MBeanExporterTests extends AbstractMBeanServerTests { } @Test - void registerNotificationListenerForNonExistentMBean() throws Exception { + void registerNotificationListenerForNonExistentMBean() { NotificationListener dummyListener = (notification, handback) -> { throw new UnsupportedOperationException(); }; @@ -191,7 +191,7 @@ public class MBeanExporterTests extends AbstractMBeanServerTests { } @Test - void autodetectNoMBeans() throws Exception { + void autodetectNoMBeans() { try (ConfigurableApplicationContext ctx = load("autodetectNoMBeans.xml")) { ctx.getBean("exporter"); } @@ -709,7 +709,7 @@ public class MBeanExporterTests extends AbstractMBeanServerTests { private boolean invoked = false; @Override - public ModelMBeanInfo getMBeanInfo(Object managedResource, String beanKey) throws JMException { + public ModelMBeanInfo getMBeanInfo(Object managedResource, String beanKey) { invoked = true; return null; } @@ -766,33 +766,12 @@ public class MBeanExporterTests extends AbstractMBeanServerTests { } @Override - public ObjectName getObjectName() throws MalformedObjectNameException { + public ObjectName getObjectName() { return this.objectName; } } - public interface PersonMBean { - - String getName(); - } - - - public static class Person implements PersonMBean { - - private String name; - - @Override - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - } - - public static final class StubNotificationListener implements NotificationListener { private List notifications = new ArrayList<>(); diff --git a/spring-context/src/test/java/org/springframework/jmx/export/NotificationListenerTests.java b/spring-context/src/test/java/org/springframework/jmx/export/NotificationListenerTests.java index 96284312a77..22dae40db9e 100644 --- a/spring-context/src/test/java/org/springframework/jmx/export/NotificationListenerTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/export/NotificationListenerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,6 @@ import java.util.Map; import javax.management.Attribute; import javax.management.AttributeChangeNotification; -import javax.management.MalformedObjectNameException; import javax.management.Notification; import javax.management.NotificationListener; import javax.management.ObjectName; @@ -43,11 +42,11 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException * @author Mark Fisher * @author Sam Brannen */ -public class NotificationListenerTests extends AbstractMBeanServerTests { +class NotificationListenerTests extends AbstractMBeanServerTests { @SuppressWarnings({"rawtypes", "unchecked"}) @Test - public void testRegisterNotificationListenerForMBean() throws Exception { + void testRegisterNotificationListenerForMBean() throws Exception { ObjectName objectName = ObjectName.getInstance("spring:name=Test"); JmxTestBean bean = new JmxTestBean(); @@ -73,7 +72,7 @@ public class NotificationListenerTests extends AbstractMBeanServerTests { @SuppressWarnings({ "rawtypes", "unchecked" }) @Test - public void testRegisterNotificationListenerWithWildcard() throws Exception { + void testRegisterNotificationListenerWithWildcard() throws Exception { ObjectName objectName = ObjectName.getInstance("spring:name=Test"); JmxTestBean bean = new JmxTestBean(); @@ -98,7 +97,7 @@ public class NotificationListenerTests extends AbstractMBeanServerTests { } @Test - public void testRegisterNotificationListenerWithHandback() throws Exception { + void testRegisterNotificationListenerWithHandback() throws Exception { String objectName = "spring:name=Test"; JmxTestBean bean = new JmxTestBean(); @@ -129,7 +128,7 @@ public class NotificationListenerTests extends AbstractMBeanServerTests { } @Test - public void testRegisterNotificationListenerForAllMBeans() throws Exception { + void testRegisterNotificationListenerForAllMBeans() throws Exception { ObjectName objectName = ObjectName.getInstance("spring:name=Test"); JmxTestBean bean = new JmxTestBean(); @@ -156,7 +155,7 @@ public class NotificationListenerTests extends AbstractMBeanServerTests { @SuppressWarnings("serial") @Test - public void testRegisterNotificationListenerWithFilter() throws Exception { + void testRegisterNotificationListenerWithFilter() throws Exception { ObjectName objectName = ObjectName.getInstance("spring:name=Test"); JmxTestBean bean = new JmxTestBean(); @@ -194,14 +193,14 @@ public class NotificationListenerTests extends AbstractMBeanServerTests { } @Test - public void testCreationWithNoNotificationListenerSet() { + void testCreationWithNoNotificationListenerSet() { assertThatIllegalArgumentException().as("no NotificationListener supplied").isThrownBy( new NotificationListenerBean()::afterPropertiesSet); } @SuppressWarnings({ "rawtypes", "unchecked" }) @Test - public void testRegisterNotificationListenerWithBeanNameAndBeanNameInBeansMap() throws Exception { + void testRegisterNotificationListenerWithBeanNameAndBeanNameInBeansMap() throws Exception { String beanName = "testBean"; ObjectName objectName = ObjectName.getInstance("spring:name=Test"); @@ -232,7 +231,7 @@ public class NotificationListenerTests extends AbstractMBeanServerTests { @SuppressWarnings({ "rawtypes", "unchecked" }) @Test - public void testRegisterNotificationListenerWithBeanNameAndBeanInstanceInBeansMap() throws Exception { + void testRegisterNotificationListenerWithBeanNameAndBeanInstanceInBeansMap() throws Exception { String beanName = "testBean"; ObjectName objectName = ObjectName.getInstance("spring:name=Test"); @@ -263,7 +262,7 @@ public class NotificationListenerTests extends AbstractMBeanServerTests { @SuppressWarnings({ "rawtypes", "unchecked" }) @Test - public void testRegisterNotificationListenerWithBeanNameBeforeObjectNameMappedToSameBeanInstance() throws Exception { + void testRegisterNotificationListenerWithBeanNameBeforeObjectNameMappedToSameBeanInstance() throws Exception { String beanName = "testBean"; ObjectName objectName = ObjectName.getInstance("spring:name=Test"); @@ -295,7 +294,7 @@ public class NotificationListenerTests extends AbstractMBeanServerTests { @SuppressWarnings({ "rawtypes", "unchecked" }) @Test - public void testRegisterNotificationListenerWithObjectNameBeforeBeanNameMappedToSameBeanInstance() throws Exception { + void testRegisterNotificationListenerWithObjectNameBeforeBeanNameMappedToSameBeanInstance() throws Exception { String beanName = "testBean"; ObjectName objectName = ObjectName.getInstance("spring:name=Test"); @@ -327,7 +326,7 @@ public class NotificationListenerTests extends AbstractMBeanServerTests { @SuppressWarnings({ "rawtypes", "unchecked" }) @Test - public void testRegisterNotificationListenerWithTwoBeanNamesMappedToDifferentBeanInstances() throws Exception { + void testRegisterNotificationListenerWithTwoBeanNamesMappedToDifferentBeanInstances() throws Exception { String beanName1 = "testBean1"; String beanName2 = "testBean2"; @@ -370,7 +369,7 @@ public class NotificationListenerTests extends AbstractMBeanServerTests { } @Test - public void testNotificationListenerRegistrar() throws Exception { + void testNotificationListenerRegistrar() throws Exception { ObjectName objectName = ObjectName.getInstance("spring:name=Test"); JmxTestBean bean = new JmxTestBean(); @@ -403,7 +402,7 @@ public class NotificationListenerTests extends AbstractMBeanServerTests { } @Test - public void testNotificationListenerRegistrarWithMultipleNames() throws Exception { + void testNotificationListenerRegistrarWithMultipleNames() throws Exception { ObjectName objectName = ObjectName.getInstance("spring:name=Test"); ObjectName objectName2 = ObjectName.getInstance("spring:name=Test2"); JmxTestBean bean = new JmxTestBean(); @@ -488,7 +487,7 @@ public class NotificationListenerTests extends AbstractMBeanServerTests { } @Override - public ObjectName getObjectName() throws MalformedObjectNameException { + public ObjectName getObjectName() { return this.objectName; } diff --git a/spring-context/src/test/java/org/springframework/jmx/export/NotificationPublisherTests.java b/spring-context/src/test/java/org/springframework/jmx/export/NotificationPublisherTests.java index 786c608c2a5..17e50b0644e 100644 --- a/spring-context/src/test/java/org/springframework/jmx/export/NotificationPublisherTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/export/NotificationPublisherTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,19 +18,15 @@ package org.springframework.jmx.export; import javax.management.Attribute; import javax.management.AttributeList; -import javax.management.AttributeNotFoundException; import javax.management.DynamicMBean; -import javax.management.InvalidAttributeValueException; import javax.management.MBeanAttributeInfo; import javax.management.MBeanConstructorInfo; -import javax.management.MBeanException; import javax.management.MBeanInfo; import javax.management.MBeanNotificationInfo; import javax.management.MBeanOperationInfo; import javax.management.Notification; import javax.management.NotificationBroadcasterSupport; import javax.management.NotificationListener; -import javax.management.ReflectionException; import org.junit.jupiter.api.Test; @@ -48,12 +44,12 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Rob Harrop * @author Juergen Hoeller */ -public class NotificationPublisherTests extends AbstractMBeanServerTests { +class NotificationPublisherTests extends AbstractMBeanServerTests { private CountingNotificationListener listener = new CountingNotificationListener(); @Test - public void testSimpleBean() throws Exception { + void testSimpleBean() throws Exception { // start the MBeanExporter ConfigurableApplicationContext ctx = loadContext("org/springframework/jmx/export/notificationPublisherTests.xml"); this.server.addNotificationListener(ObjectNameManager.getInstance("spring:type=Publisher"), listener, null, @@ -66,7 +62,7 @@ public class NotificationPublisherTests extends AbstractMBeanServerTests { } @Test - public void testSimpleBeanRegisteredManually() throws Exception { + void testSimpleBeanRegisteredManually() throws Exception { // start the MBeanExporter ConfigurableApplicationContext ctx = loadContext("org/springframework/jmx/export/notificationPublisherTests.xml"); MBeanExporter exporter = (MBeanExporter) ctx.getBean("exporter"); @@ -81,7 +77,7 @@ public class NotificationPublisherTests extends AbstractMBeanServerTests { } @Test - public void testMBean() throws Exception { + void testMBean() throws Exception { // start the MBeanExporter ConfigurableApplicationContext ctx = loadContext("org/springframework/jmx/export/notificationPublisherTests.xml"); this.server.addNotificationListener(ObjectNameManager.getInstance("spring:type=PublisherMBean"), listener, @@ -94,7 +90,7 @@ public class NotificationPublisherTests extends AbstractMBeanServerTests { /* @Test - public void testStandardMBean() throws Exception { + void testStandardMBean() throws Exception { // start the MBeanExporter ApplicationContext ctx = new ClassPathXmlApplicationContext("org/springframework/jmx/export/notificationPublisherTests.xml"); this.server.addNotificationListener(ObjectNameManager.getInstance("spring:type=PublisherStandardMBean"), listener, null, null); @@ -106,7 +102,7 @@ public class NotificationPublisherTests extends AbstractMBeanServerTests { */ @Test - public void testLazyInit() throws Exception { + void testLazyInit() throws Exception { // start the MBeanExporter ConfigurableApplicationContext ctx = loadContext("org/springframework/jmx/export/notificationPublisherLazyTests.xml"); assertThat(ctx.getBeanFactory().containsSingleton("publisher")).as("Should not have instantiated the bean yet").isFalse(); @@ -170,14 +166,12 @@ public class NotificationPublisherTests extends AbstractMBeanServerTests { public static class MyNotificationPublisherMBean extends NotificationBroadcasterSupport implements DynamicMBean { @Override - public Object getAttribute(String attribute) throws AttributeNotFoundException, MBeanException, - ReflectionException { + public Object getAttribute(String attribute) { return null; } @Override - public void setAttribute(Attribute attribute) throws AttributeNotFoundException, - InvalidAttributeValueException, MBeanException, ReflectionException { + public void setAttribute(Attribute attribute) { } @Override @@ -191,8 +185,7 @@ public class NotificationPublisherTests extends AbstractMBeanServerTests { } @Override - public Object invoke(String actionName, Object[] params, String[] signature) throws MBeanException, - ReflectionException { + public Object invoke(String actionName, Object[] params, String[] signature) { return null; } diff --git a/spring-context/src/test/java/org/springframework/jmx/export/annotation/AnnotationMetadataAssemblerTests.java b/spring-context/src/test/java/org/springframework/jmx/export/annotation/AnnotationMetadataAssemblerTests.java index e58d826c4fa..9ca391f16e8 100644 --- a/spring-context/src/test/java/org/springframework/jmx/export/annotation/AnnotationMetadataAssemblerTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/export/annotation/AnnotationMetadataAssemblerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,13 +32,13 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Rob Harrop * @author Chris Beams */ -public class AnnotationMetadataAssemblerTests extends AbstractMetadataAssemblerTests { +class AnnotationMetadataAssemblerTests extends AbstractMetadataAssemblerTests { private static final String OBJECT_NAME = "bean:name=testBean4"; @Test - public void testAttributeFromInterface() throws Exception { + void testAttributeFromInterface() throws Exception { ModelMBeanInfo inf = getMBeanInfoFromAssembler(); ModelMBeanAttributeInfo attr = inf.getAttribute("Colour"); assertThat(attr.isWritable()).as("The name attribute should be writable").isTrue(); @@ -46,21 +46,21 @@ public class AnnotationMetadataAssemblerTests extends AbstractMetadataAssemblerT } @Test - public void testOperationFromInterface() throws Exception { + void testOperationFromInterface() throws Exception { ModelMBeanInfo inf = getMBeanInfoFromAssembler(); ModelMBeanOperationInfo op = inf.getOperation("fromInterface"); assertThat(op).isNotNull(); } @Test - public void testOperationOnGetter() throws Exception { + void testOperationOnGetter() throws Exception { ModelMBeanInfo inf = getMBeanInfoFromAssembler(); ModelMBeanOperationInfo op = inf.getOperation("getExpensiveToCalculate"); assertThat(op).isNotNull(); } @Test - public void testRegistrationOnInterface() throws Exception { + void testRegistrationOnInterface() throws Exception { Object bean = getContext().getBean("testInterfaceBean"); ModelMBeanInfo inf = getAssembler().getMBeanInfo(bean, "bean:name=interfaceTestBean"); assertThat(inf).isNotNull(); diff --git a/spring-context/src/test/java/org/springframework/jmx/export/annotation/AnnotationTestBeanFactory.java b/spring-context/src/test/java/org/springframework/jmx/export/annotation/AnnotationTestBeanFactory.java index 1634b6b75c3..814598b4d5e 100644 --- a/spring-context/src/test/java/org/springframework/jmx/export/annotation/AnnotationTestBeanFactory.java +++ b/spring-context/src/test/java/org/springframework/jmx/export/annotation/AnnotationTestBeanFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,7 +31,7 @@ public class AnnotationTestBeanFactory implements FactoryBean getWithMapping("com.foo.bar.Unknown")); } @Test - public void testWithNonInterface() throws Exception { + void testWithNonInterface() { assertThatIllegalArgumentException().isThrownBy(() -> getWithMapping("JmxTestBean")); } @Test - public void testWithFallThrough() throws Exception { + void testWithFallThrough() throws Exception { InterfaceBasedMBeanInfoAssembler assembler = getWithMapping("foobar", "org.springframework.jmx.export.assembler.ICustomJmxBean"); assembler.setManagedInterfaces(new Class[] {IAdditionalTestMethods.class}); @@ -69,7 +69,7 @@ public class InterfaceBasedMBeanInfoAssemblerMappedTests extends AbstractJmxAsse } @Test - public void testNickNameIsExposed() throws Exception { + void testNickNameIsExposed() throws Exception { ModelMBeanInfo inf = (ModelMBeanInfo) getMBeanInfo(); MBeanAttributeInfo attr = inf.getAttribute("NickName"); @@ -92,7 +92,7 @@ public class InterfaceBasedMBeanInfoAssemblerMappedTests extends AbstractJmxAsse } @Override - protected MBeanInfoAssembler getAssembler() throws Exception { + protected MBeanInfoAssembler getAssembler() { return getWithMapping( "org.springframework.jmx.export.assembler.IAdditionalTestMethods, " + "org.springframework.jmx.export.assembler.ICustomJmxBean"); diff --git a/spring-context/src/test/java/org/springframework/jmx/export/assembler/InterfaceBasedMBeanInfoAssemblerTests.java b/spring-context/src/test/java/org/springframework/jmx/export/assembler/InterfaceBasedMBeanInfoAssemblerTests.java index 699b56312cc..69225145ce4 100644 --- a/spring-context/src/test/java/org/springframework/jmx/export/assembler/InterfaceBasedMBeanInfoAssemblerTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/export/assembler/InterfaceBasedMBeanInfoAssemblerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,7 @@ package org.springframework.jmx.export.assembler; /** * @author Rob Harrop */ -public class InterfaceBasedMBeanInfoAssemblerTests extends AbstractJmxAssemblerTests { +class InterfaceBasedMBeanInfoAssemblerTests extends AbstractJmxAssemblerTests { @Override protected String getObjectName() { diff --git a/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodExclusionMBeanInfoAssemblerComboTests.java b/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodExclusionMBeanInfoAssemblerComboTests.java index 42214760d79..08a05ff4519 100644 --- a/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodExclusionMBeanInfoAssemblerComboTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodExclusionMBeanInfoAssemblerComboTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,12 +31,12 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Rob Harrop * @author Chris Beams */ -public class MethodExclusionMBeanInfoAssemblerComboTests extends AbstractJmxAssemblerTests { +class MethodExclusionMBeanInfoAssemblerComboTests extends AbstractJmxAssemblerTests { protected static final String OBJECT_NAME = "bean:name=testBean4"; @Test - public void testGetAgeIsReadOnly() throws Exception { + void testGetAgeIsReadOnly() throws Exception { ModelMBeanInfo info = getMBeanInfoFromAssembler(); ModelMBeanAttributeInfo attr = info.getAttribute(AGE_ATTRIBUTE); assertThat(attr.isReadable()).as("Age is not readable").isTrue(); @@ -44,7 +44,7 @@ public class MethodExclusionMBeanInfoAssemblerComboTests extends AbstractJmxAsse } @Test - public void testNickNameIsExposed() throws Exception { + void testNickNameIsExposed() throws Exception { ModelMBeanInfo inf = (ModelMBeanInfo) getMBeanInfo(); MBeanAttributeInfo attr = inf.getAttribute("NickName"); assertThat(attr).as("Nick Name should not be null").isNotNull(); @@ -73,7 +73,7 @@ public class MethodExclusionMBeanInfoAssemblerComboTests extends AbstractJmxAsse } @Override - protected MBeanInfoAssembler getAssembler() throws Exception { + protected MBeanInfoAssembler getAssembler() { MethodExclusionMBeanInfoAssembler assembler = new MethodExclusionMBeanInfoAssembler(); Properties props = new Properties(); props.setProperty(OBJECT_NAME, "setAge,isSuperman,setSuperman,dontExposeMe"); diff --git a/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodExclusionMBeanInfoAssemblerMappedTests.java b/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodExclusionMBeanInfoAssemblerMappedTests.java index c5a35ccc835..080b2b19bfd 100644 --- a/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodExclusionMBeanInfoAssemblerMappedTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodExclusionMBeanInfoAssemblerMappedTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,12 +30,12 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Rob Harrop * @author Chris Beams */ -public class MethodExclusionMBeanInfoAssemblerMappedTests extends AbstractJmxAssemblerTests { +class MethodExclusionMBeanInfoAssemblerMappedTests extends AbstractJmxAssemblerTests { protected static final String OBJECT_NAME = "bean:name=testBean4"; @Test - public void testGetAgeIsReadOnly() throws Exception { + void testGetAgeIsReadOnly() throws Exception { ModelMBeanInfo info = getMBeanInfoFromAssembler(); ModelMBeanAttributeInfo attr = info.getAttribute(AGE_ATTRIBUTE); assertThat(attr.isReadable()).as("Age is not readable").isTrue(); @@ -43,7 +43,7 @@ public class MethodExclusionMBeanInfoAssemblerMappedTests extends AbstractJmxAss } @Test - public void testNickNameIsExposed() throws Exception { + void testNickNameIsExposed() throws Exception { ModelMBeanInfo inf = (ModelMBeanInfo) getMBeanInfo(); MBeanAttributeInfo attr = inf.getAttribute("NickName"); assertThat(attr).as("Nick Name should not be null").isNotNull(); @@ -72,7 +72,7 @@ public class MethodExclusionMBeanInfoAssemblerMappedTests extends AbstractJmxAss } @Override - protected MBeanInfoAssembler getAssembler() throws Exception { + protected MBeanInfoAssembler getAssembler() { MethodExclusionMBeanInfoAssembler assembler = new MethodExclusionMBeanInfoAssembler(); Properties props = new Properties(); props.setProperty(OBJECT_NAME, "setAge,isSuperman,setSuperman,dontExposeMe"); diff --git a/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodExclusionMBeanInfoAssemblerNotMappedTests.java b/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodExclusionMBeanInfoAssemblerNotMappedTests.java index 514a75dcd22..50943d36b1b 100644 --- a/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodExclusionMBeanInfoAssemblerNotMappedTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodExclusionMBeanInfoAssemblerNotMappedTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,12 +31,12 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Rob Harrop * @author Chris Beams */ -public class MethodExclusionMBeanInfoAssemblerNotMappedTests extends AbstractJmxAssemblerTests { +class MethodExclusionMBeanInfoAssemblerNotMappedTests extends AbstractJmxAssemblerTests { protected static final String OBJECT_NAME = "bean:name=testBean4"; @Test - public void testGetAgeIsReadOnly() throws Exception { + void testGetAgeIsReadOnly() throws Exception { ModelMBeanInfo info = getMBeanInfoFromAssembler(); ModelMBeanAttributeInfo attr = info.getAttribute(AGE_ATTRIBUTE); assertThat(attr.isReadable()).as("Age is not readable").isTrue(); @@ -44,7 +44,7 @@ public class MethodExclusionMBeanInfoAssemblerNotMappedTests extends AbstractJmx } @Test - public void testNickNameIsExposed() throws Exception { + void testNickNameIsExposed() throws Exception { ModelMBeanInfo inf = (ModelMBeanInfo) getMBeanInfo(); MBeanAttributeInfo attr = inf.getAttribute("NickName"); assertThat(attr).as("Nick Name should not be null").isNotNull(); @@ -73,7 +73,7 @@ public class MethodExclusionMBeanInfoAssemblerNotMappedTests extends AbstractJmx } @Override - protected MBeanInfoAssembler getAssembler() throws Exception { + protected MBeanInfoAssembler getAssembler() { MethodExclusionMBeanInfoAssembler assembler = new MethodExclusionMBeanInfoAssembler(); Properties props = new Properties(); props.setProperty("bean:name=testBean5", "setAge,isSuperman,setSuperman,dontExposeMe"); diff --git a/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodExclusionMBeanInfoAssemblerTests.java b/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodExclusionMBeanInfoAssemblerTests.java index ce6fa1bd516..83f5b1cc25e 100644 --- a/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodExclusionMBeanInfoAssemblerTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodExclusionMBeanInfoAssemblerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,7 +33,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Rick Evans * @author Chris Beams */ -public class MethodExclusionMBeanInfoAssemblerTests extends AbstractJmxAssemblerTests { +class MethodExclusionMBeanInfoAssemblerTests extends AbstractJmxAssemblerTests { private static final String OBJECT_NAME = "bean:name=testBean5"; @@ -66,7 +66,7 @@ public class MethodExclusionMBeanInfoAssemblerTests extends AbstractJmxAssembler } @Test - public void testSupermanIsReadOnly() throws Exception { + void testSupermanIsReadOnly() throws Exception { ModelMBeanInfo info = getMBeanInfoFromAssembler(); ModelMBeanAttributeInfo attr = info.getAttribute("Superman"); @@ -78,7 +78,7 @@ public class MethodExclusionMBeanInfoAssemblerTests extends AbstractJmxAssembler * https://opensource.atlassian.com/projects/spring/browse/SPR-2754 */ @Test - public void testIsNotIgnoredDoesntIgnoreUnspecifiedBeanMethods() throws Exception { + void testIsNotIgnoredDoesntIgnoreUnspecifiedBeanMethods() throws Exception { final String beanKey = "myTestBean"; MethodExclusionMBeanInfoAssembler assembler = new MethodExclusionMBeanInfoAssembler(); Properties ignored = new Properties(); diff --git a/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodNameBasedMBeanInfoAssemblerMappedTests.java b/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodNameBasedMBeanInfoAssemblerMappedTests.java index 875d932d09e..02a1bb59d07 100644 --- a/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodNameBasedMBeanInfoAssemblerMappedTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodNameBasedMBeanInfoAssemblerMappedTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,13 +30,13 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Rob Harrop * @author Chris Beams */ -public class MethodNameBasedMBeanInfoAssemblerMappedTests extends AbstractJmxAssemblerTests { +class MethodNameBasedMBeanInfoAssemblerMappedTests extends AbstractJmxAssemblerTests { protected static final String OBJECT_NAME = "bean:name=testBean4"; @Test - public void testGetAgeIsReadOnly() throws Exception { + void testGetAgeIsReadOnly() throws Exception { ModelMBeanInfo info = getMBeanInfoFromAssembler(); ModelMBeanAttributeInfo attr = info.getAttribute(AGE_ATTRIBUTE); @@ -45,7 +45,7 @@ public class MethodNameBasedMBeanInfoAssemblerMappedTests extends AbstractJmxAss } @Test - public void testWithFallThrough() throws Exception { + void testWithFallThrough() throws Exception { MethodNameBasedMBeanInfoAssembler assembler = getWithMapping("foobar", "add,myOperation,getName,setName,getAge"); assembler.setManagedMethods("getNickName", "setNickName"); @@ -57,7 +57,7 @@ public class MethodNameBasedMBeanInfoAssemblerMappedTests extends AbstractJmxAss } @Test - public void testNickNameIsExposed() throws Exception { + void testNickNameIsExposed() throws Exception { ModelMBeanInfo inf = (ModelMBeanInfo) getMBeanInfo(); MBeanAttributeInfo attr = inf.getAttribute("NickName"); @@ -80,7 +80,7 @@ public class MethodNameBasedMBeanInfoAssemblerMappedTests extends AbstractJmxAss } @Override - protected MBeanInfoAssembler getAssembler() throws Exception { + protected MBeanInfoAssembler getAssembler() { return getWithMapping("getNickName,setNickName,add,myOperation,getName,setName,getAge"); } diff --git a/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodNameBasedMBeanInfoAssemblerTests.java b/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodNameBasedMBeanInfoAssemblerTests.java index f287abb69ef..6d691f86143 100644 --- a/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodNameBasedMBeanInfoAssemblerTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodNameBasedMBeanInfoAssemblerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,7 +29,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @author David Boden * @author Chris Beams */ -public class MethodNameBasedMBeanInfoAssemblerTests extends AbstractJmxAssemblerTests { +class MethodNameBasedMBeanInfoAssemblerTests extends AbstractJmxAssemblerTests { protected static final String OBJECT_NAME = "bean:name=testBean5"; @@ -57,7 +57,7 @@ public class MethodNameBasedMBeanInfoAssemblerTests extends AbstractJmxAssembler } @Test - public void testGetAgeIsReadOnly() throws Exception { + void testGetAgeIsReadOnly() throws Exception { ModelMBeanInfo info = getMBeanInfoFromAssembler(); ModelMBeanAttributeInfo attr = info.getAttribute(AGE_ATTRIBUTE); @@ -66,7 +66,7 @@ public class MethodNameBasedMBeanInfoAssemblerTests extends AbstractJmxAssembler } @Test - public void testSetNameParameterIsNamed() throws Exception { + void testSetNameParameterIsNamed() throws Exception { ModelMBeanInfo info = getMBeanInfoFromAssembler(); MBeanOperationInfo operationSetAge = info.getOperation("setName"); diff --git a/spring-context/src/test/java/org/springframework/jmx/export/assembler/ReflectiveAssemblerTests.java b/spring-context/src/test/java/org/springframework/jmx/export/assembler/ReflectiveAssemblerTests.java index 54b3c546714..a96de524c05 100644 --- a/spring-context/src/test/java/org/springframework/jmx/export/assembler/ReflectiveAssemblerTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/export/assembler/ReflectiveAssemblerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,7 @@ package org.springframework.jmx.export.assembler; /** * @author Rob Harrop */ -public class ReflectiveAssemblerTests extends AbstractJmxAssemblerTests { +class ReflectiveAssemblerTests extends AbstractJmxAssemblerTests { protected static final String OBJECT_NAME = "bean:name=testBean1"; diff --git a/spring-context/src/test/java/org/springframework/jmx/export/naming/AbstractNamingStrategyTests.java b/spring-context/src/test/java/org/springframework/jmx/export/naming/AbstractNamingStrategyTests.java index 404c7df367b..66c6e5ad9ae 100644 --- a/spring-context/src/test/java/org/springframework/jmx/export/naming/AbstractNamingStrategyTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/export/naming/AbstractNamingStrategyTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,7 +28,7 @@ import static org.assertj.core.api.Assertions.assertThat; public abstract class AbstractNamingStrategyTests { @Test - public void naming() throws Exception { + void naming() throws Exception { ObjectNamingStrategy strat = getStrategy(); ObjectName objectName = strat.getObjectName(getManagedResource(), getKey()); assertThat(getCorrectObjectName()).isEqualTo(objectName.getCanonicalName()); @@ -36,7 +36,7 @@ public abstract class AbstractNamingStrategyTests { protected abstract ObjectNamingStrategy getStrategy() throws Exception; - protected abstract Object getManagedResource() throws Exception; + protected abstract Object getManagedResource(); protected abstract String getKey(); diff --git a/spring-context/src/test/java/org/springframework/jmx/export/naming/IdentityNamingStrategyTests.java b/spring-context/src/test/java/org/springframework/jmx/export/naming/IdentityNamingStrategyTests.java index 3aa4baa2053..ad99a3b4f7a 100644 --- a/spring-context/src/test/java/org/springframework/jmx/export/naming/IdentityNamingStrategyTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/export/naming/IdentityNamingStrategyTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,10 +30,10 @@ import static org.assertj.core.api.Assertions.assertThat; /** * @author Rob Harrop */ -public class IdentityNamingStrategyTests { +class IdentityNamingStrategyTests { @Test - public void naming() throws MalformedObjectNameException { + void naming() throws MalformedObjectNameException { JmxTestBean bean = new JmxTestBean(); IdentityNamingStrategy strategy = new IdentityNamingStrategy(); ObjectName objectName = strategy.getObjectName(bean, "null"); diff --git a/spring-context/src/test/java/org/springframework/jmx/export/naming/KeyNamingStrategyTests.java b/spring-context/src/test/java/org/springframework/jmx/export/naming/KeyNamingStrategyTests.java index 53b64367e3d..c16d05e6a5a 100644 --- a/spring-context/src/test/java/org/springframework/jmx/export/naming/KeyNamingStrategyTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/export/naming/KeyNamingStrategyTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,13 +19,13 @@ package org.springframework.jmx.export.naming; /** * @author Rob Harrop */ -public class KeyNamingStrategyTests extends AbstractNamingStrategyTests { +class KeyNamingStrategyTests extends AbstractNamingStrategyTests { private static final String OBJECT_NAME = "spring:name=test"; @Override - protected ObjectNamingStrategy getStrategy() throws Exception { + protected ObjectNamingStrategy getStrategy() { return new KeyNamingStrategy(); } diff --git a/spring-context/src/test/java/org/springframework/jmx/export/naming/PropertiesFileNamingStrategyTests.java b/spring-context/src/test/java/org/springframework/jmx/export/naming/PropertiesFileNamingStrategyTests.java index aaade22dcb4..39c21311d61 100644 --- a/spring-context/src/test/java/org/springframework/jmx/export/naming/PropertiesFileNamingStrategyTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/export/naming/PropertiesFileNamingStrategyTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,7 @@ import org.springframework.core.io.ClassPathResource; /** * @author Juergen Hoeller */ -public class PropertiesFileNamingStrategyTests extends PropertiesNamingStrategyTests { +class PropertiesFileNamingStrategyTests extends PropertiesNamingStrategyTests { @Override protected ObjectNamingStrategy getStrategy() throws Exception { diff --git a/spring-context/src/test/java/org/springframework/jmx/export/naming/PropertiesNamingStrategyTests.java b/spring-context/src/test/java/org/springframework/jmx/export/naming/PropertiesNamingStrategyTests.java index d2a2a41ae49..e1e58562e85 100644 --- a/spring-context/src/test/java/org/springframework/jmx/export/naming/PropertiesNamingStrategyTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/export/naming/PropertiesNamingStrategyTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ import java.util.Properties; * @author Rob Harrop * @author Juergen Hoeller */ -public class PropertiesNamingStrategyTests extends AbstractNamingStrategyTests { +class PropertiesNamingStrategyTests extends AbstractNamingStrategyTests { private static final String OBJECT_NAME = "bean:name=namingTest"; diff --git a/spring-context/src/test/java/org/springframework/jmx/export/notification/ModelMBeanNotificationPublisherTests.java b/spring-context/src/test/java/org/springframework/jmx/export/notification/ModelMBeanNotificationPublisherTests.java index f64fbb13ccd..f1def7aede8 100644 --- a/spring-context/src/test/java/org/springframework/jmx/export/notification/ModelMBeanNotificationPublisherTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/export/notification/ModelMBeanNotificationPublisherTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,28 +34,28 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException * @author Rick Evans * @author Chris Beams */ -public class ModelMBeanNotificationPublisherTests { +class ModelMBeanNotificationPublisherTests { @Test - public void testCtorWithNullMBean() throws Exception { + void testCtorWithNullMBean() { assertThatIllegalArgumentException().isThrownBy(() -> new ModelMBeanNotificationPublisher(null, createObjectName(), this)); } @Test - public void testCtorWithNullObjectName() throws Exception { + void testCtorWithNullObjectName() { assertThatIllegalArgumentException().isThrownBy(() -> new ModelMBeanNotificationPublisher(new SpringModelMBean(), null, this)); } @Test - public void testCtorWithNullManagedResource() throws Exception { + void testCtorWithNullManagedResource() { assertThatIllegalArgumentException().isThrownBy(() -> new ModelMBeanNotificationPublisher(new SpringModelMBean(), createObjectName(), null)); } @Test - public void testSendNullNotification() throws Exception { + void testSendNullNotification() throws Exception { NotificationPublisher publisher = new ModelMBeanNotificationPublisher(new SpringModelMBean(), createObjectName(), this); assertThatIllegalArgumentException().isThrownBy(() -> @@ -63,7 +63,7 @@ public class ModelMBeanNotificationPublisherTests { } @Test - public void testSendVanillaNotification() throws Exception { + void testSendVanillaNotification() throws Exception { StubSpringModelMBean mbean = new StubSpringModelMBean(); Notification notification = new Notification("network.alarm.router", mbean, 1872); ObjectName objectName = createObjectName(); @@ -77,7 +77,7 @@ public class ModelMBeanNotificationPublisherTests { } @Test - public void testSendAttributeChangeNotification() throws Exception { + void testSendAttributeChangeNotification() throws Exception { StubSpringModelMBean mbean = new StubSpringModelMBean(); Notification notification = new AttributeChangeNotification(mbean, 1872, System.currentTimeMillis(), "Shall we break for some tea?", "agree", "java.lang.Boolean", Boolean.FALSE, Boolean.TRUE); ObjectName objectName = createObjectName(); @@ -93,7 +93,7 @@ public class ModelMBeanNotificationPublisherTests { } @Test - public void testSendAttributeChangeNotificationWhereSourceIsNotTheManagedResource() throws Exception { + void testSendAttributeChangeNotificationWhereSourceIsNotTheManagedResource() throws Exception { StubSpringModelMBean mbean = new StubSpringModelMBean(); Notification notification = new AttributeChangeNotification(this, 1872, System.currentTimeMillis(), "Shall we break for some tea?", "agree", "java.lang.Boolean", Boolean.FALSE, Boolean.TRUE); ObjectName objectName = createObjectName(); diff --git a/spring-context/src/test/java/org/springframework/jmx/support/ConnectorServerFactoryBeanTests.java b/spring-context/src/test/java/org/springframework/jmx/support/ConnectorServerFactoryBeanTests.java index 5f349774451..db4d84a032b 100644 --- a/spring-context/src/test/java/org/springframework/jmx/support/ConnectorServerFactoryBeanTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/support/ConnectorServerFactoryBeanTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,6 @@ package org.springframework.jmx.support; import java.io.IOException; -import java.net.MalformedURLException; import javax.management.InstanceNotFoundException; import javax.management.MBeanServer; @@ -47,7 +46,6 @@ class ConnectorServerFactoryBeanTests extends AbstractMBeanServerTests { private static final String OBJECT_NAME = "spring:type=connector,name=test"; - @SuppressWarnings("deprecation") private final String serviceUrl = "service:jmx:jmxmp://localhost:" + TestSocketUtils.findAvailableTcpPort(); @@ -112,7 +110,7 @@ class ConnectorServerFactoryBeanTests extends AbstractMBeanServerTests { } } - private void checkServerConnection(MBeanServer hostedServer) throws IOException, MalformedURLException { + private void checkServerConnection(MBeanServer hostedServer) throws IOException { // Try to connect using client. JMXServiceURL serviceURL = new JMXServiceURL(this.serviceUrl); JMXConnector connector = JMXConnectorFactory.connect(serviceURL); diff --git a/spring-context/src/test/java/org/springframework/jmx/support/MBeanServerConnectionFactoryBeanTests.java b/spring-context/src/test/java/org/springframework/jmx/support/MBeanServerConnectionFactoryBeanTests.java index 6391f607f93..51fc4e44e31 100644 --- a/spring-context/src/test/java/org/springframework/jmx/support/MBeanServerConnectionFactoryBeanTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/support/MBeanServerConnectionFactoryBeanTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,7 +44,7 @@ class MBeanServerConnectionFactoryBeanTests extends AbstractMBeanServerTests { @Test - void noServiceUrl() throws Exception { + void noServiceUrl() { MBeanServerConnectionFactoryBean bean = new MBeanServerConnectionFactoryBean(); assertThatIllegalArgumentException() .isThrownBy(bean::afterPropertiesSet) diff --git a/spring-context/src/test/java/org/springframework/jmx/support/MBeanServerFactoryBeanTests.java b/spring-context/src/test/java/org/springframework/jmx/support/MBeanServerFactoryBeanTests.java index a0092708c58..e35bc130cfb 100644 --- a/spring-context/src/test/java/org/springframework/jmx/support/MBeanServerFactoryBeanTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/support/MBeanServerFactoryBeanTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,7 +42,7 @@ class MBeanServerFactoryBeanTests { @BeforeEach @AfterEach - void resetMBeanServers() throws Exception { + void resetMBeanServers() { MBeanTestUtils.resetMBeanServers(); } @@ -120,12 +120,12 @@ class MBeanServerFactoryBeanTests { } @Test - void createMBeanServer() throws Exception { + void createMBeanServer() { assertCreation(true, "The server should be available in the list"); } @Test - void newMBeanServer() throws Exception { + void newMBeanServer() { assertCreation(false, "The server should not be available in the list"); } diff --git a/spring-context/src/test/java/org/springframework/jndi/JndiObjectFactoryBeanTests.java b/spring-context/src/test/java/org/springframework/jndi/JndiObjectFactoryBeanTests.java index 4b9c4f7af23..f33f555dfcb 100644 --- a/spring-context/src/test/java/org/springframework/jndi/JndiObjectFactoryBeanTests.java +++ b/spring-context/src/test/java/org/springframework/jndi/JndiObjectFactoryBeanTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,16 +41,16 @@ import static org.mockito.Mockito.verify; * @author Juergen Hoeller * @author Chris Beams */ -public class JndiObjectFactoryBeanTests { +class JndiObjectFactoryBeanTests { @Test - public void testNoJndiName() throws NamingException { + void testNoJndiName() { JndiObjectFactoryBean jof = new JndiObjectFactoryBean(); assertThatIllegalArgumentException().isThrownBy(jof::afterPropertiesSet); } @Test - public void testLookupWithFullNameAndResourceRefTrue() throws Exception { + void testLookupWithFullNameAndResourceRefTrue() throws Exception { JndiObjectFactoryBean jof = new JndiObjectFactoryBean(); Object o = new Object(); jof.setJndiTemplate(new ExpectedLookupTemplate("java:comp/env/foo", o)); @@ -61,7 +61,7 @@ public class JndiObjectFactoryBeanTests { } @Test - public void testLookupWithFullNameAndResourceRefFalse() throws Exception { + void testLookupWithFullNameAndResourceRefFalse() throws Exception { JndiObjectFactoryBean jof = new JndiObjectFactoryBean(); Object o = new Object(); jof.setJndiTemplate(new ExpectedLookupTemplate("java:comp/env/foo", o)); @@ -72,7 +72,7 @@ public class JndiObjectFactoryBeanTests { } @Test - public void testLookupWithSchemeNameAndResourceRefTrue() throws Exception { + void testLookupWithSchemeNameAndResourceRefTrue() throws Exception { JndiObjectFactoryBean jof = new JndiObjectFactoryBean(); Object o = new Object(); jof.setJndiTemplate(new ExpectedLookupTemplate("java:foo", o)); @@ -83,7 +83,7 @@ public class JndiObjectFactoryBeanTests { } @Test - public void testLookupWithSchemeNameAndResourceRefFalse() throws Exception { + void testLookupWithSchemeNameAndResourceRefFalse() throws Exception { JndiObjectFactoryBean jof = new JndiObjectFactoryBean(); Object o = new Object(); jof.setJndiTemplate(new ExpectedLookupTemplate("java:foo", o)); @@ -94,7 +94,7 @@ public class JndiObjectFactoryBeanTests { } @Test - public void testLookupWithShortNameAndResourceRefTrue() throws Exception { + void testLookupWithShortNameAndResourceRefTrue() throws Exception { JndiObjectFactoryBean jof = new JndiObjectFactoryBean(); Object o = new Object(); jof.setJndiTemplate(new ExpectedLookupTemplate("java:comp/env/foo", o)); @@ -105,7 +105,7 @@ public class JndiObjectFactoryBeanTests { } @Test - public void testLookupWithShortNameAndResourceRefFalse() throws Exception { + void testLookupWithShortNameAndResourceRefFalse() { JndiObjectFactoryBean jof = new JndiObjectFactoryBean(); Object o = new Object(); jof.setJndiTemplate(new ExpectedLookupTemplate("java:comp/env/foo", o)); @@ -115,7 +115,7 @@ public class JndiObjectFactoryBeanTests { } @Test - public void testLookupWithArbitraryNameAndResourceRefFalse() throws Exception { + void testLookupWithArbitraryNameAndResourceRefFalse() throws Exception { JndiObjectFactoryBean jof = new JndiObjectFactoryBean(); Object o = new Object(); jof.setJndiTemplate(new ExpectedLookupTemplate("foo", o)); @@ -126,7 +126,7 @@ public class JndiObjectFactoryBeanTests { } @Test - public void testLookupWithExpectedTypeAndMatch() throws Exception { + void testLookupWithExpectedTypeAndMatch() throws Exception { JndiObjectFactoryBean jof = new JndiObjectFactoryBean(); String s = ""; jof.setJndiTemplate(new ExpectedLookupTemplate("foo", s)); @@ -137,7 +137,7 @@ public class JndiObjectFactoryBeanTests { } @Test - public void testLookupWithExpectedTypeAndNoMatch() throws Exception { + void testLookupWithExpectedTypeAndNoMatch() { JndiObjectFactoryBean jof = new JndiObjectFactoryBean(); jof.setJndiTemplate(new ExpectedLookupTemplate("foo", new Object())); jof.setJndiName("foo"); @@ -148,7 +148,7 @@ public class JndiObjectFactoryBeanTests { } @Test - public void testLookupWithDefaultObject() throws Exception { + void testLookupWithDefaultObject() throws Exception { JndiObjectFactoryBean jof = new JndiObjectFactoryBean(); jof.setJndiTemplate(new ExpectedLookupTemplate("foo", "")); jof.setJndiName("myFoo"); @@ -159,7 +159,7 @@ public class JndiObjectFactoryBeanTests { } @Test - public void testLookupWithDefaultObjectAndExpectedType() throws Exception { + void testLookupWithDefaultObjectAndExpectedType() throws Exception { JndiObjectFactoryBean jof = new JndiObjectFactoryBean(); jof.setJndiTemplate(new ExpectedLookupTemplate("foo", "")); jof.setJndiName("myFoo"); @@ -170,7 +170,7 @@ public class JndiObjectFactoryBeanTests { } @Test - public void testLookupWithDefaultObjectAndExpectedTypeConversion() throws Exception { + void testLookupWithDefaultObjectAndExpectedTypeConversion() throws Exception { JndiObjectFactoryBean jof = new JndiObjectFactoryBean(); jof.setJndiTemplate(new ExpectedLookupTemplate("foo", "")); jof.setJndiName("myFoo"); @@ -181,7 +181,7 @@ public class JndiObjectFactoryBeanTests { } @Test - public void testLookupWithDefaultObjectAndExpectedTypeConversionViaBeanFactory() throws Exception { + void testLookupWithDefaultObjectAndExpectedTypeConversionViaBeanFactory() throws Exception { JndiObjectFactoryBean jof = new JndiObjectFactoryBean(); jof.setJndiTemplate(new ExpectedLookupTemplate("foo", "")); jof.setJndiName("myFoo"); @@ -193,7 +193,7 @@ public class JndiObjectFactoryBeanTests { } @Test - public void testLookupWithDefaultObjectAndExpectedTypeNoMatch() throws Exception { + void testLookupWithDefaultObjectAndExpectedTypeNoMatch() { JndiObjectFactoryBean jof = new JndiObjectFactoryBean(); jof.setJndiTemplate(new ExpectedLookupTemplate("foo", "")); jof.setJndiName("myFoo"); @@ -203,7 +203,7 @@ public class JndiObjectFactoryBeanTests { } @Test - public void testLookupWithProxyInterface() throws Exception { + void testLookupWithProxyInterface() throws Exception { JndiObjectFactoryBean jof = new JndiObjectFactoryBean(); TestBean tb = new TestBean(); jof.setJndiTemplate(new ExpectedLookupTemplate("foo", tb)); @@ -219,7 +219,7 @@ public class JndiObjectFactoryBeanTests { } @Test - public void testLookupWithProxyInterfaceAndDefaultObject() throws Exception { + void testLookupWithProxyInterfaceAndDefaultObject() { JndiObjectFactoryBean jof = new JndiObjectFactoryBean(); TestBean tb = new TestBean(); jof.setJndiTemplate(new ExpectedLookupTemplate("foo", tb)); @@ -230,7 +230,7 @@ public class JndiObjectFactoryBeanTests { } @Test - public void testLookupWithProxyInterfaceAndLazyLookup() throws Exception { + void testLookupWithProxyInterfaceAndLazyLookup() throws Exception { JndiObjectFactoryBean jof = new JndiObjectFactoryBean(); final TestBean tb = new TestBean(); jof.setJndiTemplate(new JndiTemplate() { @@ -258,7 +258,7 @@ public class JndiObjectFactoryBeanTests { } @Test - public void testLookupWithProxyInterfaceWithNotCache() throws Exception { + void testLookupWithProxyInterfaceWithNotCache() throws Exception { JndiObjectFactoryBean jof = new JndiObjectFactoryBean(); final TestBean tb = new TestBean(); jof.setJndiTemplate(new JndiTemplate() { @@ -288,7 +288,7 @@ public class JndiObjectFactoryBeanTests { } @Test - public void testLookupWithProxyInterfaceWithLazyLookupAndNotCache() throws Exception { + void testLookupWithProxyInterfaceWithLazyLookupAndNotCache() throws Exception { JndiObjectFactoryBean jof = new JndiObjectFactoryBean(); final TestBean tb = new TestBean(); jof.setJndiTemplate(new JndiTemplate() { @@ -322,7 +322,7 @@ public class JndiObjectFactoryBeanTests { } @Test - public void testLazyLookupWithoutProxyInterface() throws NamingException { + void testLazyLookupWithoutProxyInterface() { JndiObjectFactoryBean jof = new JndiObjectFactoryBean(); jof.setJndiName("foo"); jof.setLookupOnStartup(false); @@ -330,7 +330,7 @@ public class JndiObjectFactoryBeanTests { } @Test - public void testNotCacheWithoutProxyInterface() throws NamingException { + void testNotCacheWithoutProxyInterface() { JndiObjectFactoryBean jof = new JndiObjectFactoryBean(); jof.setJndiName("foo"); jof.setCache(false); @@ -339,7 +339,7 @@ public class JndiObjectFactoryBeanTests { } @Test - public void testLookupWithProxyInterfaceAndExpectedTypeAndMatch() throws Exception { + void testLookupWithProxyInterfaceAndExpectedTypeAndMatch() throws Exception { JndiObjectFactoryBean jof = new JndiObjectFactoryBean(); TestBean tb = new TestBean(); jof.setJndiTemplate(new ExpectedLookupTemplate("foo", tb)); @@ -356,7 +356,7 @@ public class JndiObjectFactoryBeanTests { } @Test - public void testLookupWithProxyInterfaceAndExpectedTypeAndNoMatch() { + void testLookupWithProxyInterfaceAndExpectedTypeAndNoMatch() { JndiObjectFactoryBean jof = new JndiObjectFactoryBean(); TestBean tb = new TestBean(); jof.setJndiTemplate(new ExpectedLookupTemplate("foo", tb)); @@ -369,7 +369,7 @@ public class JndiObjectFactoryBeanTests { } @Test - public void testLookupWithExposeAccessContext() throws Exception { + void testLookupWithExposeAccessContext() throws Exception { JndiObjectFactoryBean jof = new JndiObjectFactoryBean(); TestBean tb = new TestBean(); final Context mockCtx = mock(); diff --git a/spring-context/src/test/java/org/springframework/jndi/JndiPropertySourceTests.java b/spring-context/src/test/java/org/springframework/jndi/JndiPropertySourceTests.java index 9ece68cea27..a153b616798 100644 --- a/spring-context/src/test/java/org/springframework/jndi/JndiPropertySourceTests.java +++ b/spring-context/src/test/java/org/springframework/jndi/JndiPropertySourceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,6 @@ package org.springframework.jndi; import javax.naming.Context; -import javax.naming.NamingException; import org.junit.jupiter.api.Test; @@ -32,22 +31,22 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Juergen Hoeller * @since 3.1 */ -public class JndiPropertySourceTests { +class JndiPropertySourceTests { @Test - public void nonExistentProperty() { + void nonExistentProperty() { JndiPropertySource ps = new JndiPropertySource("jndiProperties"); assertThat(ps.getProperty("bogus")).isNull(); } @Test - public void nameBoundWithoutPrefix() { + void nameBoundWithoutPrefix() { final SimpleNamingContext context = new SimpleNamingContext(); context.bind("p1", "v1"); JndiTemplate jndiTemplate = new JndiTemplate() { @Override - protected Context createInitialContext() throws NamingException { + protected Context createInitialContext() { return context; } }; @@ -60,13 +59,13 @@ public class JndiPropertySourceTests { } @Test - public void nameBoundWithPrefix() { + void nameBoundWithPrefix() { final SimpleNamingContext context = new SimpleNamingContext(); context.bind("java:comp/env/p1", "v1"); JndiTemplate jndiTemplate = new JndiTemplate() { @Override - protected Context createInitialContext() throws NamingException { + protected Context createInitialContext() { return context; } }; @@ -79,10 +78,10 @@ public class JndiPropertySourceTests { } @Test - public void propertyWithDefaultClauseInResourceRefMode() { + void propertyWithDefaultClauseInResourceRefMode() { JndiLocatorDelegate jndiLocator = new JndiLocatorDelegate() { @Override - public Object lookup(String jndiName) throws NamingException { + public Object lookup(String jndiName) { throw new IllegalStateException("Should not get called"); } }; @@ -93,10 +92,10 @@ public class JndiPropertySourceTests { } @Test - public void propertyWithColonInNonResourceRefMode() { + void propertyWithColonInNonResourceRefMode() { JndiLocatorDelegate jndiLocator = new JndiLocatorDelegate() { @Override - public Object lookup(String jndiName) throws NamingException { + public Object lookup(String jndiName) { assertThat(jndiName).isEqualTo("my:key"); return "my:value"; } diff --git a/spring-context/src/test/java/org/springframework/jndi/JndiTemplateEditorTests.java b/spring-context/src/test/java/org/springframework/jndi/JndiTemplateEditorTests.java index eaeb25836b1..3343fc1d505 100644 --- a/spring-context/src/test/java/org/springframework/jndi/JndiTemplateEditorTests.java +++ b/spring-context/src/test/java/org/springframework/jndi/JndiTemplateEditorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,16 +25,16 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException * @author Rod Johnson * @author Chris Beams */ -public class JndiTemplateEditorTests { +class JndiTemplateEditorTests { @Test - public void testNullIsIllegalArgument() { + void testNullIsIllegalArgument() { assertThatIllegalArgumentException().isThrownBy(() -> new JndiTemplateEditor().setAsText(null)); } @Test - public void testEmptyStringMeansNullEnvironment() { + void testEmptyStringMeansNullEnvironment() { JndiTemplateEditor je = new JndiTemplateEditor(); je.setAsText(""); JndiTemplate jt = (JndiTemplate) je.getValue(); @@ -42,7 +42,7 @@ public class JndiTemplateEditorTests { } @Test - public void testCustomEnvironment() { + void testCustomEnvironment() { JndiTemplateEditor je = new JndiTemplateEditor(); // These properties are meaningless for JNDI, but we don't worry about that: // the underlying JNDI implementation will throw exceptions when the user tries diff --git a/spring-context/src/test/java/org/springframework/jndi/JndiTemplateTests.java b/spring-context/src/test/java/org/springframework/jndi/JndiTemplateTests.java index a61b632735f..b6db8ea6dca 100644 --- a/spring-context/src/test/java/org/springframework/jndi/JndiTemplateTests.java +++ b/spring-context/src/test/java/org/springframework/jndi/JndiTemplateTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,10 +33,10 @@ import static org.mockito.Mockito.verify; * @author Chris Beams * @since 08.07.2003 */ -public class JndiTemplateTests { +class JndiTemplateTests { @Test - public void testLookupSucceeds() throws Exception { + void testLookupSucceeds() throws Exception { Object o = new Object(); String name = "foo"; final Context context = mock(); @@ -55,7 +55,7 @@ public class JndiTemplateTests { } @Test - public void testLookupFails() throws Exception { + void testLookupFails() throws Exception { NameNotFoundException ne = new NameNotFoundException(); String name = "foo"; final Context context = mock(); @@ -74,7 +74,7 @@ public class JndiTemplateTests { } @Test - public void testLookupReturnsNull() throws Exception { + void testLookupReturnsNull() throws Exception { String name = "foo"; final Context context = mock(); given(context.lookup(name)).willReturn(null); @@ -92,7 +92,7 @@ public class JndiTemplateTests { } @Test - public void testLookupFailsWithTypeMismatch() throws Exception { + void testLookupFailsWithTypeMismatch() throws Exception { Object o = new Object(); String name = "foo"; final Context context = mock(); @@ -111,7 +111,7 @@ public class JndiTemplateTests { } @Test - public void testBind() throws Exception { + void testBind() throws Exception { Object o = new Object(); String name = "foo"; final Context context = mock(); @@ -129,7 +129,7 @@ public class JndiTemplateTests { } @Test - public void testRebind() throws Exception { + void testRebind() throws Exception { Object o = new Object(); String name = "foo"; final Context context = mock(); @@ -147,7 +147,7 @@ public class JndiTemplateTests { } @Test - public void testUnbind() throws Exception { + void testUnbind() throws Exception { String name = "something"; final Context context = mock(); diff --git a/spring-context/src/test/java/org/springframework/scheduling/annotation/AnnotationAsyncExecutionInterceptorTests.java b/spring-context/src/test/java/org/springframework/scheduling/annotation/AnnotationAsyncExecutionInterceptorTests.java index a7f335afa39..a726e37f2c2 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/annotation/AnnotationAsyncExecutionInterceptorTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/annotation/AnnotationAsyncExecutionInterceptorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,7 +30,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Chris Beams * @since 3.1.2 */ -public class AnnotationAsyncExecutionInterceptorTests { +class AnnotationAsyncExecutionInterceptorTests { @Test @SuppressWarnings("unused") diff --git a/spring-context/src/test/java/org/springframework/scheduling/annotation/AsyncAnnotationBeanPostProcessorTests.java b/spring-context/src/test/java/org/springframework/scheduling/annotation/AsyncAnnotationBeanPostProcessorTests.java index 3d342f0e478..9302682f690 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/annotation/AsyncAnnotationBeanPostProcessorTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/annotation/AsyncAnnotationBeanPostProcessorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -49,10 +49,10 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; * @author Juergen Hoeller * @author Stephane Nicoll */ -public class AsyncAnnotationBeanPostProcessorTests { +class AsyncAnnotationBeanPostProcessorTests { @Test - public void proxyCreated() { + void proxyCreated() { ConfigurableApplicationContext context = initContext( new RootBeanDefinition(AsyncAnnotationBeanPostProcessor.class)); Object target = context.getBean("target"); @@ -61,7 +61,7 @@ public class AsyncAnnotationBeanPostProcessorTests { } @Test - public void invokedAsynchronously() { + void invokedAsynchronously() { ConfigurableApplicationContext context = initContext( new RootBeanDefinition(AsyncAnnotationBeanPostProcessor.class)); @@ -75,7 +75,7 @@ public class AsyncAnnotationBeanPostProcessorTests { } @Test - public void invokedAsynchronouslyOnProxyTarget() { + void invokedAsynchronouslyOnProxyTarget() { StaticApplicationContext context = new StaticApplicationContext(); context.registerBeanDefinition("postProcessor", new RootBeanDefinition(AsyncAnnotationBeanPostProcessor.class)); TestBean tb = new TestBean(); @@ -94,7 +94,7 @@ public class AsyncAnnotationBeanPostProcessorTests { } @Test - public void threadNamePrefix() { + void threadNamePrefix() { BeanDefinition processorDefinition = new RootBeanDefinition(AsyncAnnotationBeanPostProcessor.class); ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); executor.setThreadNamePrefix("testExecutor"); @@ -111,7 +111,7 @@ public class AsyncAnnotationBeanPostProcessorTests { } @Test - public void taskExecutorByBeanType() { + void taskExecutorByBeanType() { StaticApplicationContext context = new StaticApplicationContext(); BeanDefinition processorDefinition = new RootBeanDefinition(AsyncAnnotationBeanPostProcessor.class); @@ -136,7 +136,7 @@ public class AsyncAnnotationBeanPostProcessorTests { } @Test - public void taskExecutorByBeanName() { + void taskExecutorByBeanName() { StaticApplicationContext context = new StaticApplicationContext(); BeanDefinition processorDefinition = new RootBeanDefinition(AsyncAnnotationBeanPostProcessor.class); @@ -165,7 +165,7 @@ public class AsyncAnnotationBeanPostProcessorTests { } @Test - public void configuredThroughNamespace() { + void configuredThroughNamespace() { GenericXmlApplicationContext context = new GenericXmlApplicationContext(); context.load(new ClassPathResource("taskNamespaceTests.xml", getClass())); context.refresh(); @@ -223,7 +223,7 @@ public class AsyncAnnotationBeanPostProcessorTests { } @Test - public void handleExceptionWithCustomExceptionHandler() { + void handleExceptionWithCustomExceptionHandler() { Method m = ReflectionUtils.findMethod(TestBean.class, "failWithVoid"); TestableAsyncUncaughtExceptionHandler exceptionHandler = new TestableAsyncUncaughtExceptionHandler(); @@ -240,7 +240,7 @@ public class AsyncAnnotationBeanPostProcessorTests { } @Test - public void exceptionHandlerThrowsUnexpectedException() { + void exceptionHandlerThrowsUnexpectedException() { Method m = ReflectionUtils.findMethod(TestBean.class, "failWithVoid"); TestableAsyncUncaughtExceptionHandler exceptionHandler = new TestableAsyncUncaughtExceptionHandler(true); diff --git a/spring-context/src/test/java/org/springframework/scheduling/annotation/AsyncExecutionTests.java b/spring-context/src/test/java/org/springframework/scheduling/annotation/AsyncExecutionTests.java index a97d1a9edf6..9774b930b72 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/annotation/AsyncExecutionTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/annotation/AsyncExecutionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -329,7 +329,7 @@ class AsyncExecutionTests { } @Test - void asyncMethodListener() throws Exception { + void asyncMethodListener() { // Arrange GenericApplicationContext context = new GenericApplicationContext(); context.registerBeanDefinition("asyncTest", new RootBeanDefinition(AsyncMethodListener.class)); @@ -346,7 +346,7 @@ class AsyncExecutionTests { } @Test - void asyncClassListener() throws Exception { + void asyncClassListener() { // Arrange GenericApplicationContext context = new GenericApplicationContext(); context.registerBeanDefinition("asyncTest", new RootBeanDefinition(AsyncClassListener.class)); @@ -364,7 +364,7 @@ class AsyncExecutionTests { } @Test - void asyncPrototypeClassListener() throws Exception { + void asyncPrototypeClassListener() { // Arrange GenericApplicationContext context = new GenericApplicationContext(); RootBeanDefinition listenerDef = new RootBeanDefinition(AsyncClassListener.class); diff --git a/spring-context/src/test/java/org/springframework/scheduling/annotation/AsyncResultTests.java b/spring-context/src/test/java/org/springframework/scheduling/annotation/AsyncResultTests.java index f4930989c0e..6c02980faef 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/annotation/AsyncResultTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/annotation/AsyncResultTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,7 +29,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; /** * @author Juergen Hoeller */ -public class AsyncResultTests { +class AsyncResultTests { @Test @SuppressWarnings("deprecation") @@ -47,7 +47,7 @@ public class AsyncResultTests { throw new AssertionError("Failure callback not expected: " + ex, ex); } }); - assertThat(values).element(0).isSameAs(value); + assertThat(values).singleElement().isSameAs(value); assertThat(future.get()).isSameAs(value); assertThat(future.completable().get()).isSameAs(value); future.completable().thenAccept(v -> assertThat(v).isSameAs(value)); @@ -55,7 +55,7 @@ public class AsyncResultTests { @Test @SuppressWarnings("deprecation") - public void asyncResultWithCallbackAndException() throws Exception { + public void asyncResultWithCallbackAndException() { IOException ex = new IOException(); final Set values = new HashSet<>(1); org.springframework.util.concurrent.ListenableFuture future = AsyncResult.forExecutionException(ex); @@ -85,7 +85,7 @@ public class AsyncResultTests { final Set values = new HashSet<>(1); org.springframework.util.concurrent.ListenableFuture future = AsyncResult.forValue(value); future.addCallback(values::add, ex -> new AssertionError("Failure callback not expected: " + ex)); - assertThat(values).element(0).isSameAs(value); + assertThat(values).singleElement().isSameAs(value); assertThat(future.get()).isSameAs(value); assertThat(future.completable().get()).isSameAs(value); future.completable().thenAccept(v -> assertThat(v).isSameAs(value)); @@ -93,7 +93,7 @@ public class AsyncResultTests { @Test @SuppressWarnings("deprecation") - public void asyncResultWithSeparateCallbacksAndException() throws Exception { + public void asyncResultWithSeparateCallbacksAndException() { IOException ex = new IOException(); final Set values = new HashSet<>(1); org.springframework.util.concurrent.ListenableFuture future = AsyncResult.forExecutionException(ex); diff --git a/spring-context/src/test/java/org/springframework/scheduling/annotation/EnableAsyncTests.java b/spring-context/src/test/java/org/springframework/scheduling/annotation/EnableAsyncTests.java index 1652e2b7e91..c5e262dc3c4 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/annotation/EnableAsyncTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/annotation/EnableAsyncTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -66,10 +66,10 @@ import static org.mockito.Mockito.mock; * @author Stephane Nicoll * @since 3.1 */ -public class EnableAsyncTests { +class EnableAsyncTests { @Test - public void proxyingOccurs() { + void proxyingOccurs() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(AsyncConfig.class); ctx.refresh(); @@ -81,7 +81,7 @@ public class EnableAsyncTests { } @Test - public void proxyingOccursWithMockitoStub() { + void proxyingOccursWithMockitoStub() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(AsyncConfigWithMockito.class, AsyncBeanUser.class); ctx.refresh(); @@ -94,7 +94,7 @@ public class EnableAsyncTests { } @Test - public void properExceptionForExistingProxyDependencyMismatch() { + void properExceptionForExistingProxyDependencyMismatch() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(AsyncConfig.class, AsyncBeanWithInterface.class, AsyncBeanUser.class); assertThatExceptionOfType(UnsatisfiedDependencyException.class).isThrownBy(ctx::refresh) @@ -103,7 +103,7 @@ public class EnableAsyncTests { } @Test - public void properExceptionForResolvedProxyDependencyMismatch() { + void properExceptionForResolvedProxyDependencyMismatch() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(AsyncConfig.class, AsyncBeanUser.class, AsyncBeanWithInterface.class); assertThatExceptionOfType(UnsatisfiedDependencyException.class).isThrownBy(ctx::refresh) @@ -112,7 +112,7 @@ public class EnableAsyncTests { } @Test - public void withAsyncBeanWithExecutorQualifiedByName() throws ExecutionException, InterruptedException { + void withAsyncBeanWithExecutorQualifiedByName() throws ExecutionException, InterruptedException { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(AsyncWithExecutorQualifiedByNameConfig.class); ctx.refresh(); @@ -131,7 +131,7 @@ public class EnableAsyncTests { } @Test - public void withAsyncBeanWithExecutorQualifiedByExpressionOrPlaceholder() throws Exception { + void withAsyncBeanWithExecutorQualifiedByExpressionOrPlaceholder() throws Exception { System.setProperty("myExecutor", "myExecutor1"); System.setProperty("my.app.myExecutor", "myExecutor2"); @@ -161,7 +161,7 @@ public class EnableAsyncTests { } @Test - public void asyncProcessorIsOrderedLowestPrecedenceByDefault() { + void asyncProcessorIsOrderedLowestPrecedenceByDefault() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(AsyncConfig.class); ctx.refresh(); @@ -173,7 +173,7 @@ public class EnableAsyncTests { } @Test - public void orderAttributeIsPropagated() { + void orderAttributeIsPropagated() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(OrderedAsyncConfig.class); ctx.refresh(); @@ -185,7 +185,7 @@ public class EnableAsyncTests { } @Test - public void customAsyncAnnotationIsPropagated() { + void customAsyncAnnotationIsPropagated() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(CustomAsyncAnnotationConfig.class, CustomAsyncBean.class); ctx.refresh(); @@ -208,7 +208,7 @@ public class EnableAsyncTests { * Fails with classpath errors on trying to classload AnnotationAsyncExecutionAspect. */ @Test - public void aspectModeAspectJAttemptsToRegisterAsyncAspect() { + void aspectModeAspectJAttemptsToRegisterAsyncAspect() { @SuppressWarnings("resource") AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(AspectJAsyncAnnotationConfig.class); @@ -216,7 +216,7 @@ public class EnableAsyncTests { } @Test - public void customExecutorBean() { + void customExecutorBean() { // Arrange AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(CustomExecutorBean.class); @@ -234,7 +234,7 @@ public class EnableAsyncTests { } @Test - public void customExecutorConfig() { + void customExecutorConfig() { // Arrange AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(CustomExecutorConfig.class); @@ -252,7 +252,7 @@ public class EnableAsyncTests { } @Test - public void customExecutorConfigWithThrowsException() { + void customExecutorConfigWithThrowsException() { // Arrange AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(CustomExecutorConfig.class); @@ -273,7 +273,7 @@ public class EnableAsyncTests { } @Test - public void customExecutorBeanConfig() { + void customExecutorBeanConfig() { // Arrange AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(CustomExecutorBeanConfig.class, ExecutorPostProcessor.class); @@ -291,7 +291,7 @@ public class EnableAsyncTests { } @Test - public void customExecutorBeanConfigWithThrowsException() { + void customExecutorBeanConfigWithThrowsException() { // Arrange AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(CustomExecutorBeanConfig.class, ExecutorPostProcessor.class); diff --git a/spring-context/src/test/java/org/springframework/scheduling/annotation/EnableSchedulingTests.java b/spring-context/src/test/java/org/springframework/scheduling/annotation/EnableSchedulingTests.java index fc7f20de8b6..ace3d2c3b82 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/annotation/EnableSchedulingTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/annotation/EnableSchedulingTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -55,13 +55,13 @@ import static org.springframework.core.testfixture.TestGroup.LONG_RUNNING; * @author Juergen Hoeller * @since 3.1 */ -public class EnableSchedulingTests { +class EnableSchedulingTests { private AnnotationConfigApplicationContext ctx; @AfterEach - public void tearDown() { + void tearDown() { if (ctx != null) { ctx.close(); } @@ -140,7 +140,7 @@ public class EnableSchedulingTests { } @Test - public void withExplicitSchedulerAmbiguity_andSchedulingEnabled() { + void withExplicitSchedulerAmbiguity_andSchedulingEnabled() { // No exception raised as of 4.3, aligned with the behavior for @Async methods (SPR-14030) ctx = new AnnotationConfigApplicationContext(AmbiguousExplicitSchedulerConfig.class); } @@ -192,12 +192,12 @@ public class EnableSchedulingTests { } @Test - public void withAmbiguousTaskSchedulers_butNoActualTasks() { + void withAmbiguousTaskSchedulers_butNoActualTasks() { ctx = new AnnotationConfigApplicationContext(SchedulingEnabled_withAmbiguousTaskSchedulers_butNoActualTasks.class); } @Test - public void withAmbiguousTaskSchedulers_andSingleTask() { + void withAmbiguousTaskSchedulers_andSingleTask() { // No exception raised as of 4.3, aligned with the behavior for @Async methods (SPR-14030) ctx = new AnnotationConfigApplicationContext(SchedulingEnabled_withAmbiguousTaskSchedulers_andSingleTask.class); } diff --git a/spring-context/src/test/java/org/springframework/scheduling/annotation/ScheduledAnnotationBeanPostProcessorObservabilityTests.java b/spring-context/src/test/java/org/springframework/scheduling/annotation/ScheduledAnnotationBeanPostProcessorObservabilityTests.java index 2dea00b171d..6132b222e83 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/annotation/ScheduledAnnotationBeanPostProcessorObservabilityTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/annotation/ScheduledAnnotationBeanPostProcessorObservabilityTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -278,7 +278,7 @@ class ScheduledAnnotationBeanPostProcessorObservabilityTests { return Mono.just("test") .tap(() -> new DefaultSignalListener<>() { @Override - public void doFirst() throws Throwable { + public void doFirst() { Observation observation = observationRegistry.getCurrentObservation(); assertThat(observation).isNotNull(); assertThat(observation.getContext()).isInstanceOf(ScheduledTaskObservationContext.class); diff --git a/spring-context/src/test/java/org/springframework/scheduling/concurrent/AbstractSchedulingTaskExecutorTests.java b/spring-context/src/test/java/org/springframework/scheduling/concurrent/AbstractSchedulingTaskExecutorTests.java index 5db612c1f8b..68f1d80a7cf 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/concurrent/AbstractSchedulingTaskExecutorTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/concurrent/AbstractSchedulingTaskExecutorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -427,7 +427,7 @@ abstract class AbstractSchedulingTaskExecutorTests { } @Override - public String call() throws Exception { + public String call() { try { Thread.sleep(10); } diff --git a/spring-context/src/test/java/org/springframework/scheduling/concurrent/ScheduledExecutorFactoryBeanTests.java b/spring-context/src/test/java/org/springframework/scheduling/concurrent/ScheduledExecutorFactoryBeanTests.java index 50cbfe83407..057d50df537 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/concurrent/ScheduledExecutorFactoryBeanTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/concurrent/ScheduledExecutorFactoryBeanTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -219,7 +219,7 @@ class ScheduledExecutorFactoryBeanTests { private static void pauseToLetTaskStart(int seconds) { try { - Thread.sleep(seconds * 1000); + Thread.sleep(seconds * 1000L); } catch (InterruptedException ignored) { } diff --git a/spring-context/src/test/java/org/springframework/scheduling/concurrent/ThreadPoolTaskSchedulerTests.java b/spring-context/src/test/java/org/springframework/scheduling/concurrent/ThreadPoolTaskSchedulerTests.java index 0bff61ceea3..7226c0abd67 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/concurrent/ThreadPoolTaskSchedulerTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/concurrent/ThreadPoolTaskSchedulerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -101,7 +101,7 @@ class ThreadPoolTaskSchedulerTests extends AbstractSchedulingTaskExecutorTests { @Test @SuppressWarnings("deprecation") - void scheduleOneTimeFailingTaskWithoutErrorHandler() throws Exception { + void scheduleOneTimeFailingTaskWithoutErrorHandler() { TestTask task = new TestTask(this.testName, 0); Future future = scheduler.schedule(task, new Date()); assertThatExceptionOfType(ExecutionException.class).isThrownBy(() -> future.get(1000, TimeUnit.MILLISECONDS)); diff --git a/spring-context/src/test/java/org/springframework/scheduling/config/AnnotationDrivenBeanDefinitionParserTests.java b/spring-context/src/test/java/org/springframework/scheduling/config/AnnotationDrivenBeanDefinitionParserTests.java index cd7e0d8037d..63924437290 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/config/AnnotationDrivenBeanDefinitionParserTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/config/AnnotationDrivenBeanDefinitionParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,44 +31,44 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Mark Fisher * @author Stephane Nicoll */ -public class AnnotationDrivenBeanDefinitionParserTests { +class AnnotationDrivenBeanDefinitionParserTests { private ConfigurableApplicationContext context = new ClassPathXmlApplicationContext( "annotationDrivenContext.xml", AnnotationDrivenBeanDefinitionParserTests.class); @AfterEach - public void closeApplicationContext() { + void closeApplicationContext() { context.close(); } @Test - public void asyncPostProcessorRegistered() { + void asyncPostProcessorRegistered() { assertThat(context.containsBean(TaskManagementConfigUtils.ASYNC_ANNOTATION_PROCESSOR_BEAN_NAME)).isTrue(); } @Test - public void scheduledPostProcessorRegistered() { + void scheduledPostProcessorRegistered() { assertThat(context.containsBean(TaskManagementConfigUtils.SCHEDULED_ANNOTATION_PROCESSOR_BEAN_NAME)).isTrue(); } @Test - public void asyncPostProcessorExecutorReference() { + void asyncPostProcessorExecutorReference() { Object executor = context.getBean("testExecutor"); Object postProcessor = context.getBean(TaskManagementConfigUtils.ASYNC_ANNOTATION_PROCESSOR_BEAN_NAME); assertThat(((Supplier) new DirectFieldAccessor(postProcessor).getPropertyValue("executor")).get()).isSameAs(executor); } @Test - public void scheduledPostProcessorSchedulerReference() { + void scheduledPostProcessorSchedulerReference() { Object scheduler = context.getBean("testScheduler"); Object postProcessor = context.getBean(TaskManagementConfigUtils.SCHEDULED_ANNOTATION_PROCESSOR_BEAN_NAME); assertThat(new DirectFieldAccessor(postProcessor).getPropertyValue("scheduler")).isSameAs(scheduler); } @Test - public void asyncPostProcessorExceptionHandlerReference() { + void asyncPostProcessorExceptionHandlerReference() { Object exceptionHandler = context.getBean("testExceptionHandler"); Object postProcessor = context.getBean(TaskManagementConfigUtils.ASYNC_ANNOTATION_PROCESSOR_BEAN_NAME); assertThat(((Supplier) new DirectFieldAccessor(postProcessor).getPropertyValue("exceptionHandler")).get()).isSameAs(exceptionHandler); diff --git a/spring-context/src/test/java/org/springframework/scheduling/config/ExecutorBeanDefinitionParserTests.java b/spring-context/src/test/java/org/springframework/scheduling/config/ExecutorBeanDefinitionParserTests.java index ef8f32846ef..fe22251fe84 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/config/ExecutorBeanDefinitionParserTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/config/ExecutorBeanDefinitionParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,20 +37,20 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; * @author Mark Fisher * @author Juergen Hoeller */ -public class ExecutorBeanDefinitionParserTests { +class ExecutorBeanDefinitionParserTests { private ApplicationContext context; @BeforeEach - public void setup() { + void setup() { this.context = new ClassPathXmlApplicationContext( "executorContext.xml", ExecutorBeanDefinitionParserTests.class); } @Test - public void defaultExecutor() throws Exception { + void defaultExecutor() throws Exception { ThreadPoolTaskExecutor executor = this.context.getBean("default", ThreadPoolTaskExecutor.class); assertThat(getCorePoolSize(executor)).isEqualTo(1); assertThat(getMaxPoolSize(executor)).isEqualTo(Integer.MAX_VALUE); @@ -64,20 +64,20 @@ public class ExecutorBeanDefinitionParserTests { } @Test - public void singleSize() { + void singleSize() { Object executor = this.context.getBean("singleSize"); assertThat(getCorePoolSize(executor)).isEqualTo(42); assertThat(getMaxPoolSize(executor)).isEqualTo(42); } @Test - public void invalidPoolSize() { + void invalidPoolSize() { assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() -> this.context.getBean("invalidPoolSize")); } @Test - public void rangeWithBoundedQueue() { + void rangeWithBoundedQueue() { Object executor = this.context.getBean("rangeWithBoundedQueue"); assertThat(getCorePoolSize(executor)).isEqualTo(7); assertThat(getMaxPoolSize(executor)).isEqualTo(42); @@ -85,7 +85,7 @@ public class ExecutorBeanDefinitionParserTests { } @Test - public void rangeWithUnboundedQueue() { + void rangeWithUnboundedQueue() { Object executor = this.context.getBean("rangeWithUnboundedQueue"); assertThat(getCorePoolSize(executor)).isEqualTo(9); assertThat(getMaxPoolSize(executor)).isEqualTo(9); @@ -95,7 +95,7 @@ public class ExecutorBeanDefinitionParserTests { } @Test - public void propertyPlaceholderWithSingleSize() { + void propertyPlaceholderWithSingleSize() { Object executor = this.context.getBean("propertyPlaceholderWithSingleSize"); assertThat(getCorePoolSize(executor)).isEqualTo(123); assertThat(getMaxPoolSize(executor)).isEqualTo(123); @@ -105,7 +105,7 @@ public class ExecutorBeanDefinitionParserTests { } @Test - public void propertyPlaceholderWithRange() { + void propertyPlaceholderWithRange() { Object executor = this.context.getBean("propertyPlaceholderWithRange"); assertThat(getCorePoolSize(executor)).isEqualTo(5); assertThat(getMaxPoolSize(executor)).isEqualTo(25); @@ -114,7 +114,7 @@ public class ExecutorBeanDefinitionParserTests { } @Test - public void propertyPlaceholderWithRangeAndCoreThreadTimeout() { + void propertyPlaceholderWithRangeAndCoreThreadTimeout() { Object executor = this.context.getBean("propertyPlaceholderWithRangeAndCoreThreadTimeout"); assertThat(getCorePoolSize(executor)).isEqualTo(99); assertThat(getMaxPoolSize(executor)).isEqualTo(99); @@ -122,19 +122,19 @@ public class ExecutorBeanDefinitionParserTests { } @Test - public void propertyPlaceholderWithInvalidPoolSize() { + void propertyPlaceholderWithInvalidPoolSize() { assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() -> this.context.getBean("propertyPlaceholderWithInvalidPoolSize")); } @Test - public void threadNamePrefix() { + void threadNamePrefix() { CustomizableThreadCreator executor = this.context.getBean("default", CustomizableThreadCreator.class); assertThat(executor.getThreadNamePrefix()).isEqualTo("default-"); } @Test - public void typeCheck() { + void typeCheck() { assertThat(this.context.isTypeMatch("default", Executor.class)).isTrue(); assertThat(this.context.isTypeMatch("default", TaskExecutor.class)).isTrue(); assertThat(this.context.isTypeMatch("default", ThreadPoolTaskExecutor.class)).isTrue(); diff --git a/spring-context/src/test/java/org/springframework/scheduling/config/ScheduledTasksBeanDefinitionParserTests.java b/spring-context/src/test/java/org/springframework/scheduling/config/ScheduledTasksBeanDefinitionParserTests.java index dde3a4faa6d..c6ab6d340f9 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/config/ScheduledTasksBeanDefinitionParserTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/config/ScheduledTasksBeanDefinitionParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,7 +48,7 @@ public class ScheduledTasksBeanDefinitionParserTests { @BeforeEach - public void setup() { + void setup() { this.context = new ClassPathXmlApplicationContext( "scheduledTasksContext.xml", ScheduledTasksBeanDefinitionParserTests.class); this.registrar = this.context.getBeansOfType( @@ -57,14 +57,14 @@ public class ScheduledTasksBeanDefinitionParserTests { } @Test - public void checkScheduler() { + void checkScheduler() { Object schedulerBean = this.context.getBean("testScheduler"); Object schedulerRef = new DirectFieldAccessor(this.registrar).getPropertyValue("taskScheduler"); assertThat(schedulerRef).isEqualTo(schedulerBean); } @Test - public void checkTarget() { + void checkTarget() { List tasks = (List) new DirectFieldAccessor( this.registrar).getPropertyValue("fixedRateTasks"); Runnable runnable = tasks.get(0).getRunnable(); @@ -76,7 +76,7 @@ public class ScheduledTasksBeanDefinitionParserTests { } @Test - public void fixedRateTasks() { + void fixedRateTasks() { List tasks = (List) new DirectFieldAccessor( this.registrar).getPropertyValue("fixedRateTasks"); assertThat(tasks).hasSize(3); @@ -87,7 +87,7 @@ public class ScheduledTasksBeanDefinitionParserTests { } @Test - public void fixedDelayTasks() { + void fixedDelayTasks() { List tasks = (List) new DirectFieldAccessor( this.registrar).getPropertyValue("fixedDelayTasks"); assertThat(tasks).hasSize(2); @@ -97,7 +97,7 @@ public class ScheduledTasksBeanDefinitionParserTests { } @Test - public void cronTasks() { + void cronTasks() { List tasks = (List) new DirectFieldAccessor( this.registrar).getPropertyValue("cronTasks"); assertThat(tasks).hasSize(1); @@ -105,7 +105,7 @@ public class ScheduledTasksBeanDefinitionParserTests { } @Test - public void triggerTasks() { + void triggerTasks() { List tasks = (List) new DirectFieldAccessor( this.registrar).getPropertyValue("triggerTasks"); assertThat(tasks).hasSize(1); diff --git a/spring-context/src/test/java/org/springframework/scheduling/config/SchedulerBeanDefinitionParserTests.java b/spring-context/src/test/java/org/springframework/scheduling/config/SchedulerBeanDefinitionParserTests.java index 6bf38e40fb8..6c7dfcb8611 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/config/SchedulerBeanDefinitionParserTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/config/SchedulerBeanDefinitionParserTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,33 +29,33 @@ import static org.assertj.core.api.Assertions.assertThat; /** * @author Mark Fisher */ -public class SchedulerBeanDefinitionParserTests { +class SchedulerBeanDefinitionParserTests { private ApplicationContext context; @BeforeEach - public void setup() { + void setup() { this.context = new ClassPathXmlApplicationContext( "schedulerContext.xml", SchedulerBeanDefinitionParserTests.class); } @Test - public void defaultScheduler() { + void defaultScheduler() { ThreadPoolTaskScheduler scheduler = (ThreadPoolTaskScheduler) this.context.getBean("defaultScheduler"); Integer size = (Integer) new DirectFieldAccessor(scheduler).getPropertyValue("poolSize"); assertThat(size).isEqualTo(1); } @Test - public void customScheduler() { + void customScheduler() { ThreadPoolTaskScheduler scheduler = (ThreadPoolTaskScheduler) this.context.getBean("customScheduler"); Integer size = (Integer) new DirectFieldAccessor(scheduler).getPropertyValue("poolSize"); assertThat(size).isEqualTo(42); } @Test - public void threadNamePrefix() { + void threadNamePrefix() { ThreadPoolTaskScheduler scheduler = (ThreadPoolTaskScheduler) this.context.getBean("customScheduler"); assertThat(scheduler.getThreadNamePrefix()).isEqualTo("customScheduler-"); } diff --git a/spring-context/src/test/java/org/springframework/scheduling/support/CronExpressionTests.java b/spring-context/src/test/java/org/springframework/scheduling/support/CronExpressionTests.java index a2b10c26c7b..57372204cb7 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/support/CronExpressionTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/support/CronExpressionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -53,7 +53,7 @@ class CronExpressionTests { }; @Test - public void isValidExpression() { + void isValidExpression() { assertThat(CronExpression.isValidExpression(null)).isFalse(); assertThat(CronExpression.isValidExpression("")).isFalse(); assertThat(CronExpression.isValidExpression("*")).isFalse(); @@ -479,7 +479,7 @@ class CronExpressionTests { } @Test - public void fixedDays() { + void fixedDays() { CronExpression expression = CronExpression.parse("0 0 0 29 2 WED"); LocalDateTime last = LocalDateTime.of(2012, 2, 29, 1, 0); @@ -509,7 +509,7 @@ class CronExpressionTests { } @Test - public void everyTenDays() { + void everyTenDays() { CronExpression cronExpression = CronExpression.parse("0 15 12 */10 1-8 5"); LocalDateTime last = LocalDateTime.parse("2021-04-30T12:14:59"); @@ -806,7 +806,7 @@ class CronExpressionTests { } @Test - public void quartzLastDayOfWeekOffset() { + void quartzLastDayOfWeekOffset() { // last Friday (5) of the month CronExpression expression = CronExpression.parse("0 0 0 * * 5L"); @@ -1295,7 +1295,7 @@ class CronExpressionTests { } @Test - public void sundayToFriday() { + void sundayToFriday() { CronExpression expression = CronExpression.parse("0 0 0 ? * SUN-FRI"); LocalDateTime last = LocalDateTime.of(2021, 2, 25, 15, 0); @@ -1314,7 +1314,7 @@ class CronExpressionTests { } @Test - public void daylightSaving() { + void daylightSaving() { CronExpression cronExpression = CronExpression.parse("0 0 9 * * *"); ZonedDateTime last = ZonedDateTime.parse("2021-03-27T09:00:00+01:00[Europe/Amsterdam]"); @@ -1355,7 +1355,7 @@ class CronExpressionTests { } @Test - public void various() { + void various() { CronExpression cronExpression = CronExpression.parse("3-57 13-28 17,18 1,15 3-12 6#1"); LocalDateTime last = LocalDateTime.of(2022, 9, 15, 17, 44, 11); LocalDateTime expected = LocalDateTime.of(2022, 10, 1, 17, 13, 3); diff --git a/spring-context/src/test/java/org/springframework/scripting/bsh/BshScriptEvaluatorTests.java b/spring-context/src/test/java/org/springframework/scripting/bsh/BshScriptEvaluatorTests.java index dff1f6424b8..20e40c3da11 100644 --- a/spring-context/src/test/java/org/springframework/scripting/bsh/BshScriptEvaluatorTests.java +++ b/spring-context/src/test/java/org/springframework/scripting/bsh/BshScriptEvaluatorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,24 +31,24 @@ import static org.assertj.core.api.Assertions.assertThat; /** * @author Juergen Hoeller */ -public class BshScriptEvaluatorTests { +class BshScriptEvaluatorTests { @Test - public void testBshScriptFromString() { + void testBshScriptFromString() { ScriptEvaluator evaluator = new BshScriptEvaluator(); Object result = evaluator.evaluate(new StaticScriptSource("return 3 * 2;")); assertThat(result).isEqualTo(6); } @Test - public void testBshScriptFromFile() { + void testBshScriptFromFile() { ScriptEvaluator evaluator = new BshScriptEvaluator(); Object result = evaluator.evaluate(new ResourceScriptSource(new ClassPathResource("simple.bsh", getClass()))); assertThat(result).isEqualTo(6); } @Test - public void testGroovyScriptWithArguments() { + void testGroovyScriptWithArguments() { ScriptEvaluator evaluator = new BshScriptEvaluator(); Map arguments = new HashMap<>(); arguments.put("a", 3); diff --git a/spring-context/src/test/java/org/springframework/scripting/config/ScriptingDefaultsTests.java b/spring-context/src/test/java/org/springframework/scripting/config/ScriptingDefaultsTests.java index 770758e0e75..d4bf35ae5d9 100644 --- a/spring-context/src/test/java/org/springframework/scripting/config/ScriptingDefaultsTests.java +++ b/spring-context/src/test/java/org/springframework/scripting/config/ScriptingDefaultsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,7 +43,7 @@ public class ScriptingDefaultsTests { @Test - public void defaultRefreshCheckDelay() throws Exception { + void defaultRefreshCheckDelay() throws Exception { ApplicationContext context = new ClassPathXmlApplicationContext(CONFIG); Advised advised = (Advised) context.getBean("testBean"); AbstractRefreshableTargetSource targetSource = @@ -55,21 +55,21 @@ public class ScriptingDefaultsTests { } @Test - public void defaultInitMethod() { + void defaultInitMethod() { ApplicationContext context = new ClassPathXmlApplicationContext(CONFIG); ITestBean testBean = (ITestBean) context.getBean("testBean"); assertThat(testBean.isInitialized()).isTrue(); } @Test - public void nameAsAlias() { + void nameAsAlias() { ApplicationContext context = new ClassPathXmlApplicationContext(CONFIG); ITestBean testBean = (ITestBean) context.getBean("/url"); assertThat(testBean.isInitialized()).isTrue(); } @Test - public void defaultDestroyMethod() { + void defaultDestroyMethod() { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(CONFIG); ITestBean testBean = (ITestBean) context.getBean("nonRefreshableTestBean"); assertThat(testBean.isDestroyed()).isFalse(); @@ -78,7 +78,7 @@ public class ScriptingDefaultsTests { } @Test - public void defaultAutowire() { + void defaultAutowire() { ApplicationContext context = new ClassPathXmlApplicationContext(CONFIG); ITestBean testBean = (ITestBean) context.getBean("testBean"); ITestBean otherBean = (ITestBean) context.getBean("otherBean"); @@ -86,7 +86,7 @@ public class ScriptingDefaultsTests { } @Test - public void defaultProxyTargetClass() { + void defaultProxyTargetClass() { ApplicationContext context = new ClassPathXmlApplicationContext(PROXY_CONFIG); Object testBean = context.getBean("testBean"); assertThat(AopUtils.isCglibProxy(testBean)).isTrue(); diff --git a/spring-context/src/test/java/org/springframework/scripting/groovy/GroovyAspectTests.java b/spring-context/src/test/java/org/springframework/scripting/groovy/GroovyAspectTests.java index 6f1550f7c8e..18bc00e7082 100644 --- a/spring-context/src/test/java/org/springframework/scripting/groovy/GroovyAspectTests.java +++ b/spring-context/src/test/java/org/springframework/scripting/groovy/GroovyAspectTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,7 +33,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; * @author Dave Syer * @author Sam Brannen */ -public class GroovyAspectTests { +class GroovyAspectTests { private final LogUserAdvice logAdvice = new LogUserAdvice(); @@ -41,7 +41,7 @@ public class GroovyAspectTests { @Test - public void manualGroovyBeanWithUnconditionalPointcut() throws Exception { + void manualGroovyBeanWithUnconditionalPointcut() throws Exception { TestService target = (TestService) scriptFactory.getScriptedObject(new ResourceScriptSource( new ClassPathResource("GroovyServiceImpl.grv", getClass()))); @@ -49,7 +49,7 @@ public class GroovyAspectTests { } @Test - public void manualGroovyBeanWithStaticPointcut() throws Exception { + void manualGroovyBeanWithStaticPointcut() throws Exception { TestService target = (TestService) scriptFactory.getScriptedObject(new ResourceScriptSource( new ClassPathResource("GroovyServiceImpl.grv", getClass()))); @@ -59,7 +59,7 @@ public class GroovyAspectTests { } @Test - public void manualGroovyBeanWithDynamicPointcut() throws Exception { + void manualGroovyBeanWithDynamicPointcut() throws Exception { TestService target = (TestService) scriptFactory.getScriptedObject(new ResourceScriptSource( new ClassPathResource("GroovyServiceImpl.grv", getClass()))); @@ -69,7 +69,7 @@ public class GroovyAspectTests { } @Test - public void manualGroovyBeanWithDynamicPointcutProxyTargetClass() throws Exception { + void manualGroovyBeanWithDynamicPointcutProxyTargetClass() throws Exception { TestService target = (TestService) scriptFactory.getScriptedObject(new ResourceScriptSource( new ClassPathResource("GroovyServiceImpl.grv", getClass()))); @@ -78,14 +78,13 @@ public class GroovyAspectTests { testAdvice(new DefaultPointcutAdvisor(pointcut, logAdvice), logAdvice, target, "GroovyServiceImpl", true); } - private void testAdvice(Advisor advisor, LogUserAdvice logAdvice, TestService target, String message) - throws Exception { + private void testAdvice(Advisor advisor, LogUserAdvice logAdvice, TestService target, String message) { testAdvice(advisor, logAdvice, target, message, false); } private void testAdvice(Advisor advisor, LogUserAdvice logAdvice, TestService target, String message, - boolean proxyTargetClass) throws Exception { + boolean proxyTargetClass) { logAdvice.reset(); diff --git a/spring-context/src/test/java/org/springframework/scripting/groovy/GroovyClassLoadingTests.java b/spring-context/src/test/java/org/springframework/scripting/groovy/GroovyClassLoadingTests.java index 5bf307fbc73..e7cc29ddf7c 100644 --- a/spring-context/src/test/java/org/springframework/scripting/groovy/GroovyClassLoadingTests.java +++ b/spring-context/src/test/java/org/springframework/scripting/groovy/GroovyClassLoadingTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,7 +30,7 @@ import static org.assertj.core.api.Assertions.assertThat; /** * @author Mark Fisher */ -public class GroovyClassLoadingTests { +class GroovyClassLoadingTests { @Test @SuppressWarnings("resource") diff --git a/spring-context/src/test/java/org/springframework/scripting/groovy/GroovyScriptEvaluatorTests.java b/spring-context/src/test/java/org/springframework/scripting/groovy/GroovyScriptEvaluatorTests.java index f57528f0d81..f2acc4f88f3 100644 --- a/spring-context/src/test/java/org/springframework/scripting/groovy/GroovyScriptEvaluatorTests.java +++ b/spring-context/src/test/java/org/springframework/scripting/groovy/GroovyScriptEvaluatorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,24 +33,24 @@ import static org.assertj.core.api.Assertions.assertThat; /** * @author Juergen Hoeller */ -public class GroovyScriptEvaluatorTests { +class GroovyScriptEvaluatorTests { @Test - public void testGroovyScriptFromString() { + void testGroovyScriptFromString() { ScriptEvaluator evaluator = new GroovyScriptEvaluator(); Object result = evaluator.evaluate(new StaticScriptSource("return 3 * 2")); assertThat(result).isEqualTo(6); } @Test - public void testGroovyScriptFromFile() { + void testGroovyScriptFromFile() { ScriptEvaluator evaluator = new GroovyScriptEvaluator(); Object result = evaluator.evaluate(new ResourceScriptSource(new ClassPathResource("simple.groovy", getClass()))); assertThat(result).isEqualTo(6); } @Test - public void testGroovyScriptWithArguments() { + void testGroovyScriptWithArguments() { ScriptEvaluator evaluator = new GroovyScriptEvaluator(); Map arguments = new HashMap<>(); arguments.put("a", 3); @@ -60,7 +60,7 @@ public class GroovyScriptEvaluatorTests { } @Test - public void testGroovyScriptWithCompilerConfiguration() { + void testGroovyScriptWithCompilerConfiguration() { GroovyScriptEvaluator evaluator = new GroovyScriptEvaluator(); MyBytecodeProcessor processor = new MyBytecodeProcessor(); evaluator.getCompilerConfiguration().setBytecodePostprocessor(processor); @@ -70,7 +70,7 @@ public class GroovyScriptEvaluatorTests { } @Test - public void testGroovyScriptWithImportCustomizer() { + void testGroovyScriptWithImportCustomizer() { GroovyScriptEvaluator evaluator = new GroovyScriptEvaluator(); ImportCustomizer importCustomizer = new ImportCustomizer(); importCustomizer.addStarImports("org.springframework.util"); @@ -80,7 +80,7 @@ public class GroovyScriptEvaluatorTests { } @Test - public void testGroovyScriptFromStringUsingJsr223() { + void testGroovyScriptFromStringUsingJsr223() { StandardScriptEvaluator evaluator = new StandardScriptEvaluator(); evaluator.setLanguage("Groovy"); Object result = evaluator.evaluate(new StaticScriptSource("return 3 * 2")); @@ -88,14 +88,14 @@ public class GroovyScriptEvaluatorTests { } @Test - public void testGroovyScriptFromFileUsingJsr223() { + void testGroovyScriptFromFileUsingJsr223() { ScriptEvaluator evaluator = new StandardScriptEvaluator(); Object result = evaluator.evaluate(new ResourceScriptSource(new ClassPathResource("simple.groovy", getClass()))); assertThat(result).isEqualTo(6); } @Test - public void testGroovyScriptWithArgumentsUsingJsr223() { + void testGroovyScriptWithArgumentsUsingJsr223() { StandardScriptEvaluator evaluator = new StandardScriptEvaluator(); evaluator.setLanguage("Groovy"); Map arguments = new HashMap<>(); diff --git a/spring-context/src/test/java/org/springframework/scripting/groovy/GroovyScriptFactoryTests.java b/spring-context/src/test/java/org/springframework/scripting/groovy/GroovyScriptFactoryTests.java index 44f1411ce3b..812f4c44233 100644 --- a/spring-context/src/test/java/org/springframework/scripting/groovy/GroovyScriptFactoryTests.java +++ b/spring-context/src/test/java/org/springframework/scripting/groovy/GroovyScriptFactoryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -66,7 +66,7 @@ import static org.mockito.Mockito.mock; public class GroovyScriptFactoryTests { @Test - public void testStaticScript() throws Exception { + void testStaticScript() { ApplicationContext ctx = new ClassPathXmlApplicationContext("groovyContext.xml", getClass()); assertThat(Arrays.asList(ctx.getBeanNamesForType(Calculator.class))).contains("calculator"); @@ -99,7 +99,7 @@ public class GroovyScriptFactoryTests { } @Test - public void testStaticScriptUsingJsr223() throws Exception { + void testStaticScriptUsingJsr223() { ApplicationContext ctx = new ClassPathXmlApplicationContext("groovyContextWithJsr223.xml", getClass()); assertThat(Arrays.asList(ctx.getBeanNamesForType(Calculator.class))).contains("calculator"); @@ -132,7 +132,7 @@ public class GroovyScriptFactoryTests { } @Test - public void testStaticPrototypeScript() throws Exception { + void testStaticPrototypeScript() { ApplicationContext ctx = new ClassPathXmlApplicationContext("groovyContext.xml", getClass()); ConfigurableMessenger messenger = (ConfigurableMessenger) ctx.getBean("messengerPrototype"); ConfigurableMessenger messenger2 = (ConfigurableMessenger) ctx.getBean("messengerPrototype"); @@ -152,7 +152,7 @@ public class GroovyScriptFactoryTests { } @Test - public void testStaticPrototypeScriptUsingJsr223() throws Exception { + void testStaticPrototypeScriptUsingJsr223() { ApplicationContext ctx = new ClassPathXmlApplicationContext("groovyContextWithJsr223.xml", getClass()); ConfigurableMessenger messenger = (ConfigurableMessenger) ctx.getBean("messengerPrototype"); ConfigurableMessenger messenger2 = (ConfigurableMessenger) ctx.getBean("messengerPrototype"); @@ -172,7 +172,7 @@ public class GroovyScriptFactoryTests { } @Test - public void testStaticScriptWithInstance() throws Exception { + void testStaticScriptWithInstance() { ApplicationContext ctx = new ClassPathXmlApplicationContext("groovyContext.xml", getClass()); assertThat(Arrays.asList(ctx.getBeanNamesForType(Messenger.class))).contains("messengerInstance"); Messenger messenger = (Messenger) ctx.getBean("messengerInstance"); @@ -187,7 +187,7 @@ public class GroovyScriptFactoryTests { } @Test - public void testStaticScriptWithInstanceUsingJsr223() throws Exception { + void testStaticScriptWithInstanceUsingJsr223() { ApplicationContext ctx = new ClassPathXmlApplicationContext("groovyContextWithJsr223.xml", getClass()); assertThat(Arrays.asList(ctx.getBeanNamesForType(Messenger.class))).contains("messengerInstance"); Messenger messenger = (Messenger) ctx.getBean("messengerInstance"); @@ -202,7 +202,7 @@ public class GroovyScriptFactoryTests { } @Test - public void testStaticScriptWithInlineDefinedInstance() throws Exception { + void testStaticScriptWithInlineDefinedInstance() { ApplicationContext ctx = new ClassPathXmlApplicationContext("groovyContext.xml", getClass()); assertThat(Arrays.asList(ctx.getBeanNamesForType(Messenger.class))).contains("messengerInstanceInline"); Messenger messenger = (Messenger) ctx.getBean("messengerInstanceInline"); @@ -217,7 +217,7 @@ public class GroovyScriptFactoryTests { } @Test - public void testStaticScriptWithInlineDefinedInstanceUsingJsr223() throws Exception { + void testStaticScriptWithInlineDefinedInstanceUsingJsr223() { ApplicationContext ctx = new ClassPathXmlApplicationContext("groovyContextWithJsr223.xml", getClass()); assertThat(Arrays.asList(ctx.getBeanNamesForType(Messenger.class))).contains("messengerInstanceInline"); Messenger messenger = (Messenger) ctx.getBean("messengerInstanceInline"); @@ -232,7 +232,7 @@ public class GroovyScriptFactoryTests { } @Test - public void testNonStaticScript() throws Exception { + void testNonStaticScript() { ApplicationContext ctx = new ClassPathXmlApplicationContext("groovyRefreshableContext.xml", getClass()); Messenger messenger = (Messenger) ctx.getBean("messenger"); @@ -251,7 +251,7 @@ public class GroovyScriptFactoryTests { } @Test - public void testNonStaticPrototypeScript() throws Exception { + void testNonStaticPrototypeScript() { ApplicationContext ctx = new ClassPathXmlApplicationContext("groovyRefreshableContext.xml", getClass()); ConfigurableMessenger messenger = (ConfigurableMessenger) ctx.getBean("messengerPrototype"); ConfigurableMessenger messenger2 = (ConfigurableMessenger) ctx.getBean("messengerPrototype"); @@ -276,14 +276,14 @@ public class GroovyScriptFactoryTests { } @Test - public void testScriptCompilationException() throws Exception { + void testScriptCompilationException() { assertThatExceptionOfType(NestedRuntimeException.class).isThrownBy(() -> new ClassPathXmlApplicationContext("org/springframework/scripting/groovy/groovyBrokenContext.xml")) .matches(ex -> ex.contains(ScriptCompilationException.class)); } @Test - public void testScriptedClassThatDoesNotHaveANoArgCtor() throws Exception { + void testScriptedClassThatDoesNotHaveANoArgCtor() throws Exception { ScriptSource script = mock(); String badScript = "class Foo { public Foo(String foo) {}}"; given(script.getScriptAsString()).willReturn(badScript); @@ -296,7 +296,7 @@ public class GroovyScriptFactoryTests { } @Test - public void testScriptedClassThatHasNoPublicNoArgCtor() throws Exception { + void testScriptedClassThatHasNoPublicNoArgCtor() throws Exception { ScriptSource script = mock(); String badScript = "class Foo { protected Foo() {} \n String toString() { 'X' }}"; given(script.getScriptAsString()).willReturn(badScript); @@ -306,7 +306,7 @@ public class GroovyScriptFactoryTests { } @Test - public void testWithTwoClassesDefinedInTheOneGroovyFile_CorrectClassFirst() throws Exception { + void testWithTwoClassesDefinedInTheOneGroovyFile_CorrectClassFirst() { ApplicationContext ctx = new ClassPathXmlApplicationContext("twoClassesCorrectOneFirst.xml", getClass()); Messenger messenger = (Messenger) ctx.getBean("messenger"); assertThat(messenger).isNotNull(); @@ -318,7 +318,7 @@ public class GroovyScriptFactoryTests { } @Test - public void testWithTwoClassesDefinedInTheOneGroovyFile_WrongClassFirst() throws Exception { + void testWithTwoClassesDefinedInTheOneGroovyFile_WrongClassFirst() { assertThatException().as("two classes defined in GroovyScriptFactory source, non-Messenger class defined first").isThrownBy(() -> { ApplicationContext ctx = new ClassPathXmlApplicationContext("twoClassesWrongOneFirst.xml", getClass()); ctx.getBean("messenger", Messenger.class); @@ -326,32 +326,32 @@ public class GroovyScriptFactoryTests { } @Test - public void testCtorWithNullScriptSourceLocator() throws Exception { + void testCtorWithNullScriptSourceLocator() { assertThatIllegalArgumentException().isThrownBy(() -> new GroovyScriptFactory(null)); } @Test - public void testCtorWithEmptyScriptSourceLocator() throws Exception { + void testCtorWithEmptyScriptSourceLocator() { assertThatIllegalArgumentException().isThrownBy(() -> new GroovyScriptFactory("")); } @Test - public void testCtorWithWhitespacedScriptSourceLocator() throws Exception { + void testCtorWithWhitespacedScriptSourceLocator() { assertThatIllegalArgumentException().isThrownBy(() -> new GroovyScriptFactory("\n ")); } @Test - public void testWithInlineScriptWithLeadingWhitespace() throws Exception { + void testWithInlineScriptWithLeadingWhitespace() { assertThatExceptionOfType(BeanCreationException.class).as("'inline:' prefix was preceded by whitespace").isThrownBy(() -> new ClassPathXmlApplicationContext("lwspBadGroovyContext.xml", getClass())) .matches(ex -> ex.contains(FileNotFoundException.class)); } @Test - public void testGetScriptedObjectDoesNotChokeOnNullInterfacesBeingPassedIn() throws Exception { + void testGetScriptedObjectDoesNotChokeOnNullInterfacesBeingPassedIn() throws Exception { ScriptSource script = mock(); given(script.getScriptAsString()).willReturn("class Bar {}"); given(script.suggestedClassName()).willReturn("someName"); @@ -362,14 +362,14 @@ public class GroovyScriptFactoryTests { } @Test - public void testGetScriptedObjectDoesChokeOnNullScriptSourceBeingPassedIn() throws Exception { + void testGetScriptedObjectDoesChokeOnNullScriptSourceBeingPassedIn() { GroovyScriptFactory factory = new GroovyScriptFactory("a script source locator (doesn't matter here)"); assertThatNullPointerException().as("NullPointerException as per contract ('null' ScriptSource supplied)").isThrownBy(() -> factory.getScriptedObject(null)); } @Test - public void testResourceScriptFromTag() throws Exception { + void testResourceScriptFromTag() { ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("groovy-with-xsd.xml", getClass()); Messenger messenger = (Messenger) ctx.getBean("messenger"); CallCounter countingAspect = (CallCounter) ctx.getBean("getMessageAspect"); @@ -386,7 +386,7 @@ public class GroovyScriptFactoryTests { } @Test - public void testPrototypeScriptFromTag() throws Exception { + void testPrototypeScriptFromTag() { ApplicationContext ctx = new ClassPathXmlApplicationContext("groovy-with-xsd.xml", getClass()); ConfigurableMessenger messenger = (ConfigurableMessenger) ctx.getBean("messengerPrototype"); ConfigurableMessenger messenger2 = (ConfigurableMessenger) ctx.getBean("messengerPrototype"); @@ -402,7 +402,7 @@ public class GroovyScriptFactoryTests { } @Test - public void testInlineScriptFromTag() throws Exception { + void testInlineScriptFromTag() { ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("groovy-with-xsd.xml", getClass()); BeanDefinition bd = ctx.getBeanFactory().getBeanDefinition("calculator"); assertThat(ObjectUtils.containsElement(bd.getDependsOn(), "messenger")).isTrue(); @@ -413,7 +413,7 @@ public class GroovyScriptFactoryTests { } @Test - public void testRefreshableFromTag() throws Exception { + void testRefreshableFromTag() { ApplicationContext ctx = new ClassPathXmlApplicationContext("groovy-with-xsd.xml", getClass()); assertThat(Arrays.asList(ctx.getBeanNamesForType(Messenger.class))).contains("refreshableMessenger"); @@ -431,7 +431,7 @@ public class GroovyScriptFactoryTests { } @Test // SPR-6268 - public void testRefreshableFromTagProxyTargetClass() throws Exception { + public void testRefreshableFromTagProxyTargetClass() { ApplicationContext ctx = new ClassPathXmlApplicationContext("groovy-with-xsd-proxy-target-class.xml", getClass()); assertThat(Arrays.asList(ctx.getBeanNamesForType(Messenger.class))).contains("refreshableMessenger"); @@ -450,7 +450,7 @@ public class GroovyScriptFactoryTests { } @Test // SPR-6268 - public void testProxyTargetClassNotAllowedIfNotGroovy() throws Exception { + public void testProxyTargetClassNotAllowedIfNotGroovy() { try { new ClassPathXmlApplicationContext("groovy-with-xsd-proxy-target-class.xml", getClass()); } @@ -460,7 +460,7 @@ public class GroovyScriptFactoryTests { } @Test - public void testAnonymousScriptDetected() throws Exception { + void testAnonymousScriptDetected() { ApplicationContext ctx = new ClassPathXmlApplicationContext("groovy-with-xsd.xml", getClass()); Map beans = ctx.getBeansOfType(Messenger.class); assertThat(beans).hasSize(4); @@ -469,7 +469,7 @@ public class GroovyScriptFactoryTests { } @Test - public void testJsr223FromTag() throws Exception { + void testJsr223FromTag() { ApplicationContext ctx = new ClassPathXmlApplicationContext("groovy-with-xsd-jsr223.xml", getClass()); assertThat(Arrays.asList(ctx.getBeanNamesForType(Messenger.class))).contains("messenger"); Messenger messenger = (Messenger) ctx.getBean("messenger"); @@ -478,7 +478,7 @@ public class GroovyScriptFactoryTests { } @Test - public void testJsr223FromTagWithInterface() throws Exception { + void testJsr223FromTagWithInterface() { ApplicationContext ctx = new ClassPathXmlApplicationContext("groovy-with-xsd-jsr223.xml", getClass()); assertThat(Arrays.asList(ctx.getBeanNamesForType(Messenger.class))).contains("messengerWithInterface"); Messenger messenger = (Messenger) ctx.getBean("messengerWithInterface"); @@ -486,7 +486,7 @@ public class GroovyScriptFactoryTests { } @Test - public void testRefreshableJsr223FromTag() throws Exception { + void testRefreshableJsr223FromTag() { ApplicationContext ctx = new ClassPathXmlApplicationContext("groovy-with-xsd-jsr223.xml", getClass()); assertThat(Arrays.asList(ctx.getBeanNamesForType(Messenger.class))).contains("refreshableMessenger"); Messenger messenger = (Messenger) ctx.getBean("refreshableMessenger"); @@ -497,7 +497,7 @@ public class GroovyScriptFactoryTests { } @Test - public void testInlineJsr223FromTag() throws Exception { + void testInlineJsr223FromTag() { ApplicationContext ctx = new ClassPathXmlApplicationContext("groovy-with-xsd-jsr223.xml", getClass()); assertThat(Arrays.asList(ctx.getBeanNamesForType(Messenger.class))).contains("inlineMessenger"); Messenger messenger = (Messenger) ctx.getBean("inlineMessenger"); @@ -505,7 +505,7 @@ public class GroovyScriptFactoryTests { } @Test - public void testInlineJsr223FromTagWithInterface() throws Exception { + void testInlineJsr223FromTagWithInterface() { ApplicationContext ctx = new ClassPathXmlApplicationContext("groovy-with-xsd-jsr223.xml", getClass()); assertThat(Arrays.asList(ctx.getBeanNamesForType(Messenger.class))).contains("inlineMessengerWithInterface"); Messenger messenger = (Messenger) ctx.getBean("inlineMessengerWithInterface"); @@ -517,7 +517,7 @@ public class GroovyScriptFactoryTests { * passed to a scripted bean :( */ @Test - public void testCanPassInMoreThanOneProperty() { + void testCanPassInMoreThanOneProperty() { ApplicationContext ctx = new ClassPathXmlApplicationContext("groovy-multiple-properties.xml", getClass()); TestBean tb = (TestBean) ctx.getBean("testBean"); @@ -533,12 +533,12 @@ public class GroovyScriptFactoryTests { } @Test - public void testMetaClassWithBeans() { + void testMetaClassWithBeans() { testMetaClass("org/springframework/scripting/groovy/calculators.xml"); } @Test - public void testMetaClassWithXsd() { + void testMetaClassWithXsd() { testMetaClass("org/springframework/scripting/groovy/calculators-with-xsd.xml"); } @@ -552,7 +552,7 @@ public class GroovyScriptFactoryTests { } @Test - public void testFactoryBean() { + void testFactoryBean() { ApplicationContext context = new ClassPathXmlApplicationContext("groovyContext.xml", getClass()); Object factory = context.getBean("&factory"); boolean condition1 = factory instanceof FactoryBean; @@ -564,7 +564,7 @@ public class GroovyScriptFactoryTests { } @Test - public void testRefreshableFactoryBean() { + void testRefreshableFactoryBean() { ApplicationContext context = new ClassPathXmlApplicationContext("groovyContext.xml", getClass()); Object factory = context.getBean("&refreshableFactory"); boolean condition1 = factory instanceof FactoryBean; diff --git a/spring-context/src/test/java/org/springframework/scripting/groovy/LogUserAdvice.java b/spring-context/src/test/java/org/springframework/scripting/groovy/LogUserAdvice.java index 841605eb427..8bcc9ffde89 100644 --- a/spring-context/src/test/java/org/springframework/scripting/groovy/LogUserAdvice.java +++ b/spring-context/src/test/java/org/springframework/scripting/groovy/LogUserAdvice.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,7 +29,7 @@ public class LogUserAdvice implements MethodBeforeAdvice, ThrowsAdvice { private int countThrows = 0; @Override - public void before(Method method, Object[] objects, @Nullable Object o) throws Throwable { + public void before(Method method, Object[] objects, @Nullable Object o) { countBefore++; // System.out.println("Method:" + method.getName()); } diff --git a/spring-context/src/test/java/org/springframework/scripting/groovy/TestService.java b/spring-context/src/test/java/org/springframework/scripting/groovy/TestService.java index aedebb2e769..75498e9d92e 100644 --- a/spring-context/src/test/java/org/springframework/scripting/groovy/TestService.java +++ b/spring-context/src/test/java/org/springframework/scripting/groovy/TestService.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,5 +18,5 @@ package org.springframework.scripting.groovy; public interface TestService { - public String sayHello(); + String sayHello(); } diff --git a/spring-context/src/test/java/org/springframework/scripting/support/RefreshableScriptTargetSourceTests.java b/spring-context/src/test/java/org/springframework/scripting/support/RefreshableScriptTargetSourceTests.java index c2ae23cdce8..cc8d45913a8 100644 --- a/spring-context/src/test/java/org/springframework/scripting/support/RefreshableScriptTargetSourceTests.java +++ b/spring-context/src/test/java/org/springframework/scripting/support/RefreshableScriptTargetSourceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,10 +24,10 @@ import static org.mockito.Mockito.mock; /** * @author Rick Evans */ -public class RefreshableScriptTargetSourceTests { +class RefreshableScriptTargetSourceTests { @Test - public void createWithNullScriptSource() throws Exception { + void createWithNullScriptSource() { assertThatIllegalArgumentException().isThrownBy(() -> new RefreshableScriptTargetSource(mock(), "a.bean", null, null, false)); } diff --git a/spring-context/src/test/java/org/springframework/scripting/support/ResourceScriptSourceTests.java b/spring-context/src/test/java/org/springframework/scripting/support/ResourceScriptSourceTests.java index bca03aee18c..83d38b26247 100644 --- a/spring-context/src/test/java/org/springframework/scripting/support/ResourceScriptSourceTests.java +++ b/spring-context/src/test/java/org/springframework/scripting/support/ResourceScriptSourceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,10 +32,10 @@ import static org.mockito.Mockito.mock; * @author Rick Evans * @author Juergen Hoeller */ -public class ResourceScriptSourceTests { +class ResourceScriptSourceTests { @Test - public void doesNotPropagateFatalExceptionOnResourceThatCannotBeResolvedToAFile() throws Exception { + void doesNotPropagateFatalExceptionOnResourceThatCannotBeResolvedToAFile() throws Exception { Resource resource = mock(); given(resource.lastModified()).willThrow(new IOException()); @@ -45,14 +45,14 @@ public class ResourceScriptSourceTests { } @Test - public void beginsInModifiedState() throws Exception { + void beginsInModifiedState() { Resource resource = mock(); ResourceScriptSource scriptSource = new ResourceScriptSource(resource); assertThat(scriptSource.isModified()).isTrue(); } @Test - public void lastModifiedWorksWithResourceThatDoesNotSupportFileBasedReading() throws Exception { + void lastModifiedWorksWithResourceThatDoesNotSupportFileBasedReading() throws Exception { Resource resource = mock(); // underlying File is asked for so that the last modified time can be checked... // And then mock the file changing; i.e. the File says it has been modified @@ -71,7 +71,7 @@ public class ResourceScriptSourceTests { } @Test - public void lastModifiedWorksWithResourceThatDoesNotSupportFileBasedAccessAtAll() throws Exception { + void lastModifiedWorksWithResourceThatDoesNotSupportFileBasedAccessAtAll() throws Exception { Resource resource = new ByteArrayResource(new byte[0]); ResourceScriptSource scriptSource = new ResourceScriptSource(resource); assertThat(scriptSource.isModified()).as("ResourceScriptSource must start off in the 'isModified' state (it obviously isn't).").isTrue(); diff --git a/spring-context/src/test/java/org/springframework/scripting/support/ScriptFactoryPostProcessorTests.java b/spring-context/src/test/java/org/springframework/scripting/support/ScriptFactoryPostProcessorTests.java index f9601ab2c3d..32cfd5e8d73 100644 --- a/spring-context/src/test/java/org/springframework/scripting/support/ScriptFactoryPostProcessorTests.java +++ b/spring-context/src/test/java/org/springframework/scripting/support/ScriptFactoryPostProcessorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -91,7 +91,7 @@ class ScriptFactoryPostProcessorTests { } @Test - void testChangeScriptWithRefreshableBeanFunctionality() throws Exception { + void testChangeScriptWithRefreshableBeanFunctionality() { BeanDefinition processorBeanDefinition = createScriptFactoryPostProcessor(true); BeanDefinition scriptedBeanDefinition = createScriptedGroovyBean(); @@ -112,7 +112,7 @@ class ScriptFactoryPostProcessorTests { } @Test - void testChangeScriptWithNoRefreshableBeanFunctionality() throws Exception { + void testChangeScriptWithNoRefreshableBeanFunctionality() { BeanDefinition processorBeanDefinition = createScriptFactoryPostProcessor(false); BeanDefinition scriptedBeanDefinition = createScriptedGroovyBean(); @@ -132,7 +132,7 @@ class ScriptFactoryPostProcessorTests { } @Test - void testRefreshedScriptReferencePropagatesToCollaborators() throws Exception { + void testRefreshedScriptReferencePropagatesToCollaborators() { BeanDefinition processorBeanDefinition = createScriptFactoryPostProcessor(true); BeanDefinition scriptedBeanDefinition = createScriptedGroovyBean(); BeanDefinitionBuilder collaboratorBuilder = BeanDefinitionBuilder.rootBeanDefinition(DefaultMessengerService.class); @@ -161,7 +161,7 @@ class ScriptFactoryPostProcessorTests { @Test @SuppressWarnings("resource") - void testReferencesAcrossAContainerHierarchy() throws Exception { + void testReferencesAcrossAContainerHierarchy() { GenericApplicationContext businessContext = new GenericApplicationContext(); businessContext.registerBeanDefinition("messenger", BeanDefinitionBuilder.rootBeanDefinition(StubMessenger.class).getBeanDefinition()); businessContext.refresh(); @@ -178,13 +178,13 @@ class ScriptFactoryPostProcessorTests { @Test @SuppressWarnings("resource") - void testScriptHavingAReferenceToAnotherBean() throws Exception { + void testScriptHavingAReferenceToAnotherBean() { // just tests that the (singleton) script-backed bean is able to be instantiated with references to its collaborators new ClassPathXmlApplicationContext("org/springframework/scripting/support/groovyReferences.xml"); } @Test - void testForRefreshedScriptHavingErrorPickedUpOnFirstCall() throws Exception { + void testForRefreshedScriptHavingErrorPickedUpOnFirstCall() { BeanDefinition processorBeanDefinition = createScriptFactoryPostProcessor(true); BeanDefinition scriptedBeanDefinition = createScriptedGroovyBean(); BeanDefinitionBuilder collaboratorBuilder = BeanDefinitionBuilder.rootBeanDefinition(DefaultMessengerService.class); @@ -211,7 +211,7 @@ class ScriptFactoryPostProcessorTests { @Test @SuppressWarnings("resource") - void testPrototypeScriptedBean() throws Exception { + void testPrototypeScriptedBean() { GenericApplicationContext ctx = new GenericApplicationContext(); ctx.registerBeanDefinition("messenger", BeanDefinitionBuilder.rootBeanDefinition(StubMessenger.class).getBeanDefinition()); @@ -230,7 +230,7 @@ class ScriptFactoryPostProcessorTests { assertThat(messenger2).isNotSameAs(messenger1); } - private static StaticScriptSource getScriptSource(GenericApplicationContext ctx) throws Exception { + private static StaticScriptSource getScriptSource(GenericApplicationContext ctx) { ScriptFactoryPostProcessor processor = (ScriptFactoryPostProcessor) ctx.getBean(PROCESSOR_BEAN_NAME); BeanDefinition bd = processor.scriptBeanFactory.getBeanDefinition("scriptedObject.messenger"); return (StaticScriptSource) bd.getConstructorArgumentValues().getIndexedArgumentValue(0, StaticScriptSource.class).getValue(); @@ -263,7 +263,7 @@ class ScriptFactoryPostProcessorTests { private static void pauseToLetRefreshDelayKickIn(int secondsToPause) { try { - Thread.sleep(secondsToPause * 1000); + Thread.sleep(secondsToPause * 1000L); } catch (InterruptedException ignored) { } diff --git a/spring-context/src/test/java/org/springframework/scripting/support/StaticScriptSourceTests.java b/spring-context/src/test/java/org/springframework/scripting/support/StaticScriptSourceTests.java index a9bddab9003..e7e6cd7eaba 100644 --- a/spring-context/src/test/java/org/springframework/scripting/support/StaticScriptSourceTests.java +++ b/spring-context/src/test/java/org/springframework/scripting/support/StaticScriptSourceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,7 +27,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException * @author Rick Evans * @author Sam Brannen */ -public class StaticScriptSourceTests { +class StaticScriptSourceTests { private static final String SCRIPT_TEXT = "print($hello) if $true;"; @@ -35,49 +35,49 @@ public class StaticScriptSourceTests { @Test - public void createWithNullScript() throws Exception { + void createWithNullScript() { assertThatIllegalArgumentException().isThrownBy(() -> new StaticScriptSource(null)); } @Test - public void createWithEmptyScript() throws Exception { + void createWithEmptyScript() { assertThatIllegalArgumentException().isThrownBy(() -> new StaticScriptSource("")); } @Test - public void createWithWhitespaceOnlyScript() throws Exception { + void createWithWhitespaceOnlyScript() { assertThatIllegalArgumentException().isThrownBy(() -> new StaticScriptSource(" \n\n\t \t\n")); } @Test - public void isModifiedIsTrueByDefault() throws Exception { + void isModifiedIsTrueByDefault() { assertThat(source.isModified()).as("Script must be flagged as 'modified' when first created.").isTrue(); } @Test - public void gettingScriptTogglesIsModified() throws Exception { + void gettingScriptTogglesIsModified() { source.getScriptAsString(); assertThat(source.isModified()).as("Script must be flagged as 'not modified' after script is read.").isFalse(); } @Test - public void gettingScriptViaToStringDoesNotToggleIsModified() throws Exception { + void gettingScriptViaToStringDoesNotToggleIsModified() { boolean isModifiedState = source.isModified(); source.toString(); assertThat(source.isModified()).as("Script's 'modified' flag must not change after script is read via toString().").isEqualTo(isModifiedState); } @Test - public void isModifiedToggledWhenDifferentScriptIsSet() throws Exception { + void isModifiedToggledWhenDifferentScriptIsSet() { source.setScript("use warnings;"); assertThat(source.isModified()).as("Script must be flagged as 'modified' when different script is passed in.").isTrue(); } @Test - public void isModifiedNotToggledWhenSameScriptIsSet() throws Exception { + void isModifiedNotToggledWhenSameScriptIsSet() { source.setScript(SCRIPT_TEXT); assertThat(source.isModified()).as("Script must not be flagged as 'modified' when same script is passed in.").isFalse(); } diff --git a/spring-context/src/test/java/org/springframework/ui/ModelMapTests.java b/spring-context/src/test/java/org/springframework/ui/ModelMapTests.java index 0909a7b8d42..5c36f02ce4f 100644 --- a/spring-context/src/test/java/org/springframework/ui/ModelMapTests.java +++ b/spring-context/src/test/java/org/springframework/ui/ModelMapTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,10 +41,10 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException * @author Juergen Hoeller * @author Chris Beams */ -public class ModelMapTests { +class ModelMapTests { @Test - public void testNoArgCtorYieldsEmptyModel() throws Exception { + void testNoArgCtorYieldsEmptyModel() { assertThat(new ModelMap()).isEmpty(); } @@ -52,7 +52,7 @@ public class ModelMapTests { * SPR-2185 - Null model assertion causes backwards compatibility issue */ @Test - public void testAddNullObjectWithExplicitKey() throws Exception { + void testAddNullObjectWithExplicitKey() { ModelMap model = new ModelMap(); model.addAttribute("foo", null); assertThat(model.containsKey("foo")).isTrue(); @@ -63,14 +63,14 @@ public class ModelMapTests { * SPR-2185 - Null model assertion causes backwards compatibility issue */ @Test - public void testAddNullObjectViaCtorWithExplicitKey() throws Exception { + void testAddNullObjectViaCtorWithExplicitKey() { ModelMap model = new ModelMap("foo", null); assertThat(model.containsKey("foo")).isTrue(); assertThat(model.get("foo")).isNull(); } @Test - public void testNamedObjectCtor() throws Exception { + void testNamedObjectCtor() { ModelMap model = new ModelMap("foo", "bing"); assertThat(model).hasSize(1); String bing = (String) model.get("foo"); @@ -79,7 +79,7 @@ public class ModelMapTests { } @Test - public void testUnnamedCtorScalar() throws Exception { + void testUnnamedCtorScalar() { ModelMap model = new ModelMap("foo", "bing"); assertThat(model).hasSize(1); String bing = (String) model.get("foo"); @@ -88,7 +88,7 @@ public class ModelMapTests { } @Test - public void testOneArgCtorWithScalar() throws Exception { + void testOneArgCtorWithScalar() { ModelMap model = new ModelMap("bing"); assertThat(model).hasSize(1); String string = (String) model.get("string"); @@ -97,14 +97,14 @@ public class ModelMapTests { } @Test - public void testOneArgCtorWithNull() { + void testOneArgCtorWithNull() { //Null model arguments added without a name being explicitly supplied are not allowed assertThatIllegalArgumentException().isThrownBy(() -> new ModelMap(null)); } @Test - public void testOneArgCtorWithCollection() throws Exception { + void testOneArgCtorWithCollection() { ModelMap model = new ModelMap(new String[]{"foo", "boing"}); assertThat(model).hasSize(1); String[] strings = (String[]) model.get("stringList"); @@ -115,14 +115,14 @@ public class ModelMapTests { } @Test - public void testOneArgCtorWithEmptyCollection() throws Exception { + void testOneArgCtorWithEmptyCollection() { ModelMap model = new ModelMap(new HashSet<>()); // must not add if collection is empty... assertThat(model).isEmpty(); } @Test - public void testAddObjectWithNull() throws Exception { + void testAddObjectWithNull() { // Null model arguments added without a name being explicitly supplied are not allowed ModelMap model = new ModelMap(); assertThatIllegalArgumentException().isThrownBy(() -> @@ -130,7 +130,7 @@ public class ModelMapTests { } @Test - public void testAddObjectWithEmptyArray() throws Exception { + void testAddObjectWithEmptyArray() { ModelMap model = new ModelMap(new int[]{}); assertThat(model).hasSize(1); int[] ints = (int[]) model.get("intList"); @@ -139,21 +139,21 @@ public class ModelMapTests { } @Test - public void testAddAllObjectsWithNullMap() throws Exception { + void testAddAllObjectsWithNullMap() { ModelMap model = new ModelMap(); model.addAllAttributes((Map) null); assertThat(model).isEmpty(); } @Test - public void testAddAllObjectsWithNullCollection() throws Exception { + void testAddAllObjectsWithNullCollection() { ModelMap model = new ModelMap(); model.addAllAttributes((Collection) null); assertThat(model).isEmpty(); } @Test - public void testAddAllObjectsWithSparseArrayList() throws Exception { + void testAddAllObjectsWithSparseArrayList() { // Null model arguments added without a name being explicitly supplied are not allowed ModelMap model = new ModelMap(); ArrayList list = new ArrayList<>(); @@ -164,7 +164,7 @@ public class ModelMapTests { } @Test - public void testAddMap() throws Exception { + void testAddMap() { Map map = new HashMap<>(); map.put("one", "one-value"); map.put("two", "two-value"); @@ -176,7 +176,7 @@ public class ModelMapTests { } @Test - public void testAddObjectNoKeyOfSameTypeOverrides() throws Exception { + void testAddObjectNoKeyOfSameTypeOverrides() { ModelMap model = new ModelMap(); model.addAttribute("foo"); model.addAttribute("bar"); @@ -186,7 +186,7 @@ public class ModelMapTests { } @Test - public void testAddListOfTheSameObjects() throws Exception { + void testAddListOfTheSameObjects() { List beans = new ArrayList<>(); beans.add(new TestBean("one")); beans.add(new TestBean("two")); @@ -197,7 +197,7 @@ public class ModelMapTests { } @Test - public void testMergeMapWithOverriding() throws Exception { + void testMergeMapWithOverriding() { Map beans = new HashMap<>(); beans.put("one", new TestBean("one")); beans.put("two", new TestBean("two")); @@ -210,7 +210,7 @@ public class ModelMapTests { } @Test - public void testInnerClass() throws Exception { + void testInnerClass() { ModelMap map = new ModelMap(); SomeInnerClass inner = new SomeInnerClass(); map.addAttribute(inner); @@ -218,7 +218,7 @@ public class ModelMapTests { } @Test - public void testInnerClassWithTwoUpperCaseLetters() throws Exception { + void testInnerClassWithTwoUpperCaseLetters() { ModelMap map = new ModelMap(); UKInnerClass inner = new UKInnerClass(); map.addAttribute(inner); @@ -226,7 +226,7 @@ public class ModelMapTests { } @Test - public void testAopCglibProxy() throws Exception { + void testAopCglibProxy() { ModelMap map = new ModelMap(); ProxyFactory factory = new ProxyFactory(); SomeInnerClass val = new SomeInnerClass(); @@ -238,7 +238,7 @@ public class ModelMapTests { } @Test - public void testAopJdkProxy() throws Exception { + void testAopJdkProxy() { ModelMap map = new ModelMap(); ProxyFactory factory = new ProxyFactory(); Map target = new HashMap<>(); @@ -250,7 +250,7 @@ public class ModelMapTests { } @Test - public void testAopJdkProxyWithMultipleInterfaces() throws Exception { + void testAopJdkProxyWithMultipleInterfaces() { ModelMap map = new ModelMap(); Map target = new HashMap<>(); ProxyFactory factory = new ProxyFactory(); @@ -265,7 +265,7 @@ public class ModelMapTests { } @Test - public void testAopJdkProxyWithDetectedInterfaces() throws Exception { + void testAopJdkProxyWithDetectedInterfaces() { ModelMap map = new ModelMap(); Map target = new HashMap<>(); ProxyFactory factory = new ProxyFactory(target); @@ -275,7 +275,7 @@ public class ModelMapTests { } @Test - public void testRawJdkProxy() throws Exception { + void testRawJdkProxy() { ModelMap map = new ModelMap(); Object proxy = Proxy.newProxyInstance( getClass().getClassLoader(), diff --git a/spring-context/src/test/java/org/springframework/util/MBeanTestUtils.java b/spring-context/src/test/java/org/springframework/util/MBeanTestUtils.java index 900184a75fa..1530e37a1e4 100644 --- a/spring-context/src/test/java/org/springframework/util/MBeanTestUtils.java +++ b/spring-context/src/test/java/org/springframework/util/MBeanTestUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,7 +32,7 @@ public class MBeanTestUtils { * {@linkplain #releaseMBeanServer(MBeanServer) releasing} all currently registered * MBeanServers. */ - public static synchronized void resetMBeanServers() throws Exception { + public static synchronized void resetMBeanServers() { for (MBeanServer server : MBeanServerFactory.findMBeanServer(null)) { releaseMBeanServer(server); } diff --git a/spring-context/src/test/java/org/springframework/validation/DataBinderConstructTests.java b/spring-context/src/test/java/org/springframework/validation/DataBinderConstructTests.java index 8f3dc0af630..7c2a0e8f41d 100644 --- a/spring-context/src/test/java/org/springframework/validation/DataBinderConstructTests.java +++ b/spring-context/src/test/java/org/springframework/validation/DataBinderConstructTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,7 +36,7 @@ import static org.assertj.core.api.Assertions.assertThat; * * @author Rossen Stoyanchev */ -public class DataBinderConstructTests { +class DataBinderConstructTests { @Test diff --git a/spring-context/src/test/java/org/springframework/validation/DataBinderFieldAccessTests.java b/spring-context/src/test/java/org/springframework/validation/DataBinderFieldAccessTests.java index d1eea63691e..570308e5535 100644 --- a/spring-context/src/test/java/org/springframework/validation/DataBinderFieldAccessTests.java +++ b/spring-context/src/test/java/org/springframework/validation/DataBinderFieldAccessTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -62,7 +62,7 @@ class DataBinderFieldAccessTests { } @Test - void bindingNoErrorsNotIgnoreUnknown() throws Exception { + void bindingNoErrorsNotIgnoreUnknown() { FieldAccessBean rod = new FieldAccessBean(); DataBinder binder = new DataBinder(rod, "person"); binder.initDirectFieldAccess(); @@ -76,7 +76,7 @@ class DataBinderFieldAccessTests { } @Test - void bindingWithErrors() throws Exception { + void bindingWithErrors() { FieldAccessBean rod = new FieldAccessBean(); DataBinder binder = new DataBinder(rod, "person"); binder.initDirectFieldAccess(); @@ -122,7 +122,7 @@ class DataBinderFieldAccessTests { } @Test - void nestedBindingWithDisabledAutoGrow() throws Exception { + void nestedBindingWithDisabledAutoGrow() { FieldAccessBean rod = new FieldAccessBean(); DataBinder binder = new DataBinder(rod, "person"); binder.setAutoGrowNestedPaths(false); @@ -135,7 +135,7 @@ class DataBinderFieldAccessTests { } @Test - void bindingWithErrorsAndCustomEditors() throws Exception { + void bindingWithErrorsAndCustomEditors() { FieldAccessBean rod = new FieldAccessBean(); DataBinder binder = new DataBinder(rod, "person"); binder.initDirectFieldAccess(); diff --git a/spring-context/src/test/java/org/springframework/validation/DataBinderTests.java b/spring-context/src/test/java/org/springframework/validation/DataBinderTests.java index fee87bcf29a..9a07c4f3366 100644 --- a/spring-context/src/test/java/org/springframework/validation/DataBinderTests.java +++ b/spring-context/src/test/java/org/springframework/validation/DataBinderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -447,7 +447,7 @@ class DataBinderTests { conversionService.addFormatter(new Formatter() { @Override - public String parse(String text, Locale locale) throws ParseException { + public String parse(String text, Locale locale) { throw new RuntimeException(text); } @Override @@ -480,7 +480,7 @@ class DataBinderTests { LocaleContextHolder.setLocale(Locale.GERMAN); try { binder.bind(pvs); - assertThat(tb.getIntegerList()).element(0).isEqualTo(1); + assertThat(tb.getIntegerList()).containsExactly(1); assertThat(binder.getBindingResult().getFieldValue("integerList[0]")).isEqualTo("1"); } finally { @@ -650,7 +650,7 @@ class DataBinderTests { binder.addCustomFormatter(new Formatter() { @Override - public String parse(String text, Locale locale) throws ParseException { + public String parse(String text, Locale locale) { throw new RuntimeException(text); } @Override @@ -1022,7 +1022,7 @@ class DataBinderTests { binder.addCustomFormatter(new Formatter() { @Override - public String parse(String text, Locale locale) throws ParseException { + public String parse(String text, Locale locale) { return "prefix" + text; } @Override @@ -1061,7 +1061,7 @@ class DataBinderTests { binder.addCustomFormatter(new Formatter() { @Override - public Integer parse(String text, Locale locale) throws ParseException { + public Integer parse(String text, Locale locale) { return 99; } @Override @@ -1085,7 +1085,7 @@ class DataBinderTests { binder.addCustomFormatter(new Formatter() { @Override - public String parse(String text, Locale locale) throws ParseException { + public String parse(String text, Locale locale) { return "prefix" + text; } @Override @@ -2007,9 +2007,7 @@ class DataBinderTests { assertThat(binder.getBindingResult().hasErrors()).isFalse(); @SuppressWarnings("unchecked") List list = (List) form.getF().get("list"); - assertThat(list).element(0).isEqualTo("firstValue"); - assertThat(list).element(1).isEqualTo("secondValue"); - assertThat(list).hasSize(2); + assertThat(list).containsExactly("firstValue", "secondValue"); } @Test diff --git a/spring-context/src/test/java/org/springframework/validation/DefaultMessageCodesResolverTests.java b/spring-context/src/test/java/org/springframework/validation/DefaultMessageCodesResolverTests.java index 962ea0c8068..d37241fcd8f 100644 --- a/spring-context/src/test/java/org/springframework/validation/DefaultMessageCodesResolverTests.java +++ b/spring-context/src/test/java/org/springframework/validation/DefaultMessageCodesResolverTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,13 +34,13 @@ class DefaultMessageCodesResolverTests { @Test - void shouldResolveMessageCode() throws Exception { + void shouldResolveMessageCode() { String[] codes = resolver.resolveMessageCodes("errorCode", "objectName"); assertThat(codes).containsExactly("errorCode.objectName", "errorCode"); } @Test - void shouldResolveFieldMessageCode() throws Exception { + void shouldResolveFieldMessageCode() { String[] codes = resolver.resolveMessageCodes("errorCode", "objectName", "field", TestBean.class); assertThat(codes).containsExactly( "errorCode.objectName.field", @@ -50,7 +50,7 @@ class DefaultMessageCodesResolverTests { } @Test - void shouldResolveIndexedFieldMessageCode() throws Exception { + void shouldResolveIndexedFieldMessageCode() { String[] codes = resolver.resolveMessageCodes("errorCode", "objectName", "a.b[3].c[5].d", TestBean.class); assertThat(codes).containsExactly( "errorCode.objectName.a.b[3].c[5].d", @@ -65,14 +65,14 @@ class DefaultMessageCodesResolverTests { } @Test - void shouldResolveMessageCodeWithPrefix() throws Exception { + void shouldResolveMessageCodeWithPrefix() { resolver.setPrefix("prefix."); String[] codes = resolver.resolveMessageCodes("errorCode", "objectName"); assertThat(codes).containsExactly("prefix.errorCode.objectName", "prefix.errorCode"); } @Test - void shouldResolveFieldMessageCodeWithPrefix() throws Exception { + void shouldResolveFieldMessageCodeWithPrefix() { resolver.setPrefix("prefix."); String[] codes = resolver.resolveMessageCodes("errorCode", "objectName", "field", TestBean.class); assertThat(codes).containsExactly( @@ -83,7 +83,7 @@ class DefaultMessageCodesResolverTests { } @Test - void shouldSupportNullPrefix() throws Exception { + void shouldSupportNullPrefix() { resolver.setPrefix(null); String[] codes = resolver.resolveMessageCodes("errorCode", "objectName", "field", TestBean.class); assertThat(codes).containsExactly( @@ -94,7 +94,7 @@ class DefaultMessageCodesResolverTests { } @Test - void shouldSupportMalformedIndexField() throws Exception { + void shouldSupportMalformedIndexField() { String[] codes = resolver.resolveMessageCodes("errorCode", "objectName", "field[", TestBean.class); assertThat(codes).containsExactly( "errorCode.objectName.field[", @@ -104,7 +104,7 @@ class DefaultMessageCodesResolverTests { } @Test - void shouldSupportNullFieldType() throws Exception { + void shouldSupportNullFieldType() { String[] codes = resolver.resolveMessageCodes("errorCode", "objectName", "field", null); assertThat(codes).containsExactly( "errorCode.objectName.field", @@ -113,14 +113,14 @@ class DefaultMessageCodesResolverTests { } @Test - void shouldSupportPostfixFormat() throws Exception { + void shouldSupportPostfixFormat() { resolver.setMessageCodeFormatter(Format.POSTFIX_ERROR_CODE); String[] codes = resolver.resolveMessageCodes("errorCode", "objectName"); assertThat(codes).containsExactly("objectName.errorCode", "errorCode"); } @Test - void shouldSupportFieldPostfixFormat() throws Exception { + void shouldSupportFieldPostfixFormat() { resolver.setMessageCodeFormatter(Format.POSTFIX_ERROR_CODE); String[] codes = resolver.resolveMessageCodes("errorCode", "objectName", "field", TestBean.class); assertThat(codes).containsExactly( @@ -131,7 +131,7 @@ class DefaultMessageCodesResolverTests { } @Test - void shouldSupportCustomFormat() throws Exception { + void shouldSupportCustomFormat() { resolver.setMessageCodeFormatter((errorCode, objectName, field) -> DefaultMessageCodesResolver.Format.toDelimitedString("CUSTOM-" + errorCode, objectName, field)); String[] codes = resolver.resolveMessageCodes("errorCode", "objectName"); diff --git a/spring-context/src/test/java/org/springframework/validation/ValidationUtilsTests.java b/spring-context/src/test/java/org/springframework/validation/ValidationUtilsTests.java index ed33f857b07..18e68042cd3 100644 --- a/spring-context/src/test/java/org/springframework/validation/ValidationUtilsTests.java +++ b/spring-context/src/test/java/org/springframework/validation/ValidationUtilsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,7 +33,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException; * @author Arjen Poutsma * @since 08.10.2004 */ -public class ValidationUtilsTests { +class ValidationUtilsTests { private final Validator emptyValidator = Validator.forInstanceOf(TestBean.class, (testBean, errors) -> ValidationUtils.rejectIfEmpty(errors, "name", "EMPTY", "You must enter a name!")); @@ -43,7 +43,7 @@ public class ValidationUtilsTests { @Test - public void testInvokeValidatorWithNullValidator() { + void testInvokeValidatorWithNullValidator() { TestBean tb = new TestBean(); Errors errors = new SimpleErrors(tb); assertThatIllegalArgumentException().isThrownBy(() -> @@ -51,14 +51,14 @@ public class ValidationUtilsTests { } @Test - public void testInvokeValidatorWithNullErrors() { + void testInvokeValidatorWithNullErrors() { TestBean tb = new TestBean(); assertThatIllegalArgumentException().isThrownBy(() -> ValidationUtils.invokeValidator(emptyValidator, tb, null)); } @Test - public void testInvokeValidatorSunnyDay() { + void testInvokeValidatorSunnyDay() { TestBean tb = new TestBean(); Errors errors = new SimpleErrors(tb); ValidationUtils.invokeValidator(emptyValidator, tb, errors); @@ -67,7 +67,7 @@ public class ValidationUtilsTests { } @Test - public void testValidationUtilsSunnyDay() { + void testValidationUtilsSunnyDay() { TestBean tb = new TestBean(""); tb.setName(" "); @@ -83,7 +83,7 @@ public class ValidationUtilsTests { } @Test - public void testValidationUtilsNull() { + void testValidationUtilsNull() { TestBean tb = new TestBean(); Errors errors = emptyValidator.validateObject(tb); assertThat(errors.hasFieldErrors("name")).isTrue(); @@ -95,7 +95,7 @@ public class ValidationUtilsTests { } @Test - public void testValidationUtilsEmpty() { + void testValidationUtilsEmpty() { TestBean tb = new TestBean(""); Errors errors = emptyValidator.validateObject(tb); assertThat(errors.hasFieldErrors("name")).isTrue(); @@ -107,7 +107,7 @@ public class ValidationUtilsTests { } @Test - public void testValidationUtilsEmptyVariants() { + void testValidationUtilsEmptyVariants() { TestBean tb = new TestBean(); Errors errors = new SimpleErrors(tb); @@ -125,7 +125,7 @@ public class ValidationUtilsTests { } @Test - public void testValidationUtilsEmptyOrWhitespace() { + void testValidationUtilsEmptyOrWhitespace() { TestBean tb = new TestBean(); // Test null @@ -152,7 +152,7 @@ public class ValidationUtilsTests { } @Test - public void testValidationUtilsEmptyOrWhitespaceVariants() { + void testValidationUtilsEmptyOrWhitespaceVariants() { TestBean tb = new TestBean(); tb.setName(" "); diff --git a/spring-context/src/test/java/org/springframework/validation/ValidatorTests.java b/spring-context/src/test/java/org/springframework/validation/ValidatorTests.java index 0827b85f857..b3007580b74 100644 --- a/spring-context/src/test/java/org/springframework/validation/ValidatorTests.java +++ b/spring-context/src/test/java/org/springframework/validation/ValidatorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,14 +28,14 @@ import static org.assertj.core.api.Assertions.assertThat; class ValidatorTests { @Test - public void testSupportsForInstanceOf() { + void testSupportsForInstanceOf() { Validator validator = Validator.forInstanceOf(TestBean.class, (testBean, errors) -> {}); assertThat(validator.supports(TestBean.class)).isTrue(); assertThat(validator.supports(TestBeanSubclass.class)).isTrue(); } @Test - public void testSupportsForType() { + void testSupportsForType() { Validator validator = Validator.forType(TestBean.class, (testBean, errors) -> {}); assertThat(validator.supports(TestBean.class)).isTrue(); assertThat(validator.supports(TestBeanSubclass.class)).isFalse(); diff --git a/spring-context/src/test/java/org/springframework/validation/beanvalidation/BeanValidationPostProcessorTests.java b/spring-context/src/test/java/org/springframework/validation/beanvalidation/BeanValidationPostProcessorTests.java index cc6b89e9db8..67ac244cb49 100644 --- a/spring-context/src/test/java/org/springframework/validation/beanvalidation/BeanValidationPostProcessorTests.java +++ b/spring-context/src/test/java/org/springframework/validation/beanvalidation/BeanValidationPostProcessorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,10 +36,10 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; /** * @author Juergen Hoeller */ -public class BeanValidationPostProcessorTests { +class BeanValidationPostProcessorTests { @Test - public void testNotNullConstraint() { + void testNotNullConstraint() { GenericApplicationContext ac = new GenericApplicationContext(); ac.registerBeanDefinition("bvpp", new RootBeanDefinition(BeanValidationPostProcessor.class)); ac.registerBeanDefinition("capp", new RootBeanDefinition(CommonAnnotationBeanPostProcessor.class)); @@ -52,7 +52,7 @@ public class BeanValidationPostProcessorTests { } @Test - public void testNotNullConstraintSatisfied() { + void testNotNullConstraintSatisfied() { GenericApplicationContext ac = new GenericApplicationContext(); ac.registerBeanDefinition("bvpp", new RootBeanDefinition(BeanValidationPostProcessor.class)); ac.registerBeanDefinition("capp", new RootBeanDefinition(CommonAnnotationBeanPostProcessor.class)); @@ -64,7 +64,7 @@ public class BeanValidationPostProcessorTests { } @Test - public void testNotNullConstraintAfterInitialization() { + void testNotNullConstraintAfterInitialization() { GenericApplicationContext ac = new GenericApplicationContext(); RootBeanDefinition bvpp = new RootBeanDefinition(BeanValidationPostProcessor.class); bvpp.getPropertyValues().add("afterInitialization", true); @@ -76,7 +76,7 @@ public class BeanValidationPostProcessorTests { } @Test - public void testNotNullConstraintAfterInitializationWithProxy() { + void testNotNullConstraintAfterInitializationWithProxy() { GenericApplicationContext ac = new GenericApplicationContext(); RootBeanDefinition bvpp = new RootBeanDefinition(BeanValidationPostProcessor.class); bvpp.getPropertyValues().add("afterInitialization", true); @@ -90,7 +90,7 @@ public class BeanValidationPostProcessorTests { } @Test - public void testSizeConstraint() { + void testSizeConstraint() { GenericApplicationContext ac = new GenericApplicationContext(); ac.registerBeanDefinition("bvpp", new RootBeanDefinition(BeanValidationPostProcessor.class)); RootBeanDefinition bd = new RootBeanDefinition(NotNullConstrainedBean.class); @@ -105,7 +105,7 @@ public class BeanValidationPostProcessorTests { } @Test - public void testSizeConstraintSatisfied() { + void testSizeConstraintSatisfied() { GenericApplicationContext ac = new GenericApplicationContext(); ac.registerBeanDefinition("bvpp", new RootBeanDefinition(BeanValidationPostProcessor.class)); RootBeanDefinition bd = new RootBeanDefinition(NotNullConstrainedBean.class); diff --git a/spring-context/src/test/java/org/springframework/validation/beanvalidation/MethodValidationAdapterPropertyPathTests.java b/spring-context/src/test/java/org/springframework/validation/beanvalidation/MethodValidationAdapterPropertyPathTests.java index 45614621d50..76a3caae13c 100644 --- a/spring-context/src/test/java/org/springframework/validation/beanvalidation/MethodValidationAdapterPropertyPathTests.java +++ b/spring-context/src/test/java/org/springframework/validation/beanvalidation/MethodValidationAdapterPropertyPathTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,7 +42,7 @@ import static org.assertj.core.api.Assertions.assertThat; * * @author Rossen Stoyanchev */ -public class MethodValidationAdapterPropertyPathTests { +class MethodValidationAdapterPropertyPathTests { private static final Person validPerson = new Person("John"); diff --git a/spring-context/src/test/java/org/springframework/validation/beanvalidation/MethodValidationAdapterTests.java b/spring-context/src/test/java/org/springframework/validation/beanvalidation/MethodValidationAdapterTests.java index db61deb272e..a63b28b6db0 100644 --- a/spring-context/src/test/java/org/springframework/validation/beanvalidation/MethodValidationAdapterTests.java +++ b/spring-context/src/test/java/org/springframework/validation/beanvalidation/MethodValidationAdapterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,7 +46,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Rossen Stoyanchev * @author Sam Brannen */ -public class MethodValidationAdapterTests { +class MethodValidationAdapterTests { private static final Person faustino1234 = new Person("Faustino1234", List.of("Working on Spring")); diff --git a/spring-context/src/test/java/org/springframework/validation/beanvalidation/MethodValidationProxyTests.java b/spring-context/src/test/java/org/springframework/validation/beanvalidation/MethodValidationProxyTests.java index 5c401b63cf1..e9cd60103e1 100644 --- a/spring-context/src/test/java/org/springframework/validation/beanvalidation/MethodValidationProxyTests.java +++ b/spring-context/src/test/java/org/springframework/validation/beanvalidation/MethodValidationProxyTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -57,7 +57,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; * @author Juergen Hoeller * @author Rossen Stoyanchev */ -public class MethodValidationProxyTests { +class MethodValidationProxyTests { @Test @SuppressWarnings("unchecked") @@ -109,17 +109,17 @@ public class MethodValidationProxyTests { } @Test - public void testLazyValidatorForMethodValidation() { + void testLazyValidatorForMethodValidation() { doTestLazyValidatorForMethodValidation(LazyMethodValidationConfig.class); } @Test - public void testLazyValidatorForMethodValidationWithProxyTargetClass() { + void testLazyValidatorForMethodValidationWithProxyTargetClass() { doTestLazyValidatorForMethodValidation(LazyMethodValidationConfigWithProxyTargetClass.class); } @Test - public void testLazyValidatorForMethodValidationWithValidatorProvider() { + void testLazyValidatorForMethodValidationWithValidatorProvider() { doTestLazyValidatorForMethodValidation(LazyMethodValidationConfigWithValidatorProvider.class); } @@ -209,7 +209,7 @@ public class MethodValidationProxyTests { @Nullable @Override - public Object invoke(MethodInvocation invocation) throws Throwable { + public Object invoke(MethodInvocation invocation) { Method method; try { method = ClassUtils.getMethod(MyValidBean.class, invocation.getMethod().getName(), (Class[]) null); diff --git a/spring-context/src/test/java/org/springframework/validation/beanvalidation/SpringValidatorAdapterTests.java b/spring-context/src/test/java/org/springframework/validation/beanvalidation/SpringValidatorAdapterTests.java index 060869a17f0..47801e12d9f 100644 --- a/spring-context/src/test/java/org/springframework/validation/beanvalidation/SpringValidatorAdapterTests.java +++ b/spring-context/src/test/java/org/springframework/validation/beanvalidation/SpringValidatorAdapterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -61,7 +61,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Kazuki Shimizu * @author Juergen Hoeller */ -public class SpringValidatorAdapterTests { +class SpringValidatorAdapterTests { private final Validator nativeValidator = Validation.buildDefaultValidatorFactory().getValidator(); @@ -71,7 +71,7 @@ public class SpringValidatorAdapterTests { @BeforeEach - public void setupSpringValidatorAdapter() { + void setupSpringValidatorAdapter() { messageSource.addMessage("Size", Locale.ENGLISH, "Size of {0} must be between {2} and {1}"); messageSource.addMessage("Same", Locale.ENGLISH, "{2} must be same value as {1}"); messageSource.addMessage("password", Locale.ENGLISH, "Password"); @@ -80,7 +80,7 @@ public class SpringValidatorAdapterTests { @Test - public void testUnwrap() { + void testUnwrap() { Validator nativeValidator = validatorAdapter.unwrap(Validator.class); assertThat(nativeValidator).isSameAs(this.nativeValidator); } @@ -174,7 +174,7 @@ public class SpringValidatorAdapterTests { } @Test - public void testPatternMessage() { + void testPatternMessage() { TestBean testBean = new TestBean(); testBean.setEmail("X"); testBean.setConfirmEmail("X"); diff --git a/spring-context/src/test/resources/org/springframework/jmx/export/annotation/lazyAssembling.xml b/spring-context/src/test/resources/org/springframework/jmx/export/annotation/lazyAssembling.xml index 7359d87ba4c..7190ff53840 100644 --- a/spring-context/src/test/resources/org/springframework/jmx/export/annotation/lazyAssembling.xml +++ b/spring-context/src/test/resources/org/springframework/jmx/export/annotation/lazyAssembling.xml @@ -20,7 +20,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/jmx/export/autodetectLazyMBeans.xml b/spring-context/src/test/resources/org/springframework/jmx/export/autodetectLazyMBeans.xml index e82e678dfcc..a92ed936fca 100644 --- a/spring-context/src/test/resources/org/springframework/jmx/export/autodetectLazyMBeans.xml +++ b/spring-context/src/test/resources/org/springframework/jmx/export/autodetectLazyMBeans.xml @@ -13,7 +13,7 @@ - + diff --git a/spring-context/src/testFixtures/java/org/springframework/context/testfixture/jmx/export/Person.java b/spring-context/src/testFixtures/java/org/springframework/context/testfixture/jmx/export/Person.java new file mode 100644 index 00000000000..391536b79dd --- /dev/null +++ b/spring-context/src/testFixtures/java/org/springframework/context/testfixture/jmx/export/Person.java @@ -0,0 +1,32 @@ +/* + * Copyright 2002-2024 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * 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 org.springframework.context.testfixture.jmx.export; + +public class Person implements PersonMBean { + + private String name; + + @Override + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + +} diff --git a/spring-context/src/testFixtures/java/org/springframework/context/testfixture/jmx/export/PersonMBean.java b/spring-context/src/testFixtures/java/org/springframework/context/testfixture/jmx/export/PersonMBean.java new file mode 100644 index 00000000000..b0cba30aaf5 --- /dev/null +++ b/spring-context/src/testFixtures/java/org/springframework/context/testfixture/jmx/export/PersonMBean.java @@ -0,0 +1,23 @@ +/* + * Copyright 2002-2024 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * 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 org.springframework.context.testfixture.jmx.export; + +public interface PersonMBean { + + String getName(); + +}