@Test(expected = IllegalArgumentException.class) public void testCharacterEditorSetAsTextWithNullNotAllowingEmptyAsNull() throws Exception { PropertyEditor charEditor = new CharacterEditor(false); charEditor.setAsText(null); }
@Test(expected = IllegalArgumentException.class) public void testCharacterEditorSetAsTextWithStringLongerThanOneCharacter() throws Exception { PropertyEditor charEditor = new CharacterEditor(false); charEditor.setAsText("ColdWaterCanyon"); }
this.defaultEditors.put(char.class, new CharacterEditor(false)); this.defaultEditors.put(Character.class, new CharacterEditor(true));
@Test public void testCharacterEditorGetAsTextReturnsEmptyStringIfValueIsNull() throws Exception { PropertyEditor charEditor = new CharacterEditor(false); assertEquals("", charEditor.getAsText()); charEditor = new CharacterEditor(true); charEditor.setAsText(null); assertEquals("", charEditor.getAsText()); charEditor.setAsText(""); assertEquals("", charEditor.getAsText()); charEditor.setAsText(" "); assertEquals(" ", charEditor.getAsText()); }
this.defaultEditors.put(char.class, new CharacterEditor(false)); this.defaultEditors.put(Character.class, new CharacterEditor(true));
@Test public void testCharacterEditorWithAllowEmpty() { CharBean cb = new CharBean(); BeanWrapper bw = new BeanWrapperImpl(cb); bw.registerCustomEditor(Character.class, new CharacterEditor(true)); bw.setPropertyValue("myCharacter", new Character('c')); assertEquals(new Character('c'), cb.getMyCharacter()); bw.setPropertyValue("myCharacter", "c"); assertEquals(new Character('c'), cb.getMyCharacter()); bw.setPropertyValue("myCharacter", "\u0041"); assertEquals(new Character('A'), cb.getMyCharacter()); bw.setPropertyValue("myCharacter", " "); assertEquals(new Character(' '), cb.getMyCharacter()); bw.setPropertyValue("myCharacter", ""); assertNull(cb.getMyCharacter()); }
@Test public void testCharacterEditor() { CharBean cb = new CharBean(); BeanWrapper bw = new BeanWrapperImpl(cb); bw.setPropertyValue("myChar", new Character('c')); assertEquals('c', cb.getMyChar()); bw.setPropertyValue("myChar", "c"); assertEquals('c', cb.getMyChar()); bw.setPropertyValue("myChar", "\u0041"); assertEquals('A', cb.getMyChar()); bw.setPropertyValue("myChar", "\\u0022"); assertEquals('"', cb.getMyChar()); CharacterEditor editor = new CharacterEditor(false); editor.setAsText("M"); assertEquals("M", editor.getAsText()); }
this.defaultEditors.put(char.class, new CharacterEditor(false)); this.defaultEditors.put(Character.class, new CharacterEditor(true));
PropertyEditor characterEditor = new CharacterEditor(false); PropertyEditor booleanEditor = new CustomBooleanEditor(false);
binder.registerCustomEditor(char.class, new CharacterEditor(true)); binder.registerCustomEditor(int.class, new IntegerEditor() { @Override