Add @SuppressWarnings(deprecation) on tests

- add on tests for deprecated class
- add on tests for specific deprecated function

Closes gh-18412

Signed-off-by: Bae Jihong <dasog@naver.com>
This commit is contained in:
Bae Jihong 2026-02-08 17:57:42 +09:00 committed by Josh Cummings
parent d76fb7f2e6
commit 9b108df1dc
55 changed files with 66 additions and 10 deletions

View File

@ -29,6 +29,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
*
* @author Ben Alex
*/
@SuppressWarnings("deprecation")
public class AuthenticationCredentialsNotFoundEventTests {
@Test

View File

@ -32,6 +32,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
*
* @author Ben Alex
*/
@SuppressWarnings("deprecation")
public class AuthorizationFailureEventTests {
private final UsernamePasswordAuthenticationToken foo = UsernamePasswordAuthenticationToken.unauthenticated("foo",

View File

@ -29,6 +29,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
*
* @author Ben Alex
*/
@SuppressWarnings("deprecation")
public class AuthorizedEventTests {
@Test

View File

@ -27,6 +27,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
*
* @author Ben Alex
*/
@SuppressWarnings("deprecation")
public class SecurityConfigTests {
@Test

View File

@ -32,6 +32,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Luke Taylor
* @author Ben Alex
*/
@SuppressWarnings("deprecation")
public class Jsr250MethodSecurityMetadataSourceTests {
Jsr250MethodSecurityMetadataSource mds;

View File

@ -31,6 +31,7 @@ import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Luke Taylor
*/
@SuppressWarnings("deprecation")
public class Jsr250VoterTests {
// SEC-1443

View File

@ -46,6 +46,7 @@ import static org.assertj.core.api.Assertions.fail;
* @author Ben Alex
* @author Luke Taylor
*/
@SuppressWarnings("deprecation")
public class SecuredAnnotationSecurityMetadataSourceTests {
private SecuredAnnotationSecurityMetadataSource mds = new SecuredAnnotationSecurityMetadataSource();

View File

@ -79,11 +79,13 @@ public class DefaultMethodSecurityExpressionHandlerTests {
}
@Test
@SuppressWarnings("deprecation")
public void setTrustResolverNull() {
assertThatIllegalArgumentException().isThrownBy(() -> this.handler.setTrustResolver(null));
}
@Test
@SuppressWarnings("deprecation")
public void createEvaluationContextCustomTrustResolver() {
setupMocks();
this.handler.setTrustResolver(this.trustResolver);
@ -175,7 +177,7 @@ public class DefaultMethodSecurityExpressionHandlerTests {
@Test
public void createEvaluationContextSupplierAuthentication() {
setupMocks();
Supplier<Authentication> mockAuthenticationSupplier = mock(Supplier.class);
Supplier<Authentication> mockAuthenticationSupplier = mock();
given(mockAuthenticationSupplier.get()).willReturn(this.authentication);
EvaluationContext context = this.handler.createEvaluationContext(mockAuthenticationSupplier,
this.methodInvocation);

View File

@ -39,6 +39,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
* @since 5.2
*/
@ExtendWith(MockitoExtension.class)
@SuppressWarnings("deprecation")
public class ExpressionBasedPreInvocationAdviceTests {
@Mock

View File

@ -34,7 +34,7 @@ import org.springframework.security.util.SimpleMethodInvocation;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
@SuppressWarnings("unchecked")
@SuppressWarnings({ "unchecked", "deprecation" })
public class MethodExpressionVoterTests {
private TestingAuthenticationToken joe = new TestingAuthenticationToken("joe", "joespass", "ROLE_blah");

View File

@ -44,6 +44,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Luke Taylor
* @since 3.0
*/
@SuppressWarnings("deprecation")
public class PrePostAnnotationSecurityMetadataSourceTests {
private PrePostAnnotationSecurityMetadataSource mds = new PrePostAnnotationSecurityMetadataSource(

View File

@ -32,6 +32,7 @@ import static org.mockito.Mockito.mock;
*
* @author Ben Alex
*/
@SuppressWarnings("deprecation")
public class AbstractSecurityInterceptorTests {
@Test

View File

@ -38,7 +38,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
*
* @author Ben Alex
*/
@SuppressWarnings("unchecked")
@SuppressWarnings({ "unchecked", "deprecation" })
public class AfterInvocationProviderManagerTests {
@Test

View File

@ -34,6 +34,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Ben Alex
*/
@SuppressWarnings("deprecation")
public class InterceptorStatusTokenTests {
@Test

View File

@ -27,6 +27,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Ben Alex
*/
@SuppressWarnings("deprecation")
public class NullRunAsManagerTests {
@Test

View File

@ -31,6 +31,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
/**
* Tests {@link RunAsImplAuthenticationProvider}.
*/
@SuppressWarnings("deprecation")
public class RunAsImplAuthenticationProviderTests {
@Test

View File

@ -34,6 +34,7 @@ import static org.assertj.core.api.Assertions.fail;
*
* @author Ben Alex
*/
@SuppressWarnings("deprecation")
public class RunAsManagerImplTests {
@Test

View File

@ -29,6 +29,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
*
* @author Ben Alex
*/
@SuppressWarnings("deprecation")
public class RunAsUserTokenTests {
@Test

View File

@ -65,7 +65,7 @@ import static org.mockito.Mockito.verifyNoMoreInteractions;
* @author Ben Alex
* @author Rob Winch
*/
@SuppressWarnings("unchecked")
@SuppressWarnings({ "unchecked", "deprecation" })
public class MethodSecurityInterceptorTests {
private TestingAuthenticationToken token;

View File

@ -33,6 +33,7 @@ import static org.mockito.Mockito.mock;
*
* @author Ben Alex
*/
@SuppressWarnings("deprecation")
public class MethodSecurityMetadataSourceAdvisorTests {
@Test

View File

@ -62,6 +62,7 @@ import static org.mockito.Mockito.verifyNoMoreInteractions;
* @author Luke Taylor
* @author Rob Winch
*/
@SuppressWarnings("deprecation")
public class AspectJMethodSecurityInterceptorTests {
private TestingAuthenticationToken token;

View File

@ -34,6 +34,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Luke Taylor
* @since 2.0.4
*/
@SuppressWarnings("deprecation")
public class MapBasedMethodSecurityMetadataSourceTests {
private final List<ConfigAttribute> ROLE_A = SecurityConfig.createList("ROLE_A");

View File

@ -49,6 +49,7 @@ import static org.mockito.Mockito.mock;
*
* @author Ben Alex
*/
@SuppressWarnings("deprecation")
public class MethodInvocationPrivilegeEvaluatorTests {
private TestingAuthenticationToken token;

View File

@ -36,7 +36,7 @@ import static org.mockito.Mockito.mock;
/**
* @author Luke Taylor
*/
@SuppressWarnings({ "unchecked" })
@SuppressWarnings({ "unchecked", "deprecation" })
public class DelegatingMethodSecurityMetadataSourceTests {
DelegatingMethodSecurityMetadataSource mds;

View File

@ -29,6 +29,7 @@ import org.springframework.security.access.intercept.aspectj.MethodInvocationAda
import static org.assertj.core.api.Assertions.assertThat;
@ExtendWith(MockitoExtension.class)
@SuppressWarnings("deprecation")
public class PostInvocationAdviceProviderTests {
@Mock

View File

@ -29,6 +29,7 @@ import org.springframework.security.access.intercept.aspectj.MethodInvocationAda
import static org.assertj.core.api.Assertions.assertThat;
@ExtendWith(MockitoExtension.class)
@SuppressWarnings("deprecation")
public class PreInvocationAuthorizationAdviceVoterTests {
@Mock

View File

@ -36,7 +36,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
*
* @author Ben Alex
*/
@SuppressWarnings("unchecked")
@SuppressWarnings({ "unchecked", "deprecation" })
public class AbstractAccessDecisionManagerTests {
@Test

View File

@ -31,6 +31,7 @@ import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Luke Taylor
*/
@SuppressWarnings("deprecation")
public class AbstractAclVoterTests {
private AbstractAclVoter voter = new AbstractAclVoter() {

View File

@ -40,6 +40,7 @@ import static org.mockito.Mockito.mock;
*
* @author Ben Alex
*/
@SuppressWarnings("deprecation")
public class AffirmativeBasedTests {
private final List<ConfigAttribute> attrs = new ArrayList<>();

View File

@ -37,6 +37,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
*
* @author Ben Alex
*/
@SuppressWarnings("deprecation")
public class AuthenticatedVoterTests {
private Authentication createAnonymous() {

View File

@ -35,6 +35,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
*
* @author Ben Alex
*/
@SuppressWarnings("deprecation")
public class ConsensusBasedTests {
@Test

View File

@ -32,6 +32,7 @@ import org.springframework.security.core.Authentication;
*
* @author Ben Alex
*/
@SuppressWarnings("deprecation")
public class DenyAgainVoter implements AccessDecisionVoter<Object> {
@Override

View File

@ -34,6 +34,7 @@ import org.springframework.security.core.Authentication;
*
* @author Ben Alex
*/
@SuppressWarnings("deprecation")
public class DenyVoter implements AccessDecisionVoter<Object> {
@Override

View File

@ -25,6 +25,7 @@ import org.springframework.security.authentication.TestingAuthenticationToken;
import static org.assertj.core.api.Assertions.assertThat;
@SuppressWarnings("deprecation")
public class RoleHierarchyVoterTests {
@Test

View File

@ -28,6 +28,7 @@ import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Luke Taylor
*/
@SuppressWarnings("deprecation")
public class RoleVoterTests {
@Test

View File

@ -35,6 +35,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
*
* @author Ben Alex
*/
@SuppressWarnings("deprecation")
public class UnanimousBasedTests {
private UnanimousBased makeDecisionManager() {

View File

@ -44,7 +44,7 @@ import static org.mockito.Mockito.verify;
/**
* @author Luke Taylor
*/
@SuppressWarnings({ "unchecked" })
@SuppressWarnings({ "unchecked", "deprecation" })
public class AclEntryAfterInvocationCollectionFilteringProviderTests {
@Test

View File

@ -48,7 +48,7 @@ import static org.mockito.Mockito.verify;
/**
* @author Luke Taylor
*/
@SuppressWarnings({ "unchecked" })
@SuppressWarnings({ "unchecked", "deprecation" })
public class AclEntryAfterInvocationProviderTests {
@Test

View File

@ -35,6 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.BDDMockito.given;
@ExtendWith(MockitoExtension.class)
@SuppressWarnings("deprecation")
public class ExpressionBasedMessageSecurityMetadataSourceFactoryTests {
@Mock

View File

@ -37,6 +37,7 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@ExtendWith(MockitoExtension.class)
@SuppressWarnings("deprecation")
public class MessageExpressionConfigAttributeTests {
@Mock

View File

@ -44,6 +44,7 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@ExtendWith(MockitoExtension.class)
@SuppressWarnings("deprecation")
public class MessageExpressionVoterTests {
@Mock
@ -76,6 +77,7 @@ public class MessageExpressionVoterTests {
}
@Test
@SuppressWarnings("unchecked")
public void voteGranted() {
given(this.expression.getValue(any(EvaluationContext.class), eq(Boolean.class))).willReturn(true);
given(this.matcher.matcher(any())).willCallRealMethod();
@ -84,6 +86,7 @@ public class MessageExpressionVoterTests {
}
@Test
@SuppressWarnings("unchecked")
public void voteDenied() {
given(this.expression.getValue(any(EvaluationContext.class), eq(Boolean.class))).willReturn(false);
given(this.matcher.matcher(any())).willCallRealMethod();
@ -92,6 +95,7 @@ public class MessageExpressionVoterTests {
}
@Test
@SuppressWarnings("unchecked")
public void voteAbstain() {
this.attributes = Arrays.<ConfigAttribute>asList(new SecurityConfig("ROLE_USER"));
assertThat(this.voter.vote(this.authentication, this.message, this.attributes))
@ -99,11 +103,13 @@ public class MessageExpressionVoterTests {
}
@Test
@SuppressWarnings("unchecked")
public void supportsObjectClassFalse() {
assertThat(this.voter.supports(Object.class)).isFalse();
}
@Test
@SuppressWarnings("unchecked")
public void supportsMessageClassTrue() {
assertThat(this.voter.supports(Message.class)).isTrue();
}
@ -119,11 +125,13 @@ public class MessageExpressionVoterTests {
}
@Test
@SuppressWarnings("unchecked")
public void setExpressionHandlerNull() {
assertThatIllegalArgumentException().isThrownBy(() -> this.voter.setExpressionHandler(null));
}
@Test
@SuppressWarnings("unchecked")
public void customExpressionHandler() {
this.voter.setExpressionHandler(this.expressionHandler);
given(this.expressionHandler.createEvaluationContext(this.authentication, this.message))
@ -136,6 +144,7 @@ public class MessageExpressionVoterTests {
}
@Test
@SuppressWarnings("unchecked")
public void postProcessEvaluationContext() {
final MessageExpressionConfigAttribute configAttribute = mock(MessageExpressionConfigAttribute.class);
this.voter.setExpressionHandler(this.expressionHandler);

View File

@ -47,6 +47,7 @@ import static org.mockito.BDDMockito.given;
import static org.mockito.BDDMockito.willThrow;
@ExtendWith(MockitoExtension.class)
@SuppressWarnings("deprecation")
public class ChannelSecurityInterceptorTests {
@Mock

View File

@ -36,6 +36,7 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.BDDMockito.given;
@ExtendWith(MockitoExtension.class)
@SuppressWarnings("deprecation")
public class DefaultMessageSecurityMetadataSourceTests {
@Mock

View File

@ -43,6 +43,7 @@ import org.springframework.security.web.access.intercept.FilterSecurityIntercept
*
* @author Ben Alex
*/
@SuppressWarnings("deprecation")
public class DefaultWebInvocationPrivilegeEvaluatorTests {
private AccessDecisionManager adm;

View File

@ -42,7 +42,7 @@ import static org.mockito.Mockito.mock;
*
* @author Ben Alex
*/
@SuppressWarnings("unchecked")
@SuppressWarnings({ "unchecked", "deprecation" })
public class ChannelDecisionManagerImplTests {
@Test

View File

@ -39,6 +39,7 @@ import static org.mockito.Mockito.mock;
*
* @author Ben Alex
*/
@SuppressWarnings("deprecation")
public class ChannelProcessingFilterTests {
@Test

View File

@ -35,6 +35,7 @@ import static org.mockito.Mockito.mock;
*
* @author Ben Alex
*/
@SuppressWarnings("deprecation")
public class InsecureChannelProcessorTests {
@Test

View File

@ -36,6 +36,7 @@ import static org.mockito.Mockito.mock;
*
* @author Ben Alex
*/
@SuppressWarnings("deprecation")
public class RetryWithHttpEntryPointTests {
@Test

View File

@ -33,6 +33,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
*
* @author Ben Alex
*/
@SuppressWarnings("deprecation")
public class RetryWithHttpsEntryPointTests {
@Test

View File

@ -35,6 +35,7 @@ import static org.mockito.Mockito.mock;
*
* @author Ben Alex
*/
@SuppressWarnings("deprecation")
public class SecureChannelProcessorTests {
@Test

View File

@ -78,11 +78,13 @@ public class DefaultWebSecurityExpressionHandlerTests {
}
@Test
@SuppressWarnings("deprecation")
public void setTrustResolverNull() {
assertThatIllegalArgumentException().isThrownBy(() -> this.handler.setTrustResolver(null));
}
@Test
@SuppressWarnings("deprecation")
public void createEvaluationContextCustomTrustResolver() {
this.handler.setTrustResolver(this.trustResolver);
Expression expression = this.handler.getExpressionParser().parseExpression("anonymous");

View File

@ -33,6 +33,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
/**
* @author Luke Taylor
*/
@SuppressWarnings("deprecation")
public class ExpressionBasedFilterInvocationSecurityMetadataSourceTests {
@Test

View File

@ -41,7 +41,7 @@ import static org.mockito.Mockito.mock;
/**
* @author Luke Taylor
*/
@SuppressWarnings({ "unchecked" })
@SuppressWarnings({ "unchecked", "deprecation" })
public class WebExpressionVoterTests {
private Authentication user = new TestingAuthenticationToken("user", "pass", "X");

View File

@ -40,6 +40,7 @@ import static org.mockito.Mockito.mock;
*
* @author Ben Alex
*/
@SuppressWarnings("deprecation")
public class DefaultFilterInvocationSecurityMetadataSourceTests {
private DefaultFilterInvocationSecurityMetadataSource fids;

View File

@ -62,6 +62,7 @@ import static org.mockito.Mockito.verifyNoMoreInteractions;
* @author Luke Taylor
* @author Rob Winch
*/
@SuppressWarnings("deprecation")
public class FilterSecurityInterceptorTests {
private AuthenticationManager am;