Migrate away from ExpectedException (#22922)
* Add limited checkstyles to test code Add a limited set of checkstyle rules to the test codebase to improve code consistency. * Fix checksyle violations in test code * Organize imports to fix checkstyle for test code * Migrate to assertThatExceptionOfType Migrate aware from ExpectedException rules to AssertJ exception assertions. Also include a checkstyle rules to ensure that the the ExpectedException is not accidentally used in the future. See gh-22894
This commit is contained in:
@@ -3,8 +3,7 @@
|
||||
<suppressions>
|
||||
|
||||
<!-- global -->
|
||||
<suppress files="[\\/]src[\\/]test[\\/]java[\\/]" checks=".*" />
|
||||
<suppress files="ValueConstants" checks="InterfaceIsType" />
|
||||
<suppress files="[\\/]src[\\/]test[\\/]java[\\/]" checks="AnnotationLocation|AnnotationUseStyle|AtclauseOrder|AvoidNestedBlocks|AvoidStarImport|FinalClass|HideUtilityClassConstructor|InnerTypeLast|JavadocStyle|JavadocType|JavadocVariable|LeftCurly|MultipleVariableDeclarations|NeedBraces|OneTopLevelClass|OuterTypeFilename|RequireThis|SpringCatch|SpringJavadoc|SpringNoThis" />
|
||||
|
||||
<!-- spring-beans -->
|
||||
<suppress files="TypeMismatchException" checks="MutableException"/>
|
||||
@@ -25,9 +24,10 @@
|
||||
<!-- spring-expression -->
|
||||
<suppress files="ExpressionException" checks="MutableException" />
|
||||
<suppress files="SpelMessage" checks="JavadocVariable|JavadocStyle" />
|
||||
<suppress files="SpelReproTests" checks="InterfaceIsType" />
|
||||
|
||||
<!-- spring-jcl -->
|
||||
<suppress files="[\\/]src[\\/]main[\\/]java[\\/]org[\\/]apache[\\/]commons[\\/]logging[\\/]" checks="Header|SpringNoThis" />
|
||||
<suppress files="[\\/]src[\\/]main[\\/]java[\\/]org[\\/]apache[\\/]commons[\\/]logging[\\/]" checks="Header|SpringNoThis|IllegalImport" />
|
||||
|
||||
<!-- spring-jdbc -->
|
||||
<suppress files="ResultSetWrappingSqlRowSet" checks="JavadocStyle" />
|
||||
@@ -45,6 +45,7 @@
|
||||
<suppress files="StompCommand" checks="JavadocVariable" />
|
||||
<suppress files="StompHeaderAccessor" checks="JavadocVariable" />
|
||||
<suppress files="StompHeaders" checks="JavadocVariable" />
|
||||
<suppress files="org[\\/]springframework[\\/]messaging[\\/]handler[\\/]annotation[\\/]ValueConstants" checks="InterfaceIsType" />
|
||||
|
||||
<!-- spring-orm -->
|
||||
<suppress files="jpa[\\/]vendor[\\/]Database" checks="JavadocVariable|JavadocStyle"/>
|
||||
@@ -62,16 +63,21 @@
|
||||
<suppress files="org[\\/]springframework[\\/]http[\\/]HttpStatus" checks="JavadocVariable|JavadocStyle" />
|
||||
<suppress files="org[\\/]springframework[\\/]web[\\/]bind[\\/]annotation[\\/]CrossOrigin" checks="JavadocStyle" />
|
||||
<suppress files="org[\\/]springframework[\\/]web[\\/]bind[\\/]annotation[\\/]RequestMethod" checks="JavadocVariable" />
|
||||
<suppress files="org[\\/]springframework[\\/]web[\\/]bind[\\/]annotation[\\/]ValueConstants" checks="InterfaceIsType" />
|
||||
<suppress files="PatternParseException" checks="JavadocVariable" />
|
||||
<suppress files="web[\\/]reactive[\\/]socket[\\/]CloseStatus" checks="JavadocStyle" />
|
||||
|
||||
<!-- spring-webmvc -->
|
||||
<suppress files="org[\\/]springframework[\\/]web[\\/]servlet[\\/]tags[\\/]form[\\/].*Tag" checks="JavadocVariable" />
|
||||
<suppress files="src[\\/]test[\\/]java[\\/]org[\\/]springframework[\\/]protobuf[\\/].*" checks=".*" />
|
||||
<suppress files="ExtractingResponseErrorHandlerTests" checks="MutableException" />
|
||||
<suppress files="ServletAnnotationControllerHandlerMethodTests" checks="InterfaceIsType" />
|
||||
|
||||
<!-- spring-websocket -->
|
||||
<suppress files="web[\\/]socket[\\/]CloseStatus" checks="JavadocStyle" />
|
||||
<suppress files="web[\\/]socket[\\/]WebSocketHttpHeaders" checks="JavadocVariable" />
|
||||
<suppress files="sockjs[\\/]frame[\\/]SockJsFrameType" checks="JavadocVariable" />
|
||||
<suppress files="sockjs[\\/]transport[\\/]TransportType" checks="JavadocVariable" />
|
||||
<suppress files="src[\\/]test[\\/]java[\\/]org[\\/]springframework[\\/]web[\\/]reactive[\\/]protobuf[\\/].*" checks=".*" />
|
||||
|
||||
</suppressions>
|
||||
|
||||
@@ -94,6 +94,11 @@
|
||||
<property name="option" value="bottom" />
|
||||
<property name="sortStaticImportsAlphabetically" value="true" />
|
||||
</module>
|
||||
<module name="com.puppycrawl.tools.checkstyle.checks.imports.IllegalImportCheck">
|
||||
<property name="regexp" value="true" />
|
||||
<property name="illegalClasses"
|
||||
value="^reactor\.core\.support\.Assert,^org\.junit\.rules\.ExpectedException,^org\.slf4j\.LoggerFactory" />
|
||||
</module>
|
||||
|
||||
<!-- Javadoc Comments -->
|
||||
<module name="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocTypeCheck">
|
||||
@@ -145,6 +150,15 @@
|
||||
<property name="illegalPattern" value="true" />
|
||||
<property name="message" value="Trailing whitespace" />
|
||||
</module>
|
||||
<module
|
||||
name="com.puppycrawl.tools.checkstyle.checks.regexp.RegexpSinglelineJavaCheck">
|
||||
<property name="maximum" value="0" />
|
||||
<property name="format"
|
||||
value="assertThatExceptionOfType\((NullPointerException|IllegalArgumentException|IOException|IllegalStateException)\.class\)" />
|
||||
<property name="message"
|
||||
value="Please use specialized AssertJ assertThat*Exception method." />
|
||||
<property name="ignoreComments" value="true" />
|
||||
</module>
|
||||
|
||||
<!-- Spring Conventions -->
|
||||
<module name="io.spring.javaformat.checkstyle.check.SpringLambdaCheck">
|
||||
|
||||
Reference in New Issue
Block a user