}
public void testAddPoll() throws Exception {
HttpResponse r = c.get("admin/javango.contrib.admin.tests.Poll/add/");
assertTrue(r instanceof FreemarkerResponse);
FreemarkerResponse fr = (FreemarkerResponse)r;
Writer writer = new CharArrayWriter();
fr.renderToWriter(writer);
System.out.println(writer.toString());
String expected =
"<tr><th><label for='id_pubDate'>Pub Date</label></th><td><input id=\"id_pubDate\" type=\"text\" name=\"pubDate\" /></td></tr>\n" +
"<tr><th><label for='id_question'>Question</label></th><td><input maxlength=\"255\" id=\"id_question\" type=\"text\" name=\"question\" /></td></tr>\n";
// TODO This is not 100% correct as the form could possibly be in this order even without the fieldset
assertTrue(writer.toString().contains(expected));
Map<String, String[]> params = new HashMap<String, String[]>();
params.put("question", new String[] {"Do you like cheese?"});
params.put("pubDate", new String[] {"01/02/2008"});
r = c.post("admin/javango.contrib.admin.tests.Poll/add/", params);
assertEquals(HttpResponseRedirect.class, r.getClass());
r = c.get("admin/javango.contrib.admin.tests.Poll/");
assertTrue(r instanceof FreemarkerResponse);
fr = (FreemarkerResponse)r;
writer = new CharArrayWriter();
fr.renderToWriter(writer);
assertTrue(writer.toString().contains("Do you like cheese?"));
}