You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by ap...@apache.org on 2007/05/29 09:23:36 UTC
svn commit: r542440 - in
/harmony/enhanced/classlib/branches/java6/modules/luni/src:
main/java/java/io/PrintWriter.java
test/java/tests/api/java/io/PrintWriterTest.java
Author: apetrenko
Date: Tue May 29 00:23:33 2007
New Revision: 542440
URL: http://svn.apache.org/viewvc?view=rev&rev=542440
Log:
Patch for HARMONY-3722 "[classlib][luni][java6]new method in j.i.PrintWriter"
Modified:
harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/PrintWriter.java
harmony/enhanced/classlib/branches/java6/modules/luni/src/test/java/tests/api/java/io/PrintWriterTest.java
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/PrintWriter.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/PrintWriter.java?view=diff&rev=542440&r1=542439&r2=542440
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/PrintWriter.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/PrintWriter.java Tue May 29 00:23:33 2007
@@ -202,6 +202,17 @@
}
return ioError;
}
+
+ /**
+ * Sets the error state of the stream to false.
+ *
+ * @since 1.6
+ */
+ protected void clearError() {
+ synchronized (lock) {
+ ioError = false;
+ }
+ }
/**
* Close this PrintWriter. This implementation flushes and then closes the
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/java/tests/api/java/io/PrintWriterTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/java/tests/api/java/io/PrintWriterTest.java?view=diff&rev=542440&r1=542439&r2=542440
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/java/tests/api/java/io/PrintWriterTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/java/tests/api/java/io/PrintWriterTest.java Tue May 29 00:23:33 2007
@@ -22,6 +22,7 @@
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
+import java.io.OutputStream;
import java.io.PrintWriter;
import java.nio.charset.Charset;
import java.util.Locale;
@@ -36,6 +37,22 @@
return "Bogus";
}
}
+
+ /**
+ * @since 1.6
+ */
+ static class MockPrintWriter extends PrintWriter {
+
+ public MockPrintWriter(OutputStream out, boolean autoflush) {
+ super(out, autoflush);
+ }
+
+ @Override
+ public void clearError() {
+ super.clearError();
+ }
+
+ }
PrintWriter pw;
@@ -184,6 +201,20 @@
assertTrue("Failed to return error", pw.checkError());
}
+ /**
+ * @tests java.io.PrintWriter#clearError()
+ * @since 1.6
+ */
+ public void test_clearError() {
+ // Test for method boolean java.io.PrintWriter.clearError()
+ MockPrintWriter mpw = new MockPrintWriter(new ByteArrayOutputStream(), false);
+ mpw.close();
+ mpw.print(490000000000.08765);
+ assertTrue("Failed to return error", mpw.checkError());
+ mpw.clearError();
+ assertFalse("Internal error state has not be cleared", mpw.checkError());
+ }
+
/**
* @tests java.io.PrintWriter#close()
*/