KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > codehaus > spice > netserve > connection > impl > AcceptorConfigTestCase


1 /*
2  * Copyright (C) The Spice Group. All rights reserved.
3  *
4  * This software is published under the terms of the Spice
5  * Software License version 1.1, a copy of which has been included
6  * with this distribution in the LICENSE.txt file.
7  */

8 package org.codehaus.spice.netserve.connection.impl;
9
10 import java.net.ServerSocket JavaDoc;
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 JavaDoc
24    {
25       final String JavaDoc name = "name";
26       final ServerSocket JavaDoc serverSocket = new ServerSocket JavaDoc();
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 JavaDoc
37    {
38       try
39       {
40          new AcceptorConfig( null,
41                              new ServerSocket JavaDoc(),
42                              new MockSocketConnectionHandler() );
43       }
44       catch ( final NullPointerException JavaDoc 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 JavaDoc
54    {
55       try
56       {
57          new AcceptorConfig( "name",
58                              null,
59                              new MockSocketConnectionHandler() );
60       }
61       catch ( final NullPointerException JavaDoc 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 JavaDoc
71    {
72       try
73       {
74          new AcceptorConfig( "name",
75                              new ServerSocket JavaDoc(),
76                              null );
77       }
78       catch ( NullPointerException JavaDoc npe )
79       {
80          assertEquals( "npe.message", "handler", npe.getMessage() );
81          return;
82       }
83       fail( "Expected to fail due to NPE for handler" );
84    }
85 }
86
Popular Tags