ThinkTimeRunner implements Runner { @Override public String execute() { String testPlanName = tsc.getTestPlanName(); int min = 1; int max = 1; String minTime = testStep.getMinTime(); String maxTime = testStep.getMaxTime(); try { min = Integer.parseInt(eval(minTime, variables)); } catch (NumberFormatException e1) { LOG.warn(LogUtil.getLogMessage("Error parsing min Think Time from step " + testPlanName) + " with value of " + minTime); } try { max = Integer.parseInt(eval(maxTime, variables)); } catch (NumberFormatException e1) { LOG.warn(LogUtil.getLogMessage("Error parsing max Think Time from step " + testPlanName) + " with value of " + maxTime); max = min; } if (min < 0) { min = 0; } if (min > max) { max = min; } int range = max - min; if (range > 0) { Random random = new Random(); range = random.nextInt(range); } long randomNumber = min + range; LOG.debug("Sleeping for " + randomNumber); if (APITestHarness.getInstance().hasMetSimulationTime() && LOG.isDebugEnabled()) { LOG.debug(LogUtil.getLogMessage("Sleeping from thinkTime for " + randomNumber + "ms. after simulation time has been met with at step " + testPlanName + ".")); } sleep(randomNumber); return TankConstants.HTTP_CASE_PASS; } ThinkTimeRunner(TestStepContext tsc); @Override String execute();  }
@Test public void testExecute_1() throws Exception { TestPlanRunner testPlanRunner = new TestPlanRunner(new HDTestPlan(), 1, "com.intuit.tank.runner.TestHttpClient"); testPlanRunner.setHttpClient(null); TestStepContext testStepContext = new TestStepContext(new ThinkTimeStep(), new Variables(), "", "", new TimerMap(), testPlanRunner); ThinkTimeRunner fixture = new ThinkTimeRunner(testStepContext); String result = fixture.execute(); assertNotNull(result); }
@Test public void testExecute_2() throws Exception { TestPlanRunner testPlanRunner = new TestPlanRunner(new HDTestPlan(), 1, "com.intuit.tank.runner.TestHttpClient"); testPlanRunner.setHttpClient(null); TestStepContext testStepContext = new TestStepContext(new ThinkTimeStep(), new Variables(), "", "", new TimerMap(), testPlanRunner); ThinkTimeRunner fixture = new ThinkTimeRunner(testStepContext); String result = fixture.execute(); assertNotNull(result); }
@Test public void testExecute_3() throws Exception { TestPlanRunner testPlanRunner = new TestPlanRunner(new HDTestPlan(), 1, "com.intuit.tank.runner.TestHttpClient"); testPlanRunner.setHttpClient(null); TestStepContext testStepContext = new TestStepContext(new ThinkTimeStep(), new Variables(), "", "", new TimerMap(), testPlanRunner); ThinkTimeRunner fixture = new ThinkTimeRunner(testStepContext); String result = fixture.execute(); assertNotNull(result); }