KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > sun > share > PropertiesUtilTest


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 /*
20  * PropertiesUtilTest.java
21  * JUnit based test
22  *
23  * Created on March 17, 2004, 4:14 PM
24  */

25
26 package org.netbeans.modules.j2ee.sun.share;
27
28 import java.util.Properties JavaDoc;
29 import junit.framework.*;
30
31 /**
32  *
33  * @author vkraemer
34  */

35 public class PropertiesUtilTest extends TestCase {
36
37     public PropertiesUtilTest(java.lang.String JavaDoc testName) {
38         super(testName);
39     }
40
41     public void testSetArrayPropertyValue() {
42         Properties JavaDoc p = new Properties JavaDoc();
43         PropertiesUtil.setArrayPropertyValue(p, "a.", null);
44         assertNull(p.getProperty("a.0"));
45         PropertiesUtil.setArrayPropertyValue(p, "a.", new String JavaDoc[] { "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     /** Test of getArrayPropertyValue method, of class org.netbeans.modules.j2ee.sun.share.PropertiesUtil. */
56     public void testGetArrayPropertyValue() {
57         Properties JavaDoc p = new Properties JavaDoc();
58         
59         String JavaDoc[] 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     // Add test methods here, they have to start with 'test' name.
82
// for example:
83
// public void testHello() {}
84

85     
86 }
87
Popular Tags