Revision: 657
http://stripes.svn.sourceforge.net/stripes/?rev=657&view=rev
Author: bengunter
Date: 2007-12-10 07:33:01 -0800 (Mon, 10 Dec 2007)
Log Message:
-----------
Ensure streams are closed immediately after we're done using them. Leaving the
streams open causes test failures under Windows. All file test failures under
Windows are now fixed except for intermittent failure in testSaveByCopy() due
to FileNotFoundException
Modified Paths:
--------------
trunk/tests/src/net/sourceforge/stripes/action/FileBeanTests.java
Modified: trunk/tests/src/net/sourceforge/stripes/action/FileBeanTests.java
===================================================================
--- trunk/tests/src/net/sourceforge/stripes/action/FileBeanTests.java
2007-12-10 15:13:33 UTC (rev 656)
+++ trunk/tests/src/net/sourceforge/stripes/action/FileBeanTests.java
2007-12-10 15:33:01 UTC (rev 657)
@@ -21,12 +21,15 @@
public void setupFiles() throws IOException {
// The from file
this.from = File.createTempFile("foo", "bar");
- FileWriter out = new FileWriter(this.from);
- out.write(LINES[0]);
- out.write('\n');
- out.write(LINES[1]);
- out.write('\n');
- out.close();
+ PrintWriter out = null;
+ try {
+ out = new PrintWriter(this.from);
+ out.println(LINES[0]);
+ out.println(LINES[1]);
+ }
+ finally {
+ try { out.close(); } catch (Exception e) {}
+ }
// A to file
this.to = new File(System.getProperty("java.io.tmpdir"), "foo-" +
System.currentTimeMillis());
@@ -40,10 +43,16 @@
/** Helper method to assert contents of post-copy file. */
private void assertContents(File toFile) throws IOException {
- BufferedReader in = new BufferedReader(new FileReader(toFile));
- Assert.assertEquals(in.readLine(), LINES[0]);
- Assert.assertEquals(in.readLine(), LINES[1]);
- Assert.assertNull(in.readLine());
+ BufferedReader in = null;
+ try {
+ in = new BufferedReader(new FileReader(toFile));
+ Assert.assertEquals(in.readLine(), LINES[0]);
+ Assert.assertEquals(in.readLine(), LINES[1]);
+ Assert.assertNull(in.readLine());
+ }
+ finally {
+ try { in.close(); } catch (Exception e) {}
+ }
}
/** Helper method that copies a reader into a writer. */
@@ -143,10 +152,15 @@
FileBean bean = new FileBean(from, "text/plain", "somefile.txt");
Assert.assertTrue(this.to.createNewFile());
- BufferedWriter out = new BufferedWriter(new FileWriter(this.to));
- out.write("This is not what we should read back after the save!\n");
- out.write("If we get this text back we're in trouble!\n");
- out.close();
+ PrintWriter out = null;
+ try {
+ out = new PrintWriter(this.to);
+ out.println("This is not what we should read back after the
save!");
+ out.println("If we get this text back we're in trouble!");
+ }
+ finally {
+ try { out.close(); } catch (Exception e) {}
+ }
bean.save(this.to);
Assert.assertTrue(this.to.exists());
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development