use of org.springframework.core.io.Resource in project spring-boot by spring-projects.
the class InitializrServiceMetadataTests method readJson.
private static JSONObject readJson(String version) throws IOException, JSONException {
Resource resource = new ClassPathResource("metadata/service-metadata-" + version + ".json");
InputStream stream = resource.getInputStream();
try {
return new JSONObject(StreamUtils.copyToString(stream, Charset.forName("UTF-8")));
} finally {
stream.close();
}
}
use of org.springframework.core.io.Resource in project spring-boot by spring-projects.
the class ClassLoaderFilesResourcePatternResolverTests method getResourceShouldReturnResource.
@Test
public void getResourceShouldReturnResource() throws Exception {
Resource resource = this.resolver.getResource("index.html");
assertThat(resource).isNotNull().isInstanceOf(ClassPathResource.class);
}
use of org.springframework.core.io.Resource 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.Resource 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.Resource in project spring-framework by spring-projects.
the class AbstractBeanDefinitionReader method loadBeanDefinitions.
@Override
public int loadBeanDefinitions(Resource... resources) throws BeanDefinitionStoreException {
Assert.notNull(resources, "Resource array must not be null");
int counter = 0;
for (Resource resource : resources) {
counter += loadBeanDefinitions(resource);
}
return counter;
}
Aggregations