### Question:
RetryableProcessProvider extends ProcessProvider { @Override public <T> void execute(DriverFactory drivers, ProcessScript<T> script) throws IOException { int maxAttempts = processProfile.getRetryCount() + 1; WGLOG.info("I01000", script.getName(), script.getSourceScript().getResourceName(), script.getDrainScript().getResourceName(), processProfile.getRetryCount()); long start = System.currentTimeMillis(); try { int attempt = 1; while (true) { assert attempt <= maxAttempts; try { processProfile.getComponent().execute(drivers, script); break; } catch (InterruptedIOException e) { WGLOG.error(e, "E01002", script.getName(), script.getSourceScript().getResourceName(), script.getDrainScript().getResourceName()); throw e; } catch (IOException e) { if (attempt < maxAttempts) { WGLOG.warn(e, "W01001", script.getName(), script.getSourceScript().getResourceName(), script.getDrainScript().getResourceName(), attempt, processProfile.getRetryCount()); attempt++; } else { WGLOG.error(e, "E01001", script.getName(), script.getSourceScript().getResourceName(), script.getDrainScript().getResourceName(), maxAttempts); throw e; } } if (processProfile.getRetryInterval() > 0) { try { Thread.sleep(TimeUnit.SECONDS.toMillis( processProfile.getRetryInterval())); } catch (InterruptedException e) { WGLOG.error(e, "E01002", script.getName(), script.getSourceScript().getResourceName(), script.getDrainScript().getResourceName()); throw (IOException) new InterruptedIOException().initCause(e); } } } WGLOG.info("I01001", script.getName(), script.getSourceScript().getResourceName(), script.getDrainScript().getResourceName(), attempt); } finally { long end = System.currentTimeMillis(); WGLOG.info("I01999", script.getName(), script.getSourceScript().getResourceName(), script.getDrainScript().getResourceName(), end - start); } }  @Override void execute(DriverFactory drivers, ProcessScript<T> script);  }### Answer:
@Test public void execute_retry2() throws Exception { ProcessProfile profile = profile(2, Action.EXCEPTION, Action.EXCEPTION, Action.SUCCESS); ProcessProvider provider = profile.createProvider(); provider.execute(factory(), script()); }
@Test public void execute_retry_over() throws Exception { ProcessProfile profile = profile(2, Action.EXCEPTION, Action.EXCEPTION, Action.EXCEPTION, Action.SUCCESS); ProcessProvider provider = profile.createProvider(); try { provider.execute(factory(), script()); fail(); } catch (IOException e) { } }
@Test public void execute_interrupted() throws Exception { ProcessProfile profile = profile(2, Action.INTERRUPT, Action.SUCCESS); ProcessProvider provider = profile.createProvider(); try { provider.execute(factory(), script()); fail(); } catch (IOException e) { } }
@Test public void execute_retry_interval() throws Exception { ProcessProfile profile = profile(2, 1, Action.EXCEPTION, Action.EXCEPTION, Action.SUCCESS); ProcessProvider provider = profile.createProvider(); long start = System.currentTimeMillis(); provider.execute(factory(), script()); long end = System.currentTimeMillis(); assertThat(end - start, is(greaterThan(1200L))); }
@Test public void execute_simple() throws Exception { ProcessProfile profile = profile(2, Action.SUCCESS); ProcessProvider provider = profile.createProvider(); provider.execute(factory(), script()); }
@Test public void execute_retry1() throws Exception { ProcessProfile profile = profile(2, Action.EXCEPTION, Action.SUCCESS); ProcessProvider provider = profile.createProvider(); provider.execute(factory(), script()); }