1 17 18 package org.apache.geronimo.common.propertyeditor; 19 20 import java.util.Map ; 21 import java.util.Properties ; 22 23 28 public class PropertiesEditorTest extends AbstractMapEditorTest { 29 30 protected void setUp() { 31 editor = PropertyEditors.findEditor(Properties .class); 32 } 33 34 public void testEditorClass() throws Exception { 35 assertEquals(PropertiesEditor.class, editor.getClass()); 36 } 37 38 protected void checkType(Object output) { 39 assertTrue("editor returned a: " + output.getClass(), output instanceof Properties ); 40 } 41 42 public void testGetValue_1Item() { 43 String input = "key1=value1"; 44 45 editor.setAsText(input); 46 Object output = editor.getValue(); 47 48 assertNotNull(output); 49 checkType(output); 50 51 Map map = (Map ) output; 52 assertEquals(1, map.size()); 53 assertEquals("value1", map.get("key1")); 54 } 55 56 public void testGetValue_2Items() { 57 String input = "key1=value1\nkey2=value2"; 58 59 editor.setAsText(input); 60 Object output = editor.getValue(); 61 62 assertNotNull(output); 63 checkType(output); 64 65 Map map = (Map ) output; 66 assertEquals(2, map.size()); 67 assertEquals("value1", map.get("key1")); 68 assertEquals("value2", map.get("key2")); 69 } 70 71 protected Map createMap() { 72 return new Properties (); 73 } 74 } 75 | Popular Tags |