From cc5d4b8b7fd56f8eb2b6ca920c1547bce3e8f4df Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Fri, 5 Feb 2016 21:57:38 -0800 Subject: [PATCH] Add AssertJ checkstyle rule Closes gh-5083 --- spring-boot-parent/src/checkstyle/checkstyle.xml | 9 ++++++++- .../org/springframework/boot/test/OutputCapture.java | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/spring-boot-parent/src/checkstyle/checkstyle.xml b/spring-boot-parent/src/checkstyle/checkstyle.xml index 7b55179e89e..856ee2b40d0 100644 --- a/spring-boot-parent/src/checkstyle/checkstyle.xml +++ b/spring-boot-parent/src/checkstyle/checkstyle.xml @@ -71,7 +71,7 @@ + value="org.assertj.core.api.Assertions.*, org.junit.Assert.*, org.junit.Assume.*, org.junit.internal.matchers.ThrowableMessageMatcher.*, org.hamcrest.CoreMatchers.*, org.hamcrest.Matchers.*, org.springframework.boot.configurationprocessor.ConfigurationMetadataMatchers.*, org.springframework.boot.configurationprocessor.TestCompiler.*, org.mockito.Mockito.*, org.mockito.BDDMockito.*, org.mockito.Matchers.*, org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*, org.springframework.test.web.servlet.result.MockMvcResultMatchers.*, org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.*, org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.*, org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo" /> @@ -136,6 +136,13 @@ value="Please use BDDMockto imports." /> + + + + + + diff --git a/spring-boot/src/main/java/org/springframework/boot/test/OutputCapture.java b/spring-boot/src/main/java/org/springframework/boot/test/OutputCapture.java index 1bc1e3beab9..2dfcadd562a 100644 --- a/spring-boot/src/main/java/org/springframework/boot/test/OutputCapture.java +++ b/spring-boot/src/main/java/org/springframework/boot/test/OutputCapture.java @@ -24,6 +24,7 @@ import java.util.ArrayList; import java.util.List; import org.hamcrest.Matcher; +import org.junit.Assert; import org.junit.rules.TestRule; import org.junit.runner.Description; import org.junit.runners.model.Statement; @@ -32,7 +33,6 @@ import org.springframework.boot.ansi.AnsiOutput; import org.springframework.boot.ansi.AnsiOutput.Enabled; import static org.hamcrest.Matchers.allOf; -import static org.junit.Assert.assertThat; /** * JUnit {@code @Rule} to capture output from System.out and System.err. @@ -63,7 +63,7 @@ public class OutputCapture implements TestRule { try { if (!OutputCapture.this.matchers.isEmpty()) { String output = OutputCapture.this.toString(); - assertThat(output, allOf(OutputCapture.this.matchers)); + Assert.assertThat(output, allOf(OutputCapture.this.matchers)); } } finally {