use of org.springframework.core.io.ByteArrayResource in project spring-boot by spring-projects.
the class ResourceBannerTests method renderWithoutTitle.
@Test
public void renderWithoutTitle() throws Exception {
Resource resource = new ByteArrayResource("banner ${application.title} ${a}".getBytes());
String banner = printBanner(resource, null, null, null);
assertThat(banner).startsWith("banner 1");
}
use of org.springframework.core.io.ByteArrayResource in project spring-boot by spring-projects.
the class YamlPropertySourceLoaderTests method orderedItems.
@Test
public void orderedItems() throws Exception {
StringBuilder yaml = new StringBuilder();
List<String> expected = new ArrayList<>();
for (char c = 'a'; c <= 'z'; c++) {
yaml.append(c + ": value" + c + "\n");
expected.add(String.valueOf(c));
}
ByteArrayResource resource = new ByteArrayResource(yaml.toString().getBytes());
EnumerablePropertySource<?> source = (EnumerablePropertySource<?>) this.loader.load("resource", resource, null);
assertThat(source).isNotNull();
assertThat(source.getPropertyNames()).isEqualTo(expected.toArray(new String[] {}));
}
use of org.springframework.core.io.ByteArrayResource in project spring-boot by spring-projects.
the class YamlPropertySourceLoaderTests method mergeItems.
@Test
public void mergeItems() throws Exception {
StringBuilder yaml = new StringBuilder();
yaml.append("foo:\n bar: spam\n");
yaml.append("---\n");
yaml.append("foo:\n baz: wham\n");
ByteArrayResource resource = new ByteArrayResource(yaml.toString().getBytes());
PropertySource<?> source = this.loader.load("resource", resource, null);
assertThat(source).isNotNull();
assertThat(source.getProperty("foo.bar")).isEqualTo("spam");
assertThat(source.getProperty("foo.baz")).isEqualTo("wham");
}
use of org.springframework.core.io.ByteArrayResource in project spring-boot by spring-projects.
the class YamlPropertySourceLoaderTests method timestampLikeItemsDoNotBecomeDates.
@Test
public void timestampLikeItemsDoNotBecomeDates() throws Exception {
ByteArrayResource resource = new ByteArrayResource("foo: 2015-01-28".getBytes());
PropertySource<?> source = this.loader.load("resource", resource, null);
assertThat(source).isNotNull();
assertThat(source.getProperty("foo")).isEqualTo("2015-01-28");
}
use of org.springframework.core.io.ByteArrayResource in project spring-framework by spring-projects.
the class YamlMapFactoryBeanTests method testGetObject.
@Test
public void testGetObject() throws Exception {
this.factory.setResources(new ByteArrayResource("foo: bar".getBytes()));
assertEquals(1, this.factory.getObject().size());
}
Aggregations