This is the mail archive of the mauve-discuss@sources.redhat.com mailing list for the Mauve project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

File.getCanonicalPath() test to strict


Hi,

The getCanonicalPath() check seems to strict. According to the spec that
call is allowed to throw a IOException which it does with libgcj when
the File does not exist. This patch makes sure that the file actually
exists first.

2002-04-05  Mark Wielaard  <mark@klomp.org>

    * gnu/testlet/java/io/File/jdk11.java (test): Make sure that file
    exists before calling getCanonicalPath().

Any objections?

Cheers,

Mark

Index: gnu/testlet/java/io/File/jdk11.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/java/io/File/jdk11.java,v
retrieving revision 1.2
diff -u -r1.2 jdk11.java
--- jdk11.java	2002/04/01 12:13:27	1.2
+++ jdk11.java	2002/04/05 12:37:05
@@ -219,6 +219,11 @@
 
     try 
       {
+	// Make sure that file exists.
+	cons.mkdir ();
+	FileOutputStream fos = new FileOutputStream (tmp3);
+	fos.write (1);
+	fos.close ();
 	harness.debug ("tmp3.getCanonicalPath () = " + tmp3.getCanonicalPath ());
 	harness.debug ("equals? " + srcdirstr + File.separator 
 		       + THIS_FILE + File.separator
@@ -228,6 +233,9 @@
 						       + THIS_FILE
 						       + File.separator
 						       + TMP_FILENAME3), "getCanonicalPath ()");
+	// Remove again
+	tmp3.delete ();
+	cons.delete ();
       } 
     catch (IOException ioe)
       {


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]