KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jacorb > test > orb > connection > ServerConnectionTimeoutTest


1 package org.jacorb.test.orb.connection;
2
3 /*
4  * JacORB - a free Java ORB
5  *
6  * Copyright (C) 1997-2001 Gerald Brose.
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public
19  * License along with this library; if not, write to the Free
20  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21  */

22
23 import junit.framework.*;
24 import junit.extensions.*;
25
26 import org.jacorb.test.common.*;
27 import org.omg.CORBA.*;
28 import org.jacorb.test.*;
29 import org.jacorb.orb.iiop.ClientIIOPConnection;
30
31 import java.util.*;
32
33 public class ServerConnectionTimeoutTest extends ClientServerTestCase
34 {
35     private TestIf server;
36
37     public ServerConnectionTimeoutTest(String JavaDoc name, ClientServerSetup setup)
38     {
39         super(name, setup);
40     }
41
42     public void setUp() throws Exception JavaDoc
43     {
44         server = TestIfHelper.narrow( setup.getServerObject() );
45     }
46
47     public static Test suite()
48     {
49         TestSuite suite = new TestSuite( "Server connection idle-timeout tests" );
50
51         Properties server_props =
52             new Properties();
53         server_props.setProperty( "jacorb.connection.server.timeout", "1000" );
54
55         ClientServerSetup setup =
56             new ClientServerSetup( suite,
57                                    "org.jacorb.test.orb.connection.ConnectionTimeoutServerImpl",
58                                    null,
59                                    server_props );
60
61         suite.addTest( new ServerConnectionTimeoutTest( "testTimeout", setup ));
62
63         return setup;
64     }
65
66     public void testTimeout()
67     {
68
69         //call remote op with reply
70
server.op();
71
72         try
73         {
74             //wait 2 secs
75
Thread.sleep( 2000 );
76         }
77         catch( Exception JavaDoc e ){ e.printStackTrace(); }
78
79         //all transports must be down by now
80
//NOTE: if this doesn't compile, please check if
81
//openTransports is uncommented in ClientIIOPConnection
82
assertTrue( ClientIIOPConnection.openTransports == 0 );
83
84         //call oneway remote op
85
server.onewayOp();
86
87         try
88         {
89             //wait 2 secs
90
Thread.sleep( 2000 );
91         }
92         catch( Exception JavaDoc e ){ e.printStackTrace(); }
93
94         //all transports must be down by now
95
//NOTE: if this doesn't compile, please check if
96
//openTransports is uncommented in ClientIIOPConnection
97
assertTrue( ClientIIOPConnection.openTransports == 0 );
98     }
99 }
100
Popular Tags