Seam Test problem (jsf required attribute)
maxseam Jul 28, 2010 6:06 PMhi!
I have problems using Seam framework for integration tests. My current problem is, that i want to test the jsf required
attribute. here is my test case:
@Test
public void testCreateOrganisation() throws Exception {
String id = login(ADMIN_LOGIN);
id = new FacesRequest(ORG_VIEW, id) {
@Override
protected void invokeApplication() throws Exception {
assertEquals(
invokeAction("#{organisations.createOrganisation}"),
JSFNavigationConstants.ORGANISATION_CREATE);
}
}.run();
new FacesRequest(ORG_CREATE_VIEW, id) {
@Override
protected void processValidations() throws Exception {
validateValue("#{selectedOrganisation.name}", "");
assertTrue(isValidationFailure());
}
@Override
protected void renderResponse() throws Exception {
FacesContext fc = FacesContext.getCurrentInstance();
assertEquals(fc.getMaximumSeverity(),
FacesMessage.SEVERITY_ERROR);
boolean contains = false;
Iterator<FacesMessage> fms = fc.getMessages();
while (fms.hasNext()) {
FacesMessage fm = fms.next();
if (fm.getDetail().equals("Feld muss ausgefüllt werden")) {
contains = true;
}
}
assertTrue(contains);
assertTrue(Manager.instance().isLongRunningConversation());
}
}.run();
}At the beginning there is some login procedure which works fine. Next I want to make a FacesRequest to the organisation
view, which is like a crud interface. In invokeApplication method i want to navigate to the create interface of organisation. Till now all is fine.
Next I want to test, if the jsf required attribute is set. Therefore i validate the empty string for the organisation name. Now i expect isValidationFailure() to return true since the required
attribute is indeed set. But it returns false. That's the point, where i don't know why and what to try next. It's nearly the same test like in the booking example:
new FacesRequest("/book.xhtml", id) {
@Override
protected void processValidations() throws Exception
{
validateValue("#{booking.creditCardName}", "");
assert isValidationFailure();
}
@Override
protected void renderResponse()
{
Iterator messages = FacesContext.getCurrentInstance().getMessages();
assert messages.hasNext();
assert ( (FacesMessage) messages.next() ).getSummary().equals("Credit card name is required");
assert !messages.hasNext();
assert Manager.instance().isLongRunningConversation();
}
@Override
protected void afterRequest()
{
assert !isInvokeApplicationBegun();
}
}.run();I didn't try it, but i believe it works ;) so the big question is, why there occurs a validtion failure in the booking example, but not in my test?
Thanks!
regards,
max.