|
@@ -19,7 +19,6 @@
|
19
|
19
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
20
|
20
|
* SOFTWARE.
|
21
|
21
|
*/
|
22
|
|
-
|
23
|
22
|
package com.dmdirc.util.io;
|
24
|
23
|
|
25
|
24
|
import java.io.File;
|
|
@@ -30,7 +29,9 @@ import java.util.Map;
|
30
|
29
|
import org.junit.Before;
|
31
|
30
|
import org.junit.Test;
|
32
|
31
|
|
33
|
|
-import static org.junit.Assert.*;
|
|
32
|
+import static org.junit.Assert.assertEquals;
|
|
33
|
+import static org.junit.Assert.assertFalse;
|
|
34
|
+import static org.junit.Assert.assertTrue;
|
34
|
35
|
|
35
|
36
|
public class ConfigFileTest {
|
36
|
37
|
|
|
@@ -46,7 +47,7 @@ public class ConfigFileTest {
|
46
|
47
|
cf.read();
|
47
|
48
|
}
|
48
|
49
|
|
49
|
|
- @Test(expected=UnsupportedOperationException.class)
|
|
50
|
+ @Test(expected = UnsupportedOperationException.class)
|
50
|
51
|
public void testWrite() throws IOException {
|
51
|
52
|
cf.write();
|
52
|
53
|
}
|
|
@@ -99,6 +100,7 @@ public class ConfigFileTest {
|
99
|
100
|
@Test
|
100
|
101
|
public void testColons() throws IOException, InvalidConfigFileException {
|
101
|
102
|
final File file = File.createTempFile("DMDirc.unittest", null);
|
|
103
|
+ file.deleteOnExit();
|
102
|
104
|
ConfigFile config = new ConfigFile(file);
|
103
|
105
|
Map<String, String> data = new HashMap<>();
|
104
|
106
|
data.put("test1", "hello");
|
|
@@ -120,6 +122,7 @@ public class ConfigFileTest {
|
120
|
122
|
@Test
|
121
|
123
|
public void testEquals() throws IOException, InvalidConfigFileException {
|
122
|
124
|
final File file = File.createTempFile("DMDirc.unittest", null);
|
|
125
|
+ file.deleteOnExit();
|
123
|
126
|
ConfigFile config = new ConfigFile(file);
|
124
|
127
|
Map<String, String> data = new HashMap<>();
|
125
|
128
|
data.put("test1", "hello");
|
|
@@ -141,6 +144,7 @@ public class ConfigFileTest {
|
141
|
144
|
@Test
|
142
|
145
|
public void testNewlines() throws IOException, InvalidConfigFileException {
|
143
|
146
|
final File file = File.createTempFile("DMDirc.unittest", null);
|
|
147
|
+ file.deleteOnExit();
|
144
|
148
|
ConfigFile config = new ConfigFile(file);
|
145
|
149
|
Map<String, String> data = new HashMap<>();
|
146
|
150
|
data.put("test1", "hello");
|
|
@@ -164,6 +168,7 @@ public class ConfigFileTest {
|
164
|
168
|
@Test
|
165
|
169
|
public void testBackslash() throws IOException, InvalidConfigFileException {
|
166
|
170
|
final File file = File.createTempFile("DMDirc.unittest", null);
|
|
171
|
+ file.deleteOnExit();
|
167
|
172
|
ConfigFile config = new ConfigFile(file);
|
168
|
173
|
Map<String, String> data = new HashMap<>();
|
169
|
174
|
data.put("test1", "hello\\");
|
|
@@ -185,6 +190,7 @@ public class ConfigFileTest {
|
185
|
190
|
@Test
|
186
|
191
|
public void testHash() throws IOException, InvalidConfigFileException {
|
187
|
192
|
final File file = File.createTempFile("DMDirc.unittest", null);
|
|
193
|
+ file.deleteOnExit();
|
188
|
194
|
ConfigFile config = new ConfigFile(file);
|
189
|
195
|
Map<String, String> data = new HashMap<>();
|
190
|
196
|
data.put("test1#", "hello");
|
|
@@ -219,6 +225,7 @@ public class ConfigFileTest {
|
219
|
225
|
@Test
|
220
|
226
|
public void testDelete() throws IOException {
|
221
|
227
|
final File file = File.createTempFile("DMDirc_unittest", null);
|
|
228
|
+ file.deleteOnExit();
|
222
|
229
|
ConfigFile config = new ConfigFile(file);
|
223
|
230
|
config.write();
|
224
|
231
|
assertTrue(file.exists());
|
|
@@ -236,10 +243,10 @@ public class ConfigFileTest {
|
236
|
243
|
assertTrue(file.isFlatDomain("section one point one"));
|
237
|
244
|
}
|
238
|
245
|
|
239
|
|
- @Test(expected=InvalidConfigFileException.class)
|
|
246
|
+ @Test(expected = InvalidConfigFileException.class)
|
240
|
247
|
public void testInvalidLine() throws IOException, InvalidConfigFileException {
|
241
|
248
|
final ConfigFile file = new ConfigFile(getClass().getResourceAsStream("test1.txt"));
|
242
|
249
|
file.read();
|
243
|
250
|
}
|
244
|
251
|
|
245
|
|
-}
|
|
252
|
+}
|