FileUtils { public static Resource getFileResource(String filePath, TestContext context) { if (filePath.contains(FILE_PATH_CHARSET_PARAMETER)) { return new PathMatchingResourcePatternResolver().getResource( context.replaceDynamicContentInString(filePath.substring(0, filePath.indexOf(FileUtils.FILE_PATH_CHARSET_PARAMETER)))); } else { return new PathMatchingResourcePatternResolver().getResource( context.replaceDynamicContentInString(filePath)); } } private  FileUtils(); static void setSimulationMode(boolean mode); static String readToString(Resource resource); static String readToString(InputStream inputStream); static String readToString(File file); static String readToString(Resource resource, Charset charset); static String readToString(InputStream inputStream, Charset charset); static void writeToFile(InputStream inputStream, File file); static void writeToFile(String content, File file); static void writeToFile(String content, File file, Charset charset); static List<File> findFiles(final String startDir, final Set<String> fileNamePatterns); static Resource getFileResource(String filePath, TestContext context); static Resource getFileResource(String filePath); static Charset getDefaultCharset(); static Charset getCharset(String path); static String getFileExtension(String path); final static String FILE_PATH_CHARSET_PARAMETER; }
@Test public void testGetFileResource() throws Exception { Resource resource = FileUtils.getFileResource("classpath:citrus-context.xml", context); Assert.assertNotNull(resource); Assert.assertTrue(resource.exists()); }
@Test public void testGetFileResourceExplicitCharset() throws Exception { Resource resource = FileUtils.getFileResource("classpath:citrus-context.xml" + FileUtils.FILE_PATH_CHARSET_PARAMETER + "ISO-8859-1", context); Assert.assertNotNull(resource); Assert.assertTrue(resource.exists()); }