Polish "Add properties to control exceptions ignored by LdapTemplate"
See gh-21289
This commit is contained in:
@@ -122,10 +122,11 @@ class LdapAutoConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void templateWithCustomConfigurationExists() {
|
||||
void templateConfigurationCanBeCustomized() {
|
||||
this.contextRunner.withPropertyValues("spring.ldap.urls:ldap://localhost:389",
|
||||
"spring.ldap.ignorePartialResultException=true", "spring.ldap.ignoreNameNotFoundException=true",
|
||||
"spring.ldap.ignoreSizeLimitExceededException=false").run((context) -> {
|
||||
"spring.ldap.template.ignorePartialResultException=true",
|
||||
"spring.ldap.template.ignoreNameNotFoundException=true",
|
||||
"spring.ldap.template.ignoreSizeLimitExceededException=false").run((context) -> {
|
||||
assertThat(context).hasSingleBean(LdapTemplate.class);
|
||||
LdapTemplate ldapTemplate = context.getBean(LdapTemplate.class);
|
||||
assertThat(ldapTemplate).hasFieldOrPropertyWithValue("ignorePartialResultException", true);
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.springframework.boot.autoconfigure.ldap;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.autoconfigure.ldap.LdapProperties.Template;
|
||||
import org.springframework.ldap.core.LdapTemplate;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -29,18 +30,16 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*/
|
||||
class LdapPropertiesTests {
|
||||
|
||||
private final LdapProperties properties = new LdapProperties();
|
||||
|
||||
@Test
|
||||
void ldapTemplatePropertiesUseConsistentLdapTemplateDefaultValues() {
|
||||
Template templateProperties = new LdapProperties().getTemplate();
|
||||
LdapTemplate ldapTemplate = new LdapTemplate();
|
||||
|
||||
assertThat(ldapTemplate).hasFieldOrPropertyWithValue("ignorePartialResultException",
|
||||
this.properties.isIgnorePartialResultException());
|
||||
templateProperties.isIgnorePartialResultException());
|
||||
assertThat(ldapTemplate).hasFieldOrPropertyWithValue("ignoreNameNotFoundException",
|
||||
this.properties.isIgnoreNameNotFoundException());
|
||||
templateProperties.isIgnoreNameNotFoundException());
|
||||
assertThat(ldapTemplate).hasFieldOrPropertyWithValue("ignoreSizeLimitExceededException",
|
||||
this.properties.isIgnoreSizeLimitExceededException());
|
||||
templateProperties.isIgnoreSizeLimitExceededException());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user