@@ -487,6 +487,43 @@ public void test402a() throws Exception {
487487 Assert .assertEquals (after_count , before_thread_count + pool_size );
488488 }
489489
490+ @ Test
491+ public void testDisconnectForcibly () throws Exception {
492+ String methodName = Utility .getMethodName ();
493+ LoggingUtilities .banner (log , cclass , methodName );
494+
495+ IMqttClient client = null ;
496+ try {
497+ String clientId = methodName ;
498+ client = clientFactory .createMqttClient (serverURI , clientId );
499+
500+ log .info ("Connecting...(serverURI:" + serverURI + ", ClientId:" + clientId );
501+ client .connect ();
502+ boolean isConnected = client .isConnected ();
503+ log .info ("isConnected = " + isConnected );
504+ log .info ("Disconnecting Forcibly with no timeout" );
505+ client .disconnectForcibly ();
506+
507+ log .info ("Re-Connecting..." );
508+ client .connect ();
509+ isConnected = client .isConnected ();
510+ log .info ("isConnected = " + isConnected );
511+ log .info ("Disconnecting Forcibly with 2 sec timeout" );
512+ client .disconnectForcibly (2000 , 2000 );
513+ }
514+ catch (MqttException exception ) {
515+ log .log (Level .SEVERE , "caught exception:" , exception );
516+ Assert .fail ("Unexpected exception: " + exception );
517+ }
518+ finally {
519+ if (client != null ) {
520+ log .info ("Close..." );
521+ client .close ();
522+ }
523+ }
524+ }
525+
526+
490527
491528 // -------------------------------------------------------------
492529 // Helper methods/classes
0 commit comments