DelegateCallback implements IOCallback { @Override public void done() { IOCallback.done(delegates); } DelegateCallback(final Collection<? extends IOCallback> delegates); @Override void done(); @Override void onError(final int errorCode, final String errorMessage);  }
@Test public void shouldCallDoneOnEachCallback() { final CountingIOCallback countingIOCallback = new CountingIOCallback(false); final DelegateCallback callback = new DelegateCallback(Arrays.asList(countingIOCallback, countingIOCallback)); callback.done(); Assert.assertEquals(2, countingIOCallback.done); Assert.assertEquals(0, countingIOCallback.onError); }
@Test public void shouldCallDoneOnEachCallbackWithExceptions() { final CountingIOCallback countingIOCallback = new CountingIOCallback(true); final DelegateCallback callback = new DelegateCallback(Arrays.asList(countingIOCallback, countingIOCallback)); callback.done(); Assert.assertEquals(2, countingIOCallback.done); Assert.assertEquals(0, countingIOCallback.onError); }
@Test public void shouldLogOnDoneForEachExceptions() { AssertionLoggerHandler.startCapture(); try { final CountingIOCallback countingIOCallback = new CountingIOCallback(true); final DelegateCallback callback = new DelegateCallback(Collections.singleton(countingIOCallback)); callback.done(); Assert.assertTrue(AssertionLoggerHandler.findText("AMQ142024")); } finally { AssertionLoggerHandler.stopCapture(); } }