### Question:
FileIOOperationsAOImpl extends IRODSGenericAO implements FileIOOperations { @Override public int write(final int fd, final byte buffer[], final int offset, final int length) throws JargonException { if (fd <= 0) { throw new IllegalArgumentException("file is not open, file descriptor was less than zero:" + fd); } if (buffer == null || buffer.length == 0) { throw new IllegalArgumentException("null or empty buffer"); } if (offset < 0) { throw new IllegalArgumentException("offset less than zero"); } if (length <= 0) { throw new IllegalArgumentException("zero or negative length"); } if (offset > length) { throw new IllegalArgumentException("offset of:" + offset + " is > length:" + length); } if (offset > buffer.length) { throw new IllegalArgumentException( "offset of:" + offset + " is greater than the buffer length of:" + buffer.length); } if (log.isDebugEnabled()) { log.debug("attempting to write to fd:" + fd + " a buffer with a size of " + buffer.length + " using a length of " + length + " and an offset of " + offset); } OpenedDataObjInp openedDataObjInp = OpenedDataObjInp.instanceForFileWrite(fd, offset, length); Tag message = getIRODSProtocol().irodsFunction(IRODSConstants.RODS_API_REQ, openedDataObjInp.getParsedTags(), null, 0, 0, buffer, offset, length, openedDataObjInp.getApiNumber()); return message.getTag(IRODSConstants.MsgHeader_PI).getTag(IRODSConstants.intInfo).getIntValue(); } FileIOOperationsAOImpl(final IRODSSession irodsSession, final IRODSAccount irodsAccount); @Override int write(final int fd, final byte buffer[], final int offset, final int length); @Override int fileRead(final int fd, final OutputStream destination, long length); @Override int fileRead(final int fd, final byte buffer[], final int offset, int length); @Override long seek(final int fd, final long seek, final SeekWhenceType whence); @Override ChecksumValue computeChecksumOnIrodsFile(final String irodsFileAbsolutePath);  }### Answer:
@Test public final void testWrite() throws Exception { String testFileName = "testFileWriteByteArrayx.csv"; String targetIrodsCollection = testingPropertiesHelper .buildIRODSCollectionAbsolutePathFromTestProperties(testingProperties, IRODS_TEST_SUBDIR_PATH); IRODSAccount irodsAccount = testingPropertiesHelper.buildIRODSAccountFromTestProperties(testingProperties); IRODSAccessObjectFactory accessObjectFactory = irodsFileSystem.getIRODSAccessObjectFactory(); IRODSFileFactory irodsFileFactory = accessObjectFactory .getIRODSFileFactory(irodsAccount); IRODSFile irodsFile = irodsFileFactory.instanceIRODSFile(targetIrodsCollection + '/' + testFileName); boolean created = irodsFile.createNewFile(); Assert.assertTrue("file was not created, cannot proceed", created); Assert.assertTrue("file I created is not a file", irodsFile.isFile()); Assert.assertTrue("i cannot write an output stream", irodsFile.canWrite()); FileIOOperations fileIOOperationsAO = new FileIOOperationsAOImpl(irodsFileSystem.getIrodsSession(), irodsAccount); String myBytes = "ajjjjjjjjjjjjjjjjjjjjjjjjfeiiiiiiiiiiiiiii54454545"; byte[] myBytesArray = myBytes.getBytes(); irodsFile.open(); fileIOOperationsAO.write(irodsFile.getFileDescriptor(), myBytesArray, 0, myBytesArray.length); irodsFile.close(); irodsFile.open(); long length = irodsFile.length(); irodsFile.close(); assertionHelper.assertIrodsFileOrCollectionExists(irodsFile.getAbsolutePath(), accessObjectFactory, irodsAccount); Assert.assertEquals("length of file does not match data written", myBytesArray.length, length); }