@Test
public void submittedConferenceShouldBeSaved() throws Exception
{
JSFSession jsfSession = new JSFSession("/submit.jsf");
JSFServerSession server = jsfSession.getJSFServerSession();
assertEquals("/submit.xhtml", server.getCurrentViewID());
assertEquals(null, server.getManagedBeanValue("#{conference.title}"));
assertEquals(null, server.getManagedBeanValue("#{conference.startDate}"));
assertEquals(null, server.getManagedBeanValue("#{conference.endDate}"));
assertEquals(null, server.getManagedBeanValue("#{conference.location}"));
assertEquals(null, server.getManagedBeanValue("#{conference.topic}"));
JSFClientSession client = jsfSession.getJSFClientSession();
if (printRenderedOutput)
{
System.out.println("GET /submit.jsf HTTP/1.1\n\n" + client.getPageAsText());
}
client.setValue("conference:title", "Devoxx");
client.setValue("conference:startDate", "2010-11-15");
client.setValue("conference:endDate", "2010-11-19");
client.setValue("conference:location", "Metropolis, Antwerp, Belgium");
client.setValue("conference:topic", "Java");
client.click("conference:submit");
assertEquals("/submission.xhtml", server.getCurrentViewID());
@SuppressWarnings("unchecked")
List<Conference> conferences = (List<Conference>) server.getManagedBeanValue("#{conferences}");
assertNotNull(conferences);
assertEquals(1, conferences.size());
Conference conference = conferences.get(0);
assertEquals("Devoxx", conference.getTitle());
assertEquals(buildDate(2010, 11, 15).toString(), conference.getStartDate().toString());