1 19 25 26 package org.netbeans.modules.j2ee.sun.share; 27 28 import java.util.Properties ; 29 import junit.framework.*; 30 31 35 public class PropertiesUtilTest extends TestCase { 36 37 public PropertiesUtilTest(java.lang.String testName) { 38 super(testName); 39 } 40 41 public void testSetArrayPropertyValue() { 42 Properties p = new Properties (); 43 PropertiesUtil.setArrayPropertyValue(p, "a.", null); 44 assertNull(p.getProperty("a.0")); 45 PropertiesUtil.setArrayPropertyValue(p, "a.", new String [] { "a", null, "b", "c"} ); 46 assertNull(p.getProperty("a.3")); 47 assertEquals(p.getProperty("a.0"),"a"); 48 assertEquals(p.getProperty("a.1"),"b"); 49 assertEquals(p.getProperty("a.2"),"c"); 50 } 51 52 53 54 55 56 public void testGetArrayPropertyValue() { 57 Properties p = new Properties (); 58 59 String [] one = PropertiesUtil.getArrayPropertyValue(p, "a."); 60 61 assertNotNull(one); 62 assertTrue(one.length == 0); 63 64 p.setProperty("a.1", "bad"); 65 66 one = PropertiesUtil.getArrayPropertyValue(p, "a."); 67 68 assertNotNull(one); 69 assertTrue(one.length == 0); 70 71 p.setProperty("a.0", "good"); 72 73 one = PropertiesUtil.getArrayPropertyValue(p, "a."); 74 75 assertNotNull(one); 76 assertTrue(one.length == 2); 77 78 p.setProperty("a.0", "good"); 79 } 80 81 85 86 } 87 | Popular Tags |