Skip to content

Commit

Permalink
Merge origin/master
Browse files Browse the repository at this point in the history
  • Loading branch information
vertigo17 committed Dec 29, 2023
2 parents c03e267 + bc465ea commit 6a08e62
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
*/
Expand Down Expand Up @@ -384,8 +384,8 @@ public List<TestCaseExecutionFile> 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());
}

Expand All @@ -395,8 +395,6 @@ public List<TestCaseExecutionFile> 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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
*/
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -56,7 +59,6 @@
import org.springframework.stereotype.Service;

/**
*
* @author bcivel
*/
@Service
Expand Down Expand Up @@ -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 = "";
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand All @@ -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;
}
Expand Down

0 comments on commit 6a08e62

Please sign in to comment.