use of org.cerberus.exception.FactoryCreationException in project cerberus-source by cerberustesting.
the class AddToExecutionQueueV002 method processRequest.
/**
* Process request for both GET and POST method.
*
* <p>
* Request processing is divided in two parts:
* <ol>
* <li>Getting all test cases which have been sent to this servlet;</li>
* <li>Try to insert all these test cases to the execution queue.</li>
* </ol>
* </p>
*
* @param request
* @param response
* @throws ServletException
* @throws IOException
*/
private void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PrintWriter out = response.getWriter();
final String charset = request.getCharacterEncoding();
Date requestDate = new Date();
// Loading Services.
ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
inQueueService = appContext.getBean(ITestCaseExecutionQueueService.class);
inQueueFactoryService = appContext.getBean(IFactoryTestCaseExecutionQueue.class);
executionThreadService = appContext.getBean(IExecutionThreadPoolService.class);
testCaseService = appContext.getBean(ITestCaseService.class);
invariantService = appContext.getBean(IInvariantService.class);
applicationService = appContext.getBean(IApplicationService.class);
testCaseCountryService = appContext.getBean(ITestCaseCountryService.class);
campaignParameterService = appContext.getBean(ICampaignParameterService.class);
countryEnvParamService = appContext.getBean(ICountryEnvParamService.class);
// Calling Servlet Transversal Util.
ServletUtil.servletStart(request);
// Default message to unexpected error.
MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);
msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", ""));
AnswerItem<List<TestCase>> testcases = null;
/**
* Adding Log entry.
*/
ILogEventService logEventService = appContext.getBean(ILogEventService.class);
logEventService.createForPublicCalls("/AddToExecutionQueueV002", "CALL", "AddToExecutionQueueV002 called : " + request.getRequestURL(), request);
// Parsing all parameters.
// Execution scope parameters : Campaign, TestCases, Countries, Environment, Browser.
String campaign = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter(PARAMETER_CAMPAIGN), null, charset);
List<String> selectTest;
selectTest = ParameterParserUtil.parseListParamAndDecode(request.getParameterValues(PARAMETER_TEST), null, charset);
List<String> selectTestCase;
selectTestCase = ParameterParserUtil.parseListParamAndDecode(request.getParameterValues(PARAMETER_TESTCASE), null, charset);
List<String> countries;
countries = ParameterParserUtil.parseListParamAndDecode(request.getParameterValues(PARAMETER_COUNTRY), null, charset);
List<String> environments;
environments = ParameterParserUtil.parseListParamAndDecodeAndDeleteEmptyValue(request.getParameterValues(PARAMETER_ENVIRONMENT), null, charset);
List<String> browsers = new ArrayList<>();
;
browsers = ParameterParserUtil.parseListParamAndDecode(request.getParameterValues(PARAMETER_BROWSER), browsers, charset);
// Execution parameters.
String tag = ParameterParserUtil.parseStringParam(request.getParameter(PARAMETER_TAG), "");
String robot = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter(PARAMETER_ROBOT), null, charset);
String robotIP = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter(PARAMETER_ROBOT_IP), null, charset);
String robotPort = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter(PARAMETER_ROBOT_PORT), null, charset);
String browserVersion = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter(PARAMETER_BROWSER_VERSION), null, charset);
String platform = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter(PARAMETER_PLATFORM), null, charset);
String screenSize = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter(PARAMETER_SCREENSIZE), null, charset);
int manualURL = ParameterParserUtil.parseIntegerParamAndDecode(request.getParameter(PARAMETER_MANUAL_URL), DEFAULT_VALUE_MANUAL_URL, charset);
String manualHost = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter(PARAMETER_MANUAL_HOST), null, charset);
String manualContextRoot = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter(PARAMETER_MANUAL_CONTEXT_ROOT), null, charset);
String manualLoginRelativeURL = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter(PARAMETER_MANUAL_LOGIN_RELATIVE_URL), null, charset);
String manualEnvData = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter(PARAMETER_MANUAL_ENV_DATA), null, charset);
int screenshot = ParameterParserUtil.parseIntegerParamAndDecode(request.getParameter(PARAMETER_SCREENSHOT), DEFAULT_VALUE_SCREENSHOT, charset);
int verbose = ParameterParserUtil.parseIntegerParamAndDecode(request.getParameter(PARAMETER_VERBOSE), DEFAULT_VALUE_VERBOSE, charset);
String timeout = request.getParameter(PARAMETER_TIMEOUT);
int pageSource = ParameterParserUtil.parseIntegerParamAndDecode(request.getParameter(PARAMETER_PAGE_SOURCE), DEFAULT_VALUE_PAGE_SOURCE, charset);
int seleniumLog = ParameterParserUtil.parseIntegerParamAndDecode(request.getParameter(PARAMETER_SELENIUM_LOG), DEFAULT_VALUE_SELENIUM_LOG, charset);
int retries = ParameterParserUtil.parseIntegerParamAndDecode(request.getParameter(PARAMETER_RETRIES), DEFAULT_VALUE_RETRIES, charset);
String manualExecution = ParameterParserUtil.parseStringParamAndDecode(request.getParameter(PARAMETER_MANUAL_EXECUTION), DEFAULT_VALUE_MANUAL_EXECUTION, charset);
int priority = ParameterParserUtil.parseIntegerParamAndDecode(request.getParameter(PARAMETER_EXEPRIORITY), DEFAULT_VALUE_PRIORITY, charset);
if (manualExecution.equals("")) {
manualExecution = DEFAULT_VALUE_MANUAL_EXECUTION;
}
String outputFormat = ParameterParserUtil.parseStringParamAndDecode(request.getParameter(PARAMETER_OUTPUTFORMAT), DEFAULT_VALUE_OUTPUTFORMAT, charset);
// Defining help message.
String helpMessage = "This servlet is used to add to Cerberus execution queue a list of execution. Execution list will be calculated from cartesian product of " + "testcase, country, environment and browser list. Those list can be defined from the associated servlet parameter but can also be defined from campaign directy inside Cerberus.\n" + "List defined from servlet overwrite the list defined from the campaign. All other execution parameters will be taken to each execution.\n" + "Available parameters:\n" + "- " + PARAMETER_CAMPAIGN + " : Campaign name from which testcase, countries, environment and browser can be defined from Cerberus. [" + campaign + "]\n" + "- " + PARAMETER_TEST + " : List of test to trigger. That list overwrite the list coming from the Campaign (if defined).. [" + selectTest + "]\n" + "- " + PARAMETER_TESTCASE + " : List of testCase to trigger. That list overwrite the list coming from the Campaign (if defined).. [" + selectTestCase + "]\n" + "- " + PARAMETER_COUNTRY + " : List of countries to trigger. That list overwrite the list coming from the Campaign (if defined).. [" + countries + "]\n" + "- " + PARAMETER_ENVIRONMENT + " : List of environment to trigger. That list overwrite the list coming from the Campaign (if defined).. [" + environments + "]\n" + "- " + PARAMETER_BROWSER + " : List of browser to trigger. That list overwrite the list coming from the Campaign (if defined).. [" + browsers + "]\n" + "- " + PARAMETER_ROBOT + " : Robot Name that will be used for every execution triggered. [" + robot + "]\n" + "- " + PARAMETER_ROBOT_IP + " : Robot IP that will be used for every execution triggered. [" + robotIP + "]\n" + "- " + PARAMETER_ROBOT_PORT + " : Robot Port that will be used for every execution triggered. [" + robotPort + "]\n" + "- " + PARAMETER_BROWSER_VERSION + " : Browser Version that will be used for every execution triggered. [" + browserVersion + "]\n" + "- " + PARAMETER_PLATFORM + " : Platform that will be used for every execution triggered. [" + platform + "]\n" + "- " + PARAMETER_SCREENSIZE + " : Size of the screen that will be used for every execution triggered. [" + screenSize + "]\n" + "- " + PARAMETER_MANUAL_URL + " : Activate (1) or not (0) the Manual URL of the application to execute. If activated the 4 parameters after are necessary. [" + manualURL + "]\n" + "- " + PARAMETER_MANUAL_HOST + " : Host of the application to test (only used when " + PARAMETER_MANUAL_URL + " is activated). [" + manualHost + "]\n" + "- " + PARAMETER_MANUAL_CONTEXT_ROOT + " : Context root of the application to test (only used when " + PARAMETER_MANUAL_URL + " is activated). [" + manualContextRoot + "]\n" + "- " + PARAMETER_MANUAL_LOGIN_RELATIVE_URL + " : Relative login URL of the application (only used when " + PARAMETER_MANUAL_URL + " is activated). [" + manualLoginRelativeURL + "]\n" + "- " + PARAMETER_MANUAL_ENV_DATA + " : Environment where to get the test data when a " + PARAMETER_MANUAL_URL + " is defined. (only used when manualURL is active). [" + manualEnvData + "]\n" + "- " + PARAMETER_TAG + " : Tag that will be used for every execution triggered. [" + tag + "]\n" + "- " + PARAMETER_SCREENSHOT + " : Activate or not the screenshots for every execution triggered. [" + screenshot + "]\n" + "- " + PARAMETER_VERBOSE + " : Verbose level for every execution triggered. [" + verbose + "]\n" + "- " + PARAMETER_TIMEOUT + " : Timeout used for the action that will be used for every execution triggered. [" + timeout + "]\n" + "- " + PARAMETER_PAGE_SOURCE + " : Record Page Source during for every execution triggered. [" + pageSource + "]\n" + "- " + PARAMETER_SELENIUM_LOG + " : Get the SeleniumLog at the end of the execution for every execution triggered. [" + seleniumLog + "]\n" + "- " + PARAMETER_MANUAL_EXECUTION + " : Execute testcase in manual mode for every execution triggered. [" + manualExecution + "]\n" + "- " + PARAMETER_RETRIES + " : Number of tries if the result is not OK for every execution triggered. [" + retries + "]\n" + "- " + PARAMETER_EXEPRIORITY + " : Priority that will be used in the queue for every execution triggered. [" + priority + "]\n" + "- " + PARAMETER_OUTPUTFORMAT + " : Format of the servlet output. can be compact, json [" + outputFormat + "]\n";
// try {
// Checking the parameter validity.
StringBuilder errorMessage = new StringBuilder();
boolean error = false;
if (tag == null || tag.isEmpty()) {
if (request.getRemoteUser() != null) {
tag = request.getRemoteUser();
}
if (tag.length() > 0) {
tag += ".";
}
if (campaign != null) {
tag += campaign;
}
if (tag.length() > 0) {
tag += ".";
}
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
String mytimestamp = sdf.format(timestamp);
tag += mytimestamp;
} else if (tag.length() > 255) {
errorMessage.append("Error - Parameter ").append(PARAMETER_TAG).append(" is too big. Maximum size if 255. Current size is : ").append(tag.length()).append("\n");
error = true;
}
if (campaign != null && !campaign.isEmpty()) {
final AnswerItem<Map<String, List<String>>> parsedCampaignParameters = campaignParameterService.parseParametersByCampaign(campaign);
if (parsedCampaignParameters.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) {
// If parameters are already defined from request, we ignore the campaign values.
if (countries == null || countries.isEmpty()) {
countries = parsedCampaignParameters.getItem().get(CampaignParameter.COUNTRY_PARAMETER);
}
if (environments == null || environments.isEmpty()) {
environments = parsedCampaignParameters.getItem().get(CampaignParameter.ENVIRONMENT_PARAMETER);
}
if (browsers == null || browsers.isEmpty()) {
browsers = parsedCampaignParameters.getItem().get(CampaignParameter.BROWSER_PARAMETER);
}
}
if ((countries != null) && (selectTest == null || selectTest.isEmpty())) {
// If no countries are found, there is no need to get the testcase list. None will be returned.
selectTest = new ArrayList<>();
selectTestCase = new ArrayList<>();
testcases = testCaseService.findTestCaseByCampaignNameAndCountries(campaign, countries.toArray(new String[countries.size()]));
for (TestCase campaignTestCase : testcases.getItem()) {
selectTest.add(campaignTestCase.getTest());
selectTestCase.add(campaignTestCase.getTestCase());
}
}
}
if (countries == null || countries.isEmpty()) {
errorMessage.append("Error - No Country defined. You can either feed it with parameter '" + PARAMETER_COUNTRY + "' or add it into the campaign definition.\n");
error = true;
}
if ((StringUtil.isNullOrEmpty(robot)) && (browsers == null || browsers.isEmpty())) {
errorMessage.append("Error - No Browser defined. You can either feed it with parameter '" + PARAMETER_BROWSER + "' or add it into the campaign definition.\n");
error = true;
}
if (selectTest == null || selectTest.isEmpty() || selectTestCase == null || selectTestCase.isEmpty()) {
errorMessage.append("Error - No TestCases defined. You can either feed it with parameters '" + PARAMETER_TEST + "' and '" + PARAMETER_TESTCASE + "' or add it into the campaign definition.\n");
error = true;
}
if ((selectTest != null) && (selectTestCase != null) && (selectTest.size() != selectTestCase.size())) {
errorMessage.append("Error - Test list size (").append(selectTest.size()).append(") is not the same as testcase list size (").append(selectTestCase.size()).append("). Please check that both list are consistent.\n");
error = true;
}
if (manualURL >= 1) {
if (manualHost == null || manualEnvData == null) {
errorMessage.append("Error - ManualURL has been activated but no ManualHost or Manual Environment defined.\n");
error = true;
}
} else if (environments == null || environments.isEmpty()) {
errorMessage.append("Error - No Environment defined (and " + PARAMETER_MANUAL_URL + " not activated). You can either feed it with parameter '" + PARAMETER_ENVIRONMENT + "' or add it into the campaign definition.\n");
error = true;
}
int nbExe = 0;
JSONArray jsonArray = new JSONArray();
String user = request.getRemoteUser() == null ? "" : request.getRemoteUser();
int nbtestcasenotactive = 0;
int nbtestcaseenvgroupnotallowed = 0;
int nbenvnotexist = 0;
boolean tagAlreadyAdded = false;
int nbbrowser = 0;
if (browsers.isEmpty()) {
nbbrowser = 1;
} else {
nbbrowser = browsers.size();
}
int nbtescase = selectTest.size();
int nbenv = environments.size();
int nbcountries = countries.size();
// Starting the request only if previous parameters exist.
if (!error) {
// Part 1: Getting all possible Execution from test cases + countries + environments + browsers which have been sent to this servlet.
Map<String, String> invariantEnv = invariantService.readToHashMapGp1StringByIdname("ENVIRONMENT", "");
List<TestCaseExecutionQueue> toInserts = new ArrayList<TestCaseExecutionQueue>();
try {
HashMap<String, CountryEnvParam> envMap = new HashMap<>();
LOG.debug("Loading all environments.");
for (CountryEnvParam envParam : countryEnvParamService.convert(countryEnvParamService.readActiveBySystem(null))) {
envMap.put(envParam.getSystem() + LOCAL_SEPARATOR + envParam.getCountry() + LOCAL_SEPARATOR + envParam.getEnvironment(), envParam);
}
LOG.debug("Nb of TestCase : " + selectTest.size());
for (int i = 0; i < selectTest.size(); i++) {
// for (String localTest : selectTest) {
String test = selectTest.get(i);
String testCase = selectTestCase.get(i);
TestCase tc = testCaseService.convert(testCaseService.readByKey(test, testCase));
// TestCases that are not active are not inserted into queue.
if (tc.getTcActive().equals("Y")) {
// We only insert testcase that exist for the given country.
for (TestCaseCountry country : testCaseCountryService.convert(testCaseCountryService.readByTestTestCase(null, test, testCase))) {
if (countries.contains(country.getCountry())) {
// for each environment we test that correspondng gp1 is compatible with testcase environment flag activation.
for (String environment : environments) {
String envGp1 = invariantEnv.get(environment);
if (((envGp1.equals("PROD")) && (tc.getActivePROD().equalsIgnoreCase("Y"))) || ((envGp1.equals("UAT")) && (tc.getActiveUAT().equalsIgnoreCase("Y"))) || ((envGp1.equals("QA")) && (tc.getActiveQA().equalsIgnoreCase("Y"))) || (envGp1.equals("DEV"))) {
// Getting Application in order to check application type against browser.
Application app = applicationService.convert(applicationService.readByKey(tc.getApplication()));
if (envMap.containsKey(app.getSystem() + LOCAL_SEPARATOR + country.getCountry() + LOCAL_SEPARATOR + environment)) {
// Create Tag only if not already done and defined.
if (!StringUtil.isNullOrEmpty(tag) && !tagAlreadyAdded) {
// We create or update it.
ITagService tagService = appContext.getBean(ITagService.class);
tagService.createAuto(tag, campaign, user);
tagAlreadyAdded = true;
}
if ((app != null) && (app.getType() != null) && app.getType().equalsIgnoreCase(Application.TYPE_GUI)) {
if (browsers == null || browsers.isEmpty()) {
browsers.add("");
}
for (String browser : browsers) {
try {
LOG.debug("Insert Queue Entry.");
toInserts.add(inQueueFactoryService.create(test, testCase, country.getCountry(), environment, robot, robotIP, robotPort, browser, browserVersion, platform, screenSize, manualURL, manualHost, manualContextRoot, manualLoginRelativeURL, manualEnvData, tag, screenshot, verbose, timeout, pageSource, seleniumLog, 0, retries, manualExecution, priority, user, null, null, null));
} catch (FactoryCreationException e) {
LOG.error("Unable to insert record due to: " + e, e);
LOG.error("test: " + test + "-" + testCase + "-" + country.getCountry() + "-" + environment + "-" + robot);
}
}
} else {
// Application does not support browser so we force an empty value.
LOG.debug("Forcing Browser to empty value. Application type=" + app.getType());
try {
LOG.debug("Insert Queue Entry.");
toInserts.add(inQueueFactoryService.create(test, testCase, country.getCountry(), environment, robot, robotIP, robotPort, "", browserVersion, platform, screenSize, manualURL, manualHost, manualContextRoot, manualLoginRelativeURL, manualEnvData, tag, screenshot, verbose, timeout, pageSource, seleniumLog, 0, retries, manualExecution, priority, user, null, null, null));
} catch (FactoryCreationException e) {
LOG.error("Unable to insert record due to: " + e, e);
LOG.error("test: " + test + "-" + testCase + "-" + country.getCountry() + "-" + environment + "-" + robot);
}
}
} else {
LOG.debug("Env does not exist or is not active.");
nbenvnotexist = nbenvnotexist + nbbrowser;
}
} else {
LOG.debug("Env group not active for testcase : " + environment);
nbtestcaseenvgroupnotallowed = nbtestcaseenvgroupnotallowed + nbbrowser;
}
}
} else {
LOG.debug("Country does not match. " + countries + " " + country.getCountry());
}
}
} else {
LOG.debug("TestCase not Active.");
nbtestcasenotactive = nbtestcasenotactive + (nbcountries * nbenv * nbbrowser);
}
}
} catch (CerberusException ex) {
LOG.warn(ex);
}
// Part 2: Try to insert all these test cases to the execution queue.
List<String> errorMessages = new ArrayList<String>();
for (TestCaseExecutionQueue toInsert : toInserts) {
try {
inQueueService.convert(inQueueService.create(toInsert));
nbExe++;
JSONObject value = new JSONObject();
value.put("queueId", toInsert.getId());
value.put("test", toInsert.getTest());
value.put("testcase", toInsert.getTestCase());
value.put("country", toInsert.getCountry());
value.put("environment", toInsert.getEnvironment());
jsonArray.put(value);
} catch (CerberusException e) {
String errorMessageTmp = "Unable to insert " + toInsert.toString() + " due to " + e.getMessage();
LOG.warn(errorMessageTmp);
errorMessages.add(errorMessageTmp);
continue;
} catch (JSONException ex) {
LOG.error(ex);
}
}
// Part 3 : Trigger JobQueue
try {
executionThreadService.executeNextInQueueAsynchroneously(false);
} catch (CerberusException ex) {
String errorMessageTmp = "Unable to feed the execution queue due to " + ex.getMessage();
LOG.warn(errorMessageTmp);
errorMessages.add(errorMessageTmp);
}
if (!errorMessages.isEmpty()) {
StringBuilder errorMessageTmp = new StringBuilder();
for (String item : errorMessages) {
errorMessageTmp.append(item);
errorMessageTmp.append(LINE_SEPARATOR);
}
errorMessage.append(errorMessageTmp.toString());
}
errorMessage.append(nbExe);
errorMessage.append(" execution(s) succesfully inserted to queue. ");
if (testcases != null && testcases.getResultMessage().getSource() == MessageEventEnum.DATA_OPERATION_WARNING_PARTIAL_RESULT) {
errorMessage.append(testcases.getResultMessage().getDescription());
}
// Message that everything went fine.
msg = new MessageEvent(MessageEventEnum.GENERIC_OK);
} else {
// In case of errors, we display the help message.
// errorMessage.append(helpMessage);
}
// Init Answer with potencial error from Parsing parameter.
AnswerItem answer = new AnswerItem(msg);
switch(outputFormat) {
case "json":
try {
JSONObject jsonResponse = new JSONObject();
jsonResponse.put("messageType", answer.getResultMessage().getMessage().getCodeString());
jsonResponse.put("message", errorMessage.toString());
jsonResponse.put("helpMessage", helpMessage);
jsonResponse.put("tag", tag);
jsonResponse.put("nbExe", nbExe);
jsonResponse.put("nbErrorTCNotActive", nbtestcasenotactive);
jsonResponse.put("nbErrorTCNotAllowedOnEnv", nbtestcaseenvgroupnotallowed);
jsonResponse.put("nbErrorEnvNotExistOrNotActive", nbenvnotexist);
jsonResponse.put("queueList", jsonArray);
response.setContentType("application/json");
response.setCharacterEncoding("utf8");
response.getWriter().print(jsonResponse.toString());
} catch (JSONException e) {
LOG.warn(e);
// returns a default error message with the json format that is able to be parsed by the client-side
response.setContentType("application/json");
response.setCharacterEncoding("utf8");
response.getWriter().print(AnswerUtil.createGenericErrorAnswer());
}
break;
default:
response.setContentType("text");
response.setCharacterEncoding("utf8");
if (error) {
errorMessage.append("\n");
errorMessage.append(helpMessage);
}
response.getWriter().print(errorMessage.toString());
}
// } catch (Exception e) {
// LOG.error(e);
// out.println(helpMessage);
// out.println(e.toString());
// }
}
use of org.cerberus.exception.FactoryCreationException in project cerberus-source by cerberustesting.
the class CreateTestCaseExecutionQueue method processRequest.
/**
* Processes requests for both HTTP <code>GET</code> and <code>POST</code>
* methods.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, CerberusException, JSONException {
JSONObject jsonResponse = new JSONObject();
JSONObject executionQueue = new JSONObject();
ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
Answer ans = new Answer();
AnswerItem ansItem = new AnswerItem();
MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);
msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", ""));
ans.setResultMessage(msg);
PolicyFactory policy = Sanitizers.FORMATTING.and(Sanitizers.LINKS);
String charset = request.getCharacterEncoding();
response.setContentType("application/json");
// Calling Servlet Transversal Util.
ServletUtil.servletStart(request);
/**
* Parsing and securing all required parameters.
*/
// Parameter that are already controled by GUI (no need to decode) --> We SECURE them
String actionState = policy.sanitize(request.getParameter("actionState"));
String actionSave = policy.sanitize(request.getParameter("actionSave"));
String environment = policy.sanitize(request.getParameter("environment"));
String country = policy.sanitize(request.getParameter("country"));
String manualEnvData = policy.sanitize(request.getParameter("manualEnvData"));
// Parameter that needs to be secured --> We SECURE+DECODE them
String test = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("test"), "", charset);
String testcase = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("testCase"), "", charset);
int manualURL = ParameterParserUtil.parseIntegerParamAndDecode(request.getParameter("manualURL"), 0, charset);
String manualHost = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("manualHost"), "", charset);
String manualContextRoot = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("manualContextRoot"), "", charset);
String manualLoginRelativeURL = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("manualLoginRelativeURL"), "", charset);
String tag = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("tag"), "", charset);
String robot = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("robot"), "", charset);
String robotIP = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("robotIP"), "", charset);
String robotPort = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("robotPort"), "", charset);
String browser = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("browser"), "", charset);
String browserVersion = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("browserVersion"), "", charset);
String platform = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("platform"), "", charset);
String screenSize = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("screenSize"), "", charset);
int verbose = ParameterParserUtil.parseIntegerParamAndDecode(request.getParameter("verbose"), 1, charset);
int screenshot = ParameterParserUtil.parseIntegerParamAndDecode(request.getParameter("screenshot"), 0, charset);
int pageSource = ParameterParserUtil.parseIntegerParamAndDecode(request.getParameter("pageSource"), 0, charset);
int seleniumLog = ParameterParserUtil.parseIntegerParamAndDecode(request.getParameter("seleniumLog"), 0, charset);
String timeout = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("timeout"), "", charset);
int retries = ParameterParserUtil.parseIntegerParamAndDecode(request.getParameter("retries"), 0, charset);
String manualExecution = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("manualExecution"), "", charset);
String debugFlag = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("debugFlag"), "N", charset);
// Parameter that we cannot secure as we need the html --> We DECODE them
String[] myIds = request.getParameterValues("id");
if (myIds == null) {
myIds = new String[1];
myIds[0] = "0";
}
long id = 0;
Integer priority = TestCaseExecutionQueue.PRIORITY_DEFAULT;
boolean prio_error = false;
try {
if (request.getParameter("priority") != null && !request.getParameter("priority").equals("")) {
priority = Integer.valueOf(policy.sanitize(request.getParameter("priority")));
}
} catch (Exception ex) {
prio_error = true;
}
boolean id_error = false;
IExecutionThreadPoolService executionThreadPoolService = appContext.getBean(IExecutionThreadPoolService.class);
// Create Tag when exist.
if (!StringUtil.isNullOrEmpty(tag)) {
// We create or update it.
ITagService tagService = appContext.getBean(ITagService.class);
tagService.createAuto(tag, "", request.getRemoteUser());
}
// Prepare the final answer.
MessageEvent msg1 = new MessageEvent(MessageEventEnum.GENERIC_OK);
Answer finalAnswer = new Answer(msg1);
List<TestCaseExecutionQueue> insertedList = new ArrayList();
for (String myId : myIds) {
id_error = false;
id = 0;
try {
id = Long.valueOf(myId);
} catch (NumberFormatException ex) {
id_error = true;
}
/**
* Checking all constrains before calling the services.
*/
if (id_error) {
msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED);
msg.setDescription(msg.getDescription().replace("%ITEM%", "Execution Queue").replace("%OPERATION%", "Update").replace("%REASON%", "Could not manage to convert id to an integer value."));
ans.setResultMessage(msg);
finalAnswer = AnswerUtil.agregateAnswer(finalAnswer, (Answer) ans);
} else if (prio_error || priority > 2147483647 || priority < -2147483648) {
msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED);
msg.setDescription(msg.getDescription().replace("%ITEM%", "Execution Queue").replace("%OPERATION%", "Update").replace("%REASON%", "Could not manage to convert priority to an integer value."));
ans.setResultMessage(msg);
finalAnswer = AnswerUtil.agregateAnswer(finalAnswer, (Answer) ans);
} else {
try {
/**
* All data seems cleans so we can call the services.
*/
ITestCaseExecutionQueueService executionQueueService = appContext.getBean(ITestCaseExecutionQueueService.class);
IFactoryTestCaseExecutionQueue executionQueueFactory = appContext.getBean(IFactoryTestCaseExecutionQueue.class);
if (actionSave.equals("save")) {
/**
* The service was able to perform the query and confirm
* the object exist, then we can update it.
*/
TestCaseExecutionQueue executionQueueData;
if (id == 0) {
// If id is not defined, we build the execution queue from all request datas.
executionQueueData = executionQueueFactory.create(test, testcase, country, environment, robot, robotIP, robotPort, browser, browserVersion, platform, screenSize, manualURL, manualHost, manualContextRoot, manualLoginRelativeURL, manualEnvData, tag, screenshot, verbose, timeout, pageSource, seleniumLog, 0, retries, manualExecution, priority, request.getRemoteUser(), null, null, null);
executionQueueData.setDebugFlag(debugFlag);
} else {
// If id is defined, we get the execution queue from database.
executionQueueData = executionQueueService.convert(executionQueueService.readByKey(id));
executionQueueData.setState(TestCaseExecutionQueue.State.QUEUED);
executionQueueData.setComment("");
executionQueueData.setDebugFlag("N");
executionQueueData.setPriority(TestCaseExecutionQueue.PRIORITY_DEFAULT);
executionQueueData.setUsrCreated(request.getRemoteUser());
}
ansItem = executionQueueService.create(executionQueueData);
finalAnswer = AnswerUtil.agregateAnswer(finalAnswer, (Answer) ansItem);
if (ansItem.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) {
TestCaseExecutionQueue addedExecution = (TestCaseExecutionQueue) ansItem.getItem();
insertedList.add(addedExecution);
}
if (myIds.length <= 1) {
if (ansItem.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) {
/**
* Update was successful. Adding Log entry.
*/
ILogEventService logEventService = appContext.getBean(LogEventService.class);
logEventService.createForPrivateCalls("/CreateTestCaseExecutionQueue", "CREATE", "Created ExecutionQueue : ['" + id + "']", request);
}
}
}
} catch (FactoryCreationException ex) {
LOG.warn(ex);
}
}
}
// Update is done, we now check what action needs to be performed.
if (actionState.equals("toQUEUED")) {
executionThreadPoolService.executeNextInQueueAsynchroneously(false);
}
/**
* Formating and returning the json result.
*/
jsonResponse.put("messageType", finalAnswer.getResultMessage().getMessage().getCodeString());
jsonResponse.put("message", finalAnswer.getResultMessage().getDescription());
if (insertedList.isEmpty()) {
jsonResponse.put("addedEntries", 0);
} else {
JSONArray executionList = new JSONArray();
for (TestCaseExecutionQueue testCaseExecutionQueue : insertedList) {
JSONObject myExecution = new JSONObject();
myExecution.append("id", testCaseExecutionQueue.getId());
executionList.put(myExecution);
}
jsonResponse.put("testCaseExecutionQueueList", executionList);
jsonResponse.put("addedEntries", insertedList.size());
}
response.getWriter().print(jsonResponse);
response.getWriter().flush();
}
use of org.cerberus.exception.FactoryCreationException in project cerberus-source by cerberustesting.
the class RunTestCase method doGet.
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PrintWriter out = response.getWriter();
ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
// Calling Servlet Transversal Util.
ServletUtil.servletStart(request);
/**
* Adding Log entry.
*/
ILogEventService logEventService = appContext.getBean(ILogEventService.class);
logEventService.createForPublicCalls("/RunTestCase", "CALL", "RunTestCase called : " + request.getRequestURL(), request);
// Tool
// Selenium IP
String ss_ip = "";
// Selenium Host (optional)
String ss_ip_user = "";
// Selenium Password (optional)
String ss_ip_pass = "";
// Selenium Port
String ss_p = "";
String browser = "";
String robotDecli = "";
String version = "";
String platform = "";
String robot = "";
String active = "";
String timeout = "";
String userAgent = "";
String screenSize = "";
boolean synchroneous = true;
int getPageSource = 0;
int getSeleniumLog = 0;
String manualExecution = "N";
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"), false);
getPageSource = ParameterParserUtil.parseIntegerParam(request.getParameter("pageSource"), 1);
getSeleniumLog = ParameterParserUtil.parseIntegerParam(request.getParameter("seleniumLog"), 1);
manualExecution = ParameterParserUtil.parseStringParam(request.getParameter("manualExecution"), "N");
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"), "");
browser = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter("Browser"), ParameterParserUtil.parseStringParamAndSanitize(request.getParameter("browser"), ""));
version = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter("version"), "");
platform = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter("platform"), "");
// hidden parameters.
long idFromQueue = ParameterParserUtil.parseIntegerParam(request.getParameter("IdFromQueue"), 0);
String executor = ParameterParserUtil.parseStringParamAndSanitize(request.getParameter("executor"), ParameterParserUtil.parseStringParamAndSanitize(request.getRemoteUser(), null));
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. [" + 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;
String errorMessage = "";
// test, testcase and country parameters are mandatory
if (StringUtils.isBlank(test)) {
errorMessage += "Error - Parameter test is mandatory. ";
error = true;
}
if (StringUtils.isBlank(testCase)) {
errorMessage += "Error - Parameter testCase is mandatory. ";
error = true;
}
if (!StringUtils.isBlank(tag) && tag.length() > 255) {
errorMessage += "Error - Parameter tag value is too big. Tag cannot be larger than 255 Characters. Currently has : " + tag.length();
error = true;
}
if (StringUtils.isBlank(country)) {
errorMessage += "Error - Parameter country is mandatory. ";
error = true;
}
// environment is mandatory when manualURL is not activated.
if (StringUtils.isBlank(environment) && !manualURL) {
errorMessage += "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);
if (!(parameterService.getParameterBooleanByKey("cerberus_automaticexecution_enable", "", true))) {
errorMessage += "Error - Execution disable by configuration (cerberus_automaticexecution_enable <> Y). ";
error = true;
LOG.info("Execution request ignored by cerberus_automaticexecution_enable parameter. " + test + " / " + testCase);
}
// If Robot is feeded, we check it exist. If it exist, we overwrite the associated parameters.
if (!StringUtil.isNullOrEmpty(robot)) {
IRobotService robotService = appContext.getBean(IRobotService.class);
try {
Robot robObj = 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_ip_user = robObj.getHostUser();
ss_ip_pass = robObj.getHostPassword();
ss_p = ParameterParserUtil.parseStringParam(String.valueOf(robObj.getPort()), ss_p);
browser = ParameterParserUtil.parseStringParam(robObj.getBrowser(), browser);
robotDecli = ParameterParserUtil.parseStringParam(robObj.getRobotDecli(), "");
if (StringUtil.isNullOrEmpty(robotDecli)) {
robotDecli = robObj.getRobot();
}
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) {
errorMessage += "Error - Robot [" + robot + "] does not exist. ";
error = true;
}
} else {
robotDecli = browser;
}
// We cannot execute a testcase on a desactivated Robot.
if (active.equals("N")) {
errorMessage += "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("*")) {
errorMessage += "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) {
errorMessage += "Error - ScreenSize format is not Correct. It must be 2 Integer separated by a *. ";
error = true;
}
}
}
// check if the test case is to be executed in the specific parameters
try {
ITestCaseCountryService tccService = appContext.getBean(ITestCaseCountryService.class);
TestCaseCountry tcc = tccService.findTestCaseCountryByKey(test, testCase, country);
if (tcc == null) {
error = true;
}
} catch (CerberusException ex) {
error = true;
errorMessage += "Error - Test Case is not selected for country. ";
}
// Create Tag when exist.
if (!StringUtil.isNullOrEmpty(tag)) {
// We create or update it.
ITagService tagService = appContext.getBean(ITagService.class);
tagService.createAuto(tag, "", executor);
}
if (!error) {
// 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);
IFactoryTestCaseExecutionQueue factoryTCExecutionQueue = appContext.getBean(IFactoryTestCaseExecutionQueue.class);
ITestCaseExecutionService tces = appContext.getBean(ITestCaseExecutionService.class);
ITestCaseService tcs = appContext.getBean(ITestCaseService.class);
TestCase tCase = factoryTCase.create(test, testCase);
// Building Execution Object.
TestCaseExecution tCExecution = factoryTCExecution.create(0, test, testCase, null, null, null, environment, country, browser, version, platform, "", 0, 0, "", "", "", null, ss_ip, null, ss_p, tag, 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), executor, numberOfRetries, screenSize, capabilities, "", "", "", "", "", manualExecution, userAgent, 0, "", robotDecli);
tCExecution.setSeleniumIPUser(ss_ip_user);
tCExecution.setSeleniumIPPassword(ss_ip_pass);
/**
* Set IdFromQueue
*/
try {
tCExecution.setQueueID(idFromQueue);
TestCaseExecutionQueue queueExecution = factoryTCExecutionQueue.create(idFromQueue, test, testCase, country, environment, robot, ss_ip, ss_p, browser, version, platform, screenSize, 0, myHost, myContextRoot, myLoginRelativeURL, myEnvData, tag, screenshot, verbose, timeout, getPageSource, getSeleniumLog, 0, numberOfRetries, manualExecution, executor, null, null, null);
tCExecution.setTestCaseExecutionQueue(queueExecution);
} catch (FactoryCreationException ex) {
LOG.error(ex);
}
/**
* 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);
/**
* Execution of the testcase.
*/
LOG.debug("Start execution " + tCExecution.getId());
tCExecution = runTestCaseService.runTestCase(tCExecution);
/**
* 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.
response.sendRedirect("TestCaseExecution.jsp?executionId=" + 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.getQueueID() + "</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("QueueID" + separator + idFromQueue);
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 if (outputFormat.equalsIgnoreCase("verbose-json")) {
// JSON verbose output.
response.setContentType("application/json");
TestCaseExecution t = (TestCaseExecution) tces.readByKeyWithDependency(tCExecution.getId()).getItem();
out.print(tCExecution.toJson(true).toString());
} 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 {
// Error occured in the servlet.
if (outputFormat.equalsIgnoreCase("verbose-txt")) {
// Text verbose output.
response.setContentType("text/plain");
String separator = " = ";
out.println("RunID" + separator + 0);
out.println("QueueID" + separator + idFromQueue);
out.println("Test" + separator + test);
out.println("TestCase" + separator + testCase);
out.println("Country" + separator + country);
out.println("Environment" + separator + environment);
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 + manualURL);
out.println("MyHost" + separator + myHost);
out.println("MyContextRoot" + separator + myContextRoot);
out.println("MyLoginRelativeURL" + separator + myLoginRelativeURL);
out.println("myEnvironmentData" + separator + myEnvData);
out.println("ReturnCode" + separator + MessageGeneralEnum.EXECUTION_FA_SERVLETVALIDATONS.getCode());
out.println("ReturnCodeDescription" + separator + MessageGeneralEnum.EXECUTION_FA_SERVLETVALIDATONS.getDescription() + " " + errorMessage);
out.println("ControlStatus" + separator + MessageGeneralEnum.EXECUTION_FA_SERVLETVALIDATONS.getCodeString());
} else {
// In case of errors, we display the help message.
response.setContentType("text/plain");
DateFormat df = new SimpleDateFormat(DateUtil.DATE_FORMAT_DISPLAY);
String errorMessageFinal = df.format(new Date()) + " - " + 0 + " [" + test + "|" + testCase + "|" + country + "|" + environment + "] : '" + MessageGeneralEnum.EXECUTION_FA_SERVLETVALIDATONS.getCodeString() + "' - " + MessageGeneralEnum.EXECUTION_FA_SERVLETVALIDATONS.getCode() + " " + MessageGeneralEnum.EXECUTION_FA_SERVLETVALIDATONS.getDescription() + " " + errorMessage;
out.println(errorMessageFinal);
}
}
}
use of org.cerberus.exception.FactoryCreationException in project cerberus-source by cerberustesting.
the class GetExecutionQueue method processRequest.
/**
* Processes requests for both HTTP <code>GET</code> and <code>POST</code>
* methods.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
* @throws org.json.JSONException
* @throws org.cerberus.exception.CerberusException
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, JSONException, CerberusException {
AnswerItem answer = new AnswerItem(new MessageEvent(MessageEventEnum.DATA_OPERATION_OK));
JSONObject jsonResponse = new JSONObject();
ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
boolean check = ParameterParserUtil.parseBooleanParam(request.getParameter("check"), false);
boolean push = ParameterParserUtil.parseBooleanParam(request.getParameter("push"), false);
if (check) {
IApplicationService applicationService = appContext.getBean(IApplicationService.class);
IInvariantService invariantService = appContext.getBean(IInvariantService.class);
ITestService testService = appContext.getBean(ITestService.class);
ITestCaseService testCaseService = appContext.getBean(ITestCaseService.class);
ICountryEnvParamService cepService = appContext.getBean(ICountryEnvParamService.class);
IParameterService parameterService = appContext.getBean(IParameterService.class);
testCaseExecutionService = appContext.getBean(ITestCaseExecutionService.class);
List<ExecutionValidator> inQueue = new ArrayList<>();
JSONArray testCaseList = new JSONArray(request.getParameter("testcase"));
JSONArray environmentList = new JSONArray(request.getParameter("environment"));
JSONArray countryList = new JSONArray(request.getParameter("countries"));
/**
* Creating all the list from the JSON to call the services
*/
List<TestCase> TCList = new ArrayList<>();
List<String> envList = new ArrayList<>();
List<String> countries = new ArrayList<>();
for (int index = 0; index < testCaseList.length(); index++) {
JSONObject testCaseJson = testCaseList.getJSONObject(index);
TestCase tc = new TestCase();
tc.setTest(testCaseJson.getString("test"));
tc.setTestCase(testCaseJson.getString("testcase"));
TCList.add(tc);
}
for (int index = 0; index < environmentList.length(); index++) {
String environment = environmentList.getString(index);
envList.add(environment);
}
for (int index = 0; index < countryList.length(); index++) {
String country = countryList.getString(index);
countries.add(country);
}
List<TestCaseExecution> tceList = testCaseExecutionService.createAllTestCaseExecution(TCList, envList, countries);
IExecutionCheckService execCheckService = appContext.getBean(IExecutionCheckService.class);
for (TestCaseExecution execution : tceList) {
boolean exception = false;
ExecutionValidator validator = new ExecutionValidator();
try {
execution.setTestObj(testService.convert(testService.readByKey(execution.getTest())));
} catch (CerberusException ex) {
MessageGeneral mes = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_TEST_NOT_FOUND);
mes.setDescription(mes.getDescription().replace("%TEST%", execution.getTest()));
validator.setValid(false);
validator.setMessage(mes.getDescription());
exception = true;
}
try {
execution.setTestCaseObj(testCaseService.findTestCaseByKey(execution.getTest(), execution.getTestCase()));
} catch (CerberusException ex) {
MessageGeneral mes = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_TESTCASE_NOT_FOUND);
mes.setDescription(mes.getDescription().replace("%TEST%", execution.getTest()));
mes.setDescription(mes.getDescription().replace("%TESTCASE%", execution.getTestCase()));
validator.setValid(false);
validator.setMessage(mes.getDescription());
exception = true;
}
try {
execution.setApplicationObj(applicationService.convert(applicationService.readByKey(execution.getTestCaseObj().getApplication())));
} catch (CerberusException ex) {
MessageGeneral mes = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_APPLICATION_NOT_FOUND);
mes.setDescription(mes.getDescription().replace("%APPLI%", execution.getTestCaseObj().getApplication()));
validator.setValid(false);
validator.setMessage(mes.getDescription());
exception = true;
}
execution.setEnvironmentData(execution.getEnvironment());
try {
execution.setCountryEnvParam(cepService.convert(cepService.readByKey(execution.getApplicationObj().getSystem(), execution.getCountry(), execution.getEnvironment())));
} catch (CerberusException ex) {
MessageGeneral mes = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_COUNTRYENV_NOT_FOUND);
mes.setDescription(mes.getDescription().replace("%SYSTEM%", execution.getApplicationObj().getSystem()));
mes.setDescription(mes.getDescription().replace("%COUNTRY%", execution.getCountry()));
mes.setDescription(mes.getDescription().replace("%ENV%", execution.getEnvironmentData()));
validator.setValid(false);
validator.setMessage(mes.getDescription());
exception = true;
}
try {
execution.setEnvironmentDataObj(invariantService.convert(invariantService.readByKey("ENVIRONMENT", execution.getEnvironmentData())));
} catch (CerberusException ex) {
MessageGeneral mes = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_ENVIRONMENT_DOESNOTEXIST);
mes.setDescription(mes.getDescription().replace("%ENV%", execution.getEnvironmentData()));
validator.setValid(false);
validator.setMessage(mes.getDescription());
exception = true;
}
String browser = ParameterParserUtil.parseStringParam(request.getParameter(PARAMETER_BROWSER), DEFAULT_VALUE_BROWSER);
if (!(StringUtil.isNullOrEmpty(browser))) {
// if application is not GUI, we force browser to empty value.
if (execution.getApplicationObj() != null && execution.getApplicationObj().getType() != null && !(execution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI))) {
execution.setBrowser("");
}
} else {
execution.setBrowser(browser);
}
String manualExecution = ParameterParserUtil.parseStringParam(request.getParameter(PARAMETER_MANUAL_EXECUTION), DEFAULT_VALUE_MANUAL_EXECUTION);
execution.setManualExecution(manualExecution);
if (exception == false) {
/**
* Checking the execution as it would be checked in the
* engine
*/
MessageGeneral message = execCheckService.checkTestCaseExecution(execution);
if (!(message.equals(new MessageGeneral(MessageGeneralEnum.EXECUTION_PE_CHECKINGPARAMETERS)))) {
validator.setValid(false);
validator.setMessage(message.getDescription());
} else {
validator.setValid(true);
validator.setMessage("Valid Execution.");
}
}
validator.setExecution(execution);
inQueue.add(validator);
}
JSONArray dataArray = new JSONArray();
for (ExecutionValidator tce : inQueue) {
JSONObject exec = new JSONObject();
exec.put("test", tce.getExecution().getTest());
exec.put("testcase", tce.getExecution().getTestCase());
exec.put("env", tce.getExecution().getEnvironment());
exec.put("country", tce.getExecution().getCountry());
exec.put("appType", tce.getExecution().getApplicationObj().getType());
exec.put("isValid", tce.isValid());
exec.put("message", tce.getMessage());
dataArray.put(exec);
}
jsonResponse.put("contentTable", dataArray);
}
if (push) {
IExecutionThreadPoolService executionThreadService = appContext.getBean(IExecutionThreadPoolService.class);
IParameterService parameterService = appContext.getBean(IParameterService.class);
IFactoryTestCaseExecutionQueue inQueueFactoryService = appContext.getBean(IFactoryTestCaseExecutionQueue.class);
ITestCaseExecutionQueueService inQueueService = appContext.getBean(ITestCaseExecutionQueueService.class);
int addedToQueue = 0;
JSONArray toAddList = new JSONArray(request.getParameter("toAddList"));
JSONArray browsers = new JSONArray(request.getParameter("browsers"));
Date requestDate = new Date();
/**
* RETRIEVING ROBOT SETTINGS *
*/
String robot = ParameterParserUtil.parseStringParam(request.getParameter(PARAMETER_ROBOT), null);
String robotIP = ParameterParserUtil.parseStringParam(request.getParameter(PARAMETER_ROBOT_IP), null);
String robotPort = ParameterParserUtil.parseStringParam(request.getParameter(PARAMETER_ROBOT_PORT), null);
String browserVersion = ParameterParserUtil.parseStringParam(request.getParameter(PARAMETER_BROWSER_VERSION), null);
String platform = ParameterParserUtil.parseStringParam(request.getParameter(PARAMETER_PLATFORM), null);
String screenSize = ParameterParserUtil.parseStringParam(request.getParameter(PARAMETER_SCREENSIZE), null);
/**
* RETRIEVING EXECUTION SETTINGS *
*/
String tag = ParameterParserUtil.parseStringParam(request.getParameter(PARAMETER_TAG), "");
int screenshot = ParameterParserUtil.parseIntegerParam(request.getParameter(PARAMETER_SCREENSHOT), DEFAULT_VALUE_SCREENSHOT);
int verbose = ParameterParserUtil.parseIntegerParam(request.getParameter(PARAMETER_VERBOSE), DEFAULT_VALUE_VERBOSE);
String timeout = request.getParameter(PARAMETER_TIMEOUT);
int pageSource = ParameterParserUtil.parseIntegerParam(request.getParameter(PARAMETER_PAGE_SOURCE), DEFAULT_VALUE_PAGE_SOURCE);
int seleniumLog = ParameterParserUtil.parseIntegerParam(request.getParameter(PARAMETER_SELENIUM_LOG), DEFAULT_VALUE_SELENIUM_LOG);
int retries = ParameterParserUtil.parseIntegerParam(request.getParameter(PARAMETER_RETRIES), DEFAULT_VALUE_RETRIES);
String manualExecution = ParameterParserUtil.parseStringParam(request.getParameter(PARAMETER_MANUAL_EXECUTION), DEFAULT_VALUE_MANUAL_EXECUTION);
/**
* RETRIEVING MANUAL ENVIRONMENT SETTINGS *
*/
String manualHost = ParameterParserUtil.parseStringParam(request.getParameter(PARAMETER_MANUAL_HOST), null);
String manualContextRoot = ParameterParserUtil.parseStringParam(request.getParameter(PARAMETER_MANUAL_CONTEXT_ROOT), null);
String manualLoginRelativeURL = ParameterParserUtil.parseStringParam(request.getParameter(PARAMETER_MANUAL_LOGIN_RELATIVE_URL), null);
String manualEnvData = ParameterParserUtil.parseStringParam(request.getParameter(PARAMETER_MANUAL_ENV_DATA), null);
// Create Tag when exist.
if (!StringUtil.isNullOrEmpty(tag)) {
// We create or update it.
ITagService tagService = appContext.getBean(ITagService.class);
tagService.createAuto(tag, "", request.getRemoteUser());
}
for (int index = 0; index < toAddList.length(); index++) {
JSONObject toAdd = toAddList.getJSONObject(index);
int manualURL = 0;
if (toAdd.getString("env").equals("MANUAL")) {
manualURL = 1;
}
try {
// Create the template
TestCaseExecutionQueue tceiq = inQueueFactoryService.create(toAdd.getString("test"), toAdd.getString("testcase"), toAdd.getString("country"), toAdd.getString("env"), robot, robotIP, robotPort, "", browserVersion, platform, screenSize, manualURL, manualHost, manualContextRoot, manualLoginRelativeURL, manualEnvData, tag, screenshot, verbose, timeout, pageSource, seleniumLog, 0, retries, manualExecution, 1000, request.getRemoteUser(), null, null, null);
// Then fill it with either no browser
if ((browsers.length() == 0) || ((toAdd.getString("appType") != null) && (!toAdd.getString("appType").equalsIgnoreCase(Application.TYPE_GUI)))) {
inQueueService.convert(inQueueService.create(tceiq));
addedToQueue++;
} else // Or with required browsers
{
for (int iterBrowser = 0; iterBrowser < browsers.length(); iterBrowser++) {
tceiq.setBrowser(browsers.getString(iterBrowser));
try {
inQueueService.convert(inQueueService.create(tceiq));
addedToQueue++;
} catch (CerberusException e) {
LOG.warn("Unable to insert execution in queue " + tceiq, e);
}
}
}
} catch (FactoryCreationException e) {
LOG.warn("Unable to create the execution queue template", e);
}
}
// Trigger execution if necessary
if (addedToQueue > 0) {
try {
executionThreadService.executeNextInQueueAsynchroneously(false);
} catch (CerberusException ex) {
String errorMessage = "Unable to feed the execution queue due to " + ex.getMessage();
LOG.warn(errorMessage);
answer.setResultMessage(new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED));
answer.getResultMessage().setDescription(errorMessage);
}
jsonResponse.put("messageType", answer.getResultMessage().getMessage().getCodeString());
jsonResponse.put("message", answer.getResultMessage().getDescription());
jsonResponse.put("addedToQueue", addedToQueue);
jsonResponse.put("redirect", "ReportingExecutionByTag.jsp?Tag=" + StringUtil.encodeAsJavaScriptURIComponent(tag));
}
}
response.setContentType("application/json");
response.getWriter().print(jsonResponse.toString());
}
use of org.cerberus.exception.FactoryCreationException in project cerberus-source by cerberustesting.
the class FactoryTestCaseExecutionQueue method create.
@Override
public TestCaseExecutionQueue create(long id, String test, String testCase, String country, String environment, String robot, String robotIP, String robotPort, String browser, String browserVersion, String platform, String screenSize, int manualURL, String manualHost, String manualContextRoot, String manualLoginRelativeURL, String manualEnvData, String tag, int screenshot, int verbose, String timeout, int pageSource, int seleniumLog, long exeId, Integer retries, String manualExecution, String usrCreated, Timestamp dateCreated, String usrModif, Timestamp dateModif) throws FactoryCreationException {
try {
TestCaseExecutionQueue inQueue = new TestCaseExecutionQueue();
inQueue.setId(id);
inQueue.setTest(test);
inQueue.setTestCase(testCase);
inQueue.setCountry(country);
inQueue.setEnvironment(environment);
inQueue.setRobot(robot);
inQueue.setRobotIP(robotIP);
inQueue.setRobotPort(robotPort);
inQueue.setBrowser(browser);
inQueue.setBrowserVersion(browserVersion);
inQueue.setPlatform(platform);
inQueue.setScreenSize(screenSize);
inQueue.setManualURL(manualURL);
inQueue.setManualHost(manualHost);
inQueue.setManualContextRoot(manualContextRoot);
inQueue.setManualLoginRelativeURL(manualLoginRelativeURL);
inQueue.setManualEnvData(manualEnvData);
inQueue.setTag(tag);
inQueue.setScreenshot(screenshot);
inQueue.setVerbose(verbose);
inQueue.setTimeout(timeout);
inQueue.setPageSource(pageSource);
inQueue.setSeleniumLog(seleniumLog);
inQueue.setUsrCreated(usrCreated);
inQueue.setUsrModif(usrModif);
inQueue.setDateCreated(dateCreated);
inQueue.setDateModif(dateModif);
inQueue.setRetries(retries);
inQueue.setManualExecution(manualExecution);
inQueue.setExeId(exeId);
inQueue.setState(TestCaseExecutionQueue.State.QUEUED);
inQueue.setComment("");
inQueue.setDebugFlag("N");
inQueue.setPriority(TestCaseExecutionQueue.PRIORITY_DEFAULT);
return inQueue;
} catch (IllegalArgumentException iae) {
throw new FactoryCreationException("Unable to create a TestCaseExecutionInQueue instance", iae);
} catch (IllegalStateException ise) {
throw new FactoryCreationException("Unable to create a TestCaseExecutionInQueue instance", ise);
}
}
Aggregations