List of usage examples for org.apache.commons.io FileUtils readFileToString
public static String readFileToString(File file) throws IOException
From source file:com.meltmedia.cadmium.blackbox.test.rest.RestApiTest.java
@Parameterized.Parameters public static Collection<Object[]> data() { if (!skip && StringUtils.isEmptyOrNull(token)) { File tokenFile = new File(System.getProperty("user.home"), ".cadmium/github.token"); if (tokenFile.exists()) { try { token = FileUtils.readFileToString(tokenFile); } catch (Exception e) { System.err.println("Failed to attain github rest api token."); }// w w w . j a va 2 s.co m } else { System.err.println("No token exists at path: " + tokenFile.getAbsolutePath()); } } if (!skip && !StringUtils.isEmptyOrNull(token)) { return Arrays.asList(new Object[][] { // System api endpoints /*[0] */ { new StatusPingEndpointTest() }, /*[1] */ { new StatusHealthEndpointTest() }, /*[2] */ { new StatusEndpointTest(token) }, /*[3] */ { new LoggerGetEndpointTest(token) }, /*[4] */ { new LoggerPostEndpointTest(token) }, /*[5] */ { new LoggerNamePostEndpointTest(token) }, /*[6] */ { new LoggerNameGetEndpointTest(token) }, /*[7] */ { new MaintenanceEndpointTest(token, MaintenanceRequest.State.ON) }, /*[8] */ { new MaintenanceEndpointTest(token, MaintenanceRequest.State.OFF) }, /*[9] */ { new HistoryEndpointTest(token) }, /*[10]*/ { new HistoryLimitEndpointTest(token) }, /*[11]*/ { new HistoryFilterEndpointTest(token) }, /*[12]*/ { new HistoryLimitFilterEndpointTest(token) }, /*[13]*/ { new UpdateEndpointTest(token, gitInit) }, /*[14]*/ { new UpdateConfigEndpointTest(token, gitInit) }, /*[15]*/ { new ApiACLEndpointTest(token) }, /*[16]*/ { new AuthenticationManagerEndpointTest(token) }, // Client api endpoints /*[17]*/ { new SearchEndpointTest() } }); } else { return Arrays.asList(new Object[][] {}); } }
From source file:ca.on.oicr.pde.workflows.GATKHaplotypeCallerWorkflowTest.java
@Test public void dryRunRegressionTests() throws IOException, Exception { TestDefinition td = TestDefinition//from ww w . j a va 2s . co m .buildFromJson(FileUtils.readFileToString(new File("src/test/resources/developmentTests.json"))); for (TestDefinition.Test t : td.getTests()) { //disable getting chr_sizes from interval_files Map<String, String> params = new HashMap<>(t.getParameters()); if (!params.containsKey("chr_sizes")) { params.put("chr_sizes", ""); } DryRun d = new DryRun(System.getProperty("bundleDirectory"), params, GATKHaplotypeCallerWorkflow.class); d.buildWorkflowModel(); d.validateWorkflow(); } }
From source file:com.blazemeter.bamboo.MockedAPI.java
public static void userProfile() throws IOException { File jsonFile = new File(TestConstants.RESOURCES + "/getUserEmail_positive.json"); String userProfile = FileUtils.readFileToString(jsonFile); mockServer.when(//from w w w .j a va 2 s . co m request().withMethod("GET").withPath("/api/latest/user").withHeader("Accept", "application/json") .withQueryStringParameters(new Parameter("api_key", TestConstants.MOCKED_USER_KEY_VALID)), unlimited()) .respond(response().withHeader("application/json").withStatusCode(200).withBody(userProfile)); jsonFile = new File(TestConstants.RESOURCES + "/getUserEmail_negative.json"); userProfile = FileUtils.readFileToString(jsonFile); mockServer.when( request().withMethod("GET").withPath("/api/latest/user").withHeader("Accept", "application/json") .withQueryStringParameters(new Parameter("api_key", TestConstants.MOCKED_USER_KEY_INVALID)), unlimited()) .respond(response().withHeader("application/json").withStatusCode(200).withBody(userProfile)); jsonFile = new File(TestConstants.RESOURCES + "/getUserEmail_jexception.txt"); userProfile = FileUtils.readFileToString(jsonFile); mockServer .when(request().withMethod("GET").withPath("/api/latest/user") .withHeader("Accept", "application/json").withQueryStringParameters( new Parameter("api_key", TestConstants.MOCKED_USER_KEY_EXCEPTION)), unlimited()) .respond(response().withHeader("application/json").withStatusCode(200).withBody(userProfile)); mockServer.when( request().withMethod("GET").withPath("/api/latest/user").withHeader("Accept", "application/json") .withQueryStringParameters(new Parameter("api_key", TestConstants.MOCKED_USER_KEY_RETRIES)), unlimited()).respond(response().withHeader("application/json").withStatusCode(200).withBody("")); }
From source file:com.mirth.connect.plugins.datatypes.hl7v2.test.HL7SerializerTest.java
@Test public void testToXmlDefault() throws Exception { String input = FileUtils.readFileToString(new File("tests/test-hl7-input.txt")); String output = FileUtils.readFileToString(new File("tests/test-hl7-output.xml")); ER7Serializer serializer = new ER7Serializer(defaultProperties.getSerializerProperties()); Assert.assertEquals(output, TestUtil.prettyPrintXml(serializer.toXML(input))); }
From source file:coreferenceresolver.gui.MainGUI.java
/** * Creates new form MainGUI//from w w w .ja v a2 s. c o m */ public MainGUI() throws IOException { initComponents(); defaulPath = FileUtils.readFileToString(new File(".\\src\\coreferenceresolver\\gui\\defaultpath")); markupBtn.setEnabled(false); testBtn.setEnabled(false); trainingBtn.setEnabled(false); applyClassifierBtn.setEnabled(false); inputFilePathTF.getDocument().addDocumentListener(new DocumentListener() { // implement the methods public void changedUpdate(DocumentEvent e) { } public void removeUpdate(DocumentEvent e) { if (e.getDocument().getLength() == 0) { markupBtn.setEnabled(false); testBtn.setEnabled(false); trainingBtn.setEnabled(false); applyClassifierBtn.setEnabled(false); } } public void insertUpdate(DocumentEvent e) { markupBtn.setEnabled(true); if (markupFilePathTF.getText() != null && !markupFilePathTF.getText().equals("")) { testBtn.setEnabled(true); trainingBtn.setEnabled(true); } if (testingFilePathTF.getText() != null && !testingFilePathTF.getText().equals("") && trainingFilePathTF.getText() != null && !trainingFilePathTF.getText().equals("")) { applyClassifierBtn.setEnabled(true); } } }); markupFilePathTF.getDocument().addDocumentListener(new DocumentListener() { // implement the methods public void changedUpdate(DocumentEvent e) { } public void removeUpdate(DocumentEvent e) { if (e.getDocument().getLength() == 0) { testBtn.setEnabled(false); trainingBtn.setEnabled(false); } } public void insertUpdate(DocumentEvent e) { if (inputFilePathTF.getText() != null && !inputFilePathTF.getText().equals("")) { testBtn.setEnabled(true); trainingBtn.setEnabled(true); } } }); testingFilePathTF.getDocument().addDocumentListener(new DocumentListener() { // implement the methods public void changedUpdate(DocumentEvent e) { } public void removeUpdate(DocumentEvent e) { if (e.getDocument().getLength() == 0) { applyClassifierBtn.setEnabled(false); } } public void insertUpdate(DocumentEvent e) { if (trainingFilePathTF.getText() != null && !trainingFilePathTF.getText().equals("") && inputFilePathTF.getText() != null && !inputFilePathTF.getText().equals("")) { applyClassifierBtn.setEnabled(true); } } }); trainingFilePathTF.getDocument().addDocumentListener(new DocumentListener() { // implement the methods public void changedUpdate(DocumentEvent e) { } public void removeUpdate(DocumentEvent e) { if (e.getDocument().getLength() == 0) { applyClassifierBtn.setEnabled(false); } } public void insertUpdate(DocumentEvent e) { if (testingFilePathTF.getText() != null && !testingFilePathTF.getText().equals("") && inputFilePathTF.getText() != null && !inputFilePathTF.getText().equals("")) { applyClassifierBtn.setEnabled(true); } } }); inputFilePathTF.setText(defaulPath + File.separatorChar + "input_test.txt"); markupFilePathTF.setText(defaulPath + File.separatorChar + "input_test.txt.markup"); trainingFilePathTF.setText(defaulPath + File.separatorChar + "train.arff"); testingFilePathTF.setText(defaulPath + File.separatorChar + "test.arff"); }
From source file:be.idamediafoundry.sofa.livecycle.maven.GenerateComponentXmlMojoTest.java
@Test public void testExecuteAnnotation() throws Exception { String sourcePath = this.getClass().getResource("/pckg/annotated").getFile(); mojo = new GenerateComponentXmlMojo("host", "port", "protocol", "username", "password", original, result, sourcePath, "annotations"); mojo.execute();/*from ww w. j a v a 2 s. com*/ System.out.println(FileUtils.readFileToString(result)); }
From source file:ca.uqam.mglunit.TestCliParsing.java
@org.junit.Test public void it_writes_to_a_file() throws Exception { String testClassName = "samples.SimpleTestWithAssert"; String outputFilePath = "./build/test." + testClassName + ".txt"; String[] args = { "-o", outputFilePath, testClassName }; Runner.main(args);/*from www. j a v a 2s . co m*/ String contents = FileUtils.readFileToString(new File(outputFilePath)); assertTrue(contents.contains("3 tests completed, 2 failures")); assertTrue(contents.contains("expected:<1> but was:<2>")); assertTrue(contents.contains("expected:<foo> but was:<bar>")); }
From source file:hu.bme.mit.trainbenchmark.benchmark.sesame.queries.SesameQuery.java
public SesameQuery(final TSesameDriver driver, final String workspaceDir, final RailwayQuery query) throws IOException { super(driver, workspaceDir, query); this.queryDefinition = FileUtils.readFileToString(new File(queryPath)); }
From source file:gov.nih.nci.cacis.common.schema.SchemaValidatorTest.java
/** * checks xsd validation with valid xml//from ww w . j a va 2 s . c om * @throws IOException - exception thrown if any */ @Test public void validateValidXML() throws IOException { final String validXmlFile = getClass().getClassLoader().getResource("validXmlForSampleXSD.xml").getFile(); final String xmlString = FileUtils.readFileToString(new File(validXmlFile)); Assert.assertNotNull(xmlString); validator.validate(xmlString); }
From source file:com.genericworkflownodes.knime.nodegeneration.templates.Template.java
/** * reads in the template from file./*from ww w. j av a2 s. c om*/ * * @param file * file * @throws IOException */ public Template(File file) throws IOException { data = FileUtils.readFileToString(file); }