public void testHiddenValues()
{
MockControl writerc = newControl(IMarkupWriter.class);
IMarkupWriter writer = (IMarkupWriter) writerc.getMock();
NestedMarkupWriter nested = newNestedWriter();
MockControl cyclec = newControl(IRequestCycle.class);
IRequestCycle cycle = (IRequestCycle) cyclec.getMock();
MockForm form = new MockForm();
cycle.isRewound(form);
cyclec.setReturnValue(false);
replayControls();
final FormSupport fs = new FormSupportImpl(writer, cycle, form);
verifyControls();
form.setBody(new IRender()
{
public void render(IMarkupWriter writer, IRequestCycle cycle)
{
fs.addHiddenValue("hidden1", "value1");
fs.addHiddenValue("hidden2", "id2", "value2");
}
});
MockControl linkc = newControl(ILink.class);
ILink link = (ILink) linkc.getMock();
IRender render = (IRender) newMock(IRender.class);
link.getParameterNames();
linkc.setReturnValue(new String[]
{ "service" });
link.getParameterValues("service");
linkc.setReturnValue(new String[]
{ "fred" });
writer.getNestedWriter();
writerc.setReturnValue(nested);
link.getURL(null, false);
linkc.setReturnValue("/app");
writer.begin("form");
writer.attribute("method", "post");
writer.attribute("action", "/app");
writer.attribute("name", "myform");
render.render(writer, cycle);
writer.println();
trainHidden(writer, "formids", "");
trainHidden(writer, "service", "fred");
trainHidden(writer, "hidden1", "value1");
trainHidden(writer, "hidden2", "id2", "value2");
nested.close();
writer.end();
replayControls();