From 95139fca76cfbf0fbe3bd377ac20c0d464268919 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Wed, 4 Oct 2023 17:39:06 +0200 Subject: [PATCH] Polishing --- .../SqlScriptsTestExecutionListenerTests.java | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/spring-test/src/test/java/org/springframework/test/context/jdbc/SqlScriptsTestExecutionListenerTests.java b/spring-test/src/test/java/org/springframework/test/context/jdbc/SqlScriptsTestExecutionListenerTests.java index c71898e96654..07b3abd10c7b 100644 --- a/spring-test/src/test/java/org/springframework/test/context/jdbc/SqlScriptsTestExecutionListenerTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/jdbc/SqlScriptsTestExecutionListenerTests.java @@ -22,7 +22,6 @@ import org.springframework.context.ApplicationContext; import org.springframework.core.annotation.AnnotationConfigurationException; import org.springframework.test.context.TestContext; -import org.springframework.test.context.jdbc.SqlConfig.TransactionMode; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; @@ -32,6 +31,7 @@ import static org.mockito.Mockito.mock; import static org.springframework.test.context.jdbc.Sql.ExecutionPhase.AFTER_TEST_CLASS; import static org.springframework.test.context.jdbc.Sql.ExecutionPhase.BEFORE_TEST_CLASS; +import static org.springframework.test.context.jdbc.SqlConfig.TransactionMode.ISOLATED; /** * Unit tests for {@link SqlScriptsTestExecutionListener}. @@ -71,11 +71,12 @@ void valueAndScriptsDeclared() throws Exception { BDDMockito.> given(testContext.getTestClass()).willReturn(clazz); given(testContext.getTestMethod()).willReturn(clazz.getDeclaredMethod("foo")); - assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> - listener.beforeTestMethod(testContext)) - .withMessageContaining("Different @AliasFor mirror values") - .withMessageContaining("attribute 'scripts' and its alias 'value'") - .withMessageContaining("values of [{bar}] and [{foo}]"); + assertThatExceptionOfType(AnnotationConfigurationException.class) + .isThrownBy(() -> listener.beforeTestMethod(testContext)) + .withMessageContainingAll( + "Different @AliasFor mirror values", + "attribute 'scripts' and its alias 'value'", + "values of [{bar}] and [{foo}]"); } @Test @@ -129,9 +130,9 @@ void afterTestClassOnMethod() throws Exception { } private void assertExceptionContains(String msg) throws Exception { - assertThatIllegalStateException().isThrownBy(() -> - listener.beforeTestMethod(testContext)) - .withMessageContaining(msg); + assertThatIllegalStateException() + .isThrownBy(() -> listener.beforeTestMethod(testContext)) + .withMessageContaining(msg); } @@ -160,7 +161,7 @@ public void foo() { static class IsolatedWithoutTxMgr { - @Sql(scripts = "foo.sql", config = @SqlConfig(transactionMode = TransactionMode.ISOLATED)) + @Sql(scripts = "foo.sql", config = @SqlConfig(transactionMode = ISOLATED)) public void foo() { } }