Changeset 1451 for trunk/java-utils-test/src/test/java/de/ugoe/cs
- Timestamp:
- 03/31/14 14:28:53 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/java-utils-test/src/test/java/de/ugoe/cs/util/FileToolsTest.java
r927 r1451 15 15 package de.ugoe.cs.util; 16 16 17 import java.io.File; 18 19 import junitx.framework.FileAssert; 20 17 21 import org.junit.*; 22 18 23 import static org.junit.Assert.*; 19 24 … … 72 77 FileTools.getLinesFromFile(filenameNotExists, false); 73 78 } 79 80 @Test 81 public void testWriteArrayToFile_1() throws Exception { 82 String[] array = new String[]{"foo", "bar"}; 83 String filename = "testdata/de.ugoe.cs.util.FileToolsTest/writeArrayToFile-actual_01.txt"; 84 String separator = ""; 85 boolean lineBreak = false; 86 87 // cleanup old result 88 new File(filename).delete(); 89 90 FileTools.writeArrayToFile(array, filename, separator, lineBreak); 91 92 FileAssert.assertEquals(new File("testdata/de.ugoe.cs.util.FileToolsTest/writeArrayToFile-expected_01.txt"), new File(filename)); 93 94 // cleanup after successful test 95 new File(filename).delete(); 96 } 97 98 @Test 99 public void testWriteArrayToFile_2() throws Exception { 100 String[] array = new String[]{"foo", "bar"}; 101 String filename = "testdata/de.ugoe.cs.util.FileToolsTest/writeArrayToFile-actual_02.txt"; 102 String separator = " - "; 103 boolean lineBreak = false; 104 105 // cleanup old result 106 new File(filename).delete(); 107 108 FileTools.writeArrayToFile(array, filename, separator, lineBreak); 109 110 FileAssert.assertEquals(new File("testdata/de.ugoe.cs.util.FileToolsTest/writeArrayToFile-expected_02.txt"), new File(filename)); 111 112 // cleanup after successful test 113 new File(filename).delete(); 114 } 115 116 @Test 117 public void testWriteArrayToFile_3() throws Exception { 118 String[] array = new String[]{"foo", "bar"}; 119 String filename = "testdata/de.ugoe.cs.util.FileToolsTest/writeArrayToFile-actual_03.txt"; 120 String separator = ""; 121 boolean lineBreak = true; 122 123 // cleanup old result 124 new File(filename).delete(); 125 126 FileTools.writeArrayToFile(array, filename, separator, lineBreak); 127 128 String expectedFile; 129 if( System.getProperty("line.separator").equals("\r\n") ) { 130 expectedFile = "testdata/de.ugoe.cs.util.FileToolsTest/writeArrayToFile-expected_03_cr.txt"; 131 } else { 132 expectedFile = "testdata/de.ugoe.cs.util.FileToolsTest/writeArrayToFile-expected_03_nocr.txt"; 133 } 134 135 FileAssert.assertEquals(new File(expectedFile), new File(filename)); 136 137 // cleanup after successful test 138 new File(filename).delete(); 139 } 74 140 75 141 public static void main(String[] args) {
Note: See TracChangeset
for help on using the changeset viewer.