Search in sources :

Example 81 with Resource

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);
}
Also used : ClassPathResource(org.springframework.core.io.ClassPathResource) Resource(org.springframework.core.io.Resource) ClassPathResource(org.springframework.core.io.ClassPathResource)

Example 82 with Resource

use of org.springframework.core.io.Resource in project head by mifos.

the class PPISurveyLocatorImpl method getPPIUploadFileForCountry.

@Override
public String getPPIUploadFileForCountry(String country) {
    try {
        String fileName = getPPIXmlFileName(country);
        Resource resource = this.resourceLoader.getResource(resolvePath());
        return getPPIFilePath(fileName, resource.getFile());
    } catch (IOException e) {
        throw new SystemException(FETCH_PPI_COUNTRY_XML_FAILED, e);
    }
}
Also used : SystemException(org.mifos.framework.exceptions.SystemException) Resource(org.springframework.core.io.Resource) IOException(java.io.IOException)

Example 83 with Resource

use of org.springframework.core.io.Resource in project head by mifos.

the class MifosResourceUtilTest method testGetResources.

@Test
public void testGetResources() throws IOException {
    Resource[] found = MifosResourceUtil.getClassPathResourcesAsResources("org/mifos/core/resources/included/**/*.xml");
    assertEquals(2, found.length);
    for (Resource resource : found) {
        String f = resource.getFilename();
        if (!"y.xml".equals(f) && !"z.xml".equals(f)) {
            fail(resource + " should not have been returned");
        }
    }
}
Also used : Resource(org.springframework.core.io.Resource) Test(org.junit.Test)

Example 84 with Resource

use of org.springframework.core.io.Resource in project head by mifos.

the class ConfigurationLocator method getCustomFilePath.

/**
     * Will not throw an exception if the file is not found. This method may be
     * used to find files in cases where we don't care if the file cannot be
     * found.
     * @throws IOException
     */
@SuppressWarnings("PMD")
public // TODO It may be clearer if this returned an URI or URL instead of a String?
String getCustomFilePath(String filename) throws IOException {
    String returnValue = filename;
    LOGGER.info("Checking existance of : " + filename);
    Resource configFile = getResource(filename);
    if (configFile != null && configFile.exists()) {
        returnValue = configFile.getURL().toExternalForm();
        LOGGER.info("Custom configuration file exists : " + returnValue);
    }
    return returnValue;
}
Also used : ClassPathResource(org.springframework.core.io.ClassPathResource) FileSystemResource(org.springframework.core.io.FileSystemResource) Resource(org.springframework.core.io.Resource)

Example 85 with Resource

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);
    }
}
Also used : ClassPathResource(org.springframework.core.io.ClassPathResource) Resource(org.springframework.core.io.Resource) ServletContext(javax.servlet.ServletContext) ClassPathResource(org.springframework.core.io.ClassPathResource)

Aggregations

Resource (org.springframework.core.io.Resource)610 Test (org.junit.Test)257 ClassPathResource (org.springframework.core.io.ClassPathResource)231 IOException (java.io.IOException)103 FileSystemResource (org.springframework.core.io.FileSystemResource)77 UrlResource (org.springframework.core.io.UrlResource)68 File (java.io.File)64 ArrayList (java.util.ArrayList)58 ByteArrayResource (org.springframework.core.io.ByteArrayResource)49 InputStream (java.io.InputStream)46 InputStreamResource (org.springframework.core.io.InputStreamResource)31 PathMatchingResourcePatternResolver (org.springframework.core.io.support.PathMatchingResourcePatternResolver)30 URL (java.net.URL)25 HashMap (java.util.HashMap)20 MockServerWebExchange (org.springframework.mock.http.server.reactive.test.MockServerWebExchange)18 ServletContextResource (org.springframework.web.context.support.ServletContextResource)18 Map (java.util.Map)17 ResourcePatternResolver (org.springframework.core.io.support.ResourcePatternResolver)17 ResourceLoader (org.springframework.core.io.ResourceLoader)16 MockHttpServletRequest (org.springframework.mock.web.test.MockHttpServletRequest)16