Code example for ScheduledFuture

Methods: cancel

0
 
   @SuppressWarnings("unchecked") 
   public void testReplQueueImpl() { 
      ReplicationQueueImpl rqi = new ReplicationQueueImpl();
      ScheduledFuture sf = createMock(ScheduledFuture.class);
      expect(sf.cancel(eq(true))).andReturn(true).once();
 
      ScheduledExecutorService ses = createMock(ScheduledExecutorService.class);
      expect(ses.scheduleWithFixedDelay(EasyMock.<Runnable>anyObject(), anyLong(), anyLong(), EasyMock.<TimeUnit>anyObject()))
         .andReturn(sf).once();
 
      RpcManager rpc = createNiceMock(RpcManager.class);
      CommandsFactory commandsFactory = createNiceMock(CommandsFactory.class);
      Configuration c = new Configuration();
      c.setUseReplQueue(true);
      replay(ses, rpc, commandsFactory,sf);
 
      rqi.injectDependencies(ses, rpc, c, commandsFactory);
 
      rqi.start();
 
      rqi.stop();
 
      verify(ses, rpc, commandsFactory, sf);
   } 
}