* Execution hook on successful execution with semaphore isolation
*/
@Test
public void testExecutionHookSuccessfulCommandWithSemaphoreIsolation() {
/* test with execute() */
TestSemaphoreCommand command = new TestSemaphoreCommand(new TestCircuitBreaker(), 1, 10);
command.execute();
assertFalse(command.isExecutedInThread());
// the run() method should run as we're not short-circuited or rejected
assertEquals(1, command.builder.executionHook.startRun.get());
// we expect a successful response from run()
assertNotNull(command.builder.executionHook.runSuccessResponse);
// we do not expect an exception
assertNull(command.builder.executionHook.runFailureException);
// the fallback() method should not be run as we were successful
assertEquals(0, command.builder.executionHook.startFallback.get());
// null since it didn't run
assertNull(command.builder.executionHook.fallbackSuccessResponse);
// null since it didn't run
assertNull(command.builder.executionHook.fallbackFailureException);
// the execute() method was used
assertEquals(1, command.builder.executionHook.startExecute.get());
// we should have a response from execute() since run() succeeded
assertNotNull(command.builder.executionHook.endExecuteSuccessResponse);
// we should not have an exception since run() succeeded
assertNull(command.builder.executionHook.endExecuteFailureException);
// thread execution
assertEquals(0, command.builder.executionHook.threadStart.get());
assertEquals(0, command.builder.executionHook.threadComplete.get());
/* test with queue() */
command = new TestSemaphoreCommand(new TestCircuitBreaker(), 1, 10);
try {
command.queue().get();
} catch (Exception e) {
throw new RuntimeException(e);
}