You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by te...@apache.org on 2007/01/11 23:40:47 UTC
svn commit: r495413 - in /harmony/enhanced/classlib/trunk/modules/luni/src:
main/java/org/apache/harmony/luni/util/NotImplementedException.java
test/java/org/apache/harmony/luni/tests/util/NYITest.java
Author: tellison
Date: Thu Jan 11 14:40:46 2007
New Revision: 495413
URL: http://svn.apache.org/viewvc?view=rev&rev=495413
Log:
Make the not implemented test quiet.
Modified:
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/NotImplementedException.java
harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/util/NYITest.java
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/NotImplementedException.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/NotImplementedException.java?view=diff&rev=495413&r1=495412&r2=495413
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/NotImplementedException.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/NotImplementedException.java Thu Jan 11 14:40:46 2007
@@ -16,6 +16,8 @@
package org.apache.harmony.luni.util;
+import java.io.PrintStream;
+
/**
* This exception is thrown by methods that are not currently implemented, so
@@ -33,31 +35,37 @@
* Default constructor.
*/
public NotImplementedException() {
- super();
- System.err.println("*** NOT IMPLEMENTED EXCEPTION ***"); //$NON-NLS-1$
- StackTraceElement thrower = getStackTrace()[0];
- System.err
- .println("*** thrown from class -> " + thrower.getClassName()); //$NON-NLS-1$
- System.err
- .println("*** method -> " + thrower.getMethodName()); //$NON-NLS-1$
-
- System.err.print("*** defined in -> "); //$NON-NLS-1$
- if (thrower.isNativeMethod()) {
- System.err.println("a native method"); //$NON-NLS-1$
- } else {
- String fileName = thrower.getFileName();
- if (fileName == null) {
- System.err.println("an unknown source"); //$NON-NLS-1$
- } else {
- int lineNumber = thrower.getLineNumber();
- System.err.print("the file \"" + fileName + "\""); //$NON-NLS-1$ //$NON-NLS-2$
- if (lineNumber >= 0) {
- System.err.print(" on line #" + lineNumber); //$NON-NLS-1$
- }
- System.err.println();
- }
- }
+ this(System.err);
}
+
+ /*
+ * Constructor that prints the message of the exception on the given stream
+ */
+ @SuppressWarnings("nls")
+ public NotImplementedException(PrintStream stream) {
+ super();
+ stream.println("*** NOT IMPLEMENTED EXCEPTION ***");
+ StackTraceElement thrower = getStackTrace()[0];
+ stream.println("*** thrown from class -> " + thrower.getClassName());
+ stream.println("*** method -> " + thrower.getMethodName());
+
+ stream.print("*** defined in -> ");
+ if (thrower.isNativeMethod()) {
+ stream.println("a native method");
+ } else {
+ String fileName = thrower.getFileName();
+ if (fileName == null) {
+ stream.println("an unknown source");
+ } else {
+ int lineNumber = thrower.getLineNumber();
+ stream.print("the file \"" + fileName + "\"");
+ if (lineNumber >= 0) {
+ stream.print(" on line #" + lineNumber);
+ }
+ stream.println();
+ }
+ }
+ }
/**
* Constructor that takes a reason message.
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/util/NYITest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/util/NYITest.java?view=diff&rev=495413&r1=495412&r2=495413
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/util/NYITest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/util/NYITest.java Thu Jan 11 14:40:46 2007
@@ -17,6 +17,10 @@
package org.apache.harmony.luni.tests.util;
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+import java.io.UnsupportedEncodingException;
+
import junit.framework.TestCase;
import org.apache.harmony.luni.util.NotImplementedException;
@@ -26,14 +30,11 @@
*/
public class NYITest extends TestCase {
- public void testNYI() {
- System.err.println("Test suite -> expect a not implemented output >>>");
- try {
- throw new NotImplementedException();
- } catch (NotImplementedException exception) {
- // Expected
- }
- System.err.println("Test suite finished not implemented output <<<");
+ public void testNYI() throws UnsupportedEncodingException {
+ ByteArrayOutputStream bos = new ByteArrayOutputStream(400);
+ PrintStream stream = new PrintStream(bos, true, "UTF-8");
+ new NotImplementedException(stream);
+ String message = new String(bos.toByteArray(), "UTF-8");
+ assertFalse(message.indexOf("NYITest") == -1);
}
-
}