Source code: com/lutris/util/tests/ConfigFileTest.java
1 /*
2 * Enhydra Java Application Server Project
3 *
4 * The contents of this file are subject to the Enhydra Public License
5 * Version 1.1 (the "License"); you may not use this file except in
6 * compliance with the License. You may obtain a copy of the License on
7 * the Enhydra web site ( http://www.enhydra.org/ ).
8 *
9 * Software distributed under the License is distributed on an "AS IS"
10 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
11 * the License for the specific terms governing rights and limitations
12 * under the License.
13 *
14 * The Initial Developer of the Enhydra Application Server is Lutris
15 * Technologies, Inc. The Enhydra Application Server and portions created
16 * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
17 * All Rights Reserved.
18 *
19 * Contributor(s):
20 *
21 * $Id: ConfigFileTest.java,v 1.8.8.1 2000/10/19 17:58:53 jasona Exp $
22 */
23
24
25
26
27
28 package com.lutris.util.tests;
29
30 import com.lutris.util.*;
31
32 public class ConfigFileTest
33 {
34 public static void main(String args[])
35 throws ParseException, ConfigException, KeywordValueException
36 {
37 ConfigFile cf = new ConfigFile(System.in);
38 String values = "value1, \"This is value 2\"";
39 cf.addEntry("adding.a.test.entry", values, "# Test comment");
40 cf.addEntry("this.will.be.removed", values, "# Test comment");
41 cf.removeEntry("bogus");
42 cf.removeEntry("this.will.be.removed");
43 Config c = cf.getConfig();
44 c.set("config.test.entry", values);
45 c.set("remove.this", values);
46 c.remove("remove.this");
47 int i1 = c.getInt("int.one");
48 int[] i2 = c.getInts("int.two");
49 double d1 = c.getDouble("double.one");
50 double[] d2 = c.getDoubles("double.two");
51 String s1 = c.getString("string.one");
52 String[] s2 = c.getStrings("string.two");
53 System.out.println("# got i1 = " + i1);
54 System.out.println("# got i2 = " + i2[0] + ", " + i2[1]);
55 System.out.println("# got d1 = " + d1);
56 System.out.println("# got d2 = " + d2[0] + ", " + d2[1]);
57 System.out.println("# got s1 = " + s1);
58 System.out.println("# got s2 = " + s2[0] + ", " + s2[1]);
59 cf.write(System.out);
60 }
61 }
62