You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by hi...@apache.org on 2010/06/23 10:19:42 UTC

svn commit: r957142 - /harmony/enhanced/java/trunk/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/RandomAccessFileTest.java

Author: hindessm
Date: Wed Jun 23 08:19:42 2010
New Revision: 957142

URL: http://svn.apache.org/viewvc?rev=957142&view=rev
Log:
Add regression test for "[#HARMONY-6542] java.io.RandomAccessFile.seek
(long pos) throughs exception on calls with 'pos' set to values
greater then 0x7FFFFFFF".  Only works for unix platforms but that's better
than not having one.

Modified:
    harmony/enhanced/java/trunk/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/RandomAccessFileTest.java

Modified: harmony/enhanced/java/trunk/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/RandomAccessFileTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/RandomAccessFileTest.java?rev=957142&r1=957141&r2=957142&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/RandomAccessFileTest.java (original)
+++ harmony/enhanced/java/trunk/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/RandomAccessFileTest.java Wed Jun 23 08:19:42 2010
@@ -1001,6 +1001,34 @@ public class RandomAccessFileTest extend
         raf.close();
     }
 
+    // Regression test for HARMONY-6542
+    public void testRandomAccessFile_seekMoreThan2gb() throws IOException {
+        if (File.separator != "/") {
+            // skip windows until a test can be implemented that doesn't
+            // require 2GB of free disk space
+            return;
+        }
+        // (all?) unix platforms support sparse files so this should not
+        // need to have 2GB free disk space to pass
+        RandomAccessFile raf = new RandomAccessFile(f, "rw");
+        // write a few bytes so we get more helpful error messages
+        // if we land in the wrong places
+        raf.write(1);
+        raf.write(2);
+        raf.seek(2147483647);
+        raf.write(3);
+        raf.write(4);
+        raf.write(5);
+        raf.write(6);
+        raf.seek(0);
+        assertEquals("seek 0", 1, raf.read());
+        raf.seek(2147483649L);
+        assertEquals("seek >2gb", 5, raf.read());
+        raf.seek(0);
+        assertEquals("seek back to 0", 1, raf.read());
+        raf.close();
+    }
+
     /**
      * Sets up the fixture, for example, open a network connection. This method
      * is called before a test is executed.



Re: svn commit: r957142 - /harmony/enhanced/java/trunk/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/RandomAccessFileTest.java

Posted by Tim Ellison <t....@gmail.com>.
On 23/Jun/2010 09:19, hindessm@apache.org wrote:
> +        if (File.separator != "/") {

or consider system property "os.name"?

> +            // skip windows until a test can be implemented that doesn't
> +            // require 2GB of free disk space
> +            return;
> +        }
> +        // (all?) unix platforms support sparse files so this should not
> +        // need to have 2GB free disk space to pass

<shudder/>