From 372b031e7b8bd1a5f063da2b6ed93736eb3ef271 Mon Sep 17 00:00:00 2001 From: mdb Date: Mon, 25 Nov 2002 22:23:21 +0000 Subject: [PATCH] Much more substantial testing for the fancy new inheritable properties. git-svn-id: https://samskivert.googlecode.com/svn/trunk@946 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- projects/samskivert/tests/build.xml | 1 + .../tests/rsrc/util/grandparent.properties | 7 +++ .../tests/rsrc/util/parent.properties | 12 +++++ .../tests/rsrc/util/test.properties | 10 ++-- .../com/samskivert/util/ConfigUtilTest.java | 54 ++++++++++++++++++- 5 files changed, 76 insertions(+), 8 deletions(-) create mode 100644 projects/samskivert/tests/rsrc/util/grandparent.properties create mode 100644 projects/samskivert/tests/rsrc/util/parent.properties diff --git a/projects/samskivert/tests/build.xml b/projects/samskivert/tests/build.xml index f56eed08..ead27356 100644 --- a/projects/samskivert/tests/build.xml +++ b/projects/samskivert/tests/build.xml @@ -22,6 +22,7 @@ + diff --git a/projects/samskivert/tests/rsrc/util/grandparent.properties b/projects/samskivert/tests/rsrc/util/grandparent.properties new file mode 100644 index 00000000..6955ec29 --- /dev/null +++ b/projects/samskivert/tests/rsrc/util/grandparent.properties @@ -0,0 +1,7 @@ +# +# $Id: grandparent.properties,v 1.1 2002/11/25 22:23:21 mdb Exp $ +# +# A test properties file + +sub.sub1 = 5 +sub.sub2 = whee! diff --git a/projects/samskivert/tests/rsrc/util/parent.properties b/projects/samskivert/tests/rsrc/util/parent.properties new file mode 100644 index 00000000..2a70a3a0 --- /dev/null +++ b/projects/samskivert/tests/rsrc/util/parent.properties @@ -0,0 +1,12 @@ +# +# $Id: parent.properties,v 1.1 2002/11/25 22:23:21 mdb Exp $ +# +# A test properties file + +_extends = rsrc/util/grandparent.properties + +prop1 = 13 +prop2 = nine +prop3 = 9, 8, 7, 6 +prop4 = one, two, three,, and a half, four +# prop5 = not defined diff --git a/projects/samskivert/tests/rsrc/util/test.properties b/projects/samskivert/tests/rsrc/util/test.properties index 755c97e5..8bf82990 100644 --- a/projects/samskivert/tests/rsrc/util/test.properties +++ b/projects/samskivert/tests/rsrc/util/test.properties @@ -1,13 +1,9 @@ # -# $Id: test.properties,v 1.2 2002/03/28 22:21:06 mdb Exp $ +# $Id: test.properties,v 1.3 2002/11/25 22:23:21 mdb Exp $ # # A test properties file +_extends = rsrc/util/parent.properties + prop1 = 25 prop2 = twenty five -prop3 = 9, 8, 7, 6 -prop4 = one, two, three,, and a half, four -# prop5 = not defined - -sub.sub1 = 5 -sub.sub2 = whee! diff --git a/projects/samskivert/tests/src/java/com/samskivert/util/ConfigUtilTest.java b/projects/samskivert/tests/src/java/com/samskivert/util/ConfigUtilTest.java index 27d37abf..a3d67d4c 100644 --- a/projects/samskivert/tests/src/java/com/samskivert/util/ConfigUtilTest.java +++ b/projects/samskivert/tests/src/java/com/samskivert/util/ConfigUtilTest.java @@ -1,5 +1,5 @@ // -// $Id: ConfigUtilTest.java,v 1.3 2002/04/11 04:07:42 mdb Exp $ +// $Id: ConfigUtilTest.java,v 1.4 2002/11/25 22:23:21 mdb Exp $ // // samskivert library - useful routines for java programs // Copyright (C) 2001 Michael Bayne @@ -27,6 +27,45 @@ import junit.framework.TestCase; import com.samskivert.Log; +/** + * Our test properties files: + * + *
+ * lib/test-c.jar:
+ * _package = testC
+ * _overrides = testAL, testBR
+ *
+ * three = testC - three
+ *
+ * lib/test-br.jar:
+ * _package = testBR
+ * _overrides = testAR
+ *
+ * two = testBR - two
+ * four = testBR - four
+ *
+ * lib/test-ar.jar:
+ * _package = testAR
+ * _overrides = test
+ *
+ * one = testAR - one
+ * two = testAR - two
+ * four = testAR - four
+ *
+ * lib/test-al.jar:
+ * _package = testAL
+ * _overrides = test
+ * 
+ * one = testAL - one
+ * 
+ * lib/test.jar:
+ * _package = test
+ *
+ * one = test - one
+ * two = test - two
+ * three = test - three
+ * 
+ */ public class ConfigUtilTest extends TestCase { public ConfigUtilTest () @@ -41,6 +80,10 @@ public class ConfigUtilTest extends TestCase Properties props = ConfigUtil.loadInheritedProperties(path); assertTrue("props valid", props.toString().equals(DUMP)); + path = "test/test.properties"; + props = ConfigUtil.loadInheritedProperties(path); + assertTrue("props valid", props.toString().equals(IDUMP)); + } catch (Exception e) { e.printStackTrace(System.err); } @@ -51,8 +94,17 @@ public class ConfigUtilTest extends TestCase return new ConfigUtilTest(); } + public static void main (String[] args) + { + ConfigUtilTest test = new ConfigUtilTest(); + test.runTest(); + } + protected static final String DUMP = "{prop4=one, two, three,, and a half, four, " + "prop3=9, 8, 7, 6, prop2=twenty five, prop1=25, " + "sub.sub2=whee!, sub.sub1=5}"; + + protected static final String IDUMP = "{two=testBR - two, " + + "one=testAR - one, three=testC - three, four=testBR - four}"; }