1 7 package com.inversoft.verge.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 TestConfigBuilder implements ConfigBuilder { 31 32 public static ConfigBuilder INSTANCE = new TestConfigBuilder(); 33 public static boolean built = false; 34 public static boolean validated = false; 35 public static boolean commited = false; 36 37 38 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 52 built = true; 53 } 54 55 57 public void rebuild(Document document, ConfigRegistry registry) 58 throws ConfigurationException { 59 if (TestConfigFactory.createRegistry) { 60 Assert.assertTrue("Should be new registry", 61 registry != TestConfigRegistry.INSTANCE); 62 } else if (TestConfigFactory.nullRegistry) { 63 Assert.assertTrue("Should be null registry", registry == null); 64 } else { 65 Assert.assertTrue("Should be instance registry", 66 registry == TestConfigRegistry.INSTANCE); 67 } 68 69 built = true; 70 } 71 72 74 public void validate(ConfigRegistry registry, Map registries) 75 throws ConfigurationException { 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", registry == null); 81 } else { 82 Assert.assertTrue("Should be instance registry", 83 registry == TestConfigRegistry.INSTANCE); 84 } 85 86 validated = true; 87 } 88 89 91 public void commit(ConfigRegistry registry, Map otherRegistries) { 92 commited = true; 93 } 94 } | Popular Tags |