### Question:
AgentDaemon implements Agent { public void run() throws GrinderException { Runtime.getRuntime().addShutdownHook(m_shutdownHook); try { while (true) { m_delegateAgent.run(); m_logger.info("agent finished"); m_sleeper.sleepNormal(m_sleepTime); } } catch (ShutdownException e) { } } AgentDaemon(Logger logger, long sleepTime,  Agent agent);   AgentDaemon(Logger logger, long sleepTime, Agent agent, Sleeper sleeper); void run(); void shutdown();  }### Answer:
@Test public void testRun() throws Exception { final ActionListSleeperStubFactory sleeperStubFactory = new ActionListSleeperStubFactory( new SleepAction[] { new SleepAction() { public void sleep(long time) throws ShutdownException { assertEquals(1000, time); } }, new SleepAction() { public void sleep(long time) throws ShutdownException { assertEquals(1000, time); throw new ShutdownException(""); } } } ); final AgentDaemon agentDaemon = new AgentDaemon(m_logger, 1000, m_agent, sleeperStubFactory.getStub()); agentDaemon.run(); sleeperStubFactory.assertFinished(); }