1
2
3
4
5
6
7
8 package org.codehaus.spice.netserve.connection.impl;
9
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
20 extends TestCase
21 {
22 public void testCreation()
23 throws Exception
24 {
25 final String name = "name";
26 final ServerSocket serverSocket = new ServerSocket();
27 final MockSocketConnectionHandler handler = new MockSocketConnectionHandler();
28 final AcceptorConfig config =
29 new AcceptorConfig( name, serverSocket, handler );
30 assertEquals( "name", name, config.getName() );
31 assertEquals( "serverSocket", serverSocket, config.getServerSocket() );
32 assertEquals( "handler", handler, config.getHandler() );
33 }
34
35 public void testNullNameInCtor()
36 throws Exception
37 {
38 try
39 {
40 new AcceptorConfig( null,
41 new ServerSocket(),
42 new MockSocketConnectionHandler() );
43 }
44 catch ( final NullPointerException npe )
45 {
46 assertEquals( "npe.message", "name", npe.getMessage() );
47 return;
48 }
49 fail( "Expected to fail due to NPE for name" );
50 }
51
52 public void testNullServerSocketInCtor()
53 throws Exception
54 {
55 try
56 {
57 new AcceptorConfig( "name",
58 null,
59 new MockSocketConnectionHandler() );
60 }
61 catch ( final NullPointerException npe )
62 {
63 assertEquals( "npe.message", "serverSocket", npe.getMessage() );
64 return;
65 }
66 fail( "Expected to fail due to NPE for serverSocket" );
67 }
68
69 public void testNullHandlerInCtor()
70 throws Exception
71 {
72 try
73 {
74 new AcceptorConfig( "name",
75 new ServerSocket(),
76 null );
77 }
78 catch ( NullPointerException npe )
79 {
80 assertEquals( "npe.message", "handler", npe.getMessage() );
81 return;
82 }
83 fail( "Expected to fail due to NPE for handler" );
84 }
85 }