@Override public void afterRun(TestCaseRunner testRunner, SecurityTestRunContext runContext) { TestCase testCase = testRunner.getTestCase(); SecurityTest securityTest = ((SecurityTestRunner) testRunner).getSecurityTest(); JUnitReport report = new JUnitReport(); report.setIncludeTestProperties(includeTestPropertiesInReport); String reportName = securityTest.getName(); report.setTestSuiteName(reportName); report.setPackage(testCase.getTestSuite().getProject().getName()); int errorCount = 0; for (TestStep ts : testCase.getTestStepList()) { SecurityTestStepResult secuTestStepResult = securityTest.getSecurityTestStepResultMap().get(ts); if (secuTestStepResult != null) { for (SecurityScanResult scanResult : secuTestStepResult.getSecurityScanResultList()) { HashMap<String, String> testProperties = getTestPropertiesAsHashMap(securityTest); List<SecurityScanRequestResult> resultList = scanResult.getSecurityRequestResultList(); Testcase secTestCase = report.addTestCase( ts.getName() + " - " + scanResult.getSecurityScanName(), scanResult.getTimeTaken(), testProperties); secTestCase.setPackage(testCase.getTestSuite().getProject().getName()); for (int i = 0; i < resultList.size(); i++) { SecurityScanRequestResult scanRequestResult = resultList.get(i); if (scanRequestResult.getStatus() == ResultStatus.FAILED) { StringBuffer result = new StringBuffer(); result .append("<pre>") .append(XmlUtils.entitize(scanRequestResult.getChangedParamsInfo(i + 1))) .append("</pre>"); for (String message : scanRequestResult.getMessages()) { result.append("<pre>").append(XmlUtils.entitize(message)).append("</pre>"); } secTestCase.addNewError().setStringValue(result.toString()); errorCount++; } } } } report.setNoofErrorsInTestSuite(errorCount); report.setTotalTime(testRunner.getTimeTaken()); reports.put(reportName, report); } }
@Override public void afterStep( TestCaseRunner testRunner, SecurityTestRunContext runContext, SecurityTestStepResult result) { if (runContext.getCurrentStep().getId().equals(testStep.getId())) { if (!(progressBar.getString().equals(STATE_CANCEL) || progressBar.getString().equals(STATE_MISSING_ASSERTIONS) || progressBar.getString().equals(STATE_MISSING_PARAMETERS)) && securityTest.getSecurityTestStepResultMap().get(testStep) != null) { SecurityTestStepResult results = securityTest.getSecurityTestStepResultMap().get(testStep); /* * This is hack since SecurityTestStepResult.getStatus() do not * returns real state of execution. * * SKIPPED state overides all except FAILED , which is wrong. */ boolean skipped = results.getSecurityScanResultList().size() > 0; for (SecurityScanResult res : results.getSecurityScanResultList()) { if (res.getStatus() == ResultStatus.SKIPPED) continue; else { skipped = false; break; } } if (skipped) { progressBar.setString("SKIPPED"); progressBar.setForeground(UNKNOWN_COLOR); } else { progressBar.setString(STATE_DONE); } } } else progressBar.setBackground(UNKNOWN_COLOR); progressBar.setValue(progressBar.getMaximum() == 0 ? 1 : progressBar.getMaximum()); ((DefaultTreeModel) tree.getModel()).nodeChanged(node); }