Search in sources :

Example 21 with ByteArrayResource

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

Example 22 with ByteArrayResource

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[] {}));
}
Also used : EnumerablePropertySource(org.springframework.core.env.EnumerablePropertySource) ArrayList(java.util.ArrayList) ByteArrayResource(org.springframework.core.io.ByteArrayResource) Test(org.junit.Test)

Example 23 with ByteArrayResource

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

Example 24 with ByteArrayResource

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

Example 25 with ByteArrayResource

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