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);
}
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));
}
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");
}
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();
}
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();
}
Aggregations