Added constants.

merge-requests/1/head
Menaka Madushanka 9 years ago
parent e3f8956d29
commit d71b00d925

@ -35,7 +35,7 @@
<modules>
<!--<module>tests-artifacts</module>-->
<module>tests-common</module>
<module>tests-integration</module>
<!--<module>tests-integration</module>-->
<!--<module>tests-ui-integration</module>-->
<module>tests-iot-web-ui</module>
</modules>

@ -1,64 +0,0 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you 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.wso2.iot.integration.ui.pages;
import org.wso2.carbon.authenticator.stub.LoginAuthenticationExceptionException;
import org.wso2.carbon.automation.engine.context.AutomationContext;
import org.wso2.carbon.automation.engine.context.TestUserMode;
import org.wso2.carbon.automation.test.utils.common.HomePageGenerator;
import org.wso2.carbon.integration.common.admin.client.AuthenticatorClient;
import javax.xml.stream.XMLStreamException;
import javax.xml.xpath.XPathExpressionException;
import java.io.IOException;
import java.rmi.RemoteException;
public class IOTIntegrationUIBaseTestCase {
protected AutomationContext automationContext;
protected void init() throws IOException, XMLStreamException, XPathExpressionException {
automationContext = new AutomationContext("IOT", "iot001", TestUserMode.SUPER_TENANT_ADMIN);
}
protected String getBackendURL() throws XPathExpressionException {
return automationContext.getContextUrls().getBackEndUrl();
}
protected String getWebAppURL() throws XPathExpressionException {
return automationContext.getContextUrls().getWebAppURL();
}
protected String getSessionCookie(AutomationContext context)
throws RemoteException, XPathExpressionException, LoginAuthenticationExceptionException {
AuthenticatorClient authenticationAdminClient = new AuthenticatorClient(context.getContextUrls().getBackEndUrl());
return authenticationAdminClient.login(automationContext.getSuperTenant().
getTenantAdmin().getUserName(), automationContext.getSuperTenant().
getTenantAdmin().getPassword(),
automationContext.getDefaultInstance().getHosts().get("default"));
}
protected String getServiceURL() throws XPathExpressionException {
String serviceURL = automationContext.getContextUrls().getServiceUrl();
return automationContext.getContextUrls().getServiceUrl();
}
protected String getLoginURL() throws XPathExpressionException {
return HomePageGenerator.getProductHomeURL(automationContext);
}
}

@ -33,8 +33,7 @@ public class AssertUtil {
* @param realPayload real json string.
* @param mustMatch If the real and expected must match, in order to become the test successful or not.
*/
public static void jsonPayloadCompare(String expectedJsonPayload, String realPayload,
boolean mustMatch) {
public static void jsonPayloadCompare(String expectedJsonPayload, String realPayload, boolean mustMatch) {
JsonElement jsonElement = new JsonParser().parse(expectedJsonPayload);
JsonObject expectedPayloadObject = jsonElement.getAsJsonObject();
jsonElement = new JsonParser().parse(realPayload);

@ -27,9 +27,51 @@ public class Constants {
public static final String IOT_DEVICES_URL = "/devicemgt/devices";
public static final String IOT_CONNECTED_CUP_NAME = "testDevice";
public static final String GROUP_NAME_FIELD_ERROR = "Group Name is a required field. It cannot be empty.";
public static final String GROUP_NAME = "group1";
public static final String GROUP_DESCRIPTION = "This is a test group";
public static final String LOGIN_USER_NAME_ERROR = "Please enter a username";
public static final String LOGIN_PASSWORD_ERROR = "Please provide a password";
public static final String LOGIN_FAILED_ERROR = "Incorrect username or password.!";
public static final String LOGIN_SHORT_PASSWORD_ERROR = "Your password must be at least 3 characters long";
public static final String LOGIN_WRONG_USER_NAME = "admnnn";
public static final String LOGIN_WRONG_USER_PASSWORD = "admmmm";
public static final String LOGIN_SHORT_PASSWORD = "ad";
public static final String ADD_USER_FIRST_NAME = "User";
public static final String ADD_USER_LAST_NAME = "User";
public static final String ADD_USER_EMAIL = "user@wso2.com";
public static final String ADD_USER_EMAIL_ERROR = "user.com";
public static final String ADD_USER_USER_NAME = "user";
public static final String ADD_USER_SHORT_USER_NAME = "us";
public static final String REGISTER_USER_FIRST_NAME = "Firstname";
public static final String REGISTER_USER_LAST_NAME = "Lastname";
public static final String REGISTER_USER_USER_NAME = "testUser";
public static final String REGISTER_USER_PASSWORD = "testPassword";
public static final String REGISTER_USER_CONFIRM_PASSWORD = "testPassword";
public static final String REGISTER_USER_EMAIL = "userName@wso2.com";
public static final String IOT_SERVER_LOGIN_PAGE_TITLE = "Login | IoT Server";
public static final String ADD_USER_SHORT_USER_NAME_ERROR_MSG = "Username must be between 3 and 30 characters long.";
public static final String ADD_USER_FIRST_NAME_ERROR_MSG = "Firstname is a required field. It cannot be empty.";
public static final String ADD_USER_LAST_NAME_ERROR_MSG = "Lastname is a required field. It cannot be empty.";
public static final String ADD_USER_NO_EMAIL_ERROR_MSG = "Email is a required field. It cannot be empty.";
public static final String ADD_USER_WRONG_EMAIL_ERROR_MSG = "Email is a required field. It cannot be empty.";
public static final String ALERT_NOT_PRESENT = "Alert is not present.";
public static final String CARBON_HOME = "carbon.home";
public static final String OS_NAME = "os.name";
public static final String BUILD_SUCCESS_MSG = "BUILD SUCCESS";
public static final int IOT_RESTART_THREAD_TIMEOUT = 30;
public static final String IOT_CONNECTED_CUP_LEVEl = "34";
public static final String IOT_CONNECTED_CUP_LEVEl = "75";
public static final String IOT_CONNECTED_CUP_TEMPERATURE = "53";
public static final String IOT_GRAPH_X_AXIS = "x";
@ -47,6 +89,11 @@ public class Constants {
public static final String IOT_CONNECTED_CUP_COFFEE_LEVEL_Y_AXIS = "Coffeelevel";
public static final String IOT_CONNECTED_CUP_COFFEE_LEVEL_X_AXIS = "time";
public static final String IOT_TEST_GROUP_SAMPLE_INSTALL = "iot.sample";
public static final String IOT_TEST_GROUP_SAMPLE_INSTALL_VERIFY = "iot.sample.install";
public static final String IOT_TEST_GROUP_SAMPLE_VERIFY = "iot.sample.install.verify";
public static final String IOT_TEST_GROUP_SAMPLE_ENROLL = "iot.sample.enroll";
public static final String IOT_TEST_GROUP_SAMPLE_ENROLL_VERIFY = "iot.sample.enroll.verify";
public static final String IOT_TEST_GROUP_SAMPLE_TEMPERATURE = "iot.sample.temp";
public static final String IOT_TEST_GROUP_SAMPLE_COFFEELEVEL = "iot.sample.level";
}

@ -48,7 +48,7 @@ public class DeviceGroupFailTest extends IOTIntegrationUIBaseTestCase {
driver.get(getWebAppURL() + Constants.IOT_GROUP_ADD_URL);
DeviceAddGroupPage addGroupPage = new DeviceAddGroupPage(driver);
Assert.assertEquals(addGroupPage.submitEmptyForm(), "Group Name is a required field. It cannot be empty.");
Assert.assertEquals(addGroupPage.submitEmptyForm(), Constants.GROUP_NAME_FIELD_ERROR);
}
@AfterClass(alwaysRun = true)

@ -51,14 +51,14 @@ public class DeviceGroupTest extends IOTIntegrationUIBaseTestCase {
@Test(description = "Test for adding a new device group.")
public void addNewGroupTest() throws IOException {
DeviceAddGroupPage addGroupPage = adminDashboard.addGroup();
addGroupPage.addNewGroup("group1", "This is test group");
addGroupPage.addNewGroup(Constants.GROUP_NAME, Constants.GROUP_DESCRIPTION);
}
@Test(description = "Check whether the created group exists", dependsOnMethods = {"addNewGroupTest"})
public void isGroupCreatedTest() throws IOException, XPathExpressionException {
driver.get(getWebAppURL() + Constants.IOT_HOME_URL);
DeviceGroupsPage groupsPage = adminDashboard.viewGroups();
Assert.assertTrue(groupsPage.isGroupCreated("group1"));
Assert.assertTrue(groupsPage.isGroupCreated(Constants.GROUP_NAME));
}
@AfterClass(alwaysRun = true)

@ -67,23 +67,23 @@ public class LoginFormValidationTest extends IOTIntegrationUIBaseTestCase {
if (!alertUserName.isDisplayed()) Assert.assertTrue(false, "Alert for user name is not present.");
if (!alertPassword.isDisplayed()) Assert.assertTrue(false, "Alert for password is not present.");
Assert.assertEquals(alertUserName.getText(), "Please enter a username");
Assert.assertEquals(alertPassword.getText(), "Please provide a password");
Assert.assertEquals(alertUserName.getText(), Constants.LOGIN_USER_NAME_ERROR);
Assert.assertEquals(alertPassword.getText(), Constants.LOGIN_PASSWORD_ERROR);
}
@Test(description = "Test for incorrect username")
public void incorrectUserNameTest() throws Exception {
clearForm();
userNameField.sendKeys("admin1");
userNameField.sendKeys(Constants.LOGIN_WRONG_USER_NAME);
passwordField.sendKeys(automationContext.getSuperTenant().getTenantAdmin().getPassword());
loginButton.click();
WebElement alert = driver.findElement(By.xpath(uiElementMapper.getElement("iot.user.login.incorrect.xpath")));
if (alert.isDisplayed()) {
Assert.assertEquals(alert.getText(), "Incorrect username or password.!");
Assert.assertEquals(alert.getText(), Constants.LOGIN_FAILED_ERROR);
} else {
Assert.assertTrue(false, "Alert is not present.");
Assert.assertTrue(false, Constants.ALERT_NOT_PRESENT);
}
}
@ -92,14 +92,14 @@ public class LoginFormValidationTest extends IOTIntegrationUIBaseTestCase {
public void incorrectPasswordTest() throws Exception {
clearForm();
userNameField.sendKeys(automationContext.getSuperTenant().getTenantAdmin().getPassword());
passwordField.sendKeys("admnn");
passwordField.sendKeys(Constants.LOGIN_WRONG_USER_PASSWORD);
loginButton.click();
WebElement alert = driver.findElement(By.xpath(uiElementMapper.getElement("iot.user.login.incorrect.xpath")));
if (alert.isDisplayed()) {
Assert.assertEquals(alert.getText(), "Incorrect username or password.!");
Assert.assertEquals(alert.getText(), Constants.LOGIN_FAILED_ERROR);
} else {
Assert.assertTrue(false, "Alert is not present.");
Assert.assertTrue(false, Constants.ALERT_NOT_PRESENT);
}
}
@ -108,14 +108,14 @@ public class LoginFormValidationTest extends IOTIntegrationUIBaseTestCase {
public void shortPasswordTest() throws Exception {
clearForm();
userNameField.sendKeys(automationContext.getSuperTenant().getTenantAdmin().getUserName());
passwordField.sendKeys("ad");
passwordField.sendKeys(Constants.LOGIN_SHORT_PASSWORD);
loginButton.click();
WebElement alert = driver.findElement(By.id(uiElementMapper.getElement("iot.user.login.password.error")));
if (alert.isDisplayed()) {
Assert.assertEquals(alert.getText(), "Your password must be at least 3 characters long");
Assert.assertEquals(alert.getText(), Constants.LOGIN_SHORT_PASSWORD_ERROR);
} else {
Assert.assertTrue(false, "Alert is not present.");
Assert.assertTrue(false, Constants.ALERT_NOT_PRESENT);
}
}

@ -52,14 +52,14 @@ public class SampleEnrollmentTest extends IOTIntegrationUIBaseTestCase {
}
@Test(description = "Verify the pop up modal is displayed.",
groups = {"iot.enroll"},
dependsOnGroups = {"iot.install"})
groups = Constants.IOT_TEST_GROUP_SAMPLE_ENROLL,
dependsOnGroups = Constants.IOT_TEST_GROUP_SAMPLE_INSTALL_VERIFY)
public void enrollDevicePopUpModalTest() throws InterruptedException, IOException {
Assert.assertTrue(connectedCupDeviceTypeViewPage.isPopUpPresent());
}
@Test(description = "Test case for device enrolment",
groups = {"iot.enroll"},
groups = Constants.IOT_TEST_GROUP_SAMPLE_ENROLL,
dependsOnMethods = {"enrollDevicePopUpModalTest"})
public void enrollDeviceTest() throws InterruptedException {
Assert.assertTrue(connectedCupDeviceTypeViewPage.enrollDevice(Constants.IOT_CONNECTED_CUP_NAME));

@ -52,15 +52,15 @@ public class SampleEnrolmentVerificationTest extends IOTIntegrationUIBaseTestCas
}
@Test(description = "Verify enrolment of the sample device",
groups = {"iot.enroll.verify"},
dependsOnGroups = "iot.enroll")
groups = Constants.IOT_TEST_GROUP_SAMPLE_ENROLL_VERIFY,
dependsOnGroups = Constants.IOT_TEST_GROUP_SAMPLE_ENROLL)
public void verifyEnrollmentTest() {
Assert.assertTrue(devicesPage.isDeviceEnrolled(Constants.IOT_CONNECTED_CUP_NAME));
}
@Test(description = "Verify navigation to device view",
dependsOnMethods = "verifyEnrollmentTest",
groups = {"iot.enroll.verify"})
groups = Constants.IOT_TEST_GROUP_SAMPLE_ENROLL_VERIFY)
public void verifyNavigationTest() throws IOException {
connectedCupDeviceViewPage = devicesPage.viewDevice(Constants.IOT_CONNECTED_CUP_NAME);
Assert.assertNotNull(connectedCupDeviceViewPage);

@ -61,36 +61,37 @@ public class SampleFunctionalityTest extends IOTIntegrationUIBaseTestCase {
}
@Test(description = "Set the temperature level.",
groups = {"iot.sample.verify"},
dependsOnGroups = "iot.enroll.verify")
groups = Constants.IOT_TEST_GROUP_SAMPLE_VERIFY,
dependsOnGroups = Constants.IOT_TEST_GROUP_SAMPLE_ENROLL_VERIFY)
public void setTemperatureTest() {
Assert.assertTrue(sampleViewPage.changeTemperature(Constants.IOT_CONNECTED_CUP_TEMPERATURE));
}
@Test(description = "Set the coffee level.",
groups = {"iot.sample.verify"},
dependsOnGroups = "iot.enroll.verify")
groups = Constants.IOT_TEST_GROUP_SAMPLE_VERIFY,
dependsOnGroups = Constants.IOT_TEST_GROUP_SAMPLE_ENROLL_VERIFY)
public void setCoffeeLevelTest() throws IOException {
Assert.assertTrue(sampleViewPage.changeCoffeeLevel(Constants.IOT_CONNECTED_CUP_LEVEl));
}
@Test(description = "Verify order coffee function.",
groups = {"iot.sample.verify"},
dependsOnGroups = "iot.enroll.verify")
groups = Constants.IOT_TEST_GROUP_SAMPLE_VERIFY,
dependsOnGroups = Constants.IOT_TEST_GROUP_SAMPLE_ENROLL_VERIFY)
public void orderCoffeeTest() throws IOException, InterruptedException {
Assert.assertTrue(sampleViewPage.orderCoffee());
}
@Test(description = "Test the graphs are present in device view.",
groups = {"iot.sample.verify"},
groups = Constants.IOT_TEST_GROUP_SAMPLE_VERIFY,
dependsOnMethods = {"setTemperatureTest", "setCoffeeLevelTest", "orderCoffeeTest"})
public void verifyGraphs() throws IOException {
Assert.assertTrue(connectedCupDeviceViewPage.isGraphsAvailable(2));
}
@Test(description = "Test the Y axis name of Temperature graph.",
groups = {"iot.sample.verify", "sample.temp"},
dependsOnGroups = {"iot.enroll.verify"},
groups = {Constants.IOT_TEST_GROUP_SAMPLE_VERIFY,
Constants.IOT_TEST_GROUP_SAMPLE_TEMPERATURE},
dependsOnGroups = Constants.IOT_TEST_GROUP_SAMPLE_ENROLL_VERIFY,
dependsOnMethods = {"verifyGraphs"})
public void temperatureGraphYAxisNameTest() throws IOException {
Assert.assertTrue(connectedCupDeviceViewPage.graphAxisName(Constants.IOT_GRAPH_Y_AXIS,
@ -99,8 +100,9 @@ public class SampleFunctionalityTest extends IOTIntegrationUIBaseTestCase {
}
@Test(description = "Test the X axis name of Temperature graph.",
groups = {"iot.sample.verify", "sample.temp"},
dependsOnGroups = {"iot.enroll.verify"},
groups = {Constants.IOT_TEST_GROUP_SAMPLE_VERIFY,
Constants.IOT_TEST_GROUP_SAMPLE_TEMPERATURE},
dependsOnGroups = Constants.IOT_TEST_GROUP_SAMPLE_ENROLL_VERIFY,
dependsOnMethods = {"verifyGraphs"})
public void temperatureGraphXAxisNameTest() throws IOException {
Assert.assertTrue(connectedCupDeviceViewPage.graphAxisName(Constants.IOT_GRAPH_X_AXIS,
@ -109,8 +111,9 @@ public class SampleFunctionalityTest extends IOTIntegrationUIBaseTestCase {
}
@Test(description = "Test the whether the Coffee Level graph legend is present.",
groups = {"iot.sample.verify", "sample.temp"},
dependsOnGroups = {"iot.enroll.verify"},
groups = {Constants.IOT_TEST_GROUP_SAMPLE_VERIFY,
Constants.IOT_TEST_GROUP_SAMPLE_TEMPERATURE},
dependsOnGroups = Constants.IOT_TEST_GROUP_SAMPLE_ENROLL_VERIFY,
dependsOnMethods = {"verifyGraphs"})
public void temperatureGraphLegendTest() {
Assert.assertTrue(connectedCupDeviceViewPage.graphLegendName(Constants.IOT_CONNECTED_CUP_TEMPERATURE_ID,
@ -118,16 +121,18 @@ public class SampleFunctionalityTest extends IOTIntegrationUIBaseTestCase {
}
@Test(description = "Test the whether the Temperature graph path is visible.",
groups = {"iot.sample.verify", "sample.temp"},
dependsOnGroups = {"iot.enroll.verify"},
groups = {Constants.IOT_TEST_GROUP_SAMPLE_VERIFY,
Constants.IOT_TEST_GROUP_SAMPLE_TEMPERATURE},
dependsOnGroups = Constants.IOT_TEST_GROUP_SAMPLE_ENROLL_VERIFY,
dependsOnMethods = {"verifyGraphs"})
public void temperatureGraphPathTest() {
Assert.assertTrue(connectedCupDeviceViewPage.checkGraphPath(Constants.IOT_CONNECTED_CUP_TEMPERATURE_GRAPH_ID));
}
@Test(description = "Test the whether the Temperature graph gets values.",
groups = {"iot.sample.verify", "sample.temp"},
dependsOnGroups = {"iot.enroll.verify"},
groups = {Constants.IOT_TEST_GROUP_SAMPLE_VERIFY,
Constants.IOT_TEST_GROUP_SAMPLE_TEMPERATURE},
dependsOnGroups = Constants.IOT_TEST_GROUP_SAMPLE_ENROLL_VERIFY,
dependsOnMethods = {"verifyGraphs"})
public void temperatureGraphDataPublisherTest() {
Assert.assertTrue(connectedCupDeviceViewPage.checkGraphValues(Constants.IOT_CONNECTED_CUP_TEMPERATURE_GRAPH_ID,
@ -135,8 +140,8 @@ public class SampleFunctionalityTest extends IOTIntegrationUIBaseTestCase {
}
@Test(description = "Test the Y axis name of Coffee Level graph.",
groups = {"iot.sample.coffee"},
dependsOnGroups = {"sample.temp"})
groups = Constants.IOT_TEST_GROUP_SAMPLE_COFFEELEVEL,
dependsOnGroups = Constants.IOT_TEST_GROUP_SAMPLE_TEMPERATURE)
public void coffeeLevelGraphYAxisNameTest() {
Assert.assertTrue(connectedCupDeviceViewPage.graphAxisName(Constants.IOT_GRAPH_Y_AXIS,
Constants.IOT_CONNECTED_CUP_COFFEE_LEVEL_ID,
@ -144,8 +149,9 @@ public class SampleFunctionalityTest extends IOTIntegrationUIBaseTestCase {
}
@Test(description = "Test the X axis name of Coffee Level graph.",
groups = {"iot.sample.coffee"},
dependsOnGroups = {"iot.enroll.verify", "sample.temp"})
groups = Constants.IOT_TEST_GROUP_SAMPLE_COFFEELEVEL,
dependsOnGroups = {Constants.IOT_TEST_GROUP_SAMPLE_ENROLL_VERIFY,
Constants.IOT_TEST_GROUP_SAMPLE_TEMPERATURE})
public void coffeeLevelGraphXAxisNameTest() {
Assert.assertTrue(connectedCupDeviceViewPage.graphAxisName(Constants.IOT_GRAPH_X_AXIS,
Constants.IOT_CONNECTED_CUP_COFFEE_LEVEL_ID,
@ -153,23 +159,23 @@ public class SampleFunctionalityTest extends IOTIntegrationUIBaseTestCase {
}
@Test(description = "Test the whether the Coffee Level graph legend is present.",
groups = {"iot.sample.coffee"},
dependsOnGroups = {"sample.temp"})
groups = Constants.IOT_TEST_GROUP_SAMPLE_COFFEELEVEL,
dependsOnGroups = {Constants.IOT_TEST_GROUP_SAMPLE_TEMPERATURE})
public void coffeeLevelGraphLegendTest() throws IOException {
Assert.assertTrue(connectedCupDeviceViewPage.graphLegendName(Constants.IOT_CONNECTED_CUP_COFFEE_LEVEL_ID,
Constants.IOT_CONNECTED_CUP_COFFEE_LEVEL_LEGEND));
}
@Test(description = "Test the whether the Coffee Level graph path is visible.",
groups = {"iot.sample.coffee"},
dependsOnGroups = {"sample.temp"})
groups = Constants.IOT_TEST_GROUP_SAMPLE_COFFEELEVEL,
dependsOnGroups = {Constants.IOT_TEST_GROUP_SAMPLE_TEMPERATURE})
public void coffeeLevelGraphPathTest() {
Assert.assertTrue(connectedCupDeviceViewPage.checkGraphPath(Constants.IOT_CONNECTED_CUP_COFFEE_LEVEL_GRAPH_ID));
}
@Test(description = "Test the whether the Coffee Level graph gets values.",
groups = {"iot.sample.coffee"},
dependsOnGroups = {"sample.temp"})
groups = Constants.IOT_TEST_GROUP_SAMPLE_COFFEELEVEL,
dependsOnGroups = Constants.IOT_TEST_GROUP_SAMPLE_TEMPERATURE)
public void coffeeLevelGraphDataPublisherTest() {
Assert.assertTrue(connectedCupDeviceViewPage.checkGraphValues(Constants.IOT_CONNECTED_CUP_COFFEE_LEVEL_GRAPH_ID,
Constants.IOT_CONNECTED_CUP_LEVEl));

@ -64,7 +64,7 @@ public class SampleInstallationTest extends IOTIntegrationUIBaseTestCase {
private Log log = LogFactory.getLog(SampleInstallationTest.class);
private Process tempProcess = null;
private Properties properties = System.getProperties();
private String carbonHome = properties.getProperty("carbon.home");
private String carbonHome = properties.getProperty(Constants.CARBON_HOME);
private String[] cmdArray;
private LogViewerClient logViewerClient;
@ -75,14 +75,14 @@ public class SampleInstallationTest extends IOTIntegrationUIBaseTestCase {
logViewerClient = new LogViewerClient(getBackendURL(), getSessionCookie(automationContext));
}
@Test(groups = {"iot.sample"},
description = "Verify the sample build process")
@Test(description = "Verify the sample build process",
groups = Constants.IOT_TEST_GROUP_SAMPLE_INSTALL)
public void sampleBuildTest() throws IOException {
String connectedCupDir = carbonHome + File.separator + "samples" + File.separator + "connectedcup";
log.info("Connected cup Sample: " + connectedCupDir);
File dir = new File(connectedCupDir);
try {
if (System.getProperty("os.name").toLowerCase().contains("windows")) {
if (System.getProperty(Constants.OS_NAME).toLowerCase().contains("windows")) {
log.info("Executing maven clean install --------------------------------");
cmdArray = new String[]{"cmd.exe", "/c", "mvn clean install"};
tempProcess = Runtime.getRuntime().exec(cmdArray, null, dir);
@ -92,7 +92,7 @@ public class SampleInstallationTest extends IOTIntegrationUIBaseTestCase {
tempProcess = Runtime.getRuntime().exec(cmdArray, null, dir);
}
boolean buildStatus = waitForMessage(tempProcess.getInputStream(), "BUILD SUCCESS");
boolean buildStatus = waitForMessage(tempProcess.getInputStream(), Constants.BUILD_SUCCESS_MSG);
Assert.assertTrue(buildStatus, "Building the sample was not successful");
} finally {
if (tempProcess != null) {
@ -101,23 +101,23 @@ public class SampleInstallationTest extends IOTIntegrationUIBaseTestCase {
}
}
@Test(groups = {"iot.sample"},
description = "Verify the sample installation process",
@Test(description = "Verify the sample installation process",
groups = Constants.IOT_TEST_GROUP_SAMPLE_INSTALL,
dependsOnMethods = {"sampleBuildTest"})
public void sampleInstallationTest() throws IOException {
log.info("CARBON_HOME: " + System.getProperty("carbon.home"));
log.info("CARBON_HOME: " + System.getProperty(Constants.CARBON_HOME));
File dir = new File(carbonHome);
log.info("Sample installation started : mvn clean install -f device-deployer.xml");
try {
if (System.getProperty("os.name").toLowerCase().contains("windows")) {
if (System.getProperty(Constants.OS_NAME).toLowerCase().contains("windows")) {
cmdArray = new String[]{"cmd.exe", "/c", "mvn clean install -f device-deployer.xml"};
tempProcess = Runtime.getRuntime().exec(cmdArray, null, dir);
} else {
cmdArray = new String[]{"mvn", "clean", "install", "-f", "device-deployer.xml"};
tempProcess = Runtime.getRuntime().exec(cmdArray, null, dir);
}
boolean buildStatus = waitForMessage(tempProcess.getInputStream(), "BUILD SUCCESS");
boolean buildStatus = waitForMessage(tempProcess.getInputStream(), Constants.BUILD_SUCCESS_MSG);
Assert.assertTrue(buildStatus, "Sample installation was not successful");
} finally {
if (tempProcess != null) {
@ -126,8 +126,8 @@ public class SampleInstallationTest extends IOTIntegrationUIBaseTestCase {
}
}
@Test(groups = {"iot.sample"},
description = "Test restarting the server",
@Test(description = "Test restarting the server",
groups = Constants.IOT_TEST_GROUP_SAMPLE_INSTALL,
dependsOnMethods = {"sampleInstallationTest"})
public void serverRestartTest() {
ServerConfigurationManager serverManager;

@ -23,6 +23,7 @@ import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.wso2.carbon.automation.extensions.selenium.BrowserManager;
import org.wso2.carbon.iot.integration.web.ui.test.common.Constants;
import org.wso2.carbon.iot.integration.web.ui.test.common.LoginUtils;
import org.wso2.carbon.iot.integration.web.ui.test.common.IOTIntegrationUIBaseTestCase;
import org.wso2.iot.integration.ui.pages.devices.EnrollDevicePage;
@ -48,8 +49,9 @@ public class SampleInstallationVerification extends IOTIntegrationUIBaseTestCase
adminDashboard = new IOTAdminDashboard(driver);
}
@Test(description = "Verify the sample is available in Virtual devices section.", groups = {"iot.install"},
dependsOnGroups = {"iot.sample"})
@Test(description = "Verify the sample is available in Virtual devices section.",
groups = Constants.IOT_TEST_GROUP_SAMPLE_INSTALL_VERIFY,
dependsOnGroups = Constants.IOT_TEST_GROUP_SAMPLE_INSTALL)
public void installationVerificationTest() throws IOException {
EnrollDevicePage enrollDevicePage = adminDashboard.enrollNewDevice();
Assert.assertTrue(enrollDevicePage.isInstalled());

@ -94,10 +94,10 @@ public class AddUserFormValidationTest extends IOTIntegrationUIBaseTestCase {
public void shortUserNameTest() {
clearForm();
firstNameField.sendKeys("User");
lastNameField.sendKeys("User");
emailField.sendKeys("user@wso2.com");
userNameField.sendKeys("us");
firstNameField.sendKeys(Constants.ADD_USER_FIRST_NAME);
lastNameField.sendKeys(Constants.ADD_USER_LAST_NAME);
emailField.sendKeys(Constants.ADD_USER_EMAIL);
userNameField.sendKeys(Constants.ADD_USER_SHORT_USER_NAME);
addUserButton.click();
@ -108,7 +108,7 @@ public class AddUserFormValidationTest extends IOTIntegrationUIBaseTestCase {
Assert.assertTrue(false, "Alert for short user name is not displayed.");
}
Assert.assertEquals(alert.getText(), "Username must be between 3 and 30 characters long.");
Assert.assertEquals(alert.getText(), Constants.ADD_USER_SHORT_USER_NAME_ERROR_MSG);
}
@Test(description = "Test for empty first name")
@ -116,9 +116,9 @@ public class AddUserFormValidationTest extends IOTIntegrationUIBaseTestCase {
clearForm();
firstNameField.sendKeys("");
lastNameField.sendKeys("User");
emailField.sendKeys("user@wso2.com");
userNameField.sendKeys("user1");
lastNameField.sendKeys(Constants.ADD_USER_LAST_NAME);
emailField.sendKeys(Constants.ADD_USER_EMAIL);
userNameField.sendKeys(Constants.ADD_USER_USER_NAME);
addUserButton.click();
@ -129,17 +129,17 @@ public class AddUserFormValidationTest extends IOTIntegrationUIBaseTestCase {
Assert.assertTrue(false, "Alert for First name is not displayed.");
}
Assert.assertEquals(alert.getText(), "Firstname is a required field. It cannot be empty.");
Assert.assertEquals(alert.getText(), Constants.ADD_USER_FIRST_NAME_ERROR_MSG);
}
@Test(description = "Test for empty last name")
public void emptyLastNameTest() {
clearForm();
firstNameField.sendKeys("User");
firstNameField.sendKeys(Constants.ADD_USER_FIRST_NAME);
lastNameField.sendKeys("");
emailField.sendKeys("user@wso2.com");
userNameField.sendKeys("user1");
emailField.sendKeys(Constants.ADD_USER_EMAIL);
userNameField.sendKeys(Constants.ADD_USER_USER_NAME);
addUserButton.click();
@ -150,17 +150,17 @@ public class AddUserFormValidationTest extends IOTIntegrationUIBaseTestCase {
Assert.assertTrue(false, "Alert for Last name is not displayed.");
}
Assert.assertEquals(alert.getText(), "Lastname is a required field. It cannot be empty.");
Assert.assertEquals(alert.getText(), Constants.ADD_USER_LAST_NAME_ERROR_MSG);
}
@Test(description = "Test for empty email name")
public void emptyEmailTest() {
clearForm();
firstNameField.sendKeys("User");
lastNameField.sendKeys("User");
firstNameField.sendKeys(Constants.ADD_USER_FIRST_NAME);
lastNameField.sendKeys(Constants.ADD_USER_LAST_NAME);
emailField.sendKeys("");
userNameField.sendKeys("user1");
userNameField.sendKeys(Constants.ADD_USER_USER_NAME);
addUserButton.click();
@ -171,17 +171,17 @@ public class AddUserFormValidationTest extends IOTIntegrationUIBaseTestCase {
Assert.assertTrue(false, "Alert for E-mail is not displayed.");
}
Assert.assertEquals(alert.getText(), "Email is a required field. It cannot be empty.");
Assert.assertEquals(alert.getText(), Constants.ADD_USER_NO_EMAIL_ERROR_MSG);
}
@Test(description = "Test for incorrect email")
public void incorrectEmailTest() {
clearForm();
firstNameField.sendKeys("User");
lastNameField.sendKeys("User");
emailField.sendKeys("user.com");
userNameField.sendKeys("user1");
firstNameField.sendKeys(Constants.ADD_USER_FIRST_NAME);
lastNameField.sendKeys(Constants.ADD_USER_LAST_NAME);
emailField.sendKeys(Constants.ADD_USER_EMAIL_ERROR);
userNameField.sendKeys(Constants.ADD_USER_USER_NAME);
addUserButton.click();
@ -192,7 +192,7 @@ public class AddUserFormValidationTest extends IOTIntegrationUIBaseTestCase {
Assert.assertTrue(false, "Alert for incorrect E-mail is not displayed.");
}
Assert.assertEquals(alert.getText(), "Provided email is invalid. Please check.");
Assert.assertEquals(alert.getText(), Constants.ADD_USER_WRONG_EMAIL_ERROR_MSG);
}
private void clearForm() {

@ -50,18 +50,16 @@ public class NewUserRegistrationTest extends IOTIntegrationUIBaseTestCase {
@Test(description = "Verify new User registration")
public void userRegisterTest() throws IOException {
LoginPage login = new LoginPage(driver);
UIElementMapper uiElementMapper = UIElementMapper.getInstance();
NewUserRegisterPage registerTest = login.registerNewUser();
LoginPage loginPage = registerTest.registerUser(
uiElementMapper.getElement("iot.user.add.firstname"),
uiElementMapper.getElement("iot.user.add.lastname"),
uiElementMapper.getElement("iot.user.add.email"),
uiElementMapper.getElement("iot.user.add.username"),
uiElementMapper.getElement("iot.user.add.password"),
uiElementMapper.getElement("iot.user.add.password"));
LoginPage loginPage = registerTest.registerUser(Constants.REGISTER_USER_FIRST_NAME,
Constants.REGISTER_USER_LAST_NAME,
Constants.REGISTER_USER_EMAIL,
Constants.REGISTER_USER_USER_NAME,
Constants.REGISTER_USER_PASSWORD,
Constants.REGISTER_USER_CONFIRM_PASSWORD);
IOTHomePage homePage = loginPage.loginAsUser(uiElementMapper.getElement("iot.user.add.username"),
uiElementMapper.getElement("iot.user.add.password"));
IOTHomePage homePage = loginPage.loginAsUser(Constants.REGISTER_USER_USER_NAME,
Constants.REGISTER_USER_PASSWORD);
Assert.assertTrue(homePage.checkUserName());
}
@ -70,7 +68,7 @@ public class NewUserRegistrationTest extends IOTIntegrationUIBaseTestCase {
public void logoutTest() throws IOException {
IOTHomePage homePage = new IOTHomePage(driver);
homePage.logout();
Assert.assertEquals(driver.getTitle(), "Login | IoT Server");
Assert.assertEquals(driver.getTitle(), Constants.IOT_SERVER_LOGIN_PAGE_TITLE);
}
@AfterClass(alwaysRun = true)

Loading…
Cancel
Save