Code formatting and fixes

application-manager-new
Menaka Madushanka 9 years ago
parent fcd5669361
commit 57f91949a3

@ -49,14 +49,12 @@ public class IOTIntegrationUIBaseTestCase {
}
protected String getSessionCookie(AutomationContext context)
throws RemoteException, XPathExpressionException,
LoginAuthenticationExceptionException {
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 {

@ -2,4 +2,5 @@ package org.wso2.iot.integration.ui.pages;
public class UIConstants {
public static long webDriverTimeOut = 10;
public static int threadTimeout = 1000;
}

@ -30,7 +30,6 @@ public class UIElementMapper {
private static UIElementMapper instance;
private UIElementMapper(){
}
public static synchronized UIElementMapper getInstance() throws IOException {
@ -59,6 +58,4 @@ public class UIElementMapper {
}
return null;
}
}

@ -36,5 +36,4 @@ public class EnrollDevicePage {
this.driver = driver;
this.uiElementMapper = UIElementMapper.getInstance();
}
}

@ -65,7 +65,6 @@ public class DeviceAddGroupPage {
addGroupButton.click();
return new DeviceGroupsPage(driver);
}
/**
@ -87,5 +86,4 @@ public class DeviceAddGroupPage {
return driver.findElement(By.xpath(
uiElementMapper.getElement("iot.device.groups.add.emptyfrom.error"))).getText();
}
}

@ -100,5 +100,4 @@ public class LoginPage {
registerLink.click();
return new NewUserRegisterPage(driver);
}
}

@ -62,6 +62,4 @@ public class AddUserPage {
return new UserAddedConfirmationPage(driver);
}
}

@ -30,5 +30,4 @@ public class EditUserPage {
public void editUser(String password, String firstName, String lastName) {
driver.findElement(By.xpath(uiElementMapper.getElement("iot.user.add.input.password.xpath")));
}
}

@ -1,3 +1,20 @@
/*
* Copyright (c) 2015, 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.uesr;
import org.openqa.selenium.By;
@ -13,19 +30,42 @@ import java.io.IOException;
/**
* This class represents the new user registration page.
* User registration page has the registration form for new users to enter the required data and the submit button.
*/
public class NewUserRegisterPage {
private WebDriver driver;
private UIElementMapper uiElementMapper;
private WebElement firstNameField;
private WebElement lastNameField;
private WebElement emailField;
private WebElement userNameField;
private WebElement passwordField;
private WebElement passwordConfirmationField;
private WebElement registerButton;
public NewUserRegisterPage(WebDriver driver) throws IOException {
this.driver = driver;
this.uiElementMapper = UIElementMapper.getInstance();
UIElementMapper uiElementMapper = UIElementMapper.getInstance();
// Check that we're on the right page.
WebDriverWait webDriverWait = new WebDriverWait(driver, UIConstants.webDriverTimeOut);
if (!webDriverWait.until(ExpectedConditions.titleContains("Register | IoT Server"))) {
throw new IllegalStateException("This is not the Register page");
}
firstNameField = driver.findElement(By.xpath(
uiElementMapper.getElement("iot.user.add.input.firstname.xpath")));
lastNameField = driver.findElement(By.xpath(
uiElementMapper.getElement("iot.user.add.input.lastname.xpath")));
emailField = driver.findElement(By.xpath(
uiElementMapper.getElement("iot.user.add.input.email.xpath")));
userNameField = driver.findElement(By.xpath(
uiElementMapper.getElement("iot.user.add.input.username.xpath")));
passwordField = driver.findElement(By.xpath(
uiElementMapper.getElement("iot.user.add.input.password.xpath")));
passwordConfirmationField = driver.findElement(By.xpath(
uiElementMapper.getElement("iot.user.add.input.confirmpassword.xpath")));
registerButton = driver.findElement(By.xpath(
uiElementMapper.getElement("iot.user.add.register.button.xpath")));
}
/**
@ -41,28 +81,37 @@ public class NewUserRegisterPage {
* @throws IOException
*/
public LoginPage registerUser(String firstName, String lastName, String email, String userName, String password,
String
confirmPassword) throws IOException {
WebElement firstNameField = driver.findElement(By.xpath(
uiElementMapper.getElement("iot.user.add.input.firstname.xpath")));
WebElement lastNameField = driver.findElement(By.xpath(
uiElementMapper.getElement("iot.user.add.input.lastname.xpath")));
WebElement emailField = driver.findElement(By.xpath(
uiElementMapper.getElement("iot.user.add.input.email.xpath")));
WebElement userNameField = driver.findElement(By.xpath(
uiElementMapper.getElement("iot.user.add.input.username.xpath")));
WebElement passwordField = driver.findElement(By.xpath(
uiElementMapper.getElement("iot.user.add.input.password.xpath")));
WebElement passwordConfirmationField = driver.findElement(By.xpath(
uiElementMapper.getElement("iot.user.add.input.confirmpassword.xpath")));
String confirmPassword) throws IOException {
handleAction(firstName, lastName, email, userName, password, confirmPassword);
return new LoginPage(driver);
}
/**
* Following method is to validate the user registration form.
* */
public void validateForm(String firstName, String lastName, String email, String userName,
String password, String confirmPassword) {
handleAction(firstName, lastName, email, userName, password, confirmPassword);
}
public void handleAction(String firstName, String lastName, String email, String userName, String password,
String confirmPassword) {
clearForm();
firstNameField.sendKeys(firstName);
lastNameField.sendKeys(lastName);
emailField.sendKeys(email);
userNameField.sendKeys(userName);
passwordField.sendKeys(password);
passwordConfirmationField.sendKeys(confirmPassword);
driver.findElement(By.xpath(uiElementMapper.getElement("iot.user.add.register.button.xpath"))).click();
return new LoginPage(driver);
registerButton.click();
}
public void clearForm() {
firstNameField.clear();
lastNameField.clear();
emailField.clear();
userNameField.clear();
passwordField.clear();
passwordConfirmationField.clear();
}
}

@ -21,8 +21,5 @@ public class UserAddedConfirmationPage {
this.uiElementMapper = UIElementMapper.getInstance();
driver.findElement(By.xpath(uiElementMapper.getElement("iot.admin.addUser.view.btn.xpath"))).click();
}
}

@ -20,6 +20,9 @@ package org.wso2.iot.integration.ui.pages.uesr;
import org.openqa.selenium.By;
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.wso2.iot.integration.ui.pages.UIConstants;
import org.wso2.iot.integration.ui.pages.UIElementMapper;
import java.io.IOException;
@ -39,18 +42,23 @@ public class UserListingPage {
/**
* @return After deleting a user, returns back to the user listing page.
*/
//Don't use generic exceptions.
public UserListingPage deleteUser() throws IOException, InterruptedException {
public UserListingPage deleteUser() throws IOException {
WebElement deleteBtn = driver.findElement(By.xpath(
uiElementMapper.getElement("iot.admin.deleteUser.btn.xpath")));
if (deleteBtn != null) {
WebDriverWait wait = new WebDriverWait(driver, UIConstants.webDriverTimeOut);
wait.until(ExpectedConditions.visibilityOf(deleteBtn));
deleteBtn.click();
} else {
return new UserListingPage(driver);
}
driver.findElement(By.xpath(uiElementMapper.getElement("iot.admin.deleteUser.yes.link.xpath"))).click();
Thread.sleep(1000);
driver.findElement(By.xpath(uiElementMapper.getElement("iot.admin.deleteUser.success.link.xpath"))).click();
WebElement deleteConfirmationBtn = driver.findElement(
By.xpath(uiElementMapper.getElement("iot.admin.deleteUser.yes.link.xpath")));
wait.until(ExpectedConditions.visibilityOf(deleteConfirmationBtn));
deleteConfirmationBtn.click();
WebElement deleteSuccessBtn = driver.findElement(
By.xpath(uiElementMapper.getElement("iot.admin.deleteUser.success.link.xpath")));
wait.until(ExpectedConditions.visibilityOf(deleteSuccessBtn));
deleteSuccessBtn.click();
return new UserListingPage(driver);
}

@ -25,7 +25,4 @@ public class ViewUserPage {
throw new IllegalStateException("This is not the User view page");
}
}
}

@ -48,9 +48,9 @@
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
</suiteXmlFiles>
<!--<skipTests>${skipUiTests}</skipTests>-->
<systemProperties>
<skipTests>true</skipTests>
<property>
<name>maven.test.haltafterfailure</name>
<value>false</value>
@ -245,30 +245,6 @@
</execution>
</executions>
</plugin>
<!--<plugin>-->
<!--<groupId>org.apache.maven.plugins</groupId>-->
<!--<artifactId>maven-antrun-plugin</artifactId>-->
<!--<executions>-->
<!--<execution>-->
<!--<id>Test.Connected.Cup</id>-->
<!--<phase>compile</phase>-->
<!--<goals>-->
<!--<goal>run</goal>-->
<!--</goals>-->
<!--<configuration>-->
<!--<tasks>-->
<!--<echo message="********************** installing ************************"/>-->
<!--&lt;!&ndash;<property name="tempDir" refid="**/wso2iots-1.0.0-SNAPSHOT"/>&ndash;&gt;-->
<!--<ant antfile="${basedir}/src/test/resources/build.xml">-->
<!--<target name="mvn clean"/>-->
<!--<target name="mvn clean package"/>-->
<!--</ant>-->
<!--</tasks>-->
<!--</configuration>-->
<!--</execution>-->
<!--</executions>-->
<!--<version>1.8</version>-->
<!--</plugin>-->
</plugins>
</build>
@ -291,8 +267,5 @@
</dependency>
</dependencies>
<properties>
<skipUiTests>true</skipUiTests>
</properties>
</project>

@ -25,7 +25,7 @@ import javax.xml.xpath.XPathExpressionException;
import java.io.IOException;
/**
* This class is used to login to the system as the Admin.
* This class is used to login to the server as the Admin.
*/
public class LoginUtils {
@ -43,6 +43,4 @@ public class LoginUtils {
test.loginAsAdmin(automationContext.getSuperTenant().getTenantAdmin().getUserName(),
automationContext.getSuperTenant().getTenantAdmin().getPassword());
}
}

@ -1,7 +0,0 @@
package org.wso2.carbon.iot.integration.web.ui.test;
/**
* Created by menaka on 2/23/16.
*/
public class TestRestartServer {
}

@ -31,6 +31,9 @@ import org.wso2.iot.integration.ui.pages.groups.DeviceAddGroupPage;
import org.wso2.iot.integration.ui.pages.groups.DeviceGroupsPage;
import org.wso2.iot.integration.ui.pages.home.IOTAdminDashboard;
import javax.xml.xpath.XPathExpressionException;
import java.io.IOException;
/**
* Test cases for grouping feature of IOT server.
*/
@ -47,13 +50,13 @@ public class DeviceGroupTest extends IOTIntegrationUIBaseTestCase {
}
@Test(description = "Test for adding a new device group.")
public void addNewGroupTest() throws Exception {
public void addNewGroupTest() throws IOException {
DeviceAddGroupPage addGroupPage = adminDashboard.addGroup();
addGroupPage.addNewGroup("group1", "This is test group");
}
@Test(description = "Check whether the created group exists", dependsOnMethods = {"addNewGroupTest"})
public void isGroupCreatedTest() throws Exception {
public void isGroupCreatedTest() throws IOException, XPathExpressionException {
driver.get(getWebAppURL() + Constants.IOT_HOME_URL);
DeviceGroupsPage groupsPage = adminDashboard.viewGroups();
Assert.assertTrue(groupsPage.isGroupCreated("group1"));
@ -63,5 +66,4 @@ public class DeviceGroupTest extends IOTIntegrationUIBaseTestCase {
public void tearDown() throws Exception {
driver.quit();
}
}

@ -27,6 +27,10 @@ import org.wso2.iot.integration.ui.pages.IOTIntegrationUIBaseTestCase;
import org.wso2.iot.integration.ui.pages.home.IOTAdminDashboard;
import org.wso2.iot.integration.ui.pages.login.LoginPage;
import javax.xml.stream.XMLStreamException;
import javax.xml.xpath.XPathExpressionException;
import java.io.IOException;
/**
* Test Login as Admin
*/
@ -34,14 +38,14 @@ public class LoginTest extends IOTIntegrationUIBaseTestCase {
private WebDriver driver;
@BeforeClass(alwaysRun = true)
public void setup() throws Exception {
public void setup() throws XPathExpressionException, XMLStreamException, IOException {
super.init();
driver = BrowserManager.getWebDriver();
driver.get(getWebAppURL() + Constants.IOT_LOGIN_PATH);
}
@Test(description = "Verify login to IOT server dashboard")
public void testAdminLogin() throws Exception {
public void testAdminLogin() throws IOException, XPathExpressionException {
LoginPage test = new LoginPage(driver);
IOTAdminDashboard dashboard = test.loginAsAdmin(
automationContext.getSuperTenant().getTenantAdmin().getUserName(),
@ -50,8 +54,7 @@ public class LoginTest extends IOTIntegrationUIBaseTestCase {
}
@AfterClass(alwaysRun = true)
public void tearDown() throws Exception {
driver.close();
public void tearDown(){
driver.quit();
}
}

@ -1,7 +0,0 @@
package org.wso2.carbon.iot.integration.web.ui.test.samples;
/**
* Created by menaka on 2/24/16.
*/
public class SampleInstall {
}

@ -0,0 +1,137 @@
/*
* 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.carbon.iot.integration.web.ui.test.samples;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.wso2.carbon.automation.engine.exceptions.AutomationFrameworkException;
import org.wso2.carbon.automation.extensions.servers.carbonserver.CarbonServerManager;
import org.wso2.iot.integration.ui.pages.IOTIntegrationUIBaseTestCase;
import javax.xml.stream.XMLStreamException;
import javax.xml.xpath.XPathExpressionException;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Properties;
/**
* Test cases for building and installation of sample device types.
* When installing a custom device type to the IOT server, developer has to create the device type as a feature and
* put it in to the samples folder.
* Then build the device type created with maven.
* After that install the device type by running the device-deployer.xml.
* Then the server has to be restarted, in order to activate newly installed device type.
* <p>
* In this test case, the build process of a new device type and installation to the server is tested.
*/
public class SampleInstallationTest extends IOTIntegrationUIBaseTestCase {
Log log = LogFactory.getLog(SampleInstallationTest.class);
private Process tempProcess = null;
private Properties properties = System.getProperties();
private String carbonHome = properties.getProperty("carbon.home");
private String[] cmdArray;
@BeforeClass(alwaysRun = true)
public void setup() throws XPathExpressionException, XMLStreamException, IOException, AutomationFrameworkException {
super.init();
}
@Test(description = "Verify the sample build process")
public void sampleBuildTest() throws IOException {
String connectedCupDir = carbonHome + File.pathSeparator + "samples" + File.pathSeparator + "connectedcup";
log.info("Connected cup Sample: " + connectedCupDir);
File dir = new File(connectedCupDir);
try {
if (System.getProperty("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);
} else {
log.info("Executing maven clean install --------------------------------");
cmdArray = new String[]{"mvn", "clean", "install"};
tempProcess = Runtime.getRuntime().exec(cmdArray, null, dir);
}
boolean buildStatus = waitForMessage(tempProcess.getInputStream(), "BUILD SUCCESS");
Assert.assertTrue(buildStatus, "Building the sample was not successful");
} finally {
if (tempProcess != null) {
tempProcess.destroy();
}
}
}
@Test(description = "Verify the sample installation process", dependsOnMethods = {"sampleBuildTest"})
public void sampleInstallationTest() throws IOException {
log.info("CARBON_HOME: " + System.getProperty("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")) {
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");
Assert.assertTrue(buildStatus, "Sample installation was not successful");
} finally {
if (tempProcess != null) {
tempProcess.destroy();
}
}
}
@Test(description = "Test restarting the server", dependsOnMethods = {"sampleInstallationTest"})
public void serverRestartTest() {
CarbonServerManager serverManager = new CarbonServerManager(automationContext);
try {
serverManager.restartGracefully();
} catch (AutomationFrameworkException e) {
log.error("Restart failed....");
}
}
@AfterClass(alwaysRun = true)
public void tearDown() throws Exception {
}
public boolean waitForMessage(InputStream inputStream, String message) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(inputStream));
String line;
boolean status = false;
while ((line = br.readLine()) != null) {
log.info(line);
if (!status && line.contains(message)) {
status = true;
}
}
return status;
}
}

@ -43,16 +43,16 @@ import java.io.IOException;
* 5. Empty email
* 6. Incorrect email
*/
public class AddUserFailTest extends IOTIntegrationUIBaseTestCase {
public class AddUserFormValidationTest extends IOTIntegrationUIBaseTestCase {
private WebDriver driver;
UIElementMapper uiElementMapper;
private UIElementMapper uiElementMapper;
WebElement firstNameField;
WebElement lastNameField;
WebElement emailField;
WebElement userNameField;
WebElement addUserButton;
private WebElement firstNameField;
private WebElement lastNameField;
private WebElement emailField;
private WebElement userNameField;
private WebElement addUserButton;
@BeforeClass(alwaysRun = true)
public void setup() throws XPathExpressionException, XMLStreamException, IOException {
@ -60,7 +60,6 @@ public class AddUserFailTest extends IOTIntegrationUIBaseTestCase {
driver = BrowserManager.getWebDriver();
LoginUtils.login(driver, automationContext, getWebAppURL());
driver.get(getWebAppURL() + Constants.IOT_USER_ADD_URL);
uiElementMapper = UIElementMapper.getInstance();
userNameField = driver.findElement(By.id(uiElementMapper.getElement("iot.admin.addUser.username.id")));
@ -72,7 +71,7 @@ public class AddUserFailTest extends IOTIntegrationUIBaseTestCase {
}
@Test(description = "Test for empty form submission")
public void emptyFormTest() throws Exception {
public void emptyFormTest(){
clearForm();
firstNameField.sendKeys("");
@ -88,7 +87,7 @@ public class AddUserFailTest extends IOTIntegrationUIBaseTestCase {
}
@Test(description = "Test for short user name")
public void shortUserNameTest() throws Exception {
public void shortUserNameTest() {
clearForm();
firstNameField.sendKeys("User");
@ -104,7 +103,7 @@ public class AddUserFailTest extends IOTIntegrationUIBaseTestCase {
}
@Test(description = "Test for empty first name")
public void emptyFirstNameTest() throws Exception {
public void emptyFirstNameTest() {
clearForm();
firstNameField.sendKeys("");
@ -120,7 +119,7 @@ public class AddUserFailTest extends IOTIntegrationUIBaseTestCase {
}
@Test(description = "Test for empty last name")
public void emptyLastNameTest() throws Exception {
public void emptyLastNameTest() {
clearForm();
firstNameField.sendKeys("User");
@ -135,7 +134,7 @@ public class AddUserFailTest extends IOTIntegrationUIBaseTestCase {
}
@Test(description = "Test for empty email name")
public void emptyEmailTest() throws Exception {
public void emptyEmailTest() {
clearForm();
firstNameField.sendKeys("User");
@ -151,7 +150,7 @@ public class AddUserFailTest extends IOTIntegrationUIBaseTestCase {
}
@Test(description = "Test for incorrect email")
public void incorrectEmailTest() throws Exception {
public void incorrectEmailTest() {
clearForm();
firstNameField.sendKeys("User");
@ -164,7 +163,6 @@ public class AddUserFailTest extends IOTIntegrationUIBaseTestCase {
Assert.assertEquals(driver.findElement(By.xpath(
uiElementMapper.getElement("iot.admin.addUser.formError.xpath"))).getText(),
"Provided email is invalid. Please check.");
}
private void clearForm() {
@ -175,8 +173,7 @@ public class AddUserFailTest extends IOTIntegrationUIBaseTestCase {
}
@AfterClass(alwaysRun = true)
public void tearDown() throws Exception {
public void tearDown() {
driver.quit();
}
}

@ -37,9 +37,9 @@ import java.io.IOException;
/**
* Test for registering a new user and login
*/
public class RegisterTest extends IOTIntegrationUIBaseTestCase {
public class NewUserRegistrationTest extends IOTIntegrationUIBaseTestCase {
private WebDriver driver;
UIElementMapper uiElementMapper;
private UIElementMapper uiElementMapper;
@BeforeClass(alwaysRun = true)
public void setup() throws XPathExpressionException, XMLStreamException, IOException {
@ -50,10 +50,10 @@ public class RegisterTest extends IOTIntegrationUIBaseTestCase {
@Test(description = "Verify new User registration")
public void userRegisterTest() throws IOException {
LoginPage test = new LoginPage(driver);
LoginPage loginPage = new LoginPage(driver);
uiElementMapper = UIElementMapper.getInstance();
NewUserRegisterPage registerTest = test.registerNewUser();
LoginPage loginPage = registerTest.registerUser(
NewUserRegisterPage registerTest = loginPage.registerNewUser();
loginPage = registerTest.registerUser(
uiElementMapper.getElement("iot.user.add.firstname"),
uiElementMapper.getElement("iot.user.add.lastname"),
uiElementMapper.getElement("iot.user.add.email"),
@ -65,10 +65,13 @@ public class RegisterTest extends IOTIntegrationUIBaseTestCase {
uiElementMapper.getElement("iot.user.add.password"));
Assert.assertTrue(homePage.checkUserName());
}
@Test(description = "Test user logout function", dependsOnMethods = {"userRegisterTest"})
public void logoutTest() throws IOException {
IOTHomePage homePage = new IOTHomePage(driver);
homePage.logout();
driver.close();
Assert.assertEquals(driver.getTitle(), "Login | IoT Server");
}
@AfterClass(alwaysRun = true)

@ -19,9 +19,6 @@ package org.wso2.carbon.iot.integration.web.ui.test.user;
import org.openqa.selenium.By;
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.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
@ -30,6 +27,7 @@ import org.wso2.carbon.automation.extensions.selenium.BrowserManager;
import org.wso2.carbon.iot.integration.web.ui.test.Constants;
import org.wso2.iot.integration.ui.pages.IOTIntegrationUIBaseTestCase;
import org.wso2.iot.integration.ui.pages.UIElementMapper;
import org.wso2.iot.integration.ui.pages.uesr.NewUserRegisterPage;
import javax.xml.stream.XMLStreamException;
import javax.xml.xpath.XPathExpressionException;
@ -44,54 +42,22 @@ import java.io.IOException;
*/
public class RegistrationFormValidationTests extends IOTIntegrationUIBaseTestCase {
private WebDriver driver;
UIElementMapper uiElementMapper;
WebElement firstNameField;
WebElement lastNameField;
WebElement emailField;
WebElement userNameField;
WebElement passwordField;
WebElement passwordConfirmationField;
WebElement registerButton;
private UIElementMapper uiElementMapper;
private NewUserRegisterPage registerPage;
@BeforeClass(alwaysRun = true)
public void setup() throws XPathExpressionException, XMLStreamException, IOException {
super.init();
driver = BrowserManager.getWebDriver();
driver.get(getWebAppURL() + Constants.IOT_USER_REGISTER_URL);
registerPage = new NewUserRegisterPage(driver);
uiElementMapper = UIElementMapper.getInstance();
WebDriverWait wait = new WebDriverWait(driver, 10);
wait.until(ExpectedConditions.titleContains("Register | IoT Server"));
firstNameField = driver.findElement(By.xpath(
uiElementMapper.getElement("iot.user.add.input.firstname.xpath")));
lastNameField = driver.findElement(By.xpath(
uiElementMapper.getElement("iot.user.add.input.lastname.xpath")));
emailField = driver.findElement(By.xpath(
uiElementMapper.getElement("iot.user.add.input.email.xpath")));
userNameField = driver.findElement(By.xpath(
uiElementMapper.getElement("iot.user.add.input.username.xpath")));
passwordField = driver.findElement(By.xpath(
uiElementMapper.getElement("iot.user.add.input.password.xpath")));
passwordConfirmationField = driver.findElement(By.xpath(
uiElementMapper.getElement("iot.user.add.input.confirmpassword.xpath")));
registerButton = driver.findElement(By.xpath(
uiElementMapper.getElement("iot.user.add.register.button.xpath")));
}
@Test(description = "Test for submitting an empty registration form")
public void emptyFormTest() {
clearForm();
firstNameField.sendKeys("");
lastNameField.sendKeys("");
emailField.sendKeys("");
userNameField.sendKeys("");
passwordField.sendKeys("");
passwordConfirmationField.sendKeys("");
registerButton.click();
public void emptyFormTest() throws IOException {
registerPage.clearForm();
registerPage.validateForm("", "", "", "", "", "");
Assert.assertEquals(driver.findElement(By.id(
uiElementMapper.getElement("iot.user.register.firstname.error"))).getText(),
@ -115,15 +81,7 @@ public class RegistrationFormValidationTests extends IOTIntegrationUIBaseTestCas
@Test(description = "Test for non matching passwords")
public void nonMatchingPasswordTest() {
clearForm();
firstNameField.sendKeys("User");
lastNameField.sendKeys("User");
emailField.sendKeys("user@user.com");
userNameField.sendKeys("user");
passwordField.sendKeys("user123");
passwordConfirmationField.sendKeys("user234");
registerButton.click();
registerPage.validateForm("user", "user", "user@wso2.com", "user1", "password", "Password");
Assert.assertEquals(driver.findElement(By.id(
uiElementMapper.getElement("iot.user.register.confirmPassword.error"))).getText(),
@ -132,12 +90,7 @@ public class RegistrationFormValidationTests extends IOTIntegrationUIBaseTestCas
@Test(description = "Test for email")
public void incorrectEmailTest() {
clearForm();
firstNameField.sendKeys("User");
lastNameField.sendKeys("User");
emailField.sendKeys("user.com");
registerButton.click();
registerPage.validateForm("user", "user", "user123", "user1", "password", "password");
Assert.assertEquals(driver.findElement(By.id(
uiElementMapper.getElement("iot.user.register.email.error"))).getText(),
@ -146,16 +99,7 @@ public class RegistrationFormValidationTests extends IOTIntegrationUIBaseTestCas
@Test(description = "Test for password length")
public void passwordLengthTest() {
clearForm();
firstNameField.sendKeys("User");
lastNameField.sendKeys("User");
emailField.sendKeys("user@user.com");
userNameField.sendKeys("user");
passwordField.sendKeys("user");
registerButton.click();
registerPage.validateForm("user", "user", "user@wso2.com", "user1", "passw", "passw");
Assert.assertEquals(driver.findElement(By.id(
uiElementMapper.getElement("iot.user.register.password.error"))).getText(),
"Password should be between 5 and 30 characters.");
@ -166,12 +110,5 @@ public class RegistrationFormValidationTests extends IOTIntegrationUIBaseTestCas
driver.quit();
}
public void clearForm() {
firstNameField.clear();
lastNameField.clear();
emailField.clear();
userNameField.clear();
passwordField.clear();
passwordConfirmationField.clear();
}
}

@ -134,26 +134,6 @@ public class ConnectedCupMQTTConnector extends MQTTTransportHandler {
String[] messageData = mqttMessage.toString().split(":");
Float value = Float.valueOf(messageData[1]);
// if (actualMessage.contains("PUBLISHER")) {
// float temperature = Float.parseFloat(actualMessage.split(":")[2]);
//
// if (!ConnectedCupServiceUtils.publishToDAS(owner, deviceId, messageData[0], value)) {
// log.error("MQTT Subscriber: Publishing data to DAS failed.");
// }
//
// if (log.isDebugEnabled()) {
// log.debug("MQTT Subscriber: Published data to DAS successfully.");
// }
//
// } else if (actualMessage.contains("TEMPERATURE")) {
// String temperatureValue = actualMessage.split(":")[1];
// SensorDataManager.getInstance().setSensorRecord(deviceId, ConnectedCupConstants.SENSOR_TEMPERATURE,
// temperatureValue,
// Calendar.getInstance().getTimeInMillis());
// }
//
//
switch(messageData[0]) {
case "temperature":
SensorDataManager.getInstance().setSensorRecord(deviceId, ConnectedCupConstants.SENSOR_TEMPERATURE,

Loading…
Cancel
Save