use of org.springframework.core.io.Resource in project spring-boot-admin by codecentric.
the class ResourcePatternResolvingResourceResolverTest method test_resolveResource.
@Test
public void test_resolveResource() {
ResourceResolver resolver = new ResourcePatternResolvingResourceResolver(new PathMatchingResourcePatternResolver(), "classpath:/t*Resource.txt");
resolver.resolveResource(null, null, null, new ResourceResolverChain() {
@Override
public Resource resolveResource(HttpServletRequest request, String requestPath, List<? extends Resource> locations) {
assertThat(locations.size(), is(1));
assertThat(locations.get(0).getFilename(), is("testResource.txt"));
return null;
}
@Override
public String resolveUrlPath(String resourcePath, List<? extends Resource> locations) {
return null;
}
});
}
use of org.springframework.core.io.Resource in project OpenMEAP by OpenMEAP.
the class Log4JConfiguratorListener method contextInitialized.
@Override
public void contextInitialized(ServletContextEvent arg0) {
BasicConfigurator.configure();
ServletContext servletContext = arg0.getServletContext();
String xmlLoc = servletContext.getInitParameter("openmeap-log4j-xml");
if (xmlLoc == null) {
return;
}
try {
Resource res = new ClassPathResource(xmlLoc);
DOMConfigurator.configure(XmlUtils.getDocument(res.getInputStream()).getDocumentElement());
} catch (Exception ioe) {
servletContext.log("The configuration failed.", ioe);
}
}
use of org.springframework.core.io.Resource in project head by mifos.
the class ApplicationInitializer method copyLogo.
private void copyLogo(ServletContext servletContext) throws IOException {
ConfigurationLocator configurationLocator = new ConfigurationLocator();
Resource logoResource = configurationLocator.getUploadedMifosLogo();
if (!logoResource.exists()) {
InputStream defaultLogoStream = servletContext.getResourceAsStream("/pages/framework/images/logo.jpg");
File logoDir = new File(configurationLocator.getConfigurationDirectory() + File.separator + configurationLocator.getLogoDirectory());
logoDir.mkdir();
File logo = new File(logoDir, configurationLocator.getLogoName());
FileUtils.copyInputStreamToFile(defaultLogoStream, logo);
logger.info("Copy default logo to: " + logo.getAbsolutePath());
}
}
use of org.springframework.core.io.Resource in project head by mifos.
the class MifosMockStrutsTestCase method setStrutsConfig.
protected void setStrutsConfig() throws IOException {
/*
* Add a pointer to the context directory so that the web.xml file can be located when running test cases using
* the junit plugin inside Eclipse.
*
* Find the Web Resources dir (where WEB-INF lives) via Classpath, not hard-coded filenames.
*/
Resource r = new ClassPathResource("META-INF/resources/WEB-INF/struts-config.xml");
if (!r.exists() || !r.isReadable()) {
fail(r.getDescription() + " does not exist or is not readable");
}
File webResourcesDirectory = r.getFile().getParentFile().getParentFile();
mockStruts.setContextDirectory(webResourcesDirectory);
setConfigFile("/WEB-INF/struts-config.xml,/WEB-INF/other-struts-config.xml");
/*
* Because there is no more old-style web.xml as strutstest expects, we simply hard-code our ActionServlet
* (actually our new ActionServlet30).
*
* Because web.xml (now web-fragment.xml) isn't actually read, the ActionServlet is not initialized with servlet
* init-params config for all /WEB-INF/*-struts-config.xml listed in web(-fragment).xml, nor are the
* context-param read into config initParameter from web.xml by the MockStrutsTestCase. All Mifos *StrutsTest
* don't seem to need that though, and pass with this.
*/
mockStruts.setActionServlet(new ActionServlet30());
request = mockStruts.getMockRequest();
context = mockStruts.getMockContext();
}
use of org.springframework.core.io.Resource in project head by mifos.
the class BranchCashConfirmationConfigServiceTest method setUp.
@Override
protected void setUp() throws Exception {
Resource branchCashConfirmationReportConfig = new ClassPathResource(FilePaths.HO_CASH_CONFIRMATION_REPORT_CONFIG);
hOCashConfirmationConfigService = new HOCashConfirmationConfigService(branchCashConfirmationReportConfig);
}
Aggregations