Updated file test
Some checks failed
Locusworks Team/commons/pipeline/head There was a failure building this commit

This commit is contained in:
Isaac Parenteau
2020-05-22 23:16:55 -05:00
parent 526a5b3dbd
commit c7c3f3c6bd
3 changed files with 10 additions and 8 deletions

View File

@ -89,7 +89,7 @@ public class KeyFile implements AutoCloseable {
try { try {
this.key = ksh.isPrivate() ? kf.generatePrivateKey(ksh.getKeySpec()) : kf.generatePublicKey(ksh.getKeySpec()); this.key = ksh.isPrivate() ? kf.generatePrivateKey(ksh.getKeySpec()) : kf.generatePublicKey(ksh.getKeySpec());
this.encryptionType = ksh.getEncryptionType(); this.encryptionType = ksh.getEncryptionType();
return; break;
} catch (NullPointerException | InvalidKeySpecException ikse) { continue; } } catch (NullPointerException | InvalidKeySpecException ikse) { continue; }
} }

View File

@ -20,7 +20,7 @@ import net.locusworks.common.interfaces.AutoCloseableIterator;
* @version 1.0.0 * @version 1.0.0
* @date 02/15/2018 * @date 02/15/2018
*/ */
public class FileReader implements AutoCloseableIterator<FileReader.LineInfo>, Iterable<FileReader.LineInfo> { public class FileReader implements AutoCloseableIterator<FileReader.LineInfo>, Iterable<FileReader.LineInfo>, AutoCloseable {
private BufferedReader reader; private BufferedReader reader;
private LineInfo info; private LineInfo info;

View File

@ -49,12 +49,14 @@ public class FileReaderTest {
@Test @Test
public void testForLoop() { public void testForLoop() {
Integer lineCount = 0; Integer lineCount = 0;
for(LineInfo s : new FileReader(Paths.get(TEST_FILE))) { try (FileReader fr = new FileReader(Paths.get(TEST_FILE))) {
lineCount++; for (LineInfo s : fr) {
Integer lineNumber = s.getLineNumber(); lineCount++;
Integer lineLength = s.getLine().length(); Integer lineNumber = s.getLineNumber();
Integer mapLineLength = numLines.get(lineNumber); Integer lineLength = s.getLine().length();
assertTrue(lineLength == (mapLineLength-1)); Integer mapLineLength = numLines.get(lineNumber);
assertTrue(lineLength == (mapLineLength-1));
}
} }
assertTrue(lineCount == numLines.size()); assertTrue(lineCount == numLines.size());
} }