LogicRunner implements Runner { public String execute() { String ret = TankConstants.HTTP_CASE_PASS; AgentLoggingOutputLogger outputLogger = new AgentLoggingOutputLogger(); Map<String, Object> inputs = new HashMap<String, Object>(); inputs.put("variables", tsc.getVariables()); if (tsc.getRequest() != null) { inputs.put("request", tsc.getRequest()); } if (tsc.getResponse() != null) { inputs.put("response", tsc.getResponse()); } String scriptToRun = new LogicScriptUtil().buildScript(step.getScript()); try { ScriptIOBean ioBean = new ScriptRunner().runScript(step.getName(), scriptToRun, new ScriptEngineManager().getEngineByExtension("js"), inputs, outputLogger); String action = (String) ioBean.getOutput("action"); if (action != null) { ret = handleAction(action); } } catch (Exception e) { LOG.error(LogUtil.getLogMessage("Error running script: " + e, LogEventType.Informational, LoggingProfile.VERBOSE), e); LOG.error("Script:\n" + scriptToRun); step.setOnFail(TankConstants.HTTP_CASE_ABORT); ret = TankConstants.HTTP_CASE_FAIL; } return ret; } LogicRunner(TestStepContext tsc); 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 LogicStep(), new Variables(), "", "", new TimerMap(), testPlanRunner); LogicRunner fixture = new LogicRunner(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 LogicStep(), new Variables(), "", "", new TimerMap(), testPlanRunner); LogicRunner fixture = new LogicRunner(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 LogicStep(), new Variables(), "", "", new TimerMap(), testPlanRunner); LogicRunner fixture = new LogicRunner(testStepContext); String result = fixture.execute(); assertNotNull(result); }