// =====================================================================
// Set Expectations
// =====================================================================
WebRequestHeader header = new WebRequestHeader();
entityFactoryMock.expects.createHeader().returns(header);
HTTPMessageEntities entities = new SimpleHTTPMessageEntities();
entityFactoryMock.expects.createHTTPMessageEntities().returns(entities);
expectAddSimpleElementProcess(header);
contextMock.expects.getProperty(WebRequestHeader.class).returns(null);
contextMock.expects.setProperty(WebRequestHeader.class,
entities, false);
// =====================================================================
// Test Expectations
// =====================================================================
addAttribute("name", name);
addAttribute("value", value);
addAttribute("from", from);
DynamicElementRule rule = new HeaderRule(entityFactoryMock);
XMLProcess process = (XMLProcess) rule.startElement(dynamicProcessMock,
elementName, attributes);
dynamicProcessMock.expects.removeProcess(process);
rule.endElement(dynamicProcessMock, elementName, process);
assertNotNull(header);
if (name == null) {
assertEquals("Name value should match", from,
header.getName());
} else {
assertEquals("Name value should match", name,
header.getName());
}
assertEquals("Value value should match", value,
header.getValue());
assertEquals("From value should match", from,
header.getFrom());
}