Best Cerberus-source code snippet using org.cerberus.crud.entity.TestCaseExecution.getRobotLog
Source:RunTestCaseV002.java
...131 String timeout = "";132 String screenSize = "";133 boolean synchroneous = true;134 int getPageSource = 0;135 int getRobotLog = 0;136 int getConsoleLog = 0;137 String manualExecution = "N";138 //Test139 String test = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter(PARAMETER_TEST), "");140 String testCase = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter(PARAMETER_TEST_CASE), "");141 String country = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter(PARAMETER_COUNTRY), "");142 String environment = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter(PARAMETER_ENVIRONMENT), "");143 //Test Dev Environment144 int manualURL = ParameterParserUtil.parseIntegerParam(request.getParameter(PARAMETER_MANUAL_URL), 0);145 String myHost = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter(PARAMETER_MANUAL_HOST), "");146 String myContextRoot = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter(PARAMETER_MANUAL_CONTEXT_ROOT), "");147 String myLoginRelativeURL = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter(PARAMETER_MANUAL_LOGIN_RELATIVE_URL), "");148 //TODO find another solution149 myLoginRelativeURL = myLoginRelativeURL.replace("=", "=");150 String myEnvData = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter(PARAMETER_MANUAL_ENV_DATA), "");151 //Execution152 String tag = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter(PARAMETER_TAG), "");153 String outputFormat = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter(PARAMETER_OUTPUT_FORMAT), "compact");154 int screenshot = ParameterParserUtil.parseIntegerParam(request.getParameter(PARAMETER_SCREENSHOT), 1);155 int video = ParameterParserUtil.parseIntegerParam(request.getParameter(PARAMETER_VIDEO), 0);156 int verbose = ParameterParserUtil.parseIntegerParam(request.getParameter(PARAMETER_VERBOSE), 0);157 timeout = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter(PARAMETER_TIMEOUT), "");158 synchroneous = ParameterParserUtil.parseBooleanParam(request.getParameter(PARAMETER_SYNCHRONEOUS), false);159 getPageSource = ParameterParserUtil.parseIntegerParam(request.getParameter(PARAMETER_PAGE_SOURCE), 1);160 getRobotLog = ParameterParserUtil.parseIntegerParam(request.getParameter(PARAMETER_ROBOT_LOG), 1);161 getConsoleLog = ParameterParserUtil.parseIntegerParam(request.getParameter(PARAMETER_CONSOLE_LOG), 1);162 manualExecution = ParameterParserUtil.parseStringParam(request.getParameter(PARAMETER_MANUAL_EXECUTION), "N");163 int numberOfRetries = ParameterParserUtil.parseIntegerParam(request.getParameter(PARAMETER_NUMBER_OF_RETRIES), 0);164 screenSize = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter(PARAMETER_SCREEN_SIZE), "");165 robot = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter(PARAMETER_ROBOT), "");166 robotHost = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter(PARAMETER_ROBOT_HOST), "");167 robotPort = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter(PARAMETER_ROBOT_PORT), "");168 robotExecutor = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter(PARAMETER_ROBOTEXECUTOR), "");169 browser = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter("Browser"), ParameterParserUtil.parseStringParamAndSanitize(request.getParameter(PARAMETER_BROWSER), ""));170 version = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter(PARAMETER_BROWSER_VERSION), "");171 platform = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter(PARAMETER_PLATFORM), "");172 // hidden parameters.173 long idFromQueue = ParameterParserUtil.parseIntegerParam(request.getParameter("IdFromQueue"), 0);174 String executor = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter(PARAMETER_EXECUTOR), ParameterParserUtil.parseStringParamAndSanitize(request.getRemoteUser(), ""));175 String helpMessage = "\nThis servlet is used to start the execution of a test case.\n"176 + "Parameter list :\n"177 + "- " + PARAMETER_TEST + " [mandatory] : Test to execute. [" + test + "]\n"178 + "- " + PARAMETER_TEST_CASE + " [mandatory] : Test Case reference to execute. [" + testCase + "]\n"179 + "- " + PARAMETER_COUNTRY + " [mandatory] : Country where the test case will execute. [" + country + "]\n"180 + "- " + PARAMETER_ENVIRONMENT + " : Environment where the test case will execute. This parameter is mandatory only if manualURL is not set to Y. [" + environment + "]\n"181 + "- " + PARAMETER_ROBOT + " : robot name on which the test will be executed. [" + robot + "]\n"182 + "- " + PARAMETER_ROBOT_HOST + " : Host of the Robot where the test will be executed. (Can be overwriten if robot is defined) [" + robotHost + "]\n"183 + "- " + PARAMETER_ROBOT_PORT + " : Port of the Robot. (Can be overwriten if robot is defined) [" + robotPort + "]\n"184 + "- " + PARAMETER_BROWSER + " : Browser to use for the execution. (Can be overwriten if robot is defined) [" + browser + "]\n"185 + "- " + PARAMETER_BROWSER_VERSION + " : Version to use for the execution. (Can be overwriten if robot is defined) [" + version + "]\n"186 + "- " + PARAMETER_PLATFORM + " : Platform to use for the execution. (Can be overwriten if robot is defined) [" + platform + "]\n"187 + "- " + PARAMETER_SCREEN_SIZE + " : Size of the screen to set for the execution. [" + screenSize + "]\n"188 + "- " + PARAMETER_MANUAL_URL + " : Activate (1) or not (0) or Override (2) the Manual URL of the application to execute. If Activated (1) the 4 parameters after are necessary. If Override (2) at least 1 parameters after are necessary (other parameters will use cerberus values) [" + manualURL + "]\n"189 + "- " + PARAMETER_MANUAL_HOST + " : Host of the application to test (only used when " + PARAMETER_MANUAL_URL + " is activated or override). [" + myHost + "].\n"190 + "- " + PARAMETER_MANUAL_CONTEXT_ROOT + " : Context root of the application to test (only used when " + PARAMETER_MANUAL_URL + " is activated or override). [" + myContextRoot + "]\n"191 + "- " + PARAMETER_MANUAL_LOGIN_RELATIVE_URL + " : Relative login URL of the application (only used when " + PARAMETER_MANUAL_URL + " is activated or override). [" + myLoginRelativeURL + "]\n"192 + "- " + PARAMETER_MANUAL_ENV_DATA + " : Environment where to get the test data when a " + PARAMETER_MANUAL_URL + " is defined. (only used when manualURL is active or override). [" + myEnvData + "]\n"193 + "- " + PARAMETER_TAG + " : Tag that will be stored on the execution. [" + tag + "]\n"194 + "- " + PARAMETER_OUTPUT_FORMAT + " : Format of the output of the execution. [" + outputFormat + "]\n"195 + "- " + PARAMETER_SCREENSHOT + " : Activate or not the screenshots. [" + screenshot + "]\n"196 + "- " + PARAMETER_VIDEO + " : Activate or not the video. [" + video + "]\n"197 + "- " + PARAMETER_VERBOSE + " : Verbose level of the execution. [" + verbose + "]\n"198 + "- " + PARAMETER_TIMEOUT + " : Timeout used for the action. If empty, the default value will be the one configured in parameter table. [" + timeout + "]\n"199 + "- " + PARAMETER_SYNCHRONEOUS + " : Synchroneous define if the servlet wait for the end of the execution to report its execution. [" + synchroneous + "\n"200 + "- " + PARAMETER_PAGE_SOURCE + " : Record Page Source during the execution. [" + getPageSource + "]\n"201 + "- " + PARAMETER_ROBOT_LOG + " : Get the Robot Log at the end of the execution. [" + getRobotLog + "]\n"202 + "- " + PARAMETER_CONSOLE_LOG + " : Get the Console Log at the end of the execution. [" + getConsoleLog + "]\n"203 + "- " + PARAMETER_MANUAL_EXECUTION + " : Execute testcase in manual mode. [" + manualExecution + "]\n"204 + "- " + PARAMETER_NUMBER_OF_RETRIES + " : Number of tries if the result is not OK. [" + numberOfRetries + "]\n";205 boolean error = false;206 String errorMessage = "";207 // -- Checking the parameter validity. --208 // test, testcase and country parameters are mandatory209 if (StringUtil.isNullOrEmpty(test)) {210 errorMessage += "Error - Parameter Test is mandatory. ";211 error = true;212 }213 if (StringUtil.isNullOrEmpty(testCase)) {214 errorMessage += "Error - Parameter TestCase is mandatory. ";215 error = true;216 }217 if (!StringUtil.isNullOrEmpty(tag) && tag.length() > 255) {218 errorMessage += "Error - Parameter Tag value is too big. Tag cannot be larger than 255 Characters. Currently has : " + tag.length();219 error = true;220 }221 if (StringUtil.isNullOrEmpty(country)) {222 errorMessage += "Error - Parameter Country is mandatory. ";223 error = true;224 }225 // environment is mandatory when manualURL is not activated.226 if (StringUtil.isNullOrEmpty(environment) && ((manualURL == 0) || (manualURL == 2))) {227 errorMessage += "Error - Parameter Environment is mandatory (or activate the manualURL parameter). ";228 error = true;229 }230 // myenv is mandatory when manualURL is activated.231 if (StringUtil.isNullOrEmpty(myEnvData) && ((manualURL == 1) || (manualURL == 2))) {232 if (StringUtil.isNullOrEmpty(environment)) {233 errorMessage += "Error - Parameter myenvdata is mandatory (when manualURL parameter is activated). ";234 error = true;235 } else {236 myEnvData = environment;237 }238 }239 // We check that execution is not desactivated by cerberus_automaticexecution_enable parameter.240 IParameterService parameterService = appContext.getBean(IParameterService.class);241 if (!(parameterService.getParameterBooleanByKey("cerberus_automaticexecution_enable", "", true))) {242 errorMessage += "Error - Execution disable by configuration (cerberus_automaticexecution_enable <> Y). ";243 error = true;244 LOG.info("Execution request ignored by cerberus_automaticexecution_enable parameter. " + test + " / " + testCase);245 }246 //verify the format of the ScreenSize. It must be 2 integer separated by a *. For example : 1024*768247 if (!"".equals(screenSize)) {248 if (!screenSize.contains("*")) {249 errorMessage += "Error - ScreenSize format is not Correct. It must be 2 Integer separated by a *. ";250 error = true;251 } else {252 try {253 String screenWidth = screenSize.split("\\*")[0];254 String screenLength = screenSize.split("\\*")[1];255 Integer.parseInt(screenWidth);256 Integer.parseInt(screenLength);257 } catch (Exception e) {258 errorMessage += "Error - ScreenSize format is not Correct. It must be 2 Integer separated by a *. ";259 error = true;260 }261 }262 }263 // Create Tag when exist.264 if (!StringUtil.isNullOrEmpty(tag)) {265 // We create or update it.266 ITagService tagService = appContext.getBean(ITagService.class);267 List<String> envList = new ArrayList<>();268 envList.add(environment);269 List<String> countryList = new ArrayList<>();270 countryList.add(country);271 tagService.createAuto(tag, "", executor, new JSONArray(envList), new JSONArray(countryList));272 }273 if (!error) {274 //TODO:FN debug messages to be removed275 LOG.debug("STARTED: Test " + test + "-" + testCase);276 IRunTestCaseService runTestCaseService = appContext.getBean(IRunTestCaseService.class);277 IFactoryTestCase factoryTCase = appContext.getBean(IFactoryTestCase.class);278 IFactoryTestCaseExecution factoryTCExecution = appContext.getBean(IFactoryTestCaseExecution.class);279 IFactoryTestCaseExecutionQueue factoryTCExecutionQueue = appContext.getBean(IFactoryTestCaseExecutionQueue.class);280 ITestCaseExecutionService tces = appContext.getBean(ITestCaseExecutionService.class);281 ITestCaseService tcs = appContext.getBean(ITestCaseService.class);282 TestCase tCase = factoryTCase.create(test, testCase);283 // Building Execution Object.284 TestCaseExecution tCExecution = factoryTCExecution.create(0, test, testCase, null, null, null, environment, country, robot, robotExecutor, robotHost, robotPort, "", browser, version, platform,285 0, 0, "", "", "", null, null, tag, verbose, screenshot, video, getPageSource, getRobotLog, getConsoleLog, synchroneous, timeout, outputFormat, null,286 Infos.getInstance().getProjectNameAndVersion(), tCase, null, null, manualURL, myHost, myContextRoot, myLoginRelativeURL, myEnvData, robotHost, robotPort,287 null, new MessageGeneral(MessageGeneralEnum.EXECUTION_PE_TESTSTARTED), executor, numberOfRetries, screenSize, null, "", "",288 "", "", "", "", "", "", "", manualExecution, "", 0, 0, "", executor, null, executor, null);289 /**290 * Set IdFromQueue291 */292 try {293 tCExecution.setQueueID(idFromQueue);294 TestCaseExecutionQueue queueExecution = factoryTCExecutionQueue.create(idFromQueue, "", test, testCase, country, environment, robot, "", robotHost, robotPort, browser, version,295 platform, screenSize, 0, myHost, myContextRoot, myLoginRelativeURL, myEnvData, tag, screenshot, video, verbose, timeout, getPageSource, getRobotLog, getConsoleLog, 0, numberOfRetries,296 manualExecution, executor, null, null, null);297 tCExecution.setTestCaseExecutionQueue(queueExecution);298 } catch (FactoryCreationException ex) {299 LOG.error(ex, ex);300 }301 /**302 * Set UUID303 */304 ExecutionUUID executionUUIDObject = appContext.getBean(ExecutionUUID.class);305 UUID executionUUID = UUID.randomUUID();306 executionUUIDObject.setExecutionUUID(executionUUID.toString(), tCExecution);307 tCExecution.setExecutionUUID(executionUUID.toString());308 LOG.info("Execution Requested : UUID=" + executionUUID);309 /**310 * Execution of the testcase.311 */312 LOG.debug("Start execution " + tCExecution.getId());313 tCExecution = runTestCaseService.runTestCase(tCExecution);314 /**315 * Clean memory in case testcase has not been316 * launched(Remove all object put in memory)317 */318 try {319 if (tCExecution.getId() == 0) {320 executionUUIDObject.removeExecutionUUID(tCExecution.getExecutionUUID());321 LOG.debug("Clean ExecutionUUID");322 }323 } catch (Exception ex) {324 LOG.error("Exception cleaning Memory: ", ex);325 }326 /**327 * Execution is finished we report the result.328 */329 long runID = tCExecution.getId();330 switch (outputFormat) {331 case "gui":332 if (runID > 0) { // Execution has been created.333 response.sendRedirect("TestCaseExecution.jsp?executionId=" + runID);334 } else { // Execution was not even created.335 response.setContentType("text/html");336 out.println("<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><title>Test Execution Result</title></head>");337 out.println("<body>");338 out.println("<table>");339 out.println("<tr><td>RunID</td><td><span id='RunID'>" + runID + "</span></td></tr>");340 out.println("<tr><td>IdFromQueue</td><td><b><span id='IdFromQueue'>" + tCExecution.getQueueID() + "</span></b></td></tr>");341 out.println("<tr><td>Test</td><td><span id='Test'>" + test + "</span></td></tr>");342 out.println("<tr><td>TestCase</td><td><span id='TestCase'>" + testCase + "</span></td></tr>");343 out.println("<tr><td>Country</td><td><span id='Country'>" + country + "</span></td></tr>");344 out.println("<tr><td>Environment</td><td><span id='Environment'>" + environment + "</span></td></tr>");345 out.println("<tr><td>TimestampStart</td><td><span id='TimestampStart'>" + new Timestamp(tCExecution.getStart()) + "</span></td></tr>");346 out.println("<tr><td>TimestampEnd</td><td><span id='TimestampEnd'>" + new Timestamp(tCExecution.getEnd()) + "</span></td></tr>");347 out.println("<tr><td>OutputFormat</td><td><span id='OutputFormat'>" + outputFormat + "</span></td></tr>");348 out.println("<tr><td>Verbose</td><td><span id='Verbose'>" + verbose + "</span></td></tr>");349 out.println("<tr><td>Screenshot</td><td><span id='Screenshot'>" + screenshot + "</span></td></tr>");350 out.println("<tr><td>PageSource</td><td><span id='PageSource'>" + getPageSource + "</span></td></tr>");351 out.println("<tr><td>SeleniumLog</td><td><span id='SeleniumLog'>" + getRobotLog + "</span></td></tr>");352 out.println("<tr><td>Robot</td><td><span id='Robot'>" + robot + "</span></td></tr>");353 out.println("<tr><td>Robot Server IP</td><td><span id='SeleniumIP'>" + robotHost + "</span></td></tr>");354 out.println("<tr><td>Robot Server Port</td><td><span id='SeleniumPort'>" + robotPort + "</span></td></tr>");355 out.println("<tr><td>Timeout</td><td><span id='Timeout'>" + timeout + "</span></td></tr>");356 out.println("<tr><td>Synchroneous</td><td><span id='Synchroneous'>" + synchroneous + "</span></td></tr>");357 out.println("<tr><td>Browser</td><td><span id='Browser'>" + browser + "</span></td></tr>");358 out.println("<tr><td>Version</td><td><span id='Version'>" + version + "</span></td></tr>");359 out.println("<tr><td>Platform</td><td><span id='Platform'>" + platform + "</span></td></tr>");360 out.println("<tr><td>Screen Size</td><td><span id='screenSize'>" + screenSize + "</span></td></tr>");361 out.println("<tr><td>Number of Retry</td><td><span id='nbretry'>" + numberOfRetries + "</span></td></tr>");362 out.println("<tr><td>ManualURL</td><td><span id='ManualURL'>" + tCExecution.getManualURL() + "</span></td></tr>");363 out.println("<tr><td>MyHost</td><td><span id='MyHost'>" + tCExecution.getMyHost() + "</span></td></tr>");364 out.println("<tr><td>MyContextRoot</td><td><span id='MyContextRoot'>" + tCExecution.getMyContextRoot() + "</span></td></tr>");365 out.println("<tr><td>MyLoginRelativeURL</td><td><span id='MyLoginRelativeURL'>" + tCExecution.getMyLoginRelativeURL() + "</span></td></tr>");366 out.println("<tr><td>myEnvironmentData</td><td><span id='myEnvironmentData'>" + tCExecution.getEnvironmentData() + "</span></td></tr>");367 out.println("<tr><td>ReturnCode</td><td><b><span id='ReturnCodeDescription'>" + tCExecution.getResultMessage().getCode() + "</span></b></td></tr>");368 out.println("<tr><td>ReturnCodeDescription</td><td><b><span id='ReturnCodeDescription'>" + tCExecution.getResultMessage().getDescription() + "</span></b></td></tr>");369 out.println("<tr><td>ControlStatus</td><td><b><span id='ReturnCodeMessage'>" + tCExecution.getResultMessage().getCodeString() + "</span></b></td></tr>");370 out.println("<tr><td></td><td></td></tr>");371 out.println("</table><br><br>");372 out.println("<table border>");373 out.println("<tr>"374 + "<td><input id=\"ButtonRetry\" type=\"button\" value=\"Retry\" onClick=\"window.location.reload()\"></td>"375 + "<td><input id=\"ButtonBack\" type=\"button\" value=\"Go Back\" onClick=\"window.history.back()\"></td>"376 + "<td><input id=\"ButtonOpenTC\" type=\"button\" value=\"Open Test Case\" onClick=\"window.open('TestCaseScript.jsp?test=" + test + "&testcase=" + testCase + "')\"></td>"377 + "</tr>");378 out.println("</table>");379 out.println("</body>");380 out.println("</html>");381 }382 break;383 case "verbose-txt":384 response.setContentType("text/plain");385 String separator = " = ";386 out.println("id" + separator + runID);387 out.println("queueID" + separator + idFromQueue);388 out.println("test" + separator + test);389 out.println("testcase" + separator + testCase);390 out.println("country" + separator + country);391 out.println("environment" + separator + environment);392 out.println("Time Start" + separator + new Timestamp(tCExecution.getStart()));393 out.println("Time End" + separator + new Timestamp(tCExecution.getEnd()));394 out.println("OutputFormat" + separator + outputFormat);395 out.println("Verbose" + separator + verbose);396 out.println("Screenshot" + separator + screenshot);397 out.println("PageSource" + separator + getPageSource);398 out.println("SeleniumLog" + separator + getRobotLog);399 out.println("Robot" + separator + robot);400 out.println("Robot Server IP" + separator + robotHost);401 out.println("Robot Server Port" + separator + robotPort);402 out.println("Timeout" + separator + timeout);403 out.println("Synchroneous" + separator + synchroneous);404 out.println("Browser" + separator + browser);405 out.println("Version" + separator + version);406 out.println("Platform" + separator + platform);407 out.println("ScreenSize" + separator + screenSize);408 out.println("Nb Of Retry" + separator + numberOfRetries);409 out.println("ManualURL" + separator + tCExecution.getManualURL());410 out.println("MyHost" + separator + tCExecution.getMyHost());411 out.println("MyContextRoot" + separator + tCExecution.getMyContextRoot());412 out.println("MyLoginRelativeURL" + separator + tCExecution.getMyLoginRelativeURL());413 out.println("myEnvironmentData" + separator + tCExecution.getEnvironmentData());414 out.println("ReturnCode" + separator + tCExecution.getResultMessage().getCode());415 out.println("controlMessage" + separator + tCExecution.getResultMessage().getDescription());416 out.println("controlStatus" + separator + tCExecution.getResultMessage().getCodeString());417 break;418 case "verbose-json":419 case "json":420 try {421 JSONObject jsonResponse = new JSONObject();422 response.setContentType("application/json");423 response.setCharacterEncoding("utf8");424 jsonResponse.put("id", runID);425 jsonResponse.put("queueID", idFromQueue);426 jsonResponse.put("test", test);427 jsonResponse.put("testcase", testCase);428 jsonResponse.put("country", country);429 jsonResponse.put("environment", environment);430 jsonResponse.put("Time Start", new Timestamp(tCExecution.getStart()));431 jsonResponse.put("Time End", new Timestamp(tCExecution.getEnd()));432 jsonResponse.put("OutputFormat", outputFormat);433 jsonResponse.put("Verbose", verbose);434 jsonResponse.put("Screenshot", screenshot);435 jsonResponse.put("PageSource", getPageSource);436 jsonResponse.put("SeleniumLog", getRobotLog);437 jsonResponse.put("Robot", robot);438 jsonResponse.put("Robot Server IP", robotHost);439 jsonResponse.put("Robot Server Port", robotPort);440 jsonResponse.put("Timeout", timeout);441 jsonResponse.put("Synchroneous", synchroneous);442 jsonResponse.put("Browser", browser);443 jsonResponse.put("Version", version);444 jsonResponse.put("Platform", platform);445 jsonResponse.put("ScreenSize", screenSize);446 jsonResponse.put("Nb Of Retry", numberOfRetries);447 jsonResponse.put("ManualURL", manualURL);448 jsonResponse.put("MyHost", myHost);449 jsonResponse.put("MyContextRoot", myContextRoot);450 jsonResponse.put("MyLoginRelativeURL", myLoginRelativeURL);451 jsonResponse.put("myEnvironmentData", myEnvData);452 jsonResponse.put("ReturnCode", tCExecution.getResultMessage().getCode());453 jsonResponse.put("controlStatus", tCExecution.getResultMessage().getCodeString());454 jsonResponse.put("controlMessage", tCExecution.getResultMessage().getDescription());455 if (runID > 0) { // Execution has been created.456 // Detail of the execution is returned from memory.457 jsonResponse.put("executionDetail", tCExecution.toJson(true));458// TestCaseExecution t = (TestCaseExecution) tces.readByKeyWithDependency(runID).getItem();459// jsonResponse.put("executionDetail", t.toJson(true));460 }461 response.getWriter().print(jsonResponse.toString());462 } catch (JSONException e) {463 LOG.warn(e);464 //returns a default error message with the json format that is able to be parsed by the client-side465 response.setContentType("application/json");466 response.setCharacterEncoding("utf8");467 response.getWriter().print(AnswerUtil.createGenericErrorAnswer());468 }469 break;470 default:471 response.setContentType("text/plain");472 DateFormat df = new SimpleDateFormat(DateUtil.DATE_FORMAT_DISPLAY);473 out.println(df.format(tCExecution.getStart()) + " - " + runID474 + " [" + test475 + "|" + testCase476 + "|" + country477 + "|" + environment478 + "] : '" + tCExecution.getResultMessage().getCodeString() + "' - "479 + tCExecution.getResultMessage().getCode()480 + " " + tCExecution.getResultMessage().getDescription());481 }482 } else {483 // An error occured when parsing the parameters.484 switch (outputFormat) {485 case "verbose-txt":486 response.setContentType("text/plain");487 String separator = " = ";488 out.println("id" + separator + 0);489 out.println("queueID" + separator + idFromQueue);490 out.println("test" + separator + test);491 out.println("testcase" + separator + testCase);492 out.println("country" + separator + country);493 out.println("environment" + separator + environment);494 out.println("OutputFormat" + separator + outputFormat);495 out.println("Verbose" + separator + verbose);496 out.println("Screenshot" + separator + screenshot);497 out.println("PageSource" + separator + getPageSource);498 out.println("SeleniumLog" + separator + getRobotLog);499 out.println("Robot" + separator + robot);500 out.println("Robot Server IP" + separator + robotHost);501 out.println("Robot Server Port" + separator + robotPort);502 out.println("Timeout" + separator + timeout);503 out.println("Synchroneous" + separator + synchroneous);504 out.println("Browser" + separator + browser);505 out.println("Version" + separator + version);506 out.println("Platform" + separator + platform);507 out.println("ScreenSize" + separator + screenSize);508 out.println("Nb Of Retry" + separator + numberOfRetries);509 out.println("ManualURL" + separator + manualURL);510 out.println("MyHost" + separator + myHost);511 out.println("MyContextRoot" + separator + myContextRoot);512 out.println("MyLoginRelativeURL" + separator + myLoginRelativeURL);513 out.println("myEnvironmentData" + separator + myEnvData);514 out.println("ReturnCode" + separator + MessageGeneralEnum.EXECUTION_FA_SERVLETVALIDATONS.getCode());515 out.println("controlMessage" + separator + MessageGeneralEnum.EXECUTION_FA_SERVLETVALIDATONS.getDescription() + " " + errorMessage);516 out.println("controlStatus" + separator + MessageGeneralEnum.EXECUTION_FA_SERVLETVALIDATONS.getCodeString());517 break;518 case "json":519 case "verbose-json":520 try {521 JSONObject jsonResponse = new JSONObject();522 jsonResponse.put("OutputFormat", outputFormat);523 jsonResponse.put("Verbose", verbose);524 jsonResponse.put("Screenshot", screenshot);525 jsonResponse.put("PageSource", getPageSource);526 jsonResponse.put("SeleniumLog", getRobotLog);527 jsonResponse.put("Robot", robot);528 jsonResponse.put("Robot Server IP", robotHost);529 jsonResponse.put("Robot Server Port", robotPort);530 jsonResponse.put("Timeout", timeout);531 jsonResponse.put("Synchroneous", synchroneous);532 jsonResponse.put("Browser", browser);533 jsonResponse.put("Version", version);534 jsonResponse.put("Platform", platform);535 jsonResponse.put("ScreenSize", screenSize);536 jsonResponse.put("Nb Of Retry", numberOfRetries);537 jsonResponse.put("ManualURL", manualURL);538 jsonResponse.put("MyHost", myHost);539 jsonResponse.put("MyContextRoot", myContextRoot);540 jsonResponse.put("MyLoginRelativeURL", myLoginRelativeURL);...
Source:RunTestCase.java
...134 String userAgent = "";135 String screenSize = "";136 boolean synchroneous = true;137 int getPageSource = 0;138 int getRobotLog = 0;139 String manualExecution = "N";140 //Test141 String test = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter("Test"), "");142 String testCase = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter("TestCase"), "");143 String country = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter("Country"), "");144 String environment = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter("Environment"), "");145 //Test Dev Environment146 boolean manualURL = ParameterParserUtil.parseBooleanParam(request.getParameter("manualURL"), false);147 String myHost = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter("myhost"), "");148 String myContextRoot = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter("mycontextroot"), "");149 String myLoginRelativeURL = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter("myloginrelativeurl"), "");150 //TODO find another solution151 myLoginRelativeURL = myLoginRelativeURL.replace("=", "=");152 String myEnvData = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter("myenvdata"), "");153 //Execution154 String tag = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter("Tag"), "");155 String outputFormat = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter("outputformat"), "compact");156 int screenshot = ParameterParserUtil.parseIntegerParam(request.getParameter("screenshot"), 1);157 int verbose = ParameterParserUtil.parseIntegerParam(request.getParameter("verbose"), 0);158 timeout = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter("timeout"), "");159 synchroneous = ParameterParserUtil.parseBooleanParam(request.getParameter("synchroneous"), false);160 getPageSource = ParameterParserUtil.parseIntegerParam(request.getParameter("pageSource"), 1);161 getRobotLog = ParameterParserUtil.parseIntegerParam(request.getParameter("seleniumLog"), 1);162 manualExecution = ParameterParserUtil.parseStringParam(request.getParameter("manualExecution"), "N");163 int numberOfRetries = ParameterParserUtil.parseIntegerParam(request.getParameter("retries"), 0);164 screenSize = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter("screenSize"), "");165 robot = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter("robot"), "");166 robotHost = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter("ss_ip"), "");167 robotPort = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter("ss_p"), "");168 browser = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter("Browser"), ParameterParserUtil.parseStringParamAndSanitize(request.getParameter("browser"), ""));169 version = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter("version"), "");170 platform = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter("platform"), "");171 // hidden parameters.172 long idFromQueue = ParameterParserUtil.parseIntegerParam(request.getParameter("IdFromQueue"), 0);173 String executor = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter("executor"), ParameterParserUtil.parseStringParamAndSanitize(request.getUserPrincipal().getName(), ""));174 String helpMessage = "\nThis servlet is used to start the execution of a test case.\n"175 + "Parameter list :\n"176 + "- Test [mandatory] : Test to execute. [" + test + "]\n"177 + "- TestCase [mandatory] : Test Case reference to execute. [" + testCase + "]\n"178 + "- Country [mandatory] : Country where the test case will execute. [" + country + "]\n"179 + "- Environment : Environment where the test case will execute. This parameter is mandatory only if manualURL is not set to Y. [" + environment + "]\n"180 + "- robot : robot name on which the test will be executed. [" + robot + "]\n"181 + "- ss_ip : Host of the Robot where the test will be executed. (Can be overwriten if robot is defined) [" + robotHost + "]\n"182 + "- ss_p : Port of the Robot. (Can be overwriten if robot is defined) [" + robotPort + "]\n"183 + "- browser : Browser to use for the execution. (Can be overwriten if robot is defined) [" + browser + "]\n"184 + "- version : Version to use for the execution. (Can be overwriten if robot is defined) [" + version + "]\n"185 + "- platform : Platform to use for the execution. (Can be overwriten if robot is defined) [" + platform + "]\n"186 + "- screenSize : Size of the screen to set for the execution. [" + screenSize + "]\n"187 + "- manualURL : Activate or not the Manual URL of the application to execute. If activated the 4 parameters after (myhost, mycontextroot, myloginrelativeurl, myenvdata) are necessary. [" + manualURL + "]\n"188 + "- myhost : Host of the application to test (only used when manualURL is feed). [" + myHost + "]\n"189 + "- mycontextroot : Context root of the application to test (only used when manualURL is feed). [" + myContextRoot + "]\n"190 + "- myloginrelativeurl : Relative login URL of the application (only used when manualURL is feed). [" + myLoginRelativeURL + "]\n"191 + "- myenvdata : Environment where to get the test data when a manualURL is defined. (only used when manualURL is feed) [" + myEnvData + "]\n"192 + "- Tag : Tag that will be stored on the execution. [" + tag + "]\n"193 + "- outputformat : Format of the output of the execution. [" + outputFormat + "]\n"194 + "- screenshot : Activate or not the screenshots. [" + screenshot + "]\n"195 + "- verbose : Verbose level of the execution. [" + verbose + "]\n"196 + "- timeout : Timeout used for the action. If empty, the default value will be the one configured in parameter table. [" + timeout + "]\n"197 + "- synchroneous : Synchroneous define if the servlet wait for the end of the execution to report its execution. [" + synchroneous + "\n"198 + "- pageSource : Record Page Source during the execution. [" + getPageSource + "]\n"199 + "- seleniumLog : Get the SeleniumLog at the end of the execution. [" + getRobotLog + "]\n"200 + "- manualExecution : Execute testcase in manual mode. [" + manualExecution + "]\n"201 + "- retries : Number of tries if the result is not OK. [" + numberOfRetries + "]\n";202 boolean error = false;203 String errorMessage = "";204 // -- Checking the parameter validity. --205 // test, testcase and country parameters are mandatory206 if (StringUtils.isBlank(test)) {207 errorMessage += "Error - Parameter Test is mandatory. ";208 error = true;209 }210 if (StringUtils.isBlank(testCase)) {211 errorMessage += "Error - Parameter TestCase is mandatory. ";212 error = true;213 }214 if (!StringUtils.isBlank(tag) && tag.length() > 255) {215 errorMessage += "Error - Parameter Tag value is too big. Tag cannot be larger than 255 Characters. Currently has : " + tag.length();216 error = true;217 }218 if (StringUtils.isBlank(country)) {219 errorMessage += "Error - Parameter Country is mandatory. ";220 error = true;221 }222 // environment is mandatory when manualURL is not activated.223 if (StringUtils.isBlank(environment) && !manualURL) {224 errorMessage += "Error - Parameter Environment is mandatory (or use the manualURL parameter). ";225 error = true;226 }227 // We check that execution is not desactivated by cerberus_automaticexecution_enable parameter.228 IParameterService parameterService = appContext.getBean(IParameterService.class);229 if (!(parameterService.getParameterBooleanByKey("cerberus_automaticexecution_enable", "", true))) {230 errorMessage += "Error - Execution disable by configuration (cerberus_automaticexecution_enable <> Y). ";231 error = true;232 LOG.info("Execution request ignored by cerberus_automaticexecution_enable parameter. " + test + " / " + testCase);233 }234 // If Robot is feeded, we check it exist. If it exist, we overwrite the associated parameters.235 Robot robObj = null;236 if (!StringUtil.isNullOrEmpty(robot)) {237 IRobotService robotService = appContext.getBean(IRobotService.class);238 try {239 robObj = robotService.readByKey(robot);240 // If Robot parameter is defined and we can find the robot, we overwrite the corresponding parameters.241 browser = ParameterParserUtil.parseStringParam(robObj.getBrowser(), browser);242 robotDecli = ParameterParserUtil.parseStringParam(robObj.getRobotDecli(), "");243 if (StringUtil.isNullOrEmpty(robotDecli)) {244 robotDecli = robObj.getRobot();245 }246 version = ParameterParserUtil.parseStringParam(robObj.getVersion(), version);247 platform = ParameterParserUtil.parseStringParam(robObj.getPlatform(), platform);248 active = robObj.getActive();249 userAgent = robObj.getUserAgent();250 screenSize = robObj.getScreenSize();251 } catch (CerberusException ex) {252 errorMessage += "Error - Robot [" + robot + "] does not exist. ";253 error = true;254 }255 } else {256 robotDecli = browser;257 }258 // We cannot execute a testcase on a desactivated Robot.259 if (active.equals("N")) {260 errorMessage += "Error - Robot is not Active. ";261 error = true;262 }263 //verify the format of the ScreenSize. It must be 2 integer separated by a *. For example : 1024*768264 if (!"".equals(screenSize)) {265 if (!screenSize.contains("*")) {266 errorMessage += "Error - ScreenSize format is not Correct. It must be 2 Integer separated by a *. ";267 error = true;268 } else {269 try {270 String screenWidth = screenSize.split("\\*")[0];271 String screenLength = screenSize.split("\\*")[1];272 Integer.parseInt(screenWidth);273 Integer.parseInt(screenLength);274 } catch (Exception e) {275 errorMessage += "Error - ScreenSize format is not Correct. It must be 2 Integer separated by a *. ";276 error = true;277 }278 }279 }280 // Create Tag when exist.281 if (!StringUtil.isNullOrEmpty(tag)) {282 // We create or update it.283 ITagService tagService = appContext.getBean(ITagService.class);284 List<String> envList = new ArrayList<>();285 envList.add(environment);286 List<String> countryList = new ArrayList<>();287 countryList.add(country);288 tagService.createAuto(tag, "", executor, new JSONArray(envList), new JSONArray(countryList));289 }290 if (!error) {291 //TODO:FN debug messages to be removed292 LOG.debug("STARTED: Test " + test + "-" + testCase);293 IRunTestCaseService runTestCaseService = appContext.getBean(IRunTestCaseService.class);294 IFactoryTestCase factoryTCase = appContext.getBean(IFactoryTestCase.class);295 IFactoryTestCaseExecution factoryTCExecution = appContext.getBean(IFactoryTestCaseExecution.class);296 IFactoryTestCaseExecutionQueue factoryTCExecutionQueue = appContext.getBean(IFactoryTestCaseExecutionQueue.class);297 ITestCaseExecutionService tces = appContext.getBean(ITestCaseExecutionService.class);298 ITestCaseService tcs = appContext.getBean(ITestCaseService.class);299 TestCase tCase = factoryTCase.create(test, testCase);300 // Building Execution Object.301 TestCaseExecution tCExecution = factoryTCExecution.create(0, test, testCase, null, null, null, environment, country, robot, "", robotHost, robotPort, robotDecli, browser, version, platform,302 0, 0, "", "", "", null, null, tag, verbose, screenshot, 0, getPageSource, getRobotLog, 0, synchroneous, timeout, outputFormat, null,303 Infos.getInstance().getProjectNameAndVersion(), tCase, null, null, manualURL ? 1 : 0, myHost, myContextRoot, myLoginRelativeURL, myEnvData, robotHost, robotPort,304 null, new MessageGeneral(MessageGeneralEnum.EXECUTION_PE_TESTSTARTED), executor, numberOfRetries, screenSize, robObj, "", "",305 "", "", "", "", "", "", "", manualExecution, userAgent, 0, 0, "", executor, null, executor, null);306 tCExecution.setSeleniumIPUser(ss_ip_user);307 tCExecution.setSeleniumIPPassword(ss_ip_pass);308 /**309 * Set IdFromQueue310 */311 try {312 tCExecution.setQueueID(idFromQueue);313 TestCaseExecutionQueue queueExecution = factoryTCExecutionQueue.create(idFromQueue, "", test, testCase, country, environment, robot, robotDecli, robotHost, robotPort, browser, version,314 platform, screenSize, 0, myHost, myContextRoot, myLoginRelativeURL, myEnvData, tag, screenshot, 0, verbose, timeout, getPageSource, getRobotLog, 0, 0, numberOfRetries,315 manualExecution, executor, null, null, null);316 tCExecution.setTestCaseExecutionQueue(queueExecution);317 } catch (FactoryCreationException ex) {318 LOG.error(ex, ex);319 }320 /**321 * Set UUID322 */323 ExecutionUUID executionUUIDObject = appContext.getBean(ExecutionUUID.class);324 UUID executionUUID = UUID.randomUUID();325 executionUUIDObject.setExecutionUUID(executionUUID.toString(), tCExecution);326 tCExecution.setExecutionUUID(executionUUID.toString());327 LOG.info("Execution Requested : UUID=" + executionUUID);328 /**329 * Execution of the testcase.330 */331 LOG.debug("Start execution " + tCExecution.getId());332 tCExecution = runTestCaseService.runTestCase(tCExecution);333 /**334 * Clean memory in case testcase has not been launched(Remove335 * all object put in memory)336 */337 try {338 if (tCExecution.getId() == 0) {339 executionUUIDObject.removeExecutionUUID(tCExecution.getExecutionUUID());340 LOG.debug("Clean ExecutionUUID");341 }342 } catch (Exception ex) {343 LOG.error("Exception cleaning Memory: ", ex);344 }345 /**346 * Execution is finished we report the result.347 */348 long runID = tCExecution.getId();349 switch (outputFormat) {350 case "gui":351 if (runID > 0) { // Execution has been created.352 response.sendRedirect("TestCaseExecution.jsp?executionId=" + runID);353 } else { // Execution was not even created.354 response.setContentType("text/html");355 out.println("<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><title>Test Execution Result</title></head>");356 out.println("<body>");357 out.println("<table>");358 out.println("<tr><td>RunID</td><td><span id='RunID'>" + runID + "</span></td></tr>");359 out.println("<tr><td>IdFromQueue</td><td><b><span id='IdFromQueue'>" + tCExecution.getQueueID() + "</span></b></td></tr>");360 out.println("<tr><td>Test</td><td><span id='Test'>" + test + "</span></td></tr>");361 out.println("<tr><td>TestCase</td><td><span id='TestCase'>" + testCase + "</span></td></tr>");362 out.println("<tr><td>Country</td><td><span id='Country'>" + country + "</span></td></tr>");363 out.println("<tr><td>Environment</td><td><span id='Environment'>" + environment + "</span></td></tr>");364 out.println("<tr><td>TimestampStart</td><td><span id='TimestampStart'>" + new Timestamp(tCExecution.getStart()) + "</span></td></tr>");365 out.println("<tr><td>TimestampEnd</td><td><span id='TimestampEnd'>" + new Timestamp(tCExecution.getEnd()) + "</span></td></tr>");366 out.println("<tr><td>OutputFormat</td><td><span id='OutputFormat'>" + outputFormat + "</span></td></tr>");367 out.println("<tr><td>Verbose</td><td><span id='Verbose'>" + verbose + "</span></td></tr>");368 out.println("<tr><td>Screenshot</td><td><span id='Screenshot'>" + screenshot + "</span></td></tr>");369 out.println("<tr><td>PageSource</td><td><span id='PageSource'>" + getPageSource + "</span></td></tr>");370 out.println("<tr><td>SeleniumLog</td><td><span id='SeleniumLog'>" + getRobotLog + "</span></td></tr>");371 out.println("<tr><td>Robot</td><td><span id='Robot'>" + robot + "</span></td></tr>");372 out.println("<tr><td>Selenium Server IP</td><td><span id='SeleniumIP'>" + robotHost + "</span></td></tr>");373 out.println("<tr><td>Selenium Server Port</td><td><span id='SeleniumPort'>" + robotPort + "</span></td></tr>");374 out.println("<tr><td>Timeout</td><td><span id='Timeout'>" + timeout + "</span></td></tr>");375 out.println("<tr><td>Synchroneous</td><td><span id='Synchroneous'>" + synchroneous + "</span></td></tr>");376 out.println("<tr><td>Browser</td><td><span id='Browser'>" + browser + "</span></td></tr>");377 out.println("<tr><td>Version</td><td><span id='Version'>" + version + "</span></td></tr>");378 out.println("<tr><td>Platform</td><td><span id='Platform'>" + platform + "</span></td></tr>");379 out.println("<tr><td>Screen Size</td><td><span id='screenSize'>" + screenSize + "</span></td></tr>");380 out.println("<tr><td>Number of Retry</td><td><span id='nbretry'>" + numberOfRetries + "</span></td></tr>");381 out.println("<tr><td>ManualURL</td><td><span id='ManualURL'>" + tCExecution.getManualURL() + "</span></td></tr>");382 out.println("<tr><td>MyHost</td><td><span id='MyHost'>" + tCExecution.getMyHost() + "</span></td></tr>");383 out.println("<tr><td>MyContextRoot</td><td><span id='MyContextRoot'>" + tCExecution.getMyContextRoot() + "</span></td></tr>");384 out.println("<tr><td>MyLoginRelativeURL</td><td><span id='MyLoginRelativeURL'>" + tCExecution.getMyLoginRelativeURL() + "</span></td></tr>");385 out.println("<tr><td>myEnvironmentData</td><td><span id='myEnvironmentData'>" + tCExecution.getEnvironmentData() + "</span></td></tr>");386 out.println("<tr><td>ReturnCode</td><td><b><span id='ReturnCodeDescription'>" + tCExecution.getResultMessage().getCode() + "</span></b></td></tr>");387 out.println("<tr><td>ReturnCodeDescription</td><td><b><span id='ReturnCodeDescription'>" + tCExecution.getResultMessage().getDescription() + "</span></b></td></tr>");388 out.println("<tr><td>ControlStatus</td><td><b><span id='ReturnCodeMessage'>" + tCExecution.getResultMessage().getCodeString() + "</span></b></td></tr>");389 out.println("<tr><td></td><td></td></tr>");390 out.println("</table><br><br>");391 out.println("<table border>");392 out.println("<tr>"393 + "<td><input id=\"ButtonRetry\" type=\"button\" value=\"Retry\" onClick=\"window.location.reload()\"></td>"394 + "<td><input id=\"ButtonBack\" type=\"button\" value=\"Go Back\" onClick=\"window.history.back()\"></td>"395 + "<td><input id=\"ButtonOpenTC\" type=\"button\" value=\"Open Test Case\" onClick=\"window.open('TestCaseScript.jsp?test=" + test + "&testcase=" + testCase + "')\"></td>"396 + "</tr>");397 out.println("</table>");398 out.println("</body>");399 out.println("</html>");400 }401 break;402 case "verbose-txt":403 response.setContentType("text/plain");404 String separator = " = ";405 out.println("RunID" + separator + runID);406 out.println("QueueID" + separator + idFromQueue);407 out.println("Test" + separator + test);408 out.println("TestCase" + separator + testCase);409 out.println("Country" + separator + country);410 out.println("Environment" + separator + environment);411 out.println("Time Start" + separator + new Timestamp(tCExecution.getStart()));412 out.println("Time End" + separator + new Timestamp(tCExecution.getEnd()));413 out.println("OutputFormat" + separator + outputFormat);414 out.println("Verbose" + separator + verbose);415 out.println("Screenshot" + separator + screenshot);416 out.println("PageSource" + separator + getPageSource);417 out.println("SeleniumLog" + separator + getRobotLog);418 out.println("Robot" + separator + robot);419 out.println("Selenium Server IP" + separator + robotHost);420 out.println("Selenium Server Port" + separator + robotPort);421 out.println("Timeout" + separator + timeout);422 out.println("Synchroneous" + separator + synchroneous);423 out.println("Browser" + separator + browser);424 out.println("Version" + separator + version);425 out.println("Platform" + separator + platform);426 out.println("ScreenSize" + separator + screenSize);427 out.println("Nb Of Retry" + separator + numberOfRetries);428 out.println("ManualURL" + separator + tCExecution.getManualURL());429 out.println("MyHost" + separator + tCExecution.getMyHost());430 out.println("MyContextRoot" + separator + tCExecution.getMyContextRoot());431 out.println("MyLoginRelativeURL" + separator + tCExecution.getMyLoginRelativeURL());432 out.println("myEnvironmentData" + separator + tCExecution.getEnvironmentData());433 out.println("ReturnCode" + separator + tCExecution.getResultMessage().getCode());434 out.println("ReturnCodeDescription" + separator + tCExecution.getResultMessage().getDescription());435 out.println("ControlStatus" + separator + tCExecution.getResultMessage().getCodeString());436 break;437 case "verbose-json":438 case "json":439 try {440 JSONObject jsonResponse = new JSONObject();441 if (runID > 0) { // Execution has been created.442 TestCaseExecution t = (TestCaseExecution) tces.readByKeyWithDependency(tCExecution.getId()).getItem();443 out.print(tCExecution.toJson(true).toString());444 } else { // Execution was not even created.445 jsonResponse.put("RunID", 0);446 jsonResponse.put("id", 0);447 jsonResponse.put("QueueID", idFromQueue);448 jsonResponse.put("Test", test);449 jsonResponse.put("TestCase", testCase);450 jsonResponse.put("Country", country);451 jsonResponse.put("Environment", environment);452 jsonResponse.put("Time Start", new Timestamp(tCExecution.getStart()));453 jsonResponse.put("Time End", new Timestamp(tCExecution.getEnd()));454 jsonResponse.put("OutputFormat", outputFormat);455 jsonResponse.put("Verbose", verbose);456 jsonResponse.put("Screenshot", screenshot);457 jsonResponse.put("PageSource", getPageSource);458 jsonResponse.put("SeleniumLog", getRobotLog);459 jsonResponse.put("Robot", robot);460 jsonResponse.put("Selenium Server IP", robotHost);461 jsonResponse.put("Selenium Server Port", robotPort);462 jsonResponse.put("Timeout", timeout);463 jsonResponse.put("Synchroneous", synchroneous);464 jsonResponse.put("Browser", browser);465 jsonResponse.put("Version", version);466 jsonResponse.put("Platform", platform);467 jsonResponse.put("ScreenSize", screenSize);468 jsonResponse.put("Nb Of Retry", numberOfRetries);469 jsonResponse.put("ManualURL", manualURL);470 jsonResponse.put("MyHost", myHost);471 jsonResponse.put("MyContextRoot", myContextRoot);472 jsonResponse.put("MyLoginRelativeURL", myLoginRelativeURL);473 jsonResponse.put("myEnvironmentData", myEnvData);474 jsonResponse.put("ReturnCode", tCExecution.getResultMessage().getCode());475 jsonResponse.put("ReturnCodeDescription", tCExecution.getResultMessage().getDescription());476 jsonResponse.put("ControlStatus", tCExecution.getResultMessage().getCodeString());477 jsonResponse.put("helpMessage", helpMessage);478 }479 response.setContentType("application/json");480 response.setCharacterEncoding("utf8");481 response.getWriter().print(jsonResponse.toString());482 } catch (JSONException e) {483 LOG.warn(e);484 //returns a default error message with the json format that is able to be parsed by the client-side485 response.setContentType("application/json");486 response.setCharacterEncoding("utf8");487 response.getWriter().print(AnswerUtil.createGenericErrorAnswer());488 }489 break;490 default:491 response.setContentType("text/plain");492 DateFormat df = new SimpleDateFormat(DateUtil.DATE_FORMAT_DISPLAY);493 out.println(df.format(tCExecution.getStart()) + " - " + runID494 + " [" + test495 + "|" + testCase496 + "|" + country497 + "|" + environment498 + "] : '" + tCExecution.getResultMessage().getCodeString() + "' - "499 + tCExecution.getResultMessage().getCode()500 + " " + tCExecution.getResultMessage().getDescription());501 }502 } else {503 // An error occured when parsing the parameters.504 switch (outputFormat) {505 case "verbose-txt":506 response.setContentType("text/plain");507 String separator = " = ";508 out.println("RunID" + separator + 0);509 out.println("QueueID" + separator + idFromQueue);510 out.println("Test" + separator + test);511 out.println("TestCase" + separator + testCase);512 out.println("Country" + separator + country);513 out.println("Environment" + separator + environment);514 out.println("OutputFormat" + separator + outputFormat);515 out.println("Verbose" + separator + verbose);516 out.println("Screenshot" + separator + screenshot);517 out.println("PageSource" + separator + getPageSource);518 out.println("SeleniumLog" + separator + getRobotLog);519 out.println("Robot" + separator + robot);520 out.println("Selenium Server IP" + separator + robotHost);521 out.println("Selenium Server Port" + separator + robotPort);522 out.println("Timeout" + separator + timeout);523 out.println("Synchroneous" + separator + synchroneous);524 out.println("Browser" + separator + browser);525 out.println("Version" + separator + version);526 out.println("Platform" + separator + platform);527 out.println("ScreenSize" + separator + screenSize);528 out.println("Nb Of Retry" + separator + numberOfRetries);529 out.println("ManualURL" + separator + manualURL);530 out.println("MyHost" + separator + myHost);531 out.println("MyContextRoot" + separator + myContextRoot);532 out.println("MyLoginRelativeURL" + separator + myLoginRelativeURL);533 out.println("myEnvironmentData" + separator + myEnvData);534 out.println("ReturnCode" + separator + MessageGeneralEnum.EXECUTION_FA_SERVLETVALIDATONS.getCode());535 out.println("ReturnCodeDescription" + separator + MessageGeneralEnum.EXECUTION_FA_SERVLETVALIDATONS.getDescription() + " " + errorMessage);536 out.println("ControlStatus" + separator + MessageGeneralEnum.EXECUTION_FA_SERVLETVALIDATONS.getCodeString());537 break;538 case "json":539 case "verbose-json":540 try {541 JSONObject jsonResponse = new JSONObject();542 jsonResponse.put("RunID", 0);543 jsonResponse.put("QueueID", idFromQueue);544 jsonResponse.put("Test", test);545 jsonResponse.put("TestCase", testCase);546 jsonResponse.put("Country", country);547 jsonResponse.put("Environment", environment);548 jsonResponse.put("OutputFormat", outputFormat);549 jsonResponse.put("Verbose", verbose);550 jsonResponse.put("Screenshot", screenshot);551 jsonResponse.put("PageSource", getPageSource);552 jsonResponse.put("SeleniumLog", getRobotLog);553 jsonResponse.put("Robot", robot);554 jsonResponse.put("Selenium Server IP", robotHost);555 jsonResponse.put("Selenium Server Port", robotPort);556 jsonResponse.put("Timeout", timeout);557 jsonResponse.put("Synchroneous", synchroneous);558 jsonResponse.put("Browser", browser);559 jsonResponse.put("Version", version);560 jsonResponse.put("Platform", platform);561 jsonResponse.put("ScreenSize", screenSize);562 jsonResponse.put("Nb Of Retry", numberOfRetries);563 jsonResponse.put("ManualURL", manualURL);564 jsonResponse.put("MyHost", myHost);565 jsonResponse.put("MyContextRoot", myContextRoot);566 jsonResponse.put("MyLoginRelativeURL", myLoginRelativeURL);...
getRobotLog
Using AI Code Generation
1import org.cerberus.crud.entity.TestCaseExecution;2import org.cerberus.crud.factory.IFactoryTestCaseExecution;3import org.cerberus.crud.service.ITestCaseExecutionService;4import org.springframework.beans.factory.annotation.Autowired;5import org.springframework.stereotype.Service;6import org.springframework.transaction.annotation.Transactional;7import org.springframework.web.bind.annotation.RequestMapping;8import org.springframework.web.bind.annotation.RequestMethod;9import org.springframework.web.bind.annotation.RestController;10import org.springframework.web.servlet.ModelAndView;11import org.springframework.web.servlet.mvc.support.RedirectAttributes;12import java.util.List;13public class RobotLogController {14 private ITestCaseExecutionService testCaseExecutionService;15 private IFactoryTestCaseExecution testCaseExecutionFactory;16 @RequestMapping(value = "/RobotLog", method = RequestMethod.GET)17 public ModelAndView robotLog() {18 ModelAndView mav = new ModelAndView("robotLog");19 return mav;20 }21 @RequestMapping(value = "/RobotLog", method = RequestMethod.POST)22 public ModelAndView robotLog(String test, String testCase, String environment, String country, String browser, String browserVersion, String robotHost, String robotPort, String robotPlatform, String robotBrowser, String robotBrowserVersion, RedirectAttributes redirectAttributes) {23 ModelAndView mav = new ModelAndView("robotLog");24 TestCaseExecution tce = testCaseExecutionFactory.create(test, testCase, 1, environment, country, browser, browserVersion, robotHost, robotPort, robotPlatform, robotBrowser, robotBrowserVersion);25 List<String> robotLog = testCaseExecutionService.getRobotLog(tce);26 mav.addObject("robotLog", robotLog);27 return mav;28 }29}30package org.cerberus.crud.entity;31import java.io.Serializable;32import java.util.Date;33public class TestCaseExecution implements Serializable {34 private long id;35 private String test;36 private String testCase;37 private int index;38 private String environment;39 private String country;40 private String browser;41 private String browserVersion;42 private String robotHost;43 private String robotPort;44 private String robotPlatform;45 private String robotBrowser;46 private String robotBrowserVersion;47 private String application;48 private String applicationVersion;49 private String tag;50 private String status;51 private String controlStatus;52 private String controlMessage;
getRobotLog
Using AI Code Generation
1package com.cerberus;2import java.util.List;3import org.cerberus.crud.entity.TestCaseExecution;4import org.cerberus.engine.entity.MessageEvent;5import org.cerberus.engine.entity.MessageGeneral;6import org.cerberus.engine.execution.IExecutionThreadService;7import org.cerberus.engine.execution.impl.ExecutionThreadService;8import org.cerberus.engine.threadpool.IExecutionThreadPoolService;9import org.cerberus.engine.threadpool.impl.ExecutionThreadPoolService;10import org.cerberus.engine.threadpool.impl.ThreadPoolService;11import org.cerberus.log.IEventService;12import org.cerberus.log.impl.EventService;13import org.cerberus.service.sikuli.ISikuliService;14import org.cerberus.service.sikuli.impl.SikuliService;15import org.cerberus.service.sikuli.impl.SikuliServiceFactory;16import org.cerberus.util.answer.AnswerItem;17public class GetRobotLog {18 public static void main(String[] args) {19 String robot = "RobotCerberus";20 String host = "localhost";21 String port = "4444";22 String tag = "Cerberus";23 String browser = "firefox";24 String version = "33";25 String platform = "WINDOWS";26 String screenSize = "1024x768";27 String seleniumIP = "localhost";28 String seleniumPort = "4444";29 String timeout = "30000";30 String retries = "0";31 String outputFormat = "HTML";32 String screenshot = "N";33 String pageSource = "N";34 String verbose = "0";35 String seleniumLog = "N";36 String robotLog = "N";37 String timeoutRobot = "0";38 String retriesRobot = "0";39 String pageSourceRobot = "N";40 String screenshotRobot = "N";41 String verboseRobot = "0";42 String outputFormatRobot = "HTML";43 String manualURL = "N";44 String manualExecution = "N";45 String manualHost = "localhost";46 String manualContextRoot = "Cerberus";47 String manualLoginRelativeURL = "Login.jsp";48 String manualEnvData = "QA";49 String manualCountry = "US";50 String manualBrowser = "firefox";51 String manualVersion = "33";
getRobotLog
Using AI Code Generation
1package org.cerberus.crud.entity;2import java.util.List;3public class TestCaseExecution {4 private List<TestCaseExecutionData> robotLog;5 public List<TestCaseExecutionData> getRobotLog() {6 return robotLog;7 }8 public void setRobotLog(List<TestCaseExecutionData> robotLog) {9 this.robotLog = robotLog;10 }11}12package org.cerberus.crud.entity;13import java.util.List;14public class TestCaseExecution {15 private List<TestCaseExecutionData> robotLog;16 public List<TestCaseExecutionData> getRobotLog() {17 return robotLog;18 }19 public void setRobotLog(List<TestCaseExecutionData> robotLog) {20 this.robotLog = robotLog;21 }22}23package org.cerberus.crud.entity;24import java.util.List;25public class TestCaseExecution {26 private List<TestCaseExecutionData> robotLog;27 public List<TestCaseExecutionData> getRobotLog() {28 return robotLog;29 }30 public void setRobotLog(List<TestCaseExecutionData> robotLog) {31 this.robotLog = robotLog;32 }33}34package org.cerberus.crud.entity;35import java.util.List;36public class TestCaseExecution {37 private List<TestCaseExecutionData> robotLog;38 public List<TestCaseExecutionData> getRobotLog() {39 return robotLog;40 }41 public void setRobotLog(List<TestCaseExecutionData> robotLog) {42 this.robotLog = robotLog;43 }44}45package org.cerberus.crud.entity;46import java.util.List;47public class TestCaseExecution {48 private List<TestCaseExecutionData> robotLog;49 public List<TestCaseExecutionData> getRobotLog() {50 return robotLog;51 }52 public void setRobotLog(List<TestCaseExecutionData> robotLog) {
getRobotLog
Using AI Code Generation
1package org.cerberus.crud.entity;2import java.util.List;3import org.cerberus.crud.entity.TestCaseExecution;4public class TestCaseExecution {5 public List<TestCaseExecution> getRobotLog() {6 return robotLog;7 }8 public void setRobotLog(List<TestCaseExecution> robotLog) {9 this.robotLog = robotLog;10 }11 private List<TestCaseExecution> robotLog;12}13package org.cerberus.crud.service.impl;14import java.util.List;15import org.cerberus.crud.entity.TestCaseExecution;16import org.cerberus.crud.service.ITestCaseExecutionService;17public class TestCaseExecutionService implements ITestCaseExecutionService {18 public List<TestCaseExecution> getRobotLog() {19 return robotLog;20 }21 public void setRobotLog(List<TestCaseExecution> robotLog) {22 this.robotLog = robotLog;23 }24 private List<TestCaseExecution> robotLog;25}26package org.cerberus.crud.service.impl;27import org.cerberus.crud.entity.TestCaseExecution;28import org.cerberus.crud.service.ITestCaseExecutionService;29public class TestCaseExecutionService implements ITestCaseExecutionService {30 public TestCaseExecution getRobotLog() {31 return robotLog;32 }33 public void setRobotLog(TestCaseExecution robotLog) {34 this.robotLog = robotLog;35 }36 private TestCaseExecution robotLog;37}38package org.cerberus.crud.service.impl;39import java.util.List;40import org.cerberus.crud.entity.TestCaseExecution;41import org.cerberus.crud.service.ITestCaseExecutionService;42public class TestCaseExecutionService implements ITestCaseExecutionService {43 public List<TestCaseExecution> getRobotLog() {44 return robotLog;45 }46 public void setRobotLog(List<TestCaseExecution> robotLog) {47 this.robotLog = robotLog;48 }49 private List<TestCaseExecution> robotLog;50}
getRobotLog
Using AI Code Generation
1import org.cerberus.crud.entity.TestCaseExecution;2import org.cerberus.crud.service.ITestCaseExecutionService;3import java.io.IOException;4import java.io.PrintWriter;5import java.util.Date;6import java.util.List;7public class 3 {8 public static void main(String[] args) throws IOException {9 ITestCaseExecutionService testCaseExecutionService = new org.cerberus.crud.service.impl.TestCaseExecutionService();
getRobotLog
Using AI Code Generation
1public class 3 {2 public static void main(String[] args) throws Exception {3 TestCaseExecution tce = new TestCaseExecution();4 String log = tce.getRobotLog();5 System.out.println(log);6 }7}
getRobotLog
Using AI Code Generation
1import org.cerberus.crud.entity.TestCaseExecution;2import org.cerberus.engine.entity.MessageEvent;3import java.util.List;4public class 3 {5 public static void main(String[] args) {6 List<MessageEvent> log = TestCaseExecution.getRobotLog(7);7 for (MessageEvent messageEvent : log) {8 System.out.println(messageEvent);9 }10 List<MessageEvent> logStep = TestCaseExecution.getRobotLog(1);11 for (MessageEvent messageEvent : logStep) {12 System.out.println(messageEvent);13 }14 }15}
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!