### Question:
PrincetonResourceDictionaryFile extends AbstractPrincetonRandomAccessDictionaryFile implements DictionaryFileFactory<PrincetonResourceDictionaryFile> { @Override public long getNextLineOffset(long offset) throws JWNLException { if (!isOpen()) { throw new JWNLException(dictionary.getMessages().resolveMessage("PRINCETON_EXCEPTION_001")); } int loffset = (int) offset; if (loffset >= buffer.length || loffset < 0) { return -1; } int i = loffset; while (i < buffer.length && '\n' != buffer[i]) { i++; } long result = i + 1; if (result >= buffer.length) { result = -1; } return result; } PrincetonResourceDictionaryFile(Dictionary dictionary, Map<String, Param> params);  PrincetonResourceDictionaryFile(Dictionary dictionary, String path, POS pos, DictionaryFileType fileType, Map<String, Param> params); @Override PrincetonResourceDictionaryFile newInstance(Dictionary dictionary, String path, POS pos, DictionaryFileType fileType); @Override void open(); @Override boolean isOpen(); @Override void close(); @Override void save(); @Override void edit(); @Override long getFirstLineOffset(); @Override long getNextLineOffset(long offset); @Override int getOffsetLength(); @Override void setOffsetLength(int length); @Override PointedCharSequence readLine(long offset); @Override PointedCharSequence readWord(long offset); long length(); static void copyStream(InputStream input, OutputStream output);  }### Answer:
@Test public void testGetNextLineOffsetPre() throws JWNLException, NoSuchFieldException, IllegalAccessException { initPRADF(null, "readLineASCII.txt"); assertEquals(-1, pradf.getNextLineOffset(-1)); assertEquals(-1, pradf.getNextLineOffset(Integer.MAX_VALUE)); }
@Test(expected = JWNLException.class) public void testGetNextLineOffsetJWNLException() throws JWNLException, NoSuchFieldException, IllegalAccessException { initPRADF(null, "readLineASCII.txt"); Field field = PrincetonResourceDictionaryFile.class.getDeclaredField("buffer"); field.setAccessible(true); field.set(pradf, null); pradf.getNextLineOffset(0); }
@Test @UseDataProvider("testGetNextLineOffset") public void testGetNextLineOffset(final int x, final int y) throws JWNLException, NoSuchFieldException, IllegalAccessException { initPRADF(null, "readLineASCII.txt"); assertEquals(y, pradf.getNextLineOffset(x)); }