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