IRequestCycle cycle = (IRequestCycle)newMock(IRequestCycle.class);
replay();
IMarkupWriter mw = new MarkupWriterImpl("text/html", writer, filter);
ResponseBuilder builder = new DefaultResponseBuilder(mw);
String bscript = "var e=4;";
String imageInit = "image initializations";
String preload = "preloadedvarname";
verify();
replay();
builder.beginBodyScript(mw, cycle);
assertOutput("<script type=\"text/javascript\"><!--"+LINE_SEPARATOR);
builder.writeImageInitializations(mw, imageInit, preload, cycle);
assertOutput(LINE_SEPARATOR
+ "dojo.addOnLoad(function(e) {\n"
+ preload + " = [];\n"
+ "if (document.images)\n"
+ "{\n" + imageInit + "}\n"
+ "});");
builder.writeBodyScript(mw, bscript, cycle);
assertOutput(bscript);
builder.endBodyScript(mw, cycle);
assertOutput(LINE_SEPARATOR + "// --></script>");
verify();
}