1 15 package hivemind.test.rules; 16 17 import hivemind.test.FrameworkTestCase; 18 19 import java.util.Map ; 20 21 import org.apache.hivemind.ApplicationRuntimeException; 22 import org.apache.hivemind.schema.rules.RuleUtils; 23 24 29 public class TestConvertInitializer extends FrameworkTestCase 30 { 31 32 public void testEmpty() 33 { 34 Map m = RuleUtils.convertInitializer(null); 35 36 assertEquals(true, m.isEmpty()); 37 38 m = RuleUtils.convertInitializer(""); 39 40 assertEquals(true, m.isEmpty()); 41 } 42 43 public void testSimple() 44 { 45 Map m = RuleUtils.convertInitializer("alpha=bravo"); 46 47 assertEquals(1, m.size()); 48 assertEquals("bravo", m.get("alpha")); 49 } 50 51 public void testComplex() 52 { 53 Map m = RuleUtils.convertInitializer("alpha=bravo,fred=barney,gromit=greyhound"); 54 55 assertEquals(3, m.size()); 56 assertEquals("bravo", m.get("alpha")); 57 assertEquals("barney", m.get("fred")); 58 assertEquals("greyhound", m.get("gromit")); 59 } 60 61 public void testFailure() 62 { 63 try 64 { 65 RuleUtils.convertInitializer("bad"); 66 67 unreachable(); 68 } 69 catch (ApplicationRuntimeException ex) 70 { 71 assertExceptionSubstring( 72 ex, 73 "Initializer string ('bad') is not in proper format (key=value[,key=value]*)."); 74 } 75 } 76 } 77 | Popular Tags |