Browse Source

Merge pull request #35 from greboid/master

Improve TextFile unit test, and remove unused ctor.
pull/36/head
Chris Smith 9 years ago
parent
commit
021c531fe6
2 changed files with 14 additions and 13 deletions
  1. 0
    13
      src/com/dmdirc/util/io/TextFile.java
  2. 14
    0
      test/com/dmdirc/util/io/TextFileTest.java

+ 0
- 13
src/com/dmdirc/util/io/TextFile.java View File

22
 package com.dmdirc.util.io;
22
 package com.dmdirc.util.io;
23
 
23
 
24
 import java.io.BufferedReader;
24
 import java.io.BufferedReader;
25
-import java.io.File;
26
 import java.io.IOException;
25
 import java.io.IOException;
27
 import java.io.InputStream;
26
 import java.io.InputStream;
28
 import java.io.InputStreamReader;
27
 import java.io.InputStreamReader;
55
      */
54
      */
56
     private List<String> lines;
55
     private List<String> lines;
57
 
56
 
58
-    /**
59
-     * Creates a new instance of TextFile for the specified File, which is to be
60
-     * read using the specified charset.
61
-     *
62
-     * @param file The file to read
63
-     * @param charset The charset to read the file in
64
-     * @since 0.6.3m1
65
-     */
66
-    public TextFile(final File file, final Charset charset) {
67
-        this(file == null ? null : file.toPath(), charset);
68
-    }
69
-
70
     /**
57
     /**
71
      * Creates a new instance of TextFile for the specified Path, which is to be
58
      * Creates a new instance of TextFile for the specified Path, which is to be
72
      * read using the specified charset.
59
      * read using the specified charset.

+ 14
- 0
test/com/dmdirc/util/io/TextFileTest.java View File

124
         assertFalse(Files.exists(temp));
124
         assertFalse(Files.exists(temp));
125
     }
125
     }
126
 
126
 
127
+    @Test
128
+    public void testIsWriteable_Stream() throws IOException {
129
+        final TextFile file = new TextFile(Files.newInputStream(test1), Charset.forName("UTF-8"));
130
+        assertFalse(file.isWritable());
131
+    }
132
+
133
+    @Test
134
+    public void testReadLine_Stream() throws IOException {
135
+        final TextFile file = new TextFile(Files.newInputStream(test1), Charset.forName("UTF-8"));
136
+        final List<String> lines = file.getLines();
137
+        assertEquals(7, lines.size());
138
+        assertEquals("Line 1", lines.get(0));
139
+    }
140
+
127
 }
141
 }

Loading…
Cancel
Save