@Test public void should_throw_exception_when_error_occurs_calling_doCall() throws Exception { PowerMockito.when(logTrackerCallable,"doCall").thenThrow(Exception.class); doCallRealMethod().when(logTrackerCallable).call(); String returnVal = logTrackerCallable.call(); PowerMockito.verifyStatic(VerificationModeFactory.times(1)); Logger.warn(anyString(), any(Exception.class)); PowerMockito.verifyStatic(VerificationModeFactory.times(1)); LogTrackerUtil.clearContext(); Assert.assertNull(returnVal); }
@Override public T call() throws Exception { try { LogTrackerUtil.setContext(context); return doCall(); } catch (LogTrackerException e) { Logger.warn("Context transfer failed", e); } catch (Exception e) { Logger.warn("Callable exception occurred", e); } finally { LogTrackerUtil.clearContext(); } return null; }
LogTrackerCallable implements Callable<T> { @Override public T call() throws Exception { try { LogTrackerUtil.setContext(context); return doCall(); } catch (LogTrackerException e) { Logger.warn("Context transfer failed", e); } catch (Exception e) { Logger.warn("Callable exception occurred", e); } finally { LogTrackerUtil.clearContext(); } return null; } }
LogTrackerCallable implements Callable<T> { @Override public T call() throws Exception { try { LogTrackerUtil.setContext(context); return doCall(); } catch (LogTrackerException e) { Logger.warn("Context transfer failed", e); } catch (Exception e) { Logger.warn("Callable exception occurred", e); } finally { LogTrackerUtil.clearContext(); } return null; } LogTrackerCallable(); }
LogTrackerCallable implements Callable<T> { @Override public T call() throws Exception { try { LogTrackerUtil.setContext(context); return doCall(); } catch (LogTrackerException e) { Logger.warn("Context transfer failed", e); } catch (Exception e) { Logger.warn("Callable exception occurred", e); } finally { LogTrackerUtil.clearContext(); } return null; } LogTrackerCallable(); @Override T call(); }
LogTrackerCallable implements Callable<T> { @Override public T call() throws Exception { try { LogTrackerUtil.setContext(context); return doCall(); } catch (LogTrackerException e) { Logger.warn("Context transfer failed", e); } catch (Exception e) { Logger.warn("Callable exception occurred", e); } finally { LogTrackerUtil.clearContext(); } return null; } LogTrackerCallable(); @Override T call();  }