RESOLVED - issue SPR-6195

This commit is contained in:
David Syer
2009-10-27 13:41:22 +00:00
parent a29253f2ca
commit 4be237dd84
2 changed files with 59 additions and 2 deletions

View File

@@ -37,6 +37,29 @@ public class StringArrayPropertyEditorTests extends TestCase {
assertEquals("0,1,2", editor.getAsText());
}
public void testTrimByDefault() throws Exception {
StringArrayPropertyEditor editor = new StringArrayPropertyEditor();
editor.setAsText(" 0,1 , 2 ");
Object value = editor.getValue();
String[] array = (String[]) value;
for (int i = 0; i < array.length; ++i) {
assertEquals("" + i, array[i]);
}
assertEquals("0,1,2", editor.getAsText());
}
public void testNoTrim() throws Exception {
StringArrayPropertyEditor editor = new StringArrayPropertyEditor(",",false,false);
editor.setAsText(" 0,1 , 2 ");
Object value = editor.getValue();
String[] array = (String[]) value;
for (int i = 0; i < array.length; ++i) {
assertEquals(3, array[i].length());
assertEquals("" + i, array[i].trim());
}
assertEquals(" 0,1 , 2 ", editor.getAsText());
}
public void testWithCustomSeparator() throws Exception {
StringArrayPropertyEditor editor = new StringArrayPropertyEditor(":");
editor.setAsText("0:1:2");