use of com.seleniumtests.customexception.ConfigurationException in project seleniumRobot by bhecquet.
the class TestTestManagerReporter method testResultIsNotRecordedWrongTestId.
@Test(groups = { "it" })
public void testResultIsNotRecordedWrongTestId() throws Exception {
try {
System.setProperty(SeleniumTestsContext.TMS_TYPE, "squash");
System.setProperty(SeleniumTestsContext.TMS_URL, "http://localhost:1234");
System.setProperty(SeleniumTestsContext.TMS_PROJECT, "Project");
System.setProperty(SeleniumTestsContext.TMS_USER, "squash");
System.setProperty(SeleniumTestsContext.TMS_PASSWORD, "squash");
doThrow(new ConfigurationException("Wrong Test ID")).when(api).addTestCaseInIteration(eq(iteration), anyInt());
executeSubTest(1, new String[] { "com.seleniumtests.it.stubclasses.StubTestClassForTestManager" }, ParallelMode.METHODS, new String[] { "testAndSubActions" });
// check no result has been recorded
verify(api, never()).setExecutionResult(eq(iterationTestPlanItem), any());
} finally {
System.clearProperty(SeleniumTestsContext.TMS_TYPE);
System.clearProperty(SeleniumTestsContext.TMS_PROJECT);
System.clearProperty(SeleniumTestsContext.TMS_URL);
System.clearProperty(SeleniumTestsContext.TMS_USER);
System.clearProperty(SeleniumTestsContext.TMS_PASSWORD);
}
}
use of com.seleniumtests.customexception.ConfigurationException in project seleniumRobot by bhecquet.
the class JiraConnector method transitionIssue.
/**
* Transition issue
* @param issueClient
* @param issue
* @param transitions
* @param transitionName
*/
private void transitionIssue(IssueRestClient issueClient, Issue issue, Map<String, Transition> transitions, String transitionName) {
for (int i = 0; i < 5; i++) {
if (transitions.get(transitionName) == null) {
// update available transitions
WaitHelper.waitForMilliSeconds(500);
transitions.clear();
issueClient.getTransitions(issue).claim().forEach(transition -> transitions.put(transition.getName(), transition));
continue;
}
issueClient.transition(issue, new TransitionInput(transitions.get(transitionName).getId(), new ArrayList<>()));
return;
}
throw new ConfigurationException(String.format("'bugtracker.jira.closeTransition': value [%s] is invalid for this issue in its current state, allowed transitions are %s", transitionName, transitions.keySet()));
}
use of com.seleniumtests.customexception.ConfigurationException in project seleniumRobot by bhecquet.
the class JiraConnector method main.
/**
* Method for getting required fields and allowed values for creating an issue on a project
*
* @param args
* server => url of jira server
* user => user to connect to jira
* password => password to connect to jira
* project => projectkey
* issueType => type of the issue that will be created
* issueKey (optional) => give the transitions for a specific issue
*/
public static void main(String[] args) {
if (args.length < 5) {
System.out.println("Usage: JiraConnector <server> <projectKey> <user> <password> <issueType>");
System.exit(1);
}
JiraConnector jiraConnector = new JiraConnector(args[0], args[1], args[2], args[3]);
IssueType issueType = jiraConnector.issueTypes.get(args[4]);
if (issueType == null) {
throw new ConfigurationException(String.format("Issue type %s cannot be found among valid issue types %s", args[4], jiraConnector.issueTypes.keySet()));
}
System.out.println("Proprities:");
for (String priority : jiraConnector.priorities.keySet()) {
System.out.println(String.format(ITEM, priority));
}
System.out.println("\nComponents:");
for (String component : jiraConnector.components.keySet()) {
System.out.println(String.format(ITEM, component));
}
System.out.println(String.format("\nListing required fields and allowed values (if any) for issue '%s'", args[4]));
Map<String, CimFieldInfo> fieldInfos = jiraConnector.getCustomFieldInfos(jiraConnector.project, issueType);
for (Entry<String, List<String>> entry : jiraConnector.getRequiredFieldsAndValues(fieldInfos).entrySet()) {
System.out.println(String.format("Field '%s':", entry.getKey()));
for (String value : entry.getValue()) {
System.out.println(String.format(ITEM, value));
}
}
if (args.length >= 6) {
IssueRestClient issueClient = jiraConnector.restClient.getIssueClient();
Issue issue;
try {
issue = issueClient.getIssue(args[5]).claim();
} catch (RestClientException e) {
throw new ScenarioException(String.format("Jira issue %s does not exist, cannot close it", args[5]));
}
Map<String, Transition> transitions = new HashMap<>();
issueClient.getTransitions(issue).claim().forEach(transition -> transitions.put(transition.getName(), transition));
System.out.println(transitions);
}
}
use of com.seleniumtests.customexception.ConfigurationException in project seleniumRobot by bhecquet.
the class Uft method prepareArguments.
/**
* Prepare list of arguments
*
* @param load if true, add '/load'
* @param execute if true, add '/execute'
* @return
*/
public List<String> prepareArguments(boolean load, boolean execute) {
// copy uft.vbs to disk
String vbsPath;
try {
File tempFile = Files.createTempDirectory("uft").resolve(SCRIPT_NAME).toFile();
tempFile.deleteOnExit();
FileUtils.copyInputStreamToFile(Thread.currentThread().getContextClassLoader().getResourceAsStream("uft/" + SCRIPT_NAME), tempFile);
vbsPath = tempFile.getAbsolutePath();
} catch (IOException e) {
throw new ScenarioException("Error sending UFT script to grid node: " + e.getMessage());
}
if (SeleniumTestsContextManager.getThreadContext().getRunMode() == DriverMode.GRID) {
SeleniumGridConnector gridConnector = SeleniumTestsContextManager.getThreadContext().getSeleniumGridConnector();
if (gridConnector != null) {
vbsPath = Paths.get(gridConnector.uploadFileToNode(vbsPath, true), SCRIPT_NAME).toString();
} else {
throw new ScenarioException("No grid connector present, executing UFT script needs a browser to be initialized");
}
}
List<String> args = new ArrayList<>();
args.add(vbsPath);
args.add(scriptPath);
if (execute) {
args.add("/execute");
parameters.forEach((key, value) -> args.add(String.format("\"%s=%s\"", key, value)));
}
if (load) {
if (almServer != null && almUser != null && almPassword != null && almDomain != null && almProject != null) {
args.add("/server:" + almServer);
args.add("/user:" + almUser);
args.add("/password:" + almPassword);
args.add("/domain:" + almDomain);
args.add("/project:" + almProject);
} else if (almServer != null || almUser != null || almPassword != null || almDomain != null || almProject != null) {
throw new ConfigurationException("All valuers pour ALM connection must be provided: server, user, password, domain and project");
}
args.add("/load");
if (killUftOnStartup) {
args.add("/clean");
}
}
return args;
}
use of com.seleniumtests.customexception.ConfigurationException in project seleniumRobot by bhecquet.
the class SauceLabsCapabilitiesFactory method uploadFile.
/**
* Upload application to saucelabs server
* @param targetAppPath
* @param serverURL
* @return
* @throws IOException
* @throws AuthenticationException
*/
private void uploadFile(String application) {
// extract user name and password from getWebDriverGrid
Matcher matcher = REG_USER_PASSWORD.matcher(SeleniumTestsContextManager.getThreadContext().getWebDriverGrid().get(0));
String user;
String password;
String datacenter;
if (matcher.matches()) {
user = matcher.group(1);
password = matcher.group(2);
datacenter = matcher.group(3);
} else {
throw new ConfigurationException("webDriverGrid variable does not have the right format for connecting to sauceLabs: \"https://<user>:<token>@ondemand.<datacenter>.saucelabs.com:443/wd/hub\"");
}
try (UnirestInstance unirest = Unirest.spawnInstance()) {
String proxyHost = System.getProperty("https.proxyHost");
String proxyPort = System.getProperty("https.proxyPort");
if (proxyHost != null && proxyPort != null) {
unirest.config().proxy(proxyHost, Integer.valueOf(proxyPort));
}
unirest.post(String.format(SAUCE_UPLOAD_URL, datacenter)).basicAuth(user, password).field("payload", new File(application)).field("name", new File(application).getName()).asString().ifFailure(response -> {
throw new ConfigurationException(String.format("Application file upload failed: %s", response.getStatusText()));
}).ifSuccess(response -> {
logger.info("Application successfuly uploaded to Saucelabs");
});
} catch (UnirestException e) {
throw new ConfigurationException("Application file upload failed: " + e.getMessage());
}
}
Aggregations