Examples of StaticMessageSource


Examples of org.springframework.context.support.StaticMessageSource

  private StaticMessageSource source;

  @Before
  public void setup() {
    source = new StaticMessageSource();
    source.addMessage("category.investment.sell", new Locale("es", "ES", ""), "Sell");
  }
View Full Code Here

Examples of org.springframework.context.support.StaticMessageSource

@Configuration
public class CustomMessageSourceConfiguration {

  @Bean
  public MessageSource exampleMessageSource() {
    StaticMessageSource source = new StaticMessageSource();
    source.addMessage("pages.message.definedsource.hello", Locale.getDefault(), "Defined Source Hello");
    return source;
  }
View Full Code Here

Examples of org.springframework.context.support.StaticMessageSource

  private DefaultObjectMessageSource messageSource;

  @Before
  public void setup() {
    this.parent = new StaticMessageSource();
    this.messageSource = new DefaultObjectMessageSource();
    this.messageSource.setParentMessageSource(this.parent);
    addMessageToParent(INNER + "Mapped", "mapped");
    addMessageToParent(INNER + "MappedArguments", "a {name} b {numberEnum} c {boolean}");
    addMessageToParent(INNER + "NumberEnum.ONE", "1");
View Full Code Here

Examples of org.springframework.context.support.StaticMessageSource

    new TestMessageSourceMap(null, null);
  }

  @Test
  public void shouldThrowUnsupportedOperationExceptions() throws Exception {
    MessageSourceMap map = new TestMessageSourceMap(new StaticMessageSource(), null);
    this.thrown.expect(UnsupportedOperationException.class);
    map.size();
  }
View Full Code Here

Examples of org.springframework.context.support.StaticMessageSource

  }

  @Test
  @SuppressWarnings("unchecked")
  public void shouldThrowNestedUnsupportedOperationExceptions() throws Exception {
    MessageSourceMap map = new TestMessageSourceMap(new StaticMessageSource(), null);
    Object value = map.get("x", "y");
    this.thrown.expect(UnsupportedOperationException.class);
    ((Map<Object, Object>) value).size();
  }
View Full Code Here

Examples of org.springframework.context.support.StaticMessageSource

    ((Map<Object, Object>) value).size();
  }

  @Test
  public void shouldAllowNullKeys() throws Exception {
    MessageSourceMap map = new TestMessageSourceMap(new StaticMessageSource(), null);
    Object actual = map.get((Object) null);
    assertThat(actual, is(nullValue()));
  }
View Full Code Here

Examples of org.springframework.context.support.StaticMessageSource

    assertThat(actual, is(nullValue()));
  }

  @Test
  public void shouldGetValue() throws Exception {
    MessageSourceMap map = new TestMessageSourceMap(new StaticMessageSource(), null);
    MessageSourceResolvable value = (MessageSourceResolvable) map.get("x");
    assertThat(value.getCodes()[0], is(equalTo("x")));
  }
View Full Code Here

Examples of org.springframework.context.support.StaticMessageSource

    assertThat(value.getCodes()[0], is(equalTo("x")));
  }

  @Test
  public void shouldUsePrefixCodes() throws Exception {
    MessageSourceMap map = new TestMessageSourceMap(new StaticMessageSource(), new String[] { "a.", "b.", "c." });
    MessageSourceResolvable value = (MessageSourceResolvable) map.get("x");
    assertThat(Arrays.asList(value.getCodes()), is(equalTo(Arrays.asList("a.x", "b.x", "c.x"))));
  }
View Full Code Here

Examples of org.springframework.context.support.StaticMessageSource

    assertThat(Arrays.asList(value.getCodes()), is(equalTo(Arrays.asList("a.x", "b.x", "c.x"))));
  }

  @Test
  public void shouldResolveOnGetValueToString() throws Exception {
    StaticMessageSource messageSource = new StaticMessageSource();
    MessageSourceMap map = new TestMessageSourceMap(messageSource, null);
    Object value = map.get("x");
    messageSource.addMessage("x", Locale.getDefault(), "message");
    assertThat(value.toString(), is(equalTo("message")));
  }
View Full Code Here

Examples of org.springframework.context.support.StaticMessageSource

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

  @Test
  public void shouldAllowNesting() throws Exception {
    MessageSourceMap map = new TestMessageSourceMap(new StaticMessageSource());
    MessageSourceResolvable value = (MessageSourceResolvable) map.get("x", "y", "z");
    assertThat(value.getCodes()[0], is(equalTo("x")));
    assertThat(Arrays.asList(value.getArguments()), is(equalTo(Arrays.<Object> asList("y", "z"))));
  }
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.