Examples of MessageSource


Examples of org.springframework.context.MessageSource

    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

Examples of org.springframework.context.MessageSource

   * 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

Examples of org.springframework.context.MessageSource

    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

Examples of org.springframework.context.MessageSource

  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

Examples of org.springframework.context.MessageSource

  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

Examples of org.springframework.context.MessageSource

  protected abstract String getFormComponentLabel();
  protected abstract JComponent getFormComponentControl();
  protected abstract void applyChanges();
 
  protected String getMessage(String key){
    MessageSource messageSource = (MessageSource)ApplicationServicesLocator.services().getService(MessageSource.class);
    return messageSource.getMessage(key, new Object[]{}, Locale.getDefault());
  }
View Full Code Here

Examples of org.springframework.context.MessageSource

    public void testRegisteredServiceIsReturned() {
        ValueChangeDetector vcd = new DefaultValueChangeDetector();
        getApplicationServices().setValueChangeDetector(vcd);
        assertSame("Expected same object back", vcd, getApplicationServices().getService(ValueChangeDetector.class));

        MessageSource msrc = new StaticMessageSource();
        getApplicationServices().setMessageSource(msrc);
        assertSame("Expected same object back", msrc, getApplicationServices().getService(MessageSource.class));
    }
View Full Code Here

Examples of org.springframework.context.MessageSource

        }
    }

    public void testSetRegistryEntries() {
        ValueChangeDetector vcd = new DefaultValueChangeDetector();
        MessageSource msrc = new StaticMessageSource();

        HashMap entries = new HashMap();
        entries.put("org.springframework.binding.value.ValueChangeDetector", vcd);
        entries.put("org.springframework.context.MessageSource", msrc);
View Full Code Here

Examples of org.springframework.context.MessageSource

        .equals("This is a default msg if not found in theme cat."));
  }

  public void testThemeSourceNesting() throws NoSuchMessageException {
    String overriddenMsg = getThemeMessage("theme.example2", null, null, Locale.UK);
    MessageSource ms = ((ThemeSource) root).getTheme(AbstractThemeResolver.ORIGINAL_DEFAULT_THEME_NAME).getMessageSource();
    String originalMsg = ms.getMessage("theme.example2", null, Locale.UK);
    assertTrue("correct overridden msg", "test-message2".equals(overriddenMsg));
    assertTrue("correct original msg", "message2".equals(originalMsg));
  }
View Full Code Here

Examples of org.springframework.context.MessageSource

  public void testThemeSourceNestingWithParentDefault() throws NoSuchMessageException {
    StaticWebApplicationContext leaf = new StaticWebApplicationContext();
    leaf.setParent(getApplicationContext());
    leaf.refresh();
    assertNotNull("theme still found", leaf.getTheme("theme"));
    MessageSource ms = leaf.getTheme("theme").getMessageSource();
    String msg = ms.getMessage("theme.example2", null, null, Locale.UK);
    assertEquals("correct overridden msg", "test-message2", msg);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.