From 934b4706d4b6e640b64c97f8b5a4ce86460377f9 Mon Sep 17 00:00:00 2001 From: Menaka Jayawardena Date: Wed, 7 Dec 2016 13:16:49 +0530 Subject: [PATCH 1/5] Modified designer.json to share query parameters in portal. --- modules/analytics/distribution/src/ues/designer.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/analytics/distribution/src/ues/designer.json b/modules/analytics/distribution/src/ues/designer.json index 3cce8451..b405b6b8 100644 --- a/modules/analytics/distribution/src/ues/designer.json +++ b/modules/analytics/distribution/src/ues/designer.json @@ -62,5 +62,8 @@ "hostname": "localhost", "port": "", "protocol": "" + }, + "queryParameters" : { + "passBetweenPages" : ["shared", "owner", "deviceId"] } } From 284c221056a8e5cdba5284e904a95b7c3acd2d7c Mon Sep 17 00:00:00 2001 From: Menaka Jayawardena Date: Fri, 6 Jan 2017 14:16:36 +0530 Subject: [PATCH 2/5] Changed the integration pom version to 3.0.1-SNAPSHOT. --- modules/integration/pom.xml | 6 +++--- modules/integration/tests-artifacts/pom.xml | 2 +- .../integration/tests-common/admin-clients/pom.xml | 2 +- .../tests-common/integration-test-utils/pom.xml | 2 +- modules/integration/tests-common/pom.xml | 2 +- modules/integration/tests-common/ui-pages/pom.xml | 2 +- .../integration/tests-common/web-ui-pages/pom.xml | 2 +- modules/integration/tests-integration-old/pom.xml | 2 +- modules/integration/tests-integration/pom.xml | 2 +- modules/integration/tests-iot-web-ui/pom.xml | 12 ++++++------ modules/integration/tests-platform/pom.xml | 2 +- modules/integration/tests-ui-integration/pom.xml | 2 +- 12 files changed, 19 insertions(+), 19 deletions(-) diff --git a/modules/integration/pom.xml b/modules/integration/pom.xml index f33b2e01..0e081ed9 100644 --- a/modules/integration/pom.xml +++ b/modules/integration/pom.xml @@ -23,7 +23,7 @@ org.wso2.iot wso2iot-parent - 1.0.0-SNAPSHOT + 3.0.1-SNAPSHOT ../../pom.xml @@ -35,8 +35,8 @@ tests-artifacts tests-common - tests-integration - tests-ui-integration + + tests-iot-web-ui diff --git a/modules/integration/tests-artifacts/pom.xml b/modules/integration/tests-artifacts/pom.xml index e33dc24c..821347eb 100644 --- a/modules/integration/tests-artifacts/pom.xml +++ b/modules/integration/tests-artifacts/pom.xml @@ -22,7 +22,7 @@ org.wso2.iot wso2iot-integration - 1.0.0-SNAPSHOT + 3.0.1-SNAPSHOT ../pom.xml diff --git a/modules/integration/tests-common/admin-clients/pom.xml b/modules/integration/tests-common/admin-clients/pom.xml index d7554600..b914a906 100644 --- a/modules/integration/tests-common/admin-clients/pom.xml +++ b/modules/integration/tests-common/admin-clients/pom.xml @@ -22,7 +22,7 @@ org.wso2.iot tests-common - 1.0.0-SNAPSHOT + 3.0.1-SNAPSHOT ../pom.xml diff --git a/modules/integration/tests-common/integration-test-utils/pom.xml b/modules/integration/tests-common/integration-test-utils/pom.xml index 7894bec2..066ecd95 100644 --- a/modules/integration/tests-common/integration-test-utils/pom.xml +++ b/modules/integration/tests-common/integration-test-utils/pom.xml @@ -22,7 +22,7 @@ org.wso2.iot tests-common - 1.0.0-SNAPSHOT + 3.0.1-SNAPSHOT ../pom.xml diff --git a/modules/integration/tests-common/pom.xml b/modules/integration/tests-common/pom.xml index a9d2d3cc..8bb599fe 100644 --- a/modules/integration/tests-common/pom.xml +++ b/modules/integration/tests-common/pom.xml @@ -21,7 +21,7 @@ org.wso2.iot wso2iot-integration - 1.0.0-SNAPSHOT + 3.0.1-SNAPSHOT ../pom.xml diff --git a/modules/integration/tests-common/ui-pages/pom.xml b/modules/integration/tests-common/ui-pages/pom.xml index cdc008aa..eac92118 100644 --- a/modules/integration/tests-common/ui-pages/pom.xml +++ b/modules/integration/tests-common/ui-pages/pom.xml @@ -24,7 +24,7 @@ org.wso2.iot tests-common - 1.0.0-SNAPSHOT + 3.0.1-SNAPSHOT ../pom.xml diff --git a/modules/integration/tests-common/web-ui-pages/pom.xml b/modules/integration/tests-common/web-ui-pages/pom.xml index 818cf2a5..e0267440 100644 --- a/modules/integration/tests-common/web-ui-pages/pom.xml +++ b/modules/integration/tests-common/web-ui-pages/pom.xml @@ -24,7 +24,7 @@ org.wso2.iot tests-common - 1.0.0-SNAPSHOT + 3.0.1-SNAPSHOT ../pom.xml diff --git a/modules/integration/tests-integration-old/pom.xml b/modules/integration/tests-integration-old/pom.xml index 6c558cce..40c53944 100644 --- a/modules/integration/tests-integration-old/pom.xml +++ b/modules/integration/tests-integration-old/pom.xml @@ -23,7 +23,7 @@ org.wso2.iot wso2iot-integration - 1.0.0-SNAPSHOT + 3.0.1-SNAPSHOT ../pom.xml diff --git a/modules/integration/tests-integration/pom.xml b/modules/integration/tests-integration/pom.xml index 6c558cce..40c53944 100644 --- a/modules/integration/tests-integration/pom.xml +++ b/modules/integration/tests-integration/pom.xml @@ -23,7 +23,7 @@ org.wso2.iot wso2iot-integration - 1.0.0-SNAPSHOT + 3.0.1-SNAPSHOT ../pom.xml diff --git a/modules/integration/tests-iot-web-ui/pom.xml b/modules/integration/tests-iot-web-ui/pom.xml index 64f14a1e..84e6b404 100644 --- a/modules/integration/tests-iot-web-ui/pom.xml +++ b/modules/integration/tests-iot-web-ui/pom.xml @@ -22,7 +22,7 @@ org.wso2.iot wso2iot-integration - 1.0.0-SNAPSHOT + 3.0.1-SNAPSHOT ../pom.xml @@ -62,7 +62,7 @@ carbon.zip - ${basedir}/../../distribution/target/wso2iots-${project.version}.zip + ${basedir}/../../distribution/target/wso2iot-${project.version}.zip @@ -131,7 +131,7 @@ org.wso2.iot - wso2iots + wso2iot ${project.version} zip true @@ -171,7 +171,7 @@ - ${basedir}/target/tobeCopied/wso2iots-${project.version}/repository/resources/security/ + ${basedir}/target/tobeCopied/wso2iot-${project.version}/repository/resources/security/ **/*.jks @@ -192,7 +192,7 @@ - ${basedir}/target/tobeCopied/wso2iots-${project.version}/repository/resources/security/ + ${basedir}/target/tobeCopied/wso2iot-${project.version}/repository/resources/security/ **/*.jks @@ -213,7 +213,7 @@ - ${basedir}/target/tobeCopied/wso2iots-${project.version}/repository/conf/axis2/ + ${basedir}/target/tobeCopied/wso2iot-${project.version}/repository/conf/axis2/ **/*.xml diff --git a/modules/integration/tests-platform/pom.xml b/modules/integration/tests-platform/pom.xml index 459c0451..6c9618b8 100644 --- a/modules/integration/tests-platform/pom.xml +++ b/modules/integration/tests-platform/pom.xml @@ -21,7 +21,7 @@ org.wso2.iot wso2iot-integration - 1.0.0-SNAPSHOT + 3.0.1-SNAPSHOT ../pom.xml diff --git a/modules/integration/tests-ui-integration/pom.xml b/modules/integration/tests-ui-integration/pom.xml index be445685..2852c1b2 100644 --- a/modules/integration/tests-ui-integration/pom.xml +++ b/modules/integration/tests-ui-integration/pom.xml @@ -22,7 +22,7 @@ org.wso2.iot wso2iot-integration - 1.0.0-SNAPSHOT + 3.0.1-SNAPSHOT ../pom.xml From 88e696b4e95a5608e62d14dafffdcf420d6dcd1f Mon Sep 17 00:00:00 2001 From: Menaka Jayawardena Date: Fri, 6 Jan 2017 14:18:58 +0530 Subject: [PATCH 3/5] Adding custom Test Automation Extensions to start up the servers. --- .../extension/AnalyticsServerExtension.java | 89 +++++++++++ .../test/extension/BrokerServerExtension.java | 89 +++++++++++ .../extension/CustomTestServerManager.java | 147 ++++++++++++++++++ .../ui/test/extension/IOTServerExtension.java | 89 +++++++++++ .../src/test/resources/automation.xml | 8 +- 5 files changed, 420 insertions(+), 2 deletions(-) create mode 100644 modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/extension/AnalyticsServerExtension.java create mode 100644 modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/extension/BrokerServerExtension.java create mode 100644 modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/extension/CustomTestServerManager.java create mode 100644 modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/extension/IOTServerExtension.java diff --git a/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/extension/AnalyticsServerExtension.java b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/extension/AnalyticsServerExtension.java new file mode 100644 index 00000000..03bdca0e --- /dev/null +++ b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/extension/AnalyticsServerExtension.java @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2017, 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.extension; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.automation.engine.annotations.ExecutionEnvironment; +import org.wso2.carbon.automation.engine.context.AutomationContext; +import org.wso2.carbon.automation.engine.context.ContextXpathConstants; +import org.wso2.carbon.automation.engine.context.TestUserMode; +import org.wso2.carbon.automation.engine.exceptions.AutomationFrameworkException; +import org.wso2.carbon.automation.engine.extensions.ExecutionListenerExtension; +import org.wso2.carbon.automation.extensions.ExtensionConstants; +import org.wso2.carbon.automation.extensions.servers.carbonserver.CarbonServerExtension; + +import javax.xml.xpath.XPathExpressionException; + +/** + * Test Automation server extension to start the DAS. + * This will set the carbon_home to {carbonHome}/core and port offset : 2 + */ +public class AnalyticsServerExtension extends ExecutionListenerExtension { + + private CustomTestServerManager serverManager; + private static final Log log = LogFactory.getLog(CarbonServerExtension.class); + private String executionEnvironment; + private AutomationContext automationContext; + + + @Override + public void initiate() throws AutomationFrameworkException { + try { + automationContext = new AutomationContext("IOT", TestUserMode.SUPER_TENANT_USER); + if(getParameters().get(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND) == null) { + getParameters().put(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND, "2"); + } + serverManager = new CustomTestServerManager(getAutomationContext(), null, getParameters()); + executionEnvironment = + automationContext.getConfigurationValue(ContextXpathConstants.EXECUTION_ENVIRONMENT); + + } catch (XPathExpressionException e) { + handleException("Error while initiating test environment", e); + } + } + + @Override + public void onExecutionStart() throws AutomationFrameworkException { + try { + if (executionEnvironment.equalsIgnoreCase(ExecutionEnvironment.STANDALONE.name())) { + String carbonHome = serverManager.startServer("analytics"); + log.info(carbonHome); + System.setProperty(ExtensionConstants.CARBON_HOME, carbonHome); + } + } catch (Exception e) { + handleException("Fail to start carbon server ", e); + } + } + + @Override + public void onExecutionFinish() throws AutomationFrameworkException { + try { + if (executionEnvironment.equalsIgnoreCase(ExecutionEnvironment.STANDALONE.name())) { + serverManager.stopServer(); + } + } catch (Exception e) { + handleException("Fail to stop carbon server ", e); + } + } + + private static void handleException(String msg, Exception e) { + log.error(msg, e); + throw new RuntimeException(msg, e); + } +} diff --git a/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/extension/BrokerServerExtension.java b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/extension/BrokerServerExtension.java new file mode 100644 index 00000000..d9657b41 --- /dev/null +++ b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/extension/BrokerServerExtension.java @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2017, 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.extension; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.automation.engine.annotations.ExecutionEnvironment; +import org.wso2.carbon.automation.engine.context.AutomationContext; +import org.wso2.carbon.automation.engine.context.ContextXpathConstants; +import org.wso2.carbon.automation.engine.context.TestUserMode; +import org.wso2.carbon.automation.engine.exceptions.AutomationFrameworkException; +import org.wso2.carbon.automation.engine.extensions.ExecutionListenerExtension; +import org.wso2.carbon.automation.extensions.ExtensionConstants; +import org.wso2.carbon.automation.extensions.servers.carbonserver.CarbonServerExtension; + +import javax.xml.xpath.XPathExpressionException; + +/** + * Test Automation server extension to start the Broker. + * This will set the carbon_home to {carbonHome}/core and port offset : 3 + */ +public class BrokerServerExtension extends ExecutionListenerExtension { + + private CustomTestServerManager serverManager; + private static final Log log = LogFactory.getLog(CarbonServerExtension.class); + private String executionEnvironment; + private AutomationContext automationContext; + + + @Override + public void initiate() throws AutomationFrameworkException { + try { + automationContext = new AutomationContext("IOT", TestUserMode.SUPER_TENANT_USER); + if(getParameters().get(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND) == null) { + getParameters().put(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND, "3"); + } + serverManager = new CustomTestServerManager(getAutomationContext(), null, getParameters()); + executionEnvironment = + automationContext.getConfigurationValue(ContextXpathConstants.EXECUTION_ENVIRONMENT); + + } catch (XPathExpressionException e) { + handleException("Error while initiating test environment", e); + } + } + + @Override + public void onExecutionStart() throws AutomationFrameworkException { + try { + if (executionEnvironment.equalsIgnoreCase(ExecutionEnvironment.STANDALONE.name())) { + String carbonHome = serverManager.startServer("broker"); + log.info(carbonHome); + System.setProperty(ExtensionConstants.CARBON_HOME, carbonHome); + } + } catch (Exception e) { + handleException("Fail to start carbon server ", e); + } + } + + @Override + public void onExecutionFinish() throws AutomationFrameworkException { + try { + if (executionEnvironment.equalsIgnoreCase(ExecutionEnvironment.STANDALONE.name())) { + serverManager.stopServer(); + } + } catch (Exception e) { + handleException("Fail to stop carbon server ", e); + } + } + + private static void handleException(String msg, Exception e) { + log.error(msg, e); + throw new RuntimeException(msg, e); + } +} diff --git a/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/extension/CustomTestServerManager.java b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/extension/CustomTestServerManager.java new file mode 100644 index 00000000..fa9c34d8 --- /dev/null +++ b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/extension/CustomTestServerManager.java @@ -0,0 +1,147 @@ +/* +* Copyright (c) 2005-2017, 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.extension; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.automation.engine.FrameworkConstants; +import org.wso2.carbon.automation.engine.context.AutomationContext; +import org.wso2.carbon.automation.engine.exceptions.AutomationFrameworkException; +import org.wso2.carbon.automation.extensions.ExtensionConstants; +import org.wso2.carbon.automation.extensions.servers.carbonserver.CarbonServerManager; + +import javax.xml.xpath.XPathExpressionException; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +public class CustomTestServerManager { + protected CarbonServerManager carbonServer; + protected String carbonZip; + protected int portOffset; + protected Map commandMap = new HashMap(); + private static final Log log = LogFactory.getLog(CustomTestServerManager.class); + protected String carbonHome; + + public CustomTestServerManager(AutomationContext context) { + carbonServer = new CarbonServerManager(context); + } + + public CustomTestServerManager(AutomationContext context, String carbonZip) { + carbonServer = new CarbonServerManager(context); + this.carbonZip = carbonZip; + } + + public CustomTestServerManager(AutomationContext context, int portOffset) { + carbonServer = new CarbonServerManager(context); + this.portOffset = portOffset; + commandMap.put(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND, String.valueOf(portOffset)); + } + + public CustomTestServerManager(AutomationContext context, String carbonZip, + Map commandMap) { + carbonServer = new CarbonServerManager(context); + this.carbonZip = carbonZip; + if (commandMap.get(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND) != null) { + this.portOffset = Integer.parseInt(commandMap.get(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND)); + } else { + throw new IllegalArgumentException("portOffset value must be set in command list"); + } + this.commandMap = commandMap; + } + + public String getCarbonZip() { + return carbonZip; + } + + public String getCarbonHome() { + return carbonHome; + } + + public int getPortOffset() { + return portOffset; + } + + public void configureServer() throws AutomationFrameworkException { + + } + + + public Map getCommands() { + return commandMap; + } + + /** + * This method is called for starting a Carbon server in preparation for execution of a + * TestSuite + *

+ * Add the @BeforeSuite TestNG annotation in the method overriding this method + * @param server : The server which needs to be start. + * @return The CARBON_HOME + * @throws java.io.IOException If an error occurs while copying the deployment artifacts into the + * Carbon server + */ + public String startServer(String server) + throws AutomationFrameworkException, IOException, XPathExpressionException { + if(carbonHome == null) { + if (carbonZip == null) { + carbonZip = System.getProperty(FrameworkConstants.SYSTEM_PROPERTY_CARBON_ZIP_LOCATION); + } + if (carbonZip == null) { + throw new IllegalArgumentException("carbon zip file cannot find in the given location"); + } + carbonHome = carbonServer.setUpCarbonHome(carbonZip) + "/" + server; + configureServer(); + } + log.info("Carbon Home - " + carbonHome ); + if (commandMap.get(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND) != null) { + this.portOffset = Integer.parseInt(commandMap.get(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND)); + } else { + this.portOffset = 0; + } + carbonServer.startServerUsingCarbonHome(carbonHome, commandMap); + return carbonHome; + } + + /** + * Restarting server already started by the method startServer + * @throws AutomationFrameworkException + */ + public void restartGracefully() throws AutomationFrameworkException { + if(carbonHome == null) { + throw new AutomationFrameworkException("No Running Server found to restart. " + + "Please make sure whether server is started"); + } + carbonServer.restartGracefully(); + } + + /** + * This method is called for stopping a Carbon server + *

+ * Add the @AfterSuite annotation in the method overriding this method + * + * @throws AutomationFrameworkException If an error occurs while shutting down the server + */ + public void stopServer() throws AutomationFrameworkException { + carbonServer.serverShutdown(portOffset); + } + + + + +} diff --git a/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/extension/IOTServerExtension.java b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/extension/IOTServerExtension.java new file mode 100644 index 00000000..c7992a47 --- /dev/null +++ b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/extension/IOTServerExtension.java @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2017, 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.extension; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.automation.engine.annotations.ExecutionEnvironment; +import org.wso2.carbon.automation.engine.context.AutomationContext; +import org.wso2.carbon.automation.engine.context.ContextXpathConstants; +import org.wso2.carbon.automation.engine.context.TestUserMode; +import org.wso2.carbon.automation.engine.exceptions.AutomationFrameworkException; +import org.wso2.carbon.automation.engine.extensions.ExecutionListenerExtension; +import org.wso2.carbon.automation.extensions.ExtensionConstants; +import org.wso2.carbon.automation.extensions.servers.carbonserver.CarbonServerExtension; + +import javax.xml.xpath.XPathExpressionException; + +/** + * Test Automation server extension to start the IOT core. + * This will set the carbon_home to {carbonHome}/core and port offset : 0 + */ +public class IOTServerExtension extends ExecutionListenerExtension { + + private CustomTestServerManager serverManager; + private static final Log log = LogFactory.getLog(CarbonServerExtension.class); + private String executionEnvironment; + private AutomationContext automationContext; + + + @Override + public void initiate() throws AutomationFrameworkException { + try { + automationContext = new AutomationContext("IOT", TestUserMode.SUPER_TENANT_USER); + if(getParameters().get(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND) == null) { + getParameters().put(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND, "0"); + } + serverManager = new CustomTestServerManager(getAutomationContext(), null, getParameters()); + executionEnvironment = + automationContext.getConfigurationValue(ContextXpathConstants.EXECUTION_ENVIRONMENT); + + } catch (XPathExpressionException e) { + handleException("Error while initiating test environment", e); + } + } + + @Override + public void onExecutionStart() throws AutomationFrameworkException { + try { + if (executionEnvironment.equalsIgnoreCase(ExecutionEnvironment.STANDALONE.name())) { + String carbonHome = serverManager.startServer("core"); + log.info(carbonHome); + System.setProperty(ExtensionConstants.CARBON_HOME, carbonHome); + } + } catch (Exception e) { + handleException("Fail to start carbon server ", e); + } + } + + @Override + public void onExecutionFinish() throws AutomationFrameworkException { + try { + if (executionEnvironment.equalsIgnoreCase(ExecutionEnvironment.STANDALONE.name())) { + serverManager.stopServer(); + } + } catch (Exception e) { + handleException("Fail to stop carbon server ", e); + } + } + + private static void handleException(String msg, Exception e) { + log.error(msg, e); + throw new RuntimeException(msg, e); + } +} diff --git a/modules/integration/tests-iot-web-ui/src/test/resources/automation.xml b/modules/integration/tests-iot-web-ui/src/test/resources/automation.xml index 936e23ed..5cfb0229 100644 --- a/modules/integration/tests-iot-web-ui/src/test/resources/automation.xml +++ b/modules/integration/tests-iot-web-ui/src/test/resources/automation.xml @@ -24,7 +24,7 @@ - 60000 + 300000 @@ -172,7 +172,9 @@ 9763 + 9446 9443 + 9445 @@ -187,7 +189,9 @@ - org.wso2.carbon.automation.extensions.servers.carbonserver.CarbonServerExtension + org.wso2.carbon.iot.integration.web.ui.test.extension.BrokerServerExtension + org.wso2.carbon.iot.integration.web.ui.test.extension.IOTServerExtension + org.wso2.carbon.iot.integration.web.ui.test.extension.AnalyticsServerExtension org.wso2.carbon.integration.common.extensions.usermgt.UserPopulateExtension From 838d1cf610b262493e8266af8cef7de79f0903e8 Mon Sep 17 00:00:00 2001 From: geethkokila Date: Fri, 6 Jan 2017 17:14:00 +0530 Subject: [PATCH 4/5] Adding the ios gateway support for the iot server --- modules/core/distribution/src/assembly/bin.xml | 10 ++++++++++ .../src/repository/conf/axis2/axis2.xml | 18 ++++++++++++++++++ modules/core/p2-profile-gen/pom.xml | 11 +++++++++++ 3 files changed, 39 insertions(+) diff --git a/modules/core/distribution/src/assembly/bin.xml b/modules/core/distribution/src/assembly/bin.xml index 86a47221..43806ba1 100644 --- a/modules/core/distribution/src/assembly/bin.xml +++ b/modules/core/distribution/src/assembly/bin.xml @@ -1255,5 +1255,15 @@ true 644 + + + ../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/iot-api-config.xml + + + ${pom.artifactId}-${pom.version}/repository/conf/ + + true + 644 + diff --git a/modules/core/distribution/src/repository/conf/axis2/axis2.xml b/modules/core/distribution/src/repository/conf/axis2/axis2.xml index fbe95442..64bd8ab5 100644 --- a/modules/core/distribution/src/repository/conf/axis2/axis2.xml +++ b/modules/core/distribution/src/repository/conf/axis2/axis2.xml @@ -152,6 +152,14 @@ + + + + + + + + + + + wso2carbon + AllowAll diff --git a/modules/core/p2-profile-gen/pom.xml b/modules/core/p2-profile-gen/pom.xml index 49d6ba81..b1b305b9 100644 --- a/modules/core/p2-profile-gen/pom.xml +++ b/modules/core/p2-profile-gen/pom.xml @@ -146,6 +146,9 @@ org.wso2.carbon.devicemgt:org.wso2.carbon.apimgt.application.extension.feature:${carbon.device.mgt.version} + + org.wso2.carbon.devicemgt:org.wso2.carbon.apimgt.handler.server.feature:${carbon.device.mgt.version} + org.wso2.carbon.devicemgt:org.wso2.carbon.email.sender.feature:${carbon.device.mgt.version} @@ -891,6 +894,10 @@ org.wso2.carbon.apimgt.webapp.publisher.feature.group ${carbon.device.mgt.version} + + org.wso2.carbon.apimgt.handler.server.feature.group + ${carbon.device.mgt.version} + org.wso2.carbon.device.mgt.oauth.extensions.feature.group ${carbon.device.mgt.version} @@ -1818,6 +1825,10 @@ org.wso2.carbon.apimgt.gateway.feature.group ${carbon.api.mgt.version} + + + + org.wso2.carbon.policy.mgt.server.feature.group ${carbon.device.mgt.version} From c9ab7103d8c061cdc8a693386e097781a2a125fa Mon Sep 17 00:00:00 2001 From: Menaka Jayawardena Date: Fri, 6 Jan 2017 19:31:40 +0530 Subject: [PATCH 5/5] Fixed IOTS-360 : Modifying current ui integration tests. --- .../ui/pages/error/IOTErrorPage.java | 31 +++++++++++++ .../ui/pages/groups/DeviceAddGroupPage.java | 7 ++- .../ui/pages/groups/DeviceGroupsPage.java | 2 +- .../ui/pages/home/IOTAdminDashboard.java | 13 +++--- .../ui/pages/home/IOTHomePage.java | 2 +- .../integration/ui/pages/login/LoginPage.java | 2 +- .../ui/pages/uesr/NewUserRegisterPage.java | 2 +- .../src/main/resources/mapper.properties | 32 +++++++------ .../web/ui/test/common/Constants.java | 6 ++- .../web/ui/test/error/InitialErrorTest.java | 39 ++++++++++++++++ .../test/login/LoginFormValidationTest.java | 35 -------------- .../web/ui/test/login/LoginTest.java | 2 +- .../user/RegistrationFormValidationTest.java | 46 ++++--------------- .../src/test/resources/testng.xml | 9 ++-- 14 files changed, 122 insertions(+), 106 deletions(-) create mode 100644 modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/error/IOTErrorPage.java create mode 100644 modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/error/InitialErrorTest.java diff --git a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/error/IOTErrorPage.java b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/error/IOTErrorPage.java new file mode 100644 index 00000000..da402c96 --- /dev/null +++ b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/error/IOTErrorPage.java @@ -0,0 +1,31 @@ +package org.wso2.iot.integration.ui.pages.error; + +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.support.ui.ExpectedConditions; +import org.openqa.selenium.support.ui.WebDriverWait; +import org.wso2.iot.integration.ui.pages.UIElementMapper; +import org.wso2.iot.integration.ui.pages.UIUtils; + +import java.io.IOException; + +public class IOTErrorPage { + + private WebDriver driver; + private UIElementMapper uiElementMapper; + private boolean isErrorPage = true; + + public IOTErrorPage (WebDriver driver) throws IOException { + this.driver = driver; + this.uiElementMapper = UIElementMapper.getInstance(); + WebDriverWait webDriverWait = new WebDriverWait(driver, UIUtils.webDriverTimeOut); + + if (!webDriverWait.until(ExpectedConditions.titleContains(uiElementMapper.getElement("cdmf.error.page")))) { + isErrorPage = false; + throw new IllegalStateException("This is not the Error page"); + } + } + + public boolean isErrorPresent() { + return this.isErrorPage; + } +} diff --git a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/groups/DeviceAddGroupPage.java b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/groups/DeviceAddGroupPage.java index 1db9969d..b80d0efb 100644 --- a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/groups/DeviceAddGroupPage.java +++ b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/groups/DeviceAddGroupPage.java @@ -20,7 +20,10 @@ package org.wso2.iot.integration.ui.pages.groups; 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.UIElementMapper; +import org.wso2.iot.integration.ui.pages.UIUtils; import java.io.IOException; @@ -37,9 +40,9 @@ public class DeviceAddGroupPage { public DeviceAddGroupPage(WebDriver driver) throws IOException { this.driver = driver; this.uiElementMapper = UIElementMapper.getInstance(); + WebDriverWait webDriverWait = new WebDriverWait(driver, UIUtils.webDriverTimeOut); - if (!driver.findElement(By.xpath - (uiElementMapper.getElement("iot.device.group.addNewGroup.xpath"))).getText().contains("ADD NEW GROUP")) { + if (!webDriverWait.until(ExpectedConditions.titleContains(uiElementMapper.getElement("cdmf.groups.page")))) { throw new IllegalStateException("This is not the Add Group page"); } } diff --git a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/groups/DeviceGroupsPage.java b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/groups/DeviceGroupsPage.java index 8a6d6ac5..8a05cd55 100644 --- a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/groups/DeviceGroupsPage.java +++ b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/groups/DeviceGroupsPage.java @@ -42,7 +42,7 @@ public class DeviceGroupsPage { WebDriverWait webDriverWait = new WebDriverWait(driver, UIUtils.webDriverTimeOut); if (!webDriverWait.until(ExpectedConditions.textToBePresentInElement(driver.findElement(By.xpath( - uiElementMapper.getElement("iot.device.groups.view.header.xpath"))), "GROUPS"))) { + uiElementMapper.getElement("iot.device.groups.view.header.xpath"))), "GROUP"))) { throw new IllegalStateException("This is not the Groups page"); } } diff --git a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/home/IOTAdminDashboard.java b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/home/IOTAdminDashboard.java index 095e28fc..828e582b 100644 --- a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/home/IOTAdminDashboard.java +++ b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/home/IOTAdminDashboard.java @@ -22,7 +22,10 @@ import org.apache.commons.logging.LogFactory; 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.UIElementMapper; +import org.wso2.iot.integration.ui.pages.UIUtils; import org.wso2.iot.integration.ui.pages.devices.DevicesPage; import org.wso2.iot.integration.ui.pages.devices.EnrollDevicePage; import org.wso2.iot.integration.ui.pages.groups.DeviceAddGroupPage; @@ -51,18 +54,16 @@ import java.io.IOException; */ public class IOTAdminDashboard { - private static final Log log = LogFactory.getLog(IOTHomePage.class); + private static final Log log = LogFactory.getLog(IOTAdminDashboard.class); private WebDriver driver; private UIElementMapper uiElementMapper; public IOTAdminDashboard(WebDriver driver) throws IOException { this.driver = driver; this.uiElementMapper = UIElementMapper.getInstance(); - log.info(driver.findElement(By.xpath(uiElementMapper.getElement("iot.admin.dashboard.title.xpath"))). - getText()); - // Check that we're on the right page. - if (!driver.findElement(By.xpath(uiElementMapper.getElement("iot.admin.dashboard.title.xpath"))). - getText().contains("DASHBOARD")) { + WebDriverWait wait = new WebDriverWait(driver, UIUtils.webDriverTimeOut); + + if (!wait.until(ExpectedConditions.titleIs(uiElementMapper.getElement("cdmf.home.page")))) { throw new IllegalStateException("This is not the home page"); } } diff --git a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/home/IOTHomePage.java b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/home/IOTHomePage.java index 28998e05..58b929e9 100644 --- a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/home/IOTHomePage.java +++ b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/home/IOTHomePage.java @@ -43,7 +43,7 @@ public class IOTHomePage { this.uiElementMapper = UIElementMapper.getInstance(); // Check that we're on the right page. WebDriverWait wait = new WebDriverWait(driver, UIUtils.webDriverTimeOut); - if (!wait.until(ExpectedConditions.titleIs("Device Management | IoT Server"))) { + if (!wait.until(ExpectedConditions.titleIs(uiElementMapper.getElement("cdmf.user.home.page")))) { throw new IllegalStateException("This is not the home page"); } } diff --git a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/login/LoginPage.java b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/login/LoginPage.java index 8a23e407..91fb30c6 100644 --- a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/login/LoginPage.java +++ b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/login/LoginPage.java @@ -50,7 +50,7 @@ public class LoginPage { this.uiElementMapper = UIElementMapper.getInstance(); WebDriverWait webDriverWait = new WebDriverWait(driver, UIUtils.webDriverTimeOut); - if (!webDriverWait.until(ExpectedConditions.titleContains("Login | IoT Server"))) { + if (!webDriverWait.until(ExpectedConditions.titleContains(uiElementMapper.getElement("cdmf.login.page")))) { throw new IllegalStateException("This is not the Login page"); } userNameField = driver.findElement(By.xpath( diff --git a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/uesr/NewUserRegisterPage.java b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/uesr/NewUserRegisterPage.java index 90582de4..b40dfe51 100644 --- a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/uesr/NewUserRegisterPage.java +++ b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/uesr/NewUserRegisterPage.java @@ -49,7 +49,7 @@ public class NewUserRegisterPage { // Check that we're on the right page. WebDriverWait webDriverWait = new WebDriverWait(driver, UIUtils.webDriverTimeOut); - if (!webDriverWait.until(ExpectedConditions.titleContains("Register | IoT Server"))) { + if (!webDriverWait.until(ExpectedConditions.titleContains(uiElementMapper.getElement("cdmf.register.page")))) { throw new IllegalStateException("This is not the Register page"); } diff --git a/modules/integration/tests-common/web-ui-pages/src/main/resources/mapper.properties b/modules/integration/tests-common/web-ui-pages/src/main/resources/mapper.properties index d5ee382e..e212e65e 100644 --- a/modules/integration/tests-common/web-ui-pages/src/main/resources/mapper.properties +++ b/modules/integration/tests-common/web-ui-pages/src/main/resources/mapper.properties @@ -16,6 +16,14 @@ # under the License. # +# CDMF Page titles ----------------------------------------------------------------------------------------------------- +cdmf.home.page=Home | CDMF +cdmf.login.page=Login | CDMF +cdmf.register.page=Register | CDMF +cdmf.error.page=Error | CDMF +cdmf.user.home.page=Device Management | CDMF +cdmf.groups.page=Group Management | CDMF + # User registration and login details----------------------------------------------------------------------------------- iot.user.add.firstname=firstname @@ -27,9 +35,10 @@ iot.user.add.email=username@wso2.com iot.user.login.username=testUser iot.user.login.password=testPassword + # User registration and login ui---------------------------------------------------------------------------------------- -iot.user.registered.name=/html/body/header/div/div[2]/a/span[1] +iot.user.registered.name=/html/body/header/div/div[2]/ul/li/a/span[2] iot.user.add.input.firstname.xpath=//*[@id="first_name"] iot.user.add.input.lastname.xpath=//*[@id="last_name"] @@ -58,18 +67,13 @@ iot.home.page.title.xpath=/html/body/div[3]/div[1]/div/span iot.admin.dashboard.title.xpath=/html/body/div[3]/div[1]/div/span iot.home.enrollDevice.xpath=//*[@id="ast-container"]/div/p/a -iot.user.logout.link.xpath=/html/body/header/div/div[2]/ul/li[3]/a +iot.user.logout.link.xpath=/html/body/header/div/div[2]/ul/li/ul/li[2]/a iot.devices.table.xpath=//*[@id="device-grid"] # Register page error elements ----------------------------------------------------------------------------------------- - -iot.user.register.firstname.error=first_name-error -iot.user.register.lastname.error=last_name-error -iot.user.register.username.error=user_name-error -iot.user.register.email.error=email-error -iot.user.register.password.error=password-error -iot.user.register.confirmPassword.error=password_confirmation-error +#//*[@id="user-create-error-msg"] +iot.user.register.form.error=user-create-error-msg # Admin dashboard Device ----------------------------------------------------------------------------------------------- iot.admin.device.viewBtn.xpath=//a[@href='/devicemgt/devices'] @@ -81,13 +85,12 @@ iot.user.login.password.error=password-error iot.user.login.incorrect.xpath=/html/body/div/div/div/div[1] iot.user.login.shortPassword=password-error - iot.dashboard.device.div.xpath=/html/body/div[3]/div[7]/div[1]/div/div/div[1] #Grouping -------------------------------------------------------------------------------------------------------------- -iot.device.group.addButton.xpath=/html/body/div[3]/div[2]/div[1]/div[2]/div/div/div[2]/div[2]/span[2]/a[2] -iot.device.group.viewButton.xpath=/html/body/div[3]/div[2]/div[1]/div[2]/div/div/div[2]/div[2]/span[2]/a[1] +iot.device.group.addButton.xpath=/html/body/div[3]/div[2]/div/div[3]/div[2]/div/div[2]/div[2]/span[2]/a[2]/span/i[2] +iot.device.group.viewButton.xpath=/html/body/div[3]/div[2]/div/div[3]/div[2]/div/div[2]/div[2]/span[2]/a[1]/span/i[2] iot.device.group.addNewGroup.xpath=/html/body/div[3]/div/div[1]/div/p[1] @@ -97,9 +100,10 @@ iot.device.group.addGroupForm.name.id=name iot.device.group.addGroupForm.description.id=description iot.device.group.addGroupForm.addButton.id=add-group-btn -iot.device.groups.view.header.xpath=/html/body/div[3]/div[1]/div/span +iot.device.groups.view.header.xpath=/html/body/div[3]/div[2]/div/h1[1] -iot.device.groups.add.emptyfrom.error=/html/body/div[3]/div/div[1]/div/span/strong +#/html/body/div[3]/div[2]/div/div[3]/div/div/div[1]/label +iot.device.groups.add.emptyfrom.error=/html/body/div[3]/div[2]/div/div[3]/div/div/div[1]/label iot.device.table.id=group-grid diff --git a/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/common/Constants.java b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/common/Constants.java index 9cb594c5..4942663c 100644 --- a/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/common/Constants.java +++ b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/common/Constants.java @@ -69,12 +69,14 @@ public class Constants { public static final String USER_NAME_ERROR = "Please enter a username"; public static final String PASSWORD_ERROR = "Please provide a password"; - public static final String FAILED_ERROR = "Incorrect username or password.!"; + public static final String FAILED_ERROR = "LOGIN\n" + + "Login failed! Please recheck the username and password and try again.!\n" + "Username *\n" + + "Password *\n" + "LOGIN\n" + "Create an account"; public static final String SHORT_PASSWORD_ERROR = "Your password must be at least 3 characters long"; public static final String WRONG_USER_NAME = "admnnn"; public static final String WRONG_USER_PASSWORD = "admmmm"; public static final String SHORT_PASSWORD = "ad"; - public static final String PAGE_TITLE = "Login | IoT Server"; + public static final String PAGE_TITLE = "Login | CDMF"; } diff --git a/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/error/InitialErrorTest.java b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/error/InitialErrorTest.java new file mode 100644 index 00000000..ac7ecda6 --- /dev/null +++ b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/error/InitialErrorTest.java @@ -0,0 +1,39 @@ +package org.wso2.carbon.iot.integration.web.ui.test.error; + +import junit.framework.Assert; +import org.openqa.selenium.WebDriver; +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.IOTIntegrationUIBaseTestCase; +import org.wso2.iot.integration.ui.pages.error.IOTErrorPage; + +import javax.xml.stream.XMLStreamException; +import javax.xml.xpath.XPathExpressionException; +import java.io.IOException; + +public class InitialErrorTest extends IOTIntegrationUIBaseTestCase{ + + private WebDriver driver; + + @BeforeClass(alwaysRun = true) + public void setup() throws XPathExpressionException, XMLStreamException, IOException { + super.init(); + driver = BrowserManager.getWebDriver(); + driver.get(getWebAppURL() + Constants.IOT_LOGIN_PATH); + } + + @Test(description = "Test for initial login error.") + public void ErrorPageTest() throws IOException { + IOTErrorPage errorPage = new IOTErrorPage(driver); + Assert.assertTrue(errorPage.isErrorPresent()); + } + + @AfterClass(alwaysRun = true) + public void tearDown(){ + driver.quit(); + } + +} diff --git a/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/login/LoginFormValidationTest.java b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/login/LoginFormValidationTest.java index b727101e..9b478a8c 100644 --- a/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/login/LoginFormValidationTest.java +++ b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/login/LoginFormValidationTest.java @@ -53,25 +53,6 @@ public class LoginFormValidationTest extends IOTIntegrationUIBaseTestCase { clearForm(); } - @Test(description = "Test for empty login form submission") - public void emptyLoginFormTest() throws Exception { - userNameField.sendKeys(""); - passwordField.sendKeys(""); - loginButton.click(); - - WebElement alertUserName = driver.findElement(By.id( - uiElementMapper.getElement("iot.user.login.username.error"))); - WebElement alertPassword = driver.findElement(By.id( - uiElementMapper.getElement("iot.user.login.password.error"))); - - 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(), Constants.User.Login.USER_NAME_ERROR); - Assert.assertEquals(alertPassword.getText(), Constants.User.Login.PASSWORD_ERROR); - - } - @Test(description = "Test for incorrect username") public void incorrectUserNameTest() throws Exception { clearForm(); @@ -103,22 +84,6 @@ public class LoginFormValidationTest extends IOTIntegrationUIBaseTestCase { } } - - @Test(description = "Test for short password") - public void shortPasswordTest() throws Exception { - clearForm(); - userNameField.sendKeys(automationContext.getSuperTenant().getTenantAdmin().getUserName()); - passwordField.sendKeys(Constants.User.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(), Constants.User.Login.SHORT_PASSWORD_ERROR); - } else { - Assert.assertTrue(false, Constants.ALERT_NOT_PRESENT); - } - } - public void clearForm() throws Exception { driver.get(getWebAppURL() + Constants.IOT_LOGIN_PATH); uiElementMapper = UIElementMapper.getInstance(); diff --git a/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/login/LoginTest.java b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/login/LoginTest.java index 4bdf52ed..ba219038 100644 --- a/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/login/LoginTest.java +++ b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/login/LoginTest.java @@ -45,7 +45,7 @@ public class LoginTest extends IOTIntegrationUIBaseTestCase { driver.get(getWebAppURL() + Constants.IOT_LOGIN_PATH); } - @Test(description = "Verify login to IOT server dashboard") + @Test(description = "Verify logins to IOT server dashboard") public void testAdminLogin() throws IOException, XPathExpressionException { LoginPage loginPage = new LoginPage(driver); IOTAdminDashboard dashboard = loginPage.loginAsAdmin( diff --git a/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/user/RegistrationFormValidationTest.java b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/user/RegistrationFormValidationTest.java index 60af0de3..ec088dd4 100644 --- a/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/user/RegistrationFormValidationTest.java +++ b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/user/RegistrationFormValidationTest.java @@ -61,80 +61,50 @@ public class RegistrationFormValidationTest extends IOTIntegrationUIBaseTestCase registerPage.validateForm("", "", "", "", "", ""); WebElement alertFirstName = driver.findElement(By.id( - uiElementMapper.getElement("iot.user.register.firstname.error"))); - WebElement alertLastName = driver.findElement(By.id( - uiElementMapper.getElement("iot.user.register.lastname.error"))); - WebElement alertEmail = driver.findElement(By.id( - uiElementMapper.getElement("iot.user.register.email.error"))); - WebElement alertUserName = driver.findElement(By.id( - uiElementMapper.getElement("iot.user.register.username.error"))); - WebElement alertPassword = driver.findElement(By.id( - uiElementMapper.getElement("iot.user.register.password.error"))); - WebElement alertConfPassword = driver.findElement(By.id( - uiElementMapper.getElement("iot.user.register.confirmPassword.error"))); + uiElementMapper.getElement("iot.user.register.form.error"))); if (!alertFirstName.isDisplayed()) { Assert.assertTrue(false, "Alert for first name is not displayed"); } - if (!alertLastName.isDisplayed()) { - Assert.assertTrue(false, "Alert for last name is not displayed"); - } - if (!alertEmail.isDisplayed()) { - Assert.assertTrue(false, "Alert for email is not displayed"); - } - if (!alertUserName.isDisplayed()) { - Assert.assertTrue(false, "Alert for user name is not displayed"); - } - if (!alertPassword.isDisplayed()) { - Assert.assertTrue(false, "Alert for password is not displayed"); - } - if (!alertConfPassword.isDisplayed()) { - Assert.assertTrue(false, "Alert for confirm password is not displayed"); - } - Assert.assertEquals(alertFirstName.getText(), "Firstname is a required field. This cannot be empty."); - Assert.assertEquals(alertLastName.getText(), "Lastname is a required field. This cannot be empty."); - Assert.assertEquals(alertEmail.getText(), "Email is a required field. This cannot be empty."); - Assert.assertEquals(alertUserName.getText(), "Username is a required field. This cannot be empty."); - Assert.assertEquals(alertPassword.getText(), "Please enter a user login password"); - Assert.assertEquals(alertConfPassword.getText(), "Please enter a user login password"); + Assert.assertEquals(alertFirstName.getText(), "Firstname is a required field. It cannot be empty."); } @Test(description = "Test for non matching passwords") public void nonMatchingPasswordTest() { registerPage.validateForm("user", "user", "user@wso2.com", "user1", "password", "Password"); WebElement alertConfPassword = driver.findElement(By.id( - uiElementMapper.getElement("iot.user.register.confirmPassword.error"))); + uiElementMapper.getElement("iot.user.register.form.error"))); if (!alertConfPassword.isDisplayed()) { Assert.assertTrue(false, "Alert for confirm password is not displayed"); } - Assert.assertEquals(alertConfPassword.getText(), "Please enter the same password as above"); + Assert.assertEquals(alertConfPassword.getText(), "Please enter the same password for confirmation."); } @Test(description = "Test for email") public void incorrectEmailTest() { registerPage.validateForm("user", "user", "user123", "user1", "password", "password"); WebElement alertEmail = driver.findElement(By.id( - uiElementMapper.getElement("iot.user.register.email.error"))); + uiElementMapper.getElement("iot.user.register.form.error"))); if (!alertEmail.isDisplayed()) { Assert.assertTrue(false, "Alert for email is not displayed"); } - Assert.assertEquals(alertEmail.getText(), "Email is not valid. Please enter a correct email address."); + Assert.assertEquals(alertEmail.getText(), "Provided email is invalid."); } @Test(description = "Test for password length") public void passwordLengthTest() { registerPage.validateForm("user", "user", "user@wso2.com", "user1", "pass", "pass"); WebElement alertPassword = driver.findElement(By.id( - uiElementMapper.getElement("iot.user.register.password.error"))); + uiElementMapper.getElement("iot.user.register.form.error"))); if (!alertPassword.isDisplayed()) { Assert.assertTrue(false, "Alert for password is not displayed"); } - Assert.assertEquals(alertPassword.getText(), "Password should be between 5 and 30 characters."); + Assert.assertEquals(alertPassword.getText(), "Password is a required field. It cannot be empty."); } @AfterClass(alwaysRun = true) diff --git a/modules/integration/tests-iot-web-ui/src/test/resources/testng.xml b/modules/integration/tests-iot-web-ui/src/test/resources/testng.xml index 6df79fcd..5ff41446 100644 --- a/modules/integration/tests-iot-web-ui/src/test/resources/testng.xml +++ b/modules/integration/tests-iot-web-ui/src/test/resources/testng.xml @@ -26,13 +26,14 @@ + - + - - - + + +