### Question:
FileRecordStore { public boolean put(final String record) throws IOException { boolean success = false; BufferedWriter writer = null; accessLock.lock(); try { writer = tryInitializeWriter(); if (recordFile.length() + record.getBytes(StringUtils.UTF8).length <= maxStorageSize) { writer.write(record); writer.newLine(); writer.flush(); success = true; } } finally { if (writer != null) { writer.close(); } accessLock.unlock(); } return success; } FileRecordStore(File workDirectory, String recordFileName, long maxStorageSize); boolean put(final String record); long getFileSize(); RecordIterator iterator();  }### Answer:
@Test public void testWhenRecordssFileIsMissingAndRecordssDirectoryIsReadOnly_error() throws IOException { File kinesisDirectory = null; try { File eventDirectory = null; FileManager fileManager = new FileManager(TEST_DIRECTORY); FileRecordStore recordStore = new FileRecordStore(TEST_DIRECTORY, RECORDER_FILE_NAME, MAX_STORAGE_SIZE); kinesisDirectory = fileManager.createDirectory(Constants.RECORDS_DIRECTORY); File recordsFile = new File(eventDirectory, Constants.RECORDS_FILE_NAME); fileManager.deleteFile(recordsFile); kinesisDirectory.setReadOnly(); recordStore.put("2"); } finally { if (kinesisDirectory != null && kinesisDirectory.exists()) { kinesisDirectory.setWritable(true); kinesisDirectory.delete(); } } }
@Test public void testWhenWritingExceedsMaxStorageSize_noMoreRecordsWritten() throws IOException { File recordsDirectory = null; File recordsFile = null; FileManager fileManager = new FileManager(TEST_DIRECTORY); FileRecordStore recordStore = new FileRecordStore(TEST_DIRECTORY, RECORDER_FILE_NAME, 100L); recordsDirectory = fileManager.getDirectory(Constants.RECORDS_DIRECTORY); recordsFile = new File(recordsDirectory, Constants.RECORDS_FILE_NAME); for (int i = 0; i < 10; i++) { recordStore.put("ten bytes"); } assertSame(recordsFile.length(), 100L); recordStore.put("0123456789"); assertSame(recordsFile.length(), 100L); }