KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > inversoft > config > test > TestConfigBuilder


1 /*
2  * Copyright (c) 2003, Inversoft
3  *
4  * This software is distribuable under the GNU Lesser General Public License.
5  * For more information visit gnu.org.
6  */

7 package com.inversoft.config.test;
8
9
10 import java.util.Map JavaDoc;
11
12 import junit.framework.Assert;
13
14 import org.jdom.Document;
15
16 import com.inversoft.config.ConfigBuilder;
17 import com.inversoft.config.ConfigRegistry;
18 import com.inversoft.config.ConfigurationException;
19
20
21 /**
22  * <p>
23  * This class is a test implementation of the config builder
24  * </p>
25  *
26  * @author Brian Pontarelli
27  * @since
28  * @version
29  */

30 public class TestConfigBuilder implements ConfigBuilder {
31
32     public static ConfigBuilder INSTANCE = new TestConfigBuilder();
33     public static boolean built = false;
34     public static boolean rebuilt = false;
35     public static boolean commited = false;
36
37
38     /**
39      */

40     public void build(Document document, ConfigRegistry registry)
41     throws ConfigurationException {
42         if (TestConfigFactory.createRegistry) {
43             Assert.assertTrue("Should be new registry",
44                 registry != TestConfigRegistry.INSTANCE);
45         } else if (TestConfigFactory.nullRegistry) {
46             Assert.assertTrue("Should be null registry", registry == null);
47         } else {
48             Assert.assertTrue("Should be instance registry",
49                 registry == TestConfigRegistry.INSTANCE);
50         }
51         built = true;
52     }
53
54     /**
55      */

56     public void rebuild(Document document, ConfigRegistry registry)
57     throws ConfigurationException {
58         if (TestConfigFactory.createRegistry) {
59             Assert.assertTrue("Should be new registry",
60                 registry != TestConfigRegistry.INSTANCE);
61         } else if (TestConfigFactory.nullRegistry) {
62             Assert.assertTrue("Should be null registry", registry == null);
63         } else {
64             Assert.assertTrue("Should be instance registry",
65                 registry == TestConfigRegistry.INSTANCE);
66         }
67         rebuilt = true;
68     }
69
70     /**
71      */

72     public void validate(ConfigRegistry registry, Map JavaDoc otherRegistries)
73     throws ConfigurationException {
74         //Assert.assertTrue("Should not contain the TestConfigRegistry",
75
//otherRegistries.get("test") == null);
76
if (TestConfigFactory.createRegistry) {
77             Assert.assertTrue("Should be new registry",
78                 registry != TestConfigRegistry.INSTANCE);
79         } else if (TestConfigFactory.nullRegistry) {
80             Assert.assertTrue("Should be null registry",
81                 registry == null);
82         } else {
83             Assert.assertTrue("Should be instance registry",
84                 registry == TestConfigRegistry.INSTANCE);
85         }
86     }
87
88     public void commit(ConfigRegistry registry, Map JavaDoc otherRegistries) {
89         commited = true;
90     }
91 }
92
Popular Tags