List of usage examples for org.apache.commons.io FileUtils readFileToString
public static String readFileToString(File file) throws IOException
From source file:com.strandls.alchemy.rest.client.stubgenerator.ProxyImplementationGeneratorTest.java
/** * Test method for/* www. j a v a 2 s. c o m*/ * {@link com.strandls.alchemy.rest.client.stubgenerator.ProxyImplementationGenerator#generateProxy(java.lang.String, java.lang.String, java.lang.String, java.io.File)} * . * * @throws IOException */ @Test public void testGenerateProxy() throws IOException { final ProxyImplementationGenerator generator = new ProxyImplementationGenerator(); final File tempDir = File.createTempFile("test", "test"); FileUtils.deleteQuietly(tempDir); if (!tempDir.mkdirs()) { throw new IOException("Cannot create temporary directory."); } try { generator.generateProxy("TestStub", "TestStubProxy", "", tempDir); assertEquals( FileUtils.readFileToString( new File("src/test/resources/com/strandls/alchemy/rest/client/stubgenerator" + "/TestStubProxy.txt")) .trim(), FileUtils.readFileToString(new File(tempDir, "TestStubProxy.java")).trim()); } finally { FileUtils.deleteQuietly(tempDir); } }
From source file:controllers.infra.Licensing.java
public static void uploadLicense(File newLicenseFile) { String newLicenseText = null; if (newLicenseFile != null) { try {/*from w w w.j av a 2 s . c om*/ newLicenseText = FileUtils.readFileToString(newLicenseFile); } catch (IOException e) { newLicenseText = null; Validation.addError("newLicenseFile", MessagesUtils.get("license.invalidLicenseFile")); Logger.error(e, "Failed to read license text file"); } } else { Validation.addError("newLicenseFile", MessagesUtils.get("license.licenseFileIsRequired")); } if (StringUtils.isNotBlank(newLicenseText)) { LicenseUtils.updateLicenseText(newLicenseText); flash.success(MessagesUtils.get("license.licenseFileUpdated")); } else { flash.error(MessagesUtils.get("license.uploadFailed")); } if (Validation.hasErrors()) { validation.keep(); } index(); }
From source file:com.mirth.connect.plugins.datatypes.ncpdp.test.NCPDPSerializerTest.java
@Test public void test51RequestFromXml() throws Exception { String input = FileUtils.readFileToString(new File("tests/test-ncpdp-51-request-output.xml")); String output = FileUtils.readFileToString(new File("tests/test-ncpdp-51-request-input.txt")); NCPDPSerializer serializer = new NCPDPSerializer(defaultProperties.getSerializerProperties()); Assert.assertEquals(output, serializer.fromXML(input)); }
From source file:de.akquinet.dustjs.CLITest.java
@Test public void compileFileToFile() throws IOException, URISyntaxException { File tmp = new File("target/tmp"); tmp.mkdirs();/* w ww . jav a 2 s . c o m*/ File test = new File("src/test/resources/META-INF/dust/test.dust"); File out = new File(tmp, "out.js"); DustEngine.main(new String[] { test.getAbsolutePath(), out.getAbsolutePath() }); String expected = "(function(){dust.register(\"test\",body_0);function body_0(chk,ctx){return chk.write(" + "\"Hello \").reference(ctx.get(\"name\"),ctx,\"h\").write(\"! You have \").reference(ctx.get(\"count\")," + "ctx,\"h\").write(\" new messages.\");}return body_0;})();"; assertEquals(expected, FileUtils.readFileToString(out)); }
From source file:hu.bme.mit.trainbenchmark.benchmark.eclipseocl.checkers.EclipseOCLChecker.java
public EclipseOCLChecker(final EMFDriver driver, final BenchmarkConfig bc) throws IOException, ParserException { super();// w w w .j a va2 s . c om this.driver = driver; final String oclQuery = FileUtils.readFileToString(new File(bc.getWorkspacePath() + "/hu.bme.mit.trainbenchmark.benchmark.eclipseocl/src/main/resources/queries/" + bc.getQuery() + ".ocl")); ocl = OCL.newInstance(); final Helper helper = ocl.createOCLHelper(); helper.setContext(getContext()); final OCLExpression query = helper.createQuery(oclQuery); queryEvaluator = ocl.createQuery(query); }
From source file:com.mirth.connect.plugins.datatypes.edi.test.EDISerializerTest.java
@Test public void testIssue1597fromXML() throws Exception { String input = FileUtils.readFileToString(new File("tests/test-1597-input-missing-elements.xml")); String output = FileUtils.readFileToString(new File("tests/test-1597-output.txt")); EDISerializer serializer = new EDISerializer(new EDIDataTypeProperties().getSerializerProperties()); Assert.assertEquals(output, serializer.fromXML(input)); }
From source file:be.fedict.eid.integration.publicws.PublicWebserviceSigningTest.java
@Test public void signCertificateInvalidDN() throws IOException { String contract = FileUtils.readFileToString( new File(getClass().getResource("/xml/CertificateSigningContractInvalidDN.xml").getFile())); trySignCertificate(contract, "869b81cb-805b-4286-9c44-5350831abf82", ResultType.INVALID_MESSAGE); }
From source file:com.properned.application.AboutController.java
public void initialize() throws IOException, URISyntaxException { logger.info("Initialize about controller"); labelApplication.setText(PropernedProperties.getInstance().getApplicationPresentation()); labelAuthorValue.setText(PropernedProperties.getInstance().getAuthor()); try {//from w w w . j a v a 2s. c o m String licence = FileUtils.readFileToString(new File("linkedlibrairies.txt")); textAreaLicence.setText(licence); } catch (IOException e) { Properned.getInstance().showError(MessageReader.getInstance().getMessage("error.load.licenceFile"), e); } }
From source file:com.github.terma.jenkins.githubprcoveragestatus.JacocoParser.java
@Override public float get(final String jacocoFilePath) { final String content; try {//from w ww. j a v a2 s .c o m content = FileUtils.readFileToString(new File(jacocoFilePath)); } catch (IOException e) { throw new IllegalArgumentException("Can't read Jacoco report by path: " + jacocoFilePath); } final float lineMissed = getByXpath(jacocoFilePath, content, MISSED_XPATH); final float lineCovered = getByXpath(jacocoFilePath, content, COVERAGE_XPATH); final float lines = lineCovered + lineMissed; if (lines == 0) { return 0; } else { return lineCovered / (lines); } }
From source file:de.tsystems.mms.apm.performancesignature.dynatrace.ActivateConfigurationTest.java
@Test public void testJenkinsConfiguration() throws Exception { FreeStyleProject project = j.createFreeStyleProject(); project.getBuildersList().add(/*from ww w . ja va 2 s.c om*/ new PerfSigActivateConfiguration(dynatraceConfigurations.get(0).name, "ActivateConfigurationTest")); FreeStyleBuild build = j.assertBuildStatusSuccess(project.scheduleBuild2(0)); String s = FileUtils.readFileToString(build.getLogFile()); assertTrue(s.contains("activated configuration successfully on")); }