List of usage examples for org.apache.commons.lang3 StringEscapeUtils escapeHtml4
public static final String escapeHtml4(final String input)
Escapes the characters in a String using HTML entities.
For example:
"bread" & "butter"
"bread" & "butter"
.
From source file:org.catrobat.jira.adminhelper.rest.UserRest.java
private Response searchUser(String query, HttpServletRequest request) { Response unauthorized = checkPermission(request); if (unauthorized != null) { return unauthorized; }/* ww w .j av a 2 s .c o m*/ if (lendingService == null) { return Response.serverError().entity("Lending Service must not be null").build(); } if (query == null || query.length() < 1) { return Response.ok(new ArrayList<JsonUser>()).build(); } query = StringEscapeUtils.escapeHtml4(query); com.atlassian.jira.user.util.UserManager jiraUserManager = ComponentAccessor.getUserManager(); TreeMap<String, JsonUser> jsonUsers = new TreeMap<String, JsonUser>(); for (ApplicationUser user : jiraUserManager.getAllUsers()) { if (user.getName().toLowerCase().contains(query.toLowerCase()) || user.getDisplayName().toLowerCase().contains(query.toLowerCase())) { JsonUser jsonUser = new JsonUser(); jsonUser.setUserName(user.getKey()); jsonUser.setDisplayName(user.getDisplayName()); jsonUsers.put(user.getName().toLowerCase(), jsonUser); } } for (Lending lending : lendingService.all()) { if (lending.getLendingByUserKey().toLowerCase().contains(query.toLowerCase()) && !jsonUsers.containsKey(lending.getLendingByUserKey().toLowerCase())) { JsonUser jsonUser = new JsonUser(); jsonUser.setUserName(lending.getLendingByUserKey()); jsonUser.setDisplayName(lending.getLendingByUserKey()); String userKey = jsonUser.getUserName().toLowerCase().replaceAll(" ", "").replaceAll("ä", "ae") .replaceAll("ö", "oe").replaceAll("ü", "ue").replaceAll("ß", "ss"); jsonUsers.put(userKey, jsonUser); } } return Response.ok(jsonUsers.values()).build(); }
From source file:org.cerberus.servlet.crud.testexecution.ReadTestCaseExecution.java
private AnswerItem findExecutionListBySystem(String system, ApplicationContext appContext, HttpServletRequest request) throws ParseException, JSONException { AnswerItem answer = new AnswerItem(new MessageEvent(MessageEventEnum.DATA_OPERATION_OK)); /**//from ww w. j a v a 2 s.c o m * Parse all parameters used in the search. */ String charset = request.getCharacterEncoding(); /** * Parse parameters - list of values */ List<String> testList = ParameterParserUtil.parseListParamAndDecode(request.getParameterValues("test"), null, charset); List<String> applicationList = ParameterParserUtil .parseListParamAndDecode(request.getParameterValues("application"), null, charset); List<String> projectList = ParameterParserUtil .parseListParamAndDecode(request.getParameterValues("project"), null, charset); List<String> tcstatusList = ParameterParserUtil .parseListParamAndDecode(request.getParameterValues("tcstatus"), null, charset); List<String> groupList = ParameterParserUtil.parseListParamAndDecode(request.getParameterValues("group"), null, charset); List<String> tcactiveList = ParameterParserUtil .parseListParamAndDecode(request.getParameterValues("tcactive"), null, charset); List<String> priorityList = ParameterParserUtil .parseListParamAndDecode(request.getParameterValues("priority"), null, charset); List<String> targetsprintList = ParameterParserUtil .parseListParamAndDecode(request.getParameterValues("targetsprint"), null, charset); List<String> targetrevisionList = ParameterParserUtil .parseListParamAndDecode(request.getParameterValues("targetrevision"), null, charset); List<String> creatorList = ParameterParserUtil .parseListParamAndDecode(request.getParameterValues("creator"), null, charset); List<String> implementerList = ParameterParserUtil .parseListParamAndDecode(request.getParameterValues("implementer"), null, charset); List<String> environmentList = ParameterParserUtil .parseListParamAndDecode(request.getParameterValues("environment"), null, charset); List<String> buildList = ParameterParserUtil.parseListParamAndDecode(request.getParameterValues("build"), null, charset); List<String> revisionList = ParameterParserUtil .parseListParamAndDecode(request.getParameterValues("revision"), null, charset); List<String> countryList = ParameterParserUtil .parseListParamAndDecode(request.getParameterValues("country"), null, charset); List<String> browserList = ParameterParserUtil .parseListParamAndDecode(request.getParameterValues("browser"), null, charset); List<String> tcestatusList = ParameterParserUtil .parseListParamAndDecode(request.getParameterValues("tcestatus"), null, charset); //Sorts the lists if (countryList != null) { Collections.sort(countryList); } if (browserList != null) { Collections.sort(browserList); } /** * Parse parameters - free text */ String bugid = StringEscapeUtils.escapeHtml4(request.getParameter("bugid")); String ticket = StringEscapeUtils.escapeHtml4(request.getParameter("ticket")); String ip = StringEscapeUtils.escapeHtml4(request.getParameter("ip")); String port = StringEscapeUtils.escapeHtml4(request.getParameter("port")); String tag = StringEscapeUtils.escapeHtml4(request.getParameter("tag")); String browserversion = StringEscapeUtils.escapeHtml4(request.getParameter("browserversion")); String comment = StringEscapeUtils.escapeHtml4(request.getParameter("comment")); /** * Gets regular executions (not in queue) */ AnswerList answerExecutions = testCaseExecutionService.readBySystemByVarious(system, testList, applicationList, projectList, tcstatusList, groupList, tcactiveList, priorityList, targetsprintList, targetrevisionList, creatorList, implementerList, buildList, revisionList, environmentList, countryList, browserList, tcestatusList, ip, port, tag, browserversion, comment, bugid, ticket); List<TestCaseExecution> testCaseExecutions = (List<TestCaseExecution>) answerExecutions.getDataList(); /** * Get list of Execution in Queue by Tag */ ITestCaseExecutionInQueueService testCaseExecutionInQueueService = appContext .getBean(ITestCaseExecutionInQueueService.class); AnswerList answerExecutionsInQueue = testCaseExecutionInQueueService.readBySystemByVarious(system, testList, applicationList, projectList, tcstatusList, groupList, tcactiveList, priorityList, targetsprintList, targetrevisionList, creatorList, implementerList, buildList, revisionList, environmentList, countryList, browserList, tcestatusList, ip, port, tag, browserversion, comment, bugid, ticket); List<TestCaseExecutionInQueue> testCaseExecutionsInQueue = (List<TestCaseExecutionInQueue>) answerExecutionsInQueue .getDataList(); /** * Merge Test Case Executions */ List<TestCaseExecution> allTestCaseExecutions = hashExecution(testCaseExecutions, testCaseExecutionsInQueue); JSONArray executionList = new JSONArray(); LinkedHashMap<String, JSONObject> ttc = new LinkedHashMap<String, JSONObject>(); for (TestCaseExecution testCaseExecution : allTestCaseExecutions) { try { JSONObject execution = testCaseExecutionToJSONObject(testCaseExecution); String execKey = testCaseExecution.getCountry() + " " + testCaseExecution.getBrowser(); //the key is country and browser String testCaseKey = testCaseExecution.getTest() + "_" + testCaseExecution.getTestCase(); JSONObject execTab = new JSONObject(); executionList.put(testCaseExecutionToJSONObject(testCaseExecution)); JSONObject ttcObject = new JSONObject(); if (ttc.containsKey(testCaseKey)) { ttcObject = ttc.get(testCaseKey); execTab = ttcObject.getJSONObject("execTab"); execTab.put(execKey, execution); ttcObject.put("execTab", execTab); } else { ttcObject.put("test", testCaseExecution.getTest()); ttcObject.put("testCase", testCaseExecution.getTestCase()); ttcObject.put("function", testCaseExecution.getTestCaseObj().getFunction()); ttcObject.put("shortDesc", testCaseExecution.getTestCaseObj().getDescription()); ttcObject.put("status", testCaseExecution.getTestCaseObj().getStatus()); ttcObject.put("application", testCaseExecution.getApplication()); ttcObject.put("bugId", testCaseExecution.getTestCaseObj().getBugID()); ttcObject.put("ticket", testCaseExecution.getTestCaseObj().getTicket()); ttcObject.put("comment", testCaseExecution.getTestCaseObj().getComment()); ttcObject.put("priority", testCaseExecution.getTestCaseObj().getPriority()); ttcObject.put("status", testCaseExecution.getStatus()); ttcObject.put("group", testCaseExecution.getTestCaseObj().getGroup()); execTab.put(execKey, execution); ttcObject.put("execTab", execTab); } ttc.put(testCaseExecution.getTest() + "_" + testCaseExecution.getTestCase(), ttcObject); } catch (JSONException ex) { Logger.getLogger(ReadTestCaseExecution.class.getName()).log(Level.SEVERE, null, ex); } } JSONObject jsonResponse = new JSONObject(); jsonResponse.put("contentTable", ttc.values()); jsonResponse.put("iTotalRecords", ttc.size()); jsonResponse.put("iTotalDisplayRecords", ttc.size()); answer.setItem(jsonResponse); answer.setResultMessage(new MessageEvent(MessageEventEnum.DATA_OPERATION_OK)); return answer; }
From source file:org.cerberus.servlet.crud.usermanagement.UpdateMyUserReporting1.java
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { JSONObject jsonResponse = new JSONObject(); MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED); String login = request.getUserPrincipal().getName(); String charset = request.getCharacterEncoding(); /**/* w w w. j a va2 s .c om*/ * Parse parameters - list of values */ List<String> tcstatusList = ParameterParserUtil .parseListParamAndDecode(request.getParameterValues("tcstatus"), null, charset); List<String> groupList = ParameterParserUtil.parseListParamAndDecode(request.getParameterValues("group"), null, charset); List<String> tcactiveList = ParameterParserUtil .parseListParamAndDecode(request.getParameterValues("tcactive"), null, charset); List<String> priorityList = ParameterParserUtil .parseListParamAndDecode(request.getParameterValues("priority"), null, charset); List<String> countryList = ParameterParserUtil .parseListParamAndDecode(request.getParameterValues("country"), null, charset); List<String> browserList = ParameterParserUtil .parseListParamAndDecode(request.getParameterValues("browser"), null, charset); List<String> tcestatusList = ParameterParserUtil .parseListParamAndDecode(request.getParameterValues("tcestatus"), null, charset); //environment List<String> environmentList = ParameterParserUtil .parseListParamAndDecode(request.getParameterValues("environment"), null, charset); List<String> projectList = ParameterParserUtil .parseListParamAndDecode(request.getParameterValues("project"), null, charset); /** * Parse parameters - free text */ String ip = StringEscapeUtils.escapeHtml4(request.getParameter("ip")); String port = StringEscapeUtils.escapeHtml4(request.getParameter("port")); String tag = StringEscapeUtils.escapeHtml4(request.getParameter("tag")); String browserversion = StringEscapeUtils.escapeHtml4(request.getParameter("browserversion")); String comment = StringEscapeUtils.escapeHtml4(request.getParameter("comment")); ApplicationContext appContext = WebApplicationContextUtils .getWebApplicationContext(this.getServletContext()); IUserService userService = appContext.getBean(UserService.class); try { User user = userService.findUserByKey(login); if (user != null) { JSONObject preferences = new JSONObject(); if (tcstatusList != null) { preferences.put("s", tcstatusList); } if (groupList != null) { preferences.put("g", groupList); } if (tcactiveList != null) { preferences.put("a", tcactiveList); } if (priorityList != null) { preferences.put("pr", priorityList); } if (countryList != null) { preferences.put("co", countryList); } if (browserList != null) { preferences.put("b", browserList); } if (tcestatusList != null) { preferences.put("es", tcestatusList); } if (environmentList != null) { preferences.put("e", environmentList); } if (projectList != null) { preferences.put("prj", projectList); } if (!StringUtil.isNullOrEmpty(ip)) { preferences.put("ip", ip); } if (!StringUtil.isNullOrEmpty(port)) { preferences.put("p", port); } if (!StringUtil.isNullOrEmpty(tag)) { preferences.put("t", tag); } if (!StringUtil.isNullOrEmpty(browserversion)) { preferences.put("br", browserversion); } if (!StringUtil.isNullOrEmpty(comment)) { preferences.put("cm", comment); } user.setReportingFavorite(preferences.toString()); userService.updateUser(user); //TODO: when converting to the new standard this should return an answer //re-send the updated preferences jsonResponse.put("preferences", preferences); msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK); msg.setDescription(msg.getDescription().replace("%ITEM%", "Execution reporting filters ") .replace("%OPERATION%", "Update")); ILogEventService logEventService = appContext.getBean(LogEventService.class); logEventService.createPrivateCalls("/UpdateMyUserReporting1", "UPDATE", "Update user reporting preference for user: " + login, request); } else { msg.setDescription( msg.getDescription().replace("%DESCRIPTION%", "Unable to update User was not found!")); } jsonResponse.put("messageType", msg.getMessage().getCodeString()); jsonResponse.put("message", msg.getDescription()); } catch (JSONException ex) { Logger.getLogger(UpdateMyUserReporting1.class.getName()).log(Level.SEVERE, null, ex); //returns a default error message with the json format that is able to be parsed by the client-side response.getWriter().print(AnswerUtil.createGenericErrorAnswer()); } catch (CerberusException ex) { Logger.getLogger(UpdateMyUserReporting1.class.getName()).log(Level.SEVERE, null, ex); //returns a default error message with the json format that is able to be parsed by the client-side response.getWriter().print(AnswerUtil.createGenericErrorAnswer()); } response.getWriter().print(jsonResponse); response.getWriter().flush(); }
From source file:org.cerberus.servlet.zzpublic.RunTestCase.java
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out = response.getWriter(); ApplicationContext appContext = WebApplicationContextUtils .getWebApplicationContext(this.getServletContext()); /**/*from w w w.j ava 2 s .c o m*/ * Adding Log entry. */ ILogEventService logEventService = appContext.getBean(ILogEventService.class); logEventService.createPublicCalls("/RunTestCase", "CALL", "RunTestCaseV0 called : " + request.getRequestURL(), request); //Tool String ss_ip = ""; // Selenium IP String ss_p = ""; // Selenium Port String browser = ""; String version = ""; String platform = ""; String robot = ""; String active = ""; String timeout = ""; String userAgent = ""; String screenSize = ""; boolean synchroneous = true; int getPageSource = 0; int getSeleniumLog = 0; boolean manualExecution = false; List<RobotCapability> capabilities = null; //Test String test = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter("Test"), ""); String testCase = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter("TestCase"), ""); String country = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter("Country"), ""); String environment = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter("Environment"), ""); //Test Dev Environment boolean manualURL = ParameterParserUtil.parseBooleanParam(request.getParameter("manualURL"), false); String myHost = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter("myhost"), ""); String myContextRoot = ParameterParserUtil .parseStringParamAndSanitize(request.getParameter("mycontextroot"), ""); String myLoginRelativeURL = ParameterParserUtil .parseStringParamAndSanitize(request.getParameter("myloginrelativeurl"), ""); //TODO find another solution myLoginRelativeURL = myLoginRelativeURL.replace("=", "="); String myEnvData = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter("myenvdata"), ""); //Execution String tag = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter("Tag"), ""); String outputFormat = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter("outputformat"), "compact"); int screenshot = ParameterParserUtil.parseIntegerParam(request.getParameter("screenshot"), 1); int verbose = ParameterParserUtil.parseIntegerParam(request.getParameter("verbose"), 0); timeout = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter("timeout"), ""); synchroneous = ParameterParserUtil.parseBooleanParam(request.getParameter("synchroneous"), true); getPageSource = ParameterParserUtil.parseIntegerParam(request.getParameter("pageSource"), 1); getSeleniumLog = ParameterParserUtil.parseIntegerParam(request.getParameter("seleniumLog"), 1); manualExecution = ParameterParserUtil.parseBooleanParam(request.getParameter("manualExecution"), false); long idFromQueue = ParameterParserUtil.parseIntegerParam(request.getParameter("IdFromQueue"), 0); int numberOfRetries = ParameterParserUtil.parseIntegerParam(request.getParameter("retries"), 0); screenSize = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter("screenSize"), ""); robot = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter("robot"), ""); ss_ip = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter("ss_ip"), ""); ss_p = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter("ss_p"), ""); if (request.getParameter("Browser") != null && !"".equals(request.getParameter("Browser"))) { browser = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter("Browser"), "firefox"); } else { browser = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter("browser"), "firefox"); } version = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter("version"), ""); platform = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter("platform"), ""); String helpMessage = "\nThis servlet is used to start the execution of a test case.\n" + "Parameter list :\n" + "- Test [mandatory] : Test to execute. [" + test + "]\n" + "- TestCase [mandatory] : Test Case reference to execute. [" + testCase + "]\n" + "- Country [mandatory] : Country where the test case will execute. [" + country + "]\n" + "- Environment : Environment where the test case will execute. This parameter is mandatory only if manualURL is not set to Y. [" + environment + "]\n" + "- robot : robot name on which the test will be executed. [" + robot + "]\n" + "- ss_ip : Host of the Robot where the test will be executed. (Can be overwriten if robot is defined) [" + ss_ip + "]\n" + "- ss_p : Port of the Robot. (Can be overwriten if robot is defined) [" + ss_p + "]\n" + "- browser : Browser to use for the execution. (Can be overwriten if robot is defined) [" + browser + "]\n" + "- version : Version to use for the execution. (Can be overwriten if robot is defined) [" + version + "]\n" + "- platform : Platform to use for the execution. (Can be overwriten if robot is defined) [" + platform + "]\n" + "- screenSize : Size of the screen to set for the execution. [" + screenSize + "]\n" + "- 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" + "- myhost : Host of the application to test (only used when manualURL is feed). [" + myHost + "]\n" + "- mycontextroot : Context root of the application to test (only used when manualURL is feed). [" + myContextRoot + "]\n" + "- myloginrelativeurl : Relative login URL of the application (only used when manualURL is feed). [" + myLoginRelativeURL + "]\n" + "- myenvdata : Environment where to get the test data when a manualURL is defined. (only used when manualURL is feed) [" + myEnvData + "]\n" + "- Tag : Tag that will be stored on the execution. [" + StringEscapeUtils.escapeHtml4(tag) + "]\n" + "- outputformat : Format of the output of the execution. [" + outputFormat + "]\n" + "- screenshot : Activate or not the screenshots. [" + screenshot + "]\n" + "- verbose : Verbose level of the execution. [" + verbose + "]\n" + "- timeout : Timeout used for the action. If empty, the default value will be the one configured in parameter table. [" + timeout + "]\n" + "- synchroneous : Synchroneous define if the servlet wait for the end of the execution to report its execution. [" + synchroneous + "\n" + "- pageSource : Record Page Source during the execution. [" + getPageSource + "]\n" + "- seleniumLog : Get the SeleniumLog at the end of the execution. [" + getSeleniumLog + "]\n" + "- manualExecution : Execute testcase in manual mode. [" + manualExecution + "]\n" + "- retries : Number of tries if the result is not OK. [" + numberOfRetries + "]\n"; boolean error = false; // -- Checking the parameter validity. -- // test, testcase and country parameters are mandatory if (StringUtils.isBlank(test)) { out.println("Error - Parameter test is mandatory."); error = true; } if (StringUtils.isBlank(testCase)) { out.println("Error - Parameter testCase is mandatory."); error = true; } if (StringUtils.isBlank(country)) { out.println("Error - Parameter country is mandatory."); error = true; } // environment is mandatory when manualURL is not activated. if (StringUtils.isBlank(environment) && !manualURL) { out.println("Error - Parameter environment is mandatory (or use the manualURL parameter)."); error = true; } // We check that execution is not desactivated by cerberus_automaticexecution_enable parameter. IParameterService parameterService = appContext.getBean(IParameterService.class); try { if (!("Y".equals( parameterService.findParameterByKey("cerberus_automaticexecution_enable", "").getValue()))) { out.println( "Error - Execution disable by configuration (cerberus_automaticexecution_enable <> Y)."); error = true; LOG.info("Execution request ignored by cerberus_automaticexecution_enable parameter. " + test + " / " + testCase); } } catch (CerberusException ex) { LOG.error( "Parameter cerberus_automaticexecution_enable not found on Cerberus database. Please make sure database is up to date."); } // If Robot is feeded, we check it exist. If it exist, we overwrite the associated parameters. if (!"".equals(robot)) { IRobotService robotService = appContext.getBean(IRobotService.class); try { Robot robObj = robotService.convert(robotService.readByKey(robot)); // If Robot parameter is defined and we can find the robot, we overwrite the corresponding parameters. ss_ip = ParameterParserUtil.parseStringParam(robObj.getHost(), ss_ip); ss_p = ParameterParserUtil.parseStringParam(String.valueOf(robObj.getPort()), ss_p); browser = ParameterParserUtil.parseStringParam(robObj.getBrowser(), browser); version = ParameterParserUtil.parseStringParam(robObj.getVersion(), version); platform = ParameterParserUtil.parseStringParam(robObj.getPlatform(), platform); active = robObj.getActive(); userAgent = robObj.getUserAgent(); capabilities = robObj.getCapabilities(); screenSize = robObj.getScreenSize(); } catch (CerberusException ex) { out.println("Error - Robot [" + robot + "] does not exist."); error = true; } } // We cannot execute a testcase on a desactivated Robot. if (active.equals("N")) { out.println("Error - Robot is not Active."); error = true; } //verify the format of the ScreenSize. It must be 2 integer separated by a *. For example : 1024*768 if (!"".equals(screenSize)) { if (!screenSize.contains("*")) { out.println("Error - ScreenSize format is not Correct. It must be 2 Integer separated by a *."); error = true; } else { try { String screenWidth = screenSize.split("\\*")[0]; String screenLength = screenSize.split("\\*")[1]; Integer.parseInt(screenWidth); Integer.parseInt(screenLength); } catch (Exception e) { out.println("Error - ScreenSize format is not Correct. It must be 2 Integer separated by a *."); error = true; } } } if (!error) { //check if the test case is to be executed in the specific parameters boolean exists = false; try { ITestCaseCountryService tccService = appContext.getBean(ITestCaseCountryService.class); TestCaseCountry tcc = tccService.findTestCaseCountryByKey(test, testCase, country); if (tcc != null) { exists = true; } } catch (CerberusException ex) { response.setContentType("text/plain"); DateFormat df = new SimpleDateFormat(DateUtil.DATE_FORMAT_DISPLAY); String errorMessage = df.format(new Date()) + " - " + 0 + " [" + test + "|" + testCase + "|" + country + "|" + environment + "] : Test Case is not selected for country!' "; out.println(errorMessage); } //there is no need to lauch the execution if the test case does not exist for the country if (exists) { //TODO:FN debug messages to be removed LOG.debug("STARTED: Test " + test + "-" + testCase); IRunTestCaseService runTestCaseService = appContext.getBean(IRunTestCaseService.class); IFactoryTestCase factoryTCase = appContext.getBean(IFactoryTestCase.class); IFactoryTestCaseExecution factoryTCExecution = appContext.getBean(IFactoryTestCaseExecution.class); ITestCaseExecutionService tces = appContext.getBean(ITestCaseExecutionService.class); TestCase tCase = factoryTCase.create(test, testCase); TestCaseExecution tCExecution = factoryTCExecution.create(0, test, testCase, null, null, environment, myEnvData, country, browser, version, platform, "", 0, 0, "", "", null, ss_ip, null, ss_p, tag, "N", verbose, screenshot, getPageSource, getSeleniumLog, synchroneous, timeout, outputFormat, null, Infos.getInstance().getProjectNameAndVersion(), tCase, null, null, manualURL, myHost, myContextRoot, myLoginRelativeURL, myEnvData, ss_ip, ss_p, null, new MessageGeneral(MessageGeneralEnum.EXECUTION_PE_TESTSTARTED), "Selenium", numberOfRetries, screenSize, capabilities, "", "", "", "", "", manualExecution); /** * Set UserAgent */ tCExecution.setUserAgent(userAgent); /** * Set UUID */ ExecutionUUID executionUUIDObject = appContext.getBean(ExecutionUUID.class); UUID executionUUID = UUID.randomUUID(); executionUUIDObject.setExecutionUUID(executionUUID.toString(), tCExecution); tCExecution.setExecutionUUID(executionUUID.toString()); LOG.info("Execution Requested : UUID=" + executionUUID); /** * Set IdFromQueue */ tCExecution.setIdFromQueue(idFromQueue); /** * Loop on the execution of the testcase until we get an OK or * reached the number of retries. */ //while (tCExecution.getNumberOfRetries() >= 0 && !tCExecution.getResultMessage().getCodeString().equals("OK")) { try { LOG.debug("Start execution " + tCExecution.getId()); tCExecution = runTestCaseService.runTestCase(tCExecution); // tCExecution.decreaseNumberOfRetries(); } catch (Exception ex) { LOG.error("Error while executing RunTestCase ", ex); // break; } // } /** * If execution happened, we Log the Execution. */ if (tCExecution.getId() != 0) { TestCaseExecution t = (TestCaseExecution) tces.readByKeyWithDependency(tCExecution.getId()) .getItem(); LOG.info("CerberusExecution " + t.toJson()); } /** * Clean memory in case testcase has not been launched(Remove * all object put in memory) */ try { if (tCExecution.getId() == 0) { executionUUIDObject.removeExecutionUUID(tCExecution.getExecutionUUID()); LOG.debug("Clean ExecutionUUID"); } } catch (Exception ex) { LOG.error("Exception cleaning Memory: ", ex); } /** * Execution is finished we report the result. */ long runID = tCExecution.getId(); if (outputFormat.equalsIgnoreCase("gui")) { // HTML GUI output. either the detailed execution page or an error page when the execution is not created. if (runID > 0) { // Execution has been created. AnswerItem a = parameterService.readByKey("", "cerberus_executiondetail_use"); if (a.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode()) && a.getItem() != null) { Parameter p = (Parameter) a.getItem(); if (!p.getValue().equals("N")) { response.sendRedirect("ExecutionDetail2.jsp?executionId=" + runID); } else { response.sendRedirect("ExecutionDetail.jsp?id_tc=" + runID); } } else { response.sendRedirect("ExecutionDetail.jsp?id_tc=" + runID); } } else { // Execution was not even created. response.setContentType("text/html"); out.println( "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><title>Test Execution Result</title></head>"); out.println("<body>"); out.println("<table>"); out.println("<tr><td>RunID</td><td><span id='RunID'>" + runID + "</span></td></tr>"); out.println("<tr><td>IdFromQueue</td><td><b><span id='IdFromQueue'>" + tCExecution.getIdFromQueue() + "</span></b></td></tr>"); out.println("<tr><td>Test</td><td><span id='Test'>" + test + "</span></td></tr>"); out.println( "<tr><td>TestCase</td><td><span id='TestCase'>" + testCase + "</span></td></tr>"); out.println("<tr><td>Country</td><td><span id='Country'>" + country + "</span></td></tr>"); out.println("<tr><td>Environment</td><td><span id='Environment'>" + environment + "</span></td></tr>"); out.println("<tr><td>TimestampStart</td><td><span id='TimestampStart'>" + new Timestamp(tCExecution.getStart()) + "</span></td></tr>"); out.println("<tr><td>TimestampEnd</td><td><span id='TimestampEnd'>" + new Timestamp(tCExecution.getEnd()) + "</span></td></tr>"); out.println("<tr><td>OutputFormat</td><td><span id='OutputFormat'>" + outputFormat + "</span></td></tr>"); out.println("<tr><td>Verbose</td><td><span id='Verbose'>" + verbose + "</span></td></tr>"); out.println("<tr><td>Screenshot</td><td><span id='Screenshot'>" + screenshot + "</span></td></tr>"); out.println("<tr><td>PageSource</td><td><span id='PageSource'>" + getPageSource + "</span></td></tr>"); out.println("<tr><td>SeleniumLog</td><td><span id='SeleniumLog'>" + getSeleniumLog + "</span></td></tr>"); out.println("<tr><td>Robot</td><td><span id='Robot'>" + robot + "</span></td></tr>"); out.println("<tr><td>Selenium Server IP</td><td><span id='SeleniumIP'>" + ss_ip + "</span></td></tr>"); out.println("<tr><td>Selenium Server Port</td><td><span id='SeleniumPort'>" + ss_p + "</span></td></tr>"); out.println("<tr><td>Timeout</td><td><span id='Timeout'>" + timeout + "</span></td></tr>"); out.println("<tr><td>Synchroneous</td><td><span id='Synchroneous'>" + synchroneous + "</span></td></tr>"); out.println("<tr><td>Browser</td><td><span id='Browser'>" + browser + "</span></td></tr>"); out.println("<tr><td>Version</td><td><span id='Version'>" + version + "</span></td></tr>"); out.println( "<tr><td>Platform</td><td><span id='Platform'>" + platform + "</span></td></tr>"); out.println("<tr><td>Screen Size</td><td><span id='screenSize'>" + screenSize + "</span></td></tr>"); out.println("<tr><td>Number of Retry</td><td><span id='nbretry'>" + numberOfRetries + "</span></td></tr>"); out.println("<tr><td>ManualURL</td><td><span id='ManualURL'>" + tCExecution.isManualURL() + "</span></td></tr>"); out.println("<tr><td>MyHost</td><td><span id='MyHost'>" + tCExecution.getMyHost() + "</span></td></tr>"); out.println("<tr><td>MyContextRoot</td><td><span id='MyContextRoot'>" + tCExecution.getMyContextRoot() + "</span></td></tr>"); out.println("<tr><td>MyLoginRelativeURL</td><td><span id='MyLoginRelativeURL'>" + tCExecution.getMyLoginRelativeURL() + "</span></td></tr>"); out.println("<tr><td>myEnvironmentData</td><td><span id='myEnvironmentData'>" + tCExecution.getEnvironmentData() + "</span></td></tr>"); out.println("<tr><td>ReturnCode</td><td><b><span id='ReturnCodeDescription'>" + tCExecution.getResultMessage().getCode() + "</span></b></td></tr>"); out.println("<tr><td>ReturnCodeDescription</td><td><b><span id='ReturnCodeDescription'>" + tCExecution.getResultMessage().getDescription() + "</span></b></td></tr>"); out.println("<tr><td>ControlStatus</td><td><b><span id='ReturnCodeMessage'>" + tCExecution.getResultMessage().getCodeString() + "</span></b></td></tr>"); out.println("<tr><td></td><td></td></tr>"); out.println("</table><br><br>"); out.println("<table border>"); out.println("<tr>" + "<td><input id=\"ButtonRetry\" type=\"button\" value=\"Retry\" onClick=\"window.location.reload()\"></td>" + "<td><input id=\"ButtonBack\" type=\"button\" value=\"Go Back\" onClick=\"window.history.back()\"></td>" + "<td><input id=\"ButtonOpenTC\" type=\"button\" value=\"Open Test Case\" onClick=\"window.open('TestCaseScript.jsp?test=" + test + "&testcase=" + testCase + "')\"></td>" + "</tr>"); out.println("</table>"); out.println("</body>"); out.println("</html>"); } } else if (outputFormat.equalsIgnoreCase("redirectToReport")) { // Redirect to the reporting page by tag. response.sendRedirect( "./ReportingExecutionByTag.jsp?Tag=" + StringUtil.encodeAsJavaScriptURIComponent(tag)); } else if (outputFormat.equalsIgnoreCase("verbose-txt")) { // Text verbose output. response.setContentType("text/plain"); String separator = " = "; out.println("RunID" + separator + runID); out.println("Test" + separator + test); out.println("TestCase" + separator + testCase); out.println("Country" + separator + country); out.println("Environment" + separator + environment); out.println("Time Start" + separator + new Timestamp(tCExecution.getStart())); out.println("Time End" + separator + new Timestamp(tCExecution.getEnd())); out.println("OutputFormat" + separator + outputFormat); out.println("Verbose" + separator + verbose); out.println("Screenshot" + separator + screenshot); out.println("PageSource" + separator + getPageSource); out.println("SeleniumLog" + separator + getSeleniumLog); out.println("Robot" + separator + robot); out.println("Selenium Server IP" + separator + ss_ip); out.println("Selenium Server Port" + separator + ss_p); out.println("Timeout" + separator + timeout); out.println("Synchroneous" + separator + synchroneous); out.println("Browser" + separator + browser); out.println("Version" + separator + version); out.println("Platform" + separator + platform); out.println("ScreenSize" + separator + screenSize); out.println("Nb Of Retry" + separator + numberOfRetries); out.println("ManualURL" + separator + tCExecution.isManualURL()); out.println("MyHost" + separator + tCExecution.getMyHost()); out.println("MyContextRoot" + separator + tCExecution.getMyContextRoot()); out.println("MyLoginRelativeURL" + separator + tCExecution.getMyLoginRelativeURL()); out.println("myEnvironmentData" + separator + tCExecution.getEnvironmentData()); out.println("ReturnCode" + separator + tCExecution.getResultMessage().getCode()); out.println( "ReturnCodeDescription" + separator + tCExecution.getResultMessage().getDescription()); out.println("ControlStatus" + separator + tCExecution.getResultMessage().getCodeString()); } else { // Default behaviour when not outputformat is defined : compact mode. response.setContentType("text/plain"); DateFormat df = new SimpleDateFormat(DateUtil.DATE_FORMAT_DISPLAY); out.println(df.format(tCExecution.getStart()) + " - " + runID + " [" + test + "|" + testCase + "|" + country + "|" + environment + "] : '" + tCExecution.getResultMessage().getCodeString() + "' - " + tCExecution.getResultMessage().getCode() + " " + tCExecution.getResultMessage().getDescription()); } } } else { // In case of errors, we display the help message. out.println(helpMessage); } }
From source file:org.codelabor.example.xss.commons.StringEscapeUtilsTest.java
public void testEscapeHtml() { String beforeReplace = "<b>hello, world!</b>"; logger.debug("beforeReplace: {}", beforeReplace); String afterEscape = StringEscapeUtils.escapeHtml4(beforeReplace); logger.debug("StringEscapeUtils.escapeHtml4: {}", afterEscape); String afterUnescape = StringEscapeUtils.unescapeHtml4(afterEscape); logger.debug("StringEscapeUtils.unescapeHtml4: {}", afterUnescape); }
From source file:org.codelabor.system.web.taglib.SystemPropertiesTag.java
@Override public void doTag() throws JspException, IOException { logger.debug("doTag"); logger.debug("emptyString: {}", emptyString); logger.debug("escapeHtml: {}", escapeHtml); JspWriter out = getJspContext().getOut(); String value = System.getProperty(key); String effectiveValue = null; if (value != null) { if (escapeHtml) { effectiveValue = StringEscapeUtils.escapeHtml4(value); } else {/*from www . j a v a 2 s .c o m*/ effectiveValue = value; } } else { if (emptyString) { effectiveValue = ""; } } logger.debug("key: {}, value: {}, effectiveValue: {}", key, value, effectiveValue); out.print(effectiveValue); }
From source file:org.codice.ddf.catalog.ui.query.FeedbackApplication.java
private Map<String, String> getTemplateValueMap(FeedbackRequest feedbackRequest) { Map<String, String> valueMap = new HashMap<>(); valueMap.put("auth_username", feedbackRequest.getAuthUsername()); valueMap.put("username", StringEscapeUtils.escapeHtml4(feedbackRequest.getUsername())); valueMap.put("email", StringEscapeUtils.escapeHtml4(feedbackRequest.getEmail())); valueMap.put("workspace_id", StringEscapeUtils.escapeHtml4(feedbackRequest.getWorkspaceId())); valueMap.put("workspace_name", StringEscapeUtils.escapeHtml4(feedbackRequest.getWorkspaceName())); valueMap.put("query", StringEscapeUtils.escapeHtml4(feedbackRequest.getQuery())); valueMap.put("query_initiated_time", StringEscapeUtils.escapeHtml4(feedbackRequest.getQueryInitiated())); valueMap.put("query_status", StringEscapeUtils.escapeHtml4(feedbackRequest.getQueryStatus())); valueMap.put("query_results", StringEscapeUtils.escapeHtml4(feedbackRequest.getQueryResults())); valueMap.put("comments", StringEscapeUtils.escapeHtml4(feedbackRequest.getComments())); return valueMap; }
From source file:org.conf4j.util.DefaultMacroEvaluator.java
private static final String escapeHtml(Object value) { return StringEscapeUtils.escapeHtml4(value.toString()).replace("\r\n", "<br>").replace("\n", "<br>"); }
From source file:org.coursera.courier.lang.DocEscaping.java
private static String escape(String raw) { String htmlEscaped = StringEscapeUtils.escapeHtml4(raw); // escape "/*" and "*/" by replacing all slashes and asterisks with the entities return htmlEscaped.replace("/*", "/*").replace("*/", "*/"); }
From source file:org.debux.webmotion.site.FileContent.java
public String getContent() { return StringEscapeUtils.escapeHtml4(content); }