harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew Zhang (JIRA)" <j...@apache.org>
Subject [jira] Created: (HARMONY-941) [classlib][nio] compatibility: java.nio.channels.FileChannel.truncate, transferTo throw different exeptions from RI.
Date Fri, 21 Jul 2006 08:39:13 GMT
[classlib][nio] compatibility: java.nio.channels.FileChannel.truncate, transferTo  throw different
exeptions from RI.
---------------------------------------------------------------------------------------------------------------------

                 Key: HARMONY-941
                 URL: http://issues.apache.org/jira/browse/HARMONY-941
             Project: Harmony
          Issue Type: Bug
          Components: Classlib
            Reporter: Andrew Zhang


java.nio.channels.FileChannel.truncate, transferTo  throw different exeptions from RI.

Following tests reproduce the problems:

    public void test_truncateJ_Exception() throws Exception {
        File testFile = File.createTempFile("test", "tmp");
        testFile.deleteOnExit();
        FileChannel readOnlyFileChannel = new FileInputStream(testFile)
                .getChannel();
        try {
            readOnlyFileChannel.truncate(-1);
            fail("should throw IllegalArgumentException");
        } catch (IllegalArgumentException e) {
            // expected
        }
  }

  public void test_transferTo_Exception() throws Exception {
        File testFile1 = File.createTempFile("test", "tmp");
        File testFile2 = File.createTempFile("test", "tmp");
        testFile1.deleteOnExit();
        testFile2.deleteOnExit();
        FileChannel readOnlyFileChannel = new FileInputStream(testFile1)
                .getChannel();
        FileChannel readWriteFileChannel = new RandomAccessFile(testFile2, "rw")
                .getChannel();
        // first throws NonWritableChannelException even arguments are illegal.
        try {
            readWriteFileChannel.transferTo(-1, 10, readOnlyFileChannel);
            fail("should throw NonWritableChannelException.");
        } catch (NonWritableChannelException e) {
            // expected
        }

        try {
            readWriteFileChannel.transferTo(0, -1, readOnlyFileChannel);
            fail("should throw NonWritableChannelException.");
        } catch (NonWritableChannelException e) {
            // expected
        }
  }

Both tests pass against RI while fail against Harmony.

I'll upload to fix these problems soon.

Best regards,
Andrew

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message