From 3b3ccb962d85667e6f20550b24742e8057686e42 Mon Sep 17 00:00:00 2001 From: Rob Winch Date: Fri, 9 Jul 2021 15:07:16 -0500 Subject: [PATCH] Fix @Test(expected = --- .../config/web/servlet/ExceptionHandlingDslTests.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/config/src/test/kotlin/org/springframework/security/config/web/servlet/ExceptionHandlingDslTests.kt b/config/src/test/kotlin/org/springframework/security/config/web/servlet/ExceptionHandlingDslTests.kt index 5aa35ddfd9..d035747a20 100644 --- a/config/src/test/kotlin/org/springframework/security/config/web/servlet/ExceptionHandlingDslTests.kt +++ b/config/src/test/kotlin/org/springframework/security/config/web/servlet/ExceptionHandlingDslTests.kt @@ -16,6 +16,7 @@ package org.springframework.security.config.web.servlet +import org.assertj.core.api.Assertions.assertThatExceptionOfType import org.junit.jupiter.api.Test import org.springframework.beans.factory.annotation.Autowired import org.springframework.security.access.AccessDeniedException @@ -67,11 +68,13 @@ class ExceptionHandlingDslTests { } } - @Test(expected = AccessDeniedException::class) + @Test fun `request when exception handling disabled then throws exception`() { this.spring.register(ExceptionHandlingDisabledConfig::class.java).autowire() - this.mockMvc.get("/") + assertThatExceptionOfType(AccessDeniedException::class.java).isThrownBy { + this.mockMvc.get("/") + } } @EnableWebSecurity