Bladeren bron

Merge pull request #35 from greboid/master

Improve TextFile unit test, and remove unused ctor.
pull/36/head
Chris Smith 9 jaren geleden
bovenliggende
commit
021c531fe6
2 gewijzigde bestanden met toevoegingen van 14 en 13 verwijderingen
  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 Bestand weergeven

@@ -22,7 +22,6 @@
22 22
 package com.dmdirc.util.io;
23 23
 
24 24
 import java.io.BufferedReader;
25
-import java.io.File;
26 25
 import java.io.IOException;
27 26
 import java.io.InputStream;
28 27
 import java.io.InputStreamReader;
@@ -55,18 +54,6 @@ public class TextFile {
55 54
      */
56 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 58
      * Creates a new instance of TextFile for the specified Path, which is to be
72 59
      * read using the specified charset.

+ 14
- 0
test/com/dmdirc/util/io/TextFileTest.java Bestand weergeven

@@ -124,4 +124,18 @@ public class TextFileTest {
124 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
 }

Laden…
Annuleren
Opslaan