You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@onami.apache.org by si...@apache.org on 2013/01/19 22:17:20 UTC
svn commit: r1435706 - in
/incubator/onami/trunk/test/src/main/java/org/apache/onami/test:
handler/MockHandler.java reflection/HandleException.java
Author: simonetripodi
Date: Sat Jan 19 21:17:20 2013
New Revision: 1435706
URL: http://svn.apache.org/viewvc?rev=1435706&view=rev
Log:
[ONAMI-56] simplify org.apache.onami.test.reflection.HandleException(String) construction introducing varargs
Modified:
incubator/onami/trunk/test/src/main/java/org/apache/onami/test/handler/MockHandler.java
incubator/onami/trunk/test/src/main/java/org/apache/onami/test/reflection/HandleException.java
Modified: incubator/onami/trunk/test/src/main/java/org/apache/onami/test/handler/MockHandler.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/test/src/main/java/org/apache/onami/test/handler/MockHandler.java?rev=1435706&r1=1435705&r2=1435706&view=diff
==============================================================================
--- incubator/onami/trunk/test/src/main/java/org/apache/onami/test/handler/MockHandler.java (original)
+++ incubator/onami/trunk/test/src/main/java/org/apache/onami/test/handler/MockHandler.java Sat Jan 19 21:17:20 2013
@@ -92,9 +92,11 @@ public final class MockHandler
if ( !element.getType().isAssignableFrom( method.getReturnType() ) )
{
- throw new HandleException( "Impossible to mock " + element.getDeclaringClass().getName()
- + " due to compatibility type, method provider " + providedClass.getName() + "#"
- + annotation.providedBy() + " returns " + method.getReturnType().getName() );
+ throw new HandleException( "Impossible to mock %s due to compatibility type, method provider %s#%s returns %s",
+ element.getDeclaringClass().getName(),
+ providedClass.getName(),
+ annotation.providedBy(),
+ method.getReturnType().getName() );
}
try
{
@@ -103,22 +105,27 @@ public final class MockHandler
}
catch ( Throwable t )
{
- throw new HandleException( "Impossible to mock " + element.getDeclaringClass().getName()
- + ", method provider " + providedClass.getName() + "#" + annotation.providedBy()
- + " raised an error", t );
+ throw new HandleException( "Impossible to mock %s, method provider %s#%s raised an error: %s",
+ element.getDeclaringClass().getName(),
+ providedClass.getName(),
+ annotation.providedBy(),
+ t );
}
}
catch ( SecurityException e )
{
- throw new HandleException( "Impossible to mock " + element.getDeclaringClass().getName()
- + ", impossible to access to method provider " + providedClass.getName() + "#"
- + annotation.providedBy(), e );
+ throw new HandleException( "Impossible to mock %s, impossible to access to method provider %s#%s: %s",
+ element.getDeclaringClass().getName(),
+ providedClass.getName(),
+ annotation.providedBy(),
+ e );
}
catch ( NoSuchMethodException e )
{
- throw new HandleException( "Impossible to mock " + element.getDeclaringClass().getName()
- + ", the method provider " + providedClass.getName() + "#" + annotation.providedBy()
- + " doesn't exist." );
+ throw new HandleException( "Impossible to mock %s, the method provider %s#%s doesn't exist.",
+ element.getDeclaringClass().getName(),
+ providedClass.getName(),
+ annotation.providedBy() );
}
}
else
@@ -141,9 +148,11 @@ public final class MockHandler
}
if ( !Modifier.isPublic( method.getModifiers() ) || !Modifier.isStatic( method.getModifiers() ) )
{
- throw new HandleException( "Impossible to invoke method " + cls + "#" + method.getName()
- + ". The method shuld be 'static public " + method.getReturnType().getName() + " "
- + method.getName() + "()'" );
+ throw new HandleException( "Impossible to invoke method %s#%s. The method shuld be 'static public %s %s()",
+ cls.getName(),
+ method.getName(),
+ method.getReturnType().getName(),
+ method.getName() );
}
return (T) method.invoke( cls );
@@ -153,7 +162,7 @@ public final class MockHandler
throw new RuntimeException( e );
}
}
- throw new HandleException( "The method: " + method + " shuld be return a type " + t );
+ throw new HandleException( "The method: %s should return type %s", method, t );
}
}
Modified: incubator/onami/trunk/test/src/main/java/org/apache/onami/test/reflection/HandleException.java
URL: http://svn.apache.org/viewvc/incubator/onami/trunk/test/src/main/java/org/apache/onami/test/reflection/HandleException.java?rev=1435706&r1=1435705&r2=1435706&view=diff
==============================================================================
--- incubator/onami/trunk/test/src/main/java/org/apache/onami/test/reflection/HandleException.java (original)
+++ incubator/onami/trunk/test/src/main/java/org/apache/onami/test/reflection/HandleException.java Sat Jan 19 21:17:20 2013
@@ -19,6 +19,8 @@ package org.apache.onami.test.reflection
* under the License.
*/
+import static java.lang.String.format;
+
/**
* Exception thrown by a {@link ClassVisitor} when a error occurs.
*/
@@ -33,9 +35,9 @@ public final class HandleException
super( message, cause );
}
- public HandleException( String message )
+ public HandleException( String message, Object...args )
{
- super( message );
+ super( format( message, args ) );
}
public HandleException( Throwable cause )