### Question:
PrincetonRandomAccessDictionaryFile extends AbstractPrincetonRandomAccessDictionaryFile implements DictionaryFileFactory<PrincetonRandomAccessDictionaryFile>, DictionaryDiskFile { @Override public PointedCharSequence readLine(long offset) throws JWNLException { if (isInvalidOffset(offset)) return null; int LINE_MAX = 64; if (DictionaryFileType.DATA == fileType) { LINE_MAX = 512; } byte[] line = new byte[LINE_MAX]; int i = 0; try { final long tailLength = raFileLength - offset; out: while (i < tailLength) { if (line.length == i) { byte[] t = new byte[line.length * 2]; System.arraycopy(line, 0, t, 0, line.length); line = t; } int readBytes = line.length - i; if (readBytes > tailLength - i) { readBytes = (int) tailLength - i; } synchronized (this) { raFile.seek(offset + i); readBytes = i + raFile.read(line, i, readBytes); } while (i < readBytes) { if ('\n' == line[i]) { break out; } i++; } } } catch (IOException e) { throw new JWNLIOException(e); } return getPointedCharSequence(offset, line, i); } PrincetonRandomAccessDictionaryFile(Dictionary dictionary, Map<String, Param> params);  PrincetonRandomAccessDictionaryFile(Dictionary dictionary, String path, POS pos, DictionaryFileType fileType, Map<String, Param> params); static void formatOffset(long i, int formatLength, StringBuilder target); @Override PrincetonRandomAccessDictionaryFile newInstance(Dictionary dictionary, String path, POS pos, DictionaryFileType fileType); @Override PointedCharSequence readLine(long offset); @Override PointedCharSequence readWord(long offset); @Override long getFirstLineOffset(); @Override long getNextLineOffset(long offset); @Override void open(); @Override boolean isOpen(); @Override void close(); @Override void edit(); @Override long length(); @Override void save(); @Override int getOffsetLength(); @Override void setOffsetLength(int length); @Override File getFile(); @Override boolean delete(); static final String WRITE_PRINCETON_HEADER_KEY; static final String CHECK_LEX_FILE_NUMBER_KEY; static final String CHECK_RELATION_LIMIT_KEY; static final String CHECK_WORD_COUNT_LIMIT_KEY; static final String CHECK_LEX_ID_LIMIT_KEY; static final String CHECK_POINTER_INDEX_LIMIT_KEY; static final String CHECK_VERB_FRAME_LIMIT_KEY; static final String CHECK_DATA_FILE_LINE_LENGTH_LIMIT_KEY; }### Answer:
@Test public void testReadLinePre() throws JWNLException, NoSuchFieldException, IllegalAccessException, IOException { initPRADF(null, bytes); assertNull(pradf.readLine(-1)); assertNull(pradf.readLine(Integer.MAX_VALUE)); }
@Test(expected = JWNLException.class) public void testReadLineJWNLException() throws JWNLException, NoSuchFieldException, IllegalAccessException, IOException { initPRADF(null, bytes); Field field = PrincetonRandomAccessDictionaryFile.class.getDeclaredField("raFile"); field.setAccessible(true); field.set(pradf, null); pradf.readLine(0); }
@Test @UseDataProvider("testReadLine") public void testReadLine(final int o, final String s, final long p) throws JWNLException, NoSuchFieldException, IllegalAccessException, IOException { initPRADF(null, bytes); PointedCharSequence sequence = pradf.readLine(o); assertNotNull(sequence); assertEquals(s, sequence.toString()); assertEquals(p, sequence.getLastBytePosition()); }
@Test @UseDataProvider("testReadLineUTF") public void testReadLineUTF(final int o, final String s, final long p) throws JWNLException, NoSuchFieldException, IllegalAccessException, IOException { initPRADF("UTF-8", utfBytes); PointedCharSequence sequence = pradf.readLine(o); assertNotNull(sequence); assertEquals(s, sequence.toString()); assertEquals(p, sequence.getLastBytePosition()); }