01: package org.codehaus.spice.netserve.connection.handlers;
02:
03: import java.net.Socket;
04:
05: import com.mockobjects.dynamic.C;
06: import com.mockobjects.dynamic.Mock;
07: import junit.framework.TestCase;
08: import org.codehaus.spice.netserve.connection.RequestHandler;
09:
10: public class DelegatingRequestHandlerTestCase extends TestCase {
11: public void testNullPassedIntoCtor() throws Exception {
12: try {
13: new DelegatingRequestHandler(null);
14: } catch (final NullPointerException npe) {
15: assertEquals("npe.getMessage()", "handler", npe
16: .getMessage());
17: return;
18: }
19: }
20:
21: public void testDelegateHandlerInvoked() throws Exception {
22: final Mock mockHandler = new Mock(RequestHandler.class);
23: final Socket socket = new Socket();
24: final Long timeout = new Long(23);
25: mockHandler.expect("handleConnection", C.args(C.eq(socket)));
26: mockHandler.expect("shutdown", C.args(C.eq(timeout)));
27: final RequestHandler handler = (RequestHandler) mockHandler
28: .proxy();
29: final DelegatingRequestHandler delegatingHandler = new DelegatingRequestHandler(
30: handler);
31:
32: delegatingHandler.handleConnection(socket);
33: delegatingHandler.shutdown(23);
34: }
35: }
|