Spring Framework MockPropertySource - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework MockPropertySource class.

This code example shows how to use the following methods:
		assertThat(sources.precedenceOf(PropertySource.named("c")), is(2));
 
		sources.replace("a-replaced", new MockPropertySource("a"));
 
		try { 
			sources.replace(bogusPS, new MockPropertySource("bogus-replaced"));
			fail("expected non-existent PropertySource exception"); 
		} 
		catch (IllegalArgumentException ex) {
			assertTrue(ex.getMessage().contains("does not exist"));
		} 
 
		try { 
			sources.addBefore("b", new MockPropertySource("b"));
			fail("expected exception"); 
		} 
		catch (IllegalArgumentException ex) {
			assertTrue(ex.getMessage().contains("cannot be added relative to itself"));
		} 
 
6
CodeRank
This code example shows how to use the following methods:
	} 
 
	@Test(expected=IllegalArgumentException.class)
	public void resolveRequiredPlaceholders_withUnresolvable() { 
		MutablePropertySources propertySources = new MutablePropertySources();
		propertySources.addFirst(new MockPropertySource().withProperty("key", "value"));
		PropertyResolver resolver = new PropertySourcesPropertyResolver(propertySources);
		resolver.resolveRequiredPlaceholders("Replace this ${key} plus ${unknown}");
	} 
 
	@Test
	public void resolveRequiredPlaceholders_withDefaultValue() { 
		MutablePropertySources propertySources = new MutablePropertySources();
		propertySources.addFirst(new MockPropertySource().withProperty("key", "value"));
		PropertyResolver resolver = new PropertySourcesPropertyResolver(propertySources);
		assertThat(resolver.resolveRequiredPlaceholders("Replace this ${key} plus ${unknown:defaultValue}"),
				equalTo("Replace this value plus defaultValue")); 
	} 
 
	@Test(expected=IllegalArgumentException.class)
4
CodeRank
This code example shows how to use the following methods:
This code example shows how to use the following methods:
This code example shows how to use the following methods: