harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zhouke...@apache.org
Subject svn commit: r933137 - in /harmony/enhanced/java/trunk/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io: FileInputStreamTest.java FileOutputStreamTest.java RandomAccessFileTest.java
Date Mon, 12 Apr 2010 08:21:46 GMT
Author: zhoukevin
Date: Mon Apr 12 08:21:46 2010
New Revision: 933137

URL: http://svn.apache.org/viewvc?rev=933137&view=rev
Log:
Add test cases to constructors of FileInputStream/FileOutputStream/RandomAccessFileTest classes
for coverage.

Modified:
    harmony/enhanced/java/trunk/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileInputStreamTest.java
    harmony/enhanced/java/trunk/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileOutputStreamTest.java
    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/FileInputStreamTest.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/FileInputStreamTest.java?rev=933137&r1=933136&r2=933137&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileInputStreamTest.java
(original)
+++ harmony/enhanced/java/trunk/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileInputStreamTest.java
Mon Apr 12 08:21:46 2010
@@ -19,10 +19,11 @@ package org.apache.harmony.luni.tests.ja
 
 import java.io.File;
 import java.io.FileInputStream;
-import java.io.InputStreamReader;
+import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.FilePermission;
 import java.io.IOException;
+import java.io.InputStreamReader;
 import java.security.Permission;
 
 import junit.framework.TestCase;
@@ -66,6 +67,32 @@ public class FileInputStreamTest extends
     }
 
     /**
+     * @tests java.io.FileInputStream#FileInputStream(java.lang.String)
+     */
+    public void test_ConstructorLjava_lang_String_I() throws IOException {
+        try {
+            is = new FileInputStream("");
+            fail("should throw FileNotFoundException.");
+        } catch (FileNotFoundException e) {
+            // Expected
+        } finally {
+            if (is != null) {
+                is.close();
+            }
+        }
+        try {
+            is = new FileInputStream(new File(""));
+            fail("should throw FileNotFoundException.");
+        } catch (FileNotFoundException e) {
+            // Expected
+        } finally {
+            if (is != null) {
+                is.close();
+            }
+        }
+    }
+
+    /**
      * @tests java.io.FileInputStream#available()
      */
     public void test_available() throws IOException {

Modified: harmony/enhanced/java/trunk/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileOutputStreamTest.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/FileOutputStreamTest.java?rev=933137&r1=933136&r2=933137&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileOutputStreamTest.java
(original)
+++ harmony/enhanced/java/trunk/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FileOutputStreamTest.java
Mon Apr 12 08:21:46 2010
@@ -20,6 +20,7 @@ package org.apache.harmony.luni.tests.ja
 import java.io.File;
 import java.io.FileDescriptor;
 import java.io.FileInputStream;
+import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
 
@@ -96,6 +97,32 @@ public class FileOutputStreamTest extend
     }
 
     /**
+     * @tests java.io.FileOutputStream#FileOutputStream(java.lang.String)
+     */
+    public void test_ConstructorLjava_lang_String_I() throws IOException {
+        try {
+            fos = new FileOutputStream("");
+            fail("should throw FileNotFoundException.");
+        } catch (FileNotFoundException e) {
+            // Expected
+        } finally {
+            if (fos != null) {
+                fos.close();
+            }
+        }
+        try {
+            fos = new FileOutputStream(new File(""));
+            fail("should throw FileNotFoundException.");
+        } catch (FileNotFoundException e) {
+            // Expected
+        } finally {
+            if (fos != null) {
+                fos.close();
+            }
+        }
+    }
+
+    /**
      * @tests java.io.FileOutputStream#close()
      */
     public void test_close() throws IOException {

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=933137&r1=933136&r2=933137&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
Mon Apr 12 08:21:46 2010
@@ -20,10 +20,10 @@ package org.apache.harmony.luni.tests.ja
 import java.io.EOFException;
 import java.io.File;
 import java.io.FileInputStream;
+import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.RandomAccessFile;
-
 import java.nio.channels.FileChannel;
 import java.nio.channels.NonWritableChannelException;
 
@@ -103,6 +103,51 @@ public class RandomAccessFileTest extend
     }
 
     /**
+     * @tests java.io.RandomAccessFile#RandomAccessFile(java.lang.String,
+     *        java.lang.String)
+     */
+    public void test_ConstructorLjava_lang_StringLjava_lang_String_I()
+            throws IOException {
+        RandomAccessFile raf = null;
+        try {
+            raf = new RandomAccessFile("", "r");
+            fail("should throw FileNotFoundException.");
+        } catch (FileNotFoundException e) {
+            // Expected
+        } finally {
+            if (raf != null) {
+                raf.close();
+                raf = null;
+            }
+        }
+        try {
+            raf = new RandomAccessFile(new File(""), "r");
+            fail("should throw FileNotFoundException.");
+        } catch (FileNotFoundException e) {
+            // Expected
+        } finally {
+            if (raf != null) {
+                raf.close();
+                raf = null;
+            }
+        }
+        File tmpDir = new File("tmpDir");
+        assertTrue(tmpDir.mkdir());
+        tmpDir.deleteOnExit();
+        try {
+            raf = new RandomAccessFile(tmpDir.getPath(), "r");
+            fail("should throw FileNotFoundException.");
+        } catch (FileNotFoundException e) {
+            // Expected
+        } finally {
+            if (raf != null) {
+                raf.close();
+                raf = null;
+            }
+        }
+    }
+
+    /**
      * @tests java.io.RandomAccessFile#close()
      */
     public void test_close() {



Mime
View raw message