use of org.springframework.core.io.InputStreamResource in project spring-boot by spring-projects.
the class AbstractJsonMarshalTester method read.
/**
* Return {@link ObjectContent} from reading from the specified input stream.
* @param inputStream the source input stream
* @return the {@link ObjectContent}
* @throws IOException on read error
*/
public ObjectContent<T> read(InputStream inputStream) throws IOException {
verify();
Assert.notNull(inputStream, "InputStream must not be null");
return read(new InputStreamResource(inputStream));
}
use of org.springframework.core.io.InputStreamResource in project spring-framework by spring-projects.
the class XmlBeanDefinitionReaderTests method withOpenInputStreamAndExplicitValidationMode.
@Test
public void withOpenInputStreamAndExplicitValidationMode() {
SimpleBeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
Resource resource = new InputStreamResource(getClass().getResourceAsStream("test.xml"));
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(registry);
reader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_DTD);
reader.loadBeanDefinitions(resource);
testBeanDefinitions(registry);
}
use of org.springframework.core.io.InputStreamResource in project spring-framework by spring-projects.
the class XmlBeanDefinitionReaderTests method withOpenInputStream.
@Test(expected = BeanDefinitionStoreException.class)
public void withOpenInputStream() {
SimpleBeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry();
Resource resource = new InputStreamResource(getClass().getResourceAsStream("test.xml"));
new XmlBeanDefinitionReader(registry).loadBeanDefinitions(resource);
}
use of org.springframework.core.io.InputStreamResource in project opennms by OpenNMS.
the class ConfigurationTestUtils method getSpringResourceForResourceWithReplacements.
public static Resource getSpringResourceForResourceWithReplacements(final Object obj, final String resource, final String[]... replacements) throws IOException {
try {
String config = getConfigForResourceWithReplacements(obj, resource, replacements);
File tmp = File.createTempFile("testConfigFile", ".xml");
tmp.deleteOnExit();
FileWriter fw = new FileWriter(tmp);
fw.write(config);
fw.close();
return new FileSystemResource(tmp);
} catch (final Throwable t) {
return new InputStreamResource(getInputStreamForResourceWithReplacements(obj, resource, replacements));
}
}
use of org.springframework.core.io.InputStreamResource in project opennms by OpenNMS.
the class AbstractJaxbConfigDaoTest method testAfterPropertiesSetWithGoodConfigFile.
public void testAfterPropertiesSetWithGoodConfigFile() throws Exception {
TestJaxbConfigDao dao = new TestJaxbConfigDao();
InputStream in = ConfigurationTestUtils.getInputStreamForConfigFile("jdbc-datacollection-config.xml");
dao.setConfigResource(new InputStreamResource(in));
dao.afterPropertiesSet();
assertNotNull("jdbc data collection should not be null", dao.getDataCollectionConfig());
}
Aggregations