From b271b1fd668d3365195781a4248f25a6d497d912 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Tue, 28 Apr 2015 14:24:01 -0500 Subject: [PATCH] LDAP-328: DirtiesContext for Integration Tests that have Order issues The upgrade to JUnit 4.11 has revealed some integration tests whose success was dependant on them being run in a particular order. To overcome this the classes containing these tests have been marked with @DirtiesContext configured to renew the application context after each test method. --- .../ldap/itest/LdapTemplateSearchResultITest.java | 3 +++ .../itest/LdapTemplateSearchResultNamespaceConfigITest.java | 3 +++ 2 files changed, 6 insertions(+) diff --git a/test/integration-tests/src/test/java/org/springframework/ldap/itest/LdapTemplateSearchResultITest.java b/test/integration-tests/src/test/java/org/springframework/ldap/itest/LdapTemplateSearchResultITest.java index 5d87a422..7a176572 100644 --- a/test/integration-tests/src/test/java/org/springframework/ldap/itest/LdapTemplateSearchResultITest.java +++ b/test/integration-tests/src/test/java/org/springframework/ldap/itest/LdapTemplateSearchResultITest.java @@ -32,6 +32,8 @@ import org.springframework.ldap.query.SearchScope; import org.springframework.ldap.support.LdapUtils; import org.springframework.ldap.test.AttributeCheckAttributesMapper; import org.springframework.ldap.test.AttributeCheckContextMapper; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.annotation.DirtiesContext.ClassMode; import org.springframework.test.context.ContextConfiguration; import javax.naming.Name; @@ -53,6 +55,7 @@ import static org.springframework.ldap.query.LdapQueryBuilder.query; * @author Mattias Hellborg Arthursson */ @ContextConfiguration(locations = {"/conf/ldapTemplateTestContext.xml"}) +@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD) public class LdapTemplateSearchResultITest extends AbstractLdapTemplateIntegrationTest { @Autowired diff --git a/test/integration-tests/src/test/java/org/springframework/ldap/itest/LdapTemplateSearchResultNamespaceConfigITest.java b/test/integration-tests/src/test/java/org/springframework/ldap/itest/LdapTemplateSearchResultNamespaceConfigITest.java index 6ff0804f..3ab4424a 100644 --- a/test/integration-tests/src/test/java/org/springframework/ldap/itest/LdapTemplateSearchResultNamespaceConfigITest.java +++ b/test/integration-tests/src/test/java/org/springframework/ldap/itest/LdapTemplateSearchResultNamespaceConfigITest.java @@ -30,6 +30,8 @@ import org.springframework.ldap.query.SearchScope; import org.springframework.ldap.support.LdapUtils; import org.springframework.ldap.test.AttributeCheckAttributesMapper; import org.springframework.ldap.test.AttributeCheckContextMapper; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.annotation.DirtiesContext.ClassMode; import org.springframework.test.context.ContextConfiguration; import javax.naming.Name; @@ -50,6 +52,7 @@ import static org.springframework.ldap.query.LdapQueryBuilder.query; * @author Mattias Hellborg Arthursson */ @ContextConfiguration(locations = {"/conf/ldapTemplateNamespaceTestContext.xml"}) +@DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD) public class LdapTemplateSearchResultNamespaceConfigITest extends AbstractLdapTemplateIntegrationTest { @Autowired