~ubuntu-branches/ubuntu/raring/libjboss-remoting-java/raring

« back to all changes in this revision

Viewing changes to src/tests/org/jboss/test/remoting/connection/ConnectionValidatorTiedToLeaseTestCase.java

  • Committer: Package Import Robot
  • Author(s): Torsten Werner
  • Date: 2011-09-09 14:01:03 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: package-import@ubuntu.com-20110909140103-hqokx61534tas9rg
Tags: 2.5.3.SP1-1
* Newer but not newest upstream release. Do not build samples.
* Change debian/watch to upstream's svn repo.
* Add patch to fix compile error caused by tomcat update.
  (Closes: #628303)
* Switch to source format 3.0.
* Switch to debhelper level 7.
* Remove useless Depends.
* Update Standards-Version: 3.9.2.
* Update README.source.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
* JBoss, Home of Professional Open Source
 
3
* Copyright 2005, JBoss Inc., and individual contributors as indicated
 
4
* by the @authors tag. See the copyright.txt in the distribution for a
 
5
* full listing of individual contributors.
 
6
*
 
7
* This is free software; you can redistribute it and/or modify it
 
8
* under the terms of the GNU Lesser General Public License as
 
9
* published by the Free Software Foundation; either version 2.1 of
 
10
* the License, or (at your option) any later version.
 
11
*
 
12
* This software is distributed in the hope that it will be useful,
 
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 
15
* Lesser General Public License for more details.
 
16
*
 
17
* You should have received a copy of the GNU Lesser General Public
 
18
* License along with this software; if not, write to the Free
 
19
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 
20
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 
21
*/
 
22
package org.jboss.test.remoting.connection;
 
23
 
 
24
import java.lang.reflect.Field;
 
25
import java.net.InetAddress;
 
26
import java.util.HashMap;
 
27
import java.util.Map;
 
28
import java.util.TimerTask;
 
29
 
 
30
import javax.management.MBeanServer;
 
31
 
 
32
import junit.framework.TestCase;
 
33
 
 
34
import org.apache.log4j.ConsoleAppender;
 
35
import org.apache.log4j.Level;
 
36
import org.apache.log4j.Logger;
 
37
import org.apache.log4j.PatternLayout;
 
38
import org.jboss.logging.XLevel;
 
39
import org.jboss.remoting.Client;
 
40
import org.jboss.remoting.ConnectionListener;
 
41
import org.jboss.remoting.ConnectionValidator;
 
42
import org.jboss.remoting.InvocationRequest;
 
43
import org.jboss.remoting.InvokerLocator;
 
44
import org.jboss.remoting.LeasePinger;
 
45
import org.jboss.remoting.MicroRemoteClientInvoker;
 
46
import org.jboss.remoting.ServerInvocationHandler;
 
47
import org.jboss.remoting.ServerInvoker;
 
48
import org.jboss.remoting.callback.InvokerCallbackHandler;
 
49
import org.jboss.remoting.transport.ClientInvoker;
 
50
import org.jboss.remoting.transport.Connector;
 
51
import org.jboss.remoting.transport.PortUtil;
 
52
 
 
53
 
 
54
/**
 
55
 * Unit tests for JBREM-891.
 
56
 * 
 
57
 * @author <a href="ron.sigal@jboss.com">Ron Sigal</a>
 
58
 * @version $Revision: 1.1 $
 
59
 * <p>
 
60
 * Copyright Jan 19, 2008
 
61
 * </p>
 
62
 */
 
63
public class ConnectionValidatorTiedToLeaseTestCase extends TestCase
 
64
{
 
65
   private static Logger log = Logger.getLogger(ConnectionValidatorTiedToLeaseTestCase.class);
 
66
   
 
67
   private static boolean firstTime = true;
 
68
   
 
69
   protected String host;
 
70
   protected int port;
 
71
   protected String locatorURI;
 
72
   protected InvokerLocator serverLocator;
 
73
   protected Connector connector;
 
74
   protected TestInvocationHandler invocationHandler;
 
75
   protected TestConnectionListener serverListener;
 
76
 
 
77
   
 
78
   public void setUp() throws Exception
 
79
   {
 
80
      if (firstTime)
 
81
      {
 
82
         firstTime = false;
 
83
         Logger.getLogger("org.jboss.remoting").setLevel(XLevel.INFO);
 
84
         Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO);
 
85
         String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n";
 
86
         PatternLayout layout = new PatternLayout(pattern);
 
87
         ConsoleAppender consoleAppender = new ConsoleAppender(layout);
 
88
         Logger.getRootLogger().addAppender(consoleAppender);  
 
89
      }
 
90
   }
 
91
 
 
92
   
 
93
   public void tearDown()
 
94
   {
 
95
   }
 
96
   
 
97
   
 
98
   public void testTiedToLeaseDefaultConfigurationLocalInvoker() throws Throwable
 
99
   {
 
100
      log.info("entering " + getName());
 
101
      
 
102
      // Start server.
 
103
      setupServer(true);
 
104
      
 
105
      // Create client.
 
106
      InvokerLocator clientLocator = new InvokerLocator(locatorURI);
 
107
      HashMap clientConfig = new HashMap();
 
108
      clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
 
109
      addExtraClientConfig(clientConfig);
 
110
      Client client = new Client(clientLocator, clientConfig);
 
111
      client.connect();
 
112
      log.info("client is connected");
 
113
      
 
114
      // Register client side listener.
 
115
      Object lock = new Object();
 
116
      TestConnectionListener clientListener = new TestConnectionListener(lock);
 
117
      client.addConnectionListener(clientListener);
 
118
      log.info("connection listener added on client side");
 
119
      
 
120
      // Verify ConnectionValidator is running.
 
121
      assertTrue(client.getPingPeriod() > -1);
 
122
      
 
123
      // Test connections.
 
124
      assertEquals("abc", client.invoke("abc"));
 
125
      log.info("connection is good");
 
126
      
 
127
      // Verify LeasePinger is running.
 
128
      assertTrue(client.getInvoker() instanceof MicroRemoteClientInvoker);
 
129
      ClientInvoker clientInvoker = client.getInvoker();
 
130
      Field field = MicroRemoteClientInvoker.class.getDeclaredField("leasePinger");
 
131
      field.setAccessible(true);
 
132
      LeasePinger pinger = (LeasePinger) field.get(clientInvoker);
 
133
      assertNotNull(pinger);
 
134
      field = LeasePinger.class.getDeclaredField("timerTask");
 
135
      field.setAccessible(true);
 
136
      TimerTask timerTask = (TimerTask) field.get(pinger);
 
137
      assertNotNull(timerTask);
 
138
      
 
139
      // Shut down lease on server side.
 
140
      connector.removeConnectionListener(serverListener);
 
141
      
 
142
      // Wait for client side listener to be notified.
 
143
      synchronized (lock)
 
144
      {
 
145
         lock.wait(30000);
 
146
      }
 
147
      
 
148
      // Verify ConnectionValidator has stopped.
 
149
      Thread.sleep(4000);
 
150
      assertTrue(clientListener.notified);
 
151
      assertEquals(-1, client.getPingPeriod());
 
152
      
 
153
      // Verfiy LeasePinger has stopped.
 
154
      timerTask = (TimerTask) field.get(pinger);
 
155
      assertNull(timerTask);
 
156
      
 
157
      client.removeConnectionListener(clientListener);
 
158
      client.disconnect();
 
159
      shutdownServer();
 
160
      log.info(getName() + " PASSES");
 
161
   }
 
162
   
 
163
   
 
164
   public void testTiedToLeaseDefaultConfigurationRemoteInvoker() throws Throwable
 
165
   {
 
166
      log.info("entering " + getName());
 
167
      
 
168
      // Start server.
 
169
      setupServer(true);
 
170
      
 
171
      // Create client.
 
172
      InvokerLocator clientLocator = new InvokerLocator(locatorURI);
 
173
      HashMap clientConfig = new HashMap();
 
174
      clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
 
175
      addExtraClientConfig(clientConfig);
 
176
      Client client = new Client(clientLocator, clientConfig);
 
177
      client.connect();
 
178
      log.info("client is connected");
 
179
      
 
180
      // Register client side listener.
 
181
      Object lock = new Object();
 
182
      TestConnectionListener clientListener = new TestConnectionListener(lock);
 
183
      Map metadata = new HashMap();
 
184
      metadata.put(InvokerLocator.FORCE_REMOTE, "true");
 
185
      client.addConnectionListener(clientListener, metadata);
 
186
      log.info("connection listener added on client side");
 
187
      
 
188
      // Verify ConnectionValidator is running.
 
189
      assertTrue(client.getPingPeriod() > -1);
 
190
      
 
191
      // Test connections.
 
192
      assertEquals("abc", client.invoke("abc"));
 
193
      log.info("connection is good");
 
194
      
 
195
      // Verify LeasePinger is running.
 
196
      assertTrue(client.getInvoker() instanceof MicroRemoteClientInvoker);
 
197
      ClientInvoker clientInvoker = client.getInvoker();
 
198
      Field field = MicroRemoteClientInvoker.class.getDeclaredField("leasePinger");
 
199
      field.setAccessible(true);
 
200
      LeasePinger pinger = (LeasePinger) field.get(clientInvoker);
 
201
      assertNotNull(pinger);
 
202
      field = LeasePinger.class.getDeclaredField("timerTask");
 
203
      field.setAccessible(true);
 
204
      TimerTask timerTask = (TimerTask) field.get(pinger);
 
205
      assertNotNull(timerTask);
 
206
      
 
207
      // Shut down lease on server side.
 
208
      connector.removeConnectionListener(serverListener);
 
209
      
 
210
      // Wait for client side listener to be notified.
 
211
      synchronized (lock)
 
212
      {
 
213
         lock.wait(30000);
 
214
      }
 
215
      
 
216
      // Verify ConnectionValidator has stopped.
 
217
      Thread.sleep(4000);
 
218
      assertTrue(clientListener.notified);
 
219
      assertEquals(-1, client.getPingPeriod());
 
220
      
 
221
      // Verfiy LeasePinger has stopped.
 
222
      timerTask = (TimerTask) field.get(pinger);
 
223
      assertNull(timerTask);
 
224
      
 
225
      client.removeConnectionListener(clientListener);
 
226
      client.disconnect();
 
227
      shutdownServer();
 
228
      log.info(getName() + " PASSES");
 
229
   }
 
230
   
 
231
   
 
232
   public void testTiedToLeaseDontStopLease() throws Throwable
 
233
   {
 
234
     log.info("entering " + getName());
 
235
      
 
236
      // Start server.
 
237
      setupServer(true);
 
238
      
 
239
      // Create client.
 
240
      InvokerLocator clientLocator = new InvokerLocator(locatorURI);
 
241
      HashMap clientConfig = new HashMap();
 
242
      clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
 
243
      addExtraClientConfig(clientConfig);
 
244
      Client client = new Client(clientLocator, clientConfig);
 
245
      client.connect();
 
246
      log.info("client is connected");
 
247
      
 
248
      // Register client side listener.
 
249
      Object lock = new Object();
 
250
      TestConnectionListener clientListener = new TestConnectionListener(lock);
 
251
      Map metadata = new HashMap();
 
252
      metadata.put(InvokerLocator.FORCE_REMOTE, "true");
 
253
      metadata.put(ConnectionValidator.TIE_TO_LEASE, "true");
 
254
      metadata.put(ConnectionValidator.STOP_LEASE_ON_FAILURE, "false");
 
255
      client.addConnectionListener(clientListener, metadata);
 
256
      log.info("connection listener added on client side");
 
257
      
 
258
      // Verify ConnectionValidator is running.
 
259
      assertTrue(client.getPingPeriod() > -1);
 
260
      
 
261
      // Test connections.
 
262
      assertEquals("abc", client.invoke("abc"));
 
263
      log.info("connection is good");
 
264
      
 
265
      // Verify LeasePinger is running.
 
266
      assertTrue(client.getInvoker() instanceof MicroRemoteClientInvoker);
 
267
      ClientInvoker clientInvoker = client.getInvoker();
 
268
      Field field = MicroRemoteClientInvoker.class.getDeclaredField("leasePinger");
 
269
      field.setAccessible(true);
 
270
      LeasePinger pinger = (LeasePinger) field.get(clientInvoker);
 
271
      assertNotNull(pinger);
 
272
      field = LeasePinger.class.getDeclaredField("timerTask");
 
273
      field.setAccessible(true);
 
274
      TimerTask timerTask = (TimerTask) field.get(pinger);
 
275
      assertNotNull(timerTask);
 
276
      
 
277
      // Shut down lease on server side.
 
278
      connector.removeConnectionListener(serverListener);
 
279
      
 
280
      // Wait for client side listener to be notified.
 
281
      synchronized (lock)
 
282
      {
 
283
         lock.wait(30000);
 
284
      }
 
285
      
 
286
      // Verify ConnectionValidator has stopped.
 
287
      Thread.sleep(4000);
 
288
      assertTrue(clientListener.notified);
 
289
      assertEquals(-1, client.getPingPeriod());
 
290
      
 
291
      // Verfiy LeasePinger has not stopped.
 
292
      timerTask = (TimerTask) field.get(pinger);
 
293
      assertNotNull(timerTask);
 
294
      
 
295
      client.removeConnectionListener(clientListener);
 
296
      client.disconnect();
 
297
      shutdownServer();
 
298
      log.info(getName() + " PASSES");
 
299
   }
 
300
   
 
301
   
 
302
   public void testNotTiedToLeaseDontStopLease() throws Throwable
 
303
   {
 
304
     log.info("entering " + getName());
 
305
      
 
306
      // Start server.
 
307
      setupServer(true);
 
308
      
 
309
      // Create client.
 
310
      InvokerLocator clientLocator = new InvokerLocator(locatorURI);
 
311
      HashMap clientConfig = new HashMap();
 
312
      clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
 
313
      addExtraClientConfig(clientConfig);
 
314
      Client client = new Client(clientLocator, clientConfig);
 
315
      client.connect();
 
316
      log.info("client is connected");
 
317
      
 
318
      // Register client side listener.
 
319
      Object lock = new Object();
 
320
      TestConnectionListener clientListener = new TestConnectionListener(lock);
 
321
      Map metadata = new HashMap();
 
322
      metadata.put(InvokerLocator.FORCE_REMOTE, "true");
 
323
      metadata.put(ConnectionValidator.TIE_TO_LEASE, "false");
 
324
      metadata.put(ConnectionValidator.STOP_LEASE_ON_FAILURE, "false");
 
325
      client.addConnectionListener(clientListener, metadata);
 
326
      log.info("connection listener added on client side");
 
327
      
 
328
      // Verify ConnectionValidator is running.
 
329
      assertTrue(client.getPingPeriod() > -1);
 
330
      
 
331
      // Test connections.
 
332
      assertEquals("abc", client.invoke("abc"));
 
333
      log.info("connection is good");
 
334
      
 
335
      // Verify LeasePinger is running.
 
336
      assertTrue(client.getInvoker() instanceof MicroRemoteClientInvoker);
 
337
      ClientInvoker clientInvoker = client.getInvoker();
 
338
      Field field = MicroRemoteClientInvoker.class.getDeclaredField("leasePinger");
 
339
      field.setAccessible(true);
 
340
      LeasePinger pinger = (LeasePinger) field.get(clientInvoker);
 
341
      assertNotNull(pinger);
 
342
      field = LeasePinger.class.getDeclaredField("timerTask");
 
343
      field.setAccessible(true);
 
344
      TimerTask timerTask = (TimerTask) field.get(pinger);
 
345
      assertNotNull(timerTask);
 
346
      
 
347
      // Shut down lease on server side.
 
348
      connector.removeConnectionListener(serverListener);
 
349
      
 
350
      // Wait for client side listener to be notified.
 
351
      synchronized (lock)
 
352
      {
 
353
         lock.wait(30000);
 
354
      }
 
355
      
 
356
      // Verify ConnectionValidator has not stopped.
 
357
      Thread.sleep(4000);
 
358
      assertFalse(clientListener.notified);
 
359
      assertTrue(client.getPingPeriod() > -1);
 
360
      
 
361
      // Verfiy LeasePinger has not stopped.
 
362
      timerTask = (TimerTask) field.get(pinger);
 
363
      assertNotNull(timerTask);
 
364
      
 
365
      client.removeConnectionListener(clientListener);
 
366
      client.disconnect();
 
367
      shutdownServer();
 
368
      log.info(getName() + " PASSES");
 
369
   }
 
370
   
 
371
   
 
372
   public void testNotTiedToLeaseStopLease() throws Throwable
 
373
   {
 
374
     log.info("entering " + getName());
 
375
      
 
376
      // Start server.
 
377
      setupServer(true);
 
378
      
 
379
      // Create client.
 
380
      InvokerLocator clientLocator = new InvokerLocator(locatorURI);
 
381
      HashMap clientConfig = new HashMap();
 
382
      clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
 
383
      addExtraClientConfig(clientConfig);
 
384
      Client client = new Client(clientLocator, clientConfig);
 
385
      client.connect();
 
386
      log.info("client is connected");
 
387
      
 
388
      // Register client side listener.
 
389
      Object lock = new Object();
 
390
      TestConnectionListener clientListener = new TestConnectionListener(lock);
 
391
      Map metadata = new HashMap();
 
392
      metadata.put(InvokerLocator.FORCE_REMOTE, "true");
 
393
      metadata.put(ConnectionValidator.TIE_TO_LEASE, "false");
 
394
      metadata.put(ConnectionValidator.STOP_LEASE_ON_FAILURE, "true");
 
395
      client.addConnectionListener(clientListener, metadata);
 
396
      log.info("connection listener added on client side");
 
397
      
 
398
      // Verify ConnectionValidator is running.
 
399
      assertTrue(client.getPingPeriod() > -1);
 
400
      
 
401
      // Test connections.
 
402
      assertEquals("abc", client.invoke("abc"));
 
403
      log.info("connection is good");
 
404
      
 
405
      // Verify LeasePinger is running.
 
406
      assertTrue(client.getInvoker() instanceof MicroRemoteClientInvoker);
 
407
      ClientInvoker clientInvoker = client.getInvoker();
 
408
      Field field = MicroRemoteClientInvoker.class.getDeclaredField("leasePinger");
 
409
      field.setAccessible(true);
 
410
      LeasePinger pinger = (LeasePinger) field.get(clientInvoker);
 
411
      assertNotNull(pinger);
 
412
      field = LeasePinger.class.getDeclaredField("timerTask");
 
413
      field.setAccessible(true);
 
414
      TimerTask timerTask = (TimerTask) field.get(pinger);
 
415
      assertNotNull(timerTask);
 
416
      
 
417
      // Prevent server from responding to ConnectionValidator pings.
 
418
      ServerInvoker serverInvoker = connector.getServerInvoker();
 
419
      field = ServerInvoker.class.getDeclaredField("started");
 
420
      field.setAccessible(true);
 
421
      field.set(serverInvoker, new Boolean(false));
 
422
      assertFalse(field.getBoolean(serverInvoker));
 
423
      log.info("Stopped server invoker");
 
424
      
 
425
      // Wait for client side listener to be notified.
 
426
      synchronized (lock)
 
427
      {
 
428
         lock.wait(30000);
 
429
      }
 
430
      
 
431
      // Verify ConnectionValidator has stopped.
 
432
      Thread.sleep(4000);
 
433
      assertTrue(clientListener.notified);
 
434
      assertEquals(-1, client.getPingPeriod());
 
435
      
 
436
      // Verfiy LeasePinger has stopped.
 
437
      field = LeasePinger.class.getDeclaredField("timerTask");
 
438
      field.setAccessible(true);
 
439
      timerTask = (TimerTask) field.get(pinger);
 
440
      assertNull(timerTask);
 
441
      
 
442
      client.removeConnectionListener(clientListener);
 
443
      client.disconnect();
 
444
      shutdownServer();
 
445
      log.info(getName() + " PASSES");
 
446
   }
 
447
   
 
448
   
 
449
   public void testTiedToLeaseServerLeasingTurnedOff() throws Throwable
 
450
   {
 
451
      log.info("entering " + getName());
 
452
      
 
453
      // Start server.
 
454
      setupServer(false);
 
455
      
 
456
      // Create client.
 
457
      InvokerLocator clientLocator = new InvokerLocator(locatorURI);
 
458
      HashMap clientConfig = new HashMap();
 
459
      clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
 
460
      addExtraClientConfig(clientConfig);
 
461
      Client client = new Client(clientLocator, clientConfig);
 
462
      client.connect();
 
463
      log.info("client is connected");
 
464
      
 
465
      // Register client side listener.
 
466
      Object lock = new Object();
 
467
      TestConnectionListener clientListener = new TestConnectionListener(lock);
 
468
      Map metadata = new HashMap();
 
469
      metadata.put(InvokerLocator.FORCE_REMOTE, "true");
 
470
      client.addConnectionListener(clientListener, metadata);
 
471
      log.info("connection listener added on client side");
 
472
      
 
473
      // Verify ConnectionValidator is running.
 
474
      assertTrue(client.getPingPeriod() > -1);
 
475
      
 
476
      // Test connections.
 
477
      assertEquals("abc", client.invoke("abc"));
 
478
      log.info("connection is good");
 
479
      
 
480
      // Wait for client side listener to be notified.
 
481
      synchronized (lock)
 
482
      {
 
483
         lock.wait(30000);
 
484
      }
 
485
      
 
486
      // Verify ConnectionValidator has not stopped.
 
487
      Thread.sleep(4000);
 
488
      assertFalse(clientListener.notified);
 
489
      assertTrue(client.getPingPeriod() > -1);
 
490
      
 
491
      client.removeConnectionListener(clientListener);
 
492
      client.disconnect();
 
493
      shutdownServer();
 
494
      log.info(getName() + " PASSES");
 
495
   }
 
496
   
 
497
   
 
498
   protected String getTransport()
 
499
   {
 
500
      return "socket";
 
501
   }
 
502
   
 
503
   
 
504
   protected void addExtraClientConfig(Map config) {}
 
505
   protected void addExtraServerConfig(Map config) {}
 
506
   
 
507
 
 
508
   protected void setupServer(boolean startLeasing) throws Exception
 
509
   {
 
510
      host = InetAddress.getLocalHost().getHostAddress();
 
511
      port = PortUtil.findFreePort(host);
 
512
      locatorURI = getTransport() + "://" + host + ":" + port; 
 
513
      locatorURI += "/?" + InvokerLocator.CLIENT_LEASE + "=true";
 
514
      locatorURI += "&" + InvokerLocator.CLIENT_LEASE_PERIOD + "=4000";
 
515
      serverLocator = new InvokerLocator(locatorURI);
 
516
      log.info("Starting remoting server with locator uri of: " + locatorURI);
 
517
      HashMap config = new HashMap();
 
518
      config.put(InvokerLocator.FORCE_REMOTE, "true");
 
519
      config.put(ServerInvoker.CLIENT_LEASE_PERIOD, "4000");
 
520
      addExtraServerConfig(config);
 
521
      connector = new Connector(serverLocator, config);
 
522
      connector.create();
 
523
      invocationHandler = new TestInvocationHandler();
 
524
      connector.addInvocationHandler("test", invocationHandler);
 
525
      if (startLeasing) 
 
526
      {
 
527
         serverListener = new TestConnectionListener();
 
528
         connector.addConnectionListener(serverListener);
 
529
      }
 
530
      connector.start();
 
531
   }
 
532
   
 
533
   
 
534
   protected void shutdownServer() throws Exception
 
535
   {
 
536
      if (connector != null)
 
537
      {
 
538
         connector.removeConnectionListener(serverListener);
 
539
         connector.stop();
 
540
      }
 
541
   }
 
542
   
 
543
   
 
544
   static class TestInvocationHandler implements ServerInvocationHandler
 
545
   {
 
546
      public void addListener(InvokerCallbackHandler callbackHandler) {}
 
547
      public Object invoke(final InvocationRequest invocation) throws Throwable
 
548
      {
 
549
         return invocation.getParameter();
 
550
      }
 
551
      public void removeListener(InvokerCallbackHandler callbackHandler) {}
 
552
      public void setMBeanServer(MBeanServer server) {}
 
553
      public void setInvoker(ServerInvoker invoker) {}
 
554
   }
 
555
   
 
556
   
 
557
   static class TestConnectionListener implements ConnectionListener
 
558
   {
 
559
      public boolean notified;
 
560
      private Object lock;
 
561
      
 
562
      TestConnectionListener()
 
563
      {
 
564
         this(new Object());
 
565
      }
 
566
      TestConnectionListener(Object lock)
 
567
      {
 
568
         this.lock = lock;
 
569
      }
 
570
      public void handleConnectionException(Throwable throwable, Client client)
 
571
      {
 
572
         notified = true;
 
573
         synchronized (lock)
 
574
         {
 
575
            try
 
576
            {
 
577
               // Give listener a chance to wait on lock.
 
578
               Thread.sleep(4000);
 
579
            }
 
580
            catch (InterruptedException e)
 
581
            {
 
582
               log.info("Unexpected interrupt in TestConnectionListener");
 
583
            }
 
584
            lock.notifyAll();
 
585
         }
 
586
      }
 
587
   }
 
588
}
 
 
b'\\ No newline at end of file'