use of org.springframework.core.io.ClassPathResource 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.ClassPathResource 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);
}
use of org.springframework.core.io.ClassPathResource in project head by mifos.
the class ReportProductOfferingServiceIntegrationTest method setUp.
@Before
public void setUp() throws Exception {
loanPrdBusinessServiceMock = createMock(LoanPrdBusinessService.class);
savingsProductBusinessServiceMock = createMock(SavingsPrdBusinessService.class);
reportProductOfferingConfig = new ClassPathResource(FilePaths.REPORT_PRODUCT_OFFERING_CONFIG);
reportProductOfferingService = new ReportProductOfferingService(loanPrdBusinessServiceMock, savingsProductBusinessServiceMock, reportProductOfferingConfig) {
@Override
protected Short getLoanProduct1() {
return LOAN_OFFERING_1_ID;
}
@Override
protected Short getLoanProduct2() {
return LOAN_OFFERING_2_ID;
}
@Override
protected Short getSavingsProduct1() {
return SAVINGS_OFFERING_1_ID;
}
@Override
protected Short getSavingsProduct2() {
return SAVINGS_OFFERING_2_ID;
}
};
}
use of org.springframework.core.io.ClassPathResource in project head by mifos.
the class DbUnitUtilities method getDataSetFromClasspathFile.
public IDataSet getDataSetFromClasspathFile(String filename, String directory) throws IOException, DataSetException {
ClassPathResource resource = new ClassPathResource(directory + filename);
File file = resource.getFile();
if (file == null) {
throw new FileNotFoundException("Couldn't find file:" + filename);
}
FlatXmlDataSetBuilder fb = new FlatXmlDataSetBuilder();
fb.setColumnSensing(true);
fb.setDtdMetadata(false);
return fb.build(file);
}
use of org.springframework.core.io.ClassPathResource in project head by mifos.
the class RESTAPITestHelper method getJSONFromDataSet.
public String getJSONFromDataSet(String apiType, String by, String apiValue) throws IOException {
String type = apiType.replace('/', '-');
String value = apiValue.replace('/', '-');
String path = String.format("/dataSets/rest/%s-%s-%s.json", type, by, value);
ClassPathResource resource = new ClassPathResource(path);
File file = resource.getFile();
if (file == null) {
throw new FileNotFoundException("Couldn't find file");
}
return FileUtil.readAsString(file);
}
Aggregations