From a3c11fc033f326f301e17b87ae857bdfe8709155 Mon Sep 17 00:00:00 2001 From: Sam Brannen <104798+sbrannen@users.noreply.github.com> Date: Tue, 2 Jan 2024 16:28:29 +0100 Subject: [PATCH] Clean up warnings in tests in Gradle build --- .../springframework/aop/framework/CglibProxyTests.java | 10 +++++----- .../aop/framework/JdkDynamicProxyTests.java | 6 ++---- .../bind/support/DefaultDataBinderFactoryTests.java | 3 ++- .../web/reactive/BindingContextTests.java | 3 ++- 4 files changed, 11 insertions(+), 11 deletions(-) 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 3d1a34cd50..91f366127f 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 @@ -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,6 @@ import org.springframework.aop.testfixture.interceptor.NopInterceptor; import org.springframework.aop.testfixture.mixin.LockMixinAdvisor; import org.springframework.beans.testfixture.beans.ITestBean; import org.springframework.beans.testfixture.beans.TestBean; -import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextException; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.lang.NonNull; @@ -52,7 +51,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException * @author Ramnivas Laddad * @author Chris Beams */ -class CglibProxyTests extends AbstractAopProxyTests implements Serializable { +class CglibProxyTests extends AbstractAopProxyTests { private static final String DEPENDENCY_CHECK_CONTEXT = CglibProxyTests.class.getSimpleName() + "-with-dependency-checking.xml"; @@ -376,8 +375,9 @@ class CglibProxyTests extends AbstractAopProxyTests implements Serializable { @Test void testWithDependencyChecking() { - ApplicationContext ctx = new ClassPathXmlApplicationContext(DEPENDENCY_CHECK_CONTEXT, getClass()); - ctx.getBean("testBean"); + try (ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(DEPENDENCY_CHECK_CONTEXT, getClass())) { + ctx.getBean("testBean"); + } } @Test 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 253c46b227..ff860ff62c 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 @@ -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; -import java.io.Serializable; - import org.aopalliance.intercept.MethodInterceptor; import org.aopalliance.intercept.MethodInvocation; import org.junit.jupiter.api.Test; @@ -38,7 +36,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException * @author Chris Beams * @since 13.03.2003 */ -class JdkDynamicProxyTests extends AbstractAopProxyTests implements Serializable { +class JdkDynamicProxyTests extends AbstractAopProxyTests { @Override protected Object createProxy(ProxyCreatorSupport as) { diff --git a/spring-web/src/test/java/org/springframework/web/bind/support/DefaultDataBinderFactoryTests.java b/spring-web/src/test/java/org/springframework/web/bind/support/DefaultDataBinderFactoryTests.java index a323acf77c..31e503f3e4 100644 --- a/spring-web/src/test/java/org/springframework/web/bind/support/DefaultDataBinderFactoryTests.java +++ b/spring-web/src/test/java/org/springframework/web/bind/support/DefaultDataBinderFactoryTests.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,6 +92,7 @@ public class DefaultDataBinderFactoryTests { public void validate(Object target, Errors errors) { } + @SuppressWarnings("unchecked") @Override public T unwrap(Class type) { return (T) this.validator; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/BindingContextTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/BindingContextTests.java index 078adc96a7..8e74863a26 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/BindingContextTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/BindingContextTests.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,6 +92,7 @@ public class BindingContextTests { public void validate(Object target, Errors errors) { } + @SuppressWarnings("unchecked") @Override public T unwrap(Class type) { return (T) this.validator;