List of usage examples for org.apache.commons.io FileUtils readFileToString
public static String readFileToString(File file, String encoding) throws IOException
From source file:com.sport.server.pdf.FopXmlGeneratorTest.java
@Test public void testCreateXml() throws RemoteException, Exception { TournamentHolder tournamentHolder = new TurReader().read(TUR_FILE); LicenceBO license = createLicense(); String fopXml = fopXmlGenerator.createXml(license, tournamentHolder, null, Locale.GERMAN); String expectedFopXml = FileUtils.readFileToString(FOP_XML_FILE, "UTF-8"); assertEquals("XML is wrongly generated", normalizeXml(expectedFopXml), normalizeXml(fopXml)); }
From source file:com.alibaba.druid.test.OdpsSelectTest6.java
public void test_distribute_by() throws Exception { File file = new File("/Users/wenshao/Downloads/datasafe_base_dev.udf_test.txt"); String sql = FileUtils.readFileToString(file, "UTF-8"); SQLStatementParser parser = new OdpsStatementParser(sql); List<SQLStatement> statementList = parser.parseStatementList(); SQLStatement stmt = statementList.get(0); Assert.assertEquals(1, statementList.size()); MySqlSchemaStatVisitor visitor = new MySqlSchemaStatVisitor(); stmt.accept(visitor);//w w w. ja va 2 s .co m // Assert.assertEquals("SELECT *" // + "\nFROM t" // + "\nWHERE ds = '20160303'" // + "\n\tAND hour IN ('18')", SQLUtils.formatOdps(sql)); }
From source file:com.autentia.xml.schema.FromFileClassType.java
@Override public String toSchema() { try {//from w ww . j a va 2 s. c o m return FileUtils.readFileToString(sourceFile, "UTF-8"); } catch (IOException e) { // logger.error(); e.printStackTrace(); } return null; }
From source file:io.github.azige.mages.Util.java
static List<Plugin> loadPluginsFromDirectory(File dir) { List<Plugin> list = new LinkedList<>(); File[] files = dir.listFiles(new FilenameFilter() { @Override// w ww . j a va 2 s. co m public boolean accept(File dir, String name) { return name.endsWith(".groovy"); } }); if (files == null) { return list; } try { GroovyClassLoader loader = new GroovyClassLoader(); loader.addClasspath(dir.getCanonicalPath()); final int extLength = ".groovy".length(); for (File f : files) { String name = f.getName(); String script = FileUtils.readFileToString(f, "UTF-8"); list.add(wrapPlugin(name.substring(0, name.length() - extLength), loader.parseClass(script).newInstance())); } } catch (Exception ex) { throw new MagesException(ex); } return list; }
From source file:com.cognitivabrasil.repositorio.data.entities.DocumentTest.java
@Test public void testXmlDeserialization() throws IOException { Document d = new Document(); String obaaXml = FileUtils.readFileToString(new File("src/test/resources/obaa1.xml"), "UTF-8"); d.setObaaXml(obaaXml);/*from www . java 2s .co m*/ OBAA m = d.getMetadata(); assertThat(m.getGeneral().getTitles(), hasItem("Ttulo 1")); }
From source file:jetbrick.tools.chm.reader.IndexesReader.java
public Map<String, String> getIndexes(File resource) throws IOException { Pattern p = Config.style.getIndexRegex(); Matcher m = p.matcher(FileUtils.readFileToString(resource, Config.encoding)); Map<String, String> indexMaps = new HashMap<String, String>(1024); while (m.find()) { addIndex(indexMaps, m.group(2), m.group(1)); }//from w w w . j a v a2 s . c o m return indexMaps; }
From source file:com.us.action.view.Viewer.java
@Override public String execute() throws Exception { Object kv = AppConfig.getArg(target); if (kv != null) { Map<String, Object> data = ObjHelper.toMap(kv); Object ti = data.get("title"); if (ti != null) { title = I118Helper.i118Val(ti.toString(), getRequest()); }//from w w w . ja va 2s .c o m Object cont = data.get(local()); if (cont != null) { content = FileUtils.readFileToString(new File(cont.toString()), "UTF-8"); } final Object webModel = data.get("webModel"); if (webModel != null) { getRequest().setAttribute("webModel", webModel); } } return view("showAll"); }
From source file:au.org.ala.delta.confor.ToPayneTest.java
@Test public void testSampleToPayne() throws Exception { runConfor();//from www . j av a2 s. com File expectedFile = new File(FilenameUtils.concat(_samplePath, "expected_results/pydata")); String expected = FileUtils.readFileToString(expectedFile, "utf-8"); System.out.println(expected); File actualFile = new File(FilenameUtils.concat(_samplePath, "pydata")); String actual = FileUtils.readFileToString(actualFile, "utf-8"); System.out.print(actual); boolean dosEol = expected.contains("\r\n"); String expectedLineSeparator = "\n"; if (dosEol) { expectedLineSeparator = "\r\n"; } if (!System.getProperty("line.separator").equals(expectedLineSeparator)) { expected = expected.replaceAll(expectedLineSeparator, System.getProperty("line.separator")); } // The heading contains the date so will be different. String heading = "Grass Genera 16.08 22-NOV-11"; // <Date>, eg. 11:32 05-OCT-11 actual = actual.replaceAll("Grass Genera.*[0-9]{2}-[a-zA-Z]{3}-[0-9]{4}", heading); assertEquals(expected.trim(), actual.trim()); }
From source file:com.mgmtp.jfunk.integrationtest.AbstractAppServerModule.java
protected static void startupServer() { server = HttpServer.createSimpleServer(); server.getServerConfiguration().addHttpHandler(new HttpHandler() { public void service(Request request, Response response) throws Exception { String htmlFileContent = null; try { htmlFileContent = FileUtils.readFileToString(new File("static/" + testHtmlFilePath), "UTF-8"); response.setContentType("text/html"); response.setContentLength(htmlFileContent.length()); response.getWriter().write(htmlFileContent); } catch (IOException e) { System.err.println(e); }/*w w w . ja va 2 s. c o m*/ } }, "/" + testApplicationPath); try { server.start(); System.err.println("Server was started up."); } catch (Exception e) { System.err.println(e); } }
From source file:au.org.ala.delta.confor.PrintCRTest.java
@Test public void testSamplePrintCR() throws Exception { runConfor();/*from w w w. ja v a2s. co m*/ File expectedFile = new File(FilenameUtils.concat(_samplePath, "expected_results/chars.rtf")); String expected = FileUtils.readFileToString(expectedFile, "cp1252"); System.out.println(expected); File actualFile = new File(FilenameUtils.concat(_samplePath, "rtf/chars.rtf")); String actual = FileUtils.readFileToString(actualFile, "cp1252"); System.out.print(actual); boolean dosEol = expected.contains("\r\n"); String expectedLineSeparator = "\n"; if (dosEol) { expectedLineSeparator = "\r\n"; } if (!System.getProperty("line.separator").equals(expectedLineSeparator)) { expected = expected.replaceAll(expectedLineSeparator, System.getProperty("line.separator")); } // The heading contains the date so will be different. for (int i = 0; i < expected.length(); i++) { if (expected.charAt(i) != actual.charAt(i)) { System.out.println("Difference @ char: " + i + " Expected: " + expected.charAt(i) + (int) expected.charAt(i) + ", Actual: " + actual.charAt(i) + (int) actual.charAt(i)); break; } } assertEquals(expected, actual); }