use of org.springframework.core.io.ByteArrayResource in project spring-framework by spring-projects.
the class YamlProcessorTests method mapConvertedToIndexedBeanReference.
@Test
public void mapConvertedToIndexedBeanReference() {
this.processor.setResources(new ByteArrayResource("foo: bar\nbar:\n spam: bucket".getBytes()));
this.processor.process(new MatchCallback() {
@Override
public void process(Properties properties, Map<String, Object> map) {
// System.err.println(properties);
assertEquals("bucket", properties.get("bar.spam"));
assertEquals(2, properties.size());
}
});
}
use of org.springframework.core.io.ByteArrayResource in project spring-framework by spring-projects.
the class YamlProcessorTests method integerKeyBehaves.
@Test
public void integerKeyBehaves() {
this.processor.setResources(new ByteArrayResource("foo: bar\n1: bar".getBytes()));
this.processor.process(new MatchCallback() {
@Override
public void process(Properties properties, Map<String, Object> map) {
assertEquals("bar", properties.get("[1]"));
assertEquals(2, properties.size());
}
});
}
use of org.springframework.core.io.ByteArrayResource in project spring-framework by spring-projects.
the class YamlPropertiesFactoryBeanTests method testLoadResourcesWithOverride.
@Test
public void testLoadResourcesWithOverride() throws Exception {
YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean();
factory.setResources(new ByteArrayResource("foo: bar\nspam:\n foo: baz".getBytes()), new ByteArrayResource("foo:\n bar: spam".getBytes()));
Properties properties = factory.getObject();
assertThat(properties.getProperty("foo"), equalTo("bar"));
assertThat(properties.getProperty("spam.foo"), equalTo("baz"));
assertThat(properties.getProperty("foo.bar"), equalTo("spam"));
}
use of org.springframework.core.io.ByteArrayResource in project spring-framework by spring-projects.
the class YamlPropertiesFactoryBeanTests method testLoadResourceWithSelectedDocuments.
@Test
public void testLoadResourceWithSelectedDocuments() throws Exception {
YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean();
factory.setResources(new ByteArrayResource("foo: bar\nspam: baz\n---\nfoo: bag\nspam: bad".getBytes()));
factory.setDocumentMatchers(new DocumentMatcher() {
@Override
public MatchStatus matches(Properties properties) {
return ("bag".equals(properties.getProperty("foo")) ? MatchStatus.FOUND : MatchStatus.NOT_FOUND);
}
});
Properties properties = factory.getObject();
assertThat(properties.getProperty("foo"), equalTo("bag"));
assertThat(properties.getProperty("spam"), equalTo("bad"));
}
use of org.springframework.core.io.ByteArrayResource in project spring-framework by spring-projects.
the class YamlPropertiesFactoryBeanTests method testLoadResourcesWithNestedInternalOverride.
@Test
@Ignore("We can't fail on duplicate keys because the Map is created by the YAML library")
public void testLoadResourcesWithNestedInternalOverride() throws Exception {
YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean();
factory.setResources(new ByteArrayResource("foo:\n bar: spam\n foo: baz\nbreak: it\nfoo: bucket".getBytes()));
Properties properties = factory.getObject();
assertThat(properties.getProperty("foo.bar"), equalTo("spam"));
}
Aggregations