### Question:
PrincetonResourceDictionaryFile extends AbstractPrincetonRandomAccessDictionaryFile implements DictionaryFileFactory<PrincetonResourceDictionaryFile> { @Override public PointedCharSequence readLine(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 null; } int i = loffset; while (i < buffer.length && '\n' != buffer[i]) { i++; } final PointedCharSequence result; if (null == encoding) { result = new ByteArrayCharSequence(buffer, loffset, i, i); } else { final ByteBuffer bb = ByteBuffer.wrap(buffer, loffset, i - loffset); try { synchronized (this) { CharBuffer cb = decoder.decode(bb); result = new CharBufferCharSequence(cb, i); } } catch (CharacterCodingException e) { throw new JWNLIOException(dictionary.getMessages().resolveMessage("PRINCETON_EXCEPTION_003", new Object[]{getFilename(), loffset}), e); } } 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 testReadLinePre() throws JWNLException, NoSuchFieldException, IllegalAccessException { initPRADF(null, "readLineASCII.txt"); assertNull(pradf.readLine(-1)); assertNull(pradf.readLine(Integer.MAX_VALUE)); }
@Test(expected = JWNLException.class) public void testReadLineJWNLException() throws JWNLException, NoSuchFieldException, IllegalAccessException { initPRADF(null, "readLineASCII.txt"); Field field = PrincetonResourceDictionaryFile.class.getDeclaredField("buffer"); 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 { initPRADF(null, "readLineASCII.txt"); 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 { initPRADF("UTF-8", "readLineUTF.txt"); PointedCharSequence sequence = pradf.readLine(o); assertNotNull(sequence); assertEquals(s, sequence.toString()); assertEquals(p, sequence.getLastBytePosition()); }