use of org.springframework.core.io.ByteArrayResource in project spring-framework by spring-projects.
the class YamlMapFactoryBeanTests method testOverrideAndRemoveDefaults.
@SuppressWarnings("unchecked")
@Test
public void testOverrideAndRemoveDefaults() throws Exception {
this.factory.setResources(new ByteArrayResource("foo:\n bar: spam".getBytes()), new ByteArrayResource("foo:\n spam: bar".getBytes()));
assertEquals(1, this.factory.getObject().size());
assertEquals(2, ((Map<String, Object>) this.factory.getObject().get("foo")).size());
}
use of org.springframework.core.io.ByteArrayResource in project spring-framework by spring-projects.
the class YamlMapFactoryBeanTests method testDuplicateKey.
@Test
public void testDuplicateKey() throws Exception {
this.factory.setResources(new ByteArrayResource("mymap:\n foo: bar\nmymap:\n bar: foo".getBytes()));
Map<String, Object> map = this.factory.getObject();
assertEquals(1, map.size());
assertTrue(map.containsKey("mymap"));
Object object = map.get("mymap");
assertTrue(object instanceof LinkedHashMap);
@SuppressWarnings("unchecked") Map<String, Object> sub = (Map<String, Object>) object;
assertEquals(1, sub.size());
assertEquals("foo", sub.get("bar"));
}
use of org.springframework.core.io.ByteArrayResource in project spring-framework by spring-projects.
the class YamlMapFactoryBeanTests method testMapWithIntegerValue.
@Test
public void testMapWithIntegerValue() throws Exception {
this.factory.setResources(new ByteArrayResource("foo:\n ? key1.key2\n : 3".getBytes()));
Map<String, Object> map = this.factory.getObject();
assertEquals(1, map.size());
assertTrue(map.containsKey("foo"));
Object object = map.get("foo");
assertTrue(object instanceof LinkedHashMap);
@SuppressWarnings("unchecked") Map<String, Object> sub = (Map<String, Object>) object;
assertEquals(1, sub.size());
assertEquals(Integer.valueOf(3), sub.get("key1.key2"));
}
use of org.springframework.core.io.ByteArrayResource in project spring-framework by spring-projects.
the class YamlMapFactoryBeanTests method testMapWithPeriodsInKey.
@Test
public void testMapWithPeriodsInKey() throws Exception {
this.factory.setResources(new ByteArrayResource("foo:\n ? key1.key2\n : value".getBytes()));
Map<String, Object> map = this.factory.getObject();
assertEquals(1, map.size());
assertTrue(map.containsKey("foo"));
Object object = map.get("foo");
assertTrue(object instanceof LinkedHashMap);
@SuppressWarnings("unchecked") Map<String, Object> sub = (Map<String, Object>) object;
assertTrue(sub.containsKey("key1.key2"));
assertEquals("value", sub.get("key1.key2"));
}
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();
}
Aggregations