Package org.springframework.context

Examples of org.springframework.context.MessageSource


    assertThat(value.toString(), is(equalTo("message")));
  }

  @Test
  public void shouldUsePrefixCodesOnGetValueToString() throws Exception {
    MessageSource messageSource = mock(MessageSource.class);
    MessageSourceMap map = new TestMessageSourceMap(messageSource, new String[] { "a.", "b.", "c." });
    Object value = map.get("x");
    given(messageSource.getMessage(msr("a.x", "b.x", "c.x"), nullLocale())).willReturn("message");
    assertThat(value.toString(), is(equalTo("message")));
  }
View Full Code Here


    assertThat(Arrays.asList(value.getArguments()), is(equalTo(Arrays.<Object> asList("y", "z"))));
  }

  @Test
  public void shouldHaveToString() throws Exception {
    MessageSource messageSource = mock(MessageSource.class, "messageSource");
    MessageSourceMap map = new TestMessageSourceMap(messageSource, new String[] { "a.", "b.", "c." });
    assertThat(map.toString(),
        containsString("messageSource = messageSource, prefixCodes = array<String>['a.', 'b.', 'c.']]"));
  }
View Full Code Here

  }

  @Test
  public void shouldUseDefinedSource() throws Exception {
    given(this.viewRoot.getViewId()).willReturn("/WEB-INF/pages/example/page.xhtml");
    MessageSource source = mock(MessageSource.class);
    this.uiMessageSource.setSource(source);
    MessageSourceMap messageSourceMap = callSetParent();
    messageSourceMap.get("test").toString();
    verify(source).getMessage((MessageSourceResolvable) any(), (Locale) any());
    verify(this.applicationContext, never()).getMessage((MessageSourceResolvable) any(), (Locale) any());
View Full Code Here

        .matches(".*after [0-9]* ms.*"));
  }

  @Test
  public void testGetEstimatedPercentCompleteMessageSourceResolvable() {
    MessageSource messageSource = new StaticMessageSource();
    String message = messageSource.getMessage(progress
        .getEstimatedPercentCompleteMessage(), Locale.UK);
    assertTrue("Wrong message: [" + message + "]", message
        .contains("50% complete"));
    assertTrue("Wrong message: [" + message + "]", message
        .matches(".*after [0-9]* ms.*"));
 
View Full Code Here

   *
   * @param servletContext {@link ServletContext} instance
   * @return {@link MessageSource} instance
   */
  public static MessageSource getMessageSource(ServletContext servletContext) {
    MessageSource msgSource = (MessageSource) servletContext.getAttribute(MESSAGESOURCE_SERVLETCONTEXT_KEY);
    if (msgSource == null) {
      throw new HDIVException("MessageSource has not been initialized in servlet context");
    }
    return msgSource;
  }
View Full Code Here

    public SpringVaadinSystemMessagesProvider(ApplicationContext applicationContext, String systemMessagesBeanName)
    {
        if (systemMessagesBeanName.equals(DEFAULT_IMPLEMENTATION))
        {
            MessageSource messageSource = applicationContext.getBean(MessageSource.class);
            systemMessagesBean = new DefaultSpringSystemMessagesProvider();
            ((DefaultSpringSystemMessagesProvider)systemMessagesBean).setMessageSource(messageSource);
            logger.debug("use default systemMessagesBean");
        }
        else
View Full Code Here

        appContext = context;
    }

    public static MessageSourceAccessor getMessageSource() {
        if (messages == null) {
            MessageSource drms = (MessageSource) appContext.getBean("messageSource");
            messages = new MessageSourceAccessor(drms);
        }
        return messages;
    }
View Full Code Here

     * Content to be added to the web console header.
     * @param path Current JSP path e.g. /WEB-INF/jsp/console/home.jsp
     * @return
     */
    public String getHeader(String path) {
        MessageSource messageSource = (MessageSource)AppUtil.getApplicationContext().getBean("messageSource");
        Locale locale = new Locale(AppUtil.getAppLocale());
        String header = messageSource.getMessage("console.header.top.subtitle", null, "", locale);
        return header;
    }
View Full Code Here

     * Content to be added to the web console header.
     * @param path Current JSP path e.g. /WEB-INF/jsp/console/home.jsp
     * @return
     */
    public String getLogo(String path) {
        MessageSource messageSource = (MessageSource)AppUtil.getApplicationContext().getBean("messageSource");
        Locale locale = new Locale(AppUtil.getAppLocale());
        String header = messageSource.getMessage("console.header.top.logo", null, "", locale);
        return header;
    }
View Full Code Here

     * Content to be added to the web console footer.
     * @param path Current JSP path e.g. /WEB-INF/jsp/console/home.jsp
     * @return
     */
    public String getFooter(String path) {
        MessageSource messageSource = (MessageSource)AppUtil.getApplicationContext().getBean("messageSource");
        Locale locale = new Locale(AppUtil.getAppLocale());
        String revision = messageSource.getMessage("console.footer.label.revision", null, "", locale);
        String footer = "&copy; Joget Workflow - Joget Inc. All Rights Reserved. " + revision;
        return footer;
    }
View Full Code Here

TOP

Related Classes of org.springframework.context.MessageSource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.