Package org.codehaus.spice.netserve.connection.handlers

Source Code of org.codehaus.spice.netserve.connection.handlers.DelegatingRequestHandlerTestCase

package org.codehaus.spice.netserve.connection.handlers;

import java.net.Socket;

import com.mockobjects.dynamic.C;
import com.mockobjects.dynamic.Mock;
import junit.framework.TestCase;
import org.codehaus.spice.netserve.connection.RequestHandler;

public class DelegatingRequestHandlerTestCase
   extends TestCase
{
   public void testNullPassedIntoCtor()
      throws Exception
   {
      try
      {
         new DelegatingRequestHandler( null );
      }
      catch ( final NullPointerException npe )
      {
         assertEquals( "npe.getMessage()", "handler", npe.getMessage() );
         return;
      }
   }

   public void testDelegateHandlerInvoked()
      throws Exception
   {
      final Mock mockHandler = new Mock( RequestHandler.class );
      final Socket socket = new Socket();
      final Long timeout = new Long( 23 );
      mockHandler.expect( "handleConnection", C.args( C.eq( socket ) ) );
      mockHandler.expect( "shutdown", C.args( C.eq( timeout ) ) );
      final RequestHandler handler = (RequestHandler) mockHandler.proxy();
      final DelegatingRequestHandler delegatingHandler =
         new DelegatingRequestHandler( handler );

      delegatingHandler.handleConnection( socket );
      delegatingHandler.shutdown( 23 );
   }
}
TOP

Related Classes of org.codehaus.spice.netserve.connection.handlers.DelegatingRequestHandlerTestCase

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.