From 628c272f2528d7796eee47d04b59257a9bedc03d Mon Sep 17 00:00:00 2001 From: MathisSenicourt Date: Fri, 29 Dec 2023 15:16:27 +0100 Subject: [PATCH 1/2] sikuli's screen now go in parameter file before beeing placed into the exectuion's file --- .../execution/impl/RecorderService.java | 14 +++++------ .../robotextension/impl/SikuliService.java | 25 +++++++++++-------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/source/src/main/java/org/cerberus/core/engine/execution/impl/RecorderService.java b/source/src/main/java/org/cerberus/core/engine/execution/impl/RecorderService.java index 88906eb7f9..46be969a89 100644 --- a/source/src/main/java/org/cerberus/core/engine/execution/impl/RecorderService.java +++ b/source/src/main/java/org/cerberus/core/engine/execution/impl/RecorderService.java @@ -1,19 +1,19 @@ /** * Cerberus Copyright (C) 2013 - 2017 cerberustesting * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + *

* This file is part of Cerberus. - * + *

* Cerberus is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + *

* Cerberus is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + *

* You should have received a copy of the GNU General Public License * along with Cerberus. If not, see . */ @@ -384,8 +384,8 @@ public List recordScreenshot(TestCaseExecution execution, fileDesc = "Desktop Screenshot Too Big !!"; } else { // Copies the temp file to the execution file - FileUtils.copyFile(newImageDesktop, new File(recorderDestop.getFullFilename())); - LOG.debug("{}Copy file finished with success - source: {} destination: {}", logPrefix, newImageDesktop.getName(), recorderDestop.getRelativeFilenameURL()); + FileUtils.moveFile(newImageDesktop, new File(recorderDestop.getFullFilename())); + LOG.debug("{}Moving file finished with success - source: {} destination: {}", logPrefix, newImageDesktop.getName(), recorderDestop.getRelativeFilenameURL()); LOG.info("File saved : {}", recorderDestop.getFullFilename()); } @@ -395,8 +395,6 @@ public List recordScreenshot(TestCaseExecution execution, testCaseExecutionFileService.save(object); //deletes the temporary file - FileUtils.forceDelete(newImageDesktop); - LOG.debug("{}Temp file deleted with success {}", logPrefix, newImageDesktop.getName()); LOG.debug("{}Desktop Screenshot done in : {}", logPrefix, recorderDestop.getRelativeFilenameURL()); } } catch (IOException | CerberusException ex) { diff --git a/source/src/main/java/org/cerberus/core/service/robotextension/impl/SikuliService.java b/source/src/main/java/org/cerberus/core/service/robotextension/impl/SikuliService.java index bb27d61ba0..1fef92cce3 100644 --- a/source/src/main/java/org/cerberus/core/service/robotextension/impl/SikuliService.java +++ b/source/src/main/java/org/cerberus/core/service/robotextension/impl/SikuliService.java @@ -1,19 +1,19 @@ /** * Cerberus Copyright (C) 2013 - 2017 cerberustesting * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + *

* This file is part of Cerberus. - * + *

* Cerberus is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + *

* Cerberus is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + *

* You should have received a copy of the GNU General Public License * along with Cerberus. If not, see . */ @@ -34,6 +34,7 @@ import java.net.URL; import java.net.URLConnection; import java.util.UUID; + import org.apache.commons.codec.binary.Base64; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; @@ -42,7 +43,9 @@ import org.apache.tika.mime.MimeType; import org.apache.tika.mime.MimeTypeException; import org.apache.tika.mime.MimeTypes; +import org.cerberus.core.crud.entity.Parameter; import org.cerberus.core.crud.service.IParameterService; +import org.cerberus.core.crud.service.impl.ParameterService; import org.cerberus.core.engine.entity.Identifier; import org.cerberus.core.engine.entity.MessageEvent; import org.cerberus.core.engine.entity.Session; @@ -56,7 +59,6 @@ import org.springframework.stereotype.Service; /** - * * @author bcivel */ @Service @@ -96,7 +98,7 @@ public class SikuliService implements ISikuliService { public static final String SIKULI_IDENTIFIER_TEXT = "text"; private JSONObject generatePostParameters(String action, String locator, String locator2, String text, String text2, - long defaultWait, String minSimilarity, Integer highlightElement, String typeDelay) throws JSONException, IOException, MalformedURLException, MimeTypeException { + long defaultWait, String minSimilarity, Integer highlightElement, String typeDelay) throws JSONException, IOException, MalformedURLException, MimeTypeException { JSONObject result = new JSONObject(); String picture = ""; String extension = ""; @@ -296,12 +298,12 @@ public boolean isSikuliServerReachableOnNode(Session session) { } if (connection == null || connection.getResponseCode() != 200) { - LOG.warn("Responce code different from 200 when calling '"+urlToConnect+"'"); + LOG.warn("Responce code different from 200 when calling '" + urlToConnect + "'"); return false; } } catch (IOException ex) { - LOG.warn("Exception catch when calling '"+urlToConnect+"' "+ex,ex); + LOG.warn("Exception catch when calling '" + urlToConnect + "' " + ex, ex); return false; } finally { if (os != null) { @@ -827,7 +829,8 @@ public File takeScreenShotFile(Session session) { String screenshotInBase64 = actionResult.getItem().getString("screenshot"); byte[] data = Base64.decodeBase64(screenshotInBase64); - image = new File("screenshotsikuli" + UUID.randomUUID().toString().subSequence(0, 14) + ".png"); + image = new File(parameterService.getParameterStringByKey(Parameter.VALUE_cerberus_exeautomedia_path, "", File.separator + "tmp") + File.separator + "tmp" + File.separator + + "screenshotsikuli-" + UUID.randomUUID().toString().subSequence(0, 13) + ".png"); FileUtils.writeByteArrayToFile(image, data); if (image != null) { @@ -838,9 +841,9 @@ public File takeScreenShotFile(Session session) { } } catch (JSONException ex) { - LOG.warn(ex); + LOG.warn(ex, ex); } catch (IOException ex) { - LOG.warn(ex); + LOG.warn(ex, ex); } return image; } From bc465ea2f6ecdac7710a074ad6632a1bc2b51c69 Mon Sep 17 00:00:00 2001 From: MathisSenicourt Date: Fri, 29 Dec 2023 15:24:56 +0100 Subject: [PATCH 2/2] remove

from header --- .../core/engine/execution/impl/RecorderService.java | 8 ++++---- .../core/service/robotextension/impl/SikuliService.java | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/source/src/main/java/org/cerberus/core/engine/execution/impl/RecorderService.java b/source/src/main/java/org/cerberus/core/engine/execution/impl/RecorderService.java index 46be969a89..70d7c6fd24 100644 --- a/source/src/main/java/org/cerberus/core/engine/execution/impl/RecorderService.java +++ b/source/src/main/java/org/cerberus/core/engine/execution/impl/RecorderService.java @@ -1,19 +1,19 @@ /** * Cerberus Copyright (C) 2013 - 2017 cerberustesting * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - *

+ * * This file is part of Cerberus. - *

+ * * Cerberus is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - *

+ * * Cerberus is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - *

+ * * You should have received a copy of the GNU General Public License * along with Cerberus. If not, see . */ diff --git a/source/src/main/java/org/cerberus/core/service/robotextension/impl/SikuliService.java b/source/src/main/java/org/cerberus/core/service/robotextension/impl/SikuliService.java index 1fef92cce3..7eacf2443a 100644 --- a/source/src/main/java/org/cerberus/core/service/robotextension/impl/SikuliService.java +++ b/source/src/main/java/org/cerberus/core/service/robotextension/impl/SikuliService.java @@ -1,19 +1,19 @@ /** * Cerberus Copyright (C) 2013 - 2017 cerberustesting * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - *

+ * * This file is part of Cerberus. - *

+ * * Cerberus is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - *

+ * * Cerberus is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - *

+ * * You should have received a copy of the GNU General Public License * along with Cerberus. If not, see . */