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.impl;
09:
10: import java.net.ServerSocket;
11:
12: import junit.framework.TestCase;
13:
14: /**
15: *
16: * @author Peter Donald
17: * @version $Revision: 1.2 $ $Date: 2004/03/21 23:42:59 $
18: */
19: public class AcceptorConfigTestCase extends TestCase {
20: public void testCreation() throws Exception {
21: final String name = "name";
22: final ServerSocket serverSocket = new ServerSocket();
23: final MockSocketConnectionHandler handler = new MockSocketConnectionHandler();
24: final AcceptorConfig config = new AcceptorConfig(name,
25: serverSocket, handler);
26: assertEquals("name", name, config.getName());
27: assertEquals("serverSocket", serverSocket, config
28: .getServerSocket());
29: assertEquals("handler", handler, config.getHandler());
30: }
31:
32: public void testNullNameInCtor() throws Exception {
33: try {
34: new AcceptorConfig(null, new ServerSocket(),
35: new MockSocketConnectionHandler());
36: } catch (final NullPointerException npe) {
37: assertEquals("npe.message", "name", npe.getMessage());
38: return;
39: }
40: fail("Expected to fail due to NPE for name");
41: }
42:
43: public void testNullServerSocketInCtor() throws Exception {
44: try {
45: new AcceptorConfig("name", null,
46: new MockSocketConnectionHandler());
47: } catch (final NullPointerException npe) {
48: assertEquals("npe.message", "serverSocket", npe
49: .getMessage());
50: return;
51: }
52: fail("Expected to fail due to NPE for serverSocket");
53: }
54:
55: public void testNullHandlerInCtor() throws Exception {
56: try {
57: new AcceptorConfig("name", new ServerSocket(), null);
58: } catch (NullPointerException npe) {
59: assertEquals("npe.message", "handler", npe.getMessage());
60: return;
61: }
62: fail("Expected to fail due to NPE for handler");
63: }
64: }
|