@@ -234,17 +234,16 @@ public void testWriteFile() throws IOException, MalformedProjectFileException {
234234 fb .setBuildDirectory (new File (parent , "built" ));
235235 fb .setWorkingDirectory (new File (parent , "src" ));
236236 fb .setMainClass (new File (pf .getParentFile (), "dir1/testfile1.java" ));
237-
238- String expected = "" ;
239- String received = "" ;
240237 fb .write ();
241238
239+ StringBuilder received = new StringBuilder ();
242240 FileReader fr = new FileReader (pf );
243241 int c = fr .read ();
244242 while (c >= 0 ) {
245- received += ( char ) c ;
243+ received . append (( char )c ) ;
246244 c = fr .read ();
247245 }
246+ fr .close ();
248247// assertEquals("Make relative", "dir1/test.java",
249248// fb.makeRelative(new File(pf.getParentFile(),"dir1/test.java")));
250249// assertEquals("The file written by the builder", expected, received);
@@ -266,13 +265,15 @@ public void testWriteFile() throws IOException, MalformedProjectFileException {
266265// pfir.getSourceFiles()[0].getPath());
267266// assertEquals("last source filename", new File(parent,"/dir3/testfile5.java").getPath(),
268267// pfir.getSourceFiles()[4].getPath());
269- assertEquals ("first aux filename" , new File (parent ,"test/testfile6.java" ).getPath (),
270- pfir .getAuxiliaryFiles ()[0 ].getPath ());
268+ assertEquals ("first aux filename" , new File (parent ,"test/testfile6.java" ).getCanonicalPath (),
269+ pfir .getAuxiliaryFiles ()[0 ].getCanonicalPath ());
271270 assertEquals ("last collapsed path" , "./[ Source Files ]/dir1/" , pfir .getCollapsedPaths ()[0 ]);
272- assertEquals ("build-dir name" , buildDir , pfir .getBuildDirectory ());
273- assertEquals ("work-dir name" , srcDir , pfir .getWorkingDirectory ());
274- assertEquals ("classpath name" , new File (parent ,"lib" ), IterUtil .first (pfir .getClassPaths ()));
275- assertEquals ("main-class name" , new File (parent ,"/dir1/testfile1.java" ), pfir .getMainClass ());
271+ assertEquals ("build-dir name" , buildDir .getCanonicalPath (), pfir .getBuildDirectory ().getCanonicalPath ());
272+ assertEquals ("work-dir name" , srcDir .getCanonicalPath (), pfir .getWorkingDirectory ().getCanonicalPath ());
273+ assertEquals ("classpath name" , new File (parent ,"lib" ).getCanonicalPath (),
274+ IterUtil .first (pfir .getClassPaths ()).getCanonicalPath ());
275+ assertEquals ("main-class name" , new File (parent ,"dir1/testfile1.java" ).getCanonicalPath (),
276+ pfir .getMainClass ().getCanonicalPath ());
276277 pf .delete ();
277278 }
278279
@@ -422,17 +423,16 @@ public void testWriteFilePJT() throws IOException, MalformedProjectFileException
422423 fb .setBuildDirectory (new File (parent , "built" ));
423424 fb .setWorkingDirectory (new File (parent , "src" ));
424425 fb .setMainClass (new File (pf .getParentFile (), "dir1/testfile1.java" ));
425-
426- String expected = "" ;
427- String received = "" ;
428426 fb .writeOld ();
429427
428+ StringBuilder received = new StringBuilder ();
430429 FileReader fr = new FileReader (pf );
431430 int c = fr .read ();
432431 while (c >= 0 ) {
433- received += ( char ) c ;
432+ received . append (( char )c ) ;
434433 c = fr .read ();
435434 }
435+ fr .close ();
436436// assertEquals("Make relative", "dir1/test.java",
437437// fb.makeRelative(new File(pf.getParentFile(),"dir1/test.java")));
438438// assertEquals("The file written by the builder", expected, received);
@@ -484,17 +484,16 @@ public void testWriteFileXML() throws IOException, MalformedProjectFileException
484484 fb .setBuildDirectory (new File (parent , "built" ));
485485 fb .setWorkingDirectory (new File (parent , "src" ));
486486 fb .setMainClass (new File (pf .getParentFile (), "dir1/testfile1.java" ));
487-
488- String expected = "" ;
489- String received = "" ;
490487 fb .write ();
491488
489+ StringBuilder received = new StringBuilder ();
492490 FileReader fr = new FileReader (pf );
493491 int c = fr .read ();
494492 while (c >= 0 ) {
495- received += ( char ) c ;
493+ received . append (( char )c ) ;
496494 c = fr .read ();
497495 }
496+ fr .close ();
498497// assertEquals("Make relative", "dir1/test.java",
499498// fb.makeRelative(new File(pf.getParentFile(),"dir1/test.java")));
500499// assertEquals("The file written by the builder", expected, received);
@@ -516,13 +515,15 @@ public void testWriteFileXML() throws IOException, MalformedProjectFileException
516515// pfir.getSourceFiles()[0].getPath());
517516// assertEquals("last source filename", new File(parent,"/dir3/testfile5.java").getPath(),
518517// pfir.getSourceFiles()[4].getPath());
519- assertEquals ("first aux filename" , new File (parent ,"test/testfile6.java" ).getPath (),
520- pfir .getAuxiliaryFiles ()[0 ].getPath ());
518+ assertEquals ("first aux filename" , new File (parent ,"test/testfile6.java" ).getCanonicalPath (),
519+ pfir .getAuxiliaryFiles ()[0 ].getCanonicalPath ());
521520 assertEquals ("last collapsed path" , "./[ Source Files ]/dir1/" , pfir .getCollapsedPaths ()[0 ]);
522- assertEquals ("build-dir name" , buildDir , pfir .getBuildDirectory ());
523- assertEquals ("work-dir name" , srcDir , pfir .getWorkingDirectory ());
524- assertEquals ("classpath name" , new File (parent ,"lib" ), IterUtil .first (pfir .getClassPaths ()));
525- assertEquals ("main-class name" , new File (parent ,"/dir1/testfile1.java" ), pfir .getMainClass ());
521+ assertEquals ("build-dir name" , buildDir .getCanonicalPath (), pfir .getBuildDirectory ().getCanonicalPath ());
522+ assertEquals ("work-dir name" , srcDir .getCanonicalPath (), pfir .getWorkingDirectory ().getCanonicalPath ());
523+ assertEquals ("classpath name" , new File (parent ,"lib" ).getCanonicalPath (),
524+ IterUtil .first (pfir .getClassPaths ()).getCanonicalPath ());
525+ assertEquals ("main-class name" , new File (parent ,"dir1/testfile1.java" ).getCanonicalPath (),
526+ pfir .getMainClass ().getCanonicalPath ());
526527 pf .delete ();
527528 }
528529
0 commit comments