use of org.apache.struts.action.ActionMessages in project sonarqube by SonarSource.
the class TestTagUtils method testActionMessages_getActionMessages_PageContext_String2.
// -- using ActionErrors
public void testActionMessages_getActionMessages_PageContext_String2() {
ActionMessages actionMessages = new ActionMessages();
actionMessages.add("prop", new ActionMessage("key.key"));
request.setAttribute("messages", actionMessages);
try {
ActionMessages messages = tagutils.getActionMessages(pageContext, "messages");
assertNotNull("messages should not be null", messages);
assertNotNull("messages prop should not be null", messages.get("prop"));
String val = null;
int i = 0;
for (Iterator iter = messages.get("prop"); iter.hasNext(); ) {
ActionMessage message = (ActionMessage) iter.next();
val = message.getKey();
i++;
}
assertEquals("only 1 message", i, 1);
assertEquals("messages prop should match", val, "key.key");
} catch (JspException e) {
fail(e.getMessage());
}
}
use of org.apache.struts.action.ActionMessages in project sonarqube by SonarSource.
the class TestTagUtils method testActionMessages_getActionMessages_PageContext_String6.
// ActionMessages (thrown Exception)
// TODO -- currently this does not hit the line for caught Exception
public void testActionMessages_getActionMessages_PageContext_String6() {
ActionMessages actionMessages = new ActionMessages();
actionMessages.add("prop", new ActionMessage("key.key"));
request.setAttribute("messages", actionMessages);
try {
ActionMessages messages = tagutils.getActionMessages(pageContext, "does-not-exist");
assertNotNull("messages should not be null", messages);
assertNotNull("messages prop should not be null", messages.get("prop"));
for (Iterator iter = messages.get("prop"); iter.hasNext(); ) {
fail("Should not have any messages for does-not-exist");
}
} catch (JspException e) {
fail(e.getMessage());
}
}
Aggregations