Package org.springframework.context

Examples of org.springframework.context.MessageSource


   * Confirms that a {@link TitleConfigurable} object will have its title set
   * correctly, as retrieved from a MessageSource using the key
   * 'beanName.title'.
   */
  public void testConfigureTitleConfigurable() {
    MessageSource messageSource = (MessageSource) EasyMock.createMock(MessageSource.class);

    DefaultApplicationObjectConfigurer configurer = new DefaultApplicationObjectConfigurer(messageSource);

    String objectName = "bogusTitleable";
    String messageCode = objectName + ".title";
    String message = "bogusTitle";

    EasyMock.expect(messageSource.getMessage(messageCode, null, Locale.getDefault())).andReturn(message);

    TitleConfigurable configurable = (TitleConfigurable) EasyMock.createMock(TitleConfigurable.class);
    configurable.setTitle(message);

    EasyMock.replay(messageSource);
View Full Code Here


    EasyMock.verify(messageSource);
    EasyMock.verify(configurable);
  }

  public void testConfigureTitleConfigurableWithNoTitleFound() {
    MessageSource messageSource = (MessageSource) EasyMock.createMock(MessageSource.class);

    DefaultApplicationObjectConfigurer configurer = new DefaultApplicationObjectConfigurer(messageSource);

    String objectName = "bogusTitleable";
    String messageCode = objectName + ".title";

    EasyMock.expect(messageSource.getMessage(messageCode, null, Locale.getDefault())).andReturn(null);

    TitleConfigurable configurable = (TitleConfigurable) EasyMock.createMock(TitleConfigurable.class);

    EasyMock.replay(messageSource);
    EasyMock.replay(configurable);
View Full Code Here

   * Confirms that a {@link DescriptionConfigurable} object will have its
   * description and caption set correctly, as retrieved from a MessageSource
   * using the key 'beanName.description' and 'beanName.caption' respectively.
   */
  public void testDescriptionConfigurable() {
    MessageSource messageSource = (MessageSource) EasyMock.createMock(MessageSource.class);

    DefaultApplicationObjectConfigurer configurer = new DefaultApplicationObjectConfigurer(messageSource);

    String objectName = "bogusDescriptionConfigurable";
    String descriptionCode = objectName + ".description";
    String captionCode = objectName + ".caption";
    String description = "bogusDescription";
    String caption = "bogusCaption";

    EasyMock.expect(messageSource.getMessage(descriptionCode, null, Locale.getDefault())).andReturn(description);
    EasyMock.expect(messageSource.getMessage(captionCode, null, Locale.getDefault())).andReturn(caption);

    DescriptionConfigurable configurable = (DescriptionConfigurable) EasyMock
        .createMock(DescriptionConfigurable.class);
    configurable.setDescription(description);
    configurable.setCaption(caption);
View Full Code Here

    EasyMock.verify(messageSource);
    EasyMock.verify(configurable);
  }

  public void testDescriptionConfigurableWithNoDescriptionFound() {
    MessageSource messageSource = (MessageSource) EasyMock.createMock(MessageSource.class);

    DefaultApplicationObjectConfigurer configurer = new DefaultApplicationObjectConfigurer(messageSource);

    String objectName = "bogusDescriptionConfigurable";
    String descriptionCode = objectName + ".description";
    String captionCode = objectName + ".caption";

    EasyMock.expect(messageSource.getMessage(descriptionCode, null, Locale.getDefault())).andReturn(null);
    EasyMock.expect(messageSource.getMessage(captionCode, null, Locale.getDefault())).andReturn(null);

    DescriptionConfigurable configurable = (DescriptionConfigurable) EasyMock
        .createMock(DescriptionConfigurable.class);

    EasyMock.replay(messageSource);
View Full Code Here

   * Confirms that a {@link LabelConfigurable} object will have its label set
   * correctly, as retrieved from a MessageSource using the key
   * 'beanName.label'.
   */
  public void testLabelConfigurable() {
    MessageSource messageSource = (MessageSource) EasyMock.createMock(MessageSource.class);

    DefaultApplicationObjectConfigurer configurer = new DefaultApplicationObjectConfigurer(messageSource);

    String objectName = "bogusLabelable";
    String messageCode = objectName + ".label";
    String message = "bogusLabelInfo";
    LabelInfo expectedLabelInfo = LabelInfo.valueOf(message);

    EasyMock.expect(messageSource.getMessage(messageCode, null, Locale.getDefault())).andReturn(message);

    LabelConfigurable configurable = (LabelConfigurable) EasyMock.createMock(LabelConfigurable.class);
    configurable.setLabelInfo(expectedLabelInfo);

    EasyMock.replay(messageSource);
View Full Code Here

    EasyMock.verify(configurable);

  }

  public void testLabelConfigurableWithNoLabelFound() {
    MessageSource messageSource = (MessageSource) EasyMock.createMock(MessageSource.class);

    DefaultApplicationObjectConfigurer configurer = new DefaultApplicationObjectConfigurer(messageSource);

    String objectName = "bogusLabelable";
    String messageCode = objectName + ".label";

    EasyMock.expect(messageSource.getMessage(messageCode, null, Locale.getDefault())).andReturn(null);

    LabelConfigurable configurable = (LabelConfigurable) EasyMock.createMock(LabelConfigurable.class);

    EasyMock.replay(messageSource);
    EasyMock.replay(configurable);
View Full Code Here

   * Confirms that a {@link CommandLabelConfigurable} object will have its
   * label set correctly, as retrieved from a MessageSource using the key
   * 'beanName.label'.
   */
  public void testCommandLabelConfigurable() {
    MessageSource messageSource = (MessageSource) EasyMock.createMock(MessageSource.class);

    DefaultApplicationObjectConfigurer configurer = new DefaultApplicationObjectConfigurer(messageSource);

    String objectName = "bogusLabelable";
    String messageCode = objectName + ".label";
    String message = "bogusLabelInfo";
    CommandButtonLabelInfo expectedLabelInfo = CommandButtonLabelInfo.valueOf(message);

    EasyMock.expect(messageSource.getMessage(messageCode, null, Locale.getDefault())).andReturn(message);

    CommandLabelConfigurable configurable = (CommandLabelConfigurable) EasyMock
        .createMock(CommandLabelConfigurable.class);
    configurable.setLabelInfo(expectedLabelInfo);

View Full Code Here

    EasyMock.verify(configurable);

  }

  public void testCommandLabelConfigurableWithNoLabelFound() {
    MessageSource messageSource = (MessageSource) EasyMock.createMock(MessageSource.class);

    DefaultApplicationObjectConfigurer configurer = new DefaultApplicationObjectConfigurer(messageSource);

    String objectName = "bogusLabelable";
    String messageCode = objectName + ".label";

    EasyMock.expect(messageSource.getMessage(messageCode, null, Locale.getDefault())).andReturn(null);

    CommandLabelConfigurable configurable = (CommandLabelConfigurable) EasyMock
        .createMock(CommandLabelConfigurable.class);

    EasyMock.replay(messageSource);
View Full Code Here

  private String getEditIconText() {
    return getMsgText("shuttleList.editText", "Edit...");
  }

  private String getMsgText(String key, String defaultMsg) {
    final MessageSource messageSource = (MessageSource) ApplicationServicesLocator.services().getService(
        MessageSource.class);
    String text = null;

    if (getFormId() != null) {
      if (getProperty() != null) {
        text = messageSource.getMessage(getFormId() + "." + getProperty() + "." + key, null, null, null);
      }
     
      if (text == null) {
        text = messageSource.getMessage(getFormId() + "." + key, null, null, null);
      }
    }

    if (text == null) {
      text = messageSource.getMessage(key, null, defaultMsg, null);
    }

    return text;
  }
View Full Code Here

  private String getMessage(String key){
    return getMessage(key, new Object[]{});
  }
 
  private String getMessage(String key, Object[] values){
    MessageSource messageSource = (MessageSource)ApplicationServicesLocator.services().getService(MessageSource.class);
    return messageSource.getMessage(key, values, Locale.getDefault());
  }
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.