01: /*
02: * Copyright (C) The Spice Group. All rights reserved.
03: *
04: * This software is published under the terms of the Spice
05: * Software License version 1.1, a copy of which has been included
06: * with this distribution in the LICENSE.txt file.
07: */
08: package org.codehaus.spice.netserve.connection.handlers;
09:
10: import com.mockobjects.dynamic.C;
11: import com.mockobjects.dynamic.Mock;
12: import java.net.Socket;
13: import junit.framework.TestCase;
14: import org.codehaus.spice.netserve.connection.RequestHandler;
15:
16: /**
17: *
18: * @author Peter Donald
19: * @version $Revision: 1.2 $ $Date: 2004/03/21 23:42:59 $
20: */
21: public class ManagedRequestHandlerTestCase extends TestCase {
22: public void testManagedRequestHandler() throws Exception {
23: final Mock mockHandler = new Mock(RequestHandler.class);
24: final Socket socket = new Socket();
25: mockHandler.expect("handleConnection", C.args(C.eq(socket)));
26: final RequestHandler handler = (RequestHandler) mockHandler
27: .proxy();
28:
29: final Mock mockManager = new Mock(RequestManager.class);
30: mockManager.expectAndReturn("aquireHandler", C.args(C
31: .isA(Socket.class)), handler);
32: mockManager.expect("releaseHandler", C.args(C.eq(handler)));
33:
34: final RequestManager manager = (RequestManager) mockManager
35: .proxy();
36:
37: final MockManagedRequestHandler managedHandler = new MockManagedRequestHandler(
38: manager);
39: managedHandler.handleConnection(socket);
40:
41: mockManager.verify();
42: mockHandler.verify();
43: }
44: }
|