Search in sources :

Example 1 with ByteArrayResource

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

the class AbstractJsonMarshalTesterTests method readResourceShouldReturnObject.

@Test
public void readResourceShouldReturnObject() throws Exception {
    Resource resource = new ByteArrayResource(JSON.getBytes());
    AbstractJsonMarshalTester<Object> tester = createTester(TYPE);
    assertThat(tester.read(resource)).isEqualTo(OBJECT);
}
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 2 with ByteArrayResource

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

the class AbstractJsonMarshalTester method parse.

/**
	 * Return {@link ObjectContent} from parsing the specific JSON bytes.
	 * @param jsonBytes the source JSON bytes
	 * @return the {@link ObjectContent}
	 * @throws IOException on parse error
	 */
public ObjectContent<T> parse(byte[] jsonBytes) throws IOException {
    verify();
    Assert.notNull(jsonBytes, "JsonBytes must not be null");
    return read(new ByteArrayResource(jsonBytes));
}
Also used : ByteArrayResource(org.springframework.core.io.ByteArrayResource)

Example 3 with ByteArrayResource

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

the class BasicJsonTesterTests method fromResourceShouldReturnJsonContent.

@Test
public void fromResourceShouldReturnJsonContent() throws Exception {
    Resource resource = new ByteArrayResource(JSON.getBytes());
    assertThat(this.json.from(resource)).isEqualToJson("source.json");
}
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 4 with ByteArrayResource

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

the class PropertiesConfigurationFactoryTests 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 5 with ByteArrayResource

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

the class RelaxedDataBinderTests method bind.

private BindingResult bind(DataBinder binder, Object target, String values) throws Exception {
    Properties properties = PropertiesLoaderUtils.loadProperties(new ByteArrayResource(values.getBytes()));
    binder.bind(new MutablePropertyValues(properties));
    binder.validate();
    return binder.getBindingResult();
}
Also used : MutablePropertyValues(org.springframework.beans.MutablePropertyValues) ByteArrayResource(org.springframework.core.io.ByteArrayResource) Properties(java.util.Properties)

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