use of com.coveros.selenified.services.Call in project selenified by Coveros.
the class ServicesOverrideIT method addHeaderDataTest.
@Test(groups = { "integration", "service", "headers" }, description = "An integration test to verify we can successfully set header values")
public void addHeaderDataTest() {
// use this object to verify the app looks as expected
Call call = this.calls.get();
// set some custom headers
Map<String, Object> headers = new HashMap<>();
headers.put("X-Atlassian-Token", "no-check");
call.addHeaders(headers);
// perform some actions - this will fail as application/xml isn't supported
call.post("posts/", new Request().setJsonPayload(new JsonObject())).verifyEquals().code(201);
// verify one issue
finish(1);
}
use of com.coveros.selenified.services.Call in project selenified by Coveros.
the class ServicesResponseVerifyEqualsIT method verifyJsonArrayIsntObject.
@Test(groups = { "integration", "service", "httpget", "response" }, description = "An integration test to verify json data response")
public void verifyJsonArrayIsntObject() {
// use this object to verify the app looks as expected
Call call = this.calls.get();
// perform some actions
call.get("posts/").verifyEquals().objectData(json1);
// verify 1 issue
finish(1);
}
use of com.coveros.selenified.services.Call in project selenified by Coveros.
the class ServicesResponseVerifyEqualsIT method verifyJsonObjectMessageMismatch.
@Test(groups = { "integration", "service", "httpget", "response" }, description = "An integration test to verify json data response")
public void verifyJsonObjectMessageMismatch() {
JsonArray json = new JsonArray();
json.add(json4);
// use this object to verify the app looks as expected
Call call = this.calls.get();
// perform some actions
call.get("posts/?id=4").verifyEquals().message(json.toString());
// verify 1 issue
finish(1);
}
use of com.coveros.selenified.services.Call in project selenified by Coveros.
the class ReporterTest method addCredentials.
@Test
public void addCredentials() throws InvalidHTTPException, InvalidReporterException {
HTTP http = new HTTP(reporter, "SomeURL");
Call call = new Call(http, new HashMap<>());
call.addCredentials("User", "Pass");
String credentialStringOutput = Reporter.getCredentialStringOutput(http);
assertTrue(credentialStringOutput.matches("<a href='javascript:void\\(0\\)' onclick='toggle\\(\"[0-9]{13}_[a-zA-Z0-9]{10}\"\\)'>Toggle Credentials</a> <span id='[0-9]{13}_[a-zA-Z0-9]{10}' style='display:none;'><div><i>Username: User</div><div>Password: Pass</i></div></span>"));
}
use of com.coveros.selenified.services.Call in project selenified by Coveros.
the class Selenified method startTest.
/**
* Gathers all of the testing information, and setup up the logging. If a
* selenium test is running, also sets up the webdriver object
*
* @param dataProvider - any objects that are being passed to the tests to loop
* through as variables
* @param method - what is the method that is being run. the test name will be
* extracted from this
* @param test - was the is context associated with this test suite. suite
* information will be extracted from this
* @param result - where are the test results stored. browser information will
* be kept here
* @param selenium - is this a selenium test. if so, the webdriver content will
* be setup
*/
protected void startTest(Object[] dataProvider, Method method, ITestContext test, ITestResult result, BrowserUse selenium) throws IOException {
String testName = TestCase.getTestName(method, dataProvider);
String outputDir = test.getOutputDirectory();
String extClass = method.getDeclaringClass().getName();
// get annotation information
Test annotation = method.getAnnotation(Test.class);
String description = annotation.description();
while (test.getAttribute(testName + INVOCATION_COUNT) == null) {
test.setAttribute(testName + INVOCATION_COUNT, 0);
}
int invocationCount = (int) test.getAttribute(testName + INVOCATION_COUNT);
Capabilities capabilities;
// setup our browser instance
if (!selenium.useBrowser()) {
capabilities = new Capabilities(new Browser("None"));
} else {
capabilities = new Capabilities(Selenified.BROWSER_LIST.get(invocationCount));
if (getAdditionalDesiredCapabilities(extClass, test) != null) {
capabilities.addExtraCapabilities(getAdditionalDesiredCapabilities(extClass, test));
}
}
Browser browser = capabilities.getBrowser();
result.setAttribute(BROWSER, browser);
// if a group indicates an invalid browser, skip the test
if (Listener.skipTest(browser, result)) {
return;
}
// setup the rest of the browser details
capabilities.setInstance(invocationCount);
DesiredCapabilities desiredCapabilities = capabilities.getDesiredCapabilities();
desiredCapabilities.setCapability("name", testName);
desiredCapabilities.setCapability("tags", Arrays.asList(result.getMethod().getGroups()));
desiredCapabilities.setCapability("build", buildName);
// setup the reporter
Reporter reporter = new Reporter(outputDir, testName, capabilities, Property.getAppURL(extClass, test), test.getName(), Arrays.asList(result.getMethod().getGroups()), getAuthor(extClass, test), getVersion(extClass, test), description);
this.reporterThreadLocal.set(reporter);
result.setAttribute(REPORTER, reporter);
// start creating instances of our app to use for testing
if (selenium.useBrowser()) {
App app = new App(capabilities, reporter);
this.apps.set(app);
reporter.setApp(app);
setupScreenSize(app);
if (selenium.loadPage()) {
loadInitialPage(app, Property.getAppURL(extClass, test), reporter);
}
if (Hub.isHubSet()) {
result.setAttribute(SESSION_ID, ((RemoteWebDriver) app.getDriver()).getSessionId());
}
} else {
this.apps.set(null);
}
// start creating instance of our api to use for testing
HTTP http = new HTTP(reporter, Property.getAppURL(extClass, test), getServiceUserCredential(extClass, test), getServicePassCredential(extClass, test));
Call call = new Call(http, getExtraHeaders(extClass, test));
if (getContentType(extClass, test) != null) {
call.setContentType(getContentType(extClass, test));
}
this.calls.set(call);
}
Aggregations