@Test public void should_throw_log_tracker_exception_when_error_occurs_setting_context() throws Exception { PowerMockito.when(LogTrackerUtil.class,"setContext", any(Http.Context.class)).thenThrow(LogTrackerException.class); doCallRealMethod().when(logTrackerRunnable).run(); logTrackerRunnable.run(); PowerMockito.verifyStatic(VerificationModeFactory.times(1)); Logger.warn(anyString(), any(LogTrackerException.class)); PowerMockito.verifyStatic(VerificationModeFactory.times(1)); LogTrackerUtil.clearContext(); }
@Override public void run() { try { LogTrackerUtil.setContext(context); doRun(); } catch (LogTrackerException e) { Logger.warn("Context transfer failed", e); } catch (Exception e) { Logger.warn("Runnable exception occurred", e); } finally { LogTrackerUtil.clearContext(); } }
LogTrackerRunnable implements Runnable { @Override public void run() { try { LogTrackerUtil.setContext(context); doRun(); } catch (LogTrackerException e) { Logger.warn("Context transfer failed", e); } catch (Exception e) { Logger.warn("Runnable exception occurred", e); } finally { LogTrackerUtil.clearContext(); } } }
LogTrackerRunnable implements Runnable { @Override public void run() { try { LogTrackerUtil.setContext(context); doRun(); } catch (LogTrackerException e) { Logger.warn("Context transfer failed", e); } catch (Exception e) { Logger.warn("Runnable exception occurred", e); } finally { LogTrackerUtil.clearContext(); } } LogTrackerRunnable(); }
LogTrackerRunnable implements Runnable { @Override public void run() { try { LogTrackerUtil.setContext(context); doRun(); } catch (LogTrackerException e) { Logger.warn("Context transfer failed", e); } catch (Exception e) { Logger.warn("Runnable exception occurred", e); } finally { LogTrackerUtil.clearContext(); } } LogTrackerRunnable(); @Override void run(); }
LogTrackerRunnable implements Runnable { @Override public void run() { try { LogTrackerUtil.setContext(context); doRun(); } catch (LogTrackerException e) { Logger.warn("Context transfer failed", e); } catch (Exception e) { Logger.warn("Runnable exception occurred", e); } finally { LogTrackerUtil.clearContext(); } } LogTrackerRunnable(); @Override void run();  }