1 15 package hivemind.test.rules; 16 17 import hivemind.test.FrameworkTestCase; 18 19 import org.apache.hivemind.impl.ModuleImpl; 20 import org.apache.hivemind.internal.Module; 21 import org.apache.hivemind.schema.SchemaProcessor; 22 import org.apache.hivemind.schema.rules.SetModuleRule; 23 import org.easymock.MockControl; 24 25 30 public class TestSetModule extends FrameworkTestCase 31 { 32 public static class Target 33 { 34 private Module _module; 35 36 public Module getModule() 37 { 38 return _module; 39 } 40 41 public void setModule(Module module) 42 { 43 _module = module; 44 } 45 46 } 47 48 public void testSetModuleRule() 49 { 50 MockControl control = newControl(SchemaProcessor.class); 51 SchemaProcessor p = (SchemaProcessor) control.getMock(); 52 53 Module m = new ModuleImpl(); 54 Target t = new Target(); 55 56 p.peek(); 57 control.setReturnValue(t); 58 59 p.getContributingModule(); 60 control.setReturnValue(m); 61 62 replayControls(); 63 64 SetModuleRule rule = new SetModuleRule(); 65 66 rule.setPropertyName("module"); 67 68 rule.begin(p, null); 69 70 assertSame(m, t.getModule()); 71 72 verifyControls(); 73 } 74 } 75 | Popular Tags |