@Test
public void testMultipleSemaphoreObservableCommandsInFlight() throws InterruptedException {

    int NUM_COMMANDS = 50;
    List<Observable<Integer>> commands = new ArrayList<Observable<Integer>>();
    for (int i = 0; i < NUM_COMMANDS; i++) {
        commands.add(Observable.defer(new Func0<Observable<Integer>>() {
            @Override
            public Observable<Integer> call() {
                return new AsynchronousObservableCommand().observe();
            }
        }));
    }
    final AtomicBoolean exceptionFound = new AtomicBoolean(false);
    final CountDownLatch latch = new CountDownLatch(1);
    Observable.merge(commands).subscribe(new Subscriber<Integer>() {
        @Override
        public void onCompleted() {
            System.out.println("OnCompleted");
            latch.countDown();
        }
        @Override
        public void onError(Throwable e) {
            System.out.println("OnError : " + e);
            e.printStackTrace();
            exceptionFound.set(true);
            latch.countDown();
        }
        @Override
        public void onNext(Integer n) {
            System.out.println("OnNext : " + n + " : " + Thread.currentThread().getName() + " : " + Hystrix.getCommandCount());// + " : " + Hystrix.getCurrentThreadExecutingCommand().name() + " : " + Hystrix.getCommandCount());
        }
    });
    latch.await();
    assertFalse(exceptionFound.get());
}