Search in sources :

Example 16 with ByteArrayResource

use of org.springframework.core.io.ByteArrayResource in project spring-boot by spring-projects.

the class PropertiesConfigurationFactoryMapTests method bindFoo.

private Foo bindFoo(final String values) throws Exception {
    Properties properties = PropertiesLoaderUtils.loadProperties(new ByteArrayResource(values.getBytes()));
    MutablePropertySources propertySources = new MutablePropertySources();
    propertySources.addFirst(new PropertiesPropertySource("test", properties));
    this.factory.setPropertySources(propertySources);
    this.factory.afterPropertiesSet();
    return this.factory.getObject();
}
Also used : PropertiesPropertySource(org.springframework.core.env.PropertiesPropertySource) ByteArrayResource(org.springframework.core.io.ByteArrayResource) MutablePropertySources(org.springframework.core.env.MutablePropertySources) Properties(java.util.Properties)

Example 17 with ByteArrayResource

use of org.springframework.core.io.ByteArrayResource in project spring-boot by spring-projects.

the class PropertiesConfigurationFactoryParameterizedTests method bindFoo.

private Foo bindFoo(final String values) throws Exception {
    Properties properties = PropertiesLoaderUtils.loadProperties(new ByteArrayResource(values.getBytes()));
    MutablePropertySources propertySources = new MutablePropertySources();
    propertySources.addFirst(new PropertiesPropertySource("test", properties));
    this.factory.setPropertySources(propertySources);
    this.factory.afterPropertiesSet();
    return this.factory.getObject();
}
Also used : PropertiesPropertySource(org.springframework.core.env.PropertiesPropertySource) ByteArrayResource(org.springframework.core.io.ByteArrayResource) MutablePropertySources(org.springframework.core.env.MutablePropertySources) Properties(java.util.Properties)

Example 18 with ByteArrayResource

use of org.springframework.core.io.ByteArrayResource in project spring-boot by spring-projects.

the class ResourceBannerTests method renderFormattedVersions.

@Test
public void renderFormattedVersions() throws Exception {
    Resource resource = new ByteArrayResource("banner ${a}${spring-boot.formatted-version}${application.formatted-version}".getBytes());
    String banner = printBanner(resource, "10.2", "2.0", null);
    assertThat(banner).startsWith("banner 1 (v10.2) (v2.0)");
}
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 19 with ByteArrayResource

use of org.springframework.core.io.ByteArrayResource in project spring-boot by spring-projects.

the class ResourceBannerTests method renderWithoutVersions.

@Test
public void renderWithoutVersions() throws Exception {
    Resource resource = new ByteArrayResource("banner ${a} ${spring-boot.version} ${application.version}".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 20 with ByteArrayResource

use of org.springframework.core.io.ByteArrayResource in project spring-boot by spring-projects.

the class ResourceBannerTests method renderWithColors.

@Test
public void renderWithColors() throws Exception {
    Resource resource = new ByteArrayResource("${Ansi.RED}This is red.${Ansi.NORMAL}".getBytes());
    AnsiOutput.setEnabled(AnsiOutput.Enabled.ALWAYS);
    String banner = printBanner(resource, null, null, null);
    assertThat(banner).startsWith("This is red.");
}
Also used : ByteArrayResource(org.springframework.core.io.ByteArrayResource) Resource(org.springframework.core.io.Resource) 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