1 15 package hivemind.test.rules; 16 17 import org.apache.hivemind.SymbolExpander; 18 import org.apache.hivemind.impl.ElementImpl; 19 import org.apache.hivemind.internal.Module; 20 import org.apache.hivemind.schema.SchemaProcessor; 21 import org.apache.hivemind.schema.rules.NullTranslator; 22 import org.apache.hivemind.schema.rules.PushContentRule; 23 import org.apache.hivemind.test.HiveMindTestCase; 24 import org.easymock.MockControl; 25 26 public class TestPushContentRule extends HiveMindTestCase 27 { 28 public void testPushContentRule() 29 { 30 MockControl control = newControl(SchemaProcessor.class); 31 32 ElementImpl element = new ElementImpl(); 33 element.setElementName("myelement"); 34 35 element.setContent("${flintstone}"); 36 37 PushContentRule rule = new PushContentRule(); 38 39 SchemaProcessor mockProcessor = (SchemaProcessor) control.getMock(); 40 41 mockProcessor.getContentTranslator(); 42 control.setReturnValue(new NullTranslator()); 43 44 mockProcessor.getContributingModule(); 45 46 MockControl moduleControl = newControl(Module.class); 47 Module mockModule = (Module) moduleControl.getMock(); 48 49 control.setReturnValue(mockModule); 50 51 MockControl symbolExpanderControl = newControl(SymbolExpander.class); 52 SymbolExpander symbolExpander = (SymbolExpander) symbolExpanderControl.getMock(); 53 54 mockProcessor.getSymbolExpander(); 55 control.setReturnValue(symbolExpander); 56 57 symbolExpander.expandSymbols("${flintstone}", element.getLocation()); 58 symbolExpanderControl.setReturnValue("FLINTSTONE"); 59 60 mockProcessor.getContributingModule(); 61 control.setReturnValue(mockModule); 62 63 mockProcessor.push("FLINTSTONE"); 64 mockProcessor.pop(); 65 66 control.setReturnValue("FLINTSTONE"); 67 68 replayControls(); 69 70 rule.begin(mockProcessor, element); 71 rule.end(mockProcessor, element); 72 73 verifyControls(); 74 } 75 } 76 | Popular Tags |