Search in sources :

Example 6 with MessageSourceResolvable

use of org.springframework.context.MessageSourceResolvable 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));
}
Also used : DefaultMessageSourceResolvable(org.springframework.context.support.DefaultMessageSourceResolvable) MessageSourceResolvable(org.springframework.context.MessageSourceResolvable) DefaultMessageSourceResolvable(org.springframework.context.support.DefaultMessageSourceResolvable) PageContext(javax.servlet.jsp.PageContext) List(java.util.List) RequestContext(org.springframework.web.servlet.support.RequestContext) Test(org.junit.Test)

Aggregations

MessageSourceResolvable (org.springframework.context.MessageSourceResolvable)6 Test (org.junit.Test)5 List (java.util.List)2 PageContext (javax.servlet.jsp.PageContext)2 DefaultMessageSourceResolvable (org.springframework.context.support.DefaultMessageSourceResolvable)2 RequestContext (org.springframework.web.servlet.support.RequestContext)2 Locale (java.util.Locale)1 MutablePropertyValues (org.springframework.beans.MutablePropertyValues)1 NoSuchMessageException (org.springframework.context.NoSuchMessageException)1