Improved ConfigAttributeEditor so it trims preceding and trailing spaces.
This commit is contained in:
parent
3f87849f31
commit
5cd65887d5
|
@ -4,6 +4,7 @@ Changes in version 0.x (2004-xx-xx)
|
||||||
* Added additional DaoAuthenticationProvider event when user not found
|
* Added additional DaoAuthenticationProvider event when user not found
|
||||||
* Added Authentication.getDetails() to DaoAuthenticationProvider response
|
* Added Authentication.getDetails() to DaoAuthenticationProvider response
|
||||||
* Extracted removeUserFromCache(String) to UserCache interface
|
* Extracted removeUserFromCache(String) to UserCache interface
|
||||||
|
* Improved ConfigAttributeEditor so it trims preceding and trailing spaces
|
||||||
* Fixed EH-CACHE-based caching implementation behaviour when cache exists
|
* Fixed EH-CACHE-based caching implementation behaviour when cache exists
|
||||||
* Fixed Ant "release" target not including project.properties
|
* Fixed Ant "release" target not including project.properties
|
||||||
* Fixed GrantedAuthorityEffectiveAclsResolver if null ACLs provided to method
|
* Fixed GrantedAuthorityEffectiveAclsResolver if null ACLs provided to method
|
||||||
|
|
|
@ -23,6 +23,11 @@ import java.beans.PropertyEditorSupport;
|
||||||
/**
|
/**
|
||||||
* A property editor that can create a populated {@link
|
* A property editor that can create a populated {@link
|
||||||
* ConfigAttributeDefinition} from a comma separated list of values.
|
* ConfigAttributeDefinition} from a comma separated list of values.
|
||||||
|
*
|
||||||
|
* <P>
|
||||||
|
* Trims preceding and trailing spaces from presented command separated tokens,
|
||||||
|
* as this can be a source of hard-to-spot configuration issues for end users.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @author Ben Alex
|
* @author Ben Alex
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
|
@ -39,7 +44,7 @@ public class ConfigAttributeEditor extends PropertyEditorSupport {
|
||||||
|
|
||||||
for (int i = 0; i < tokens.length; i++) {
|
for (int i = 0; i < tokens.length; i++) {
|
||||||
configDefinition.addConfigAttribute(new SecurityConfig(
|
configDefinition.addConfigAttribute(new SecurityConfig(
|
||||||
tokens[i]));
|
tokens[i].trim()));
|
||||||
}
|
}
|
||||||
|
|
||||||
setValue(configDefinition);
|
setValue(configDefinition);
|
||||||
|
|
|
@ -17,6 +17,7 @@ package net.sf.acegisecurity;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
|
||||||
|
@ -126,6 +127,27 @@ public class ConfigAttributeEditorTests extends TestCase {
|
||||||
assertTrue(result == null);
|
assertTrue(result == null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testStripsTrailingAndLeadingSpaces() {
|
||||||
|
ConfigAttributeEditor editor = new ConfigAttributeEditor();
|
||||||
|
editor.setAsText(" HELLO, DOCTOR,NAME, YESTERDAY ,TOMORROW ");
|
||||||
|
|
||||||
|
ConfigAttributeDefinition result = (ConfigAttributeDefinition) editor
|
||||||
|
.getValue();
|
||||||
|
Iterator iter = result.getConfigAttributes();
|
||||||
|
|
||||||
|
ArrayList list = new ArrayList();
|
||||||
|
|
||||||
|
while (iter.hasNext()) {
|
||||||
|
list.add(iter.next());
|
||||||
|
}
|
||||||
|
|
||||||
|
assertEquals("HELLO", ((ConfigAttribute) list.get(0)).getAttribute());
|
||||||
|
assertEquals("DOCTOR", ((ConfigAttribute) list.get(1)).getAttribute());
|
||||||
|
assertEquals("NAME", ((ConfigAttribute) list.get(2)).getAttribute());
|
||||||
|
assertEquals("YESTERDAY", ((ConfigAttribute) list.get(3)).getAttribute());
|
||||||
|
assertEquals("TOMORROW", ((ConfigAttribute) list.get(4)).getAttribute());
|
||||||
|
}
|
||||||
|
|
||||||
public void testToString() {
|
public void testToString() {
|
||||||
ConfigAttributeEditor editor = new ConfigAttributeEditor();
|
ConfigAttributeEditor editor = new ConfigAttributeEditor();
|
||||||
editor.setAsText("KOALA,KANGAROO,EMU,WOMBAT");
|
editor.setAsText("KOALA,KANGAROO,EMU,WOMBAT");
|
||||||
|
|
Loading…
Reference in New Issue