use of org.springframework.context.support.DefaultMessageSourceResolvable in project spring-framework by spring-projects.
the class MessageTagTests method messageTagWithMessageSourceResolvable.
@Test
public void messageTagWithMessageSourceResolvable() throws JspException {
PageContext pc = createPageContext();
final StringBuffer message = new StringBuffer();
MessageTag tag = new MessageTag() {
@Override
protected void writeMessage(String msg) {
message.append(msg);
}
};
tag.setPageContext(pc);
tag.setMessage(new DefaultMessageSourceResolvable("test"));
assertTrue("Correct doStartTag return value", tag.doStartTag() == Tag.EVAL_BODY_INCLUDE);
assertEquals("Correct doEndTag return value", Tag.EVAL_PAGE, tag.doEndTag());
assertEquals("Correct message", "test message", message.toString());
}
use of org.springframework.context.support.DefaultMessageSourceResolvable in project spring-framework by spring-projects.
the class ThemeTagTests method requestContext.
@Test
@SuppressWarnings("rawtypes")
public void requestContext() throws ServletException {
PageContext pc = createPageContext();
RequestContext rc = new RequestContext((HttpServletRequest) pc.getRequest());
assertEquals("theme test message", rc.getThemeMessage("themetest"));
assertEquals("theme test message", rc.getThemeMessage("themetest", (String[]) null));
assertEquals("theme test message", rc.getThemeMessage("themetest", "default"));
assertEquals("theme test message", rc.getThemeMessage("themetest", (Object[]) null, "default"));
assertEquals("theme test message arg1", rc.getThemeMessage("themetestArgs", new String[] { "arg1" }));
assertEquals("theme test message arg1", rc.getThemeMessage("themetestArgs", Arrays.asList(new String[] { "arg1" })));
assertEquals("default", rc.getThemeMessage("themetesta", "default"));
assertEquals("default", rc.getThemeMessage("themetesta", (List) null, "default"));
MessageSourceResolvable resolvable = new DefaultMessageSourceResolvable(new String[] { "themetest" });
assertEquals("theme test message", rc.getThemeMessage(resolvable));
}
use of org.springframework.context.support.DefaultMessageSourceResolvable in project spring-framework by spring-projects.
the class MessageTagTests method requestContext.
@Test
@SuppressWarnings("rawtypes")
public void requestContext() throws ServletException {
PageContext pc = createPageContext();
RequestContext rc = new RequestContext((HttpServletRequest) pc.getRequest(), pc.getServletContext());
assertEquals("test message", rc.getMessage("test"));
assertEquals("test message", rc.getMessage("test", (Object[]) null));
assertEquals("test message", rc.getMessage("test", "default"));
assertEquals("test message", rc.getMessage("test", (Object[]) null, "default"));
assertEquals("test arg1 message arg2", rc.getMessage("testArgs", new String[] { "arg1", "arg2" }, "default"));
assertEquals("test arg1 message arg2", rc.getMessage("testArgs", Arrays.asList(new String[] { "arg1", "arg2" }), "default"));
assertEquals("default", rc.getMessage("testa", "default"));
assertEquals("default", rc.getMessage("testa", (List) null, "default"));
MessageSourceResolvable resolvable = new DefaultMessageSourceResolvable(new String[] { "test" });
assertEquals("test message", rc.getMessage(resolvable));
}
Aggregations