Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* (C) Copyright 2015 Kurento (http://kurento.org/)
*
* 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.
*
*/
package org.kurento.test.config;
import static org.kurento.commons.PropertiesManager.getProperty;
import static org.kurento.test.config.TestConfiguration.TEST_CONFIG_EXECUTIONS_DEFAULT;
import static org.kurento.test.config.TestConfiguration.TEST_CONFIG_EXECUTIONS_PROPERTY;
import static org.kurento.test.config.TestConfiguration.TEST_CONFIG_FILE_DEFAULT;
import java.io.BufferedReader;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import org.junit.Assert;
import org.kurento.commons.ClassPath;
import org.kurento.test.base.KurentoTest;
import org.kurento.test.browser.Browser;
import org.kurento.test.browser.BrowserType;
import org.kurento.test.browser.WebPageType;
import org.openqa.selenium.Platform;
import com.google.gson.Gson;
/**
* Scenarios for test (e.g. one local browser and other in remote...)
*
* @author Boni Garcia ([email protected])
* @since 5.1.0
*/
public class TestScenario {
public static final String INSTANCES_SEPARATOR = "-";
private Map browserMap;
private List urlList;
public TestScenario() {
browserMap = new TreeMap<>();
urlList = new ArrayList<>();
}
public void addBrowser(String id, Browser browser) {
if (browser.getNumInstances() > 0) {
for (int i = 0; i < browser.getNumInstances(); i++) {
if (browser.getBrowserPerInstance() > 1) {
for (int j = 0; j < browser.getBrowserPerInstance(); j++) {
String browserId = id + i + INSTANCES_SEPARATOR + j;
addBrowserInstance(browserId, new Browser(browser.getBuilder()));
}
} else {
addBrowserInstance(id + i, new Browser(browser.getBuilder()));
}
}
} else {
addBrowserInstance(id, browser);
}
}
private void addBrowserInstance(String id, Browser browser) {
assertKeyNotExist(id);
browser.setId(id);
browserMap.put(id, browser);
}
private void assertKeyNotExist(String key) {
Assert.assertFalse("'" + key + "' key already registered in browser config map",
browserMap.keySet().contains(key));
}
public BrowserScope getScope(String key) {
return browserMap.get(key).getScope();
}
public BrowserType getBrowserType(String key) {
return browserMap.get(key).getBrowserType();
}
public Platform getPlatform(String key) {
return browserMap.get(key).getPlatform();
}
public String getBrowserVersion(String key) {
return browserMap.get(key).getBrowserVersion();
}
@Override
public String toString() {
String out = "";
Map browsers = new HashMap<>();
for (String key : browserMap.keySet()) {
String browser = getBrowserType(key).toString();
String version = getBrowserVersion(key);
Platform platform = getPlatform(key);
if (version != null) {
browser += version;
}
if (platform != null) {
browser += platform;
}
if (browsers.containsKey(browser)) {
int newCount = browsers.get(browser) + 1;
browsers.put(browser, newCount);
} else {
browsers.put(browser, 1);
}
}
for (String browser : browsers.keySet()) {
int count = browsers.get(browser);
if (!out.isEmpty()) {
out += " ";
}
if (count > 1) {
out += count + "X";
}
out += browser;
}
return out;
}
private static String getConfigFile() {
return getProperty(TEST_CONFIG_FILE_DEFAULT);
}
public static Collection