1 7 package com.inversoft.verge.config.test; 8 9 10 import java.util.ResourceBundle ; 11 12 import com.inversoft.config.ConfigFactoryRegistry; 13 import com.inversoft.config.ConfigurationException; 14 import com.inversoft.junit.WebTestCase; 15 import com.inversoft.verge.config.VergeConfigConstants; 16 import com.inversoft.verge.config.VergeConfigMediator; 17 18 19 28 public class VergeConfigMediatorTest extends WebTestCase { 29 30 33 public VergeConfigMediatorTest(String name) { 34 super(name); 35 setLocal(true); 36 } 37 38 39 42 public void testMediate() { 43 44 getContext().setInitParameter(VergeConfigConstants.CONTEXT_PARAM, 45 "src/com/inversoft/verge/config/test/test.xml," + 46 "src/com/inversoft/verge/config/test/test2.xml"); 47 48 VergeConfigMediator mediator = new VergeConfigMediator(); 49 try { 50 ResourceBundle bundle = ResourceBundle.getBundle( 51 "com.inversoft.verge.config.test.ConfigBundle"); 52 ConfigFactoryRegistry.load(bundle); 53 54 TestConfigBuilder.built = false; 55 TestConfigBuilder.validated = false; 56 TestConfigBuilder.commited = false; 57 mediator.mediate(getContext()); 58 59 assertTrue(TestConfigBuilder.built); 60 assertTrue(TestConfigBuilder.validated); 61 assertTrue(TestConfigBuilder.commited); 62 } catch (ConfigurationException e) { 63 fail(e.toString()); 64 } 65 } 66 67 70 public void testMediateNone() { 71 72 VergeConfigMediator mediator = new VergeConfigMediator(); 73 try { 74 ResourceBundle bundle = ResourceBundle.getBundle( 75 "com.inversoft.verge.config.test.ConfigBundle"); 76 ConfigFactoryRegistry.load(bundle); 77 78 TestConfigBuilder.built = false; 79 TestConfigBuilder.validated = false; 80 TestConfigBuilder.commited = false; 81 mediator.mediate(getContext()); 82 83 assertFalse(TestConfigBuilder.built); 84 assertFalse(TestConfigBuilder.validated); 85 assertFalse(TestConfigBuilder.commited); 86 } catch (ConfigurationException e) { 87 fail(e.toString()); 88 } 89 } 90 91 94 public void testMediateFailure() { 95 96 getContext().setInitParameter(VergeConfigConstants.CONTEXT_PARAM, 97 "src/com/inversoft/verge/config/test/test.xml," + 98 "src/com/inversoft/verge/config/test/test2.xml," + 99 "src/com/inversoft/verge/config/test/test-bad.xml"); 100 101 VergeConfigMediator mediator = new VergeConfigMediator(); 102 try { 103 ResourceBundle bundle = ResourceBundle.getBundle( 104 "com.inversoft.verge.config.test.ConfigBundle"); 105 ConfigFactoryRegistry.load(bundle); 106 mediator.mediate(getContext()); 107 fail("Should have failed"); 108 } catch (ConfigurationException e) { 109 } 111 } 112 113 116 public void testMediateDefaultFactories() { 117 118 getContext().setInitParameter(VergeConfigConstants.CONTEXT_PARAM, 119 "src/com/inversoft/verge/config/test/default-forms.xml"); 120 121 VergeConfigMediator mediator = new VergeConfigMediator(); 122 try { 123 ResourceBundle bundle = ResourceBundle.getBundle( 124 "com.inversoft.verge.config.test.ConfigBundle"); 125 ConfigFactoryRegistry.load(bundle); 126 mediator.mediate(getContext()); 127 } catch (ConfigurationException e) { 128 fail("Should not have thrown exception! - " + e.toString()); 129 } 130 } 131 } | Popular Tags |