@Test public void testBinaryMessageInError() { HttpClientFactory httpClientFatory = Mockito.spy( new HttpClientFactory()); httpClientFatory.getDmClient().setMessageQueue( new RoboconfMessageQueue()); DmWebSocket socket = new DmWebSocket( httpClientFatory ); socket.onWebSocketBinary( new byte[1], 0, 1 ); }
@Override public void onWebSocketBinary( byte[] payload, int offset, int len ) { this.logger.finest( "A binary message was received." ); try { Message msg = HttpSerializationUtils.deserializeObject( payload ); this.logger.finest( "The received message was deserialized as an instance of " + msg.getClass().getSimpleName()); this.httpClientFactory.getDmClient().processReceivedMessage( msg, this.session ); } catch( ClassNotFoundException | IOException e ) { this.logger.severe( "A message could not be deserialized. => " + e.getClass().getSimpleName()); Utils.logException( this.logger, e ); this.httpClientFactory.getDmClient().errorWhileReceivingMessage(); } }
DmWebSocket implements WebSocketListener { @Override public void onWebSocketBinary( byte[] payload, int offset, int len ) { this.logger.finest( "A binary message was received." ); try { Message msg = HttpSerializationUtils.deserializeObject( payload ); this.logger.finest( "The received message was deserialized as an instance of " + msg.getClass().getSimpleName()); this.httpClientFactory.getDmClient().processReceivedMessage( msg, this.session ); } catch( ClassNotFoundException | IOException e ) { this.logger.severe( "A message could not be deserialized. => " + e.getClass().getSimpleName()); Utils.logException( this.logger, e ); this.httpClientFactory.getDmClient().errorWhileReceivingMessage(); } } }
DmWebSocket implements WebSocketListener { @Override public void onWebSocketBinary( byte[] payload, int offset, int len ) { this.logger.finest( "A binary message was received." ); try { Message msg = HttpSerializationUtils.deserializeObject( payload ); this.logger.finest( "The received message was deserialized as an instance of " + msg.getClass().getSimpleName()); this.httpClientFactory.getDmClient().processReceivedMessage( msg, this.session ); } catch( ClassNotFoundException | IOException e ) { this.logger.severe( "A message could not be deserialized. => " + e.getClass().getSimpleName()); Utils.logException( this.logger, e ); this.httpClientFactory.getDmClient().errorWhileReceivingMessage(); } } DmWebSocket( HttpClientFactory httpClientFactory ); }
DmWebSocket implements WebSocketListener { @Override public void onWebSocketBinary( byte[] payload, int offset, int len ) { this.logger.finest( "A binary message was received." ); try { Message msg = HttpSerializationUtils.deserializeObject( payload ); this.logger.finest( "The received message was deserialized as an instance of " + msg.getClass().getSimpleName()); this.httpClientFactory.getDmClient().processReceivedMessage( msg, this.session ); } catch( ClassNotFoundException | IOException e ) { this.logger.severe( "A message could not be deserialized. => " + e.getClass().getSimpleName()); Utils.logException( this.logger, e ); this.httpClientFactory.getDmClient().errorWhileReceivingMessage(); } } DmWebSocket( HttpClientFactory httpClientFactory ); @Override void onWebSocketBinary( byte[] payload, int offset, int len ); @Override void onWebSocketClose( int statusCode, String reason ); @Override void onWebSocketConnect( Session session ); @Override void onWebSocketError( Throwable cause ); @Override void onWebSocketText( String message ); }
DmWebSocket implements WebSocketListener { @Override public void onWebSocketBinary( byte[] payload, int offset, int len ) { this.logger.finest( "A binary message was received." ); try { Message msg = HttpSerializationUtils.deserializeObject( payload ); this.logger.finest( "The received message was deserialized as an instance of " + msg.getClass().getSimpleName()); this.httpClientFactory.getDmClient().processReceivedMessage( msg, this.session ); } catch( ClassNotFoundException | IOException e ) { this.logger.severe( "A message could not be deserialized. => " + e.getClass().getSimpleName()); Utils.logException( this.logger, e ); this.httpClientFactory.getDmClient().errorWhileReceivingMessage(); } } DmWebSocket( HttpClientFactory httpClientFactory ); @Override void onWebSocketBinary( byte[] payload, int offset, int len ); @Override void onWebSocketClose( int statusCode, String reason ); @Override void onWebSocketConnect( Session session ); @Override void onWebSocketError( Throwable cause ); @Override void onWebSocketText( String message );  }