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