Search in sources :

Example 26 with ByteArrayResource

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());
}
Also used : ByteArrayResource(org.springframework.core.io.ByteArrayResource) Test(org.junit.Test)

Example 27 with ByteArrayResource

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"));
}
Also used : ByteArrayResource(org.springframework.core.io.ByteArrayResource) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test)

Example 28 with ByteArrayResource

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"));
}
Also used : ByteArrayResource(org.springframework.core.io.ByteArrayResource) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test)

Example 29 with ByteArrayResource

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"));
}
Also used : ByteArrayResource(org.springframework.core.io.ByteArrayResource) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test)

Example 30 with ByteArrayResource

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();
}
Also used : ByteArrayResource(org.springframework.core.io.ByteArrayResource) InputStreamResource(org.springframework.core.io.InputStreamResource) Resource(org.springframework.core.io.Resource) ByteArrayResource(org.springframework.core.io.ByteArrayResource) DataBuffer(org.springframework.core.io.buffer.DataBuffer) Test(org.junit.Test)

Aggregations

ByteArrayResource (org.springframework.core.io.ByteArrayResource)89 Test (org.junit.Test)66 Resource (org.springframework.core.io.Resource)30 Properties (java.util.Properties)26 JmsNorthbounderConfig (org.opennms.netmgt.alarmd.northbounder.jms.JmsNorthbounderConfig)6 JmsNorthbounderConfigDao (org.opennms.netmgt.alarmd.northbounder.jms.JmsNorthbounderConfigDao)6 InetAddress (java.net.InetAddress)5 ArrayList (java.util.ArrayList)5 LinkedList (java.util.LinkedList)5 NorthboundAlarm (org.opennms.netmgt.alarmd.api.NorthboundAlarm)5 JmsDestination (org.opennms.netmgt.alarmd.northbounder.jms.JmsDestination)5 OnmsAlarm (org.opennms.netmgt.model.OnmsAlarm)5 OnmsIpInterface (org.opennms.netmgt.model.OnmsIpInterface)5 OnmsNode (org.opennms.netmgt.model.OnmsNode)5 IOException (java.io.IOException)4 LinkedHashMap (java.util.LinkedHashMap)4 Map (java.util.Map)4 MutablePropertySources (org.springframework.core.env.MutablePropertySources)4 FileSystemResource (org.springframework.core.io.FileSystemResource)4 InputStream (java.io.InputStream)3