You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by jc...@apache.org on 2005/10/14 05:48:01 UTC
svn commit: r320989 - in
/jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy:
interceptor/TestLoggingMethodInterceptor.java util/Echo.java
util/EchoImpl.java
Author: jcarman
Date: Thu Oct 13 20:47:57 2005
New Revision: 320989
URL: http://svn.apache.org/viewcvs?rev=320989&view=rev
Log:
Improving test coverage (a bit).
Modified:
jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/interceptor/TestLoggingMethodInterceptor.java
jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/util/Echo.java
jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/util/EchoImpl.java
Modified: jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/interceptor/TestLoggingMethodInterceptor.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/interceptor/TestLoggingMethodInterceptor.java?rev=320989&r1=320988&r2=320989&view=diff
==============================================================================
--- jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/interceptor/TestLoggingMethodInterceptor.java (original)
+++ jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/interceptor/TestLoggingMethodInterceptor.java Thu Oct 13 20:47:57 2005
@@ -36,11 +36,46 @@
echo = ( Echo ) new CglibProxyFactory()
.createInterceptorProxy( new EchoImpl(), new LoggingMethodInterceptor( ( Log ) logMock.proxy() ),
new Class[]{ Echo.class } );
+ }
+
+ public void testWhenLoggingDisabled()
+ {
+ logMock = mock( Log.class );
+ echo = ( Echo ) new CglibProxyFactory()
+ .createInterceptorProxy( new EchoImpl(), new LoggingMethodInterceptor( ( Log ) logMock.proxy() ),
+ new Class[]{ Echo.class } );
+ logMock.expects( once() ).method( "isDebugEnabled" ).will( returnValue( false ) );
+ echo.echoBack( "Hello" );
+
+ }
+
+ public void testWithArrayParameter()
+ {
+ logMock.expects( once() ).method( "isDebugEnabled" ).will( returnValue( true ) );
+ logMock.expects( once() ).method( "debug" ).with( eq( "BEGIN echoBack((java.lang.String[]){Hello, World})" ) );
+ logMock.expects( once() ).method( "debug" ).with( eq( "END echoBack() [HelloWorld]" ) );
+ echo.echoBack( new String[] { "Hello", "World" } );
+ }
+
+ public void testMultipleParameters()
+ {
+ logMock.expects( once() ).method( "isDebugEnabled" ).will( returnValue( true ) );
+ logMock.expects( once() ).method( "debug" ).with( eq( "BEGIN echoBack(Hello, World)" ) );
+ logMock.expects( once() ).method( "debug" ).with( eq( "END echoBack() [HelloWorld]" ) );
+ echo.echoBack( "Hello", "World" );
+ }
+
+ public void testNullReturnValue()
+ {
logMock.expects( once() ).method( "isDebugEnabled" ).will( returnValue( true ) );
+ logMock.expects( once() ).method( "debug" ).with( eq( "BEGIN echoBack(<null>)" ) );
+ logMock.expects( once() ).method( "debug" ).with( eq( "END echoBack() [<null>]" ) );
+ echo.echoBack( ( String )null );
}
public void testNonVoidMethod()
{
+ logMock.expects( once() ).method( "isDebugEnabled" ).will( returnValue( true ) );
logMock.expects( once() ).method( "debug" ).with( eq( "BEGIN echoBack(Hello)" ) );
logMock.expects( once() ).method( "debug" ).with( eq( "END echoBack() [Hello]" ) );
echo.echoBack( "Hello" );
@@ -48,6 +83,7 @@
public void testException()
{
+ logMock.expects( once() ).method( "isDebugEnabled" ).will( returnValue( true ) );
logMock.expects( once() ).method( "debug" ).with( eq( "BEGIN ioException()" ) );
logMock.expects( once() ).method( "debug" ).with( eq( "EXCEPTION ioException() -- java.io.IOException" ), isA( IOException.class ) );
try
@@ -63,6 +99,7 @@
public void testRuntimeException()
{
+ logMock.expects( once() ).method( "isDebugEnabled" ).will( returnValue( true ) );
logMock.expects( once() ).method( "debug" ).with( eq( "BEGIN illegalArgument()" ) );
logMock.expects( once() ).method( "debug" ).with( eq( "EXCEPTION illegalArgument() -- java.lang.IllegalArgumentException" ), isA( IllegalArgumentException.class ) );
try
@@ -78,6 +115,7 @@
public void testVoidMethod()
{
+ logMock.expects( once() ).method( "isDebugEnabled" ).will( returnValue( true ) );
logMock.expects( once() ).method( "debug" ).with( eq( "BEGIN echo()" ) );
logMock.expects( once() ).method( "debug" ).with( eq( "END echo()" ) );
echo.echo();
Modified: jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/util/Echo.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/util/Echo.java?rev=320989&r1=320988&r2=320989&view=diff
==============================================================================
--- jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/util/Echo.java (original)
+++ jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/util/Echo.java Thu Oct 13 20:47:57 2005
@@ -25,6 +25,7 @@
{
public String echoBack( String message );
public String echoBack( String message1, String message2 );
+ public String echoBack( String[] messages );
public int echoBack( int i );
public void echo();
Modified: jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/util/EchoImpl.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/util/EchoImpl.java?rev=320989&r1=320988&r2=320989&view=diff
==============================================================================
--- jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/util/EchoImpl.java (original)
+++ jakarta/commons/sandbox/proxy/trunk/src/test/org/apache/commons/proxy/util/EchoImpl.java Thu Oct 13 20:47:57 2005
@@ -29,6 +29,17 @@
return message1 + message2;
}
+ public String echoBack( String[] messages )
+ {
+ final StringBuffer sb = new StringBuffer();
+ for( int i = 0; i < messages.length; i++ )
+ {
+ String message = messages[i];
+ sb.append( message );
+ }
+ return sb.toString();
+ }
+
public int echoBack( int i )
{
return i;
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org