### Question:
PrincetonResourceDictionaryFile extends AbstractPrincetonRandomAccessDictionaryFile implements DictionaryFileFactory<PrincetonResourceDictionaryFile> { @Override public long getFirstLineOffset() throws JWNLException { if (-1 == firstLineOffset) { synchronized (this) { if (-1 == firstLineOffset) { if (!isOpen()) { throw new JWNLException(dictionary.getMessages().resolveMessage("PRINCETON_EXCEPTION_001")); } int i = 0; boolean eol = true; while (i < buffer.length) { if (eol && ' ' != buffer[i]) { break; } eol = '\n' == buffer[i]; i++; } firstLineOffset = i; } } } return firstLineOffset; } 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(expected = JWNLException.class) public void testGetFirstLineOffsetJWNLException() throws JWNLException, NoSuchFieldException, IllegalAccessException { initPRADF(null, "firstLineOffset.txt"); Field field = PrincetonResourceDictionaryFile.class.getDeclaredField("buffer"); field.setAccessible(true); field.set(pradf, null); pradf.getFirstLineOffset(); }
@Test public void testGetFirstLineOffset() throws NoSuchFieldException, IllegalAccessException, JWNLException { initPRADF(null, "firstLineOffset.txt"); assertEquals(2210, pradf.getFirstLineOffset()); assertEquals(2210, pradf.getFirstLineOffset()); assertEquals("line", pradf.readLine(2210).toString()); initPRADF(null, "readLineASCII.txt"); assertEquals(0, pradf.getFirstLineOffset()); }