List of usage examples for org.apache.commons.io FileUtils writeLines
public static void writeLines(File file, Collection lines) throws IOException
toString()
value of each item in a collection to the specified File
line by line. From source file:org.openengsb.core.workflow.drools.deployer.WorkflowDeployerServiceTest.java
@Test public void testInstallGlobals_shouldAddGlobals() throws Exception { File globalfile = temporaryFolder.newFile("test1.global"); FileUtils.writeLines(globalfile, Arrays.asList(Logger.class.getName() + " logger", "")); workflowDeployer.install(globalfile); verify(ruleManager).addGlobal(Logger.class.getName(), "logger"); }
From source file:org.openengsb.core.workflow.drools.deployer.WorkflowDeployerServiceTest.java
@Test public void testInstallImportsAndGlobalsRequiredByRule_shouldParseCorrectly() throws Exception { setupWithRealCompiler();//from w ww . jav a 2 s. c om File importFile = temporaryFolder.newFile("test1.import"); FileUtils.writeLines(importFile, Arrays.asList(Event.class.getName(), BigInteger.class.getName(), "")); workflowDeployer.install(importFile); File globalFile = temporaryFolder.newFile("test1.global"); FileUtils.writeLines(globalFile, Arrays.asList(Logger.class.getName() + " logger", "")); workflowDeployer.install(globalFile); File testRuleFile = temporaryFolder.newFile("test1.rule"); FileUtils.writeLines(testRuleFile, Arrays.asList("when", " Event()", "then", " BigInteger i = new BigInteger(1);", " logger.info(i.toString());", "")); workflowDeployer.install(testRuleFile); }
From source file:org.openengsb.core.workflow.drools.deployer.WorkflowDeployerServiceTest.java
@Test public void testInstallWrongOrder_shouldAttemptInstallAgain() throws Exception { setupWithRealCompiler();// w w w . j a v a 2 s . c om final File importFile = temporaryFolder.newFile("test1.import"); FileUtils.writeLines(importFile, Arrays.asList(Event.class.getName(), BigInteger.class.getName(), Logger.class.getName(), "")); final File globalFile = temporaryFolder.newFile("test1.global"); FileUtils.writeLines(globalFile, Arrays.asList(List.class.getName() + " listtest", Logger.class.getSimpleName() + " logger", "")); final File testRuleFile = temporaryFolder.newFile("test1.rule"); FileUtils.writeLines(testRuleFile, Arrays.asList("when", " Event()", "then", " BigInteger i = new BigInteger(1);", " logger.info(i.toString());", "")); workflowDeployer.install(testRuleFile); workflowDeployer.install(globalFile); workflowDeployer.install(importFile); assertThat(ruleManager.get(new RuleBaseElementId(RuleBaseElementType.Rule, "test1")), not(nullValue())); }
From source file:org.openengsb.core.workflow.drools.deployer.WorkflowDeployerServiceTest.java
@Test public void testUninstallGlobal_shouldRemoveGlobal() throws Exception { final File globalFile = temporaryFolder.newFile("test1.global"); FileUtils.writeLines(globalFile, Arrays.asList(Logger.class.getName() + " logger", "")); workflowDeployer.install(globalFile); globalFile.delete();//from w w w . j av a 2 s. co m workflowDeployer.uninstall(globalFile); assertThat(ruleManager.listGlobals().keySet(), not(hasItem("logger"))); }
From source file:org.openengsb.core.workflow.drools.deployer.WorkflowDeployerServiceTest.java
@Test public void testUninstallImport_shouldRemoveImport() throws Exception { File importFile = temporaryFolder.newFile("test1.import"); FileUtils.writeLines(importFile, Arrays.asList(Event.class.getName(), BigInteger.class.getName(), "")); workflowDeployer.install(importFile); importFile.delete();/*from w w w. ja v a2 s .co m*/ workflowDeployer.uninstall(importFile); verify(ruleManager).removeImport(BigInteger.class.getName()); }
From source file:org.openengsb.core.workflow.drools.deployer.WorkflowDeployerServiceTest.java
@Test public void updateImport_shouldAddImports() throws Exception { File importFile = temporaryFolder.newFile("test1.import"); FileUtils.writeLines(importFile, Arrays.asList(Event.class.getName(), BigInteger.class.getName(), "")); workflowDeployer.install(importFile); FileUtils.writeLines(importFile,/*from w ww . j a v a 2s. c o m*/ Arrays.asList(Event.class.getName(), BigInteger.class.getName(), Number.class.getName(), "")); workflowDeployer.update(importFile); verify(ruleManager).addImport(Number.class.getName()); }
From source file:org.openengsb.persistence.rulebase.filebackend.ImportDeclarationPersistenceBackendService.java
private void writeStorageFile(List<String> imports) throws PersistenceException { LOGGER.debug("write imports to \"{}\"", storageFile); try {// ww w . j a v a2 s .co m FileUtils.writeLines(storageFile, imports); } catch (IOException e) { throw new PersistenceException(e); } }
From source file:org.openestate.tool.helloworld.db.hsql.HSqlDbHelloWorldExtension.java
private static SqlFile readHsqlFile(String file) throws IOException { // read query from a resource file try (InputStream input = getResourceAsStream(file)) { List<String> lines = IOUtils.readLines(input, "UTF-8"); // write query into a temporary file File tempFile = File.createTempFile("helloworld.", ".sql"); tempFile.deleteOnExit();//from ww w. j a v a 2 s. co m FileUtils.writeLines(tempFile, lines); // create a SQL file return new SqlFile(tempFile, "UTF-8"); } }
From source file:org.opensilk.music.AppPreferences.java
public static boolean writeAutoShuffleDirectory(Context context, String directory) { try {/*from w w w .j av a 2s . c om*/ File f = new File(context.getFilesDir(), AUTO_SHUFFLE_FOLDER); FileUtils.writeLines(f, Collections.singleton(directory)); return true; } catch (IOException e) { return false; } }
From source file:org.ow2.proactive.scheduler.authentication.ManageUsersTest.java
private void createBulkUsers() throws Exception { FileUtils.writeLines(sourceLoginFile, sourceUsers1); FileUtils.writeLines(sourceGroupFile, sourceGroups1); ManageUsers.manageUsers("-" + ManageUsers.CREATE_OPTION, "-" + ManageUsers.SOURCE_LOGINFILE_OPTION, sourceLoginFile.getAbsolutePath(), "-" + ManageUsers.SOURCE_GROUPFILE_OPTION, sourceGroupFile.getAbsolutePath(), "-" + ManageUsers.LOGINFILE_OPTION, loginFile.getAbsolutePath(), "-" + ManageUsers.GROUPFILE_OPTION, groupFile.getAbsolutePath(), "-" + ManageUsers.KEYFILE_OPTION, publicKeyFile.getAbsolutePath()); validateContents(users, groups);/* w ww . ja va 2 s . c o m*/ }