@Test public void testClose() throws Exception { CommandFuture<Void> future = new DefaultCommandFuture<>(); when(command.execute()).thenReturn(future); future.setFailure(new Exception()); RetryCommandFactory<Void> retryCommandFactory = DefaultRetryCommandFactory.retryForever(scheduled, 0); OneThreadTaskExecutor oneThreadTaskExecutor = new OneThreadTaskExecutor(retryCommandFactory, executors); oneThreadTaskExecutor.executeCommand(command); sleep(100); logger.info("[testClose][destroy]"); oneThreadTaskExecutor.destroy(); retryCommandFactory.destroy(); sleep(50); verify(command, new AtLeast(1)).execute(); verify(command, new AtLeast(1)).reset(); logger.info("[testClose][sleep verify no more interactions]"); sleep(100); verifyNoMoreInteractions(command); }
@Override public void executeCommand(Command<?> command) { if (command instanceof RequestResponseCommand) { super.executeCommand(command); } else { throw new IllegalArgumentException("Only timeout enabled command is allowed"); } }
MutexableOneThreadTaskExecutor extends OneThreadTaskExecutor { @Override public void executeCommand(Command<?> command) { if (command instanceof RequestResponseCommand) { super.executeCommand(command); } else { throw new IllegalArgumentException("Only timeout enabled command is allowed"); } } }
MutexableOneThreadTaskExecutor extends OneThreadTaskExecutor { @Override public void executeCommand(Command<?> command) { if (command instanceof RequestResponseCommand) { super.executeCommand(command); } else { throw new IllegalArgumentException("Only timeout enabled command is allowed"); } } MutexableOneThreadTaskExecutor(Executor executors, ScheduledExecutorService scheduled); }
MutexableOneThreadTaskExecutor extends OneThreadTaskExecutor { @Override public void executeCommand(Command<?> command) { if (command instanceof RequestResponseCommand) { super.executeCommand(command); } else { throw new IllegalArgumentException("Only timeout enabled command is allowed"); } } MutexableOneThreadTaskExecutor(Executor executors, ScheduledExecutorService scheduled); @Override void executeCommand(Command<?> command); @SuppressWarnings("unchecked") void clearAndExecuteCommand(RequestResponseCommand<?> command); }
MutexableOneThreadTaskExecutor extends OneThreadTaskExecutor { @Override public void executeCommand(Command<?> command) { if (command instanceof RequestResponseCommand) { super.executeCommand(command); } else { throw new IllegalArgumentException("Only timeout enabled command is allowed"); } } MutexableOneThreadTaskExecutor(Executor executors, ScheduledExecutorService scheduled); @Override void executeCommand(Command<?> command); @SuppressWarnings("unchecked") void clearAndExecuteCommand(RequestResponseCommand<?> command);  }