### Question:
BasicMonitorProvider extends ExecutionMonitorProvider { @Override public PhaseMonitor newInstance(ExecutionContext context) throws InterruptedException, IOException { if (context == null) { throw new IllegalArgumentException("context must not be null"); } return new LoggingExecutionMonitor(context, stepUnit); }  @Override PhaseMonitor newInstance(ExecutionContext context); static final String KEY_STEP_UNIT; }### Answer:
@Test public void simple() throws Exception { Map<String, String> conf = new HashMap<>(); ServiceProfile<ExecutionMonitorProvider> profile = new ServiceProfile<>( "testing", BasicMonitorProvider.class, conf, ProfileContext.system(getClass().getClassLoader())); ExecutionMonitorProvider instance = profile.newInstance(); try (ExecutionMonitor monitor = instance.newInstance(CONTEXT)) { monitor.open(3); monitor.progressed(1); monitor.progressed(1); monitor.progressed(1); } }
@Test public void with_stepUnit() throws Exception { Map<String, String> conf = new HashMap<>(); conf.put(BasicMonitorProvider.KEY_STEP_UNIT, "0.1"); ServiceProfile<ExecutionMonitorProvider> profile = new ServiceProfile<>( "testing", BasicMonitorProvider.class, conf, ProfileContext.system(getClass().getClassLoader())); ExecutionMonitorProvider instance = profile.newInstance(); try (ExecutionMonitor monitor = instance.newInstance(CONTEXT)) { monitor.open(100); for (int i = 0; i < 100; i++) { monitor.progressed(1); } } }
@Test public void large_stepUnit() throws Exception { Map<String, String> conf = new HashMap<>(); conf.put(BasicMonitorProvider.KEY_STEP_UNIT, "0.5"); ServiceProfile<ExecutionMonitorProvider> profile = new ServiceProfile<>( "testing", BasicMonitorProvider.class, conf, ProfileContext.system(getClass().getClassLoader())); ExecutionMonitorProvider instance = profile.newInstance(); try (ExecutionMonitor monitor = instance.newInstance(CONTEXT)) { monitor.open(100); for (int i = 0; i < 100; i++) { monitor.progressed(1); } } }
@Test(expected = IOException.class) public void invalid_stepUnit() throws Exception { Map<String, String> conf = new HashMap<>(); conf.put(BasicMonitorProvider.KEY_STEP_UNIT, "INVALID"); ServiceProfile<ExecutionMonitorProvider> profile = new ServiceProfile<>( "testing", BasicMonitorProvider.class, conf, ProfileContext.system(getClass().getClassLoader())); profile.newInstance(); }