1 7 package com.inversoft.config.test; 8 9 10 import java.util.Map ; 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 30 public class TestConfigBuilder2 implements ConfigBuilder { 31 32 public static ConfigBuilder INSTANCE = new TestConfigBuilder2(); 33 public static boolean built = false; 34 public static boolean rebuilt = false; 35 public static boolean commited = false; 36 37 39 public void build(Document document, ConfigRegistry registry) 40 throws ConfigurationException { 41 if (TestConfigFactory2.createRegistry) { 42 Assert.assertTrue("Should be new registry", 43 registry != TestConfigRegistry2.INSTANCE); 44 } else if (TestConfigFactory2.nullRegistry) { 45 Assert.assertTrue("Should be null registry", 46 registry == null); 47 } else { 48 Assert.assertTrue("Should be instance registry", 49 registry == TestConfigRegistry2.INSTANCE); 50 } 51 built = true; 52 } 53 54 56 public void rebuild(Document document, ConfigRegistry registry) 57 throws ConfigurationException { 58 if (TestConfigFactory2.createRegistry) { 59 Assert.assertTrue("Should be new registry", 60 registry != TestConfigRegistry2.INSTANCE); 61 } else if (TestConfigFactory2.nullRegistry) { 62 Assert.assertTrue("Should be null registry", registry == null); 63 } else { 64 Assert.assertTrue("Should be instance registry", 65 registry == TestConfigRegistry2.INSTANCE); 66 } 67 rebuilt = true; 68 } 69 70 72 public void validate(ConfigRegistry registry, Map otherRegistries) 73 throws ConfigurationException { 74 Assert.assertTrue("Should not contain TestConfigRegistry", 75 otherRegistries.get("test2") == null); 76 if (TestConfigFactory2.createRegistry) { 77 Assert.assertTrue("Should be new registry", 78 registry != TestConfigRegistry2.INSTANCE); 79 } else if (TestConfigFactory2.nullRegistry) { 80 Assert.assertTrue("Should be null registry", registry == null); 81 } else { 82 Assert.assertTrue("Should be instance registry", 83 registry == TestConfigRegistry2.INSTANCE); 84 } 85 } 86 87 public void commit(ConfigRegistry registry, Map otherRegistries) { 88 commited = true; 89 } 90 } 91 | Popular Tags |