}
public void testBindStatusGetErrorMessagesAsString() throws JspException {
// one error (should not include delimiter)
PageContext pc = createPageContext();
Errors errors = new ServletRequestDataBinder(new TestBean(), "tb").getBindingResult();
errors.reject("code1", null, "message1");
pc.getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "tb", errors);
BindTag tag = new BindTag();
tag.setPageContext(pc);
tag.setPath("tb");
tag.doStartTag();
BindStatus status = (BindStatus) pc.getAttribute(BindTag.STATUS_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
assertEquals("Error messages String should be 'message1'",
status.getErrorMessagesAsString(","), "message1");
// two errors
pc = createPageContext();
errors = new ServletRequestDataBinder(new TestBean(), "tb").getBindingResult();
errors.reject("code1", null, "message1");
errors.reject("code1", null, "message2");
pc.getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "tb", errors);
tag = new BindTag();
tag.setPageContext(pc);
tag.setPath("tb");
tag.doStartTag();
status = (BindStatus) pc.getAttribute(BindTag.STATUS_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
assertEquals("Error messages String should be 'message1,message2'",
status.getErrorMessagesAsString(","), "message1,message2");
// no errors
pc = createPageContext();
errors = new ServletRequestDataBinder(new TestBean(), "tb").getBindingResult();
pc.getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "tb", errors);
tag = new BindTag();
tag.setPageContext(pc);
tag.setPath("tb");
tag.doStartTag();