HttpDmClient extends AbstractRoutingClient<Session> { @Override protected void process( Session session, Message message ) throws IOException { if( session.isOpen()) { HttpUtils.sendAsynchronously( message, session.getRemote()); } else { this.logger.finer( "Session is not available anymore. No message can be published." ); } } HttpDmClient( HttpRoutingContext routingContext ); @Override void openConnection(); @Override void closeConnection(); @Override void setMessageQueue( RoboconfMessageQueue messageQueue ); @Override String getMessagingType(); @Override Map<String,String> getConfiguration(); @Override void publish( MessagingContext ctx, Message msg ); void processReceivedMessage( Message message, Session session ); void errorWhileReceivingMessage(); void setHttpServerIp( String httpServerIp ); void setHttpPort( int httpPort );  }
@Test public void testProcess() throws Exception { HttpRoutingContext routingContext = new HttpRoutingContext(); HttpDmClient httpDmClient = new HttpDmClient( routingContext ); Message message = Mockito.mock( Message.class ); Session session = Mockito.mock( Session.class ); Mockito.when( session.isOpen()).thenReturn( false ); httpDmClient.process( session, message ); Mockito.verifyZeroInteractions( message ); Mockito.verify( session, Mockito.only()).isOpen(); Mockito.reset( session ); Future<Void> future = Mockito.mock( Future.class ); RemoteEndpoint remote = Mockito.mock( RemoteEndpoint.class ); Mockito.when( remote.sendBytesByFuture( Mockito.any( ByteBuffer.class ) )).thenReturn( future ); Mockito.when( session.getRemote()).thenReturn( remote ); Mockito.when( session.isOpen()).thenReturn( true ); httpDmClient.process( session, message ); Mockito.verifyZeroInteractions( message ); Mockito.verify( session, Mockito.times( 1 )).isOpen(); Mockito.verify( session, Mockito.times( 1 )).getRemote(); Mockito.verifyNoMoreInteractions( session ); }