Author: kenney Date: Mon Dec 18 19:22:14 2006 New Revision: 488512 URL: http://svn.apache.org/viewvc?view=rev&rev=488512 Log: PR: MSUREFIRE-119
use 'UNKNOWN' for the method test name if no getName method is supplied. Whatever value is used here doesn't seem to matter, though. Modified: maven/sandbox/surefire-plugin-merge/surefire-providers/surefire-junit/src/main/java/org/apache/maven/surefire/junit/TestListenerInvocationHandler.java Modified: maven/sandbox/surefire-plugin-merge/surefire-providers/surefire-junit/src/main/java/org/apache/maven/surefire/junit/TestListenerInvocationHandler.java URL: http://svn.apache.org/viewvc/maven/sandbox/surefire-plugin-merge/surefire-providers/surefire-junit/src/main/java/org/apache/maven/surefire/junit/TestListenerInvocationHandler.java?view=diff&rev=488512&r1=488511&r2=488512 ============================================================================== --- maven/sandbox/surefire-plugin-merge/surefire-providers/surefire-junit/src/main/java/org/apache/maven/surefire/junit/TestListenerInvocationHandler.java (original) +++ maven/sandbox/surefire-plugin-merge/surefire-providers/surefire-junit/src/main/java/org/apache/maven/surefire/junit/TestListenerInvocationHandler.java Mon Dec 18 19:22:14 2006 @@ -155,7 +155,7 @@ // Handler for TestListener.addFailure(Test, Throwable) private void handleAddError( Object[] args ) - throws IllegalAccessException, NoSuchMethodException, InvocationTargetException + throws IllegalAccessException, InvocationTargetException { ReportEntry report = new ReportEntry( args[0], args[0].toString(), args[1].toString(), getStackTraceWriter( args ) ); @@ -166,15 +166,25 @@ } private JUnitStackTraceWriter getStackTraceWriter( Object[] args ) - throws NoSuchMethodException, IllegalAccessException, InvocationTargetException + throws IllegalAccessException, InvocationTargetException { - Method m = args[0].getClass().getMethod( "getName", EMPTY_CLASS_ARRAY ); - String testName = (String) m.invoke( args[0], EMPTY_STRING_ARRAY ); + String testName; + + try + { + Method m = args[0].getClass().getMethod( "getName", EMPTY_CLASS_ARRAY ); + testName = (String) m.invoke( args[0], EMPTY_STRING_ARRAY ); + } + catch ( NoSuchMethodException e ) + { + testName = "UNKNOWN"; + } + return new JUnitStackTraceWriter( args[0].getClass().getName(), testName, (Throwable) args[1] ); } private void handleAddFailure( Object[] args ) - throws IllegalAccessException, NoSuchMethodException, InvocationTargetException + throws IllegalAccessException, InvocationTargetException { ReportEntry report = new ReportEntry( args[0], args[0].toString(), args[1].toString(), getStackTraceWriter( args ) );