1 15 package hivemind.test.rules; 16 17 import hivemind.test.config.impl.Datum; 18 19 import java.util.List ; 20 import java.util.Map ; 21 22 import org.apache.hivemind.Registry; 23 import org.apache.hivemind.internal.Module; 24 import org.apache.hivemind.schema.rules.ConfigurationTranslator; 25 import org.apache.hivemind.xml.XmlTestCase; 26 27 32 public class TestConfigurationTranslator extends XmlTestCase 33 { 34 35 public void testNull() 36 { 37 Module m = (Module) newMock(Module.class); 38 39 replayControls(); 40 ConfigurationTranslator t = new ConfigurationTranslator(); 41 42 assertNull(t.translate(m, null, null, null)); 43 44 verifyControls(); 45 } 46 47 public void testConfigurationTranslator() throws Exception 48 { 49 Registry r = buildFrameworkRegistry("ConfigurationTranslator.xml"); 50 51 DatumHolder h = (DatumHolder) r.getService( 52 "hivemind.test.rules.ExtensionPointTranslator", 53 DatumHolder.class); 54 List l1 = h.getDatums(); 55 List l2 = (List ) r.getConfiguration("hivemind.test.rules.EP"); 56 57 assertSame(l2, l1); 58 } 59 60 public void testFailure() throws Exception 61 { 62 Registry r = buildFrameworkRegistry("ConfigurationTranslator.xml"); 63 64 interceptLogging("hivemind.test.rules"); 65 66 DatumHolder h = (DatumHolder) r 67 .getService("hivemind.test.rules.Failure", DatumHolder.class); 68 69 71 h.getDatums(); 72 73 assertLoggedMessagePattern("Configuration point hivemind\\.test\\.rules\\.missing does not exist\\."); 74 75 assertNull(h.getDatums()); 76 } 77 78 public void testMappedConfigurationTranslator() throws Exception 79 { 80 Registry r = buildFrameworkRegistry("ConfigurationTranslator.xml"); 81 82 MappedDatumHolder h = (MappedDatumHolder) r.getService( 83 "hivemind.test.rules.MappedExtensionPointTranslator", 84 MappedDatumHolder.class); 85 Map m1 = h.getDatums(); 86 87 assertEquals(2, m1.size()); 88 assertEquals("value1", ((Datum) m1.get("key1")).getValue()); 89 assertEquals("value2", ((Datum) m1.get("key2")).getValue()); 90 } 91 } | Popular Tags |