use of org.springframework.core.io.ByteArrayResource in project spring-framework by spring-projects.
the class YamlPropertiesFactoryBeanTests method testLoadNull.
@Test
public void testLoadNull() throws Exception {
YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean();
factory.setResources(new ByteArrayResource("foo: bar\nspam:".getBytes()));
Properties properties = factory.getObject();
assertThat(properties.getProperty("foo"), equalTo("bar"));
assertThat(properties.getProperty("spam"), equalTo(""));
}
use of org.springframework.core.io.ByteArrayResource in project spring-framework by spring-projects.
the class YamlPropertiesFactoryBeanTests method testBadResource.
@Test
public void testBadResource() throws Exception {
YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean();
factory.setResources(new ByteArrayResource("foo: bar\ncd\nspam:\n foo: baz".getBytes()));
this.exception.expect(ScannerException.class);
this.exception.expectMessage("line 3, column 1");
factory.getObject();
}
use of org.springframework.core.io.ByteArrayResource in project spring-framework by spring-projects.
the class YamlPropertiesFactoryBeanTests method testLoadResource.
@Test
public void testLoadResource() throws Exception {
YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean();
factory.setResources(new ByteArrayResource("foo: bar\nspam:\n foo: baz".getBytes()));
Properties properties = factory.getObject();
assertThat(properties.getProperty("foo"), equalTo("bar"));
assertThat(properties.getProperty("spam.foo"), equalTo("baz"));
}
use of org.springframework.core.io.ByteArrayResource in project spring-framework by spring-projects.
the class ResourceEncoderTests method encode.
@Test
public void encode() throws Exception {
String s = "foo";
Resource resource = new ByteArrayResource(s.getBytes(StandardCharsets.UTF_8));
Mono<Resource> source = Mono.just(resource);
Flux<DataBuffer> output = this.encoder.encode(source, this.bufferFactory, ResolvableType.forClass(Resource.class), null, Collections.emptyMap());
StepVerifier.create(output).consumeNextWith(stringConsumer(s)).expectComplete().verify();
}
use of org.springframework.core.io.ByteArrayResource in project spring-framework by spring-projects.
the class ResourceRegionEncoderTests method shouldEncodeResourceRegionByteArrayResource.
@Test
public void shouldEncodeResourceRegionByteArrayResource() throws Exception {
String content = "Spring Framework test resource content.";
shouldEncodeResourceRegion(new ByteArrayResource(content.getBytes(StandardCharsets.UTF_8)));
}
Aggregations