1 package org.codehaus.spice.netserve.connection.handlers; 2 3 import java.net.Socket ; 4 5 import com.mockobjects.dynamic.C; 6 import com.mockobjects.dynamic.Mock; 7 import junit.framework.TestCase; 8 import org.codehaus.spice.netserve.connection.RequestHandler; 9 10 public class DelegatingRequestHandlerTestCase 11 extends TestCase 12 { 13 public void testNullPassedIntoCtor() 14 throws Exception 15 { 16 try 17 { 18 new DelegatingRequestHandler( null ); 19 } 20 catch ( final NullPointerException npe ) 21 { 22 assertEquals( "npe.getMessage()", "handler", npe.getMessage() ); 23 return; 24 } 25 } 26 27 public void testDelegateHandlerInvoked() 28 throws Exception 29 { 30 final Mock mockHandler = new Mock( RequestHandler.class ); 31 final Socket socket = new Socket (); 32 final Long timeout = new Long ( 23 ); 33 mockHandler.expect( "handleConnection", C.args( C.eq( socket ) ) ); 34 mockHandler.expect( "shutdown", C.args( C.eq( timeout ) ) ); 35 final RequestHandler handler = (RequestHandler) mockHandler.proxy(); 36 final DelegatingRequestHandler delegatingHandler = 37 new DelegatingRequestHandler( handler ); 38 39 delegatingHandler.handleConnection( socket ); 40 delegatingHandler.shutdown( 23 ); 41 } 42 } 43 | Popular Tags |