@Test
  public void testFileRead() throws FileNotFoundException {
    // open our file
    FileInputStream stream = new FileInputStream(mSampleFile);
    mHandler = new InputOutputStreamHandler(stream, null, true);

    int retval = 0;
    retval = mHandler.open(mSampleFile, IURLProtocolHandler.URL_RDONLY_MODE);
    assertTrue(retval >= 0);

    long bytesRead = 0;

    byte[] buffer = new byte[1024];
    while ((retval = mHandler.read(buffer, buffer.length)) > 0) {
      bytesRead += retval;
    }
    // and close
    retval = mHandler.close();
    assertTrue(retval >= 0);
    assertEquals(4546420, bytesRead);
  }
  @Test
  public void testFileWrite() throws FileNotFoundException {

    String copyFile = this.getClass().getName() + "_" + this.getName() + ".flv";

    FileInputStream inStream = new FileInputStream(mSampleFile);
    FileOutputStream outStream = new FileOutputStream(copyFile);
    mHandler = new InputOutputStreamHandler(null, outStream, true);
    int retval = 0;

    // First, open the write mHandler.
    retval = mHandler.open(copyFile, IURLProtocolHandler.URL_WRONLY_MODE);
    assertTrue(retval >= 0);

    // Now, create and open a read mHandler.
    // note that without a protocol string, should default to file:
    IURLProtocolHandler reader = new InputOutputStreamHandler(inStream, null, true);
    retval = reader.open(null, IURLProtocolHandler.URL_RDONLY_MODE);

    long bytesWritten = 0;
    long totalBytes = 0;

    byte[] buffer = new byte[1024];
    while ((retval = reader.read(buffer, buffer.length)) > 0) {
      totalBytes += retval;
      // Write the output.
      retval = mHandler.write(buffer, retval);
      assertTrue(retval >= 0);
      bytesWritten += retval;
    }
    assertEquals(totalBytes, bytesWritten);
    assertEquals(4546420, totalBytes);

    // close each file
    retval = reader.close();
    assertTrue(retval >= 0);

    retval = mHandler.close();
    assertTrue(retval >= 0);
  }