1
0
mirror of synced 2026-05-22 13:23:17 +00:00

Replace ExpectedException @Rules with AssertJ

Replace JUnit ExpectedException @Rules with AssertJ calls.
This commit is contained in:
Phillip Webb
2020-09-10 18:40:27 -07:00
committed by Josh Cummings
parent 910b81928f
commit 20baa7d409
24 changed files with 383 additions and 543 deletions
@@ -17,21 +17,18 @@
package org.springframework.security;
import org.junit.After;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.springframework.beans.factory.BeanDefinitionStoreException;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
/**
* @author Eddú Meléndez
*/
public class LdapServerBeanDefinitionParserTests {
@Rule
public ExpectedException thrown = ExpectedException.none();
private ClassPathXmlApplicationContext context;
@After
@@ -44,10 +41,9 @@ public class LdapServerBeanDefinitionParserTests {
@Test
public void apacheDirectoryServerIsStartedByDefault() {
this.thrown.expect(BeanDefinitionStoreException.class);
this.thrown.expectMessage("Embedded LDAP server is not provided");
this.context = new ClassPathXmlApplicationContext("applicationContext-security.xml");
assertThatExceptionOfType(BeanDefinitionStoreException.class)
.isThrownBy(() -> this.context = new ClassPathXmlApplicationContext("applicationContext-security.xml"))
.withMessageContaining("Embedded LDAP server is not provided");
}
}