Here are the examples of the java api play.libs.IO.readContentAsString() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
4 Examples
19
View Complete Implementation : Fixtures.java
Copyright Apache License 2.0
Author : eBay
Copyright Apache License 2.0
Author : eBay
public static void executeSQL(File sqlScript) {
executeSQL(IO.readContentreplacedtring(sqlScript));
}
19
View Complete Implementation : VirtualFile.java
Copyright Apache License 2.0
Author : eBay
Copyright Apache License 2.0
Author : eBay
public String contentreplacedtring() {
try {
return IO.readContentreplacedtring(inputstream());
} catch (Exception e) {
throw new UnexpectedException(e);
}
}
16
View Complete Implementation : Evolutions.java
Copyright Apache License 2.0
Author : eBay
Copyright Apache License 2.0
Author : eBay
public synchronized static Stack<Evolution> listApplicationEvolutions() {
Stack<Evolution> evolutions = new Stack<Evolution>();
evolutions.add(new Evolution(0, "", "", true));
if (evolutionsDirectory.exists()) {
for (File evolution : evolutionsDirectory.listFiles()) {
if (evolution.getName().matches("^[0-9]+[.]sql$")) {
if (Logger.isTraceEnabled()) {
Logger.trace("Loading evolution %s", evolution);
}
int version = Integer.parseInt(evolution.getName().substring(0, evolution.getName().indexOf(".")));
String sql = IO.readContentreplacedtring(evolution);
StringBuffer sql_up = new StringBuffer();
StringBuffer sql_down = new StringBuffer();
StringBuffer current = new StringBuffer();
for (String line : sql.split("\r?\n")) {
if (line.trim().matches("^#.*[!]Ups")) {
current = sql_up;
} else if (line.trim().matches("^#.*[!]Downs")) {
current = sql_down;
} else if (line.trim().startsWith("#")) {
// skip
} else if (!StringUtils.isEmpty(line.trim())) {
current.append(line).append("\n");
}
}
evolutions.add(new Evolution(version, sql_up.toString(), sql_down.toString(), true));
}
}
Collections.sort(evolutions);
}
return evolutions;
}
14
View Complete Implementation : TestRunner.java
Copyright Apache License 2.0
Author : eBay
Copyright Apache License 2.0
Author : eBay
public static void run(String test) throws Exception {
if (test.equals("init")) {
File testResults = Play.getFile("test-result");
if (!testResults.exists()) {
testResults.mkdir();
}
for (File tr : testResults.listFiles()) {
if ((tr.getName().endsWith(".html") || tr.getName().startsWith("result.")) && !tr.delete()) {
Logger.warn("Cannot delete %s ...", tr.getAbsolutePath());
}
}
renderText("done");
}
if (test.equals("end")) {
File testResults = Play.getFile("test-result/result." + params.get("result"));
IO.writeContent(params.get("result"), testResults);
renderText("done");
}
if (test.endsWith(".clreplaced")) {
Play.getFile("test-result").mkdir();
TestEngine.TestResults results = TestEngine.run(test.substring(0, test.length() - 6));
response.status = results.preplaceded ? 200 : 500;
Template resultTemplate = TemplateLoader.load("TestRunner/results.html");
Map<String, Object> options = new HashMap<String, Object>();
options.put("test", test);
options.put("results", results);
String result = resultTemplate.render(options);
File testResults = Play.getFile("test-result/" + test + (results.preplaceded ? ".preplaceded" : ".failed") + ".html");
IO.writeContent(result, testResults);
try {
// Write xml output
options.remove("out");
resultTemplate = TemplateLoader.load("TestRunner/results-xunit.xml");
String resultXunit = resultTemplate.render(options);
File testXunitResults = Play.getFile("test-result/TEST-" + test.substring(0, test.length() - 6) + ".xml");
IO.writeContent(resultXunit, testXunitResults);
} catch (Exception e) {
Logger.error(e, "Cannot ouput XML unit output");
}
response.contentType = "text/html";
renderText(result);
}
if (test.endsWith(".test.html.suite")) {
test = test.substring(0, test.length() - 6);
render("TestRunner/selenium-suite.html", test);
}
if (test.endsWith(".test.html")) {
File testFile = Play.getFile("test/" + test);
if (!testFile.exists()) {
for (VirtualFile root : Play.roots) {
File moduleTestFile = Play.getFile(root.relativePath() + "/test/" + test);
if (moduleTestFile.exists()) {
testFile = moduleTestFile;
}
}
}
if (testFile.exists()) {
Template testTemplate = TemplateLoader.load(VirtualFile.open(testFile));
Map<String, Object> options = new HashMap<String, Object>();
response.contentType = "text/html";
renderText(testTemplate.render(options));
} else {
renderText("Test not found, %s", testFile);
}
}
if (test.endsWith(".test.html.result")) {
flash.keep();
test = test.substring(0, test.length() - 7);
File testResults = Play.getFile("test-result/" + test.replace("/", ".") + ".preplaceded.html");
if (testResults.exists()) {
response.contentType = "text/html";
response.status = 200;
renderText(IO.readContentreplacedtring(testResults));
}
testResults = Play.getFile("test-result/" + test.replace("/", ".") + ".failed.html");
if (testResults.exists()) {
response.contentType = "text/html";
response.status = 500;
renderText(IO.readContentreplacedtring(testResults));
}
response.status = 404;
renderText("No test result");
}
}