summaryrefslogtreecommitdiffstats
path: root/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup
diff options
context:
space:
mode:
Diffstat (limited to 'ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup')
-rw-r--r--ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/ArtifactsCorrelationManager.java72
-rw-r--r--ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/AttFtpClient.java211
-rw-r--r--ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/DriverFactory.java132
-rw-r--r--ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/ExtentManager.java166
-rw-r--r--ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/ExtentTestActions.java127
-rw-r--r--ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/ExtentTestManager.java70
-rw-r--r--ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/MobProxy.java132
-rw-r--r--ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/OnboardCSVReport.java63
-rw-r--r--ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/ReportAfterTestManager.java124
-rw-r--r--ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/Retry.java40
-rw-r--r--ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/SetupCDTest.java527
-rw-r--r--ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/TestFtp.java92
-rw-r--r--ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/WebDriverThread.java160
-rw-r--r--ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/WindowTest.java86
-rw-r--r--ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/WindowTestManager.java50
15 files changed, 0 insertions, 2052 deletions
diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/ArtifactsCorrelationManager.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/ArtifactsCorrelationManager.java
deleted file mode 100644
index ce46d5b833..0000000000
--- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/ArtifactsCorrelationManager.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.ci.tests.execute.setup;
-
-import org.openecomp.sdc.ci.tests.datatypes.HeatMetaFirstLevelDefinition;
-
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.Map.Entry;
-import java.util.Set;
-
-public class ArtifactsCorrelationManager {
-
- private static HashMap<String, LinkedList<HeatMetaFirstLevelDefinition>> vNFArtifactsCorrelationMap = new HashMap<String, LinkedList<HeatMetaFirstLevelDefinition>>();
- private static HashMap<String, Entry<String, LinkedList<HeatMetaFirstLevelDefinition>>> serviceVNFCorrelationMap = new HashMap<String, Entry<String, LinkedList<HeatMetaFirstLevelDefinition>>>();
-
- public static void addVNFartifactDetails(String vspName,
- LinkedList<HeatMetaFirstLevelDefinition> deploymentArtifacts) {
-
- vNFArtifactsCorrelationMap.put(vspName, deploymentArtifacts);
-
-
- }
-
- public static Entry<String, LinkedList<HeatMetaFirstLevelDefinition>> getVNFartifactDetails(String vnfName) {
-
-
- Set<Entry<String, LinkedList<HeatMetaFirstLevelDefinition>>> entrySet = vNFArtifactsCorrelationMap.entrySet();
- for (Entry<String, LinkedList<HeatMetaFirstLevelDefinition>> entry : entrySet) {
- String key = entry.getKey();
- if (key.equals(vnfName)) {
- return entry;
- }
-
- }
- return null;
-
- }
-
-
- public static void addVNFtoServiceArtifactCorrelation(String service, String vnfName) {
-
- serviceVNFCorrelationMap.put(service, getVNFartifactDetails(vnfName));
-
- }
-
- public static Set<Entry<String, Entry<String, LinkedList<HeatMetaFirstLevelDefinition>>>> getServiceArtifactCorrelationMap(String service) {
-
- return serviceVNFCorrelationMap.entrySet();
-
- }
-
-}
-
diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/AttFtpClient.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/AttFtpClient.java
deleted file mode 100644
index 37e8855800..0000000000
--- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/AttFtpClient.java
+++ /dev/null
@@ -1,211 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.ci.tests.execute.setup;
-
-import org.apache.commons.net.ftp.FTPClient;
-import org.apache.commons.net.ftp.FTPFile;
-import org.apache.commons.net.ftp.FTPReply;
-
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Date;
-import java.util.List;
-import java.util.stream.Collectors;
-
-public class AttFtpClient {
-
- private static final AttFtpClient FTP_CLIENT = new AttFtpClient();
-
- public static AttFtpClient getFtpClient() {
- return FTP_CLIENT;
- }
-
- private FTPClient apacheFtpClient;
-
- private AttFtpClient() {
- apacheFtpClient = new FTPClient();
- }
-
-
- public void init(String server, int port, String user, String pass) {
-
- try {
- apacheFtpClient.connect(server, port);
- showServerReply(apacheFtpClient);
-
-
- int replyCode = apacheFtpClient.getReplyCode();
- if (!FTPReply.isPositiveCompletion(replyCode)) {
- System.out.println("Connect failed");
- return;
- }
-
- boolean success = apacheFtpClient.login(user, pass);
- showServerReply(apacheFtpClient);
-
- if (!success) {
- System.out.println("Could not login to the server");
- return;
- }
- } catch (IOException ex) {
- System.out.println("Oops! Something wrong happened");
- ex.printStackTrace();
- }
- }
-
- public File retrieveLastModifiedFileFromFTP() throws IOException {
- FTPFile[] files1 = retrieveListOfFile();
-
- // sort list by TimeStamp
- List<FTPFile> sorted = Arrays.asList(files1).stream()
- .sorted(Comparator.comparing(FTPFile::getTimestamp)).collect(Collectors.toList());
- printFileDetailsList(sorted);
-
- // retrieve file from FTP
- FTPFile ftpFile = sorted.get(sorted.size() - 1);
-
- return retrieveFileFromFTP(ftpFile);
-
- }
-
- public FTPFile[] retrieveListOfFile() throws IOException {
- // Lists files and directories
- FTPFile[] files = apacheFtpClient.listFiles("");
-
- printNames(files);
- return files;
- }
-
- public File retrieveFileFromFTP(FTPFile ftpFile) throws IOException {
-
- File downloadFile1 = new File("tmp");
- OutputStream outputStream1 = new BufferedOutputStream(new FileOutputStream(downloadFile1));
- boolean success = apacheFtpClient.retrieveFile(ftpFile.getName(), outputStream1);
- outputStream1.close();
-
- if (success) {
- System.out.println("File #1 has been downloaded successfully.");
- }
-
-
- return downloadFile1;
-
- }
-
- public void deleteFilesFromFTPserver() throws IOException {
- FTPFile[] files = retrieveListOfFile();
- deleteFiles(files);
- }
-
- public void terminateClient() throws IOException {
-
- String status = apacheFtpClient.getStatus();
-
- // logs out and disconnects from server
- try {
- if (apacheFtpClient.isConnected()) {
- apacheFtpClient.logout();
- apacheFtpClient.disconnect();
- }
- } catch (IOException ex) {
- ex.printStackTrace();
- }
- }
-
- private void printFileDetailsList(List<FTPFile> list) {
- DateFormat dateFormater = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-
- for (FTPFile ftpFile : list) {
-
- String details = ftpFile.getName();
- if (ftpFile.isDirectory()) {
- details = "[" + details + "]";
- }
- details += "\t\t" + ftpFile.getSize();
- details += "\t\t" + dateFormater.format(ftpFile.getTimestamp().getTime());
-
- System.out.println(details);
- }
- }
-
- private void printNames(FTPFile[] files) {
- if (files != null && files.length > 0) {
- for (FTPFile aFile : files) {
- System.out.println(aFile);
- }
- }
- }
-
- private void showServerReply(FTPClient ftpClient) {
- String[] replies = ftpClient.getReplyStrings();
- if (replies != null && replies.length > 0) {
- for (String aReply : replies) {
- System.out.println("SERVER: " + aReply);
- }
- }
- }
-
- public class LastModifiedComparator implements Comparator<FTPFile> {
-
- public int compare(FTPFile f1, FTPFile f2) {
- return f1.getTimestamp().compareTo(f2.getTimestamp());
- }
- }
-
- public FTPFile getMaxLastModified(FTPFile[] ftpFiles) {
- return Collections.max(Arrays.asList(ftpFiles), new LastModifiedComparator());
- }
-
- public static void displayFiles(File[] files) {
- for (File file : files) {
- System.out.printf("File: %-20s Last Modified:" + new Date(file.lastModified()) + "\n", file.getName());
- }
- }
-
- public void deleteFiles(FTPFile[] files) {
-
- for (FTPFile file : files) {
-
- boolean deleted = false;
- try {
- deleted = apacheFtpClient.deleteFile(file.getName());
- } catch (IOException e) {
- e.printStackTrace();
- }
-
- if (deleted) {
- System.out.println("The file was deleted successfully.");
- } else {
- System.out.println("Could not delete theĀ  file, it may not exist.");
- }
- }
-
- }
-
-}
diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/DriverFactory.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/DriverFactory.java
deleted file mode 100644
index 8cfe5bdba0..0000000000
--- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/DriverFactory.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.ci.tests.execute.setup;
-
-
-import org.apache.commons.io.FileUtils;
-import org.openecomp.sdc.ci.tests.config.Config;
-import org.openecomp.sdc.ci.tests.utilities.FileHandling;
-import org.openecomp.sdc.ci.tests.utils.Utils;
-import org.openqa.selenium.WebDriver;
-import org.openqa.selenium.firefox.FirefoxProfile;
-import org.testng.annotations.AfterSuite;
-import org.testng.annotations.BeforeSuite;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FilenameFilter;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-
-
-public class DriverFactory {
-
- private static ThreadLocal<WebDriverThread> driverThread;
- private static List<WebDriverThread> webDriverThreadPool = Collections.synchronizedList(new ArrayList<WebDriverThread>());
- private static Config config;
-
- public DriverFactory() {
- try {
- config = Utils.getConfig();
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- }
- }
-
- @BeforeSuite(alwaysRun = true)
- public static void instantiateDriverObject() {
-
- // Selenium 3.4.0 change, location of gecko driver, set system property
-// System.setProperty("webdriver.gecko.driver","C:\\Gekko18\\geckodriver-v0.18.0-win64\\geckodriver.exe"); //change for 3.4.0, gecko driver location
- // End of Selenium 3.4.0 change
-
- File basePath = new File(FileHandling.getBasePath());
- File[] listFiles = basePath.listFiles(new FilenameFilter() {
-
- @Override
- public boolean accept(File basePath, String name) {
- return name.startsWith(WebDriverThread.AUTOMATION_DOWNLOAD_DIR);
- }
- });
- Arrays.asList(listFiles).forEach(e -> FileHandling.deleteDirectory(e.getAbsolutePath()));
-
-
- driverThread = new ThreadLocal<WebDriverThread>() {
- @Override
- protected WebDriverThread initialValue() {
- WebDriverThread webDriverThread = new WebDriverThread(config);
- webDriverThreadPool.add(webDriverThread);
- return webDriverThread;
- }
- };
- }
-
- public static WebDriver getDriver() {
- return driverThread.get().getDriver();
- }
-
- public static FirefoxProfile getDriverFirefoxProfile() throws Exception {
- return driverThread.get().getFirefoxProfile();
- }
-
- @AfterSuite(alwaysRun = true)
- public static void quitDriverAfterSuite() throws Exception {
- for (WebDriverThread webDriverThread : webDriverThreadPool) {
- if (webDriverThread.getDriver() != null) {
- webDriverThread.quitDriver();
- }
- }
-
- MobProxy.removeAllProxyServers();
-
- deleteDownloadDirs();
- }
-
- private static void deleteDownloadDirs() throws IOException {
- //System.gc();
- HashMap<Long, WindowTest> windowMap = WindowTestManager.getWholeMap();
- for (WindowTest win : windowMap.values()) {
- String downloadDirectory = win.getDownloadDirectory();
- FileUtils.deleteDirectory(new File(downloadDirectory));
- }
- }
-
- public static void quitDriver() throws Exception {
- driverThread.get().quitDriver();
- driverThread.remove();
- WindowTestManager.removeWindowTest();
- MobProxy.removePoxyServer();
- }
-
- public static Config getConfig() {
- return config;
- }
-
- public static void setConfig(Config config) {
- DriverFactory.config = config;
- }
-
-
-}
diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/ExtentManager.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/ExtentManager.java
deleted file mode 100644
index 6bd2e4b870..0000000000
--- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/ExtentManager.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.ci.tests.execute.setup;
-
-import com.aventstack.extentreports.ExtentReports;
-import com.aventstack.extentreports.reporter.ExtentHtmlReporter;
-import com.aventstack.extentreports.reporter.ExtentXReporter;
-import com.aventstack.extentreports.reporter.configuration.Protocol;
-import com.aventstack.extentreports.reporter.configuration.Theme;
-import org.openecomp.sdc.ci.tests.config.Config;
-import org.openecomp.sdc.ci.tests.utilities.FileHandling;
-import org.openecomp.sdc.ci.tests.utilities.RestCDUtils;
-import org.openecomp.sdc.ci.tests.utils.Utils;
-import org.openecomp.sdc.ci.tests.utils.rest.AutomationUtils;
-import org.testng.ITestContext;
-
-import java.io.File;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.GregorianCalendar;
-
-public class ExtentManager {
-
- private static final String VERSIONS_INFO_FILE_NAME = "versions.info";
- private static ExtentReports extent;
- private static ExtentHtmlReporter htmlReporter;
- private static ExtentXReporter extentxReporter;
-
- public enum suiteNameXml {
-
- TESTNG_FAILED_XML_NAME("testng-failed.xml");
-
- suiteNameXml(String value) {
- this.value = value;
- }
-
- private String value;
-
- public String getValue() {
- return value;
- }
-
- }
-
- private static synchronized ExtentReports setReporter(String filePath, String htmlFile, Boolean isAppend) throws Exception {
- String dbIp = DriverFactory.getConfig().getReportDBhost();
- int dbPort = DriverFactory.getConfig().getReportDBport();
-
- if (extent == null) {
- extentxReporter = new ExtentXReporter(dbIp, dbPort);
- extent = new ExtentReports();
- initAndSetExtentHtmlReporter(filePath, htmlFile, isAppend);
- if (extentxReporter.config().getReportObjectId() != null) {
- setExtentXReporter(isAppend);
- } else {
- extentxReporter.stop();
- }
- }
- return extent;
- }
-
- private static synchronized void setExtentXReporter(Boolean isAppend) {
- extentxReporter.setAppendExisting(isAppend);
- extent.attachReporter(extentxReporter);
- }
-
- private static synchronized void initAndSetExtentHtmlReporter(String filePath, String htmlFile, Boolean isAppend) throws Exception {
- htmlReporter = new ExtentHtmlReporter(filePath + htmlFile);
- setConfiguration(htmlReporter);
- htmlReporter.setAppendExisting(isAppend);
- extent.attachReporter(htmlReporter);
- }
-
- static synchronized ExtentReports getReporter() {
- return extent;
- }
-
- static void initReporter(String filepath, String htmlFile, ITestContext context) throws Exception {
-
- String onboardVersion = AutomationUtils.getOnboardVersion();
- String osVersion = AutomationUtils.getOSVersion();
- Config config = Utils.getConfig();
- String envData = config.getUrl();
- String suiteName = getSuiteName(context);
- String reportStartDate = null;
- if (suiteName.equals(suiteNameXml.TESTNG_FAILED_XML_NAME.getValue())) {
- if (config.getUseBrowserMobProxy()) {
- setTrafficCaptue(config);
- }
- setReporter(filepath, htmlFile, true);
- String suiteNameFromVersionInfoFile = FileHandling.getKeyByValueFromPropertyFormatFile(filepath + VERSIONS_INFO_FILE_NAME, "suiteName");
- reporterDataDefinition(onboardVersion, osVersion, envData, suiteNameFromVersionInfoFile);
- } else {
- FileHandling.deleteDirectory(SetupCDTest.getReportFolder());
- FileHandling.createDirectory(filepath);
- setReporter(filepath, htmlFile, false);
- Calendar calendar = new GregorianCalendar();
- SimpleDateFormat formatter = new SimpleDateFormat("MMM dd, yyyy hh:mm:ss a");
- reportStartDate = formatter.format(calendar.getTime());
- reporterDataDefinition(onboardVersion, osVersion, envData, suiteName);
- AutomationUtils.createVersionsInfoFile(filepath + VERSIONS_INFO_FILE_NAME, onboardVersion, osVersion, envData, suiteName, reportStartDate);
- }
-
- }
-
- private static void reporterDataDefinition(String onboardVersion, String osVersion, String envData, String suiteNameFromVersionInfoFile) throws Exception {
- extent.setSystemInfo("Onboard Version", onboardVersion);
- extent.setSystemInfo("OS Version", osVersion);
- extent.setSystemInfo("Host Name Address", RestCDUtils.getExecutionHostAddress());
- extent.setSystemInfo("ExecutedOn", envData);
- extent.setSystemInfo("SuiteName", suiteNameFromVersionInfoFile);
- }
-
- static String getSuiteName(ITestContext context) {
- String suitePath = context.getSuite().getXmlSuite().getFileName();
- if (suitePath != null) {
- File file = new File(suitePath);
- String suiteName = file.getName();
- return suiteName;
- }
- return null;
- }
-
- private static synchronized ExtentHtmlReporter setConfiguration(ExtentHtmlReporter htmlReporter) throws Exception {
-
- htmlReporter.config().setTheme(Theme.STANDARD);
- htmlReporter.config().setEncoding("UTF-8");
- htmlReporter.config().setProtocol(Protocol.HTTPS);
- htmlReporter.config().setDocumentTitle("SDC Automation Report");
- htmlReporter.config().setChartVisibilityOnOpen(true);
- htmlReporter.config().setReportName("SDC Automation Report");
- htmlReporter.config().setChartVisibilityOnOpen(false);
- htmlReporter.setStartTime(null);
- return htmlReporter;
- }
-
- public static void closeReporter() {
- extent.flush();
- }
-
- private static void setTrafficCaptue(Config config) {
- boolean mobProxyStatus = config.getUseBrowserMobProxy();
- if (mobProxyStatus) {
- config.setCaptureTraffic(true);
- }
- }
-}
-
diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/ExtentTestActions.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/ExtentTestActions.java
deleted file mode 100644
index d05d3c5498..0000000000
--- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/ExtentTestActions.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.ci.tests.execute.setup;
-
-import com.aventstack.extentreports.ExtentTest;
-import com.aventstack.extentreports.MediaEntityBuilder;
-import com.aventstack.extentreports.Status;
-import com.aventstack.extentreports.markuputils.ExtentColor;
-import com.aventstack.extentreports.markuputils.Markup;
-import com.aventstack.extentreports.markuputils.MarkupHelper;
-import org.openecomp.sdc.ci.tests.api.SomeInterface;
-import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Optional;
-import java.util.UUID;
-
-public final class ExtentTestActions {
-
- private static final SomeInterface testManager = ExtentTestManager.getInstance();
- private static final Logger LOGGER = LoggerFactory.getLogger(ExtentTestActions.class);
-
- private ExtentTestActions() {
-
- }
-
- public static void log(Status logStatus, Markup mark) {
- ExtentTest test = testManager.getTest();
- test.log(logStatus, mark);
- }
-
- public static void log(Status logStatus, String message) {
- ExtentTest test = testManager.getTest();
- test.log(logStatus, message);
- }
-
- public static void log(Status logStatus, String message, String duration) {
- log(logStatus, message + addDurationTag(duration));
- }
-
- public static void log(Status logStatus, Throwable throwabel) {
- ExtentTest test = testManager.getTest();
- test.log(logStatus, throwabel);
- }
-
- static void addTag(Status logStatus, String message) {
- Markup m = null;
- switch (logStatus) {
- case PASS:
- m = MarkupHelper.createLabel(message, ExtentColor.GREEN);
- break;
- case FAIL:
- m = MarkupHelper.createLabel(message, ExtentColor.RED);
- break;
- case SKIP:
- m = MarkupHelper.createLabel(message, ExtentColor.BLUE);
- break;
- case FATAL:
- m = MarkupHelper.createLabel(message, ExtentColor.BROWN);
- break;
- default:
- break;
- }
-
- if (m != null) {
- log(logStatus, m);
- }
- }
-
- public static Optional<String> takeScreenshot(final Status logStatus, final String screenshotName,
- final String message) {
- try {
- return Optional.of(addScreenshot(logStatus, screenshotName, message));
- } catch (final IOException e) {
- LOGGER.warn("Could not take screenshot", e);
- }
-
- return Optional.empty();
- }
-
- public static String addScreenshot(final Status logStatus, String screenshotName,
- final String message) throws IOException {
- final String[] splitUuid = UUID.randomUUID().toString().split("-");
- screenshotName = screenshotName + "-" + splitUuid[splitUuid.length - 1];
- final File imageFile = GeneralUIUtils.takeScreenshot(screenshotName, SetupCDTest.getScreenshotFolder());
- final String imageFilePath = new File(SetupCDTest.getReportFolder()).toURI().relativize(imageFile.toURI())
- .getPath();
- testManager.getTest()
- .log(logStatus, message, MediaEntityBuilder.createScreenCaptureFromPath(imageFilePath).build());
- return imageFilePath;
- }
-
- private static String addDurationTag(String duration) {
- return "<td width=\"80px\">" + duration + "</td>";
- }
-
- private static String addLinkTag(String fileName, String pathToFile) {
- return String.format("<a download=\"%s\" href=\"%s\">HAR file</a>", fileName, pathToFile);
- }
-
- static void addFileToReportAsLink(File harFile, String pathToFileFromReportDirectory, String message) {
- log(Status.INFO, message, addLinkTag(harFile.getName(), pathToFileFromReportDirectory));
- }
-
-
-}
diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/ExtentTestManager.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/ExtentTestManager.java
deleted file mode 100644
index 669cbe17ef..0000000000
--- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/ExtentTestManager.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.ci.tests.execute.setup;
-
-import com.aventstack.extentreports.ExtentReports;
-import com.aventstack.extentreports.ExtentTest;
-import org.openecomp.sdc.ci.tests.api.SomeInterface;
-
-import java.util.HashMap;
-
-public class ExtentTestManager implements SomeInterface {
-
- private final HashMap<Long, ExtentTest> extentTestByThreadIdMap = new HashMap<>();
- private final ExtentReports extent = ExtentManager.getReporter();
- private static final ExtentTestManager INSTANCE = new ExtentTestManager();
-
- private ExtentTestManager() {
-
- }
-
- public static ExtentTestManager getInstance() {
- return INSTANCE;
- }
-
- @Override
- public synchronized ExtentTest getTest() {
- return extentTestByThreadIdMap.get(Thread.currentThread().getId());
- }
-
- public synchronized void endTest() {
- extent.flush();
- }
-
- public synchronized ExtentTest startTest(final String testName) {
- return startTest(testName, "");
- }
-
- public synchronized ExtentTest startTest(final String testName, final String desc) {
- final ExtentTest test = extent.createTest(testName, desc);
- extentTestByThreadIdMap.put(Thread.currentThread().getId(), test);
-
- return test;
- }
-
- public synchronized <T> void assignCategory(Class<T> clazz) {
- String[] parts = clazz.getName().split("\\.");
- String lastOne1 = parts[parts.length - 1];
- String lastOne2 = parts[parts.length - 2];
- extentTestByThreadIdMap.get(Thread.currentThread().getId()).assignCategory(lastOne2 + "-" + lastOne1);
- }
-}
-
diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/MobProxy.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/MobProxy.java
deleted file mode 100644
index 70a1dd6f81..0000000000
--- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/MobProxy.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.ci.tests.execute.setup;
-
-import ch.qos.logback.classic.Level;
-import ch.qos.logback.classic.Logger;
-import ch.qos.logback.classic.LoggerContext;
-import com.github.markusbernhardt.proxy.ProxySearch;
-import com.github.markusbernhardt.proxy.ProxySearch.Strategy;
-import com.github.markusbernhardt.proxy.util.PlatformUtil;
-import com.github.markusbernhardt.proxy.util.PlatformUtil.Platform;
-import net.lightbody.bmp.BrowserMobProxyServer;
-import org.apache.http.HttpStatus;
-import org.slf4j.LoggerFactory;
-
-import java.net.InetSocketAddress;
-import java.net.Proxy;
-import java.net.ProxySelector;
-import java.net.SocketAddress;
-import java.net.URI;
-import java.util.HashMap;
-import java.util.List;
-
-public class MobProxy {
-
- private static HashMap<Long, BrowserMobProxyServer> mobProxyServerMap = new HashMap<Long, BrowserMobProxyServer>();
- private static InetSocketAddress localProxyAddress = getProxy();
-
- public static InetSocketAddress getProxy() {
- setLogger();
-
- ProxySearch proxySearch = new ProxySearch();
- if (PlatformUtil.getCurrentPlattform() == Platform.WIN) {
- proxySearch.addStrategy(Strategy.IE);
- proxySearch.addStrategy(Strategy.FIREFOX);
- proxySearch.addStrategy(Strategy.JAVA);
- } else if (PlatformUtil.getCurrentPlattform() == Platform.LINUX) {
- proxySearch.addStrategy(Strategy.GNOME);
- proxySearch.addStrategy(Strategy.KDE);
- proxySearch.addStrategy(Strategy.FIREFOX);
- proxySearch.addStrategy(Strategy.ENV_VAR);
- return null;
- } else {
- proxySearch.addStrategy(Strategy.OS_DEFAULT);
- }
- ProxySelector proxySelector = proxySearch.getProxySelector();
-
- ProxySelector.setDefault(proxySelector);
- URI home = URI.create("http://www.google.com");
- System.out.println("ProxySelector: " + proxySelector);
- System.out.println("URI: " + home);
- List<Proxy> proxyList = proxySelector.select(home);
- String host = null;
- String port = null;
- if (proxyList != null && !proxyList.isEmpty()) {
- for (Proxy proxy : proxyList) {
- System.out.println(proxy);
- SocketAddress address = proxy.address();
- if (address instanceof InetSocketAddress) {
- host = ((InetSocketAddress) address).getHostName();
- port = Integer.toString(((InetSocketAddress) address).getPort());
- System.setProperty("http.proxyHost", host);
- System.setProperty("http.proxyPort", port);
- }
- }
- }
- InetSocketAddress address = new InetSocketAddress(host, Integer.parseInt(port));
- return address;
- }
-
- // set logger for all classes connected to MobProxy
- public static void setLogger() {
- LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
- for (Logger logger : lc.getLoggerList()) {
- logger.setLevel(Level.INFO);
- }
- }
-
- public static synchronized void setProxyServer() {
- BrowserMobProxyServer server = new BrowserMobProxyServer();
- server.setTrustAllServers(true);
- if (localProxyAddress != null) {
- server.setChainedProxy(localProxyAddress);
- server.start();
- } else {
- server.start();
- // filter firefox requests to mozilla when system proxy is absent
- server.blacklistRequests(".*mozilla.*", HttpStatus.SC_OK);
- }
- addProxyServerToPull(Thread.currentThread().getId(), server);
- }
-
- public static synchronized BrowserMobProxyServer getPoxyServer() {
- return mobProxyServerMap.get(Thread.currentThread().getId());
- }
-
- public static void addProxyServerToPull(Long threadId, BrowserMobProxyServer server) {
- mobProxyServerMap.put(threadId, server);
- }
-
- public static synchronized void removePoxyServer() {
- if (getPoxyServer() != null) {
- getPoxyServer().stop();
- mobProxyServerMap.remove(Thread.currentThread().getId());
- }
- }
-
- public static void removeAllProxyServers() {
- for (Long threadNumber : mobProxyServerMap.keySet()) {
- mobProxyServerMap.get(threadNumber).stop();
- }
- }
-
-}
diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/OnboardCSVReport.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/OnboardCSVReport.java
deleted file mode 100644
index c748a6bccf..0000000000
--- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/OnboardCSVReport.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.ci.tests.execute.setup;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.PrintWriter;
-
-public class OnboardCSVReport {
-
- private StringBuilder sb;
- private PrintWriter pw;
-
- public OnboardCSVReport(String filepath, String filename) {
- sb = new StringBuilder();
- try {
- File csvFile = new File(filepath + filename);
- pw = new PrintWriter(csvFile);
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- }
-
- }
-
- public StringBuilder appendStringToFile(String content) {
- return sb.append(content + ",");
- }
-
- public void openNewRow() {
- sb.append("\n");
- }
-
- public void writeRow(String... content) {
- for (String str : content) {
- appendStringToFile(str);
- }
- openNewRow();
- }
-
- public void closeFile() {
- pw.write(sb.toString());
- pw.close();
- }
-
-}
diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/ReportAfterTestManager.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/ReportAfterTestManager.java
deleted file mode 100644
index e35ba05004..0000000000
--- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/ReportAfterTestManager.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.ci.tests.execute.setup;
-
-import com.aventstack.extentreports.Status;
-import org.apache.commons.lang3.StringUtils;
-import org.openecomp.sdc.ci.tests.execute.setup.ExtentManager.suiteNameXml;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.ITestContext;
-import org.testng.ITestResult;
-
-import java.io.IOException;
-
-import static org.openecomp.sdc.ci.tests.execute.setup.ExtentTestActions.addScreenshot;
-import static org.openecomp.sdc.ci.tests.execute.setup.ExtentTestActions.addTag;
-import static org.openecomp.sdc.ci.tests.execute.setup.ExtentTestActions.log;
-
-public class ReportAfterTestManager {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(ReportAfterTestManager.class);
- private static String testName;
- private static Throwable throwable;
- private static String exceptionMsgFormat = "%s - The following exception occurred:";
-
- private ReportAfterTestManager() {
-
- }
-
- public static void report(final ITestResult result, final ITestContext context) {
- testName = result.getName();
- throwable = result.getThrowable();
-
- final String suiteName = ExtentManager.getSuiteName(context);
-
- switch (result.getStatus()) {
- case ITestResult.SUCCESS:
- logSuccessAfterTest();
- break;
-
- case ITestResult.FAILURE:
- logFailure(suiteName);
- break;
-
- case ITestResult.SKIP:
- logSkipAfterTest();
- break;
-
- default:
- break;
- }
-
- }
-
- private static void logSuccessAfterTest() {
- addTag(Status.PASS, "Success");
- takeScreenshot(Status.PASS);
- }
-
- private static void logFailAfterTest() {
- addTag(Status.FAIL, "Failure");
- log(Status.ERROR, String.format(exceptionMsgFormat, Status.ERROR));
- log(Status.ERROR, throwable);
- takeScreenshot(Status.FAIL);
- }
-
- private static void logSkipAfterTest() {
- addTag(Status.SKIP, "Skipped");
- log(Status.SKIP, String.format(exceptionMsgFormat, Status.SKIP));
- log(Status.SKIP, throwable);
- takeScreenshot(Status.SKIP);
- }
-
- private static void logFatalAfterTest() {
- addTag(Status.FATAL, "Fatal");
- log(Status.FATAL, String.format(exceptionMsgFormat, Status.FATAL));
- log(Status.FATAL, throwable);
- takeScreenshot(Status.FATAL);
- }
-
- private static void takeScreenshot(final Status status) {
- String adjustedTestName = testName;
- String infoFromDataProvider = WindowTestManager.getWindowMap().getAddedValueFromDataProvider();
- if (StringUtils.isNotEmpty(infoFromDataProvider)) {
- infoFromDataProvider = infoFromDataProvider.replace(":", "-");
- adjustedTestName = String.format("%s | %s", testName, infoFromDataProvider);
- }
- try {
- addScreenshot(status, adjustedTestName, "Finished the test with the following screenshot:");
- } catch (final IOException e) {
- final String warnMsg = "Could not take screenshot of the final screen";
- LOGGER.warn(warnMsg, e);
- log(Status.WARNING, String.format("%s: %s", warnMsg, e.getMessage()));
- }
- }
-
- private static void logFailure(final String suiteName) {
- if (suiteNameXml.TESTNG_FAILED_XML_NAME.getValue().equals(suiteName)) {
- logFatalAfterTest();
- } else {
- logFailAfterTest();
- }
- }
-
-}
-
diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/Retry.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/Retry.java
deleted file mode 100644
index b28f64e887..0000000000
--- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/Retry.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.ci.tests.execute.setup;
-
-import org.testng.IRetryAnalyzer;
-import org.testng.ITestResult;
-
-public class Retry implements IRetryAnalyzer {
- private int retryCount = 0;
- private int maxRetryCount = 1;
-
- public boolean retry(ITestResult result) {
-
- if (retryCount < maxRetryCount) {
- retryCount++;
- return true;
- }
- return false;
- }
-
-
-}
diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/SetupCDTest.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/SetupCDTest.java
deleted file mode 100644
index a700a0d4b6..0000000000
--- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/SetupCDTest.java
+++ /dev/null
@@ -1,527 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.ci.tests.execute.setup;
-
-import ch.qos.logback.classic.Level;
-import ch.qos.logback.classic.LoggerContext;
-import com.aventstack.extentreports.ExtentTest;
-import com.aventstack.extentreports.Status;
-import net.lightbody.bmp.core.har.Har;
-import org.json.simple.JSONObject;
-import org.openecomp.sdc.be.model.User;
-import org.openecomp.sdc.ci.tests.config.UserCredentialsFromFile;
-import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum;
-import org.openecomp.sdc.ci.tests.datatypes.UserCredentials;
-import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
-import org.openecomp.sdc.ci.tests.execute.sanity.OnboardingFlowsUi;
-import org.openecomp.sdc.ci.tests.execute.setup.ExtentManager.suiteNameXml;
-import org.openecomp.sdc.ci.tests.pages.HomePage;
-import org.openecomp.sdc.ci.tests.run.StartTest;
-import org.openecomp.sdc.ci.tests.utilities.FileHandling;
-import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;
-import org.openecomp.sdc.ci.tests.utilities.RestCDUtils;
-import org.openecomp.sdc.ci.tests.utils.rest.AutomationUtils;
-import org.openqa.selenium.By;
-import org.openqa.selenium.JavascriptExecutor;
-import org.openqa.selenium.WebDriver;
-import org.openqa.selenium.WebElement;
-import org.openqa.selenium.support.ui.ExpectedConditions;
-import org.openqa.selenium.support.ui.WebDriverWait;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.Assert;
-import org.testng.ITestContext;
-import org.testng.ITestResult;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.AfterSuite;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.BeforeSuite;
-import org.testng.annotations.Optional;
-import org.testng.annotations.Parameters;
-import org.testng.annotations.Test;
-
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.UUID;
-
-public abstract class SetupCDTest extends DriverFactory {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(SetupCDTest.class);
-
- private static final String RE_RUN = "<html><font color=\"red\">ReRun - </font></html>";
- private static final String WEB_SEAL_PASSWORD = "123123a";
- protected static final String HEAT_FILE_YAML_NAME_PREFIX = "Heat-File";
- protected static final String HEAT_FILE_YAML_NAME_SUFFIX = ".yaml";
- private static final int BASIC_SLEEP_DURATION = 1000;
-
- /**************** CONSTANTS ****************/
- private static final String CREDENTIALS_FILE = "credentials.yaml";
-
- private static final String REPORT_FILE_NAME = "SDC_UI_Extent_Report.html";
- private static final String REPORT_FOLDER = "." + File.separator + "ExtentReport" + File.separator;
- private static final String SCREENSHOT_FOLDER = REPORT_FOLDER + "screenshots" + File.separator;
- private static final String HAR_FILES_FOLDER_NAME = "har_files";
- private static final String HAR_FILES_FOLDER = REPORT_FOLDER + HAR_FILES_FOLDER_NAME + File.separator;
-
- private static final String SHORT_CSV_REPORT_FILE_NAME = "ShortReport.csv";
-
- private static final int NUM_OF_ATTEMPTS_TO_REFTRESH = 2;
-
- /**************** PRIVATES ****************/
- private static String url;
-
- private static boolean uiSimulator;
- private static boolean localEnv = true;
- private static OnboardCSVReport csvReport;
- private final UserCredentialsFromFile credentialsIns = UserCredentialsFromFile.getInstance();
- private static ITestContext myContext;
-
- public SetupCDTest() {
- LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
- lc.getLogger("org.apache").setLevel(Level.INFO);
- }
-
- public static ExtentTest getExtendTest() {
- return ExtentTestManager.getInstance().getTest();
- }
-
- public static WindowTest getWindowTest() {
- return WindowTestManager.getWindowMap();
- }
-
- private OnboardCSVReport getCsvReport() {
- return csvReport;
- }
-
- public static String getReportFolder() {
- return REPORT_FOLDER;
- }
-
- public static String getScreenshotFolder() {
- return SCREENSHOT_FOLDER;
- }
-
- private static String getHarFilesFolder() {
- return HAR_FILES_FOLDER;
- }
-
-
- protected abstract UserRoleEnum getRole();
-
- /**************** BEFORE ****************/
-
- @BeforeSuite(alwaysRun = true)
- public void setupBeforeSuite(ITestContext context) throws Exception {
- RestCDUtils.deleteOnDemand();
- myContext = context;
- setErrorConfigurationFile();
- setUrl();
- ExtentManager.initReporter(getReportFolder(), REPORT_FILE_NAME, context);
- csvReport = new OnboardCSVReport(getReportFolder(), SHORT_CSV_REPORT_FILE_NAME);
- }
-
- private static void setErrorConfigurationFile() {
- if (!System.getProperty("os.name").contains("Windows")) {
- String errorConfigurationFilename = getConfig().getErrorConfigurationFile();
- errorConfigurationFilename = errorConfigurationFilename.substring(errorConfigurationFilename.lastIndexOf("/") + 1, errorConfigurationFilename.length());
- getConfig().setErrorConfigurationFile(FileHandling.getBasePath() + File.separator + "conf" + File.separator + errorConfigurationFilename);
- if (new File(getConfig().getErrorConfigurationFile()).exists()) {
- System.out.println("Found error-configuration.yaml in : " + getConfig().getErrorConfigurationFile());
- }
- }
- }
-
- @BeforeMethod(alwaysRun = true)
- public void setBrowserBeforeTest(java.lang.reflect.Method method, ITestContext context) throws Exception {
-
- boolean emptyDataProvider = method.getAnnotation(Test.class).dataProvider().isEmpty();
- String className = method.getDeclaringClass().getName();
- if (emptyDataProvider && !className.contains("ToscaValidationTest")) {
- System.out.println("ExtentReport instance started from BeforeMethod...");
- String suiteName = ExtentManager.getSuiteName(context);
- if (suiteName.equals(suiteNameXml.TESTNG_FAILED_XML_NAME.getValue())) {
- ExtentTestManager.getInstance().startTest(RE_RUN + method.getName());
- } else {
- ExtentTestManager.getInstance().startTest(method.getName());
- }
-
- ExtentTestManager.getInstance().assignCategory(this.getClass());
- setBrowserBeforeTest(getRole());
- } else {
- System.out.println("ExtentReport instance started from Test...");
- }
-
- getConfig().setWindowsDownloadDirectory(getWindowTest().getDownloadDirectory());
-
- if (getConfig().getCaptureTraffic()) {
- try {
- MobProxy.getPoxyServer().newHar(method.getName() + ".har");
- } catch (Throwable e) {
- e.printStackTrace();
- }
- }
- }
-
- /**************** AFTER ****************/
- @AfterMethod(alwaysRun = true)
- public void quitAfterTest(final ITestResult result, final ITestContext context) throws Exception {
- try {
- ReportAfterTestManager.report(result, context);
- GeneralUIUtils.closeErrorMessage();
- } finally {
- try {
- if (getConfig().getCaptureTraffic()) {
- addTrafficFileToReport(result);
- }
-
- if (result.getInstanceName().equals(OnboardingFlowsUi.class.getName()) && result.getStatus() == ITestResult.FAILURE) {
- final String msg = "Onboarding test failed, closing browser";
- LOGGER.info(msg);
- getExtendTest().log(Status.INFO, msg);
- quitDriver();
- } else if (!getUser().getRole().toLowerCase().equals(UserRoleEnum.ADMIN.name().toLowerCase())) {
- boolean navigateToHomePageSuccess = HomePage.navigateToHomePage();
- if (!navigateToHomePageSuccess) {
- final String msg = "Navigating to homepage failed, reopening driver";
- LOGGER.info(msg);
- getExtendTest().log(Status.INFO, msg);
- quitDriver();
- }
- }
-
- } catch (final Exception e) {
- LOGGER.error("An unexpected error has occurred", e);
- getExtendTest().log(Status.ERROR, "Exception:" + e.toString());
- }
-
-
- ExtentTestManager.getInstance().endTest();
- final String suiteName = ExtentManager.getSuiteName(context);
-// write result to csv file
- if ((!suiteNameXml.TESTNG_FAILED_XML_NAME.getValue().equals(suiteName)) && (result.getStatus() == ITestResult.SKIP)) {
- addResultToCSV(result, context);
- }
- if (suiteNameXml.TESTNG_FAILED_XML_NAME.getValue().equals(suiteName) && !(result.getStatus() == ITestResult.SUCCESS)) {
- addResultToCSV(result, context);
- }
- FileHandling.cleanCurrentDownloadDir();
- }
-
- }
-
- private void addResultToCSV(ITestResult result, ITestContext context) {
- ExtentTest test = getExtendTest();
- com.aventstack.extentreports.model.Test model = test.getModel();
- String name = model.getName();
- String status = model.getStatus().toString();
- getCsvReport().writeRow(result.getInstanceName(), name.replace(RE_RUN, ""), status);
- }
-
- private void generateReport4Jenkins(ITestContext context) {
- final String suiteName = ExtentManager.getSuiteName(context);
- final JSONObject obj = new JSONObject();
- final String success = Integer.toString(context.getPassedTests().size());
- final String failed = Integer.toString(context.getFailedTests().size());
- final String total = Integer.toString(context.getFailedTests().size() + context.getPassedTests().size());
- obj.put("projectName", "SDC-ONAP-UI-Automation-" + suiteName);
- obj.put("projectVersion", AutomationUtils.getOSVersion());
- obj.put("platform", "Linux");
- obj.put("total", total);
- obj.put("success", success);
- obj.put("failed", failed);
-
- try (FileWriter file = new FileWriter(getReportFolder() + "jenkinsResults.json")) {
- file.write(obj.toJSONString());
- file.flush();
- } catch (final IOException e) {
- LOGGER.debug("An error has occurred while writing 'jenkinsResults.json' file", e);
- }
-
- LOGGER.debug(obj.toJSONString());
- }
-
-
- @Parameters({"eraseAfterTests"})
- @AfterSuite(alwaysRun = true)
- public void afterSuite2(@Optional("true") String eraseAfterTestsReadValue) throws Exception {
-
- csvReport.closeFile();
- generateReport4Jenkins(myContext);
-
- if (Boolean.parseBoolean(eraseAfterTestsReadValue)) {
- RestCDUtils.deleteOnDemand();
- } else {
- System.out.println("Resources will not be deleted according to suite configuration ...");
- }
-
- if (getConfig().getUseBrowserMobProxy()) {
- MobProxy.getPoxyServer().stop();
- }
- }
-
- private static String setUrl() {
- url = getConfig().getUrl();
- uiSimulator = getConfig().isUiSimulator();
- if (url == null) {
- String message = "no URL found";
- System.out.println(message);
- Assert.fail(message);
- } else if (!url.contains("localhost") && !url.contains("192.168.33.10") && !url.contains("127.0.0.1") && !url.contains("192.168.50.5") && !uiSimulator) {
- localEnv = false;
- }
- return url;
- }
-
-
- private static void navigateToUrl(final String url) {
- try {
- LOGGER.info("Deleting cookies");
- deleteCookies();
- LOGGER.info("Navigating to URL : " + url);
- getDriver().navigate().to(url);
- GeneralUIUtils.waitForLoader();
- LOGGER.info("Zooming out");
- GeneralUIUtils.windowZoomOutUltimate();
- } catch (Exception e) {
- final String errorMsg = String.format("Could not navigate to '%s'", url);
- LOGGER.error(errorMsg, e);
- getExtendTest().log(Status.ERROR, errorMsg);
- Assert.fail(errorMsg);
- }
- }
-
- private static void deleteCookies() throws Exception {
- getDriver().manage().deleteAllCookies();
- Thread.sleep(BASIC_SLEEP_DURATION);
-
- int attempts = 0;
- final int max_attempts = 3;
-
- while (!getDriver().manage().getCookies().isEmpty() && attempts < max_attempts) {
- getExtendTest().log(Status.INFO, "Trying to delete cookies one more time - " + (attempts + 1) + "/" + max_attempts + "attempts");
- String deleteCookiesJS = "document.cookie.split(';').forEach(function(c) { document.cookie = c.replace(/^ +/, '').replace(/=.*/, '=;expires=' + new Date().toUTCString() + ';path=/'); });";
- ((JavascriptExecutor) getDriver()).executeScript(deleteCookiesJS);
- attempts++;
-
- if (attempts == max_attempts) {
- String msg = "Did not delete cookies, can't login as user " + WindowTestManager.getWindowMap().getUser().getRole();
- System.out.println(msg);
- getExtendTest().log(Status.ERROR, msg);
- Assert.fail(msg);
- }
- }
- }
-
- private void loginToSystem(UserRoleEnum role) throws Exception {
- final int gettingWebElementTimeOut = 30;
- UserCredentials credentials = new UserCredentials(role.getUserId(), role.getPassword(), role.getFirstName(), role.getLastName(), role.name());
- if (localEnv) {
- loginToSimulator(role);
- } else {
- sendUserAndPasswordKeys(credentials);
- WebElement submitButton = GeneralUIUtils.getWebElementBy(By.name("btnSubmit"), gettingWebElementTimeOut);
- submitButton.click();
- WebElement buttonOK = GeneralUIUtils.getWebElementBy(By.name("successOK"), gettingWebElementTimeOut);
- Assert.assertTrue(buttonOK.isDisplayed(), "OK button is not displayed.");
- buttonOK.click();
- }
- GeneralUIUtils.ultimateWait();
- getWindowTest().setUser(credentials);
- }
-
- private void goToHomePage(UserRoleEnum role) throws Exception {
- final int gettingButtonTimeOut = 10;
- try {
- getWindowTest().setRefreshAttempts(getWindowTest().getRefreshAttempts() == 0 ? NUM_OF_ATTEMPTS_TO_REFTRESH : getWindowTest().getRefreshAttempts());
- if (!role.equals(UserRoleEnum.ADMIN)) {
-
- WebElement closeButton = GeneralUIUtils.getClickableButtonBy(By.className("sdc-welcome-close"), gettingButtonTimeOut);
- if (closeButton != null) {
- closeButton.click();
- }
-
- if (!GeneralUIUtils.isElementVisibleByTestId(DataTestIdEnum.MainMenuButtons.HOME_BUTTON.getValue())) {
- restartBrowser(role);
- }
- }
- } catch (Exception e) {
- restartBrowser(role);
- }
- }
-
- private void restartBrowser(UserRoleEnum role) throws Exception {
- getWindowTest().setRefreshAttempts(getWindowTest().getRefreshAttempts() - 1);
- if (getWindowTest().getRefreshAttempts() <= 0) {
- System.out.println("ERR : Something is wrong with browser!");
- Assert.fail("ERR : Something is wrong with browser!");
- }
- System.out.println("Trying again...");
- getExtendTest().log(Status.INFO, "Trying again...");
- getExtendTest().log(Status.INFO, String.format("%s attempt(s) left", getWindowTest().getRefreshAttempts()));
- System.out.println(String.format("%s attempt(s) left", getWindowTest().getRefreshAttempts()));
-
- reloginWithNewRole(role);
- }
-
- private void loginToSimulator(UserRoleEnum role) {
- final int gettingWebElementTimeOut = 30;
- WebDriver driver = GeneralUIUtils.getDriver();
- WebDriverWait wait = new WebDriverWait(driver, gettingWebElementTimeOut);
-
- wait.until(ExpectedConditions.visibilityOf(driver.findElement(By.xpath("//*[@method='" + "post" + "']"))));
-
- WebElement userIdTextbox = GeneralUIUtils.getWebElementBy(By.name("userId"));
- userIdTextbox.sendKeys(role.getUserId());
- WebElement passwordTextbox = GeneralUIUtils.getWebElementBy(By.name("password"));
- passwordTextbox.sendKeys(WEB_SEAL_PASSWORD);
-
- wait.until(ExpectedConditions.elementToBeClickable(driver.findElement(By.xpath("//*[@value='" + "Login" + "']")))).click();
- }
-
- private void sendUserAndPasswordKeys(UserCredentials userId) {
- System.out.println("Login as user : " + userId.getUserId());
- WebElement userNameTextbox = GeneralUIUtils.getWebElementBy(By.name("userid"));
- userNameTextbox.sendKeys(userId.getUserId());
- WebElement passwordTextbox = GeneralUIUtils.getWebElementBy(By.name("password"));
- passwordTextbox.sendKeys(userId.getPassword());
- }
-
- private void loginWithUser(final UserRoleEnum role) {
- try {
- final String msg = String
- .format("Login as user '%s', role '%s'", role.getUserId(), role.getUserRole());
- getExtendTest().log(Status.INFO, msg);
- LOGGER.info(msg);
- loginToSystem(role);
- LOGGER.debug("Going to home page");
- goToHomePage(role);
- } catch (final Exception e) {
- throw new RuntimeException(e);
- } finally {
- getWindowTest().setPreviousRole(getWindowTest().getUser().getRole());
- }
- }
-
- private void setUser(UserRoleEnum role) {
- User user = new User();
- user.setUserId(role.getUserId());
- user.setFirstName(role.getFirstName());
- user.setRole(role.name());
- user.setLastName(role.getLastName());
-
- getWindowTest().setUser(user);
- }
-
- public User getUser() {
- return getWindowTest().getUser();
- }
-
- private void setBrowserBeforeTest(final UserRoleEnum role) {
- LOGGER.info(String.format("Setup before test for role '%s'", role.name()));
- if (!getWindowTest().getPreviousRole().equalsIgnoreCase(role.name())) {
- LOGGER.info(String.format("Logging in with new role '%s'. Previous role was: '%s'.", role.name(),
- getWindowTest().getPreviousRole()));
- navigateAndLogin(role);
- }
- }
-
- private void navigateAndLogin(final UserRoleEnum role) {
- getWindowTest().setRefreshAttempts(getWindowTest().getRefreshAttempts());
- setUser(role);
- navigateToUrl(url);
- loginWithUser(role);
- GeneralUIUtils.ultimateWait();
- }
-
- public User getUser(UserRoleEnum role) {
- User user = new User();
- user.setUserId(role.getUserId());
- user.setFirstName(role.getFirstName());
- user.setLastName(role.getLastName());
- user.setRole(role.name());
- return user;
- }
-
- protected void reloginWithNewRole(final UserRoleEnum role) {
- navigateAndLogin(role);
- }
-
- private void addTrafficFileToReport(ITestResult result) {
- try {
- // Get the HAR data
- Har har = MobProxy.getPoxyServer().getHar();
- String shortUUID = UUID.randomUUID().toString().split("-")[0];
- File harFile = new File(getHarFilesFolder() + result.getName() + shortUUID + ".har");
- new File(getHarFilesFolder()).mkdirs();
-
- har.writeTo(harFile);
-
- String pathToFileFromReportDirectory = HAR_FILES_FOLDER_NAME + File.separator + harFile.getName();
- ExtentTestActions.addFileToReportAsLink(harFile, pathToFileFromReportDirectory, "File with captured traffic");
- } catch (IOException ioe) {
- ioe.printStackTrace();
- }
- }
-
- /*
- * * Start section of test in ExtentReport with DataProvider parameters,
- * should be started from test method, see example in onboardVNFTest
- */
- public void setLog(String fromDataProvider) {
-
- String suiteName = ExtentManager.getSuiteName(myContext);
- if (suiteNameXml.TESTNG_FAILED_XML_NAME.getValue().equals(suiteName)) {
- ExtentTestManager.getInstance().startTest(RE_RUN + Thread.currentThread().getStackTrace()[2].getMethodName() + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + fromDataProvider);
- } else {
- ExtentTestManager.getInstance().startTest(Thread.currentThread().getStackTrace()[2].getMethodName() + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + fromDataProvider);
- }
-
-
- getWindowTest().setAddedValueFromDataProvider(fromDataProvider);
- ExtentTestManager.getInstance().assignCategory(this.getClass());
- setBrowserBeforeTest(getRole());
- }
-
-
- /**************** MAIN ****************/
- public static void main(String[] args) {
- System.out.println("---------------------");
- System.out.println("running test from CLI");
- System.out.println("---------------------");
-
- String attsdcFilePath = FileHandling.getBasePath() + File.separator + "conf" + File.separator + "attsdc.yaml";
- System.setProperty("config.resource", attsdcFilePath);
- System.out.println("attsdc.yaml file path is : " + attsdcFilePath);
-
- String filepath = FileHandling.getBasePath() + File.separator + "Files" + File.separator;
- System.setProperty("filePath", filepath);
- System.out.println("filePath is : " + System.getProperty("filePath"));
-
- Object[] testSuitsList = FileHandling.filterFileNamesFromFolder(FileHandling.getBasePath() + File.separator + "testSuites", ".xml");
- if (testSuitsList != null) {
- System.out.println(String.format("Found %s testSuite(s)", testSuitsList.length));
- args = Arrays.copyOf(testSuitsList, testSuitsList.length, String[].class);
- StartTest.main(args);
- }
- }
-}
diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/TestFtp.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/TestFtp.java
deleted file mode 100644
index bb48cbddb8..0000000000
--- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/TestFtp.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.ci.tests.execute.setup;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-
-public class TestFtp {
-
- public static void main(String[] args) throws IOException {
- AttFtpClient instance = AttFtpClient.getFtpClient();
-
- String server = "localhost";
- final int port = 2121;
- String user = "admin";
- String pass = "admin";
- AttFtpClient.getFtpClient().init(server, port, user, pass);
-
- try {
- AttFtpClient.getFtpClient().retrieveListOfFile();
-
- File retrieveLastModifiedFileFromFTP = instance.retrieveLastModifiedFileFromFTP();
- String content = new String(Files.readAllBytes(Paths.get(retrieveLastModifiedFileFromFTP.getPath())), StandardCharsets.UTF_8);
-// instance.deleteFilesFromFTPserver();
- System.out.println(content);
- readFile(retrieveLastModifiedFileFromFTP);
-
- } finally {
- instance.terminateClient();
- }
-
-
- }
-
- private static void readFile(File retrieveLastModifiedFileFromFTP) {
-
- StringBuilder sb = new StringBuilder();
- BufferedReader br = null;
- FileReader fileReader = null;
- try {
- fileReader = new FileReader(retrieveLastModifiedFileFromFTP.getPath());
- br = new BufferedReader(fileReader);
- String line;
- while ((line = br.readLine()) != null) {
- if (sb.length() > 0) {
- sb.append("\n");
- }
- sb.append(line);
- }
- } catch (IOException e) {
- System.out.println(e);
- } finally {
- try {
- if (br != null) {
- br.close();
- }
- if (fileReader != null) {
- fileReader.close();
- }
- } catch (IOException ex) {
- System.out.println(ex);
- }
- }
- String contents = sb.toString();
- System.out.println(contents);
-
- }
-
-}
diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/WebDriverThread.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/WebDriverThread.java
deleted file mode 100644
index 6118fa2fee..0000000000
--- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/WebDriverThread.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.ci.tests.execute.setup;
-
-import net.lightbody.bmp.BrowserMobProxyServer;
-import net.lightbody.bmp.client.ClientUtil;
-import net.lightbody.bmp.proxy.CaptureType;
-import org.openecomp.sdc.ci.tests.config.Config;
-import org.openecomp.sdc.ci.tests.exception.WebDriverThreadRuntimeException;
-import org.openecomp.sdc.ci.tests.utilities.FileHandling;
-import org.openqa.selenium.Platform;
-import org.openqa.selenium.UnexpectedAlertBehaviour;
-import org.openqa.selenium.WebDriver;
-import org.openqa.selenium.firefox.FirefoxDriver;
-import org.openqa.selenium.firefox.FirefoxProfile;
-import org.openqa.selenium.remote.CapabilityType;
-import org.openqa.selenium.remote.DesiredCapabilities;
-import org.openqa.selenium.remote.LocalFileDetector;
-import org.openqa.selenium.remote.RemoteWebDriver;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.File;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.UUID;
-
-public class WebDriverThread {
-
- private final static Logger LOGGER = LoggerFactory.getLogger(SetupCDTest.class);
-
- static final String AUTOMATION_DOWNLOAD_DIR = "automationDownloadDir";
- private WebDriver webdriver;
- private FirefoxProfile firefoxProfile;
- private static final String SELENIUM_NODE_URL = "http://%s:%s/wd/hub";
-
- WebDriverThread(Config config) {
- initDriver(config);
- webdriver.manage().window().maximize();
- }
-
- public WebDriver getDriver() {
- return webdriver;
- }
-
- void quitDriver() {
- if (webdriver != null) {
- webdriver.quit();
- webdriver = null;
- }
- }
-
-
- private void initDriver(final Config config) {
- if (config.isRemoteTesting()) {
- LOGGER.info("Opening REMOTE browser");
- final String remoteEnvIP = config.getRemoteTestingMachineIP();
- final String remoteEnvPort = config.getRemoteTestingMachinePort();
-
- final DesiredCapabilities cap = DesiredCapabilities.firefox();
- cap.setPlatform(Platform.ANY);
- cap.setBrowserName("firefox");
-
- final String remoteUrlString = String.format(SELENIUM_NODE_URL, remoteEnvIP, remoteEnvPort);
- final URL remoteUrl;
- try {
- remoteUrl = new URL(remoteUrlString);
- } catch (MalformedURLException e) {
- throw new WebDriverThreadRuntimeException(String.format("Malformed URL '%s'", remoteUrlString), e);
- }
- final RemoteWebDriver remoteWebDriver = new RemoteWebDriver(remoteUrl, cap);
- remoteWebDriver.setFileDetector(new LocalFileDetector());
- webdriver = remoteWebDriver;
- } else {
- if (config.getUseBrowserMobProxy()) {
- setWebDriverWithMobProxy();
- return;
- }
-
- LOGGER.info("Opening LOCAL browser");
-
- final DesiredCapabilities cap = DesiredCapabilities.firefox();
- cap.setBrowserName("firefox");
- cap.setCapability(FirefoxDriver.PROFILE, initFirefoxProfile());
- //unexpected model dialog fix.
- cap.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.ACCEPT);
-
- firefoxProfile.setPreference("network.proxy.type", 2);
- firefoxProfile.setPreference("network.proxy.autoconfig_url", "http://autoproxy.sbc.com/autoproxy.cgi");
- firefoxProfile.setPreference("network.proxy.no_proxies_on", "localhost");
-
- webdriver = new FirefoxDriver(cap);
- }
- }
-
- private FirefoxProfile initFirefoxProfile() {
- firefoxProfile = new FirefoxProfile();
- firefoxProfile.setPreference("browser.download.folderList", 2);
- firefoxProfile.setPreference("browser.download.manager.showWhenStarting", false);
- firefoxProfile.setPreference("browser.download.dir", getDownloadDirectory());
- firefoxProfile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/octet-stream, application/xml, text/plain, text/xml, image/jpeg");
- return firefoxProfile;
- }
-
- private String getDownloadDirectory() {
- String downloadDirectory = FileHandling.getBasePath() + File.separator + AUTOMATION_DOWNLOAD_DIR + UUID.randomUUID().toString().split("-")[0] + File.separator;
- File dir = new File(downloadDirectory);
- if (!dir.exists()) {
- dir.mkdirs();
- }
- return dir.getAbsolutePath();
- }
-
- FirefoxProfile getFirefoxProfile() {
- return firefoxProfile;
- }
-
- private void setWebDriverWithMobProxy() {
- WebDriver driver = null;
- MobProxy.setProxyServer();
- BrowserMobProxyServer proxyServer = MobProxy.getPoxyServer();
-
- firefoxProfile = new FirefoxProfile();
- firefoxProfile.setPreference("browser.download.folderList", 2);
- firefoxProfile.setPreference("browser.download.manager.showWhenStarting", false);
- firefoxProfile.setPreference("browser.download.dir", getDownloadDirectory());
- firefoxProfile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/octet-stream, application/xml, text/plain, text/xml, image/jpeg");
- firefoxProfile.setAcceptUntrustedCertificates(true);
- firefoxProfile.setAssumeUntrustedCertificateIssuer(true);
-
- DesiredCapabilities capabilities = new DesiredCapabilities();
-
- capabilities.setCapability(FirefoxDriver.PROFILE, firefoxProfile);
- capabilities.setCapability(CapabilityType.PROXY, ClientUtil.createSeleniumProxy(proxyServer));
- capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
-
- webdriver = new FirefoxDriver(capabilities);
- proxyServer.enableHarCaptureTypes(CaptureType.REQUEST_CONTENT, CaptureType.RESPONSE_CONTENT, CaptureType.REQUEST_COOKIES, CaptureType.REQUEST_BINARY_CONTENT,
- CaptureType.REQUEST_HEADERS, CaptureType.RESPONSE_COOKIES, CaptureType.RESPONSE_HEADERS, CaptureType.RESPONSE_BINARY_CONTENT);
- }
-
-}
diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/WindowTest.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/WindowTest.java
deleted file mode 100644
index 1de4b4c799..0000000000
--- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/WindowTest.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.ci.tests.execute.setup;
-
-import org.openecomp.sdc.be.model.User;
-
-import java.io.File;
-
-public class WindowTest {
-
- public WindowTest() {
- refreshAttempts = 0;
- previousRole = "";
- addedValueFromDataProvider = null;
- try {
- downloadDirectory = DriverFactory.getDriverFirefoxProfile().getStringPreference("browser.download.dir", null) + File.separator;
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- private int refreshAttempts;
- private String previousRole;
- private User user;
- private String addedValueFromDataProvider;
- private String downloadDirectory;
-
- public int getRefreshAttempts() {
- return refreshAttempts;
- }
-
- public void setRefreshAttempts(int refreshAttempts) {
- this.refreshAttempts = refreshAttempts;
- }
-
- public String getPreviousRole() {
- return previousRole;
- }
-
- public void setPreviousRole(String previousRole) {
- this.previousRole = previousRole;
- }
-
- public User getUser() {
- return user;
- }
-
- public void setUser(User user) {
- this.user = user;
- }
-
- public synchronized String getAddedValueFromDataProvider() {
- return addedValueFromDataProvider;
- }
-
- public synchronized void setAddedValueFromDataProvider(String addedValueFromDataProvider) {
- this.addedValueFromDataProvider = addedValueFromDataProvider;
- }
-
- public String getDownloadDirectory() {
- return downloadDirectory;
- }
-
- public void setDownloadDirectory(String downloadDirectory) {
- this.downloadDirectory = downloadDirectory;
- }
-
-}
diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/WindowTestManager.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/WindowTestManager.java
deleted file mode 100644
index ad67fab8e8..0000000000
--- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/setup/WindowTestManager.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.ci.tests.execute.setup;
-
-import java.util.HashMap;
-
-public class WindowTestManager {
-
- private static HashMap<Long, WindowTest> windowMap = new HashMap<Long, WindowTest>();
-
- public static synchronized WindowTest getWindowMap() {
- Long currentThreadId = Thread.currentThread().getId();
- boolean containsKey = windowMap.containsKey(currentThreadId);
- if (!containsKey) {
- setWindowMap(currentThreadId);
- }
- return windowMap.get(currentThreadId);
- }
-
- private static synchronized void setWindowMap(Long currentThreadId) {
- WindowTestManager.windowMap.put(currentThreadId, new WindowTest());
- }
-
- public static synchronized void removeWindowTest() {
- windowMap.remove(Thread.currentThread().getId());
- }
-
- public static synchronized HashMap<Long, WindowTest> getWholeMap() {
- return windowMap;
- }
-
-}